Previous 15994 Revisions Next

r4428 Saturday 21st March, 2009 at 06:43:50 UTC by Firewave
Removed obsolete files
[src/emu]sndintrf.c
[src/emu/sound]custom.c custom.h
[src/emu/video]cdp1869.c
[src/mame/drivers]brasil.c fruit.c rcasino.c steaser.c

src/mame/drivers/rcasino.c
r4427r4428
1/*
2"Royal Casino"
3
4    ----------------------------------------
5    Casino Royal by Dyna Electronics CO. LTD
6    ----------------------------------------
7
8    Location    Device      File ID     Checksum
9    --------------------------------------------
10    18B          2764        RI-W1        C62D
11    16B          2764        RI-W2        AC85
12    15B          2732        RI-W3        70B7
13    11B          2732        RI-W4        0C21
14    9B           2764        RI-W5        EB59
15    8B           2764        RI-W6        C934
16    6B           2732        RI-W7        4130
17    9E         82S123      PROM1.BPR      0F29
18    8E         82S123      PROM2.BPR      0EE5
19
20    Notes: PCB No. D-2608208A1-2
21
22    Brief hardware overview
23    -----------------------
24
25    Main processor  - Z80
26    Sound           - AY-3-8910
27
28    ---
29
30    Driver by Curt Coder
31
32TODO:
33
34Get correct data for hopper on and lockout.
35*/
36
37#include "driver.h"
38#include "cpu/z80/z80.h"
39#include "sound/ay8910.h"
40
41static tilemap *bg_tilemap;
42static int pulse;
43static int hopper;
44static PALETTE_INIT( rcasino )
45{
46   int i;
47
48   for (i = 0; i < machine->config->total_colors; i++)
49   {
50      int bit0, bit1, bit2, r, g, b;
51
52      // red component
53
54      bit0 = (*color_prom >> 7) & 0x01;
55      bit1 = (*color_prom >> 6) & 0x01;
56      bit2 = (*color_prom >> 5) & 0x01;
57
58      r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
59
60      // green component
61
62      bit0 = (*color_prom >> 4) & 0x01;
63      bit1 = (*color_prom >> 3) & 0x01;
64      bit2 = (*color_prom >> 2) & 0x01;
65
66      g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
67
68      // blue component
69
70      bit0 = 0;
71      bit1 = (*color_prom >> 1) & 0x01;
72      bit2 = (*color_prom >> 0) & 0x01;
73
74      b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
75
76      palette_set_color(machine, i, MAKE_RGB(r, g, b));
77
78      color_prom++;
79   }
80}
81
82static WRITE8_HANDLER( rcasino_videoram_w )
83{
84   videoram[offset] = data;
85   tilemap_mark_tile_dirty(bg_tilemap, offset);
86}
87
88static WRITE8_HANDLER( rcasino_colorram_w )
89{
90   colorram[offset] = data;
91   tilemap_mark_tile_dirty(bg_tilemap, offset);
92}
93
94static TILE_GET_INFO( get_bg_tile_info )
95{
96   int attr = colorram[tile_index];
97   int bank = (attr & 0x40) >> 6;
98   int code = videoram[tile_index] + ((attr & 0x30) << 4);
99   int color = attr & 0x0f;
100
101   SET_TILE_INFO(bank, code, color, 0);
102}
103
104static VIDEO_START(rcasino)
105{
106   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows,
107      8, 8, 32, 32);
108}
109
110static VIDEO_UPDATE(rcasino)
111{
112   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
113   return 0;
114}
115
116static WRITE8_HANDLER( rcasino_port_10_w )
117{
118//  popmessage("port 10 data %u", data);
119   // write several values when the wheels are spinning
120}
121
122static WRITE8_HANDLER( rcasino_port_11_w )
123{
124   /*
125        write 0 when "P1 FlipFlop" (start1) is pressed
126        write 1 when "P2 FlipFlop" (start2) is pressed
127        write 2 when in "Super Conti" game
128
129        In royalmah.c games this is an input port selector, but
130        there are only 2 input ports in this game and this write
131        seems to have no effect
132    */
133}
134
135static WRITE8_HANDLER( rcasino_lamp_w )
136{
137   // button lamps
138   set_led_status(0, data & 0x01);
139   set_led_status(1, data & 0x02);
140   set_led_status(2, data & 0x04);
141   set_led_status(3, data & 0x08);
142   set_led_status(4, data & 0x10);
143}
144
145static WRITE8_HANDLER( rcasino_coin_counter_w )
146{
147   // coin counter
148   coin_counter_w(0, data & 0x01);
149
150   // payout counter
151   coin_counter_w(1, data & 0x04);
152
153   // activate hopper
154   //hopper = data & 0x08;
155
156   // write 0x80 if payout fails and "call dealer" appears on screen, is it a coin lockout?
157   //coin_lockout_w(0, data & 0x80);
158//Probably, most of these systems have some protection to stop clueless people from clogging up a broken hopper.
159}
160
161static READ8_HANDLER( rcasino_port_11_r )
162{
163   if (hopper)
164   {
165       if (pulse)
166       pulse = 0;
167       else pulse = 0x04;
168   }
169   return input_port_read(space->machine, "IN1") + pulse;
170}
171
172static ADDRESS_MAP_START( rcasino_map, ADDRESS_SPACE_PROGRAM, 8 )
173   AM_RANGE(0x0000, 0x4fff) AM_ROM
174   AM_RANGE(0xe000, 0xe7ff) AM_RAM
175   AM_RANGE(0xf000, 0xf3ff) AM_RAM_WRITE(rcasino_videoram_w) AM_BASE(&videoram)
176   AM_RANGE(0xf800, 0xfbff) AM_RAM_WRITE(rcasino_colorram_w) AM_BASE(&colorram)
177ADDRESS_MAP_END
178
179static ADDRESS_MAP_START( rcasino_io_map, ADDRESS_SPACE_IO, 8 )
180   ADDRESS_MAP_GLOBAL_MASK(0xff)
181   AM_RANGE(0x01, 0x01) AM_DEVREAD("ay", ay8910_r)
182   AM_RANGE(0x02, 0x03) AM_DEVWRITE("ay", ay8910_data_address_w)
183   AM_RANGE(0x10, 0x10) AM_READ_PORT("IN0") AM_WRITE(rcasino_port_10_w)
184//  AM_RANGE(0x11, 0x11) AM_READ_PORT("IN1") AM_WRITE(rcasino_port_11_w)
185   AM_RANGE(0x11, 0x11) AM_READWRITE(rcasino_port_11_r, rcasino_port_11_w)
186   AM_RANGE(0x12, 0x12) AM_WRITE(rcasino_lamp_w)
187   AM_RANGE(0x13, 0x13) AM_WRITE(rcasino_coin_counter_w)
188ADDRESS_MAP_END
189
190static INPUT_PORTS_START( rcasino )
191   PORT_START("IN0")
192   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(KEYCODE_A)   // SW1
193   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(KEYCODE_S)   // SW2
194   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_D)   // SW3
195   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_F)   // SW4
196   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_G)   // SW5
197   PORT_BIT( 0xe0, IP_ACTIVE_LOW, IPT_UNUSED )
198
199   PORT_START("IN1")
200   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )                           // Coin
201   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_NAME("Note Acceptor")// Note
202   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_OTHER ) PORT_CODE(KEYCODE_4) PORT_NAME("Payout")// Pay Out
203   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE2 )                        // Hopper Micro
204   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 )                          // 1P FlipFlop
205   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 )                          // 2P FlipFlop
206   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
207
208   PORT_START("DSW1")
209   PORT_DIPNAME( 0x01, 0x01, "Poker available?" )
210   PORT_DIPSETTING(    0x01, DEF_STR( No ) )
211   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
212   PORT_DIPNAME( 0x02, 0x02, "Black Jack available?")
213   PORT_DIPSETTING(    0x02, DEF_STR( No ) )
214   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
215   PORT_DIPNAME( 0x04, 0x04, "Hi and Low available?" )
216   PORT_DIPSETTING(    0x04, DEF_STR( No ) )
217   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
218   PORT_DIPNAME( 0x08, 0x08, "Five Line (Slot) available?")
219   PORT_DIPSETTING(    0x08, DEF_STR( No ) )
220   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
221   PORT_DIPNAME( 0x10, 0x10, "Super Continental available?")
222   PORT_DIPSETTING(    0x10, DEF_STR( No ) )
223   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
224   PORT_DIPNAME( 0x20, 0x20, "Rule Change (BlackJack, even)" )
225   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
226   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
227   PORT_DIPNAME( 0x40, 0x40, "Rule Change (Poker, Royal Flush)" )
228   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
229   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
230   PORT_DIPNAME( 0x80, 0x80, "Rule Change (Poker, Jack or Better)")
231   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
232   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
233
234   PORT_START("DSW2")
235   PORT_DIPNAME( 0x01, 0x01, "Enable Hopper Payout" )   // enables Payout button
236   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
237   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
238   PORT_DIPNAME( 0x02, 0x02, "Enable Hopper Win Payout")   // enables Payout button
239   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
240   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
241   PORT_DIPNAME( 0x04, 0x04, "Hi Lo, Royal Flush" )
242   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
243   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
244   PORT_DIPNAME( 0x08, 0x08, "Game Bet")
245   PORT_DIPSETTING(    0x08, "Normal Game")
246   PORT_DIPSETTING(    0x00, "Double Game")
247   PORT_DIPNAME( 0x10, 0x10, "Always Off" )
248   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
249   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
250   PORT_DIPNAME( 0x20, 0x20, "Always Off")
251   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
252   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
253   PORT_SERVICE( 0x40, IP_ACTIVE_LOW )
254   PORT_DIPNAME( 0x80, 0x80, "Analyzer" )
255   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
256   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
257INPUT_PORTS_END
258
259static const gfx_layout charlayout =
260{
261   8, 8,
262   RGN_FRAC(1,2),
263   2,
264   { 0, 0x2000*8 },
265   { 7, 6, 5, 4, 3, 2, 1, 0 },
266   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
267   8*8
268};
269
270static const gfx_layout charlayout2 =
271{
272   8, 8,
273   RGN_FRAC(1,2),
274   2,
275   { 0, 0x1000*8 },
276   { 7, 6, 5, 4, 3, 2, 1, 0 },
277   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
278   8*8
279};
280
281static GFXDECODE_START( rcasino )
282   GFXDECODE_ENTRY( "gfx1", 0x0000, charlayout,  0, 16 )
283   GFXDECODE_ENTRY( "gfx2", 0x0000, charlayout2, 0, 16 )
284GFXDECODE_END
285
286static const ay8910_interface ay8910_config =
287{
288   AY8910_LEGACY_OUTPUT,
289   AY8910_DEFAULT_LOADS,
290   DEVCB_INPUT_PORT("DSW1"),
291   DEVCB_INPUT_PORT("DSW2"),
292   DEVCB_NULL,
293   DEVCB_NULL
294};
295
296static MACHINE_DRIVER_START( rcasino )
297   // basic machine hardware
298   MDRV_CPU_ADD("maincpu", Z80, 8000000/2)   // ???
299   MDRV_CPU_PROGRAM_MAP(rcasino_map, 0)
300   MDRV_CPU_IO_MAP(rcasino_io_map, 0)
301   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
302
303   // video hardware
304
305   MDRV_SCREEN_ADD("screen", RASTER)
306   MDRV_SCREEN_REFRESH_RATE(60)
307   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
308   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
309   MDRV_SCREEN_SIZE(32*8, 32*8)
310   MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)
311
312   MDRV_GFXDECODE(rcasino)
313   MDRV_PALETTE_LENGTH(64)
314
315   MDRV_PALETTE_INIT(rcasino)
316   MDRV_VIDEO_START(rcasino)
317   MDRV_VIDEO_UPDATE(rcasino)
318
319   // sound hardware
320   MDRV_SPEAKER_STANDARD_MONO("mono")
321
322   MDRV_SOUND_ADD("ay", AY8910, 18432000/12)
323   MDRV_SOUND_CONFIG(ay8910_config)
324   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
325
326MACHINE_DRIVER_END
327
328ROM_START( rcasino )
329   ROM_REGION( 0x10000, "maincpu", 0 )
330   ROM_LOAD( "ri-w1.18b", 0x0000, 0x2000, CRC(ed105d69) SHA1(951697e1050f72967f0710155aa8ff72db73fce1) )
331   ROM_LOAD( "ri-w2.16b", 0x2000, 0x2000, CRC(a1a80b33) SHA1(2f969713cae288de1985d7baa70cad50c4148970) )
332   ROM_LOAD( "ri-w3.15b", 0x4000, 0x1000, CRC(acf77a36) SHA1(599470e461a261130e942d174051648459f37a37) )
333
334   ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE )
335   ROM_LOAD( "ri-w5.9b",  0x0000, 0x2000, CRC(81d20577) SHA1(50a1e0231400c106539ffa78deb3e0e6c8afc3f5) )
336   ROM_LOAD( "ri-w6.8b",  0x2000, 0x2000, CRC(b2dd4e1e) SHA1(323dcfb26653c17951db65ce2ced3325d35489e4) )
337
338   ROM_REGION( 0x2000, "gfx2", ROMREGION_DISPOSE )
339   ROM_LOAD( "ri-w4.11b", 0x0000, 0x1000, CRC(7ca0e78c) SHA1(163cfd1f76ecbd14219146963d1abc4c09c0ac8c) )
340   ROM_LOAD( "ri-w7.6b",  0x1000, 0x1000, CRC(8e0d3b9c) SHA1(c5211d834b0db488839a5c53d00435a0b59cd4ca) )
341
342   ROM_REGION( 0x40, "proms", 0 )
343   ROM_LOAD( "prom1.9e",  0x0000, 0x0020, CRC(93312432) SHA1(3c7abc165e6bc7e0c56ca97d89b0b5e06323b82e) )
344   ROM_LOAD( "prom2.8e",  0x0020, 0x0020, CRC(2b5c7826) SHA1(c0de392aebd6982e5846c12aeb2e871358be60d7) )
345ROM_END
346
347GAME( 1984, rcasino, 0, rcasino, rcasino, 0, ROT270, "Dyna Electronics", "Royal Casino", GAME_IMPERFECT_COLORS )
src/mame/drivers/brasil.c
r4427r4428
1/*************************************************************************************************
2
3New Magic Card (c) 19?? New High Video?
4
5driver by David Haywood & Angelo Salese
6
7Notes:
8-"New Magic Card" is almost certainly an earlier revision of the "Bra$il / Fashion" sets,
9 with colour mapped bitmaps instead of RGB565 etc..For sure is "pre-2002" because in-game displays
10 "Maximum credit = 10.000 Italian Lire" on title screen.
11
12TODO:
13-understand how the blitter deletes some background parts in Bra$il / Fashion and understand how
14 the status registers really works;
15-inputs are grossly mapped;
16-add the sound chip into MAME (OkiM6376),it's an alternative version of the more common OkiM6295.
17-NVRAM emulation?
18-Hook-up the V-Blank bit (check if it is really a V-Blank etc.)
19-I don't really know if the manufacturer is really New High Video,I've got that name from f205v.
20-Why Bra$il harass the player with that "memory sub-game"? Broken logic or BTANB?
21
22*************************************************************************************************/
23
24#include "driver.h"
25#include "cpu/nec/nec.h"
26#include "cpu/i86/i86.h"
27#include "sound/okim6376.h"
28#include "fashion.lh"
29
30static UINT16 *blit_ram;
31
32static VIDEO_START(brasil)
33{
34
35}
36
37static VIDEO_UPDATE(brasil)
38{
39   int x,y,count;
40
41   count = (0/2);
42
43   for(y=0;y<300;y++)
44   {
45      for(x=0;x<400;x++)
46      {
47         UINT32 color;
48         UINT32 b;
49         UINT32 g;
50         UINT32 r;
51
52         color = (blit_ram[count]) & 0xffff;
53
54         b = (color & 0x001f) << 3;
55         g = (color & 0x07e0) >> 3;
56         r = (color & 0xf800) >> 8;
57         if(x<video_screen_get_visible_area(screen)->max_x && y<video_screen_get_visible_area(screen)->max_y)
58            *BITMAP_ADDR32(bitmap, y, x) = b | (g<<8) | (r<<16);
59
60         count++;
61      }
62   }
63
64   return 0;
65}
66
67static VIDEO_UPDATE(vidpokr2)
68{
69   int x,y,count;
70
71   count = (0/2);
72
73   for(y=0;y<224;y++)
74   {
75      for(x=0;x<160;x++)
76      {
77         UINT32 color;
78
79         color = ((blit_ram[count]) & 0x00ff)>>0;
80
81         if((x*2)<video_screen_get_visible_area(screen)->max_x && ((y)+0)<video_screen_get_visible_area(screen)->max_y)
82            *BITMAP_ADDR32(bitmap, y, (x*2)+0) = screen->machine->pens[color];
83
84         color = ((blit_ram[count]) & 0xff00)>>8;
85
86         if(((x*2)+1)<video_screen_get_visible_area(screen)->max_x && ((y)+0)<video_screen_get_visible_area(screen)->max_y)
87            *BITMAP_ADDR32(bitmap, y, (x*2)+1) = screen->machine->pens[color];
88
89         count++;
90      }
91   }
92
93   return 0;
94}
95
96/*Some sort of status registers,probably blitter/vblank related.*/
97static UINT16 unk_latch;
98static UINT16 vblank_bit;
99
100/*Bra$il*/
101static READ16_HANDLER( blit_status_r )
102{
103   switch(offset*2)
104   {
105      case 0:
106      vblank_bit^=0x10;
107
108      return 3 | vblank_bit;
109      case 2: return (unk_latch & 3); //and 0x3f
110   }
111
112   return 0;
113}
114
115/*bankaddress might be incorrect.*/
116static WRITE16_HANDLER( blit_status_w )
117{
118   static UINT32 bankaddress;
119   UINT8 *ROM = memory_region(space->machine, "user1");
120
121   switch(data & 3) //data & 7?
122   {
123      case 0: unk_latch = 1; break;
124      case 1: unk_latch = 0; break;
125      case 2: unk_latch = 2; break;
126   }
127
128   bankaddress = (data & 0x07) * 0x40000;
129
130   memory_set_bankptr(space->machine, 1, &ROM[bankaddress]);
131
132//  popmessage("%04x",data);
133}
134
135/* New Magic Card */
136static READ16_HANDLER( vidpokr2_blit_status_r )
137{
138   switch(offset*2)
139   {
140      case 0: return 2; //and $7
141      case 2: return 2; //and $7
142   }
143   return 0;
144}
145
146/*bankaddress might be incorrect.*/
147static WRITE16_HANDLER( vidpokr2_blit_status_w )
148{
149   static UINT32 bankaddress;
150   UINT8 *ROM = memory_region(space->machine, "user1");
151
152   bankaddress = (data & 0x07) * 0x40000;
153
154   memory_set_bankptr(space->machine, 1, &ROM[bankaddress]);
155
156//  popmessage("%04x",data);
157}
158
159static WRITE16_HANDLER( paletteram_io_w )
160{
161   static int pal_offs,r,g,b,internal_pal_offs;
162
163   switch(offset*2)
164   {
165      case 0:
166         pal_offs = 0;
167         break;
168      case 2:
169         internal_pal_offs = 0;
170         break;
171      case 4:
172         switch(internal_pal_offs)
173         {
174            case 0:
175               r = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
176               internal_pal_offs++;
177               break;
178            case 1:
179               g = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
180               internal_pal_offs++;
181               break;
182            case 2:
183               b = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
184               palette_set_color(space->machine, pal_offs, MAKE_RGB(r, g, b));
185               internal_pal_offs = 0;
186               pal_offs++;
187               break;
188         }
189
190         break;
191   }
192}
193
194/*There's a reset button located there too.*/
195static READ16_HANDLER( vidpokr2_vblank_r )
196{
197   return vblank_bit; //0x80
198}
199
200static WRITE16_HANDLER( vidpokr2_vblank_w )
201{
202   vblank_bit = data;
203}
204
205
206static UINT16 t1,t3;
207
208static READ16_HANDLER( read1_r )
209{
210//  return mame_rand(space->machine);
211   return input_port_read(space->machine, "IN0");
212}
213
214static READ16_HANDLER( read2_r )
215{
216//  return mame_rand(space->machine);
217   return input_port_read(space->machine, "IN1");
218}
219
220static READ16_HANDLER( read3_r )
221{
222//  return mame_rand(space->machine);
223   return input_port_read(space->machine, "IN2");
224}
225
226static WRITE16_HANDLER( write1_w )
227{
228   t1 = data;
229/*
230    - Lbits -
231    7654 3210
232    =========
233    ---- ---x  Hold1 lamp.
234    ---- --x-  Hold2 lamp.
235    ---- -x--  Hold3 lamp.
236    ---- x---  Hold4 lamp.
237    ---x ----  Hold5 lamp.
238    --x- ----  Start lamp.
239*/
240   output_set_lamp_value(1, (data & 1));         /* Lamp 1 - HOLD 1 */
241   output_set_lamp_value(2, (data >> 1) & 1);      /* Lamp 2 - HOLD 2 */
242   output_set_lamp_value(3, (data >> 2) & 1);      /* Lamp 3 - HOLD 3 */
243   output_set_lamp_value(4, (data >> 3) & 1);      /* Lamp 4 - HOLD 4 */
244   output_set_lamp_value(5, (data >> 4) & 1);      /* Lamp 5 - HOLD 5 */
245   output_set_lamp_value(6, (data >> 5) & 1);      /* Lamp 6 - START  */
246
247//  popmessage("%04x %04x",t1,t3);
248}
249
250static WRITE16_HANDLER( write2_w )
251{
252   static int i;
253
254//  popmessage("%04x",data);
255
256   for(i=0;i<4;i++)
257   {
258      coin_counter_w(i,data & 0x20);
259      coin_lockout_w(i,~data & 0x08);
260   }
261}
262
263/*Different coin-lockout in this one*/
264static WRITE16_HANDLER( fashion_write2_w )
265{
266   static int i;
267
268//  popmessage("%04x",data);
269
270   for(i=0;i<4;i++)
271   {
272      coin_counter_w(i,data & 0x20);
273      coin_lockout_w(i,~data & 0x01);
274   }
275}
276
277static WRITE16_HANDLER( write3_w )
278{
279   if (t3 != data) {
280      t3 = data;
281      okim6376_data_0_lsb_w(space, 0, t3, mem_mask);
282      okim6376_data_0_lsb_w(space, 0, (1 << 4), mem_mask);
283   }
284//  popmessage("%04x %04x",t1,t3);
285}
286
287static ADDRESS_MAP_START( brasil_map, ADDRESS_SPACE_PROGRAM, 16 )
288   AM_RANGE(0x00000, 0x0ffff) AM_RAM /*irq vector area + work ram*/
289   AM_RANGE(0x40000, 0x7ffff) AM_RAM AM_BASE(&blit_ram) /*blitter ram*/
290   AM_RANGE(0x80000, 0xbffff) AM_ROMBANK(1)
291   AM_RANGE(0xc0000, 0xfffff) AM_ROM AM_REGION("boot_prg",0)
292ADDRESS_MAP_END
293
294static ADDRESS_MAP_START( brasil_io, ADDRESS_SPACE_IO, 16 )
295   AM_RANGE(0x0030, 0x0033) AM_READ( blit_status_r )
296   AM_RANGE(0x0030, 0x0031) AM_WRITE( blit_status_w )
297   AM_RANGE(0x0000, 0x0001) AM_WRITE( write1_w ) // lamps
298   AM_RANGE(0x0002, 0x0003) AM_WRITE( write2_w ) // coin counter & coin lockout
299    AM_RANGE(0x0006, 0x0007) AM_WRITE( write3_w ) // sound chip routes here
300    AM_RANGE(0x0008, 0x0009) AM_READ( read1_r )
301   AM_RANGE(0x000a, 0x000b) AM_READ( read2_r )
302   AM_RANGE(0x000e, 0x000f) AM_READ( read3_r )
303//  AM_RANGE(0x000e, 0x000f) AM_WRITE
304//  AM_RANGE(0xffa2, 0xffa3) AM_WRITE
305ADDRESS_MAP_END
306
307static ADDRESS_MAP_START( vidpokr2_map, ADDRESS_SPACE_PROGRAM, 16 )
308   AM_RANGE(0x00000, 0x0ffff) AM_RAM /*irq vector area + work ram*/
309   AM_RANGE(0x40000, 0x7ffff) AM_RAM AM_BASE(&blit_ram) /*blitter ram*/
310   AM_RANGE(0x80000, 0xbffff) AM_ROMBANK(1)
311   AM_RANGE(0xc0000, 0xfffff) AM_ROM AM_REGION("boot_prg",0)
312ADDRESS_MAP_END
313
314static ADDRESS_MAP_START( vidpokr2_io, ADDRESS_SPACE_IO, 16 )
315   AM_RANGE(0x0030, 0x0033) AM_READ( vidpokr2_blit_status_r )
316   AM_RANGE(0x0030, 0x0031) AM_WRITE( vidpokr2_blit_status_w )
317   AM_RANGE(0x0000, 0x0001) AM_WRITE( write1_w ) // lamps
318   AM_RANGE(0x0002, 0x0003) AM_WRITE( write2_w ) // coin counter & coin lockout
319   AM_RANGE(0x0004, 0x0005) AM_WRITE( vidpokr2_vblank_w )
320    AM_RANGE(0x0006, 0x0007) AM_WRITE( write3_w ) // sound chip routes here
321    AM_RANGE(0x0008, 0x0009) AM_READ( read1_r )
322   AM_RANGE(0x000a, 0x000b) AM_READ( read2_r )
323   AM_RANGE(0x000c, 0x000d) AM_READ( vidpokr2_vblank_r )
324   AM_RANGE(0x000e, 0x000f) AM_READ( read3_r )
325   AM_RANGE(0x0010, 0x0015) AM_WRITE( paletteram_io_w )
326//  AM_RANGE(0x000e, 0x000f) AM_WRITE
327//  AM_RANGE(0xffa2, 0xffa3) AM_WRITE
328ADDRESS_MAP_END
329
330static INPUT_PORTS_START( brasil )
331   PORT_START("IN0")
332   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("Take Button") PORT_CODE(KEYCODE_A)
333   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_START1 )
334   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Hold 2") PORT_CODE(KEYCODE_X)
335   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Hold 4") PORT_CODE(KEYCODE_V)
336   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Risk Button") PORT_CODE(KEYCODE_S)
337   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Hold 3") PORT_CODE(KEYCODE_C)
338   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Hold 5") PORT_CODE(KEYCODE_B)
339   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Hold 1") PORT_CODE(KEYCODE_Z)
340   PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Unknown ) )
341   PORT_DIPSETTING(      0x0100, DEF_STR( Off ) )
342   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
343   PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Unknown ) )
344   PORT_DIPSETTING(      0x0200, DEF_STR( Off ) )
345   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
346   PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Unknown ) )
347   PORT_DIPSETTING(      0x0400, DEF_STR( Off ) )
348   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
349   PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unknown ) )
350   PORT_DIPSETTING(      0x0800, DEF_STR( Off ) )
351   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
352   PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
353   PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
354   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
355   PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )
356   PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
357   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
358   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
359   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
360   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
361   PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unknown ) )
362   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
363   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
364   PORT_START("IN1")
365   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
366   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
367   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_COIN3 )
368   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_COIN4 ) // note
369   PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) ) //ticket
370   PORT_DIPSETTING(      0x0010, DEF_STR( Off ) )
371   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
372   PORT_SERVICE( 0x0020, IP_ACTIVE_LOW )
373   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) ) //hopper
374   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
375   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
376   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )
377   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
378   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
379   PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Unknown ) )
380   PORT_DIPSETTING(      0x0100, DEF_STR( Off ) )
381   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
382   PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Unknown ) )
383   PORT_DIPSETTING(      0x0200, DEF_STR( Off ) )
384   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
385   PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Unknown ) )
386   PORT_DIPSETTING(      0x0400, DEF_STR( Off ) )
387   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
388   PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unknown ) )
389   PORT_DIPSETTING(      0x0800, DEF_STR( Off ) )
390   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
391   PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
392   PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
393   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
394   PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )
395   PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
396   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
397   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
398   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
399   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
400   PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unknown ) )
401   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
402   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
403   PORT_START("IN2")
404   PORT_DIPNAME( 0x0001, 0x0001, "IN2" )
405   PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
406   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
407   PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) )
408   PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
409   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
410   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )
411   PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
412   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
413   PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )
414   PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
415   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
416   PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) )
417   PORT_DIPSETTING(      0x0010, DEF_STR( Off ) )
418   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
419   PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) )
420   PORT_DIPSETTING(      0x0020, DEF_STR( Off ) )
421   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
422   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
423   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
424   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
425   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )
426   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
427   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
428   PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Unknown ) )
429   PORT_DIPSETTING(      0x0100, DEF_STR( Off ) )
430   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
431   PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Unknown ) )
432   PORT_DIPSETTING(      0x0200, DEF_STR( Off ) )
433   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
434   PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Unknown ) )
435   PORT_DIPSETTING(      0x0400, DEF_STR( Off ) )
436   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
437   PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unknown ) )
438   PORT_DIPSETTING(      0x0800, DEF_STR( Off ) )
439   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
440   PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
441   PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
442   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
443   PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )
444   PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
445   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
446   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
447   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
448   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
449   PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unknown ) )
450   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
451   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
452INPUT_PORTS_END
453
454/*Slightly different inputs*/
455static INPUT_PORTS_START( fashion )
456   PORT_START("IN0")
457   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("Take Button") PORT_CODE(KEYCODE_A)
458   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_START1 )
459   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Hold 2") PORT_CODE(KEYCODE_X)
460   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Hold 4") PORT_CODE(KEYCODE_V)
461   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Stock 2") PORT_CODE(KEYCODE_S)
462   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Hold 3 / Risk Button") PORT_CODE(KEYCODE_C)
463   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Hold 5") PORT_CODE(KEYCODE_B)
464   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Hold 1") PORT_CODE(KEYCODE_Z)
465   PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Unknown ) )
466   PORT_DIPSETTING(      0x0100, DEF_STR( Off ) )
467   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
468   PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Unknown ) )
469   PORT_DIPSETTING(      0x0200, DEF_STR( Off ) )
470   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
471   PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Unknown ) )
472   PORT_DIPSETTING(      0x0400, DEF_STR( Off ) )
473   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
474   PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unknown ) )
475   PORT_DIPSETTING(      0x0800, DEF_STR( Off ) )
476   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
477   PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
478   PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
479   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
480   PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )
481   PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
482   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
483   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
484   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
485   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
486   PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unknown ) )
487   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
488   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
489   PORT_START("IN1")
490   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
491   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
492   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_COIN3 )
493   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_COIN4 ) PORT_NAME("Stock 3 / Note") PORT_CODE(KEYCODE_8)
494   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON9 ) PORT_NAME("Stock 1 / Ticket") PORT_CODE(KEYCODE_Q)
495   PORT_SERVICE( 0x0020, IP_ACTIVE_LOW )
496   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON10 ) PORT_NAME("Stock 5") PORT_CODE(KEYCODE_T)
497   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON11 ) PORT_NAME("Stock 4") PORT_CODE(KEYCODE_R)
498   PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Unknown ) )
499   PORT_DIPSETTING(      0x0100, DEF_STR( Off ) )
500   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
501   PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Unknown ) )
502   PORT_DIPSETTING(      0x0200, DEF_STR( Off ) )
503   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
504   PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Unknown ) )
505   PORT_DIPSETTING(      0x0400, DEF_STR( Off ) )
506   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
507   PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unknown ) )
508   PORT_DIPSETTING(      0x0800, DEF_STR( Off ) )
509   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
510   PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
511   PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
512   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
513   PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )
514   PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
515   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
516   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
517   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
518   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
519   PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unknown ) )
520   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
521   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
522   PORT_START("IN2")
523   PORT_DIPNAME( 0x0001, 0x0001, "IN2" )
524   PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
525   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
526   PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) )
527   PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
528   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
529   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )
530   PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
531   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
532   PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )
533   PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
534   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
535   PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) )
536   PORT_DIPSETTING(      0x0010, DEF_STR( Off ) )
537   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
538   PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) )
539   PORT_DIPSETTING(      0x0020, DEF_STR( Off ) )
540   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
541   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
542   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
543   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
544   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )
545   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
546   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
547   PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Unknown ) )
548   PORT_DIPSETTING(      0x0100, DEF_STR( Off ) )
549   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
550   PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Unknown ) )
551   PORT_DIPSETTING(      0x0200, DEF_STR( Off ) )
552   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
553   PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Unknown ) )
554   PORT_DIPSETTING(      0x0400, DEF_STR( Off ) )
555   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
556   PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unknown ) )
557   PORT_DIPSETTING(      0x0800, DEF_STR( Off ) )
558   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
559   PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
560   PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
561   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
562   PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )
563   PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
564   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
565   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
566   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
567   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
568   PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unknown ) )
569   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
570   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
571INPUT_PORTS_END
572
573static INTERRUPT_GEN( vblank_irq )
574{
575   cpu_set_input_line_and_vector(device,0,HOLD_LINE,0x08/4);
576}
577
578static MACHINE_DRIVER_START( brasil )
579   MDRV_CPU_ADD("main", I80186, 20000000 )   // ?
580   MDRV_CPU_PROGRAM_MAP(brasil_map,0)
581   MDRV_CPU_IO_MAP(brasil_io,0)
582   MDRV_CPU_VBLANK_INT("main", vblank_irq)
583
584   MDRV_SCREEN_ADD("main", RASTER)
585   MDRV_SCREEN_REFRESH_RATE(60)
586   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
587   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
588   MDRV_SCREEN_SIZE(400, 300)
589   MDRV_SCREEN_VISIBLE_AREA(0, 400-1, 0, 300-1)
590
591   MDRV_PALETTE_LENGTH(0x200)
592
593   MDRV_VIDEO_START(brasil)
594   MDRV_VIDEO_UPDATE(brasil)
595
596   /* sound hardware */
597   MDRV_SPEAKER_STANDARD_MONO("mono")
598
599   //OkiM6376
600   MDRV_SOUND_ADD("samples", OKIM6376, XTAL_12MHz/2/2)
601   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
602
603MACHINE_DRIVER_END
604
605
606static MACHINE_DRIVER_START( vidpokr2 )
607   MDRV_CPU_ADD("main", V30, 8000000 )   // ?
608   MDRV_CPU_PROGRAM_MAP(vidpokr2_map,0)
609   MDRV_CPU_IO_MAP(vidpokr2_io,0)
610   MDRV_CPU_VBLANK_INT("main", vblank_irq)
611
612   MDRV_SCREEN_ADD("main", RASTER)
613   MDRV_SCREEN_REFRESH_RATE(60)
614   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
615   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
616   MDRV_SCREEN_SIZE(400, 300)
617   MDRV_SCREEN_VISIBLE_AREA(0, 320-1, 0, 200-1)
618
619   MDRV_PALETTE_LENGTH(0x100)
620
621   MDRV_VIDEO_START(brasil)
622   MDRV_VIDEO_UPDATE(vidpokr2)
623
624   /* sound hardware */
625   MDRV_SPEAKER_STANDARD_MONO("mono")
626
627   //OkiM6376
628   MDRV_SOUND_ADD("samples", OKIM6376, XTAL_12MHz/2/2)
629   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
630
631MACHINE_DRIVER_END
632
633/*
634CPU
635
6361x NEC 9145N5-V30-D70116C-8 (main)
6371x OKI M6376 (sound)
6381x ispLSI2032-80LJ-H013J05 (main)
6391x ispLSI1032E-70LJ-E013S09 (main)
6401x ADV476KP35-9948-F112720.1 (GFX)
6411x oscillator 16.000MHz
642
643ROMs
6441x M27C2001 (ic31)
6452x M27C4001 (ic32,ic33)
646
647Note
648
6491x 28x2 edge connector (not JAMMA)
6501x 8 legs connector
6511x 3 legs jumper
6521x pushbutton
6531x battery
6541x trimmer (volume)
655
656PCB markings: "V150500 CE type 001/v0"
657PCB n. E178247
658
659*/
660
661ROM_START( newmcard )
662   ROM_REGION( 0x100000, "user1", 0 ) /* V30 Code */
663   ROM_LOAD16_BYTE( "mc32.ic4", 0x00000, 0x80000, CRC(d9817f48) SHA1(c523a8248b487081ea2e0e326dcc660b051c23c1) )
664   ROM_LOAD16_BYTE( "mc33.ic5", 0x00001, 0x80000, CRC(83a855ab) SHA1(7f9384c875b951d17caa91f8a7365edaf7f9afe1) )
665
666   ROM_REGION( 0x040000, "boot_prg", 0 ) /*copy for program code*/
667   ROM_COPY( "user1", 0x0c0000, 0x000000, 0x40000 )
668
669   ROM_REGION( 0x080000, "samples", 0 ) /* M6376 Samples */
670   ROM_LOAD( "mc31.ic15", 0x00000, 0x40000, CRC(8b72ffec) SHA1(fca5cf2594325e0c9fe446ddf2330c669f7f37a9) )
671ROM_END
672
673/*
674CPUs
675N80C186XL25 (main)(u1)
6761x ispLSI2032-80LJ (u13)(not dumped)
6771x ispLSI1032E-70LJ (u18)(not dumped)
6781x M6376 (sound)(u17)
6791x oscillator 40.000MHz
680
681ROMs
6821x MX27C4000 (u16)
6832x M27C801 (u7,u8)
684
685Note
686
6871x 28x2 edge connector (cn1)
6881x 5 legs connector (cn2)
6891x 8 legs connector (cn3)
6901x trimmer (volume)
6911x pushbutton (k1)
6921x battery (b1)
693
694
695cpu is 80186 based (with extras), see
696http://media.digikey.com/pdf/Data%20Sheets/Intel%20PDFs/80C186XL,%2080C188XL.pdf
697
698*/
699
700ROM_START( brasil )
701   ROM_REGION( 0x200000, "user1", 0 ) /* N80C186XL25 Code */
702   ROM_LOAD16_BYTE( "record_brasil_hrc7_vers.3.u7", 0x000000, 0x100000, CRC(627e0d58) SHA1(6ff8ba7b21e1ea5c88de3f02a057906c9a7cd808) )
703   ROM_LOAD16_BYTE( "record_brasil_hrc8_vers.3.u8", 0x000001, 0x100000, CRC(47f7ba2a) SHA1(0add7bbf771fd0bf205a05e910cb388cf052b09f) )
704
705   ROM_REGION( 0x040000, "boot_prg", 0 ) /*copy for program code*/
706   ROM_COPY( "user1", 0x1c0000, 0x000000, 0x40000 )
707
708   ROM_REGION( 0x080000, "samples", 0 ) /* M6376 Samples */
709   ROM_LOAD( "sound_brasil_hbr_vers.1.u16", 0x00000, 0x80000, CRC(d71a5566) SHA1(2f7aefc06e39ce211e31b15aadf6338b679e7a31) )
710ROM_END
711
712ROM_START( fashion )
713   ROM_REGION( 0x200000, "user1", 0 ) /* N80C186XL25 Code */
714   ROM_LOAD16_BYTE( "fashion1-hfs7v2.14.high-video8m.u7", 0x000000, 0x100000, CRC(20411b89) SHA1(3ed6336978e5046eeef26115614cb74e3ffe134a) )
715   ROM_LOAD16_BYTE( "fashion1-hfs8v2.14.high-video8m.u8", 0x000001, 0x100000, CRC(521f34f3) SHA1(91edc90fcd895a096955ac031a42da04510df1e6) )
716
717   ROM_REGION( 0x040000, "boot_prg", 0 ) /*copy for program code*/
718   ROM_COPY( "user1", 0x1c0000, 0x000000, 0x40000 )
719
720   ROM_REGION( 0x080000, "samples", 0 ) /* M6376 Samples */
721   ROM_LOAD( "sound-fashion-v-1-memory4m.u16", 0x00000, 0x80000, CRC(2927c799) SHA1(f11cad096a23fee10bfdff5bf944c96e30f4a8b8) )
722ROM_END
723
724static DRIVER_INIT( fashion )
725{
726   memory_install_write16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_IO), 0x0002, 0x0003, 0, 0, fashion_write2_w );
727}
728
729GAMEL( 19??, newmcard,  0,      vidpokr2,    brasil,   0,       ROT0,  "New High Video?", "New Magic Card",         0,                           layout_fashion )
730GAMEL( 2000, brasil,    0,      brasil,      brasil,   0,       ROT0,  "New High Video?", "Bra$il (Version 3)",     GAME_IMPERFECT_GRAPHICS, layout_fashion )
731GAMEL( 2000, fashion,   brasil, brasil,      fashion,  fashion, ROT0,  "New High Video?", "Fashion (Version 2.14)", GAME_IMPERFECT_GRAPHICS, layout_fashion )
src/mame/drivers/steaser.c
r4427r4428
1/* Strip Teaser
2 this has *2* 68705 MCUs..  neither dumped
3
4Strip Teaser (unknown manufacturer)
5------------------------------------
6
7lower board (Dk-B)
8
9TS68000CP12 (main cpu)
10osc. 11.0592MHz
11MC68HC705C8P (MCU)
12UM6845RA (CRT controller-Supports alphanumeric and graphics modes.Addresses up to 16 KB of video memory-2 MHz)
13Lithium battery 3,6V
14
15
16upper board (8L74) (soundboard?)
17
18MC68HC705C8P (MCU)
19osc. 4.0000MHz
20non JAMMA connector
211x dipswitch (4 switch)
22
23
24ROMs
251x AT27c010 (u31.1)(program)
261x AM27C010 (u32.6)(program)
274x M27C4001 (u46.2 - u51.3 - u61.4 - u66.5)(GFX)
281x M27C4001 (u18.7)(sound)
29
30
312008.07.01 - Tomasz Slanina - preliminary gfx blitter emulation
32
33TODO:
34- fix blitter writes (missing fill ?)
35- controls (probably one of the MCUS is used to read controls)
36- sound
37
38*/
39
40
41#include "driver.h"
42#include "cpu/m68000/m68000.h"
43#include "deprecat.h"
44
45
46static int clr_offset=0;
47
48static UINT16 *mainram;
49
50static UINT16 data_9a0000, data_998000, data_9b0000, data_9a8000, data_990000, data_988000;
51
52
53static WRITE16_HANDLER(blitter_9b8000_w)
54{
55   UINT8 *rom = memory_region(space->machine, "gfx1");
56   int len=memory_region_length(space->machine, "gfx1");
57   int w = video_screen_get_width(space->machine->primary_screen);
58   int h = video_screen_get_height(space->machine->primary_screen);
59   int x,y;
60   UINT16 pix;
61
62   int x0=(data_9a8000&0xff)<<1;
63   int y0=data_9a8000>>8;
64   int dx=data_9b0000&0xff;
65   int dy=((data_9b0000>>8)^0xff)+1;
66   UINT32 of=data_998000|(data_9a0000<<8);
67
68   if(of==0)
69   {
70      bitmap_fill(tmpbitmap,NULL,get_black_pen(space->machine));
71      return;
72   }
73
74   if(dx==0)
75   {
76      dx=0x100;
77   }
78
79   dx<<=1;
80
81#if 0
82   printf("[%x] %x blit %x -> %x,%x  (%x*%x ) [%x] %x - %.4x %.4x - %.4x - %.4x\n",data,cpu_get_pc(space->cpu),of,x0,y0,dx,dy,data_9b0000,data_9a8000,data_9a0000,data_998000,data_990000,data_988000);
83#endif
84
85   for(y=0;y<dy;++y)
86   {
87      for(x=0;x<dx;++x)
88      {
89         if(of<len && y+y0<h && x+x0<w)
90         {
91            pix=*(rom+of);
92
93            if(pix==0)
94            {
95               pix=0x100; //dirty hack
96            }
97
98
99            {
100               *BITMAP_ADDR16(tmpbitmap, y+y0, x+x0) = pix;
101            }
102         }
103         ++of;
104      }
105   }
106}
107
108
109
110static VIDEO_START(steaser)
111{
112   tmpbitmap = auto_bitmap_alloc(32*8*2,32*8*2,video_screen_get_format(machine->primary_screen));
113}
114
115static VIDEO_UPDATE(steaser)
116{
117   copybitmap(bitmap,tmpbitmap,0,0,0,0,cliprect);
118   return 0;
119}
120
121static READ16_HANDLER( steaser_bd0000_r )
122{
123   return 0xffff;
124}
125
126static READ16_HANDLER( steaser_9e0000_r )
127{
128   return 0;
129}
130
131static WRITE16_HANDLER(mcu_w)
132{
133   //communciation with MCU ?
134}
135
136static WRITE16_HANDLER(unk_w)
137{
138   switch(cpu_get_pc(space->cpu))
139   {
140      case 0x1348: mainram[0x00932/2]=0xffff; break; //dirt way to exit loop
141/*      case 0x16ce:
142        {
143            int addr=(cpu_get_reg(space->cpu, M68K_D2)+0x089c)>>1;
144            mainram[addr&0x7fff]=0xffff;//mame_rand(space->machine);
145        }
146        break;*/
147   }
148}
149
150static WRITE16_HANDLER(blitter_990000_w)
151{
152   COMBINE_DATA(&data_990000);
153}
154
155static WRITE16_HANDLER(blitter_998000_w)
156{
157   COMBINE_DATA(&data_998000);
158}
159
160static WRITE16_HANDLER(blitter_9a0000_w)
161{
162   COMBINE_DATA(&data_9a0000);
163}
164
165static WRITE16_HANDLER(blitter_9a8000_w)
166{
167   COMBINE_DATA(&data_9a8000);
168}
169
170static WRITE16_HANDLER(blitter_9b0000_w)
171{
172   COMBINE_DATA(&data_9b0000);
173}
174
175static WRITE16_HANDLER(blitter_988000_w)
176{
177   COMBINE_DATA(&data_988000);
178}
179
180static WRITE16_HANDLER( color_offset_w )
181{
182      data>>=8;
183      clr_offset=data*3;
184}
185
186static WRITE16_HANDLER( color_data_w )
187{
188      data>>=8;
189      colorram[clr_offset]=data;
190      palette_set_color_rgb(space->machine,clr_offset/3,pal6bit(colorram[(clr_offset/3)*3]),pal6bit(colorram[(clr_offset/3)*3+1]),pal6bit(colorram[(clr_offset/3)*3+2]));
191      clr_offset=(clr_offset+1)%768;
192}
193
194
195static ADDRESS_MAP_START( steaser_map, ADDRESS_SPACE_PROGRAM, 16 )
196   AM_RANGE(0x000000, 0x03ffff) AM_ROM
197   AM_RANGE(0xbd0000, 0xbd0001) AM_READ( steaser_bd0000_r )
198   AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_BASE(&mainram)
199   AM_RANGE(0x800000, 0x800001) AM_READ( steaser_bd0000_r )
200   AM_RANGE(0x880000, 0x880001) AM_READ( steaser_bd0000_r )
201   AM_RANGE(0x840000, 0x840001) AM_WRITE(mcu_w)
202//  AM_RANGE(0x8c0000, 0x8c0001) AM_WRITENOP
203//  AM_RANGE(0x900000, 0x900003) AM_RAM
204
205   AM_RANGE(0x900000, 0x900001) AM_WRITE(color_offset_w)
206   AM_RANGE(0x900002, 0x900003) AM_WRITE(color_data_w)
207   AM_RANGE(0x900004, 0x900005) AM_WRITENOP
208   AM_RANGE(0x940000, 0x940001) AM_WRITENOP
209   AM_RANGE(0x980000, 0x98000f) AM_WRITENOP //blitter related
210   AM_RANGE(0x988000, 0x988001) AM_WRITE(blitter_988000_w)
211   AM_RANGE(0x990000, 0x990001) AM_WRITE(blitter_990000_w)
212   AM_RANGE(0x998000, 0x998001) AM_WRITE(blitter_998000_w)
213   AM_RANGE(0x9a0000, 0x9a0001) AM_WRITE(blitter_9a0000_w)
214   AM_RANGE(0x9a8000, 0x9a8001) AM_WRITE(blitter_9a8000_w)
215   AM_RANGE(0x9b0000, 0x9b0001) AM_WRITE(blitter_9b0000_w)
216   AM_RANGE(0x9b8000, 0x9b8001) AM_WRITE(blitter_9b8000_w)
217   AM_RANGE(0x9e0000, 0x9e0001) AM_READ( steaser_9e0000_r )
218   AM_RANGE(0x9f0000, 0x9f0001) AM_WRITE(unk_w)
219ADDRESS_MAP_END
220
221static INPUT_PORTS_START( steaser )
222INPUT_PORTS_END
223
224
225
226static INTERRUPT_GEN( steaser_irq )
227{
228   int num=cpu_getiloops(device)+3;
229   cpu_set_input_line(device, num, HOLD_LINE);
230}
231
232static MACHINE_DRIVER_START( steaser )
233   MDRV_CPU_ADD("main", M68000, 11059200 )
234   MDRV_CPU_PROGRAM_MAP(steaser_map,0)
235   MDRV_CPU_VBLANK_INT_HACK(steaser_irq,4)
236
237   MDRV_SCREEN_ADD("main", RASTER)
238   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
239   MDRV_SCREEN_SIZE(32*8*2, 32*8*2)
240   MDRV_SCREEN_VISIBLE_AREA(0*8, 2*32*8-1, 0*8, 32*8-1)
241   MDRV_SCREEN_REFRESH_RATE(60)
242   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
243
244   MDRV_PALETTE_LENGTH(0x200)
245
246   MDRV_VIDEO_START(steaser)
247   MDRV_VIDEO_UPDATE(steaser)
248MACHINE_DRIVER_END
249
250
251ROM_START( steaser )
252   ROM_REGION( 0x40000, "main", 0 ) /* 68000 Code */
253   ROM_LOAD16_BYTE( "u31.1", 0x00001, 0x20000, CRC(7963e960) SHA1(2a1c68265e0a3909ccd097ea784e3e179f528844) )
254   ROM_LOAD16_BYTE( "u32.6", 0x00000, 0x20000, CRC(c0ab5fb1) SHA1(15b3dbf0242e885b7009c21479544a821d4e5a7d) )
255
256   ROM_REGION( 0x1000, "cpu1", 0 ) /* 68705 */
257   ROM_LOAD( "mc68hc705c8p_main.mcu", 0x00000, 0x1000, NO_DUMP )
258
259   ROM_REGION( 0x1000, "cpu2", 0 ) /* 68705 */
260   ROM_LOAD( "mc68hc705c8p_sub.mcu", 0x00000, 0x1000, NO_DUMP )
261
262   ROM_REGION( 0x80000, "samples", 0 ) /* Sound Samples */
263   ROM_LOAD( "u18.7", 0x00000, 0x80000, CRC(ee942232) SHA1(b9c1fc73c6006bcad0dd177e0f30a96f1063a993) )
264
265   ROM_REGION( 0x200000, "gfx1", 0 ) /* GFX */
266   ROM_LOAD( "u46.2", 0x000000, 0x80000, CRC(c4a5e47b) SHA1(9f3d3124c76c0bdf8cdca849e1d921a335e433b6) )
267   ROM_LOAD( "u51.3", 0x080000, 0x80000, CRC(4dc57435) SHA1(7dfa6f9e35986dd48869786abbe70103f336bcb1) )
268   ROM_LOAD( "u61.4", 0x100000, 0x80000, CRC(d8d8dc6f) SHA1(5a76b1fd1a3a532e5ff2de127286ace7d3567c58) )
269   ROM_LOAD( "u66.5", 0x180000, 0x80000, CRC(da309671) SHA1(66baf8a83024547c471da39748ff99a9a9013ea4) )
270ROM_END
271
272static DRIVER_INIT(steaser)
273{
274   colorram=auto_malloc(768);
275}
276
277GAME( 1993, steaser, 0, steaser, steaser, steaser, ROT0,  "Unknown", "Strip Teaser (Italy)", GAME_NOT_WORKING|GAME_NO_SOUND )
src/mame/drivers/fruit.c
r4427r4428
1/*
2
3Fruit?
4
5Video Fruit Machine
6
7- Doesn't make much sense,anything (including rom load/rom dump etc.) might be bad or heavily protected.
8*/
9
10#include "driver.h"
11#include "cpu/z80/z80.h"
12
13static UINT8 *fruit_vram;
14
15static VIDEO_START(fruit)
16{
17
18}
19
20static VIDEO_UPDATE(fruit)
21{
22   const gfx_element *gfx = screen->machine->gfx[1];
23   int count = 0x0000;
24
25   int y,x;
26
27
28   for (y=0;y<64;y++)
29   {
30      for (x=0;x<64;x++)
31      {
32         int tile = (fruit_vram[count]);
33         //int colour = tile>>12;
34         drawgfx(bitmap,gfx,tile,0,0,0,x*8,y*8,cliprect,TRANSPARENCY_NONE,0);
35
36         count++;
37      }
38   }
39
40   return 0;
41}
42
43static ADDRESS_MAP_START( mainmap, ADDRESS_SPACE_PROGRAM, 8 )
44   AM_RANGE(0x0000, 0x2fff) AM_ROM
45   AM_RANGE(0xa000, 0xafff) AM_RAM
46   AM_RANGE(0xb000, 0xbfff) AM_RAM AM_BASE(&fruit_vram)
47   AM_RANGE(0xd000, 0xdfff) AM_ROM //second rom mirrors there
48   AM_RANGE(0xe000, 0xefff) AM_ROM //first rom mirrors there
49   AM_RANGE(0xf000, 0xffff) AM_RAM
50ADDRESS_MAP_END
51
52
53
54static INPUT_PORTS_START( fruit )
55INPUT_PORTS_END
56
57static const gfx_layout tiles32x32_layout =
58{
59   32,32,
60   RGN_FRAC(1,3),
61   3,
62   { RGN_FRAC(0,3),RGN_FRAC(1,3),RGN_FRAC(2,3) },
63   { 0,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 },
64   { 0*32, 1*32, 2*32, 3*32,4*32,5*32,6*32,7*32,8*32,9*32,10*32,11*32,12*32,13*32,14*32,15*32,16*32,17*32,18*32,19*32,20*32,21*32,22*32,23*32,24*32,25*32,26*32,27*32,28*32,29*32,30*32,31*32 },
65   32*32
66};
67
68static const gfx_layout tiles8x8_layout =
69{
70   8,8,
71   RGN_FRAC(1,1),
72   1,
73   { 0 },
74   { 0,1,2,3,4,5,6,7 },
75   { 0*8,1*8,2*8,3*8,4*8,5*8,6*8,7*8},
76   8*8
77};
78static GFXDECODE_START( fruit )
79   GFXDECODE_ENTRY( "gfx1", 0, tiles32x32_layout, 0, 16 )
80   GFXDECODE_ENTRY( "gfx2", 0, tiles8x8_layout, 0, 16 )
81GFXDECODE_END
82
83static MACHINE_DRIVER_START( fruit )
84   /* basic machine hardware */
85   MDRV_CPU_ADD("main", Z80,8000000)       /* ? MHz */
86   MDRV_CPU_PROGRAM_MAP(mainmap,0)
87   MDRV_CPU_VBLANK_INT("main", irq0_line_hold)
88
89   /* video hardware */
90   MDRV_SCREEN_ADD("main", RASTER)
91   MDRV_SCREEN_REFRESH_RATE(60)
92   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
93   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
94   MDRV_SCREEN_SIZE(512, 512)
95   MDRV_SCREEN_VISIBLE_AREA(0, 512-1, 0, 512-1)
96
97   MDRV_GFXDECODE(fruit)
98   MDRV_PALETTE_LENGTH(0x100)
99
100   MDRV_VIDEO_START(fruit)
101   MDRV_VIDEO_UPDATE(fruit)
102MACHINE_DRIVER_END
103
104
105
106ROM_START( fruit )
107   ROM_REGION( 0x10000, "main", 0 )
108   ROM_LOAD( "vp-h9.bin",  0x00000, 0x1000, CRC(f595daf7) SHA1(be5abd34fd06f73cd80f5b15902d158e33705c8f) )
109   ROM_RELOAD(             0x0e000, 0x1000 )
110   ROM_LOAD( "vp-h10.bin", 0x01000, 0x1000, CRC(b0539100) SHA1(763f31f72f55c3322b24e127b37130d37daa5216) )
111   ROM_RELOAD(             0x0d000, 0x1000 )
112   ROM_LOAD( "vp-h11.bin", 0x02000, 0x1000, CRC(fa176072) SHA1(18203278bb9c505f07390f7b95ecf9ab6d7b7122) )
113
114   ROM_REGION( 0x1800, "gfx1", 0 ) // fruits - 3bpp
115   ROM_LOAD( "vp-h5.bin", 0x00000, 0x0800, CRC(dfffe063) SHA1(1b860323fe93b7d010fa35167769555a6bd4a49c) )
116   ROM_LOAD( "vp-h6.bin", 0x00800, 0x0800, CRC(355203b8) SHA1(959f3599a24293f392e8b10061c39d3244f34c05) )
117   ROM_LOAD( "vp-h7.bin", 0x01000, 0x0800, CRC(7784de8a) SHA1(40851724c9b7ef26964462b5e97ad943df4d56e2) )
118
119   ROM_REGION( 0x800, "gfx2", 0 ) // screen layout stuff - 1bpp
120   ROM_LOAD( "vp-h8.bin", 0x00000, 0x0800, CRC(d587e541) SHA1(902b6c4673b8b989d034d60d3c47f2499f100ba2) )
121ROM_END
122
123GAME( 1987, fruit,  0,    fruit, fruit,  0, ROT270, "unknown", "Unknown Fruits Game", GAME_NOT_WORKING|GAME_NO_SOUND )
src/emu/sndintrf.c
r4427r4428
1/***************************************************************************
2
3    sndintrf.c
4
5    Core sound interface functions and definitions.
6
7    Copyright Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
9
10****************************************************************************
11
12    Still to do:
13        * fix drivers that used to use ADPCM
14        * many cores do their own resampling; they should stop
15        * many cores mix to a separate buffer; no longer necessary
16
17***************************************************************************/
18
19#include "driver.h"
20
21
22
23/***************************************************************************
24    DEBUGGING
25***************************************************************************/
26
27#define VERBOSE         (0)
28
29#define VPRINTF(x) do { if (VERBOSE) mame_printf_debug x; } while (0)
30
31
32
33/***************************************************************************
34    TYPE DEFINITIONS
35***************************************************************************/
36
37typedef struct _sndintrf_data sndintrf_data;
38struct _sndintrf_data
39{
40   sound_type      sndtype;       /* type index of this sound chip */
41   sound_type      aliastype;      /* aliased type index of this sound chip */
42   device_config *   device;         /* dummy device for now */
43   int            index;          /* index of this sound chip */
44};
45
46
47
48/***************************************************************************
49    VALIDATION MACROS
50***************************************************************************/
51
52#define VERIFY_SNDNUM(name) \
53   assert_always(sndnum >= 0 && sndnum < totalsnd, #name "() called with invalid sound num!")
54
55#define VERIFY_SNDTI(name) \
56   int sndnum = sndti_to_sndnum(sndtype, sndindex); \
57   assert_always(sndindex >= 0 && sndindex < totalsnd && sndnum != -1, #name "() called with invalid (type,index) pair!")
58
59#define VERIFY_SNDTYPE(name) \
60
61
62
63/***************************************************************************
64    GLOBAL VARIABLES
65***************************************************************************/
66
67static sndintrf_data sound[MAX_SOUND];
68static int totalsnd;
69
70
71
72/***************************************************************************
73    INITIALIZATION
74***************************************************************************/
75
76/*-------------------------------------------------
77    sndintrf_init - discover all linked sound
78    systems and build a matrix for sound
79    (type,index) pairs for the current machine
80-------------------------------------------------*/
81
82void sndintrf_init(running_machine *machine)
83{
84   /* zap the sound data structures */
85   memset(sound, 0, sizeof(sound));
86   totalsnd = 0;
87}
88
89
90/*-------------------------------------------------
91    sndintrf_init_sound - initialize data for a
92    particular sndnum
93-------------------------------------------------*/
94
95static DEVICE_GET_INFO( sndclass )
96{
97   sndintrf_data *snddata = device->inline_config;
98   (*snddata->sndtype)(device, state, (sndinfo *)info);
99}
100
101int sndintrf_init_sound(running_machine *machine, int sndnum, const char *tag, sound_type sndtype, int clock, const void *config)
102{
103   snd_start_func start;
104   sndintrf_data *info = &sound[sndnum];
105   int tokenbytes;
106   int index;
107   int sndidx;
108
109   info->device = auto_malloc(sizeof(*info->device) + strlen(tag));
110   memset(info->device, 0, sizeof(*info->device) + strlen(tag));
111   info->device->type = DEVICE_GET_INFO_NAME(sndclass);
112   info->device->machine = machine;
113   strcpy(info->device->tag, tag);
114   info->device->static_config = config;
115   info->device->region = memory_region(info->device->machine, info->device->tag);
116   info->device->regionbytes = memory_region_length(info->device->machine, info->device->tag);
117
118   /* hack: stash the info pointer in the inline_config */
119   info->device->inline_config = info;
120
121   /* fill in the type and interface */
122   info->sndtype = sndtype;
123   info->aliastype = (sound_type)sndtype_get_info_fct(sndtype, SNDINFO_FCT_ALIAS);
124   if (info->aliastype == 0)
125      info->aliastype = sndtype;
126   info->device->clock = clock;
127
128   /* compute the index */
129   for (index = 0, sndidx = 0; sndidx < totalsnd; sndidx++)
130      if (sound[sndidx].aliastype == info->aliastype)
131         index++;
132   info->index = index;
133   totalsnd++;
134
135   /* allocate the token */
136   tokenbytes = sndtype_get_info_int(sndtype, DEVINFO_INT_TOKEN_BYTES);
137   assert(tokenbytes != 0);
138   info->device->token = auto_malloc(tokenbytes);
139   memset(info->device->token, 0, tokenbytes);
140
141   /* start the chip, tagging all its streams */
142   start = (snd_start_func)sndtype_get_info_fct(sndtype, SNDINFO_PTR_START);
143   (*start)(info->device, clock);
144   VPRINTF(("  token = %p\n", info->device->token));
145
146   return 0;
147}
148
149
150/*-------------------------------------------------
151    sndintrf_exit_sound - tear down data for a
152    particular sndnum
153-------------------------------------------------*/
154
155void sndintrf_exit_sound(int sndnum)
156{
157   sndinfo info;
158
159   info.stop = NULL;
160   (*sound[sndnum].sndtype)(NULL, SNDINFO_PTR_STOP, &info);
161
162   /* stop the chip */
163   if (info.stop)
164      (*info.stop)(sound[sndnum].device);
165}
166
167
168
169/***************************************************************************
170    HELPERS
171***************************************************************************/
172
173/*-------------------------------------------------
174    sndti_exists - return TRUE if a (type,index)
175    pair describes an existing chip
176-------------------------------------------------*/
177
178int sndti_exists(sound_type type, int index)
179{
180   return (sndti_to_sndnum(type, index) != -1);
181}
182
183
184/*-------------------------------------------------
185    sndti_to_sndnum - map a (type,index) pair to
186    a sound number
187-------------------------------------------------*/
188
189int sndti_to_sndnum(sound_type type, int index)
190{
191   int sndnum;
192   for (sndnum = 0; sndnum < totalsnd; sndnum++)
193      if (sound[sndnum].aliastype == type)
194         if (index-- == 0)
195            return sndnum;
196   return -1;
197}
198
199
200/*-------------------------------------------------
201    sndnum_to_sndti - map a sound number to a
202    (type,index) pair
203-------------------------------------------------*/
204
205sound_type sndnum_to_sndti(int sndnum, int *index)
206{
207   if (index != NULL)
208      *index = sound[sndnum].index;
209   return sound[sndnum].aliastype;
210}
211
212
213/*-------------------------------------------------
214    sndtype_count - count the number of a
215    given type
216-------------------------------------------------*/
217
218int sndtype_count(sound_type sndtype)
219{
220   int index;
221   int count = 0;
222
223   for (index = 0; index < totalsnd; index++)
224      if (sound[index].sndtype == sndtype)
225         count++;
226
227   return count;
228}
229
230
231
232/***************************************************************************
233    CHIP INTERFACES BY INDEX
234***************************************************************************/
235
236/*-------------------------------------------------
237    Get info accessors
238-------------------------------------------------*/
239
240INT64 sndnum_get_info_int(int sndnum, UINT32 state)
241{
242   sndinfo info;
243
244   VERIFY_SNDNUM(sndnum_get_info_int);
245   info.i = 0;
246   (*sound[sndnum].sndtype)(sound[sndnum].device, state, &info);
247   return info.i;
248}
249
250void *sndnum_get_info_ptr(int sndnum, UINT32 state)
251{
252   sndinfo info;
253
254   VERIFY_SNDNUM(sndnum_get_info_ptr);
255   info.p = NULL;
256   (*sound[sndnum].sndtype)(sound[sndnum].device, state, &info);
257   return info.p;
258}
259
260genf *sndnum_get_info_fct(int sndnum, UINT32 state)
261{
262   sndinfo info;
263
264   VERIFY_SNDNUM(sndnum_get_info_fct);
265   info.f = NULL;
266   (*sound[sndnum].sndtype)(sound[sndnum].device, state, &info);
267   return info.f;
268}
269
270const char *sndnum_get_info_string(int sndnum, UINT32 state)
271{
272   extern char *get_temp_string_buffer(void);
273   sndinfo info;
274
275   VERIFY_SNDNUM(sndnum_get_info_string);
276   info.s = get_temp_string_buffer();
277   (*sound[sndnum].sndtype)(sound[sndnum].device, state, &info);
278   return info.s;
279}
280
281
282/*-------------------------------------------------
283    Misc accessors
284-------------------------------------------------*/
285
286void sndnum_reset(int sndnum)
287{
288   sndinfo info;
289
290   VERIFY_SNDNUM(sndnum_reset);
291   info.reset = NULL;
292   (*sound[sndnum].sndtype)(NULL, SNDINFO_PTR_RESET, &info);
293   if (info.reset)
294      (info.reset)(sound[sndnum].device);
295}
296
297int sndnum_clock(int sndnum)
298{
299   VERIFY_SNDNUM(sndnum_clock);
300   return sound[sndnum].device->clock;
301}
302
303void *sndnum_token(int sndnum)
304{
305   VERIFY_SNDNUM(sndnum_token);
306   return sound[sndnum].device->token;
307}
308
309
310
311/***************************************************************************
312    CHIP INTERFACES BY (TYPE,INDEX) PAIR
313***************************************************************************/
314
315/*-------------------------------------------------
316    Get info accessors
317-------------------------------------------------*/
318
319INT64 sndti_get_info_int(sound_type sndtype, int sndindex, UINT32 state)
320{
321   sndinfo info;
322
323   VERIFY_SNDTI(sndti_get_info_int);
324   info.i = 0;
325   (*sound[sndnum].sndtype)(sound[sndnum].device, state, &info);
326   return info.i;
327}
328
329void *sndti_get_info_ptr(sound_type sndtype, int sndindex, UINT32 state)
330{
331   sndinfo info;
332
333   VERIFY_SNDTI(sndti_get_info_ptr);
334   info.p = NULL;
335   (*sound[sndnum].sndtype)(sound[sndnum].device, state, &info);
336   return info.p;
337}
338
339genf *sndti_get_info_fct(sound_type sndtype, int sndindex, UINT32 state)
340{
341   sndinfo info;
342
343   VERIFY_SNDTI(sndti_get_info_fct);
344   info.f = NULL;
345   (*sound[sndnum].sndtype)(sound[sndnum].device, state, &info);
346   return info.f;
347}
348
349const char *sndti_get_info_string(sound_type sndtype, int sndindex, UINT32 state)
350{
351   extern char *get_temp_string_buffer(void);
352   sndinfo info;
353
354   VERIFY_SNDTI(sndti_get_info_string);
355   info.s = get_temp_string_buffer();
356   (*sound[sndnum].sndtype)(sound[sndnum].device, state, &info);
357   return info.s;
358}
359
360
361/*-------------------------------------------------
362    Misc accessors
363-------------------------------------------------*/
364
365void sndti_reset(sound_type sndtype, int sndindex)
366{
367   sndinfo info;
368
369   VERIFY_SNDTI(sndti_reset);
370   info.reset = NULL;
371   (*sound[sndnum].sndtype)(NULL, SNDINFO_PTR_RESET, &info);
372
373   if (info.reset)
374      (*info.reset)(sound[sndnum].device);
375}
376
377int sndti_clock(sound_type sndtype, int sndindex)
378{
379   VERIFY_SNDTI(sndti_clock);
380   return sound[sndnum].device->clock;
381}
382
383void *sndti_token(sound_type sndtype, int sndindex)
384{
385   VERIFY_SNDTI(sndti_token);
386   return sound[sndnum].device->token;
387}
388
389
390
391/***************************************************************************
392    CHIP INTERFACES BY TYPE
393***************************************************************************/
394
395/*-------------------------------------------------
396    Get info accessors
397-------------------------------------------------*/
398
399INT64 sndtype_get_info_int(sound_type sndtype, UINT32 state)
400{
401   snd_get_info_func get_info = sndtype;
402   sndinfo info;
403
404   VERIFY_SNDTYPE(sndtype_get_info_int);
405   info.i = 0;
406   (*get_info)(NULL, state, &info);
407   return info.i;
408}
409
410void *sndtype_get_info_ptr(sound_type sndtype, UINT32 state)
411{
412   snd_get_info_func get_info = sndtype;
413   sndinfo info;
414
415   VERIFY_SNDTYPE(sndtype_get_info_ptr);
416   info.p = NULL;
417   (*get_info)(NULL, state, &info);
418   return info.p;
419}
420
421genf *sndtype_get_info_fct(sound_type sndtype, UINT32 state)
422{
423   snd_get_info_func get_info = sndtype;
424   sndinfo info;
425
426   VERIFY_SNDTYPE(sndtype_get_info_fct);
427   info.f = NULL;
428   (*get_info)(NULL, state, &info);
429   return info.f;
430}
431
432const char *sndtype_get_info_string(sound_type sndtype, UINT32 state)
433{
434   extern char *get_temp_string_buffer(void);
435   snd_get_info_func get_info = sndtype;
436   sndinfo info;
437
438   VERIFY_SNDTYPE(sndtype_get_info_string);
439   info.s = get_temp_string_buffer();
440   (*get_info)(NULL, state, &info);
441   return info.s;
442}
src/emu/video/cdp1869.c
r4427r4428
1#include "driver.h"
2#include "sndintrf.h"
3#include "streams.h"
4#include "cpu/cdp1802/cdp1802.h"
5#include "sound/cdp1869.h"
6#include "video/cdp1869.h"
7
8/*
9
10    TODO:
11
12    - connect to sound system when possible
13    - white noise
14    - scanline based update
15    - separate to CDP1869 and CDP1870/6
16
17*/
18
19#define CDP1869_WEIGHT_RED      30 /* % of max luminance */
20#define CDP1869_WEIGHT_GREEN   59
21#define CDP1869_WEIGHT_BLUE      11
22
23#define CDP1869_COLUMNS_HALF   20
24#define CDP1869_COLUMNS_FULL   40
25#define CDP1869_ROWS_HALF      12
26#define CDP1869_ROWS_FULL_PAL   25
27#define CDP1869_ROWS_FULL_NTSC   24
28
29enum
30{
31   CDB0 = 0,
32   CDB1,
33   CDB2,
34   CDB3,
35   CDB4,
36   CDB5,
37   CCB0,
38   CCB1
39};
40
41typedef struct _cdp1869_t cdp1869_t;
42struct _cdp1869_t
43{
44   const cdp1869_interface *intf;   /* interface */
45   const device_config *screen;   /* screen */
46   const device_config *cpu;      /* CPU */
47   sound_stream *stream;         /* sound output */
48   int color_clock;
49
50   /* video state */
51   int dispoff;               /* display off */
52   int fresvert;               /* full resolution vertical */
53   int freshorz;               /* full resolution horizontal */
54   int cmem;                  /* character memory access mode */
55   int dblpage;               /* double page mode */
56   int line16;                  /* 16-line hi-res mode */
57   int line9;                  /* 9 line mode */
58   int cfc;                  /* color format control */
59   UINT8 col;                  /* character color control */
60   UINT8 bkg;                  /* background color */
61   UINT16 pma;                  /* page memory address */
62   UINT16 hma;                  /* home memory address */
63
64   /* video timer */
65   emu_timer *prd_changed_timer;   /* predisplay changed timer */
66
67   /* sound state */
68   INT16 signal;               /* current signal */
69   int incr;                  /* initial wave state */
70   int toneoff;               /* tone off */
71   int wnoff;                  /* white noise off */
72   UINT8 tonediv;               /* tone divisor */
73   UINT8 tonefreq;               /* tone range select */
74   UINT8 toneamp;               /* tone output amplitude */
75   UINT8 wnfreq;               /* white noise range select */
76   UINT8 wnamp;               /* white noise output amplitude */
77};
78
79INLINE cdp1869_t *get_safe_token(const device_config *device)
80{
81   assert(device != NULL);
82   assert(device->token != NULL);
83
84   return (cdp1869_t *)device->token;
85}
86
87/* Predisplay Timer */
88
89static void update_prd_changed_timer(cdp1869_t *cdp1869)
90{
91   if (cdp1869->prd_changed_timer != NULL)
92   {
93      attotime duration;
94      int start, end, level;
95      int scanline = video_screen_get_vpos(cdp1869->screen);
96      int next_scanline;
97
98      if (cdp1869->intf->pal_ntsc == CDP1869_NTSC)
99      {
100         start = CDP1869_SCANLINE_PREDISPLAY_START_NTSC;
101         end = CDP1869_SCANLINE_PREDISPLAY_END_NTSC;
102      }
103      else
104      {
105         start = CDP1869_SCANLINE_PREDISPLAY_START_PAL;
106         end = CDP1869_SCANLINE_PREDISPLAY_END_PAL;
107      }
108
109      if (scanline < start)
110      {
111         next_scanline = start;
112         level = 0;
113      }
114      else if (scanline < end)
115      {
116         next_scanline = end;
117         level = 1;
118      }
119      else
120      {
121         next_scanline = start;
122         level = 0;
123      }
124
125      if (cdp1869->dispoff)
126      {
127         level = 1;
128      }
129
130      duration = video_screen_get_time_until_pos(cdp1869->screen, next_scanline, 0);
131      timer_adjust_oneshot(cdp1869->prd_changed_timer, duration, level);
132   }
133}
134
135static TIMER_CALLBACK( prd_changed_tick )
136{
137   const device_config *device = ptr;
138   cdp1869_t *cdp1869 = get_safe_token(device);
139
140   /* call the callback function -- we know it exists */
141   cdp1869->intf->on_prd_changed(device, param);
142
143   update_prd_changed_timer(cdp1869);
144}
145
146/* State Save Postload */
147
148static STATE_POSTLOAD( cdp1869_state_save_postload )
149{
150   update_prd_changed_timer(param);
151}
152
153/* CDP1802 X Register */
154
155static UINT16 cdp1802_get_r_x(cdp1869_t *cdp1869)
156{
157   return cpu_get_reg(cdp1869->cpu, CDP1802_R0 + cpu_get_reg(cdp1869->cpu, CDP1802_X));
158}
159
160/* Palette Initialization */
161
162static rgb_t cdp1869_get_rgb(int i, int c, int l)
163{
164   int luma = 0, r, g, b;
165
166   luma += (l & 4) ? CDP1869_WEIGHT_RED : 0;
167   luma += (l & 1) ? CDP1869_WEIGHT_GREEN : 0;
168   luma += (l & 2) ? CDP1869_WEIGHT_BLUE : 0;
169
170   luma = (luma * 0xff) / 100;
171
172   r = (c & 4) ? luma : 0;
173   g = (c & 1) ? luma : 0;
174   b = (c & 2) ? luma : 0;
175
176   return MAKE_RGB(r, g, b);
177}
178
179/* Screen Update */
180
181static int cdp1869_get_lines(const device_config *device)
182{
183   cdp1869_t *cdp1869 = get_safe_token(device);
184
185   if (cdp1869->line16 && !cdp1869->dblpage)
186   {
187      return 16;
188   }
189   else if (!cdp1869->line9)
190   {
191      return 9;
192   }
193   else
194   {
195      return 8;
196   }
197}
198
199static UINT16 cdp1869_get_pmemsize(const device_config *device, int cols, int rows)
200{
201   cdp1869_t *cdp1869 = get_safe_token(device);
202
203   int pmemsize = cols * rows;
204
205   if (cdp1869->dblpage) pmemsize *= 2;
206   if (cdp1869->line16) pmemsize *= 2;
207
208   return pmemsize;
209}
210
211static UINT16 cdp1869_get_pma(const device_config *device)
212{
213   cdp1869_t *cdp1869 = get_safe_token(device);
214
215   if (cdp1869->dblpage)
216   {
217      return cdp1869->pma;
218   }
219   else
220   {
221      return cdp1869->pma & 0x3ff;
222   }
223}
224
225static int cdp1869_get_pen(const device_config *device, int ccb0, int ccb1, int pcb)
226{
227   cdp1869_t *cdp1869 = get_safe_token(device);
228
229   int r = 0, g = 0, b = 0, color;
230
231   switch (cdp1869->col)
232   {
233   case 0:
234      r = ccb0;
235      b = ccb1;
236      g = pcb;
237      break;
238
239   case 1:
240      r = ccb0;
241      b = pcb;
242      g = ccb1;
243      break;
244
245   case 2:
246   case 3:
247      r = pcb;
248      b = ccb0;
249      g = ccb1;
250      break;
251   }
252
253   color = (r << 2) + (b << 1) + g;
254
255   if (cdp1869->cfc)
256   {
257      return color + ((cdp1869->bkg + 1) * 8);
258   }
259   else
260   {
261      return color;
262   }
263}
264
265static void cdp1869_draw_line(const device_config *device, bitmap_t *bitmap, int x, int y, int data, int color)
266{
267   cdp1869_t *cdp1869 = get_safe_token(device);
268
269   int i;
270
271   data <<= 2;
272
273   for (i = 0; i < CDP1869_CHAR_WIDTH; i++)
274   {
275      if (data & 0x80)
276      {
277         *BITMAP_ADDR16(bitmap, y, x) = color;
278
279         if (!cdp1869->fresvert)
280         {
281            *BITMAP_ADDR16(bitmap, y + 1, x) = color;
282         }
283
284         if (!cdp1869->freshorz)
285         {
286            *BITMAP_ADDR16(bitmap, y, x + 1) = color;
287
288            if (!cdp1869->fresvert)
289            {
290               *BITMAP_ADDR16(bitmap, y + 1, x + 1) = color;
291            }
292         }
293      }
294
295      if (!cdp1869->freshorz)
296      {
297         x++;
298      }
299
300      x++;
301
302      data <<= 1;
303   }
304}
305
306static void cdp1869_draw_char(const device_config *device, bitmap_t *bitmap, int x, int y, UINT16 pma, const rectangle *screenrect)
307{
308   cdp1869_t *cdp1869 = get_safe_token(device);
309
310   UINT8 cma = 0;
311
312   for (cma = 0; cma < cdp1869_get_lines(device); cma++)
313   {
314      UINT8 data = cdp1869->intf->char_ram_r(device, pma, cma);
315
316      int ccb0 = BIT(data, CCB0);
317      int ccb1 = BIT(data, CCB1);
318      int pcb = BIT(cdp1869->intf->pcb_r(device, pma, cma), 0);
319
320      int color = cdp1869_get_pen(device, ccb0, ccb1, pcb);
321
322      cdp1869_draw_line(device, bitmap, screenrect->min_x + x, screenrect->min_y + y, data, color);
323
324      y++;
325
326      if (!cdp1869->fresvert)
327      {
328         y++;
329      }
330   }
331}
332
333/* Palette Initialization */
334
335PALETTE_INIT( cdp1869 )
336{
337   int i, c, l;
338
339   // color-on-color display (CFC=0)
340
341   for (i = 0; i < 8; i++)
342   {
343      palette_set_color(machine, i, cdp1869_get_rgb(i, i, 15));
344   }
345
346   // tone-on-tone display (CFC=1)
347
348   for (c = 0; c < 8; c++)
349   {
350      for (l = 0; l < 8; l++)
351      {
352         palette_set_color(machine, i, cdp1869_get_rgb(i, c, l));
353         i++;
354      }
355   }
356}
357
358/* Register Access */
359
360WRITE8_DEVICE_HANDLER( cdp1869_out3_w )
361{
362   cdp1869_t *cdp1869 = get_safe_token(device);
363
364   /*
365      bit   description
366
367        0   bkg green
368        1   bkg blue
369        2   bkg red
370        3   cfc
371        4   disp off
372        5   colb0
373        6   colb1
374        7   fres horz
375    */
376
377   cdp1869->bkg = data & 0x07;
378   cdp1869->cfc = BIT(data, 3);
379   cdp1869->dispoff = BIT(data, 4);
380   cdp1869->col = (data & 0x60) >> 5;
381   cdp1869->freshorz = BIT(data, 7);
382}
383
384WRITE8_DEVICE_HANDLER( cdp1869_out4_w )
385{
386   cdp1869_t *cdp1869 = get_safe_token(device);
387
388   UINT16 word = cdp1802_get_r_x(cdp1869);
389
390   /*
391      bit   description
392
393        0   tone amp 2^0
394        1   tone amp 2^1
395        2   tone amp 2^2
396        3   tone amp 2^3
397        4   tone freq sel0
398        5   tone freq sel1
399        6   tone freq sel2
400        7   tone off
401        8   tone / 2^0
402        9   tone / 2^1
403       10   tone / 2^2
404       11   tone / 2^3
405       12   tone / 2^4
406       13   tone / 2^5
407       14   tone / 2^6
408       15   always 0
409    */
410
411   cdp1869->toneamp = word & 0x0f;
412   cdp1869->tonefreq = (word & 0x70) >> 4;
413   cdp1869->toneoff = BIT(word, 7);
414   cdp1869->tonediv = (word & 0x7f00) >> 8;
415
416   // fork out to CDP1869 sound core
417   cdp1869_set_toneamp(0, cdp1869->toneamp);
418   cdp1869_set_tonefreq(0, cdp1869->tonefreq);
419   cdp1869_set_toneoff(0, cdp1869->toneoff);
420   cdp1869_set_tonediv(0, cdp1869->tonediv);
421}
422
423WRITE8_DEVICE_HANDLER( cdp1869_out5_w )
424{
425   cdp1869_t *cdp1869 = get_safe_token(device);
426
427   UINT16 word = cdp1802_get_r_x(cdp1869);
428
429   /*
430      bit   description
431
432        0   cmem access mode
433        1   x
434        2   x
435        3   9-line
436        4   x
437        5   16 line hi-res
438        6   double page
439        7   fres vert
440        8   wn amp 2^0
441        9   wn amp 2^1
442       10   wn amp 2^2
443       11   wn amp 2^3
444       12   wn freq sel0
445       13   wn freq sel1
446       14   wn freq sel2
447       15   wn off
448    */
449
450   cdp1869->cmem = BIT(word, 0);
451   cdp1869->line9 = BIT(word, 3);
452
453   if (cdp1869->intf->pal_ntsc == CDP1869_NTSC)
454   {
455      cdp1869->line16 = BIT(word, 5);
456   }
457
458   cdp1869->dblpage = BIT(word, 6);
459   cdp1869->fresvert = BIT(word, 7);
460
461   cdp1869->wnamp = (word & 0x0f00) >> 8;
462   cdp1869->wnfreq = (word & 0x7000) >> 12;
463   cdp1869->wnoff = BIT(word, 15);
464
465   // fork out to CDP1869 sound core
466   cdp1869_set_wnamp(0, cdp1869->wnamp);
467   cdp1869_set_wnfreq(0, cdp1869->wnfreq);
468   cdp1869_set_wnoff(0, cdp1869->wnoff);
469
470   if (cdp1869->cmem)
471   {
472      cdp1869->pma = word;
473   }
474   else
475   {
476      cdp1869->pma = 0;
477   }
478}
479
480WRITE8_DEVICE_HANDLER( cdp1869_out6_w )
481{
482   cdp1869_t *cdp1869 = get_safe_token(device);
483
484   UINT16 word = cdp1802_get_r_x(cdp1869);
485
486   /*
487      bit   description
488
489        0   pma0 reg
490        1   pma1 reg
491        2   pma2 reg
492        3   pma3 reg
493        4   pma4 reg
494        5   pma5 reg
495        6   pma6 reg
496        7   pma7 reg
497        8   pma8 reg
498        9   pma9 reg
499       10   pma10 reg
500       11   x
501       12   x
502       13   x
503       14   x
504       15   x
505    */
506
507   cdp1869->pma = word & 0x7ff;
508}
509
510WRITE8_DEVICE_HANDLER( cdp1869_out7_w )
511{
512   cdp1869_t *cdp1869 = get_safe_token(device);
513
514   UINT16 word = cdp1802_get_r_x(cdp1869);
515
516   /*
517      bit   description
518
519        0   x
520        1   x
521        2   hma2 reg
522        3   hma3 reg
523        4   hma4 reg
524        5   hma5 reg
525        6   hma6 reg
526        7   hma7 reg
527        8   hma8 reg
528        9   hma9 reg
529       10   hma10 reg
530       11   x
531       12   x
532       13   x
533       14   x
534       15   x
535    */
536
537   cdp1869->hma = word & 0x7fc;
538}
539
540/* Page RAM Access */
541
542READ8_DEVICE_HANDLER( cdp1869_pageram_r )
543{
544   cdp1869_t *cdp1869 = get_safe_token(device);
545
546   UINT16 pma;
547
548   if (cdp1869->cmem)
549   {
550      pma = cdp1869_get_pma(device);
551   }
552   else
553   {
554      pma = offset;
555   }
556
557   return cdp1869->intf->page_ram_r(device, pma);
558}
559
560WRITE8_DEVICE_HANDLER( cdp1869_pageram_w )
561{
562   cdp1869_t *cdp1869 = get_safe_token(device);
563
564   UINT16 pma;
565
566   if (cdp1869->cmem)
567   {
568      pma = cdp1869_get_pma(device);
569   }
570   else
571   {
572      pma = offset;
573   }
574
575   if (cdp1869->intf->page_ram_w)
576   {
577      cdp1869->intf->page_ram_w(device, pma, data);
578   }
579}
580
581/* Character RAM Access */
582
583READ8_DEVICE_HANDLER( cdp1869_charram_r )
584{
585   cdp1869_t *cdp1869 = get_safe_token(device);
586
587   UINT8 cma = offset & 0x0f;
588   UINT16 pma;
589
590   if (cdp1869->cmem)
591   {
592      pma = cdp1869_get_pma(device);
593   }
594   else
595   {
596      pma = offset;
597   }
598
599   if (cdp1869->dblpage)
600   {
601      cma &= 0x07;
602   }
603
604   return cdp1869->intf->char_ram_r(device, pma, cma);
605}
606
607WRITE8_DEVICE_HANDLER( cdp1869_charram_w )
608{
609   cdp1869_t *cdp1869 = get_safe_token(device);
610
611   UINT8 cma = offset & 0x0f;
612   UINT16 pma;
613
614   if (cdp1869->cmem)
615   {
616      pma = cdp1869_get_pma(device);
617   }
618   else
619   {
620      pma = offset;
621   }
622
623   if (cdp1869->dblpage)
624   {
625      cma &= 0x07;
626   }
627
628   if (cdp1869->intf->char_ram_w)
629   {
630      cdp1869->intf->char_ram_w(device, pma, cma, data);
631   }
632}
633
634/* Screen Update */
635
636void cdp1869_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect)
637{
638   cdp1869_t *cdp1869 = get_safe_token(device);
639
640   rectangle screen_rect, outer;
641
642   switch (cdp1869->intf->pal_ntsc)
643   {
644   case CDP1869_NTSC:
645      outer.min_x = CDP1869_HBLANK_END;
646      outer.max_x = CDP1869_HBLANK_START - 1;
647      outer.min_y = CDP1869_SCANLINE_VBLANK_END_NTSC;
648      outer.max_y = CDP1869_SCANLINE_VBLANK_START_NTSC - 1;
649      screen_rect.min_x = CDP1869_SCREEN_START_NTSC;
650      screen_rect.max_x = CDP1869_SCREEN_END - 1;
651      screen_rect.min_y = CDP1869_SCANLINE_DISPLAY_START_NTSC;
652      screen_rect.max_y = CDP1869_SCANLINE_DISPLAY_END_NTSC - 1;
653      break;
654
655   default:
656   case CDP1869_PAL:
657      outer.min_x = CDP1869_HBLANK_END;
658      outer.max_x = CDP1869_HBLANK_START - 1;
659      outer.min_y = CDP1869_SCANLINE_VBLANK_END_PAL;
660      outer.max_y = CDP1869_SCANLINE_VBLANK_START_PAL - 1;
661      screen_rect.min_x = CDP1869_SCREEN_START_PAL;
662      screen_rect.max_x = CDP1869_SCREEN_END - 1;
663      screen_rect.min_y = CDP1869_SCANLINE_DISPLAY_START_PAL;
664      screen_rect.max_y = CDP1869_SCANLINE_DISPLAY_END_PAL - 1;
665      break;
666   }
667
668   sect_rect(&outer, cliprect);
669   bitmap_fill(bitmap, &outer, device->machine->pens[cdp1869->bkg]);
670
671   if (!cdp1869->dispoff)
672   {
673      int sx, sy, rows, cols, width, height;
674      UINT16 addr, pmemsize;
675
676      width = CDP1869_CHAR_WIDTH;
677      height = cdp1869_get_lines(device);
678
679      if (!cdp1869->freshorz)
680      {
681         width *= 2;
682      }
683
684      if (!cdp1869->fresvert)
685      {
686         height *= 2;
687      }
688
689      cols = cdp1869->freshorz ? CDP1869_COLUMNS_FULL : CDP1869_COLUMNS_HALF;
690      rows = (screen_rect.max_y - screen_rect.min_y + 1) / height;
691
692      pmemsize = cdp1869_get_pmemsize(device, cols, rows);
693
694      addr = cdp1869->hma;
695
696      for (sy = 0; sy < rows; sy++)
697      {
698         for (sx = 0; sx < cols; sx++)
699         {
700            int x = sx * width;
701            int y = sy * height;
702
703            cdp1869_draw_char(device, bitmap, x, y, addr, &screen_rect);
704
705            addr++;
706
707            if (addr == pmemsize) addr = 0;
708         }
709      }
710   }
711}
712
713/* Sound Update */
714
715#ifdef UNUSED_FUNCTION
716static void cdp1869_sum_square_wave(stream_sample_t *buffer, double frequency, double amplitude)
717{
718   // do a fast fourier transform on all the waves in the white noise range
719}
720
721static void cdp1869_sound_update(const device_config *device, stream_sample_t **inputs, stream_sample_t **_buffer, int length)
722{
723   cdp1869_t *cdp1869 = get_safe_token(device);
724
725   INT16 signal = cdp1869->signal;
726   stream_sample_t *buffer = _buffer[0];
727
728   memset(buffer, 0, length * sizeof(*buffer));
729
730   if (!cdp1869->toneoff && cdp1869->toneamp)
731   {
732      double frequency = (device->clock / 2) / (512 >> cdp1869->tonefreq) / (cdp1869->tonediv + 1);
733
734      int rate = device->machine->sample_rate / 2;
735
736      /* get progress through wave */
737      int incr = cdp1869->incr;
738
739      if (signal < 0)
740      {
741         signal = -(cdp1869->toneamp * (0x07fff / 15));
742      }
743      else
744      {
745         signal = cdp1869->toneamp * (0x07fff / 15);
746      }
747
748      while( length-- > 0 )
749      {
750         *buffer++ = signal;
751         incr -= frequency;
752         while( incr < 0 )
753         {
754            incr += rate;
755            signal = -signal;
756         }
757      }
758
759      /* store progress through wave */
760      cdp1869->incr = incr;
761      cdp1869->signal = signal;
762   }
763
764    if (!cdp1869->wnoff)
765    {
766      int wndiv;
767        double amplitude = cdp1869->wnamp * ((0.78*5) / 15);
768
769        for (wndiv = 0; wndiv < 128; wndiv++)
770        {
771            double frequency = (device->clock / 2) / (4096 >> cdp1869->wnfreq) / (wndiv + 1);
772
773            cdp1869_sum_square_wave(buffer, frequency, amplitude);
774        }
775    }
776}
777#endif
778
779/* Device Interface */
780
781static DEVICE_START( cdp1869 )
782{
783   const cdp1869_inline *inline_config = device->inline_config;
784   cdp1869_t *cdp1869 = get_safe_token(device);
785
786   // validate arguments
787
788   assert(device != NULL);
789   assert(device->tag != NULL);
790   assert(device->static_config != NULL);
791   assert(inline_config != NULL);
792
793   cdp1869->intf = device->static_config;
794
795   assert(cdp1869->intf->page_ram_r != NULL);
796   assert(cdp1869->intf->pcb_r != NULL);
797   assert(cdp1869->intf->char_ram_r != NULL);
798
799   // set initial values
800
801   cdp1869->toneoff = 1;
802   cdp1869->wnoff = 1;
803
804   // get the screen device
805
806   cdp1869->screen = devtag_get_device(device->machine, VIDEO_SCREEN, inline_config->screen_tag);
807   assert(cdp1869->screen != NULL);
808
809   // get the CPU device
810
811   cdp1869->cpu = cputag_get_cpu(device->machine, inline_config->cpu_tag);
812   assert(cdp1869->cpu != NULL);
813
814   // allocate timers
815
816   if (cdp1869->intf->on_prd_changed != NULL)
817   {
818      cdp1869->prd_changed_timer = timer_alloc(device->machine, prd_changed_tick, (void *)device);
819      update_prd_changed_timer(cdp1869);
820   }
821
822   // register for state saving
823   state_save_register_postload(device->machine, cdp1869_state_save_postload, cdp1869);
824
825   state_save_register_device_item(device, 0, cdp1869->dispoff);
826   state_save_register_device_item(device, 0, cdp1869->fresvert);
827   state_save_register_device_item(device, 0, cdp1869->freshorz);
828   state_save_register_device_item(device, 0, cdp1869->cmem);
829   state_save_register_device_item(device, 0, cdp1869->dblpage);
830   state_save_register_device_item(device, 0, cdp1869->line16);
831   state_save_register_device_item(device, 0, cdp1869->line9);
832   state_save_register_device_item(device, 0, cdp1869->cfc);
833   state_save_register_device_item(device, 0, cdp1869->col);
834   state_save_register_device_item(device, 0, cdp1869->bkg);
835   state_save_register_device_item(device, 0, cdp1869->pma);
836   state_save_register_device_item(device, 0, cdp1869->hma);
837
838   state_save_register_device_item(device, 0, cdp1869->signal);
839   state_save_register_device_item(device, 0, cdp1869->incr);
840   state_save_register_device_item(device, 0, cdp1869->toneoff);
841   state_save_register_device_item(device, 0, cdp1869->wnoff);
842   state_save_register_device_item(device, 0, cdp1869->tonediv);
843   state_save_register_device_item(device, 0, cdp1869->tonefreq);
844   state_save_register_device_item(device, 0, cdp1869->toneamp);
845   state_save_register_device_item(device, 0, cdp1869->wnfreq);
846   state_save_register_device_item(device, 0, cdp1869->wnamp);
847}
848
849static DEVICE_SET_INFO( cdp1869 )
850{
851   switch (state)
852   {
853      /* no parameters to set */
854   }
855}
856
857DEVICE_GET_INFO( cdp1869_video )
858{
859   switch (state)
860   {
861      /* --- the following bits of info are returned as 64-bit signed integers --- */
862      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(cdp1869_t);            break;
863      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = sizeof(cdp1869_inline);         break;
864      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;         break;
865
866      /* --- the following bits of info are returned as pointers to data or functions --- */
867      case DEVINFO_FCT_SET_INFO:                  info->set_info = DEVICE_SET_INFO_NAME(cdp1869); break;
868      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(cdp1869);   break;
869      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
870      case DEVINFO_FCT_RESET:                     /* Nothing */                        break;
871
872      /* --- the following bits of info are returned as NULL-terminated strings --- */
873      case DEVINFO_STR_NAME:                     strcpy(info->s, "RCA CDP1869");            break;
874      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "RCA CDP1800");            break;
875      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                  break;
876      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);               break;
877      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
878   }
879}
src/emu/sound/custom.c
r4427r4428
1#include "sndintrf.h"
2#include "custom.h"
3
4
5struct custom_info
6{
7   const custom_sound_interface *intf;
8   void *      token;
9};
10
11
12
13static SND_START( custom )
14{
15   struct custom_info *info = device->token;
16
17   /* stash a pointer and call the start routine */
18   info->intf = device->static_config;
19   if (info->intf->start)
20   {
21      info->token = (*info->intf->start)(device, clock, device->static_config);
22      assert_always(info->token != NULL, "Error starting custom sound");
23   }
24}
25
26
27static SND_STOP( custom )
28{
29   struct custom_info *info = device->token;
30   if (info->intf->stop)
31      (*info->intf->stop)(device, info->token);
32}
33
34
35static SND_RESET( custom )
36{
37   struct custom_info *info = device->token;
38   if (info->intf->reset)
39      (*info->intf->reset)(device, info->token);
40}
41
42
43void *custom_get_token(int index)
44{
45   struct custom_info *token = sndti_token(SOUND_CUSTOM, index);
46   return token->token;
47}
48
49
50
51/**************************************************************************
52 * Generic get_info
53 **************************************************************************/
54
55static SND_SET_INFO( custom )
56{
57   switch (state)
58   {
59      /* no parameters to set */
60   }
61}
62
63
64SND_GET_INFO( custom )
65{
66   switch (state)
67   {
68      /* --- the following bits of info are returned as 64-bit signed integers --- */
69      case SNDINFO_INT_TOKEN_BYTES:               info->i = sizeof(struct custom_info);         break;
70
71      /* --- the following bits of info are returned as pointers to data or functions --- */
72      case SNDINFO_PTR_SET_INFO:                  info->set_info = SND_SET_INFO_NAME( custom );   break;
73      case SNDINFO_PTR_START:                     info->start = SND_START_NAME( custom );         break;
74      case SNDINFO_PTR_STOP:                     info->stop = SND_STOP_NAME( custom );         break;
75      case SNDINFO_PTR_RESET:                     info->reset = SND_RESET_NAME( custom );         break;
76
77      /* --- the following bits of info are returned as NULL-terminated strings --- */
78      case SNDINFO_STR_NAME:                     strcpy(info->s, "Custom");                  break;
79      case SNDINFO_STR_CORE_FAMILY:               strcpy(info->s, "None");                  break;
80      case SNDINFO_STR_CORE_VERSION:               strcpy(info->s, "1.0");                     break;
81      case SNDINFO_STR_CORE_FILE:                  strcpy(info->s, __FILE__);                  break;
82      case SNDINFO_STR_CORE_CREDITS:               strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
83   }
84}
85
src/emu/sound/custom.h
r4427r4428
1#pragma once
2
3#ifndef __CUSTOM_H__
4#define __CUSTOM_H__
5
6typedef struct _custom_sound_interface custom_sound_interface;
7struct _custom_sound_interface
8{
9   void *(*start)(const device_config *device, int clock, const custom_sound_interface *config);
10   void (*stop)(const device_config *device, void *token);
11   void (*reset)(const device_config *device, void *token);
12   void *extra_data;
13};
14
15void *custom_get_token(int index);
16
17#define CUSTOM_START(name) void *name(const device_config *device, int clock, const custom_sound_interface *config)
18#define CUSTOM_STOP(name) void name(const device_config *device, void *token)
19#define CUSTOM_RESET(name) void name(const device_config *device, void *token)
20
21SND_GET_INFO( custom );
22#define SOUND_CUSTOM SND_GET_INFO_NAME( custom )
23
24#endif /* __CUSTOM_H__ */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team