Previous 15994 Revisions Next

r15219 Saturday 19th May, 2012 at 09:17:59 UTC by Miodrag Milanović
Sync with MAME r16343 (nw)
[src/emu]info.c info.h ioport.c
[src/emu/sound]pokey.c pokey.h
[src/emu/video]psx.c
[src/ldplayer]ldplayer.c ldplayer.mak
[src/lib/util]chd.c
[src/mame]mame.lst
[src/mame/audio]bzone.c
[src/mame/drivers]8080bw.c atarigt.c atarigx2.c blitz68k.c bzone.c ccastles.c crgolf.c decocass.c dkong.c feversoc.c flyball.c galdrvr.c itech8.c ksys573.c mcr.c megatech.c missile.c namcops2.c namcos21.c xmen.c
[src/mame/includes]astrocde.h
[src/mame/video]astrocde.c bfm_dm01.c gsword.c

src/mame/mame.lst
r15218r15219
238238checkmanj      // (c) 1982 Jaleco (Zenitone/Zilec in ROM CM4, and the programmer names)
239239dingo         // (c) 1983 Ashby Computers and Graphics LTD. + Jaleco license
240240dingoe         // (c) 1983 Ashby Computers and Graphics LTD. + Jaleco license
241blkhole         // TDS (Tokyo Denshi Sekkei)
241blkhole         // TDS (Tokyo Denshi Sekkei) & MINTS
242242kingball      // (c) 1980 Namco
243243kingballj      // (c) 1980 Namco
244244scorpionmc      // bootleg
r15218r15219
951951solvalou      // (c) 1991 (Japan)
952952starblad      // (c) 1991
953953driveyes      // (c) 1992?
954            // 1992, ShimDrive
954            // 1992, SimDrive
955955aircomb         // (c) 1992 (US)
956956aircombj      // (c) 1992 (Japan)
957957cybsled         // (c) 1993
r15218r15219
14311431spceking      // (c) 1978 Leijac Corporation (Konami)
14321432spcewars      // (c) 1978 Sanritsu
14331433astropal      // (c) 19?? Sidam
1434cosmo         // TDS+Mints
1434cosmo         // TDS & Mints
14351435darthvdr      // bootleg
14361436
1437143718w            // 653 (c) 1979 Midway
r15218r15219
35533553
35543554// Konami System 573
35553555sys573
3556hndlchmp      // 1997 - Handle Champ (GQ710 VER. JAA)
35563557darkhleg      // 1998 - Dark Horse Legend (GX706 VER. JAA)
35573558fbaitbc         // 1998 - Fisherman's Bait - A Bass Challenge (GE765 VER. UAB)
35583559bassangl      // 1998 - Bass Angler (GE765 VER. JAA)
src/mame/audio/bzone.c
r15218r15219
400400
401401   MCFG_SPEAKER_STANDARD_MONO("mono")
402402
403   MCFG_SOUND_ADD("pokey",  POKEY, BZONE_MASTER_CLOCK / 8)
403   MCFG_SOUND_ADD("pokey",  POKEYN, BZONE_MASTER_CLOCK / 8)
404404   MCFG_SOUND_CONFIG(bzone_pokey_interface)
405405   MCFG_SOUND_ROUTE_EX(0, "discrete", 1.0, 0)
406406
src/mame/includes/astrocde.h
r15218r15219
4242   UINT8 m_vertical_feedback;
4343   UINT8 m_horizontal_feedback;
4444   emu_timer *m_scanline_timer;
45   emu_timer *m_intoff_timer;
4546   UINT8 m_colors[8];
4647   UINT8 m_colorsplit;
4748   UINT8 m_bgdata;
src/mame/video/astrocde.c
r15218r15219
3232
3333static void init_savestate(running_machine &machine);
3434static TIMER_CALLBACK( scanline_callback );
35static TIMER_CALLBACK( interrupt_off );
3536static void init_sparklestar(running_machine &machine);
3637
3738
r15218r15219
162163VIDEO_START( astrocde )
163164{
164165   astrocde_state *state = machine.driver_data<astrocde_state>();
165   /* allocate a per-scanline timer */
166
167   /* allocate timers */
166168   state->m_scanline_timer = machine.scheduler().timer_alloc(FUNC(scanline_callback));
167169   state->m_scanline_timer->adjust(machine.primary_screen->time_until_pos(1), 1);
170   state->m_intoff_timer = machine.scheduler().timer_alloc(FUNC(interrupt_off));
168171
169172   /* register for save states */
170173   init_savestate(machine);
r15218r15219
178181VIDEO_START( profpac )
179182{
180183   astrocde_state *state = machine.driver_data<astrocde_state>();
181   /* allocate a per-scanline timer */
184
185   /* allocate timers */
182186   state->m_scanline_timer = machine.scheduler().timer_alloc(FUNC(scanline_callback));
183187   state->m_scanline_timer->adjust(machine.primary_screen->time_until_pos(1), 1);
188   state->m_intoff_timer = machine.scheduler().timer_alloc(FUNC(interrupt_off));
184189
185190   /* allocate videoram */
186191   state->m_profpac_videoram = auto_alloc_array(machine, UINT16, 0x4000 * 4);
r15218r15219
389394      if ((state->m_interrupt_enabl & 0x01) == 0)
390395      {
391396         cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, state->m_interrupt_vector & 0xf0);
392         machine.scheduler().timer_set(machine.primary_screen->time_until_pos(vfeedback), FUNC(interrupt_off));
397         state->m_intoff_timer->adjust(machine.primary_screen->time_until_pos(vfeedback));
393398      }
394399
395400      /* mode 1 means assert for 1 instruction */
396401      else
397402      {
398403         cputag_set_input_line_and_vector(machine, "maincpu", 0, ASSERT_LINE, state->m_interrupt_vector & 0xf0);
399         machine.scheduler().timer_set(machine.device<cpu_device>("maincpu")->cycles_to_attotime(1), FUNC(interrupt_off));
404         state->m_intoff_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(1));
400405      }
401406
402407      /* latch the feedback registers */
src/mame/video/gsword.c
r15218r15219
99#include "includes/gsword.h"
1010
1111
12static PALETTE_INIT( common )
13{
14   const UINT8 *color_prom = machine.root_device().memregion("proms")->base();
15   int i;
16
17   /* characters */
18   for (i = 0; i < 0x100; i++)
19      colortable_entry_set_value(machine.colortable, i, i);
20
21   /* sprites */
22   for (i = 0x100; i < 0x200; i++)
23   {
24      UINT8 ctabentry = (BITSWAP8(color_prom[i - 0x100],7,6,5,4,0,1,2,3) & 0x0f) | 0x80;
25      colortable_entry_set_value(machine.colortable, i, ctabentry);
26   }
27}
28
29
3012PALETTE_INIT( josvolly )
3113{
3214   const UINT8 *color_prom = machine.root_device().memregion("proms")->base();
r15218r15219
4830   /* color_prom now points to the beginning of the lookup table */
4931   color_prom += 0x300;
5032
51   PALETTE_INIT_CALL(common);
33   /* characters */
34   for (i = 0; i < 0x100; i++)
35      colortable_entry_set_value(machine.colortable, i, i);
36
37   /* sprites */
38   for (i = 0x100; i < 0x200; i++)
39   {
40      UINT8 ctabentry = (BITSWAP8(color_prom[i - 0x100],7,6,5,4,0,1,2,3) & 0x0f) | 0x80;
41      colortable_entry_set_value(machine.colortable, i, ctabentry);
42   }
5243}
5344
5445
r15218r15219
9081   /* color_prom now points to the beginning of the lookup table */
9182   color_prom += 0x200;
9283
93   PALETTE_INIT_CALL(common);
84   /* characters */
85   for (i = 0; i < 0x100; i++)
86      colortable_entry_set_value(machine.colortable, i, i);
87
88   /* sprites */
89   for (i = 0x100; i < 0x200; i++)
90   {
91      UINT8 ctabentry = (BITSWAP8(color_prom[i - 0x100],7,6,5,4,0,1,2,3) & 0x0f) | 0x80;
92      colortable_entry_set_value(machine.colortable, i, ctabentry);
93   }
9494}
9595
9696WRITE8_MEMBER(gsword_state::gsword_videoram_w)
src/mame/video/bfm_dm01.c
r15218r15219
146146      dm01.scanline[8] &= 0x80;//filter all other bits
147147      if ( (row >= 0)  && (row < DM_MAXLINES) )
148148      {
149         int p,pos;
150         pos =0;
151         p = 0;
149         int p = 0;
152150
153151         while ( p < (DM_BYTESPERROW) )
154152         {
src/mame/drivers/ccastles.c
r15218r15219
333333   AM_RANGE(0x9000, 0x90ff) AM_MIRROR(0x0300) AM_READWRITE(nvram_r, nvram_w)
334334   AM_RANGE(0x9400, 0x9403) AM_MIRROR(0x01fc) AM_READ(leta_r)
335335   AM_RANGE(0x9600, 0x97ff) AM_READ_PORT("IN0")
336   AM_RANGE(0x9800, 0x980f) AM_MIRROR(0x01f0) AM_DEVREADWRITE_LEGACY("pokey1", pokey_r, pokey_w)
337   AM_RANGE(0x9a00, 0x9a0f) AM_MIRROR(0x01f0) AM_DEVREADWRITE_LEGACY("pokey2", pokey_r, pokey_w)
336   AM_RANGE(0x9800, 0x980f) AM_MIRROR(0x01f0) AM_DEVREADWRITE("pokey1", pokeyn_device, read, write)
337   AM_RANGE(0x9a00, 0x9a0f) AM_MIRROR(0x01f0) AM_DEVREADWRITE("pokey2", pokeyn_device, read, write)
338338   AM_RANGE(0x9c00, 0x9c7f) AM_WRITE(nvram_recall_w)
339339   AM_RANGE(0x9c80, 0x9cff) AM_WRITE(ccastles_hscroll_w)
340340   AM_RANGE(0x9d00, 0x9d7f) AM_WRITE(ccastles_vscroll_w)
r15218r15219
495495   /* sound hardware */
496496   MCFG_SPEAKER_STANDARD_MONO("mono")
497497
498   MCFG_SOUND_ADD("pokey1", POKEY, MASTER_CLOCK/8)
498   MCFG_SOUND_ADD("pokey1", POKEYN, MASTER_CLOCK/8)
499499   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
500500
501   MCFG_SOUND_ADD("pokey2", POKEY, MASTER_CLOCK/8)
501   MCFG_SOUND_ADD("pokey2", POKEYN, MASTER_CLOCK/8)
502502   MCFG_SOUND_CONFIG(pokey_config)
503503   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
504504MACHINE_CONFIG_END
src/mame/drivers/namcops2.c
r15218r15219
1818    Copyright Nicola Salmoria and the MAME Team.
1919    Visit http://mamedev.org for licensing and usage restrictions.
2020
21
22List of Namco System 246 games:
23* Battle Gear 3 (Taito, 2002)
24* Battle Gear 3 Tuned (Taito, 2003)
25* Bloody Roar 3 (Namco / 8ing / Raizing, 2000)
26* Capcom Fighting Jam (Capcom, 2004)
27* Cobra: The Arcade (Namco, 2004)
28* Dragon Chronicles (Namco, 2002)
29* Fate/Unlimited Codes (Capcom / Type-Moon / Cavia / 8ing, 2008)
30* Getchu Play! Tottoko Hamutaro (Banpresto, 2007)
31* Mobile Suit Gundam SEED: Federation Vs. Z.A.F.T. (Capcom / Banpresto, 2005)
32* Mobile Suit Gundam SEED Destiny: Federation Vs. Z.A.F.T. II (Banpresto, 2006)
33* Mobile Suit Gundam Z: AEUG Vs. Titans (Capcom / Banpresto, 2003)
34* Mobile Suit Gundam Z: AEUG Vs. Titans DX (Capcom / Banpresto, 2004)
35* Minnade Kitaeru Zennou Training (Namco, 2006)
36* Netchuu Pro Yakyuu 2002 (Namco, 2002)
37* Pride GP 2003 (Capcom, 2003)
38* Quiz and Variety Sukusuku Inufuku 2 (Namco / AMI / Hamster, 2007)
39* Quiz Mobile Suit Gundam: Tou. Senshi (Banpresto, 2006)
40* Raizin Ping Pong (Taito, 2001)
41* Ridge Racer V: Arcade Battle (Namco, 2000)
42* Sengoku Basara X Cross (Capcom / ARC System Works, 2008)
43* Smash Court Pro Tournament (Namco, 2001)
44* Soul Calibur II (Namco, 2002)
45* Soul Calibur II Ver.D (Namco, 2003)
46* Soul Calibur III Arcade Edition (Namco, 2006)
47* Taiko No Tatsujin 7 (Namco, 2005)
48* Taiko No Tatsujin 8 (Namco, 2006)
49* Technic Beat (Arika, 2002)
50* Tekken 4 (Namco, 2001)
51* Time Crisis 3 (Namco, 2002)
52* Vampire Night (Namco / Sega / WOW Entertainment, 2000)
53* Wangan Midnight (Namco, 2001)
54* Wangan Midnight R (Namco, 2002)
55* Zoids Infinity (Taito, 2004)
56
57List of Namco System 256 Games
58* Chou Dragon Ball Z (Banpresto, 2005)
59* Druaga Online - The Story of Aon (Namco, 2005)
60* Kinnikuman Muscle Grand Prix (Banpresto, 2006)
61* Kinnikuman Muscle Grand Prix 2 (Banpresto, 2007)
62* Kinnikuman Muscle Grand Prix 2 Tokumori (Banpresto, 2008)
63* Mobile Suit Gundam SEED Destiny: Federation Vs. Z.A.F.T. II (Banpresto, 2006)
64* Mobile Suit Gundam: Gundam Vs. Gundam (Banpresto, 2008)
65* Mobile Suit Gundam: Gundam Vs. Gundam Next (Banpresto, 2009)
66* Quiz and Variety Sukusuku Inufuku 2 (Namco / AMI / Hamster, 2007)
67* Sengoku Basara X Cross (Capcom / ARC System Works, 2008)
68* Taiko No Tatsujin 9 (Namco, 2006)
69* Taiko No Tatsujin 10 (Namco, 2007)
70* Taiko No Tatsujin 11 (Namco, 2008)
71* Taiko No Tatsujin 12 (Namco, 2008)
72* Taiko No Tatsujin 12 Don! (Namco, 2009)
73* Taiko No Tatsujin 13 (Namco, 2009)
74* Taiko No Tatsujin 14 (Namco, 2010)
75* Tekken 5 (Namco, 2004)
76* Tekken 5.1 (Namco, 2005)
77* Tekken 5 Dark Resurrection (Namco, 2005)
78* The Battle of YuYu Hakusho (Banpresto, 2006)
79* THE iDOLM@STER (Namco, 2005)
80* Zoids Infinity EX (Taito, 2005)
81* Zoids Infinity EX Plus (Taito, 2006)
82
83List of System Super 256 Games
84* Time Crisis 4 (Namco, 2006)
85
2186***************************************************************************/
2287
2388
src/mame/drivers/namcos21.c
r15218r15219
25052505GAME( 1991, driveyes, 0,       driveyes,          winrun,       driveyes, ROT0,    "Namco", "Driver's Eyes (US)",                    GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS )
25062506GAME( 1991, solvalou, 0,       poly_c140_typeA,   s21default,   solvalou, ROT0,    "Namco", "Solvalou (Japan)",                      GAME_IMPERFECT_GRAPHICS )
25072507GAME( 1991, starblad, 0,       poly_c140_typeA,   s21default,   starblad, ROT0,    "Namco", "Starblade (Japan)",                     GAME_IMPERFECT_GRAPHICS )
2508/* 1992, ShimDrive */
2508/* 1992, SimDrive */
25092509GAME( 1992, aircomb,  0,       poly_c140_typeB,   aircombt,     aircombt, ROT0,    "Namco", "Air Combat (US)",                        GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS )
25102510GAME( 1992, aircombj, aircomb, poly_c140_typeB,   aircombt,     aircombt, ROT0,    "Namco", "Air Combat (Japan)",                    GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS )
25112511GAME( 1993, cybsled,  0,       poly_c140_typeA,   cybsled,      cybsled,  ROT0,    "Namco", "Cyber Sled (US)",                       GAME_IMPERFECT_GRAPHICS )
src/mame/drivers/megatech.c
r15218r15219
611611
612612
613613/* MegaTech Games - Genesis & sms! Games with a timer */
614/* epr-12253b.20 is known to exist (Version 0 - Revision B) */
614615
615616#define MEGATECH_BIOS \
616617   ROM_REGION( 0x400000, "maincpu", ROMREGION_ERASEFF ) \
617618   ROM_REGION( 0x10000, "mtbios", 0 ) \
618   ROM_LOAD( "epr12664.20", 0x000000, 0x8000, CRC(f71e9526) SHA1(1c7887541d02c41426992d17f8e3db9e03975953) ) \
619   ROM_SYSTEM_BIOS( 0, "ver1", "Ver 1" ) \
620   ROMX_LOAD( "epr-12664.20",  0x000000, 0x8000, CRC(f71e9526) SHA1(1c7887541d02c41426992d17f8e3db9e03975953), ROM_BIOS(1)) \
621   ROM_SYSTEM_BIOS( 1, "ver0", "Ver 0" ) \
622   ROMX_LOAD( "epr-12263a.20", 0x000000, 0x8000, CRC(07c3f423) SHA1(50c28bbc2d4349c820d988ae3f20aae3f808545f), ROM_BIOS(2)) \
619623
620624/* no games */
621625ROM_START( megatech )
src/mame/drivers/galdrvr.c
r15218r15219
63766376GAME( 19??, tst_galx, galaxian, galaxian, galaxian, galaxian, ROT90,  "<unknown>", "Galaxian Test ROM", GAME_SUPPORTS_SAVE )
63776377
63786378/* other games on basic galaxian hardware */
6379GAME( 1981, blkhole,  0,        galaxian, blkhole,  galaxian, ROT90,  "TDS", "Black Hole", GAME_SUPPORTS_SAVE )
6379GAME( 1981, blkhole,  0,        galaxian, blkhole,  galaxian, ROT90,  "TDS & MINTS", "Black Hole", GAME_SUPPORTS_SAVE )
63806380GAME( 1982, orbitron, 0,        galaxian, orbitron, galaxian, ROT270, "Signatron USA", "Orbitron", GAME_SUPPORTS_SAVE )
63816381GAME( 1980, luctoday, 0,        galaxian, luctoday, galaxian, ROT270, "Sigma", "Lucky Today",GAME_WRONG_COLORS | GAME_SUPPORTS_SAVE )
63826382GAME( 19??, chewing,  luctoday, galaxian, luctoday, galaxian, ROT90,  "<unknown>", "Chewing Gum", GAME_SUPPORTS_SAVE )
src/mame/drivers/missile.c
r15218r15219
714714WRITE8_MEMBER(missile_state::missile_w)
715715{
716716   UINT8 *videoram = m_videoram;
717
717718   /* if we're in MADSEL mode, write to video RAM */
718719   if (get_madsel(&space))
719720   {
r15218r15219
730731
731732   /* POKEY */
732733   else if (offset < 0x4800)
733      pokey_w(machine().device("pokey"), offset & 0x0f, data);
734   {
735      pokeyn_device *pokey_dev = downcast<pokeyn_device *>(machine().device("pokey"));
736      pokey_dev->write(*machine().firstcpu->space(), offset, data, 0xff);
737   }
734738
735739   /* OUT0 */
736740   else if (offset < 0x4900)
r15218r15219
790794
791795   /* POKEY */
792796   else if (offset < 0x4800)
793      result = pokey_r(machine().device("pokey"), offset & 0x0f);
797   {
798      pokeyn_device *pokey_dev = downcast<pokeyn_device *>(machine().device("pokey"));
799      result = pokey_dev->read(*machine().firstcpu->space(), offset & 0x0f, 0xff);
800   }
794801
795802   /* IN0 */
796803   else if (offset < 0x4900)
r15218r15219
10461053   /* sound hardware */
10471054   MCFG_SPEAKER_STANDARD_MONO("mono")
10481055
1049   MCFG_SOUND_ADD("pokey", POKEY, MASTER_CLOCK/8)
1056   MCFG_SOUND_ADD("pokey", POKEYN, MASTER_CLOCK/8)
10501057   MCFG_SOUND_CONFIG(pokey_config)
10511058   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
10521059MACHINE_CONFIG_END
src/mame/drivers/crgolf.c
r15218r15219
9696
9797READ8_MEMBER(crgolf_state::analog_input_r)
9898{
99   return ((ioport("STICK1")->read() & 0xf0)) ^ 0x88;
99   return ((ioport("STICK0")->read() >> 4) | (ioport("STICK1")->read() & 0xf0)) ^ 0x88;
100100}
101101
102102
src/mame/drivers/feversoc.c
r15218r15219
136136
137137READ32_MEMBER(feversoc_state::in0_r)
138138{
139
139   UINT32 io0 = (ioport("IN1")->read()&0xffff) << 16;
140   UINT32 io1 = (ioport("IN0")->read()&0xffff) << 0;
140141   m_x^=0x40; //vblank? eeprom read bit?
141   return (ioport("IN1")->read()<<16);
142   return io0 | io1 | m_x;
142143}
143144
144145WRITE32_MEMBER(feversoc_state::output_w)
r15218r15219
205206   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) ) //hopper i/o
206207   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
207208   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
208//  PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) ) //vblank/eeprom read bit?
209//  PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
210//  PORT_DIPSETTING(    0x00, DEF_STR( On ) )
209   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // maybe eeprom in / vblank
211210   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNUSED ) //PORT_NAME("Slottle") PORT_CODE(KEYCODE_Z)
212211   PORT_DIPNAME( 0x0100, 0x0100, "DIP 1-1" )
213212   PORT_DIPSETTING(    0x0100, DEF_STR( Off ) )
src/mame/drivers/mcr.c
r15218r15219
339339   if (mcr_cocktail_flip)
340340      return ioport("ssio:IP0")->read() | 0x08;
341341   else
342      return ((ioport("ssio:IP2")->read() & 0x01) << 4);
342      return ((ioport("ssio:IP0")->read() & ~0x14) | 0x08) | ((ioport("ssio:IP0")->read() & 0x08) >> 1) | ((ioport("ssio:IP2")->read() & 0x01) << 4);
343343}
344344
345345
src/mame/drivers/bzone.c
r15218r15219
309309   AM_RANGE(0x1800, 0x1800) AM_DEVREAD_LEGACY("mathbox", mathbox_status_r)
310310   AM_RANGE(0x1810, 0x1810) AM_DEVREAD_LEGACY("mathbox", mathbox_lo_r)
311311   AM_RANGE(0x1818, 0x1818) AM_DEVREAD_LEGACY("mathbox", mathbox_hi_r)
312   AM_RANGE(0x1820, 0x182f) AM_DEVREADWRITE_LEGACY("pokey", pokey_r, pokey_w)
312//   AM_RANGE(0x1820, 0x182f) AM_DEVREADWRITE_LEGACY("pokey", pokey_r, pokey_w)
313   AM_RANGE(0x1820, 0x182f) AM_DEVREADWRITE("pokey", pokeyn_device, read, write)
313314   AM_RANGE(0x1840, 0x1840) AM_DEVWRITE_LEGACY("discrete", bzone_sounds_w)
314315   AM_RANGE(0x1860, 0x187f) AM_DEVWRITE_LEGACY("mathbox", mathbox_go_w)
315316   AM_RANGE(0x2000, 0x2fff) AM_RAM AM_BASE_LEGACY(&avgdvg_vectorram) AM_SIZE_LEGACY(&avgdvg_vectorram_size) AM_REGION("maincpu", 0x2000)
r15218r15219
333334   AM_RANGE(0x1808, 0x1808) AM_DEVWRITE_LEGACY("custom", redbaron_joysound_w)   /* and select joystick pot also */
334335   AM_RANGE(0x180a, 0x180a) AM_WRITENOP            /* sound reset, yet todo */
335336   AM_RANGE(0x180c, 0x180c) AM_DEVWRITE("earom", atari_vg_earom_device, ctrl_w)
336   AM_RANGE(0x1810, 0x181f) AM_DEVREADWRITE_LEGACY("pokey", pokey_r, pokey_w)
337   //AM_RANGE(0x1810, 0x181f) AM_DEVREADWRITE_LEGACY("pokey", pokey_r, pokey_w)
338   AM_RANGE(0x1820, 0x182f) AM_DEVREADWRITE("pokey", pokeyn_device, read, write)
337339   AM_RANGE(0x1820, 0x185f) AM_DEVREADWRITE("earom", atari_vg_earom_device, read, write)
338340   AM_RANGE(0x1860, 0x187f) AM_DEVWRITE_LEGACY("mathbox", mathbox_go_w)
339341   AM_RANGE(0x2000, 0x2fff) AM_RAM AM_BASE_LEGACY(&avgdvg_vectorram) AM_SIZE_LEGACY(&avgdvg_vectorram_size) AM_REGION("maincpu", 0x2000)
r15218r15219
600602   /* sound hardware */
601603   MCFG_SPEAKER_STANDARD_MONO("mono")
602604
603   MCFG_SOUND_ADD("pokey", POKEY, 1500000)
605   MCFG_SOUND_ADD("pokey", POKEYN, 1500000)
604606   MCFG_SOUND_CONFIG(redbaron_pokey_interface)
605607   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
606608
src/mame/drivers/dkong.c
r15218r15219
732732    else
733733    {
734734        /* Steering Wheel inputs */
735        return (ioport("IN4")->read() & 3);
735        return (ioport("IN0")->read() & ~3) | (ioport("IN4")->read() & 3);
736736    }
737737}
738738
r15218r15219
747747    else
748748    {
749749        /* Steering Wheel inputs */
750        return (ioport("IN5")->read() & 3);
750        return (ioport("IN1")->read() & ~3) | (ioport("IN5")->read() & 3);
751751    }
752752}
753753
src/mame/drivers/itech8.c
r15218r15219
11041104{
11051105   const char *tag1 = (const char *)param;
11061106   const char *tag2 = tag1 + strlen(tag1) + 1;
1107   return ioport(tag2)->read();
1107   return ioport(tag1)->read() & ioport(tag2)->read();
11081108}
11091109
11101110static INPUT_PORTS_START( gtg )
src/mame/drivers/blitz68k.c
r15218r15219
11561156READ16_MEMBER(blitz68k_state::hermit_track_r)
11571157{
11581158#ifdef MAME_DEBUG
1159//  popmessage("track %02x %02x", ioport("TRACK_Y")->read());
1159//  popmessage("track %02x %02x", ioport("TRACK_X")->read(), ioport("TRACK_Y")->read());
11601160#endif
11611161
11621162   return
src/mame/drivers/flyball.c
r15218r15219
173173/* two physical buttons (start game and stop runner) share the same port bit */
174174READ8_MEMBER(flyball_state::flyball_input_r)
175175{
176   return ioport("IN1")->read();
176   return ioport("IN0")->read() & ioport("IN1")->read();
177177}
178178
179179READ8_MEMBER(flyball_state::flyball_scanline_r)
src/mame/drivers/8080bw.c
r15218r15219
34533453GAME( 1979, invadpt2br,invadpt2,invadpt2, invadpt2, 0, ROT270, "Taito do Brasil", "Space Invaders Part II (Brazil)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND )
34543454GAME( 1980, invaddlx, invadpt2, invaders, invadpt2, 0, ROT270, "Taito (Midway license)", "Space Invaders Deluxe", GAME_SUPPORTS_SAVE )
34553455GAME( 1980, vortex,   0,        vortex,   vortex, vortex, ROT270, "Zilec Electronics", "Vortex", GAME_IMPERFECT_COLORS | GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND ) /* Encrypted 8080/IO */
3456GAME( 1979, cosmo,    0,        cosmo,    cosmo,    0, ROT90,  "TDS & Mints", "Cosmo", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND )
3456GAME( 1979, cosmo,    0,        cosmo,    cosmo,    0, ROT90,  "TDS & MINTS", "Cosmo", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND )
34573457GAME( 1979, schaser,  0,        schaser,  schaser,  0, ROT270, "Taito", "Space Chaser", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_COLORS )
34583458GAME( 1979, schasercv,schaser,  schasercv,schasercv,0, ROT270, "Taito", "Space Chaser (CV version)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_COLORS )
34593459GAME( 1979, sflush,   0,        sflush,   sflush,   0, ROT270, "Taito", "Straight Flush",GAME_SUPPORTS_SAVE | GAME_NO_SOUND | GAME_IMPERFECT_COLORS | GAME_NO_COCKTAIL)
src/mame/drivers/ksys573.c
r15218r15219
108108N *GUITARFREAKS 11thMIX                         2004.04
109109G *Gun Mania                                    2000.07    G?906 JA          (no CD)
110110? *Gun Mania Zone Plus                          2000.10
111P Handle Champ                                  1997.12    GQ710 JA          (no CD)
111112P Hyper Bishi Bashi Champ                       1998.07    GC876 EA          (no CD)
112113P Hyper Bishi Bashi Champ - 2 Player            1999.08    GC908 JA          908    A02
113114P Jikkyou Powerful Pro Yakyuu EX                1998.04    GX802 JA          802 JA B02
r15218r15219
36123613   PORT_BIT( 0x00000080, IP_ACTIVE_HIGH, IPT_BUTTON8 ) PORT_PLAYER(4) PORT_CODE(KEYCODE_I)
36133614INPUT_PORTS_END
36143615
3616static INPUT_PORTS_START( hndlchmp )
3617   PORT_INCLUDE( konami573 )
3618
3619   PORT_START( "analog0" )
3620   PORT_BIT( 0xff, 0xc0, IPT_PEDAL ) PORT_MINMAX( 0xc0, 0xf0 ) PORT_SENSITIVITY( 100 ) PORT_KEYDELTA( 20 ) PORT_PLAYER( 2 )
3621
3622   PORT_START( "analog1" )
3623   PORT_BIT( 0xff, 0xc0, IPT_PEDAL ) PORT_MINMAX( 0xc0, 0xf0 ) PORT_SENSITIVITY( 100 ) PORT_KEYDELTA( 20 ) PORT_PLAYER( 1 )
3624
3625   PORT_START( "analog2" )
3626   PORT_BIT( 0xff, 0x7f, IPT_PADDLE ) PORT_MINMAX( 0x48, 0xb7 ) PORT_SENSITIVITY( 25 ) PORT_KEYDELTA( 30 ) PORT_PLAYER( 2 )
3627
3628   PORT_START( "analog3" )
3629   PORT_BIT( 0xff, 0x7f, IPT_PADDLE ) PORT_MINMAX( 0x48, 0xb7 ) PORT_SENSITIVITY( 25 ) PORT_KEYDELTA( 30 ) PORT_PLAYER( 1 )
3630INPUT_PORTS_END
3631
36153632static INPUT_PORTS_START( hyperbbc )
36163633   PORT_INCLUDE( konami573 )
36173634
r15218r15219
36993716
37003717#define SYS573_BIOS_A \
37013718   ROM_REGION32_LE( 0x080000, "bios", 0 ) \
3702   ROM_LOAD( "700a01.22g",   0x0000000, 0x080000, CRC(11812ef8) SHA1(e1284add4aaddd5337bd7f4e27614460d52b5b48))
3719   ROM_SYSTEM_BIOS( 0, "std",        "Standard" ) \
3720   ROMX_LOAD( "700a01.22g",   0x0000000, 0x080000, CRC(11812ef8) SHA1(e1284add4aaddd5337bd7f4e27614460d52b5b48), ROM_BIOS(1) ) \
3721   ROM_SYSTEM_BIOS( 1, "gchgchmp",   "Found on Gachagachamp" ) \
3722   ROMX_LOAD( "700_a01.22g",  0x000000,  0x080000, CRC(39ebb0ca) SHA1(9aab8c637dd2be84d79007e52f108abe92bf29dd), ROM_BIOS(2) ) \
3723   ROM_SYSTEM_BIOS( 2, "dsem2",      "Found on Dancing Stage Euro Mix 2" ) \
3724   ROMX_LOAD( "700b01.22g",   0x0000000, 0x080000, CRC(6cf852af) NO_DUMP, ROM_BIOS(3) )
37033725
37043726#define SYS573_DIGITAL_ID \
37053727   ROM_REGION( 0x000008, "digital_id", 0 ) /* digital board id */      \
r15218r15219
48174839   DISK_IMAGE_READONLY( "918xxb02", 0, BAD_DUMP SHA1(8ced8952fff3e70ce0621a491f0973af5a6ccd82) )
48184840ROM_END
48194841
4842ROM_START( hndlchmp )
4843   SYS573_BIOS_A
4844
4845   ROM_REGION( 0x200000, "onboard.0", 0 ) /* onboard flash */
4846   ROM_LOAD( "710ja.31m",    0x000000, 0x200000, CRC(f5f71b1d) SHA1(7d518e5333f44e6ec921a1e882df970953814b6e) )
4847   ROM_REGION( 0x200000, "onboard.1", 0 ) /* onboard flash */
4848   ROM_LOAD( "710ja.27m",    0x000000, 0x200000, CRC(b3d8c037) SHA1(678b88c37111d1fde8996c7d71b66ec1c4f161fe) )
4849   ROM_REGION( 0x200000, "onboard.2", 0 ) /* onboard flash */
4850   ROM_LOAD( "710ja.31l",    0x000000, 0x200000, CRC(78e8556c) SHA1(9f6bb651ddeb042ebf1ba057d4932494149f47d6) )
4851   ROM_REGION( 0x200000, "onboard.3", 0 ) /* onboard flash */
4852   ROM_LOAD( "710ja.27l",    0x000000, 0x200000, CRC(f6a87155) SHA1(269bfdf05ee4ab2e4b87b6e92045e56d0557a576) )
4853   ROM_REGION( 0x200000, "onboard.4", 0 ) /* onboard flash */
4854   ROM_LOAD( "710ja.31j",    0x000000, 0x200000, CRC(bdc05d16) SHA1(ee397950f7e7e910fdc05737f99604e43d288719) )
4855   ROM_REGION( 0x200000, "onboard.5", 0 ) /* onboard flash */
4856   ROM_LOAD( "710ja.27j",    0x000000, 0x200000, CRC(ad925ed3) SHA1(e3222308961851cccee2de9da804f74854907451) )
4857   ROM_REGION( 0x200000, "onboard.6", 0 ) /* onboard flash */
4858   ROM_LOAD( "710ja.31h",    0x000000, 0x200000, CRC(a0293108) SHA1(2e5651a4c1b8e021cc3060db138c9fe7c28caa3b) )
4859   ROM_REGION( 0x200000, "onboard.7", 0 ) /* onboard flash */
4860   ROM_LOAD( "710ja.27h",    0x000000, 0x200000, CRC(aed26efe) SHA1(20b6fccd0bc5495d8258b976f72d330d6315c6f6) )
4861
4862   ROM_REGION( 0x002000, "m48t58", 0 ) /* timekeeper */
4863   ROM_LOAD( "710ja.22h",    0x000000, 0x002000, CRC(b784de91) SHA1(048157e9ad6df46656dbac6349b0c821254e1c37) )
4864ROM_END
4865
48204866ROM_START( gtrfrks )
48214867   SYS573_BIOS_A
48224868
r15218r15219
54095455   DISK_IMAGE_READONLY( "gca18jaa", 0, SHA1(8adcc8ef76cbfb9f47fec5702b0b200565b5c561) )
54105456ROM_END
54115457
5412// System 573 BIOS (we're missing the later version that boots up with a pseudo-GUI)
5413GAME( 1998, sys573,   0,        konami573,    konami573, konami573,  ROT0, "Konami", "System 573 BIOS", GAME_IS_BIOS_ROOT )
5458GAME( 1997, sys573,   0,        konami573,    konami573, konami573,  ROT0, "Konami", "System 573 BIOS", GAME_IS_BIOS_ROOT )
54145459
5460GAME( 1997, hndlchmp, sys573,   konami573,    hndlchmp,  konami573,  ROT0, "Konami", "Handle Champ (GQ710 VER. JAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
54155461GAME( 1998, darkhleg, sys573,   konami573x,   konami573, konami573,  ROT0, "Konami", "Dark Horse Legend (GX706 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
54165462GAME( 1998, fbaitbc,  sys573,   k573baitx,    fbaitbc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait - A Bass Challenge (GE765 VER. UAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
54175463GAME( 1998, bassangl, fbaitbc,  k573baitx,    fbaitbc,   ge765pwbba, ROT0, "Konami", "Bass Angler (GE765 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
src/mame/drivers/xmen.c
r15218r15219
466466   MCFG_SOUND_ROUTE(0, "lspeaker", 0.20)
467467   MCFG_SOUND_ROUTE(1, "rspeaker", 0.20)
468468
469   MCFG_SOUND_ADD("k054539", K054539, 48000)
469   MCFG_K054539_ADD("k054539", 48000, k054539_config)
470470   MCFG_SOUND_ROUTE(0, "lspeaker", 1.00)
471471   MCFG_SOUND_ROUTE(1, "rspeaker", 1.00)
472472MACHINE_CONFIG_END
src/mame/drivers/decocass.c
r15218r15219
3131 
3232    -------------------------------------------------------------
3333 
34    Hamburger doesn't work; no protection details were supplied.
35 
3634    Here is the protection data for DS Telejan and Pro Golf (set 2).
3735    This information maps onto the various handlers in machine/decocass.c but it's
3836    not at all clear how to create a new one that fits these specs.
r15218r15219
10691067   ROM_LOAD( "cprogolf.cas", 0x0000, 0x8000, CRC(02123cd1) SHA1(e4c630ed293725f23d539cb43beb97953558dabd) )
10701068ROM_END
10711069
1072ROM_START( cprogolfj )
1070ROM_START( cprogolfj ) // version 1-A
10731071   DECOCASS_BIOS_A_ROMS
10741072
10751073   ROM_REGION( 0x00020, "dongle", 0 )     /* dongle data */
r15218r15219
10801078ROM_END
10811079
10821080/* 14 */
1083ROM_START( cdsteljn )
1081ROM_START( cdsteljn ) // version 4-A-3
10841082   DECOCASS_BIOS_A_ROMS
10851083
10861084   ROM_REGION( 0x00020, "dongle", 0 )     /* dongle data */
r15218r15219
12371235   ROM_LOAD( "cbtime.cas",   0x0000, 0x8000, CRC(56d7dc58) SHA1(34b2513c9ca7ab40f532b6d6d911aa3012113632) )
12381236ROM_END
12391237
1240ROM_START( chamburger )
1238ROM_START( chamburger ) // version 0-A-0
12411239   DECOCASS_BIOS_A_ROMS
12421240
12431241   ROM_REGION( 0x01000, "dongle", 0 )     /* dongle data */
src/mame/drivers/atarigx2.c
r15218r15219
8989   switch (offset)
9090   {
9191      case 0:
92         return (ioport("A2D1")->read() << 8);
92         return (ioport("A2D0")->read() << 24) | (ioport("A2D1")->read() << 8);
9393      case 1:
94         return (ioport("A2D3")->read() << 8);
94         return (ioport("A2D2")->read() << 24) | (ioport("A2D3")->read() << 8);
9595   }
9696
9797   return 0;
src/mame/drivers/atarigt.c
r15218r15219
155155   compute_fake_pots(pots);
156156   return (pots[0] << 24) | (pots[3] << 8);
157157#else
158   return (ioport("AN2")->read() << 8);
158   return (ioport("AN1")->read() << 24) | (ioport("AN2")->read() << 8);
159159#endif
160160}
161161
r15218r15219
167167   compute_fake_pots(pots);
168168   return (pots[2] << 24) | (pots[1] << 8);
169169#else
170   return (ioport("AN4")->read() << 8);
170   return (ioport("AN3")->read() << 24) | (ioport("AN4")->read() << 8);
171171#endif
172172}
173173
src/emu/video/psx.c
r15218r15219
13341334
13351335   for( ;; )
13361336   {
1337      if( n_y >= 1024 )
1338      {
1339         return;
1340      }
1341
13371342      if( n_y == COORD_DY( vertex[ n_leftpoint ].n_coord ) )
13381343      {
13391344         while( n_y == COORD_DY( vertex[ p_n_leftpointlist[ n_leftpoint ] ].n_coord ) )
r15218r15219
15151520
15161521   for( ;; )
15171522   {
1523      if( n_y >= 1024 )
1524      {
1525         return;
1526      }
1527
15181528      if( n_y == COORD_DY( vertex[ n_leftpoint ].n_coord ) )
15191529      {
15201530         while( n_y == COORD_DY( vertex[ p_n_leftpointlist[ n_leftpoint ] ].n_coord ) )
r15218r15219
16981708
16991709   for( ;; )
17001710   {
1711      if( n_y >= 1024 )
1712      {
1713         return;
1714      }
1715
17011716      if( n_y == COORD_DY( vertex[ n_leftpoint ].n_coord ) )
17021717      {
17031718         while( n_y == COORD_DY( vertex[ p_n_leftpointlist[ n_leftpoint ] ].n_coord ) )
r15218r15219
19241939
19251940   for( ;; )
19261941   {
1942      if( n_y >= 1024 )
1943      {
1944         return;
1945      }
1946
19271947      if( n_y == COORD_DY( vertex[ n_leftpoint ].n_coord ) )
19281948      {
19291949         while( n_y == COORD_DY( vertex[ p_n_leftpointlist[ n_leftpoint ] ].n_coord ) )
src/emu/sound/pokey.c
r15218r15219
11/*****************************************************************************
22 *
3 *  POKEY chip emulator 4.51
3 *  POKEY chip emulator 4.6
44 *  Copyright Nicola Salmoria and the MAME Team
55 *
66 *  Based on original info found in Ron Fries' Pokey emulator,
r15218r15219
1212 *  things means it is distributed as is, no warranties whatsoever.
1313 *  For more details read mame.txt that comes with MAME.
1414 *
15 *  4.6:
16 *  - changed audio emulation to emulate borrow 3 clock delay and
17 *    proper channel reset. New frequency only becomes effective
18 *    after the counter hits 0. Emulation also treats counters
19 *    as 8 bit counters which are linked now instead of monolytic
20 *    16 bit counters.
21 *
1522 *  4.51:
1623 *  - changed to use the attotime datatype
1724 *  4.5:
r15218r15219
7885 */
7986#define POKEY_DEFAULT_GAIN (32767/11/4)
8087
81#define VERBOSE       
88#define VERBOSE       1
8289#define VERBOSE_SOUND   0
8390#define VERBOSE_TIMER   0
8491#define VERBOSE_POLY   0
85#define VERBOSE_RAND   
92#define VERBOSE_RAND   1
8693
8794#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
8895
r15218r15219
157164typedef struct _pokey_state pokey_state;
158165struct _pokey_state
159166{
167   INT32 clock_cnt[3];      /* clock counters */
168   INT32 borrow_cnt[4];   /* borrow counters */
169
160170   INT32 counter[4];      /* channel counter */
161171   INT32 divisor[4];      /* channel divisor (modulo value) */
162172   UINT32 volume[4];      /* channel volume - derived */
163173   UINT8 output[4];      /* channel output signal (1 active, 0 inactive) */
164   UINT8 audible[4];      /* channel plays an audible tone/effect */
165   UINT32 samplerate_24_8; /* sample rate in 24.8 format */
166   UINT32 samplepos_fract; /* sample position fractional part */
167   UINT32 samplepos_whole; /* sample position whole part */
168   UINT32 polyadjust;      /* polynome adjustment */
174   UINT8 filter_sample[4];  /* hi-pass filter sample */
169175   UINT32 p4;              /* poly4 index */
170176   UINT32 p5;              /* poly5 index */
171177   UINT32 p9;              /* poly9 index */
r15218r15219
174180   UINT32 r17;             /* rand17 index */
175181   UINT32 clockmult;      /* clock multiplier */
176182   device_t *device;
177   sound_stream * channel; /* streams channel */
183   sound_stream * m_stream; /* streams channel */
178184   emu_timer *timer[3];   /* timers for channel 1,2 and 4 events */
179185   attotime timer_period[3];   /* computed periods for these timers */
180186   int timer_param[3];      /* computed parameters for these timers */
r15218r15219
221227static TIMER_CALLBACK( pokey_timer_expire );
222228static TIMER_CALLBACK( pokey_pot_trigger );
223229
230#define CLK_1 0
231#define CLK_28 1
232#define CLK_114 2
224233
225#define SAMPLE   -1
234static const int clock_divisors[3] = {1, 28, 114};
226235
227#define ADJUST_EVENT(chip)                                    \
228   chip->counter[CHAN1] -= event;                              \
229   chip->counter[CHAN2] -= event;                              \
230   chip->counter[CHAN3] -= event;                              \
231   chip->counter[CHAN4] -= event;                              \
232   chip->samplepos_whole -= event;                              \
233   chip->polyadjust += event
236INLINE pokey_state *get_safe_token(device_t *device)
237{
238   assert(device != NULL);
239   assert(device->type() == POKEY);
240   return (pokey_state *)downcast<legacy_device_base *>(device)->token();
241}
234242
235#if SUPPRESS_INAUDIBLE
243INLINE void reset_channel(pokey_state *chip, int ch)
244{
245   chip->counter[ch] = chip->AUDF[ch] ^ 0xff;
246}
236247
237#define PROCESS_CHANNEL(chip,ch)                                        \
238   int toggle = 0;                                        \
239   ADJUST_EVENT(chip);                                     \
240   /* reset the channel counter */                            \
241   if( chip->audible[ch] )                                    \
242      chip->counter[ch] = chip->divisor[ch];                     \
243   else                                                \
244      chip->counter[ch] = 0x7fffffff;                           \
245   chip->p4 = (chip->p4+chip->polyadjust)%0x0000f;                  \
246   chip->p5 = (chip->p5+chip->polyadjust)%0x0001f;                  \
247   chip->p9 = (chip->p9+chip->polyadjust)%0x001ff;                  \
248   chip->p17 = (chip->p17+chip->polyadjust)%0x1ffff;               \
249   chip->polyadjust = 0;                                    \
250   if( (chip->AUDC[ch] & NOTPOLY5) || P5(chip) )                  \
251   {                                                   \
252      if( chip->AUDC[ch] & PURE )                              \
253         toggle = 1;                                     \
254      else                                             \
255      if( chip->AUDC[ch] & POLY4 )                           \
256         toggle = chip->output[ch] == !P4(chip);                  \
257      else                                             \
258      if( chip->AUDCTL & POLY9 )                              \
259         toggle = chip->output[ch] == !P9(chip);                  \
260      else                                             \
261         toggle = chip->output[ch] == !P17(chip);               \
262   }                                                   \
263   if( toggle )                                          \
264   {                                                   \
265      if( chip->audible[ch] )                                 \
266      {                                                \
267         if( chip->output[ch] )                              \
268            sum -= chip->volume[ch];                        \
269         else                                          \
270            sum += chip->volume[ch];                        \
271      }                                                \
272      chip->output[ch] ^= 1;                                 \
273   }                                                   \
274   /* is this a filtering channel (3/4) and is the filter active? */   \
275   if( chip->AUDCTL & ((CH1_FILTER|CH2_FILTER) & (0x10 >> ch)) )      \
276    {                                                                   \
277      if( ch >= 2 && chip->output[ch-2] )                        \
278        {                                                               \
279         chip->output[ch-2] = 0;                              \
280         if( chip->audible[ch] )                              \
281            sum -= chip->volume[ch-2];                        \
282        }                                                               \
283    }                                                                   \
284248
285#else
249INLINE void process_channel(pokey_state *chip, int ch)
250{
251   int toggle = 0;
286252
287#define PROCESS_CHANNEL(chip,ch)                                        \
288   int toggle = 0;                                        \
289   ADJUST_EVENT(chip);                                     \
290   /* reset the channel counter */                            \
291   chip->counter[ch] = p[chip].divisor[ch];                     \
292   chip->p4 = (chip->p4+chip->polyadjust)%0x0000f;                  \
293   chip->p5 = (chip->p5+chip->polyadjust)%0x0001f;                  \
294   chip->p9 = (chip->p9+chip->polyadjust)%0x001ff;                  \
295   chip->p17 = (chip->p17+chip->polyadjust)%0x1ffff;               \
296   chip->polyadjust = 0;                                    \
297   if( (chip->AUDC[ch] & NOTPOLY5) || P5(chip) )                  \
298   {                                                   \
299      if( chip->AUDC[ch] & PURE )                              \
300         toggle = 1;                                     \
301      else                                             \
302      if( chip->AUDC[ch] & POLY4 )                           \
303         toggle = chip->output[ch] == !P4(chip);                  \
304      else                                             \
305      if( chip->AUDCTL & POLY9 )                              \
306         toggle = chip->output[ch] == !P9(chip);                  \
307      else                                             \
308         toggle = chip->output[ch] == !P17(chip);               \
309   }                                                   \
310   if( toggle )                                          \
311   {                                                   \
312      if( chip->output[ch] )                                 \
313         sum -= chip->volume[ch];                           \
314      else                                             \
315         sum += chip->volume[ch];                           \
316      chip->output[ch] ^= 1;                                 \
317   }                                                   \
318   /* is this a filtering channel (3/4) and is the filter active? */   \
319   if( chip->AUDCTL & ((CH1_FILTER|CH2_FILTER) & (0x10 >> ch)) )      \
320    {                                                                   \
321      if( ch >= 2 && chip->output[ch-2] )                        \
322        {                                                               \
323         chip->output[ch-2] = 0;                              \
324         sum -= chip->volume[ch-2];                           \
325        }                                                               \
326    }                                                                   \
253   if( (chip->AUDC[ch] & NOTPOLY5) || P5(chip) )
254   {
255      if( chip->AUDC[ch] & PURE )
256         toggle = 1;
257      else
258      if( chip->AUDC[ch] & POLY4 )
259         toggle = chip->output[ch] == !P4(chip);
260      else
261      if( chip->AUDCTL & POLY9 )
262         toggle = chip->output[ch] == !P9(chip);
263      else
264         toggle = chip->output[ch] == !P17(chip);
265   }
266   if( toggle )
267   {
268      chip->output[ch] ^= 1;
269   }
270}
327271
328#endif
272/*
273 * http://www.atariage.com/forums/topic/3328-sio-protocol/page__st__100#entry1680190:
274 * I noticed that the Pokey counters have clocked carry (actually, "borrow") positions that delay the
275 * counter by 3 cycles, plus the 1 reset clock. So 16 bit mode has 6 carry delays and a reset clock.
276 * I'm sure this was done because the propagation delays limited the number of cells the subtraction could ripple though.
277 *
278 */
329279
330#define PROCESS_SAMPLE(chip)                                            \
331    ADJUST_EVENT(chip);                                                 \
332    /* adjust the sample position */                                    \
333   chip->samplepos_whole++;                                 \
334   /* store sum of output signals into the buffer */               \
335   *buffer++ = (sum > 0x7fff) ? 0x7fff : sum;                     \
336   samples--
280INLINE void inc_chan(pokey_state *chip, int ch)
281{
282   chip->counter[ch] = (chip->counter[ch] + 1) & 0xff;
283   if (chip->counter[ch] == 0 && chip->borrow_cnt[ch] == 0)
284      chip->borrow_cnt[ch] = 3;
285}
337286
338#if HEAVY_MACRO_USAGE
287INLINE int check_borrow(pokey_state *chip, int ch)
288{
289   if (chip->borrow_cnt[ch] > 0)
290   {
291      chip->borrow_cnt[ch]--;
292      return (chip->borrow_cnt[ch] == 0);
293   }
294   return 0;
295}
339296
340/*
341 * This version of PROCESS_POKEY repeats the search for the minimum
342 * event value without using an index to the channel. That way the
343 * PROCESS_CHANNEL macros can be called with fixed values and expand
344 * to much more efficient code
345 */
297static STREAM_UPDATE( pokey_update )
298{
299   pokey_state *chip = (pokey_state *)param;
300   stream_sample_t *buffer = outputs[0];
301   int base_clock = (chip->AUDCTL & CLK_15KHZ) ? CLK_114 : CLK_28;
346302
347#define PROCESS_POKEY(chip)                                  \
348   UINT32 sum = 0;                                        \
349   if( chip->output[CHAN1] )                                 \
350      sum += chip->volume[CHAN1];                              \
351   if( chip->output[CHAN2] )                                 \
352      sum += chip->volume[CHAN2];                              \
353   if( chip->output[CHAN3] )                                 \
354      sum += chip->volume[CHAN3];                              \
355   if( chip->output[CHAN4] )                                 \
356      sum += chip->volume[CHAN4];                              \
357    while( samples > 0 )                                                 \
358   {                                                   \
359      if( chip->counter[CHAN1] < chip->samplepos_whole )            \
360      {                                                \
361         if( chip->counter[CHAN2] <  chip->counter[CHAN1] )         \
362         {                                             \
363            if( chip->counter[CHAN3] <  chip->counter[CHAN2] )      \
364            {                                          \
365               if( chip->counter[CHAN4] < chip->counter[CHAN3] )   \
366               {                                       \
367                  UINT32 event = chip->counter[CHAN4];         \
368                        PROCESS_CHANNEL(chip,CHAN4);                    \
369               }                                       \
370               else                                    \
371               {                                       \
372                  UINT32 event = chip->counter[CHAN3];         \
373                        PROCESS_CHANNEL(chip,CHAN3);                    \
374               }                                       \
375            }                                          \
376            else                                       \
377            if( chip->counter[CHAN4] < chip->counter[CHAN2] )      \
378            {                                          \
379               UINT32 event = chip->counter[CHAN4];            \
380                    PROCESS_CHANNEL(chip,CHAN4);                        \
381            }                                          \
382                else                                                    \
383            {                                          \
384               UINT32 event = chip->counter[CHAN2];            \
385                    PROCESS_CHANNEL(chip,CHAN2);                        \
386            }                                          \
387            }                                                           \
388         else                                          \
389         if( chip->counter[CHAN3] < chip->counter[CHAN1] )         \
390         {                                             \
391            if( chip->counter[CHAN4] < chip->counter[CHAN3] )      \
392            {                                          \
393               UINT32 event = chip->counter[CHAN4];            \
394                    PROCESS_CHANNEL(chip,CHAN4);                        \
395            }                                          \
396                else                                                    \
397            {                                          \
398               UINT32 event = chip->counter[CHAN3];            \
399                    PROCESS_CHANNEL(chip,CHAN3);                        \
400            }                                          \
401            }                                                           \
402         else                                          \
403         if( chip->counter[CHAN4] < chip->counter[CHAN1] )         \
404         {                                             \
405            UINT32 event = chip->counter[CHAN4];               \
406                PROCESS_CHANNEL(chip,CHAN4);                            \
407         }                                             \
408            else                                                        \
409         {                                             \
410            UINT32 event = chip->counter[CHAN1];               \
411                PROCESS_CHANNEL(chip,CHAN1);                            \
412         }                                             \
413      }                                                \
414      else                                             \
415      if( chip->counter[CHAN2] < chip->samplepos_whole )            \
416      {                                                \
417         if( chip->counter[CHAN3] < chip->counter[CHAN2] )         \
418         {                                             \
419            if( chip->counter[CHAN4] < chip->counter[CHAN3] )      \
420            {                                          \
421               UINT32 event = chip->counter[CHAN4];            \
422                    PROCESS_CHANNEL(chip,CHAN4);                        \
423            }                                          \
424            else                                       \
425            {                                          \
426               UINT32 event = chip->counter[CHAN3];            \
427                    PROCESS_CHANNEL(chip,CHAN3);                        \
428            }                                          \
429         }                                             \
430         else                                          \
431         if( chip->counter[CHAN4] < chip->counter[CHAN2] )         \
432         {                                             \
433            UINT32 event = chip->counter[CHAN4];               \
434                PROCESS_CHANNEL(chip,CHAN4);                            \
435         }                                             \
436         else                                          \
437         {                                             \
438            UINT32 event = chip->counter[CHAN2];               \
439                PROCESS_CHANNEL(chip,CHAN2);                            \
440         }                                             \
441      }                                                \
442      else                                             \
443      if( chip->counter[CHAN3] < chip->samplepos_whole )            \
444        {                                                               \
445         if( chip->counter[CHAN4] < chip->counter[CHAN3] )         \
446         {                                             \
447            UINT32 event = chip->counter[CHAN4];               \
448                PROCESS_CHANNEL(chip,CHAN4);                            \
449         }                                             \
450         else                                          \
451         {                                             \
452            UINT32 event = chip->counter[CHAN3];               \
453                PROCESS_CHANNEL(chip,CHAN3);                            \
454         }                                             \
455      }                                                \
456      else                                             \
457      if( chip->counter[CHAN4] < chip->samplepos_whole )            \
458      {                                                \
459         UINT32 event = chip->counter[CHAN4];                  \
460            PROCESS_CHANNEL(chip,CHAN4);                                \
461        }                                                               \
462      else                                             \
463      {                                                \
464         UINT32 event = chip->samplepos_whole;                  \
465         PROCESS_SAMPLE(chip);                              \
466      }                                                \
467   }                                                   \
468   chip->rtimer->adjust(attotime::never)
303   while( samples > 0 )
304   {
305      int ch, clk;
306      UINT32 sum = 0;
307      int clock_triggered[3] = {0,0,0};
469308
470#else   /* no HEAVY_MACRO_USAGE */
471/*
472 * And this version of PROCESS_POKEY uses event and channel variables
473 * so that the PROCESS_CHANNEL macro needs to index memory at runtime.
474 */
309      for (clk = 0; clk < 3; clk++)
310      {
311         chip->clock_cnt[clk]++;
312         if (chip->clock_cnt[clk] >= clock_divisors[clk])
313         {
314            chip->clock_cnt[clk] = 0;
315            clock_triggered[clk] = 1;
316         }
317      }
475318
476#define PROCESS_POKEY(chip)                                             \
477   UINT32 sum = 0;                                        \
478   if( chip->output[CHAN1] )                                 \
479      sum += chip->volume[CHAN1];                              \
480   if( chip->output[CHAN2] )                                 \
481      sum += chip->volume[CHAN2];                              \
482   if( chip->output[CHAN3] )                                 \
483      sum += chip->volume[CHAN3];                              \
484   if( chip->output[CHAN4] )                                 \
485        sum += chip->volume[CHAN4];                                     \
486   while( samples > 0 )                                                 \
487   {                                                   \
488      UINT32 event = chip->samplepos_whole;                     \
489      UINT32 channel = SAMPLE;                              \
490      if( chip->counter[CHAN1] < event )                        \
491        {                                                               \
492         event = chip->counter[CHAN1];                        \
493         channel = CHAN1;                                 \
494      }                                                \
495      if( chip->counter[CHAN2] < event )                        \
496        {                                                               \
497         event = chip->counter[CHAN2];                        \
498         channel = CHAN2;                                 \
499        }                                                               \
500      if( chip->counter[CHAN3] < event )                        \
501        {                                                               \
502         event = chip->counter[CHAN3];                        \
503         channel = CHAN3;                                 \
504        }                                                               \
505      if( chip->counter[CHAN4] < event )                        \
506        {                                                               \
507         event = chip->counter[CHAN4];                        \
508         channel = CHAN4;                                 \
509        }                                                               \
510        if( channel == SAMPLE )                                         \
511      {                                                \
512            PROCESS_SAMPLE(chip);                                       \
513        }                                                               \
514      else                                             \
515      {                                                \
516         PROCESS_CHANNEL(chip,channel);                        \
517      }                                                \
518   }                                                   \
519   chip->rtimer->adjust(attotime::never)
319      chip->p4 = (chip->p4 + 1) % 0x0000f;
320      chip->p5 = (chip->p5 + 1) % 0x0001f;
321      chip->p9 = (chip->p9 + 1) % 0x001ff;
322      chip->p17 = (chip->p17 + 1 ) % 0x1ffff;
520323
521#endif
522324
325      clk = (chip->AUDCTL & CH1_HICLK) ? CLK_1 : base_clock;
326      if (clock_triggered[clk])
327         inc_chan(chip, CHAN1);
523328
524INLINE pokey_state *get_safe_token(device_t *device)
525{
526   assert(device != NULL);
527   assert(device->type() == POKEY);
528   return (pokey_state *)downcast<legacy_device_base *>(device)->token();
529}
329      clk = (chip->AUDCTL & CH3_HICLK) ? CLK_1 : base_clock;
330      if (clock_triggered[clk])
331         inc_chan(chip, CHAN3);
530332
333      if (clock_triggered[base_clock])
334      {
335         if (!(chip->AUDCTL & CH12_JOINED))
336            inc_chan(chip, CHAN2);
337         if (!(chip->AUDCTL & CH34_JOINED))
338            inc_chan(chip, CHAN4);
339      }
531340
532static STREAM_UPDATE( pokey_update )
533{
534   pokey_state *chip = (pokey_state *)param;
535   stream_sample_t *buffer = outputs[0];
536   PROCESS_POKEY(chip);
341      /* do CHAN2 before CHAN1 because CHAN1 may set borrow! */
342      if (check_borrow(chip, CHAN2))
343      {
344         int isJoined = (chip->AUDCTL & CH12_JOINED);
345         if (isJoined)
346            reset_channel(chip, CHAN1);
347         reset_channel(chip, CHAN2);
348         process_channel(chip, CHAN2);
349      }
350
351      if (check_borrow(chip, CHAN1))
352      {
353         int isJoined = (chip->AUDCTL & CH12_JOINED);
354         if (isJoined)
355            inc_chan(chip, CHAN2);
356         else
357            reset_channel(chip, CHAN1);
358         process_channel(chip, CHAN1);
359      }
360
361      /* do CHAN4 before CHAN3 because CHAN3 may set borrow! */
362      if (check_borrow(chip, CHAN4))
363      {
364         int isJoined = (chip->AUDCTL & CH34_JOINED);
365         if (isJoined)
366            reset_channel(chip, CHAN3);
367         reset_channel(chip, CHAN4);
368         process_channel(chip, CHAN4);
369         /* is this a filtering channel (3/4) and is the filter active? */
370         if (chip->AUDCTL & CH2_FILTER)
371            chip->filter_sample[CHAN2] = chip->output[CHAN2];
372         else
373            chip->filter_sample[CHAN2] = 1;
374      }
375
376      if (check_borrow(chip, CHAN3))
377      {
378         int isJoined = (chip->AUDCTL & CH34_JOINED);
379         if (isJoined)
380            inc_chan(chip, CHAN4);
381         else
382            reset_channel(chip, CHAN3);
383         process_channel(chip, CHAN3);
384         /* is this a filtering channel (3/4) and is the filter active? */
385         if (chip->AUDCTL & CH1_FILTER)
386            chip->filter_sample[CHAN1] = chip->output[CHAN1];
387         else
388            chip->filter_sample[CHAN1] = 1;
389      }
390
391      for (ch = 0; ch < 4; ch++)
392      {
393         sum += (((chip->output[ch] ^ chip->filter_sample[ch]) || (chip->AUDC[ch] & VOLUME_ONLY)) ? chip->volume[ch] : 0 );
394      }
395
396          /* store sum of output signals into the buffer */
397          *buffer++ = (sum > 0x7fff) ? 0x7fff : sum;
398          samples--;
399
400   }
401   chip->rtimer->adjust(attotime::never);
402
537403}
538404
539405
r15218r15219
555421static void rand_init(UINT8 *rng, int size, int left, int right, int add)
556422{
557423    int mask = (1 << size) - 1;
424    int i;
425    UINT32 lfsr = 0;
426
427   LOG_RAND(("rand %d\n", size));
428
429   if (size == 17)
430   {
431       for( i = 0; i < mask; i++ )
432      {
433           /* calculate next bit @ 7 */
434          int in8 = !((lfsr >> 8) & 1) ^ ((lfsr >> 13) & 1);
435          int in = (lfsr & 1);
436          lfsr = lfsr >> 1;
437          lfsr = (lfsr & 0xff7f) | (in8 << 7);
438          lfsr = (in << 16) | lfsr;
439         *rng = (lfsr >> 8)  & 0xff;      /* use bits 0..7 */
440           LOG_RAND(("%05x: %02x\n", lfsr, *rng));
441           rng++;
442      }
443   }
444   else
445   {
446       for( i = 0; i < mask; i++ )
447      {
448           /* calculate next bit */
449          int in = !((lfsr >> 0) & 1) ^ ((lfsr >> 5) & 1);
450          lfsr = lfsr >> 1;
451          lfsr = (in << 8) | lfsr;
452         *rng = lfsr & 0xff;      /* use bits 0..7 */
453           LOG_RAND(("%05x: %02x\n", lfsr, *rng));
454           rng++;
455      }
456   }
457
458}
459
460#if 0
461static void rand_init_old(UINT8 *rng, int size, int left, int right, int add)
462{
463    int mask = (1 << size) - 1;
558464    int i, x = 0;
559465
560466   LOG_RAND(("rand %d\n", size));
r15218r15219
570476      x = ((x << left) + (x >> right) + add) & mask;
571477   }
572478}
479#endif
573480
574
575481static void register_for_save(pokey_state *chip, device_t *device)
576482{
577483   device->save_item(NAME(chip->counter));
578484   device->save_item(NAME(chip->divisor));
579485   device->save_item(NAME(chip->volume));
580486   device->save_item(NAME(chip->output));
581   device->save_item(NAME(chip->audible));
582   device->save_item(NAME(chip->samplepos_fract));
583   device->save_item(NAME(chip->samplepos_whole));
584   device->save_item(NAME(chip->polyadjust));
487   device->save_item(NAME(chip->filter_sample));
488   device->save_item(NAME(chip->clock_cnt));
585489   device->save_item(NAME(chip->p4));
586490   device->save_item(NAME(chip->p5));
587491   device->save_item(NAME(chip->p9));
r15218r15219
640544   rand_init(chip->rand9,   9, 8, 1, 0x00180);
641545   rand_init(chip->rand17, 17,16, 1, 0x1c000);
642546
643   chip->samplerate_24_8 = (device->clock() << 8) / sample_rate;
644547   chip->divisor[CHAN1] = 4;
645548   chip->divisor[CHAN2] = 4;
646549   chip->divisor[CHAN3] = 4;
r15218r15219
664567   chip->serout_w.resolve(chip->intf.serout_w, *device);
665568   chip->interrupt_cb = chip->intf.interrupt_cb;
666569
667   chip->channel = device->machine().sound().stream_alloc(*device, 0, 1, sample_rate, chip, pokey_update);
570   chip->m_stream = device->machine().sound().stream_alloc(*device, 0, 1, sample_rate, chip, pokey_update);
668571
669572   register_for_save(chip, device);
670573}
r15218r15219
952855   pokey_state *p = get_safe_token(device);
953856   int ch_mask = 0, new_val;
954857
955   p->channel->update();
858   p->m_stream->update();
956859
957860    /* determine which address was changed */
958861   switch (offset & 15)
r15218r15219
1045948      p->timer[TIMER4]->adjust(attotime::never, p->timer_param[TIMER4]);
1046949
1047950        /* reset all counters to zero (side effect) */
1048      p->polyadjust = 0;
1049      p->counter[CHAN1] = 0;
1050      p->counter[CHAN2] = 0;
1051      p->counter[CHAN3] = 0;
1052      p->counter[CHAN4] = 0;
1053951
952      reset_channel(p, CHAN1);
953      reset_channel(p, CHAN2);
954      reset_channel(p, CHAN3);
955      reset_channel(p, CHAN4);
956      /* From the pokey documentation */
957      p->output[CHAN1] = 0;
958      p->output[CHAN2] = 0;
959      p->output[CHAN3] = 0;
960      p->output[CHAN4] = 0;
961      p->filter_sample[CHAN1] = 1;
962      p->filter_sample[CHAN2] = 1;
963      p->filter_sample[CHAN3] = 0;
964      p->filter_sample[CHAN4] = 0;
965
1054966        /* joined chan#1 and chan#2 ? */
1055967      if( p->AUDCTL & CH12_JOINED )
1056968        {
r15218r15219
12021114
12031115      p->volume[CHAN1] = (p->AUDC[CHAN1] & VOLUME_MASK) * POKEY_DEFAULT_GAIN;
12041116        p->divisor[CHAN1] = new_val;
1205      if( new_val < p->counter[CHAN1] )
1206         p->counter[CHAN1] = new_val;
12071117      if( p->interrupt_cb && p->timer[TIMER1] )
12081118         p->timer[TIMER1]->adjust(p->clock_period * new_val, p->timer_param[TIMER1], p->timer_period[TIMER1]);
1209      p->audible[CHAN1] = !(
1210         (p->AUDC[CHAN1] & VOLUME_ONLY) ||
1211         (p->AUDC[CHAN1] & VOLUME_MASK) == 0 ||
1212         ((p->AUDC[CHAN1] & PURE) && new_val < (p->samplerate_24_8 >> 8)));
1213      if( !p->audible[CHAN1] )
1214      {
1215         p->output[CHAN1] = 1;
1216         p->counter[CHAN1] = 0x7fffffff;
1217         /* 50% duty cycle should result in half volume */
1218            p->volume[CHAN1] >>= 1;
1219        }
12201119    }
12211120
12221121    if( ch_mask & (1 << CHAN2) )
r15218r15219
12381137
12391138      p->volume[CHAN2] = (p->AUDC[CHAN2] & VOLUME_MASK) * POKEY_DEFAULT_GAIN;
12401139      p->divisor[CHAN2] = new_val;
1241      if( new_val < p->counter[CHAN2] )
1242         p->counter[CHAN2] = new_val;
12431140      if( p->interrupt_cb && p->timer[TIMER2] )
12441141         p->timer[TIMER2]->adjust(p->clock_period * new_val, p->timer_param[TIMER2], p->timer_period[TIMER2]);
1245      p->audible[CHAN2] = !(
1246         (p->AUDC[CHAN2] & VOLUME_ONLY) ||
1247         (p->AUDC[CHAN2] & VOLUME_MASK) == 0 ||
1248         ((p->AUDC[CHAN2] & PURE) && new_val < (p->samplerate_24_8 >> 8)));
1249      if( !p->audible[CHAN2] )
1250      {
1251         p->output[CHAN2] = 1;
1252         p->counter[CHAN2] = 0x7fffffff;
1253         /* 50% duty cycle should result in half volume */
1254         p->volume[CHAN2] >>= 1;
1255        }
12561142    }
12571143
12581144    if( ch_mask & (1 << CHAN3) )
r15218r15219
12671153
12681154      p->volume[CHAN3] = (p->AUDC[CHAN3] & VOLUME_MASK) * POKEY_DEFAULT_GAIN;
12691155      p->divisor[CHAN3] = new_val;
1270      if( new_val < p->counter[CHAN3] )
1271         p->counter[CHAN3] = new_val;
12721156      /* channel 3 does not have a timer associated */
1273      p->audible[CHAN3] = !(
1274         (p->AUDC[CHAN3] & VOLUME_ONLY) ||
1275         (p->AUDC[CHAN3] & VOLUME_MASK) == 0 ||
1276         ((p->AUDC[CHAN3] & PURE) && new_val < (p->samplerate_24_8 >> 8))) ||
1277         (p->AUDCTL & CH1_FILTER);
1278      if( !p->audible[CHAN3] )
1279      {
1280         p->output[CHAN3] = 1;
1281         p->counter[CHAN3] = 0x7fffffff;
1282         /* 50% duty cycle should result in half volume */
1283         p->volume[CHAN3] >>= 1;
1284        }
12851157    }
12861158
12871159    if( ch_mask & (1 << CHAN4) )
r15218r15219
13031175
13041176      p->volume[CHAN4] = (p->AUDC[CHAN4] & VOLUME_MASK) * POKEY_DEFAULT_GAIN;
13051177      p->divisor[CHAN4] = new_val;
1306      if( new_val < p->counter[CHAN4] )
1307         p->counter[CHAN4] = new_val;
13081178      if( p->interrupt_cb && p->timer[TIMER4] )
13091179         p->timer[TIMER4]->adjust(p->clock_period * new_val, p->timer_param[TIMER4], p->timer_period[TIMER4]);
1310      p->audible[CHAN4] = !(
1311         (p->AUDC[CHAN4] & VOLUME_ONLY) ||
1312         (p->AUDC[CHAN4] & VOLUME_MASK) == 0 ||
1313         ((p->AUDC[CHAN4] & PURE) && new_val < (p->samplerate_24_8 >> 8))) ||
1314         (p->AUDCTL & CH2_FILTER);
1315      if( !p->audible[CHAN4] )
1316      {
1317         p->output[CHAN4] = 1;
1318         p->counter[CHAN4] = 0x7fffffff;
1319         /* 50% duty cycle should result in half volume */
1320         p->volume[CHAN4] >>= 1;
1321        }
13221180    }
13231181}
13241182
r15218r15219
14071265      /* --- the following bits of info are returned as NULL-terminated strings --- */
14081266      case DEVINFO_STR_NAME:                     strcpy(info->s, "POKEY");                  break;
14091267      case DEVINFO_STR_FAMILY:               strcpy(info->s, "Atari custom");            break;
1410      case DEVINFO_STR_VERSION:               strcpy(info->s, "4.51");                  break;
1268      case DEVINFO_STR_VERSION:               strcpy(info->s, "4.6");                  break;
14111269      case DEVINFO_STR_SOURCE_FILE:                  strcpy(info->s, __FILE__);                  break;
14121270      case DEVINFO_STR_CREDITS:               strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
14131271   }
r15218r15219
14151273
14161274
14171275DEFINE_LEGACY_SOUND_DEVICE(POKEY, pokey);
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292// device type definition
1293const device_type POKEYN = &device_creator<pokeyn_device>;
1294
1295//**************************************************************************
1296//  LIVE DEVICE
1297//**************************************************************************
1298
1299//-------------------------------------------------
1300//  okim9810_device - constructor
1301//-------------------------------------------------
1302
1303pokeyn_device::pokeyn_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
1304   : device_t(mconfig, POKEYN, "POKEYN", tag, owner, clock),
1305     device_sound_interface(mconfig, *this),
1306     m_stream(NULL)
1307{
1308}
1309
1310
1311//-------------------------------------------------
1312//  device_start - device-specific startup
1313//-------------------------------------------------
1314
1315void pokeyn_device::device_start()
1316{
1317   //int sample_rate = clock();
1318   int i;
1319
1320   if (static_config())
1321      memcpy(&m_intf, static_config(), sizeof(pokey_interface));
1322   m_clock_period = attotime::from_hz(clock());
1323
1324   /* calculate the A/D times
1325     * In normal, slow mode (SKCTL bit SK_PADDLE is clear) the conversion
1326     * takes N scanlines, where N is the paddle value. A single scanline
1327     * takes approximately 64us to finish (1.78979MHz clock).
1328     * In quick mode (SK_PADDLE set) the conversion is done very fast
1329     * (takes two scanlines) but the result is not as accurate.
1330     */
1331
1332   m_ad_time_fast = (attotime::from_nsec(64000*2/228) * FREQ_17_EXACT) / clock();
1333   m_ad_time_slow = (attotime::from_nsec(64000      ) * FREQ_17_EXACT) / clock();
1334
1335   /* initialize the poly counters */
1336   poly_init(m_poly4,   4, 3, 1, 0x00004);
1337   poly_init(m_poly5,   5, 3, 2, 0x00008);
1338   poly_init(m_poly9,   9, 8, 1, 0x00180);
1339   poly_init(m_poly17, 17,16, 1, 0x1c000);
1340
1341   /* initialize the random arrays */
1342   rand_init(m_rand9,   9, 8, 1, 0x00180);
1343   rand_init(m_rand17, 17,16, 1, 0x1c000);
1344
1345   m_divisor[CHAN1] = 4;
1346   m_divisor[CHAN2] = 4;
1347   m_divisor[CHAN3] = 4;
1348   m_divisor[CHAN4] = 4;
1349   m_clockmult = DIV_64;
1350   m_KBCODE = 0x09;       /* Atari 800 'no key' */
1351   m_SKCTL = SK_RESET;    /* let the RNG run after reset */
1352   m_rtimer = timer_alloc(0);
1353
1354   m_timer[0] = timer_alloc(1);
1355   m_timer[1] = timer_alloc(1);
1356   m_timer[2] = timer_alloc(1);
1357
1358   for (i=0; i<8; i++)
1359   {
1360      m_ptimer[i] = timer_alloc(2);
1361      m_pot_r[i].resolve(m_intf.pot_r[i], *this);
1362   }
1363   m_allpot_r.resolve(m_intf.allpot_r, *this);
1364   m_serin_r.resolve(m_intf.serin_r, *this);
1365   m_serout_w.resolve(m_intf.serout_w, *this);
1366   m_interrupt_cb = m_intf.interrupt_cb;
1367
1368   m_stream = stream_alloc(0, 1, clock());
1369
1370   save_item(NAME(m_counter));
1371   save_item(NAME(m_divisor));
1372   save_item(NAME(m_volume));
1373   save_item(NAME(m_output));
1374   save_item(NAME(m_filter_sample));
1375   save_item(NAME(m_clock_cnt));
1376   save_item(NAME(m_borrow_cnt));
1377   save_item(NAME(m_p4));
1378   save_item(NAME(m_p5));
1379   save_item(NAME(m_p9));
1380   save_item(NAME(m_p17));
1381   save_item(NAME(m_r9));
1382   save_item(NAME(m_r17));
1383   save_item(NAME(m_clockmult));
1384   save_item(NAME(m_timer_period[0]));
1385   save_item(NAME(m_timer_period[1]));
1386   save_item(NAME(m_timer_period[2]));
1387   save_item(NAME(m_timer_param));
1388   save_item(NAME(m_AUDF));
1389   save_item(NAME(m_AUDC));
1390   save_item(NAME(m_POTx));
1391   save_item(NAME(m_AUDCTL));
1392   save_item(NAME(m_ALLPOT));
1393   save_item(NAME(m_KBCODE));
1394   save_item(NAME(m_RANDOM));
1395   save_item(NAME(m_SERIN));
1396   save_item(NAME(m_SEROUT));
1397   save_item(NAME(m_IRQST));
1398   save_item(NAME(m_IRQEN));
1399   save_item(NAME(m_SKSTAT));
1400   save_item(NAME(m_SKCTL));}
1401
1402
1403//-------------------------------------------------
1404//  device_reset - device-specific reset
1405//-------------------------------------------------
1406
1407void pokeyn_device::device_reset()
1408{
1409   m_stream->update();
1410}
1411
1412
1413//-------------------------------------------------
1414//  device_post_load - device-specific post-load
1415//-------------------------------------------------
1416
1417void pokeyn_device::device_post_load()
1418{
1419}
1420
1421
1422//-------------------------------------------------
1423//  device_clock_changed - called if the clock
1424//  changes
1425//-------------------------------------------------
1426
1427void pokeyn_device::device_clock_changed()
1428{
1429}
1430
1431//-------------------------------------------------
1432//  stream_generate - handle update requests for
1433//  our sound stream
1434//-------------------------------------------------
1435
1436void pokeyn_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
1437{
1438   if (id == 1)
1439   {
1440      int timers = param;
1441
1442      LOG_TIMER(("POKEY #%p timer %d with IRQEN $%02x\n", this, timers, m_IRQEN));
1443
1444       /* check if some of the requested timer interrupts are enabled */
1445      timers &= m_IRQEN;
1446
1447       if( timers )
1448       {
1449         /* set the enabled timer irq status bits */
1450         m_IRQST |= timers;
1451           /* call back an application supplied function to handle the interrupt */
1452         if( m_interrupt_cb )
1453            (*m_interrupt_cb)(this, timers);
1454       }
1455   }
1456   else if (id == 2)
1457   {
1458      int pot = param;
1459
1460      LOG(("POKEY #%p POT%d triggers after %dus\n", this, pot, (int)(1000000 * m_ptimer[pot]->elapsed().as_double())));
1461      m_ALLPOT &= ~(1 << pot);   /* set the enabled timer irq status bits */
1462
1463   }
1464   else if (id == 3)
1465   {
1466      /* serout_ready_cb */
1467       if( m_IRQEN & IRQ_SEROR )
1468      {
1469         m_IRQST |= IRQ_SEROR;
1470         if( m_interrupt_cb )
1471            (m_interrupt_cb)(this, IRQ_SEROR);
1472      }
1473   }
1474   else if (id == 4)
1475   {
1476      /* serout_complete */
1477       if( m_IRQEN & IRQ_SEROC )
1478      {
1479         m_IRQST |= IRQ_SEROC;
1480         if( m_interrupt_cb )
1481            (m_interrupt_cb)(this, IRQ_SEROC);
1482      }
1483   }
1484   else
1485      assert_always(FALSE, "Unknown id in pokey_device::device_timer");
1486}
1487
1488//-------------------------------------------------
1489//  stream_generate - handle update requests for
1490//  our sound stream
1491//-------------------------------------------------
1492
1493/*
1494 * http://www.atariage.com/forums/topic/3328-sio-protocol/page__st__100#entry1680190:
1495 * I noticed that the Pokey counters have clocked carry (actually, "borrow") positions that delay the
1496 * counter by 3 cycles, plus the 1 reset clock. So 16 bit mode has 6 carry delays and a reset clock.
1497 * I'm sure this was done because the propagation delays limited the number of cells the subtraction could ripple though.
1498 *
1499 */
1500
1501void pokeyn_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
1502{
1503   stream_sample_t *buffer = outputs[0];
1504   int base_clock = (m_AUDCTL & CLK_15KHZ) ? CLK_114 : CLK_28;
1505
1506   while( samples > 0 )
1507   {
1508      int ch, clk;
1509      UINT32 sum = 0;
1510      int clock_triggered[3] = {0,0,0};
1511
1512      for (clk = 0; clk < 3; clk++)
1513      {
1514         m_clock_cnt[clk]++;
1515         if (m_clock_cnt[clk] >= clock_divisors[clk])
1516         {
1517            m_clock_cnt[clk] = 0;
1518            clock_triggered[clk] = 1;
1519         }
1520      }
1521
1522      m_p4 = (m_p4 + 1) % 0x0000f;
1523      m_p5 = (m_p5 + 1) % 0x0001f;
1524      m_p9 = (m_p9 + 1) % 0x001ff;
1525      m_p17 = (m_p17 + 1 ) % 0x1ffff;
1526
1527
1528      clk = (m_AUDCTL & CH1_HICLK) ? CLK_1 : base_clock;
1529      if (clock_triggered[clk])
1530         inc_chan(CHAN1);
1531
1532      clk = (m_AUDCTL & CH3_HICLK) ? CLK_1 : base_clock;
1533      if (clock_triggered[clk])
1534         inc_chan(CHAN3);
1535
1536      if (clock_triggered[base_clock])
1537      {
1538         if (!(m_AUDCTL & CH12_JOINED))
1539            inc_chan(CHAN2);
1540         if (!(m_AUDCTL & CH34_JOINED))
1541            inc_chan(CHAN4);
1542      }
1543
1544      /* do CHAN2 before CHAN1 because CHAN1 may set borrow! */
1545      if (check_borrow(CHAN2))
1546      {
1547         int isJoined = (m_AUDCTL & CH12_JOINED);
1548         if (isJoined)
1549            reset_channel(CHAN1);
1550         reset_channel(CHAN2);
1551         process_channel(CHAN2);
1552      }
1553
1554      if (check_borrow(CHAN1))
1555      {
1556         int isJoined = (m_AUDCTL & CH12_JOINED);
1557         if (isJoined)
1558            inc_chan(CHAN2);
1559         else
1560            reset_channel(CHAN1);
1561         process_channel(CHAN1);
1562      }
1563
1564      /* do CHAN4 before CHAN3 because CHAN3 may set borrow! */
1565      if (check_borrow(CHAN4))
1566      {
1567         int isJoined = (m_AUDCTL & CH34_JOINED);
1568         if (isJoined)
1569            reset_channel(CHAN3);
1570         reset_channel(CHAN4);
1571         process_channel(CHAN4);
1572         /* is this a filtering channel (3/4) and is the filter active? */
1573         if (m_AUDCTL & CH2_FILTER)
1574            m_filter_sample[CHAN2] = m_output[CHAN2];
1575         else
1576            m_filter_sample[CHAN2] = 1;
1577      }
1578
1579      if (check_borrow(CHAN3))
1580      {
1581         int isJoined = (m_AUDCTL & CH34_JOINED);
1582         if (isJoined)
1583            inc_chan(CHAN4);
1584         else
1585            reset_channel(CHAN3);
1586         process_channel(CHAN3);
1587         /* is this a filtering channel (3/4) and is the filter active? */
1588         if (m_AUDCTL & CH1_FILTER)
1589            m_filter_sample[CHAN1] = m_output[CHAN1];
1590         else
1591            m_filter_sample[CHAN1] = 1;
1592      }
1593
1594      for (ch = 0; ch < 4; ch++)
1595      {
1596         sum += (((m_output[ch] ^ m_filter_sample[ch]) || (m_AUDC[ch] & VOLUME_ONLY)) ? m_volume[ch] : 0 );
1597      }
1598
1599          /* store sum of output signals into the buffer */
1600          *buffer++ = (sum > 0x7fff) ? 0x7fff : sum;
1601          samples--;
1602
1603   }
1604   m_rtimer->adjust(attotime::never);
1605
1606}
1607
1608
1609
1610//-------------------------------------------------
1611//  read - memory interface for reading the active status
1612//-------------------------------------------------
1613
1614READ8_MEMBER( pokeyn_device::read )
1615{
1616   int data = 0, pot;
1617   UINT32 adjust = 0;
1618
1619   switch (offset & 15)
1620   {
1621   case POT0_C: case POT1_C: case POT2_C: case POT3_C:
1622   case POT4_C: case POT5_C: case POT6_C: case POT7_C:
1623      pot = offset & 7;
1624      if( !m_pot_r[pot].isnull() )
1625      {
1626         /*
1627             * If the conversion is not yet finished (ptimer running),
1628             * get the current value by the linear interpolation of
1629             * the final value using the elapsed time.
1630             */
1631         if( m_ALLPOT & (1 << pot) )
1632         {
1633            data = m_ptimer[pot]->elapsed().attoseconds / ((m_SKCTL & SK_PADDLE) ? m_ad_time_fast : m_ad_time_slow).attoseconds;
1634            LOG(("POKEY '%s' read POT%d (interpolated) $%02x\n", tag(), pot, data));
1635            }
1636         else
1637         {
1638            data = m_POTx[pot];
1639            LOG(("POKEY '%s' read POT%d (final value)  $%02x\n", tag(), pot, data));
1640         }
1641      }
1642      else
1643         logerror("%s: warning - read '%s' POT%d\n", machine().describe_context(), tag(), pot);
1644      break;
1645
1646    case ALLPOT_C:
1647      /****************************************************************
1648         * If the 2 least significant bits of SKCTL are 0, the ALLPOTs
1649         * are disabled (SKRESET). Thanks to MikeJ for pointing this out.
1650         ****************************************************************/
1651      if( (m_SKCTL & SK_RESET) == 0)
1652      {
1653         data = 0;
1654         LOG(("POKEY '%s' ALLPOT internal $%02x (reset)\n", tag(), data));
1655      }
1656      else if( !m_allpot_r.isnull() )
1657      {
1658         data = m_allpot_r(offset);
1659         LOG(("POKEY '%s' ALLPOT callback $%02x\n", tag(), data));
1660      }
1661      else
1662      {
1663         data = m_ALLPOT;
1664         LOG(("POKEY '%s' ALLPOT internal $%02x\n", tag(), data));
1665      }
1666      break;
1667
1668   case KBCODE_C:
1669      data = m_KBCODE;
1670      break;
1671
1672   case RANDOM_C:
1673      /****************************************************************
1674         * If the 2 least significant bits of SKCTL are 0, the random
1675         * number generator is disabled (SKRESET). Thanks to Eric Smith
1676         * for pointing out this critical bit of info! If the random
1677         * number generator is enabled, get a new random number. Take
1678         * the time gone since the last read into account and read the
1679         * new value from an appropriate offset in the rand17 table.
1680         ****************************************************************/
1681      if( m_SKCTL & SK_RESET )
1682      {
1683         adjust = m_rtimer->elapsed().as_double() / m_clock_period.as_double();
1684         m_r9 = (m_r9 + adjust) % 0x001ff;
1685         m_r17 = (m_r17 + adjust) % 0x1ffff;
1686      }
1687      else
1688      {
1689         adjust = 1;
1690         m_r9 = 0;
1691         m_r17 = 0;
1692            LOG_RAND(("POKEY '%s' rand17 frozen (SKCTL): $%02x\n", tag(), m_RANDOM));
1693      }
1694      if( m_AUDCTL & POLY9 )
1695      {
1696         m_RANDOM = m_rand9[m_r9];
1697         LOG_RAND(("POKEY '%s' adjust %u rand9[$%05x]: $%02x\n", tag(), adjust, m_r9, m_RANDOM));
1698      }
1699      else
1700      {
1701         m_RANDOM = m_rand17[m_r17];
1702         LOG_RAND(("POKEY '%s' adjust %u rand17[$%05x]: $%02x\n", tag(), adjust, m_r17, m_RANDOM));
1703      }
1704      if (adjust > 0)
1705         m_rtimer->adjust(attotime::never);
1706      data = m_RANDOM ^ 0xff;
1707      break;
1708
1709   case SERIN_C:
1710      if( !m_serin_r.isnull() )
1711         m_SERIN = m_serin_r(offset);
1712      data = m_SERIN;
1713      LOG(("POKEY '%s' SERIN  $%02x\n", tag(), data));
1714      break;
1715
1716   case IRQST_C:
1717      /* IRQST is an active low input port; we keep it active high */
1718      /* internally to ease the (un-)masking of bits */
1719      data = m_IRQST ^ 0xff;
1720      LOG(("POKEY '%s' IRQST  $%02x\n", tag(), data));
1721      break;
1722
1723   case SKSTAT_C:
1724      /* SKSTAT is also an active low input port */
1725      data = m_SKSTAT ^ 0xff;
1726      LOG(("POKEY '%s' SKSTAT $%02x\n", tag(), data));
1727      break;
1728
1729   default:
1730      LOG(("POKEY '%s' register $%02x\n", tag(), offset));
1731        break;
1732    }
1733    return data;
1734
1735}
1736
1737
1738//-------------------------------------------------
1739//  write - memory interface for write
1740//-------------------------------------------------
1741
1742WRITE8_MEMBER( pokeyn_device::write )
1743{
1744   write_cmd(offset, data);
1745}
1746
1747void pokeyn_device::write_cmd(int offset, UINT8 data)
1748{
1749   int ch_mask = 0, new_val;
1750
1751   m_stream->update();
1752
1753    /* determine which address was changed */
1754   switch (offset & 15)
1755    {
1756    case AUDF1_C:
1757      if( data == m_AUDF[CHAN1] )
1758            return;
1759      LOG_SOUND(("POKEY '%s' AUDF1  $%02x\n", tag(), data));
1760      m_AUDF[CHAN1] = data;
1761        ch_mask = 1 << CHAN1;
1762      if( m_AUDCTL & CH12_JOINED )      /* if ch 1&2 tied together */
1763            ch_mask |= 1 << CHAN2;    /* then also change on ch2 */
1764        break;
1765
1766    case AUDC1_C:
1767      if( data == m_AUDC[CHAN1] )
1768            return;
1769      LOG_SOUND(("POKEY '%s' AUDC1  $%02x (%s)\n", tag(), data, audc2str(data)));
1770      m_AUDC[CHAN1] = data;
1771        ch_mask = 1 << CHAN1;
1772        break;
1773
1774    case AUDF2_C:
1775      if( data == m_AUDF[CHAN2] )
1776            return;
1777      LOG_SOUND(("POKEY '%s' AUDF2  $%02x\n", tag(), data));
1778      m_AUDF[CHAN2] = data;
1779        ch_mask = 1 << CHAN2;
1780        break;
1781
1782    case AUDC2_C:
1783      if( data == m_AUDC[CHAN2] )
1784            return;
1785      LOG_SOUND(("POKEY '%s' AUDC2  $%02x (%s)\n", tag(), data, audc2str(data)));
1786      m_AUDC[CHAN2] = data;
1787        ch_mask = 1 << CHAN2;
1788        break;
1789
1790    case AUDF3_C:
1791      if( data == m_AUDF[CHAN3] )
1792            return;
1793      LOG_SOUND(("POKEY '%s' AUDF3  $%02x\n", tag(), data));
1794      m_AUDF[CHAN3] = data;
1795        ch_mask = 1 << CHAN3;
1796
1797      if( m_AUDCTL & CH34_JOINED )   /* if ch 3&4 tied together */
1798            ch_mask |= 1 << CHAN4;  /* then also change on ch4 */
1799        break;
1800
1801    case AUDC3_C:
1802      if( data == m_AUDC[CHAN3] )
1803            return;
1804      LOG_SOUND(("POKEY '%s' AUDC3  $%02x (%s)\n", tag(), data, audc2str(data)));
1805      m_AUDC[CHAN3] = data;
1806        ch_mask = 1 << CHAN3;
1807        break;
1808
1809    case AUDF4_C:
1810      if( data == m_AUDF[CHAN4] )
1811            return;
1812      LOG_SOUND(("POKEY '%s' AUDF4  $%02x\n", tag(), data));
1813      m_AUDF[CHAN4] = data;
1814        ch_mask = 1 << CHAN4;
1815        break;
1816
1817    case AUDC4_C:
1818      if( data == m_AUDC[CHAN4] )
1819            return;
1820      LOG_SOUND(("POKEY '%s' AUDC4  $%02x (%s)\n", tag(), data, audc2str(data)));
1821      m_AUDC[CHAN4] = data;
1822        ch_mask = 1 << CHAN4;
1823        break;
1824
1825    case AUDCTL_C:
1826      if( data == m_AUDCTL )
1827            return;
1828      LOG_SOUND(("POKEY '%s' AUDCTL $%02x (%s)\n", tag(), data, audctl2str(data)));
1829      m_AUDCTL = data;
1830        ch_mask = 15;       /* all channels */
1831        /* determine the base multiplier for the 'div by n' calculations */
1832      m_clockmult = (m_AUDCTL & CLK_15KHZ) ? DIV_15 : DIV_64;
1833        break;
1834
1835    case STIMER_C:
1836        /* first remove any existing timers */
1837      LOG_TIMER(("POKEY '%s' STIMER $%02x\n", tag(), data));
1838
1839      m_timer[TIMER1]->adjust(attotime::never, m_timer_param[TIMER1]);
1840      m_timer[TIMER2]->adjust(attotime::never, m_timer_param[TIMER2]);
1841      m_timer[TIMER4]->adjust(attotime::never, m_timer_param[TIMER4]);
1842
1843        /* reset all counters to zero (side effect) */
1844      reset_channel(CHAN1);
1845      reset_channel(CHAN2);
1846      reset_channel(CHAN3);
1847      reset_channel(CHAN4);
1848      /* From the pokey documentation */
1849      m_output[CHAN1] = 0;
1850      m_output[CHAN2] = 0;
1851      m_output[CHAN3] = 0;
1852      m_output[CHAN4] = 0;
1853      m_filter_sample[CHAN1] = 1;
1854      m_filter_sample[CHAN2] = 1;
1855      m_filter_sample[CHAN3] = 0;
1856      m_filter_sample[CHAN4] = 0;
1857        /* joined chan#1 and chan#2 ? */
1858      if( m_AUDCTL & CH12_JOINED )
1859        {
1860         if( m_divisor[CHAN2] > 4 )
1861         {
1862            LOG_TIMER(("POKEY '%s' timer1+2 after %d clocks\n", tag(), m_divisor[CHAN2]));
1863            /* set timer #1 _and_ #2 event after timer_div clocks of joined CHAN1+CHAN2 */
1864            m_timer_period[TIMER2] = m_clock_period * m_divisor[CHAN2];
1865            m_timer_param[TIMER2] = IRQ_TIMR2|IRQ_TIMR1;
1866            m_timer[TIMER2]->adjust(m_timer_period[TIMER2], m_timer_param[TIMER2], m_timer_period[TIMER2]);
1867         }
1868        }
1869        else
1870        {
1871         if( m_divisor[CHAN1] > 4 )
1872         {
1873            LOG_TIMER(("POKEY '%s' timer1 after %d clocks\n", tag(), m_divisor[CHAN1]));
1874            /* set timer #1 event after timer_div clocks of CHAN1 */
1875            m_timer_period[TIMER1] = m_clock_period * m_divisor[CHAN1];
1876            m_timer_param[TIMER1] = IRQ_TIMR1;
1877            m_timer[TIMER1]->adjust(m_timer_period[TIMER1], m_timer_param[TIMER1], m_timer_period[TIMER1]);
1878         }
1879
1880         if( m_divisor[CHAN2] > 4 )
1881         {
1882            LOG_TIMER(("POKEY '%s' timer2 after %d clocks\n", tag(), m_divisor[CHAN2]));
1883            /* set timer #2 event after timer_div clocks of CHAN2 */
1884            m_timer_period[TIMER2] = m_clock_period * m_divisor[CHAN2];
1885            m_timer_param[TIMER2] = IRQ_TIMR2;
1886            m_timer[TIMER2]->adjust(m_timer_period[TIMER2], m_timer_param[TIMER2], m_timer_period[TIMER2]);
1887         }
1888        }
1889
1890      /* Note: p[chip] does not have a timer #3 */
1891
1892      if( m_AUDCTL & CH34_JOINED )
1893        {
1894            /* not sure about this: if audc4 == 0000xxxx don't start timer 4 ? */
1895         if( m_AUDC[CHAN4] & 0xf0 )
1896            {
1897            if( m_divisor[CHAN4] > 4 )
1898            {
1899               LOG_TIMER(("POKEY '%s' timer4 after %d clocks\n", tag(), m_divisor[CHAN4]));
1900               /* set timer #4 event after timer_div clocks of CHAN4 */
1901               m_timer_period[TIMER4] = m_clock_period * m_divisor[CHAN4];
1902               m_timer_param[TIMER4] = IRQ_TIMR4;
1903               m_timer[TIMER4]->adjust(m_timer_period[TIMER4], m_timer_param[TIMER4], m_timer_period[TIMER4]);
1904            }
1905            }
1906        }
1907        else
1908        {
1909         if( m_divisor[CHAN4] > 4 )
1910         {
1911            LOG_TIMER(("POKEY '%s' timer4 after %d clocks\n", tag(), m_divisor[CHAN4]));
1912            /* set timer #4 event after timer_div clocks of CHAN4 */
1913            m_timer_period[TIMER4] = m_clock_period * m_divisor[CHAN4];
1914            m_timer_param[TIMER4] = IRQ_TIMR4;
1915            m_timer[TIMER4]->adjust(m_timer_period[TIMER4], m_timer_param[TIMER4], m_timer_period[TIMER4]);
1916         }
1917        }
1918
1919      m_timer[TIMER1]->enable(m_IRQEN & IRQ_TIMR1);
1920      m_timer[TIMER2]->enable(m_IRQEN & IRQ_TIMR2);
1921      m_timer[TIMER4]->enable(m_IRQEN & IRQ_TIMR4);
1922        break;
1923
1924    case SKREST_C:
1925        /* reset SKSTAT */
1926      LOG(("POKEY '%s' SKREST $%02x\n", tag(), data));
1927      m_SKSTAT &= ~(SK_FRAME|SK_OVERRUN|SK_KBERR);
1928        break;
1929
1930    case POTGO_C:
1931      LOG(("POKEY '%s' POTGO  $%02x\n", tag(), data));
1932      pokey_potgo();
1933        break;
1934
1935    case SEROUT_C:
1936      LOG(("POKEY '%s' SEROUT $%02x\n", tag(), data));
1937      m_serout_w(offset, data);
1938      m_SKSTAT |= SK_SEROUT;
1939        /*
1940         * These are arbitrary values, tested with some custom boot
1941         * loaders from Ballblazer and Escape from Fractalus
1942         * The real times are unknown
1943         */
1944        timer_set(attotime::from_usec(200), 3);
1945        /* 10 bits (assumption 1 start, 8 data and 1 stop bit) take how long? */
1946        timer_set(attotime::from_usec(2000), 4);// FUNC(pokey_serout_complete), 0, p);
1947        break;
1948
1949    case IRQEN_C:
1950      LOG(("POKEY '%s' IRQEN  $%02x\n", tag(), data));
1951
1952        /* acknowledge one or more IRQST bits ? */
1953      if( m_IRQST & ~data )
1954        {
1955            /* reset IRQST bits that are masked now */
1956         m_IRQST &= data;
1957        }
1958        else
1959        {
1960         /* enable/disable timers now to avoid unneeded
1961               breaking of the CPU cores for masked timers */
1962         if( m_timer[TIMER1] && ((m_IRQEN^data) & IRQ_TIMR1) )
1963            m_timer[TIMER1]->enable(data & IRQ_TIMR1);
1964         if( m_timer[TIMER2] && ((m_IRQEN^data) & IRQ_TIMR2) )
1965            m_timer[TIMER2]->enable(data & IRQ_TIMR2);
1966         if( m_timer[TIMER4] && ((m_IRQEN^data) & IRQ_TIMR4) )
1967            m_timer[TIMER4]->enable(data & IRQ_TIMR4);
1968        }
1969      /* store irq enable */
1970      m_IRQEN = data;
1971        break;
1972
1973    case SKCTL_C:
1974      if( data == m_SKCTL )
1975            return;
1976      LOG(("POKEY '%s' SKCTL  $%02x\n", tag(), data));
1977      m_SKCTL = data;
1978        if( !(data & SK_RESET) )
1979        {
1980            write_cmd(IRQEN_C,  0);
1981            write_cmd(SKREST_C, 0);
1982        }
1983        break;
1984    }
1985
1986   /************************************************************
1987     * As defined in the manual, the exact counter values are
1988     * different depending on the frequency and resolution:
1989     *    64 kHz or 15 kHz - AUDF + 1
1990     *    1.79 MHz, 8-bit  - AUDF + 4
1991     *    1.79 MHz, 16-bit - AUDF[CHAN1]+256*AUDF[CHAN2] + 7
1992     ************************************************************/
1993
1994    /* only reset the channels that have changed */
1995
1996    if( ch_mask & (1 << CHAN1) )
1997    {
1998        /* process channel 1 frequency */
1999      if( m_AUDCTL & CH1_HICLK )
2000         new_val = m_AUDF[CHAN1] + DIVADD_HICLK;
2001        else
2002         new_val = (m_AUDF[CHAN1] + DIVADD_LOCLK) * m_clockmult;
2003
2004      LOG_SOUND(("POKEY '%s' chan1 %d\n", tag(), new_val));
2005
2006      m_volume[CHAN1] = (m_AUDC[CHAN1] & VOLUME_MASK) * POKEY_DEFAULT_GAIN;
2007        m_divisor[CHAN1] = new_val;
2008      if( m_interrupt_cb && m_timer[TIMER1] )
2009         m_timer[TIMER1]->adjust(m_clock_period * new_val, m_timer_param[TIMER1], m_timer_period[TIMER1]);
2010    }
2011
2012    if( ch_mask & (1 << CHAN2) )
2013    {
2014        /* process channel 2 frequency */
2015      if( m_AUDCTL & CH12_JOINED )
2016        {
2017         if( m_AUDCTL & CH1_HICLK )
2018            new_val = m_AUDF[CHAN2] * 256 + m_AUDF[CHAN1] + DIVADD_HICLK_JOINED;
2019            else
2020            new_val = (m_AUDF[CHAN2] * 256 + m_AUDF[CHAN1] + DIVADD_LOCLK) * m_clockmult;
2021         LOG_SOUND(("POKEY '%s' chan1+2 %d\n", tag(), new_val));
2022        }
2023        else
2024      {
2025         new_val = (m_AUDF[CHAN2] + DIVADD_LOCLK) * m_clockmult;
2026         LOG_SOUND(("POKEY '%s' chan2 %d\n", tag(), new_val));
2027      }
2028
2029      m_volume[CHAN2] = (m_AUDC[CHAN2] & VOLUME_MASK) * POKEY_DEFAULT_GAIN;
2030      m_divisor[CHAN2] = new_val;
2031      if( m_interrupt_cb && m_timer[TIMER2] )
2032         m_timer[TIMER2]->adjust(m_clock_period * new_val, m_timer_param[TIMER2], m_timer_period[TIMER2]);
2033    }
2034
2035    if( ch_mask & (1 << CHAN3) )
2036    {
2037        /* process channel 3 frequency */
2038      if( m_AUDCTL & CH3_HICLK )
2039         new_val = m_AUDF[CHAN3] + DIVADD_HICLK;
2040        else
2041         new_val = (m_AUDF[CHAN3] + DIVADD_LOCLK) * m_clockmult;
2042
2043      LOG_SOUND(("POKEY '%s' chan3 %d\n", tag(), new_val));
2044
2045      m_volume[CHAN3] = (m_AUDC[CHAN3] & VOLUME_MASK) * POKEY_DEFAULT_GAIN;
2046      m_divisor[CHAN3] = new_val;
2047      /* channel 3 does not have a timer associated */
2048    }
2049
2050    if( ch_mask & (1 << CHAN4) )
2051    {
2052        /* process channel 4 frequency */
2053      if( m_AUDCTL & CH34_JOINED )
2054        {
2055         if( m_AUDCTL & CH3_HICLK )
2056            new_val = m_AUDF[CHAN4] * 256 + m_AUDF[CHAN3] + DIVADD_HICLK_JOINED;
2057            else
2058            new_val = (m_AUDF[CHAN4] * 256 + m_AUDF[CHAN3] + DIVADD_LOCLK) * m_clockmult;
2059         LOG_SOUND(("POKEY '%s' chan3+4 %d\n", tag(), new_val));
2060        }
2061        else
2062      {
2063         new_val = (m_AUDF[CHAN4] + DIVADD_LOCLK) * m_clockmult;
2064         LOG_SOUND(("POKEY '%s' chan4 %d\n", tag(), new_val));
2065      }
2066
2067      m_volume[CHAN4] = (m_AUDC[CHAN4] & VOLUME_MASK) * POKEY_DEFAULT_GAIN;
2068      m_divisor[CHAN4] = new_val;
2069      if( m_interrupt_cb && m_timer[TIMER4] )
2070         m_timer[TIMER4]->adjust(m_clock_period * new_val, m_timer_param[TIMER4], m_timer_period[TIMER4]);
2071    }
2072}
2073
2074
2075//-------------------------------------------------
2076//  private stuff
2077//-------------------------------------------------
2078
2079inline void pokeyn_device::process_channel(int ch)
2080{
2081   int toggle = 0;
2082
2083   if( (m_AUDC[ch] & NOTPOLY5) || m_poly5[m_p5] )
2084   {
2085      if( m_AUDC[ch] & PURE )
2086         toggle = 1;
2087      else
2088      if( m_AUDC[ch] & POLY4 )
2089         toggle = m_output[ch] == !m_poly4[m_p4];
2090      else
2091      if( m_AUDCTL & POLY9 )
2092         toggle = m_output[ch] == !m_poly9[m_p9];
2093      else
2094         toggle = m_output[ch] == !m_poly17[m_p17];
2095   }
2096   if( toggle )
2097   {
2098      m_output[ch] ^= 1;
2099   }
2100   /* is this a filtering channel (3/4) and is the filter active? */
2101
2102   if( m_AUDCTL & ((CH1_FILTER|CH2_FILTER) & (0x10 >> ch)) )
2103    {
2104      if( ch >= 2)
2105        {
2106         m_filter_sample[ch-2] = m_output[ch-2];
2107        }
2108    }
2109
2110}
2111
2112
2113inline void pokeyn_device::reset_channel(int ch)
2114{
2115   m_counter[ch] = m_AUDF[ch] ^ 0xff;
2116}
2117
2118
2119inline void pokeyn_device::inc_chan(int ch)
2120{
2121   m_counter[ch] = (m_counter[ch] + 1) & 0xff;
2122   if (m_counter[ch] == 0 && m_borrow_cnt[ch] == 0)
2123      m_borrow_cnt[ch] = 3;
2124}
2125
2126inline int pokeyn_device::check_borrow(int ch)
2127{
2128   if (m_borrow_cnt[ch] > 0)
2129   {
2130      m_borrow_cnt[ch]--;
2131      return (m_borrow_cnt[ch] == 0);
2132   }
2133   return 0;
2134}
2135
2136void pokeyn_device::pokey_potgo(void)
2137{
2138    int pot;
2139
2140   LOG(("POKEY #%p pokey_potgo\n", this));
2141
2142    m_ALLPOT = 0xff;
2143
2144    for( pot = 0; pot < 8; pot++ )
2145   {
2146      m_POTx[pot] = 0xff;
2147      if( !m_pot_r[pot].isnull() )
2148      {
2149         int r = m_pot_r[pot](pot);
2150
2151         LOG(("POKEY %s pot_r(%d) returned $%02x\n", tag(), pot, r));
2152         if( r != -1 )
2153         {
2154            if (r > 228)
2155                    r = 228;
2156
2157                /* final value */
2158                m_POTx[pot] = r;
2159            m_ptimer[pot]->adjust(((m_SKCTL & SK_PADDLE) ? m_ad_time_fast : m_ad_time_slow) * r, pot);
2160         }
2161      }
2162   }
2163}
2164
2165
2166void pokeyn_device::poly_init(UINT8 *poly, int size, int left, int right, int add)
2167{
2168   int mask = (1 << size) - 1;
2169    int i, x = 0;
2170
2171   LOG_POLY(("poly %d\n", size));
2172   for( i = 0; i < mask; i++ )
2173   {
2174      *poly++ = x & 1;
2175      LOG_POLY(("%05x: %d\n", x, x&1));
2176        /* calculate next bit */
2177      x = ((x << left) + (x >> right) + add) & mask;
2178   }
2179}
2180
2181void pokeyn_device::rand_init(UINT8 *rng, int size, int left, int right, int add)
2182{
2183    int mask = (1 << size) - 1;
2184    int i, x = 0;
2185
2186   LOG_RAND(("rand %d\n", size));
2187    for( i = 0; i < mask; i++ )
2188   {
2189      if (size == 17)
2190         *rng = x >> 6;   /* use bits 6..13 */
2191      else
2192         *rng = x;      /* use bits 0..7 */
2193        LOG_RAND(("%05x: %02x\n", x, *rng));
2194        rng++;
2195        /* calculate next bit */
2196      x = ((x << left) + (x >> right) + add) & mask;
2197   }
2198}
src/emu/sound/pokey.h
r15218r15219
9292
9393DECLARE_LEGACY_SOUND_DEVICE(POKEY, pokey);
9494
95//**************************************************************************
96//  TYPE DEFINITIONS
97//**************************************************************************
98
99
100// ======================> pokey_device
101
102class pokeyn_device : public device_t,
103                  public device_sound_interface
104{
105public:
106   // construction/destruction
107   pokeyn_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
108
109   DECLARE_READ8_MEMBER( read );
110   DECLARE_WRITE8_MEMBER( write );
111
112protected:
113   // device-level overrides
114   virtual void device_start();
115   virtual void device_reset();
116   virtual void device_post_load();
117   virtual void device_clock_changed();
118   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
119
120   // device_sound_interface overrides
121   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
122
123   // configuration state
124   pokey_interface m_intf;
125
126private:
127
128   void poly_init(UINT8 *poly, int size, int left, int right, int add);
129   void rand_init(UINT8 *rng, int size, int left, int right, int add);
130   inline void process_channel(int ch);
131   inline void reset_channel(int ch);
132   inline void inc_chan(int ch);
133   inline int check_borrow(int ch);
134   void pokey_potgo(void);
135   void write_cmd(int offset, UINT8 data);
136
137
138
139   // internal state
140   sound_stream* m_stream;
141
142   INT32 m_clock_cnt[3];      /* clock counters */
143   INT32 m_borrow_cnt[4];   /* borrow counters */
144
145   INT32 m_counter[4];      /* channel counter */
146   INT32 m_divisor[4];      /* channel divisor (modulo value) */
147   UINT32 m_volume[4];      /* channel volume - derived */
148   UINT8 m_output[4];      /* channel output signal (1 active, 0 inactive) */
149   UINT8 m_filter_sample[4];  /* hi-pass filter sample */
150   UINT32 m_p4;              /* poly4 index */
151   UINT32 m_p5;              /* poly5 index */
152   UINT32 m_p9;              /* poly9 index */
153   UINT32 m_p17;             /* poly17 index */
154   UINT32 m_r9;            /* rand9 index */
155   UINT32 m_r17;             /* rand17 index */
156   UINT32 m_clockmult;      /* clock multiplier */
157   emu_timer *m_timer[3];   /* timers for channel 1,2 and 4 events */
158   attotime m_timer_period[3];   /* computed periods for these timers */
159   int m_timer_param[3];      /* computed parameters for these timers */
160   emu_timer *m_rtimer;     /* timer for calculating the random offset */
161   emu_timer *m_ptimer[8];   /* pot timers */
162   devcb_resolved_read8 m_pot_r[8];
163   devcb_resolved_read8 m_allpot_r;
164   devcb_resolved_read8 m_serin_r;
165   devcb_resolved_write8 m_serout_w;
166   void (*m_interrupt_cb)(device_t *device, int mask);
167   UINT8 m_AUDF[4];          /* AUDFx (D200, D202, D204, D206) */
168   UINT8 m_AUDC[4];         /* AUDCx (D201, D203, D205, D207) */
169   UINT8 m_POTx[8];         /* POTx   (R/D200-D207) */
170   UINT8 m_AUDCTL;         /* AUDCTL (W/D208) */
171   UINT8 m_ALLPOT;         /* ALLPOT (R/D208) */
172   UINT8 m_KBCODE;         /* KBCODE (R/D209) */
173   UINT8 m_RANDOM;         /* RANDOM (R/D20A) */
174   UINT8 m_SERIN;         /* SERIN  (R/D20D) */
175   UINT8 m_SEROUT;         /* SEROUT (W/D20D) */
176   UINT8 m_IRQST;         /* IRQST  (R/D20E) */
177   UINT8 m_IRQEN;         /* IRQEN  (W/D20E) */
178   UINT8 m_SKSTAT;         /* SKSTAT (R/D20F) */
179   UINT8 m_SKCTL;         /* SKCTL  (W/D20F) */
180   attotime m_clock_period;
181   attotime m_ad_time_fast;
182   attotime m_ad_time_slow;
183
184   UINT8 m_poly4[0x0f];
185   UINT8 m_poly5[0x1f];
186   UINT8 m_poly9[0x1ff];
187   UINT8 m_poly17[0x1ffff];
188
189   UINT8 m_rand9[0x1ff];
190   UINT8 m_rand17[0x1ffff];
191
192};
193
194
195// device type definition
196extern const device_type POKEYN;
197
198
95199#endif   /* __POKEY_H__ */
src/emu/ioport.c
r15218r15219
39153915   // allocate settings
39163916   setting_alloc(defval & mask, DEF_STR(Off));
39173917   setting_alloc(~defval & mask, DEF_STR(On));
3918   // clear cursettings set by setting_alloc
3919   m_cursetting = NULL;
39183920}
39193921
39203922
src/emu/info.c
r15218r15219
105105"\t\t\t<!ATTLIST chip type (cpu|audio) #REQUIRED>\n"
106106"\t\t\t<!ATTLIST chip clock CDATA #IMPLIED>\n"
107107"\t\t<!ELEMENT display EMPTY>\n"
108"\t\t\t<!ATTLIST display tag CDATA #IMPLIED>\n"
108109"\t\t\t<!ATTLIST display type (raster|vector|lcd|unknown) #REQUIRED>\n"
109110"\t\t\t<!ATTLIST display rotate (0|90|180|270) #REQUIRED>\n"
110111"\t\t\t<!ATTLIST display flipx (yes|no) \"no\">\n"
r15218r15219
318319   output_device_roms();
319320   output_sample();
320321   output_chips(m_drivlist.config().root_device(), "");
321   output_display(m_drivlist.config().root_device());
322   output_display(m_drivlist.config().root_device(), "");
322323   output_sound(m_drivlist.config().root_device());
323324   output_input(portlist);
324325   output_switches(portlist, "", IPT_DIPSWITCH, "dipswitch", "dipvalue");
r15218r15219
372373
373374   output_rom(device);
374375   output_chips(device, devtag);
375   output_display(device);
376   output_display(device, devtag);
376377   if (has_speaker)
377378      output_sound(device);
378379   if (has_input)
r15218r15219
679680//  displays
680681//-------------------------------------------------
681682
682void info_xml_creator::output_display(device_t &device)
683void info_xml_creator::output_display(device_t &device, const char *root_tag)
683684{
684685   // iterate over screens
685686   screen_device_iterator iter(device);
686687   for (const screen_device *screendev = iter.first(); screendev != NULL; screendev = iter.next())
687688   {
688      fprintf(m_output, "\t\t<display");
689
690      switch (screendev->screen_type())
689      if (strcmp(screendev->tag(), device.tag()))
691690      {
692         case SCREEN_TYPE_RASTER:   fprintf(m_output, " type=\"raster\"");   break;
693         case SCREEN_TYPE_VECTOR:   fprintf(m_output, " type=\"vector\"");   break;
694         case SCREEN_TYPE_LCD:      fprintf(m_output, " type=\"lcd\"");      break;
695         default:               fprintf(m_output, " type=\"unknown\"");   break;
691         astring newtag(screendev->tag()), oldtag(":");
692         newtag.substr(newtag.find(oldtag.cat(root_tag)) + oldtag.len());
693         
694         fprintf(m_output, "\t\t<display");
695         fprintf(m_output, " tag=\"%s\"", xml_normalize_string(newtag));
696         
697         switch (screendev->screen_type())
698         {
699            case SCREEN_TYPE_RASTER:   fprintf(m_output, " type=\"raster\"");   break;
700            case SCREEN_TYPE_VECTOR:   fprintf(m_output, " type=\"vector\"");   break;
701            case SCREEN_TYPE_LCD:      fprintf(m_output, " type=\"lcd\"");      break;
702            default:               fprintf(m_output, " type=\"unknown\"");   break;
703         }
704         
705         // output the orientation as a string
706         switch (m_drivlist.driver().flags & ORIENTATION_MASK)
707         {
708            case ORIENTATION_FLIP_X:
709               fprintf(m_output, " rotate=\"0\" flipx=\"yes\"");
710               break;
711            case ORIENTATION_FLIP_Y:
712               fprintf(m_output, " rotate=\"180\" flipx=\"yes\"");
713               break;
714            case ORIENTATION_FLIP_X|ORIENTATION_FLIP_Y:
715               fprintf(m_output, " rotate=\"180\"");
716               break;
717            case ORIENTATION_SWAP_XY:
718               fprintf(m_output, " rotate=\"90\" flipx=\"yes\"");
719               break;
720            case ORIENTATION_SWAP_XY|ORIENTATION_FLIP_X:
721               fprintf(m_output, " rotate=\"90\"");
722               break;
723            case ORIENTATION_SWAP_XY|ORIENTATION_FLIP_Y:
724               fprintf(m_output, " rotate=\"270\"");
725               break;
726            case ORIENTATION_SWAP_XY|ORIENTATION_FLIP_X|ORIENTATION_FLIP_Y:
727               fprintf(m_output, " rotate=\"270\" flipx=\"yes\"");
728               break;
729            default:
730               fprintf(m_output, " rotate=\"0\"");
731               break;
732         }
733         
734         // output width and height only for games that are not vector
735         if (screendev->screen_type() != SCREEN_TYPE_VECTOR)
736         {
737            const rectangle &visarea = screendev->visible_area();
738            fprintf(m_output, " width=\"%d\"", visarea.width());
739            fprintf(m_output, " height=\"%d\"", visarea.height());
740         }
741         
742         // output refresh rate
743         fprintf(m_output, " refresh=\"%f\"", ATTOSECONDS_TO_HZ(screendev->refresh_attoseconds()));
744         
745         // output raw video parameters only for games that are not vector
746         // and had raw parameters specified
747         if (screendev->screen_type() != SCREEN_TYPE_VECTOR && !screendev->oldstyle_vblank_supplied())
748         {
749            int pixclock = screendev->width() * screendev->height() * ATTOSECONDS_TO_HZ(screendev->refresh_attoseconds());
750           
751            fprintf(m_output, " pixclock=\"%d\"", pixclock);
752            fprintf(m_output, " htotal=\"%d\"", screendev->width());
753            fprintf(m_output, " hbend=\"%d\"", screendev->visible_area().min_x);
754            fprintf(m_output, " hbstart=\"%d\"", screendev->visible_area().max_x+1);
755            fprintf(m_output, " vtotal=\"%d\"", screendev->height());
756            fprintf(m_output, " vbend=\"%d\"", screendev->visible_area().min_y);
757            fprintf(m_output, " vbstart=\"%d\"", screendev->visible_area().max_y+1);
758         }
759         fprintf(m_output, " />\n");
696760      }
697
698      // output the orientation as a string
699      switch (m_drivlist.driver().flags & ORIENTATION_MASK)
700      {
701         case ORIENTATION_FLIP_X:
702            fprintf(m_output, " rotate=\"0\" flipx=\"yes\"");
703            break;
704         case ORIENTATION_FLIP_Y:
705            fprintf(m_output, " rotate=\"180\" flipx=\"yes\"");
706            break;
707         case ORIENTATION_FLIP_X|ORIENTATION_FLIP_Y:
708            fprintf(m_output, " rotate=\"180\"");
709            break;
710         case ORIENTATION_SWAP_XY:
711            fprintf(m_output, " rotate=\"90\" flipx=\"yes\"");
712            break;
713         case ORIENTATION_SWAP_XY|ORIENTATION_FLIP_X:
714            fprintf(m_output, " rotate=\"90\"");
715            break;
716         case ORIENTATION_SWAP_XY|ORIENTATION_FLIP_Y:
717            fprintf(m_output, " rotate=\"270\"");
718            break;
719         case ORIENTATION_SWAP_XY|ORIENTATION_FLIP_X|ORIENTATION_FLIP_Y:
720            fprintf(m_output, " rotate=\"270\" flipx=\"yes\"");
721            break;
722         default:
723            fprintf(m_output, " rotate=\"0\"");
724            break;
725      }
726
727      // output width and height only for games that are not vector
728      if (screendev->screen_type() != SCREEN_TYPE_VECTOR)
729      {
730         const rectangle &visarea = screendev->visible_area();
731         fprintf(m_output, " width=\"%d\"", visarea.width());
732         fprintf(m_output, " height=\"%d\"", visarea.height());
733      }
734
735      // output refresh rate
736      fprintf(m_output, " refresh=\"%f\"", ATTOSECONDS_TO_HZ(screendev->refresh_attoseconds()));
737
738      // output raw video parameters only for games that are not vector
739      // and had raw parameters specified
740      if (screendev->screen_type() != SCREEN_TYPE_VECTOR && !screendev->oldstyle_vblank_supplied())
741      {
742         int pixclock = screendev->width() * screendev->height() * ATTOSECONDS_TO_HZ(screendev->refresh_attoseconds());
743
744         fprintf(m_output, " pixclock=\"%d\"", pixclock);
745         fprintf(m_output, " htotal=\"%d\"", screendev->width());
746         fprintf(m_output, " hbend=\"%d\"", screendev->visible_area().min_x);
747         fprintf(m_output, " hbstart=\"%d\"", screendev->visible_area().max_x+1);
748         fprintf(m_output, " vtotal=\"%d\"", screendev->height());
749         fprintf(m_output, " vbend=\"%d\"", screendev->visible_area().min_y);
750         fprintf(m_output, " vbstart=\"%d\"", screendev->visible_area().max_y+1);
751      }
752      fprintf(m_output, " />\n");
753761   }
754762}
755763
src/emu/info.h
r15218r15219
6868   void output_device_roms();
6969   void output_sample();
7070   void output_chips(device_t &device, const char *root_tag);
71   void output_display(device_t &device);
71   void output_display(device_t &device, const char *root_tag);
7272   void output_sound(device_t &device);
7373   void output_input(const ioport_list &portlist);
7474   void output_switches(const ioport_list &portlist, const char *root_tag, int type, const char *outertag, const char *innertag);
src/lib/util/chd.c
r15218r15219
14061406      case CHDERR_NOT_SUPPORTED:            return "operation not supported";
14071407      case CHDERR_METADATA_NOT_FOUND:         return "can't find metadata";
14081408      case CHDERR_INVALID_METADATA_SIZE:      return "invalid metadata size";
1409      case CHDERR_UNSUPPORTED_VERSION:      return "unsupported CHD version";
1409      case CHDERR_UNSUPPORTED_VERSION:      return "mismatched DIFF and CHD or unsupported CHD version";
14101410      case CHDERR_VERIFY_INCOMPLETE:         return "incomplete verify";
14111411      case CHDERR_INVALID_METADATA:         return "invalid metadata";
14121412      case CHDERR_INVALID_STATE:            return "invalid state";
src/ldplayer/ldplayer.mak
r15218r15219
99#
1010###########################################################################
1111
12# add some additional include libraries for the mame files
13INCPATH += \
14   -I$(SRC)/mame \
1215
1316LDPSRC = $(SRC)/ldplayer
1417LDPOBJ = $(OBJ)/ldplayer
src/ldplayer/ldplayer.c
r15218r15219
1111
1212#include "emu.h"
1313#include "emuopts.h"
14#include "chd.h"
1415#include "cpu/mcs48/mcs48.h"
1516#include "machine/ldpr8210.h"
1617#include "machine/ldv1000.h"
r15218r15219
1920#include "pr8210.lh"
2021
2122
23#define APPNAME               "MAME"
24#define APPNAME_LOWER         "mame"
25#define CONFIGNAME            "mame"
26#define APPLONGNAME            "M.A.M.E."
27#define FULLLONGNAME         "Multiple Arcade Machine Emulator"
28#define CAPGAMENOUN            "GAME"
29#define CAPSTARTGAMENOUN      "Game"
30#define GAMENOUN            "game"
31#define GAMESNOUN            "games"
32#define COPYRIGHT            "Copyright Nicola Salmoria\nand the MAME team\nhttp://mamedev.org"
33#define COPYRIGHT_INFO         "Copyright Nicola Salmoria and the MAME team"
34#define DISCLAIMER            "MAME is an emulator: it reproduces, more or less faithfully, the behaviour of\n" \
35                        "several arcade machines. But hardware is useless without software, so an image\n" \
36                        "of the ROMs which run on that hardware is required. Such ROMs, like any other\n" \
37                        "commercial software, are copyrighted material and it is therefore illegal to\n" \
38                        "use them if you don't own the original arcade machine. Needless to say, ROMs\n" \
39                        "are not distributed together with MAME. Distribution of MAME together with ROM\n" \
40                        "images is a violation of copyright law and should be promptly reported to the\n" \
41                        "authors so that appropriate legal action can be taken.\n"
42#define USAGE               "Usage:  %s [%s] [options]"
43#define XML_ROOT             "mame"
44#define XML_TOP             "game"
45#define STATE_MAGIC_NUM         "MAMESAVE"
2246
47const char * emulator_info::get_appname() { return APPNAME;}
48const char * emulator_info::get_appname_lower() { return APPNAME_LOWER;}
49const char * emulator_info::get_configname() { return CONFIGNAME;}
50const char * emulator_info::get_applongname() { return APPLONGNAME;}
51const char * emulator_info::get_fulllongname() { return FULLLONGNAME;}
52const char * emulator_info::get_capgamenoun() { return CAPGAMENOUN;}
53const char * emulator_info::get_capstartgamenoun() { return CAPSTARTGAMENOUN;}
54const char * emulator_info::get_gamenoun() { return GAMENOUN;}
55const char * emulator_info::get_gamesnoun() { return GAMESNOUN;}
56const char * emulator_info::get_copyright() { return COPYRIGHT;}
57const char * emulator_info::get_copyright_info() { return COPYRIGHT_INFO;}
58const char * emulator_info::get_disclaimer() { return DISCLAIMER;}
59const char * emulator_info::get_usage() { return USAGE;}
60const char * emulator_info::get_xml_root() { return XML_ROOT;}
61const char * emulator_info::get_xml_top() { return XML_TOP;}
62const char * emulator_info::get_state_magic_num() { return STATE_MAGIC_NUM;}
63void emulator_info::printf_usage(const char *par1, const char *par2) { mame_printf_info(USAGE, par1, par2); }
64
2365/*************************************
2466 *
2567 *  Constants
r15218r15219
3981   ldplayer_state(const machine_config &mconfig, device_type type, const char *tag)
4082      : driver_device(mconfig, type, tag),
4183        m_last_controls(0),
42        m_playing(false),
43        m_laserdisc(*this, "laserdisc") { }
84        m_playing(false) { }
4485
4586   // callback hook
46   static chd_file *get_disc_static(device_t *device) { return device->machine().driver_data<ldplayer_state>()->get_disc(); }
87   static chd_file *get_disc_static(laserdisc_device &device) { return device.machine().driver_data<ldplayer_state>()->get_disc(); }
4788
4889protected:
4990   // device overrides
r15218r15219
99140   astring m_filename;
100141   ioport_value m_last_controls;
101142   bool m_playing;
102   required_device<laserdisc_device> m_laserdisc;
103143};
104144
105145
r15218r15219
108148public:
109149   // construction/destruction
110150   pr8210_state(const machine_config &mconfig, device_type type, const char *tag)
111      : ldplayer_state(machine, config),
112        m_bit_timer(timer_alloc(TIMER_ID_BIT)),
151      : ldplayer_state(mconfig, type, tag),
152        m_laserdisc(*this, "laserdisc"),
113153        m_command_buffer_in(0),
114154        m_command_buffer_out(0) { }
115155
116156protected:
117157   // device overrides
118158   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
159   virtual void machine_start();
119160   virtual void machine_reset();
120161
121162   // command execution hook
r15218r15219
131172      TIMER_ID_BIT_OFF
132173   };
133174
175   required_device<pioneer_pr8210_device> m_laserdisc;
176
134177   // internal state
135178   emu_timer *m_bit_timer;
136179   UINT32 m_command_buffer_in;
r15218r15219
144187public:
145188   // construction/destruction
146189   ldv1000_state(const machine_config &mconfig, device_type type, const char *tag)
147      : ldplayer_state(machine, config) { }
190      : ldplayer_state(mconfig, type, tag),
191        m_laserdisc(*this, "laserdisc") { }
148192
149193protected:
194   required_device<pioneer_ldv1000_device> m_laserdisc;
195
150196   // command execution hook
151197   virtual void execute_command(int command);
152198};
r15218r15219
161207
162208chd_file *ldplayer_state::get_disc()
163209{
210   bool found = FALSE;
164211   // open a path to the ROMs and find the first CHD file
165212   file_enumerator path(machine().options().media_path());
166213
r15218r15219
182229         file_error filerr = image_file.open(dir->name);
183230         if (filerr == FILERR_NONE)
184231         {
185            astring fullpath(image_file->fullpath();
232            astring fullpath(image_file.fullpath());
186233            image_file.close();
187234
188235            // try to open the CHD
r15218r15219
190237            if (set_disk_handle(machine(), "laserdisc", fullpath) == CHDERR_NONE)
191238            {
192239               m_filename.cpy(dir->name);
240               found = TRUE;
193241               break;
194242            }
195243         }
196
197         // close the file on failure
198         auto_free(machine(), image_file);
199         image_file = NULL;
200244      }
201245   }
202246
203247   // if we failed, pop a message and exit
204   if (image_file == NULL)
248   if (found == FALSE)
205249      throw emu_fatalerror("No valid image file found!\n");
206250
207251   return get_disk_handle(machine(), "laserdisc");
r15218r15219
358402         // if we have bits, process
359403         if (bitsleft != 0)
360404         {
361            // assert the line and set a timer for deassertion
362            laserdisc_line_w(m_laserdisc, LASERDISC_LINE_CONTROL, ASSERT_LINE);
405            // assert the line and set a timer for deassertion           
406            m_laserdisc->control_w(ASSERT_LINE);
363407            timer_set(attotime::from_usec(250), TIMER_ID_BIT_OFF);
364408
365409            // space 0 bits apart by 1msec, and 1 bits by 2msec
r15218r15219
380424
381425      // deassert the control line
382426      case TIMER_ID_BIT_OFF:
383         laserdisc_line_w(m_laserdisc, LASERDISC_LINE_CONTROL, CLEAR_LINE);
427         m_laserdisc->control_w(CLEAR_LINE);
384428         break;
385429
386430      // others to the parent class
r15218r15219
390434   }
391435}
392436
437void pr8210_state::machine_start()
438{
439   ldplayer_state::machine_start();
440   m_bit_timer = timer_alloc(TIMER_ID_BIT);   
441}
393442
394443void pr8210_state::machine_reset()
395444{
r15218r15219
520569   switch (command)
521570   {
522571      case CMD_SCAN_REVERSE:
523         laserdisc_data_w(m_laserdisc, 0xf8);
572         m_laserdisc->data_w(0xf8);
524573         m_playing = true;
525574         break;
526575
527576      case CMD_STEP_REVERSE:
528         laserdisc_data_w(m_laserdisc, 0xfe);
577         m_laserdisc->data_w(0xfe);
529578         m_playing = false;
530579         break;
531580
532581      case CMD_SCAN_FORWARD:
533         laserdisc_data_w(m_laserdisc, 0xf0);
582         m_laserdisc->data_w(0xf0);
534583         m_playing = true;
535584         break;
536585
537586      case CMD_STEP_FORWARD:
538         laserdisc_data_w(m_laserdisc, 0xf6);
587         m_laserdisc->data_w(0xf6);
539588         m_playing = false;
540589         break;
541590
542591      case CMD_PLAY:
543         laserdisc_data_w(m_laserdisc, 0xfd);
592         m_laserdisc->data_w(0xfd);
544593         m_playing = true;
545594         break;
546595
547596      case CMD_PAUSE:
548         laserdisc_data_w(m_laserdisc, 0xa0);
597         m_laserdisc->data_w(0xa0);
549598         m_playing = false;
550599         break;
551600
552601      case CMD_FRAME_TOGGLE:
553         laserdisc_data_w(m_laserdisc, 0xf1);
602         m_laserdisc->data_w(0xf1);
554603         break;
555604
556605      case CMD_0:
r15218r15219
563612      case CMD_7:
564613      case CMD_8:
565614      case CMD_9:
566         laserdisc_data_w(m_laserdisc, digits[command - CMD_0]);
615         m_laserdisc->data_w(digits[command - CMD_0]);
567616         break;
568617
569618      case CMD_SEARCH:
570         laserdisc_data_w(m_laserdisc, 0xf7);
619         m_laserdisc->data_w(0xf7);
571620         m_playing = false;
572621         break;
573622   }
r15218r15219
618667 *************************************/
619668
620669static MACHINE_CONFIG_START( ldplayer_ntsc, ldplayer_state )
621   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
622   MCFG_LASERDISC_SCREEN_ADD_NTSC("screen", "laserdisc")
623670MACHINE_CONFIG_END
624671
625672
626673static MACHINE_CONFIG_DERIVED_CLASS( ldv1000, ldplayer_ntsc, ldv1000_state )
627674   MCFG_LASERDISC_LDV1000_ADD("laserdisc")
675   MCFG_LASERDISC_GET_DISC(laserdisc_get_disc_delegate(FUNC(ldplayer_state::get_disc_static), device))
676   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
628677   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
629678   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
630   MCFG_LASERDISC_GET_DISC(ldplayer_state::get_disc_static)
679   MCFG_LASERDISC_SCREEN_ADD_NTSC("screen", "laserdisc")
631680MACHINE_CONFIG_END
632681
633682
634683static MACHINE_CONFIG_DERIVED_CLASS( pr8210, ldplayer_ntsc, pr8210_state )
635684   MCFG_LASERDISC_PR8210_ADD("laserdisc")
685   MCFG_LASERDISC_GET_DISC(laserdisc_get_disc_delegate(FUNC(ldplayer_state::get_disc_static), device))
686   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
636687   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
637688   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
638   MCFG_LASERDISC_GET_DISC(ldplayer_state::get_disc_static)
689   MCFG_LASERDISC_SCREEN_ADD_NTSC("screen", "laserdisc")
639690MACHINE_CONFIG_END
640691
641692

Previous 15994 Revisions Next


© 1998-2018 The MESS Team