Previous 15994 Revisions Next

r15254 Monday 21st May, 2012 at 08:00:31 UTC by Miodrag Milanović
Clean-ups and version bump
[src]version.c
[src/emu]device.h info.c ioport.c ioport.h rendlay.c rendlay.h timer.c
[src/emu/cpu/i386]i386.c
[src/emu/cpu/powerpc]ppc.h ppccom.h
[src/emu/machine]68681.c
[src/emu/sound]pokey.c pokey.h tc8830f.c tc8830f.h
[src/ldplayer]ldplayer.c
[src/mame]mame.lst mame.mak
[src/mame/drivers]bzone.c chance32.c cps2.c crimfght.c csplayh5.c decocass.c fortecar.c gei.c igs017.c megasys1.c midyunit.c naomi.c neodrvr.c pacman.c quantum.c r2dx_v33.c segas32.c statriv2.c tecmo.c timeplt.c twincobr.c wardner.c
[src/mame/includes]atari.h twincobr.h
[src/mame/machine]atari.c mega32x.c megavdp.c
[src/mame/video]bfm_dm01.c twincobr.c
[src/mess]mess.lst mess.mak
[src/mess/drivers]cxhumax.c dm7000.c e01.c esq5505.c m20.c test_t400.c vic20.c vidbrain.c
[src/mess/includes]cxhumax.h dm7000.h vidbrain.h
[src/mess/machine]8530scc.c c64_cpm.c kaypro.c kb_msnat.c lisa.c vic20user.c vic20user.h
[src/mess/video]uv201.c uv201.h

src/mame/mame.lst
r15253r15254
44454445slipstrmh
44464446
44474447// Sega Multi System 32 games
4448            // 1993.05 Outrunners (Japan)
44494448orunners      // 1993.?? Outrunners (World)
44504449orunnersu      // 1993.06 Outrunners (US)
4450orunnersj      // 1993.05 Outrunners (Japan)
44514451harddunkj      // 1994.04 Hard Dunk 3on3 (Japan)
44524452harddunk      // 1994.?? Hard Dunk 3on3 (World)
44534453            // 1993.03 Title Fight (Japan)
r15253r15254
52275227            // 12 1981.08 Flash Boy/DECO Kid
52285228cprogolf      // 13 1981.08 Tournament Pro Golf
52295229cprogolfj      // 13 1981.08 Tournament Pro Golf (Japan)
5230cdsteljn       // 14 1981.06 DS Telejan
5230cdsteljn      // 14 1981.06 DS Telejan
52315231cluckypo      // 15 1981.?? Lucky Poker
52325232ctisland      // 16 1982.02 Treasure Island
52335233ctisland2      // 16
r15253r15254
52435243            // 24 1982.07 Tsumego Kaisyou
52445244            // 25 1982.10 Angler Dangler? (fishing)
52455245cbtime         // 26 1982.08 Hamburger/Burger Time
5246chamburger        // 26 1982.08 Hamburger (Japan)
5246chamburger        // 26 1982.08 Hamburger (Japan)
52475247cburnrub      // 27 1982.11 Burnin' Rubber
52485248cburnrub2      // 27
52495249cbnj         // 27         Bump 'n' Jump
src/mame/machine/mega32x.c
r15253r15254
195195#161 Runlength Mode
196196
197197*/
198       
198
199199#include "includes/megadriv.h"
200200
201201
src/mame/machine/megavdp.c
r15253r15254
29362936   megadrive_visible_scanlines = 224;
29372937   megadrive_irq6_scanline = 224;
29382938   megadrive_z80irq_scanline = 226;
2939}   
2939}
src/mame/machine/atari.c
r15253r15254
2424
2525static void pokey_reset(running_machine &machine);
2626
27void atari_interrupt_cb(device_t *device, int mask)
27void atari_interrupt_cb(pokeyn_device *device, int mask)
2828{
2929
3030   if (VERBOSE_POKEY)
src/mame/includes/twincobr.h
r15253r15254
1414   twincobr_state(const machine_config &mconfig, device_type type, const char *tag)
1515      : driver_device(mconfig, type, tag) ,
1616      m_sharedram(*this, "sharedram"),
17      m_spriteram(*this, "spriteram"){ }
17      m_spriteram8(*this, "spriteram8"),
18      m_spriteram16(*this, "spriteram16"){ }
1819
1920   int m_toaplan_main_cpu;
2021   int m_wardner_membank;
r15253r15254
5152   tilemap_t *m_bg_tilemap;
5253   tilemap_t *m_fg_tilemap;
5354   tilemap_t *m_tx_tilemap;
54   required_device<buffered_spriteram16_device> m_spriteram;
55   optional_device<buffered_spriteram8_device> m_spriteram8;
56   optional_device<buffered_spriteram16_device> m_spriteram16;
5557   DECLARE_WRITE16_MEMBER(twincobr_dsp_addrsel_w);
5658   DECLARE_READ16_MEMBER(twincobr_dsp_r);
5759   DECLARE_WRITE16_MEMBER(twincobr_dsp_w);
src/mame/includes/atari.h
r15253r15254
1313#define ATARI_H
1414
1515#include "machine/6821pia.h"
16#include "sound/pokey.h"
1617
1718/*----------- defined in machine/atari.c -----------*/
1819
r15253r15254
3031
3132MACHINE_START( atarixl );
3233
33void atari_interrupt_cb(device_t *device, int mask);
34void atari_interrupt_cb(pokeyn_device *device, int mask);
3435
3536void a800_handle_keyboard(running_machine &machine);
3637void a5200_handle_keypads(running_machine &machine);
src/mame/mame.mak
r15253r15254
19721972
19731973$(DRIVERS)/cdi.o:   $(LAYOUT)/cdi.lh
19741974
1975$(DRIVERS)/chance32.o:   $(LAYOUT)/chance32.lh
1976
19751977$(DRIVERS)/changela.o:   $(LAYOUT)/changela.lh
19761978
19771979$(DRIVERS)/chqflag.o:   $(LAYOUT)/chqflag.lh
src/mame/video/twincobr.c
r15253r15254
352352
353353READ8_MEMBER(twincobr_state::wardner_sprite_r)
354354{
355   UINT16 *spriteram16 = reinterpret_cast<UINT16 *>(m_spriteram8->live());
355356   int shift = (offset & 1) * 8;
356   return m_spriteram->live()[offset/2] >> shift;
357   return spriteram16[offset/2] >> shift;
357358}
358359
359360WRITE8_MEMBER(twincobr_state::wardner_sprite_w)
360361{
361   UINT16 *spriteram16 = m_spriteram->live();
362   UINT16 *spriteram16 = reinterpret_cast<UINT16 *>(m_spriteram8->live());
362363   if (offset & 1)
363364      spriteram16[offset/2] = (spriteram16[offset/2] & 0x00ff) | (data << 8);
364365   else
r15253r15254
376377   twincobr_state *state = machine.driver_data<twincobr_state>();
377378
378379   if (state->m_fgscrollx != state->m_bgscrollx) {
379      UINT16 *buffered_spriteram16 = state->m_spriteram->buffer();
380      UINT16 *buffered_spriteram16 = reinterpret_cast<UINT16 *>(state->m_spriteram8->buffer());
380381      if ((state->m_fgscrollx==0x1c9) || (state->m_flip_screen && (state->m_fgscrollx==0x17a))) {   /* in the shop ? */
381382         int wardner_hack = buffered_spriteram16[0x0b04/2];
382383      /* sprite position 0x6300 to 0x8700 -- hero on shop keeper (normal) */
r15253r15254
453454
454455   if (state->m_display_on)
455456   {
456      UINT16 *buffered_spriteram16 = state->m_spriteram->buffer();
457      for (offs = 0;offs < state->m_spriteram->bytes()/2;offs += 4)
457      UINT16 *buffered_spriteram16;
458      UINT32 bytes;
459      if (state->m_spriteram16 != NULL)
458460      {
461         buffered_spriteram16 = state->m_spriteram16->buffer();
462         bytes = state->m_spriteram16->bytes();
463      }
464      else
465      {
466         buffered_spriteram16 = reinterpret_cast<UINT16 *>(state->m_spriteram8->buffer());
467         bytes = state->m_spriteram8->bytes();
468      }
469      for (offs = 0;offs < bytes/2;offs += 4)
470      {
459471         int attribute,sx,sy,flipx,flipy;
460472         int sprite, color;
461473
src/mame/video/bfm_dm01.c
r15253r15254
5858   int       data_avail,
5959              control,
6060           xcounter,
61        segbuffer[65],
61      segbuffer[65],
6262              busy;
6363
6464UINT8 scanline[DM_BYTESPERROW],
r15253r15254
152152         {
153153
154154            UINT8 d = dm01.scanline[p];
155           
155
156156            for (int bitpos=0; bitpos <8; bitpos++)
157157            {
158158               if (((p*8)+bitpos) <65)
159159               {
160160                  if (d & 1<<(7-bitpos)) dm01.segbuffer[(p*8)+bitpos]=1;
161                  else dm01.segbuffer[(p*8)+bitpos]=0;   
161                  else dm01.segbuffer[(p*8)+bitpos]=0;
162162               }
163163            }
164164            p++;
r15253r15254
167167         for (int pos=0;pos<65;pos++)
168168         {
169169            output_set_indexed_value("dotmatrix", pos +(65*row), dm01.segbuffer[(pos)]);
170         }         
170         }
171171      }
172172   }
173173}
src/mame/drivers/csplayh5.c
r15253r15254
99    - fix h8 CPU core bugs, it trips various unhandled opcodes
1010    - Implement DVD routing and YUV decoding;
1111    - game timings seem busted, could be due of missing DVD hook-up
12    - csplayh8: inputs doesn't work at all, slower than the others too
12    - csplayh1: inputs doesn't work at all, slower than the others too
1313
1414***************************************************************************/
1515
r15253r15254
713713    ROM_LOAD16_BYTE( "8.bin", 0x000001, 0x080000, CRC(a8567f1b) SHA1(2a854ef8b1988ad097bbcbeddc4b275ad738e1e1) )
714714
715715   DISK_REGION( "dvd" )
716   DISK_IMAGE( "csplayh8", 0, SHA1(d6514882c2626e62c5079df9ac68ecb70fc33209) )
716   DISK_IMAGE( "csplayh1", 0, SHA1(d6514882c2626e62c5079df9ac68ecb70fc33209) )
717717
718718   ROM_REGION( 0x1000, "gal", ROMREGION_ERASE00 )
719719   ROM_LOAD( "gal16v8b.ic8", 0x000000, 0x0008c1, NO_DUMP )
src/mame/drivers/cps2.c
r15253r15254
91489148   ROM_REGION( CODE_SIZE, "maincpu", 0 )      /* 68000 code */
91499149   ROM_LOAD16_WORD_SWAP( "xvsud.03h", 0x000000, 0x80000, CRC(4e2e76b7) SHA1(812ebe4063a1c5d8c86200a51e6ab00e57e02869) )
91509150   ROM_LOAD16_WORD_SWAP( "xvsud.04h", 0x080000, 0x80000, CRC(290c61a7) SHA1(f0d409048c9d477ee98e6df92febcd4492a291ee) )
9151//   ROM_LOAD16_WORD_SWAP( "xvsd.05a",  0x100000, 0x80000, CRC(de347b11) SHA1(297ae207811df9a4973de1df00b2efaa14a0137d) ) // bad dump?
9151//  ROM_LOAD16_WORD_SWAP( "xvsd.05a",  0x100000, 0x80000, CRC(de347b11) SHA1(297ae207811df9a4973de1df00b2efaa14a0137d) ) // bad dump?
91529152   ROM_LOAD16_WORD_SWAP( "xvs.05a",   0x100000, 0x80000, CRC(7db6025d) SHA1(2d74f48f83f45359bfaca28ab686625766af12ee) )
91539153   ROM_LOAD16_WORD_SWAP( "xvs.06a",   0x180000, 0x80000, CRC(e8e2c75c) SHA1(929408cb5d98e95cec75ea58e4701b0cbdbcd016) )
9154//   ROM_LOAD16_WORD_SWAP( "xvsd.07",   0x200000, 0x80000, CRC(f761ded7) SHA1(e49277398734dea044e7c8ec16800db196905e6f) ) // bad dump ?
9154//  ROM_LOAD16_WORD_SWAP( "xvsd.07",   0x200000, 0x80000, CRC(f761ded7) SHA1(e49277398734dea044e7c8ec16800db196905e6f) ) // bad dump ?
91559155   ROM_LOAD16_WORD_SWAP( "xvs.07",    0x200000, 0x80000, CRC(08f0abed) SHA1(ef16c376232dba63b0b9bc3aa0640f9001ccb68a) )
91569156   ROM_LOAD16_WORD_SWAP( "xvs.08",    0x280000, 0x80000, CRC(81929675) SHA1(19cf7afbc1daaefec40195e40ba74970f3906a1c) )
91579157   ROM_LOAD16_WORD_SWAP( "xvs.09",    0x300000, 0x80000, CRC(9641f36b) SHA1(dcba3482d1ba37ccfb30d402793ee063c6621aed) )
src/mame/drivers/igs017.c
r15253r15254
19781978                     (    BIT(~x, 1)               <<  2   ) |
19791979                     (    BIT( x, 0)               <<  1   ) |
19801980                     (    bit0                  <<  0   ) ;
1981         
1981
19821982         logerror("%s: exec bitswap - mode_3 %02x, mode_f %02x, xor0 %x, val %04x -> %04x\n", machine().describe_context(), m_prot_m3, m_prot_mf, xor0, x, m_prot_val);
19831983
19841984         break;
r15253r15254
21482148
21492149   AM_RANGE(0x000000, 0x07ffff) AM_ROM
21502150   AM_RANGE(0x500000, 0x503fff) AM_RAM
2151//   AM_RANGE(0x910000, 0x910003) accesses appear to be from leftover code where the final checks were disabled
2151//  AM_RANGE(0x910000, 0x910003) accesses appear to be from leftover code where the final checks were disabled
21522152   AM_RANGE(0xb02000, 0xb02fff) AM_READWRITE( spriteram_lsb_r, spriteram_lsb_w ) AM_SHARE("spriteram")
21532153   AM_RANGE(0xb03000, 0xb037ff) AM_RAM_WRITE( lhzb2a_paletteram_w ) AM_SHARE("paletteram")
21542154   AM_RANGE(0xb04024, 0xb04025) AM_WRITE( video_disable_lsb_w )
src/mame/drivers/naomi.c
r15253r15254
55495549    ROM_LOAD( "nja3-key.bin", 0x000000, 0x000004, CRC(e6997eb0) SHA1(c866a5069e28939be5a8fc867bc14791decac3c8) )
55505550
55515551    ROM_REGION( 0x20000, "jyu_io", 0 )  // H8/3334-based I/O board ROM, eventually should be separated out
5552    ROM_LOAD( "jyu1_prg0a.ic3", 0x000000, 0x020000, CRC(aec4dbc1) SHA1(bddd4f345baf7f594998a39c09da18b3834f0ac2) )
5552    ROM_LOAD( "jyu1_prg0a.ic3", 0x000000, 0x020000, CRC(aec4dbc1) SHA1(bddd4f345baf7f594998a39c09da18b3834f0ac2) )
55535553ROM_END
55545554
55555555// this one's weird: the rom test checksum for IC 1 matches a screenshot from h/w, but on h/w it says ---- instead of BAD.
src/mame/drivers/wardner.c
r15253r15254
205205
206206   AM_RANGE(0x8000, 0xffff) AM_ROMBANK("bank1") /* Overlapped RAM/Banked ROM - See below */
207207
208   AM_RANGE(0x8000, 0x8fff) AM_WRITE(wardner_sprite_w) AM_SHARE("spriteram")
208   AM_RANGE(0x8000, 0x8fff) AM_WRITE(wardner_sprite_w) AM_SHARE("spriteram8")
209209   AM_RANGE(0x9000, 0x9fff) AM_ROM
210210   AM_RANGE(0xa000, 0xadff) AM_WRITE(paletteram_xBBBBBGGGGGRRRRR_byte_le_w) AM_SHARE("paletteram")
211211   AM_RANGE(0xae00, 0xafff) AM_RAM AM_SHARE("rambase_ae00")
r15253r15254
430430   MCFG_MC6845_ADD("crtc", HD6845, XTAL_14MHz/4, twincobr_mc6845_intf)   /* 3.5MHz measured on CLKin */
431431
432432   MCFG_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
433   MCFG_BUFFERED_SPRITERAM16_ADD("spriteram")
433   MCFG_BUFFERED_SPRITERAM8_ADD("spriteram8")
434434
435435   MCFG_SCREEN_ADD("screen", RASTER)
436436   MCFG_SCREEN_RAW_PARAMS(XTAL_14MHz/2, 446, 0, 320, 286, 0, 240)
437437   MCFG_SCREEN_UPDATE_STATIC(toaplan0)
438   MCFG_SCREEN_VBLANK_DEVICE("spriteram", buffered_spriteram16_device, vblank_copy_rising)
438   MCFG_SCREEN_VBLANK_DEVICE("spriteram8", buffered_spriteram8_device, vblank_copy_rising)
439439
440440   MCFG_GFXDECODE(wardner)
441441   MCFG_PALETTE_LENGTH(1792)
src/mame/drivers/r2dx_v33.c
r15253r15254
867867
868868   ROM_REGION( 0x400000, "gfx2", 0 ) /* background gfx */
869869   ROM_LOAD( "back-1", 0x000000, 0x100000, CRC(8b7f9219) SHA1(3412b6f8a4fe245e521ddcf185a53f2f4520eb57) ) /* Same as "MUSHA BACK-1" of other Zero Team sets */
870   ROM_LOAD( "back-2", 0x100000, 0x080000, CRC(ce61c952) SHA1(52a843c8ba428b121fab933dd3b313b2894d80ac) ) /* Same as "MUSHA BACK-1" of other Zero Team sets */
870   ROM_LOAD( "back-2", 0x100000, 0x080000, CRC(ce61c952) SHA1(52a843c8ba428b121fab933dd3b313b2894d80ac) ) /* Same as "MUSHA BACK-2" of other Zero Team sets */
871871
872872   ROM_REGION( 0x800000, "gfx3", 0 ) /* sprite gfx (encrypted) */
873873   ROM_LOAD32_WORD( "obj-1", 0x000000, 0x200000, CRC(45be8029) SHA1(adc164f9dede9a86b96a4d709e9cba7d2ad0e564) ) /* Same as "MUSHA OBJ-1" of other Zero Team sets */
874   ROM_LOAD32_WORD( "obj-2", 0x000002, 0x200000, CRC(cb61c19d) SHA1(151a2ce9c32f3321a974819e9b165dddc31c8153) ) /* Same as "MUSHA OBJ-1" of other Zero Team sets */
874   ROM_LOAD32_WORD( "obj-2", 0x000002, 0x200000, CRC(cb61c19d) SHA1(151a2ce9c32f3321a974819e9b165dddc31c8153) ) /* Same as "MUSHA OBJ-2" of other Zero Team sets */
875875
876876   ROM_REGION( 0x100000, "oki", 0 ) /* ADPCM samples */
877877   ROM_LOAD( "6.pcm", 0x00000, 0x40000, CRC(48be32b1) SHA1(969d2191a3c46871ee8bf93088b3cecce3eccf0c) ) /* Same as other Zero Team sets */
src/mame/drivers/gei.c
r15253r15254
10591059   DEVCB_NULL,                  /* Port C read */
10601060   DEVCB_HANDLER(sound_w)         /* Port C write */
10611061};
1062                                 
1062
10631063static I8255A_INTERFACE( getrivia_ppi8255_1_intf )
10641064{
10651065   DEVCB_INPUT_PORT("IN1"),      /* Port A read */
r15253r15254
10691069   DEVCB_NULL,                  /* Port C read */
10701070   DEVCB_HANDLER(lamps2_w)         /* Port C write */
10711071};
1072                                 
1072
10731073static I8255A_INTERFACE( gselect_ppi8255_0_intf )
10741074{
10751075   DEVCB_INPUT_PORT("DSWA"),      /* Port A read */
r15253r15254
10791079   DEVCB_NULL,                  /* Port C read */
10801080   DEVCB_HANDLER(sound2_w)         /* Port C write */
10811081};
1082                                 
1082
10831083static I8255A_INTERFACE( gselect_ppi8255_1_intf )
10841084{
10851085   DEVCB_INPUT_PORT("IN1"),      /* Port A read */
r15253r15254
10891089   DEVCB_INPUT_PORT("IN2"),      /* Port C read */
10901090   DEVCB_HANDLER(nmi_w)         /* Port C write */
10911091};
1092                                 
1092
10931093static I8255A_INTERFACE( findout_ppi8255_1_intf )
10941094{
10951095   DEVCB_INPUT_PORT("IN1"),      /* Port A read */
r15253r15254
10991099   DEVCB_HANDLER(portC_r),         /* Port C read */
11001100   DEVCB_NULL                  /* Port C write */
11011101};
1102                                                                   
11031102
1103
11041104static INTERRUPT_GEN( vblank_irq )
11051105{
11061106   gei_state *state = device->machine().driver_data<gei_state>();
src/mame/drivers/segas32.c
r15253r15254
31363136   ROM_LOAD( "mpr15552.bin", 0x200000, 0x200000, CRC(1c4b5e73) SHA1(50a8e9a200575a3522a51bf094aa0e87b90bb0a3) )
31373137ROM_END
31383138
3139ROM_START( orunnersj )
3140   ROM_REGION( 0x200000, "maincpu", 0 ) /* v60 code */
3141   ROM_LOAD32_WORD_x4( "epr15616.37", 0x000000, 0x020000, CRC(fb550545) SHA1(2f2c36843b115f5417e1f2ccd4a34ebf91265190) ) /* Need to verify the EPR numbers */
3142   ROM_LOAD32_WORD_x4( "epr15617.40", 0x000002, 0x020000, CRC(6bb741e0) SHA1(d92087a2c0b6de4287e569eecf9758615a85d1eb) ) /* Need to verify the EPR numbers */
3143   ROM_LOAD32_WORD( "mpr15538.bin",   0x100000, 0x080000, CRC(93958820) SHA1(e19b6f18a5707dbb64ae009d63c05eac5bac4a81) )
3144   ROM_LOAD32_WORD( "mpr15539.bin",   0x100002, 0x080000, CRC(219760fa) SHA1(bd62a83de9c9542f6da454a87dc4947492f65c52) )
31393145
3146   ROM_REGION( 0x180000, "soundcpu", 0 ) /* sound CPU */
3147   ROM_LOAD( "epr15550.bin", 0x100000, 0x80000, CRC(0205d2ed) SHA1(3475479e1a45fe96eefbe53842758898db7accbf) )
3148
3149   ROM_REGION( 0x400000, "gfx1", 0 ) /* tiles */
3150   ROM_LOAD16_BYTE( "mpr15548.bin", 0x000000, 0x200000, CRC(b6470a66) SHA1(e1544590c02d41f62f82a4d771b893fb0f2734c7) )
3151   ROM_LOAD16_BYTE( "mpr15549.bin", 0x000001, 0x200000, CRC(81d12520) SHA1(1555893941e832f00ad3d0b3ad0c34a0d3a1c58a) )
3152
3153   ROM_REGION32_BE( 0x1000000, "gfx2", 0 ) /* sprites */
3154   ROMX_LOAD( "mpr15540.bin", 0x000000, 0x200000, CRC(a10d72b4) SHA1(6d9d5e20be6721b53ce49df4d5a1bbd91f5b3aed) , ROM_SKIP(6)|ROM_GROUPWORD )
3155   ROMX_LOAD( "mpr15542.bin", 0x000002, 0x200000, CRC(40952374) SHA1(c669ef52508bc2f49cf812dc86ac98fb535471fa) , ROM_SKIP(6)|ROM_GROUPWORD )
3156   ROMX_LOAD( "mpr15544.bin", 0x000004, 0x200000, CRC(39e3df45) SHA1(38a7b21617b45613b05509dda388f8f7770b186c) , ROM_SKIP(6)|ROM_GROUPWORD )
3157   ROMX_LOAD( "mpr15546.bin", 0x000006, 0x200000, CRC(e3fcc12c) SHA1(1cf7e05c7873f68789a27a91cddf471df40d7907) , ROM_SKIP(6)|ROM_GROUPWORD )
3158   ROMX_LOAD( "mpr15541.bin", 0x800000, 0x200000, CRC(a2003c2d) SHA1(200a2c7d78d3f5f28909267fdcdbddd58c5f5fa2) , ROM_SKIP(6)|ROM_GROUPWORD )
3159   ROMX_LOAD( "mpr15543.bin", 0x800002, 0x200000, CRC(933e8e7b) SHA1(0d53286f524f47851a483569dc37e9f6d34cc5f4) , ROM_SKIP(6)|ROM_GROUPWORD )
3160   ROMX_LOAD( "mpr15545.bin", 0x800004, 0x200000, CRC(53dd0235) SHA1(4aee5ae1820ff933b6bd8a54bdbf989c0bc95c1a) , ROM_SKIP(6)|ROM_GROUPWORD )
3161   ROMX_LOAD( "mpr15547.bin", 0x800006, 0x200000, CRC(edcb2a43) SHA1(f0bcfcc749ca0267f85bf9838164869912944d00) , ROM_SKIP(6)|ROM_GROUPWORD )
3162
3163   ROM_REGION( 0x400000, "sega", 0 ) /* Sega PCM sound data */
3164   ROM_LOAD( "mpr15551.bin", 0x000000, 0x200000, CRC(4894bc73) SHA1(351f5c03fb430fd87df915dfe3a377b5ada622c4) )
3165   ROM_LOAD( "mpr15552.bin", 0x200000, 0x200000, CRC(1c4b5e73) SHA1(50a8e9a200575a3522a51bf094aa0e87b90bb0a3) )
3166ROM_END
3167
3168
31403169/**************************************************************************************************************************
31413170 **************************************************************************************************************************
31423171 **************************************************************************************************************************
r15253r15254
42944323GAME( 1994, harddunkj,harddunk, multi32,      harddunk, harddunk, ROT0, "Sega",   "Hard Dunk (Japan)", GAME_IMPERFECT_GRAPHICS )
42954324GAME( 1992, orunners, 0,        multi32,      orunners, orunners, ROT0, "Sega",   "OutRunners (World)", GAME_IMPERFECT_GRAPHICS )
42964325GAME( 1992, orunnersu,orunners, multi32,      orunners, orunners, ROT0, "Sega",   "OutRunners (US)", GAME_IMPERFECT_GRAPHICS )
4326GAME( 1992, orunnersj,orunners, multi32,      orunners, orunners, ROT0, "Sega",   "OutRunners (Japan)", GAME_IMPERFECT_GRAPHICS )
42974327GAME( 1992, scross,   0,        multi32,      scross,   scross,   ROT0, "Sega",   "Stadium Cross (World)", GAME_IMPERFECT_GRAPHICS )
42984328GAME( 1992, scrossu,  scross,   multi32,      scross,   scross,   ROT0, "Sega",   "Stadium Cross (US)", GAME_IMPERFECT_GRAPHICS )
42994329GAME( 1992, titlef,   0,        multi32,      titlef,   titlef,   ROT0, "Sega",   "Title Fight (World)", GAME_IMPERFECT_GRAPHICS )
src/mame/drivers/neodrvr.c
r15253r15254
547547
548548
549549    Unofficial pcb's from NG:DEV.TEAM:
550   
550
551551    MVS CHA:
552552    GIGA CHAR Board 1.0
553553    GIGA CHAR Board 1.5
554   
554
555555    MVS PROG:
556556    GIGA PROG Board 1.0
557557    GIGA PROG Board 1.5
r15253r15254
646646
647647*****************************************************************************
648648
649   Neo-Geo bios
649    Neo-Geo bios
650650
651651*****************************************************************************
652652
r15253r15254
817817
818818/****************************************************************************
819819
820   Official sets
820    Official sets
821821
822822*****************************************************************************
823823
r15253r15254
75117511
75127512/*  Some info about the 2nd AES release of Samurai Shodown 5 Special (samsh5sph):
75137513
7514   The fixed carts have a small round neogeo sticker applied to the front side of the cart (top right near cart sticker).
7515   SNK Playmore had authorized a recall of all Samurai Shodown V Special (Samurai Spirits 0 Special) home cartridges. This recall involved bug fixes
7516   and the addition of fatalities. (The fatalities were originally removed at the last minute due to the Nagasaki incident, a murder caused by a child killing her classmate by knife.)
7517   Bug fixes: Improvements on Voice, Back Ground Music, and Practice mode.
7518   Fatalities: SNK PLAYMORE modified the game program by including the removed "Zetumei Ougi" in a modified version.
7519   This new version does not show the complete fatalities, they are instead replaced by what SNK PLAYMORE refers to as "lessened fatalities".
7514    The fixed carts have a small round neogeo sticker applied to the front side of the cart (top right near cart sticker).
7515    SNK Playmore had authorized a recall of all Samurai Shodown V Special (Samurai Spirits 0 Special) home cartridges. This recall involved bug fixes
7516    and the addition of fatalities. (The fatalities were originally removed at the last minute due to the Nagasaki incident, a murder caused by a child killing her classmate by knife.)
7517    Bug fixes: Improvements on Voice, Back Ground Music, and Practice mode.
7518    Fatalities: SNK PLAYMORE modified the game program by including the removed "Zetumei Ougi" in a modified version.
7519    This new version does not show the complete fatalities, they are instead replaced by what SNK PLAYMORE refers to as "lessened fatalities".
75207520*/
75217521
75227522
r15253r15254
75967596
75977597/****************************************************************************
75987598
7599   BrezzaSoft games, licensed?
7599    BrezzaSoft games, licensed?
76007600
76017601****************************************************************************/
76027602
r15253r15254
77117711
77127712/****************************************************************************
77137713
7714   Vektorlogic games, unlicensed
7714    Vektorlogic games, unlicensed
77157715
77167716****************************************************************************/
77177717
r15253r15254
77537753
77547754/****************************************************************************
77557755
7756   Jamma PCB sets
7756    Jamma PCB sets
77577757
77587758****************************************************************************/
77597759
r15253r15254
79247924
79257925/****************************************************************************
79267926
7927   Bootleg sets
7927    Bootleg sets
79287928
79297929****************************************************************************/
79307930
r15253r15254
89538953
89548954/****************************************************************************
89558955
8956   Game specific input definitions
8956    Game specific input definitions
89578957
89588958****************************************************************************/
89598959
r15253r15254
92539253
92549254/****************************************************************************
92559255
9256   Game specific inits
9256    Game specific inits
92579257
92589258****************************************************************************/
92599259
r15253r15254
99249924
99259925/****************************************************************************
99269926
9927   Softlist stuff
9927    Softlist stuff
99289928
99299929****************************************************************************/
99309930
src/mame/drivers/statriv2.c
r15253r15254
273273static I8255A_INTERFACE( ppi8255_intf )
274274{
275275   /* PPI 8255 group A & B set to Mode 0.
276    Port A, B and lower 4 bits of C set as Input.
277    High 4 bits of C set as Output */
276     Port A, B and lower 4 bits of C set as Input.
277     High 4 bits of C set as Output */
278278   DEVCB_INPUT_PORT("IN0"),         /* Port A read */
279279   DEVCB_NULL,                     /* Port A write */
280280   DEVCB_INPUT_PORT("IN1"),         /* Port B read */
src/mame/drivers/fortecar.c
r15253r15254
448448static I8255A_INTERFACE( ppi8255_intf )
449449{
450450   /*  Init with 0x9a... A, B and high C as input
451    Serial Eprom connected to Port C */
451    Serial Eprom connected to Port C */
452452   DEVCB_INPUT_PORT("SYSTEM"),                  /* Port A read */
453453   DEVCB_NULL,                              /* Port A write */
454454   DEVCB_INPUT_PORT("INPUT"),                  /* Port B read */
src/mame/drivers/midyunit.c
r15253r15254
742742   PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNKNOWN )
743743INPUT_PORTS_END
744744
745static INPUT_PORTS_START( mkyawdim )
746   PORT_INCLUDE( mkla4 )
745747
748   PORT_MODIFY("IN1")
749   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNUSED ) // no ADPCM in these bootlegs
750INPUT_PORTS_END
751
746752static INPUT_PORTS_START( term2 )
747753   PORT_START("IN0")
748754   PORT_BIT( 0x000f, IP_ACTIVE_LOW, IPT_UNUSED )
r15253r15254
27472753GAME( 1992, mkyturboe,mk,       yunit_adpcm_6bit_fast,   mkla4,    mkyturbo, ROT0, "hack",     "Mortal Kombat (Turbo 3.0 08/31/92, hack)", GAME_SUPPORTS_SAVE )
27482754GAME( 1992, mknifty,  mk,       yunit_adpcm_6bit_fast,   mkla4,    mkyturbo, ROT0, "hack",     "Mortal Kombat (Nifty Kombo, hack)", GAME_SUPPORTS_SAVE )
27492755GAME( 1992, mknifty666, mk,     yunit_adpcm_6bit_fast,   mkla4,    mkyturbo, ROT0, "hack",     "Mortal Kombat (Nifty Kombo 666, hack)", GAME_SUPPORTS_SAVE )
2750GAME( 1992, mkyawdim, mk,       mkyawdim,                mkla4,    mkyawdim, ROT0, "bootleg (Yawdim)", "Mortal Kombat (Yawdim bootleg, set 1)", GAME_SUPPORTS_SAVE )
2751GAME( 1992, mkyawdim2,mk,       mkyawdim,                mkla4,    mkyawdim, ROT0, "bootleg (Yawdim)", "Mortal Kombat (Yawdim bootleg, set 2)", GAME_SUPPORTS_SAVE | GAME_NO_SOUND )
2756GAME( 1992, mkyawdim, mk,       mkyawdim,                mkyawdim, mkyawdim, ROT0, "bootleg (Yawdim)", "Mortal Kombat (Yawdim bootleg, set 1)", GAME_SUPPORTS_SAVE )
2757GAME( 1992, mkyawdim2,mk,       mkyawdim,                mkyawdim, mkyawdim, ROT0, "bootleg (Yawdim)", "Mortal Kombat (Yawdim bootleg, set 2)", GAME_SUPPORTS_SAVE | GAME_NO_SOUND )
27522758
27532759GAME( 1992, totcarn,  0,        yunit_adpcm_6bit_fast,   totcarn,  totcarn,  ROT0, "Midway",   "Total Carnage (rev LA1 03/10/92)", GAME_SUPPORTS_SAVE )
27542760GAME( 1992, totcarnp, totcarn,  yunit_adpcm_6bit_fast,   totcarn,  totcarn,  ROT0, "Midway",   "Total Carnage (prototype, rev 1.0 01/25/92)", GAME_SUPPORTS_SAVE )
src/mame/drivers/bzone.c
r15253r15254
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)
313313   AM_RANGE(0x1820, 0x182f) AM_DEVREADWRITE("pokey", pokeyn_device, read, write)
314314   AM_RANGE(0x1840, 0x1840) AM_DEVWRITE_LEGACY("discrete", bzone_sounds_w)
315315   AM_RANGE(0x1860, 0x187f) AM_DEVWRITE_LEGACY("mathbox", mathbox_go_w)
src/mame/drivers/twincobr.c
r15253r15254
277277static ADDRESS_MAP_START( main_program_map, AS_PROGRAM, 16, twincobr_state )
278278   AM_RANGE(0x000000, 0x02ffff) AM_ROM
279279   AM_RANGE(0x030000, 0x033fff) AM_RAM      /* 68K and DSP shared RAM */
280   AM_RANGE(0x040000, 0x040fff) AM_RAM AM_SHARE("spriteram")
280   AM_RANGE(0x040000, 0x040fff) AM_RAM AM_SHARE("spriteram16")
281281   AM_RANGE(0x050000, 0x050dff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_word_w) AM_SHARE("paletteram")
282282   AM_RANGE(0x060000, 0x060001) AM_DEVWRITE8("crtc", mc6845_device, address_w, 0x00ff)
283283   AM_RANGE(0x060002, 0x060003) AM_DEVWRITE8("crtc", mc6845_device, register_w, 0x00ff)
r15253r15254
583583   MCFG_MC6845_ADD("crtc", HD6845, XTAL_28MHz/8, twincobr_mc6845_intf)   /* 3.5MHz measured on CLKin */
584584
585585   MCFG_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
586   MCFG_BUFFERED_SPRITERAM16_ADD("spriteram")
586   MCFG_BUFFERED_SPRITERAM16_ADD("spriteram16")
587587
588588   MCFG_SCREEN_ADD("screen", RASTER)
589589   MCFG_SCREEN_RAW_PARAMS(XTAL_28MHz/4, 446, 0, 320, 286, 0, 240)
590590   MCFG_SCREEN_UPDATE_STATIC(toaplan0)
591   MCFG_SCREEN_VBLANK_DEVICE("spriteram", buffered_spriteram16_device, vblank_copy_rising)
591   MCFG_SCREEN_VBLANK_DEVICE("spriteram16", buffered_spriteram16_device, vblank_copy_rising)
592592
593593   MCFG_GFXDECODE(twincobr)
594594   MCFG_PALETTE_LENGTH(1792)
src/mame/drivers/tecmo.c
r15253r15254
10781078   ROM_LOAD( "b14-s3.bin",  0x30000, 0x08000, CRC(4d29637a) SHA1(28e85925138256b8ce5a1c4a5df5b219b1b6b197) )   /* tiles #2 */ // half size is correct, rom type 27256
10791079
10801080   ROM_REGION( 0x8000, "adpcm", ROMREGION_ERASE00 )   /* ADPCM samples */
1081//    ROM_LOAD( "silkworm.1",   0x0000, 0x8000, CRC(5b553644) SHA1(5d39d2251094c17f7b732b4861401b3516fce9b1) )
1081// ROM_LOAD( "silkworm.1",   0x0000, 0x8000, CRC(5b553644) SHA1(5d39d2251094c17f7b732b4861401b3516fce9b1) )
10821082ROM_END
10831083
10841084ROM_START( gemini )
src/mame/drivers/decocass.c
r15253r15254
2828
2929    The actual cassettes use a custom player hooked to the BIO board, and are roughly microcassette form factor, but are larger and will not fit in a conventional microcassette player.
3030    Each cassette has two tracks on it: a clock track and a data track, for a form of synchronous serial. The data is stored in blocks with headers and checksums.
31 
3231
32
3333 ***********************************************************************/
3434
3535#include "emu.h"
r15253r15254
10801080   ROM_LOAD( "a-0061.dgl",   0x0000, 0x0020, CRC(1bc9fccb) SHA1(ffc59c7660d5c87a8deca294f80260b6bc7c3027) ) /* Should be dp-1144a?? */
10811081
10821082   ROM_REGION( 0x10000, "cassette", 0 )     /* (max) 64k for cassette image */
1083   ROM_LOAD( "dt-1144-a3.cas", 0x000000, 0x007300, CRC(1336a912) SHA1(0c64e069713b411da38b43f14306953621726d35) )
1083   ROM_LOAD( "dt-1144-a3.cas", 0x000000, 0x007300, CRC(1336a912) SHA1(0c64e069713b411da38b43f14306953621726d35) )
10841084ROM_END
10851085
10861086/* 15 Lucky Poker */
r15253r15254
15671567/* 12 */ // 1981.08 Flash Boy/DECO Kid
15681568/* 13 */ GAME( 1981, cprogolf,  decocass, cprogolf, cprogolf, decocass, ROT270, "Data East Corporation", "Tournament Pro Golf (DECO Cassette)", 0 )
15691569         GAME( 1981, cprogolfj, cprogolf, cprogolfj,cprogolf, decocass, ROT270, "Data East Corporation", "Tournament Pro Golf (DECO Cassette, Japan)", 0 )
1570/* 14 */ GAME( 1981, cdsteljn,  decocass, cdsteljn, decocass, decocass, ROT270, "Data East Corporation", "DS Telejan (DECO Cassette, Japan)", 0)
1570/* 14 */ GAME( 1981, cdsteljn,  decocass, cdsteljn, decocass, decocass, ROT270, "Data East Corporation", "DS Telejan (DECO Cassette, Japan)", 0)
15711571/* 15 */ GAME( 1981, cluckypo,  decocass, cluckypo, decocass, decocass, ROT270, "Data East Corporation", "Lucky Poker (DECO Cassette)", 0 )
15721572/* 16 */ GAME( 1981, ctisland,  decocass, ctisland, decocass, decocrom, ROT270, "Data East Corporation", "Treasure Island (DECO Cassette, set 1)", 0 )
15731573         GAME( 1981, ctisland2, ctisland, ctisland, decocass, decocrom, ROT270, "Data East Corporation", "Treasure Island (DECO Cassette, set 2)", 0 )
src/mame/drivers/quantum.c
r15253r15254
8080
8181static READ8_DEVICE_HANDLER( input_1_r )
8282{
83   return (device->machine().root_device().ioport("DSW0")->read() << (7 - (offset - POT0_C))) & 0x80;
83   return (device->machine().root_device().ioport("DSW0")->read() << (7 - (offset - pokeyn_device::POT0_C))) & 0x80;
8484}
8585
8686
8787static READ8_DEVICE_HANDLER( input_2_r )
8888{
89   return (device->machine().root_device().ioport("DSW1")->read() << (7 - (offset - POT0_C))) & 0x80;
89   return (device->machine().root_device().ioport("DSW1")->read() << (7 - (offset - pokeyn_device::POT0_C))) & 0x80;
9090}
9191
9292
src/mame/drivers/timeplt.c
r15253r15254
9797static WRITE8_DEVICE_HANDLER(chkun_sound_w)
9898{
9999   timeplt_state *state = device->machine().driver_data<timeplt_state>();
100   
100
101101   // d0-d3: P0-P3
102102   // d5: /R (unused?)
103103   // d6: /W
104104   if (~data & 0x40)
105105      state->m_tc8830f->write_p(data & 0xf);
106   
106
107107   // d4 (or d7?): /ACL
108108   if (~data & 0x10)
109109      state->m_tc8830f->reset();
src/mame/drivers/megasys1.c
r15253r15254
40204020static DRIVER_INIT( monkelf )
40214021{
40224022   DRIVER_INIT_CALL(avspirit);
4023   
4023
40244024   megasys1_state *state = machine.driver_data<megasys1_state>();
40254025   UINT16 *ROM = (UINT16*)state->memregion("maincpu")->base();
40264026   ROM[0x00744/2] = 0x4e71; // weird check, 0xe000e R is a port-based trap?
src/mame/drivers/pacman.c
r15253r15254
40504050
40514051   ROM_REGION( 0x2000, "gfx1", 0 )
40524052   ROM_LOAD( "p1.5e",        0x0000, 0x1000, CRC(04333722) SHA1(bb179d5302b26b815b5d7eff14865e7b4f8a6880) )
4053    ROM_LOAD( "p2.5f",        0x1000, 0x1000, CRC(615af909) SHA1(fd6a1dde780b39aea76bf1c4befa5882573c2ef4) )
4053   ROM_LOAD( "p2.5f",        0x1000, 0x1000, CRC(615af909) SHA1(fd6a1dde780b39aea76bf1c4befa5882573c2ef4) )
40544054
40554055   ROM_REGION( 0x0120, "proms", 0 )
40564056   ROM_LOAD( "82s123.7f",    0x0000, 0x0020, CRC(2fc650bd) SHA1(8d0268dee78e47c712202b0ec4f1f51109b1f2a5) )
r15253r15254
40734073
40744074   ROM_REGION( 0x2000, "gfx1", 0 )
40754075   ROM_LOAD( "p7.bin",       0x0000, 0x1000, CRC(04333722) SHA1(bb179d5302b26b815b5d7eff14865e7b4f8a6880) )
4076    ROM_LOAD( "p8.bin",       0x1000, 0x1000, CRC(615af909) SHA1(fd6a1dde780b39aea76bf1c4befa5882573c2ef4) )
4076   ROM_LOAD( "p8.bin",       0x1000, 0x1000, CRC(615af909) SHA1(fd6a1dde780b39aea76bf1c4befa5882573c2ef4) )
40774077
40784078   ROM_REGION( 0x0120, "proms", 0 )
40794079   ROM_LOAD( "82s123.7f",    0x0000, 0x0020, CRC(2fc650bd) SHA1(8d0268dee78e47c712202b0ec4f1f51109b1f2a5) )
src/mame/drivers/chance32.c
r15253r15254
1/*
1/*********************************************************
22
3Chance 32 - Poker Game by PAL Company
3  Chance 32
44
51x HD46505SP / HD6845SP
61x Z84C0008PEC
5  PAL System Co, Ltd.
6  Osaka, Japan.
77
8XTAL: 12.000 Mhz
8  Driver by David Haywood, Angelo Salese & Roberto Fresca.
99
1010
11 todo, fix tilemaps, colours, inputs, hook up oki, add CRTC device
11  1x HD46505SP / HD6845SP
12  1x Z84C0008PEC
1213
13*/
14  XTAL: 12.000 Mhz
1415
16
17*********************************************************/
18
1519#include "emu.h"
1620#include "cpu/z80/z80.h"
1721#include "sound/okim6295.h"
1822#include "video/mc6845.h"
1923
24#include "chance32.lh"
2025
2126
2227class chance32_state : public driver_device
r15253r15254
4247   }
4348
4449   DECLARE_WRITE8_MEMBER(mux_w);
50   DECLARE_WRITE8_MEMBER(muxout_w);
4551   DECLARE_READ8_MEMBER(mux_r);
4652
4753   tilemap_t *m_fg_tilemap;
r15253r15254
5359   UINT8 mux_data;
5460};
5561
62
5663static TILE_GET_INFO( get_fg_tile_info )
5764{
5865   chance32_state *state = machine.driver_data<chance32_state>();
r15253r15254
9198   state->m_bg_tilemap->set_flip(TILE_FLIPX|TILE_FLIPY);
9299}
93100
101
94102SCREEN_UPDATE_IND16( chance32 )
95103{
96104   chance32_state *state = screen.machine().driver_data<chance32_state>();
r15253r15254
108116}
109117
110118
111static ADDRESS_MAP_START( chance32_map, AS_PROGRAM, 8, chance32_state )
112   AM_RANGE(0x0000, 0xcfff) AM_ROM
113   AM_RANGE(0xd800, 0xdfff) AM_RAM
114
115   AM_RANGE(0xe000, 0xefff) AM_RAM_WRITE(paletteram_xGGGGGRRRRRBBBBB_byte_le_w) AM_SHARE("paletteram")
116
117   AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(chance32_fgram_w) AM_SHARE("fgram")
118   AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(chance32_bgram_w) AM_SHARE("bgram")
119ADDRESS_MAP_END
120
121119WRITE8_MEMBER(chance32_state::mux_w)
122120{
123121   mux_data = data;
r15253r15254
138136   return res;
139137}
140138
139
140WRITE8_MEMBER(chance32_state::muxout_w)
141{
142/* Muxed Lamps
143
144  There are 2 groups of 7 output lines muxed in port 60h
145  The first bit is the group/mux selector.
146
147  - bits -
148  7654 3210
149  ---- ---x   Mux selector.
150  ---- --x-   Small / Big lamps.
151  ---- -x--   Big / Small lamps.
152  ---- x---   Hold 5 lamp.
153  ---x ----   Hold 4 lamp.
154  --x- ----   Hold 3 lamp.
155  -x-- ----   Hold 2 lamp.
156  x--- ----   Hold 1 lamp.
157
158  (alt state)
159
160  - bits -
161  7654 3210
162  ---- ---x   Mux selector.
163  ---- --x-   unknown...
164  ---- -x--   Fever lamp
165  ---- x---   Cancel lamp.
166  ---x ----   D-Up / Take lamps.
167  --x- ----   Take / D-Up lamps.
168  -x-- ----   Deal lamp.
169  x--- ----   Bet lamp.
170
171*/
172   if (data & 1)   // bit 0 is the mux selector.
173
174   {
175      output_set_lamp_value(0, (data >> 1) & 1);   /* Lamp 0 - Small / Big */
176      output_set_lamp_value(1, (data >> 2) & 1);   /* Lamp 1 - Big / Small */
177      output_set_lamp_value(2, (data >> 3) & 1);   /* Lamp 2 - Hold 5 */
178      output_set_lamp_value(3, (data >> 4) & 1);   /* Lamp 3 - Hold 4 */
179      output_set_lamp_value(4, (data >> 5) & 1);   /* Lamp 4 - Hold 3 */
180      output_set_lamp_value(5, (data >> 6) & 1);   /* Lamp 5 - Hold 2 */
181      output_set_lamp_value(6, (data >> 7) & 1);   /* Lamp 6 - Hold 1 */
182
183      logerror("Lamps A: %02x\n", data);
184   }
185
186   else
187   {
188      // bit 1 is unknown...
189      output_set_lamp_value(7, (data >> 2) & 1);   /* Lamp 7 - Fever! */
190      output_set_lamp_value(8, (data >> 3) & 1);   /* Lamp 8 - Cancel */
191      output_set_lamp_value(9, (data >> 4) & 1);   /* Lamp 9 - D-Up / Take */
192      output_set_lamp_value(10, (data >> 5) & 1);   /* Lamp 10 - Take / D-Up */
193      output_set_lamp_value(11, (data >> 6) & 1);   /* Lamp 11 - Deal */
194      output_set_lamp_value(12, (data >> 7) & 1);   /* Lamp 12 - Bet */
195
196      logerror("Lamps B: %02x\n", data);
197   }
198}
199
200
201static ADDRESS_MAP_START( chance32_map, AS_PROGRAM, 8, chance32_state )
202   AM_RANGE(0x0000, 0xcfff) AM_ROM
203   AM_RANGE(0xd800, 0xdfff) AM_RAM
204   AM_RANGE(0xe000, 0xefff) AM_RAM_WRITE(paletteram_xGGGGGRRRRRBBBBB_byte_le_w) AM_SHARE("paletteram")
205   AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(chance32_fgram_w) AM_SHARE("fgram")
206   AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(chance32_bgram_w) AM_SHARE("bgram")
207ADDRESS_MAP_END
208
141209static ADDRESS_MAP_START( chance32_portmap, AS_IO, 8, chance32_state )
142210   ADDRESS_MAP_GLOBAL_MASK(0xff)
143   //AM_RANGE(0x10, 0x10) AM_WRITENOP // ?
211   AM_RANGE(0x10, 0x10) AM_WRITENOP      // writting bit3 constantly... watchdog?
144212   AM_RANGE(0x13, 0x13) AM_WRITE(mux_w)
145213   AM_RANGE(0x20, 0x20) AM_READ_PORT("DSW0")
146214   AM_RANGE(0x21, 0x21) AM_READ_PORT("DSW1")
r15253r15254
148216   AM_RANGE(0x23, 0x23) AM_READ_PORT("DSW3")
149217   AM_RANGE(0x24, 0x24) AM_READ_PORT("DSW4")
150218   AM_RANGE(0x25, 0x25) AM_READ(mux_r)
151//  AM_RANGE(0x26, 0x26) AM_READ_PORT("UNK") // vblank?
219   AM_RANGE(0x26, 0x26) AM_READ_PORT("UNK") // vblank (other bits are checked for different reasons)
152220   AM_RANGE(0x30, 0x30) AM_DEVWRITE("crtc", mc6845_device, address_w)
153221   AM_RANGE(0x31, 0x31) AM_DEVWRITE("crtc", mc6845_device, register_w)
154222   AM_RANGE(0x50, 0x50) AM_DEVREADWRITE("oki", okim6295_device, read, write)
155//  AM_RANGE(0x60, 0x60) AM_WRITENOP // lamps
156
223   AM_RANGE(0x60, 0x60) AM_WRITE(muxout_w)
157224ADDRESS_MAP_END
158225
159226
160
161227static INPUT_PORTS_START( chance32 )
162   PORT_START("UNK")
163228
164229   PORT_START("DSW0")
165230   PORT_DIPNAME( 0x01, 0x00, "DSW0" )
r15253r15254
168233   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) )
169234   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
170235   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
171   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) )
236   PORT_DIPNAME( 0x04, 0x00, "Auto Max Bet" )
172237   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
173238   PORT_DIPSETTING(    0x04, DEF_STR( On ) )
174   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) )
239   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Flip_Screen ) )
175240   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
176241   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
177242   PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) )
r15253r15254
180245   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) )
181246   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
182247   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
183   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
184   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
185   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
186   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
187   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
188   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
248   PORT_DIPNAME( 0xc0, 0x00, "Maximum Bet" )
249   PORT_DIPSETTING(    0x00, "10" )
250   PORT_DIPSETTING(    0x40, "20" )
251   PORT_DIPSETTING(    0x80, "30" )
252   PORT_DIPSETTING(    0xc0, "50" )
189253
190254   PORT_START("DSW1")
191255   PORT_DIPNAME( 0x01, 0x00, "DSW1" )
r15253r15254
206270   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) )
207271   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
208272   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
209   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
210   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
211   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
212   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
213   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
214   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
273   PORT_DIPNAME( 0x40, 0x00, "Auto Hold" )
274   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
275   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
276   PORT_DIPNAME( 0x80, 0x00, "Double-Up Type" )
277   PORT_DIPSETTING(    0x00, "Holds" )
278   PORT_DIPSETTING(    0x80, "Big/Small" )
215279
216280   PORT_START("DSW2")
217   PORT_DIPNAME( 0x01, 0x00, "DSW2" )
281   PORT_DIPNAME( 0x07, 0x00, "Remote" )
282   PORT_DIPSETTING(    0x00, "5" )
283   PORT_DIPSETTING(    0x01, "10" )
284   PORT_DIPSETTING(    0x02, "20" )
285   PORT_DIPSETTING(    0x03, "25" )
286   PORT_DIPSETTING(    0x04, "40" )
287   PORT_DIPSETTING(    0x05, "50" )
288   PORT_DIPSETTING(    0x06, "60" )
289   PORT_DIPSETTING(    0x07, "100" )
290   PORT_DIPNAME( 0x38, 0x00, "A-B Coinage Multiplier" )
291   PORT_DIPSETTING(    0x00, "x1" )
292   PORT_DIPSETTING(    0x08, "x2" )
293   PORT_DIPSETTING(    0x10, "x4" )
294   PORT_DIPSETTING(    0x18, "x5" )
295   PORT_DIPSETTING(    0x20, "x6" )
296   PORT_DIPSETTING(    0x28, "x10" )
297   PORT_DIPSETTING(    0x30, "x25" )
298   PORT_DIPSETTING(    0x38, "x50" )
299   PORT_DIPNAME( 0x40, 0x00, "DSW2" )
218300   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
219   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
220   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) )
221   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
222   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
223   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) )
224   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
225   PORT_DIPSETTING(    0x04, DEF_STR( On ) )
226   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) )
227   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
228   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
229   PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) )
230   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
231   PORT_DIPSETTING(    0x10, DEF_STR( On ) )
232   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) )
233   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
234   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
235   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
236   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
237301   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
238302   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
239303   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
r15253r15254
269333   PORT_DIPNAME( 0x01, 0x00, "DSW4" )
270334   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
271335   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
272   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) )
273   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
274   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
275   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) )
276   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
277   PORT_DIPSETTING(    0x04, DEF_STR( On ) )
336   PORT_DIPNAME( 0x06, 0x00, "Bet Limit" )
337   PORT_DIPSETTING(    0x00, "5000" )
338   PORT_DIPSETTING(    0x02, "10000" )
339   PORT_DIPSETTING(    0x04, "20000" )
340   PORT_DIPSETTING(    0x06, "30000" )
278341   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) )
279342   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
280343   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
r15253r15254
291354   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
292355   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
293356
294   PORT_START("IN0")
295   PORT_DIPNAME( 0x01, 0x00, "0" )
296   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
297   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
357   PORT_START("UNK")
358   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_VBLANK("screen")   /* Otherwise is a 'Freeze' DIP switch */
298359   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) )
299360   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
300361   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
r15253r15254
317378   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
318379   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
319380
381   PORT_START("IN0")
382   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_POKER_CANCEL )
383   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_GAMBLE_DEAL )
384   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_GAMBLE_D_UP )
385   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_GAMBLE_BOOK )
386   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_POKER_BET )
387   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
388   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
389   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
390
320391   PORT_START("IN1")
321   PORT_DIPNAME( 0x01, 0x00, "1" )
322   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
323   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
324   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) )
325   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
326   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
327   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) )
328   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
329   PORT_DIPSETTING(    0x04, DEF_STR( On ) )
330   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) )
331   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
332   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
333   PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) )
334   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
335   PORT_DIPSETTING(    0x10, DEF_STR( On ) )
336   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) )
337   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
338   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
339   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
340   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
341   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
342   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
343   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
344   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
392   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_POKER_HOLD1 )
393   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_POKER_HOLD2 )
394   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_POKER_HOLD3 )
395   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_POKER_HOLD4 )
396   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_POKER_HOLD5 )
397   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
398   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
399   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
345400
346401   PORT_START("IN2")
347   PORT_DIPNAME( 0x01, 0x00, "2" )
348   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
349   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
350   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) )
351   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
352   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
353   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) )
354   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
355   PORT_DIPSETTING(    0x04, DEF_STR( On ) )
356   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) )
357   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
358   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
359   PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) )
360   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
361   PORT_DIPSETTING(    0x10, DEF_STR( On ) )
362   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) )
363   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
364   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
365   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
366   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
367   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
368   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
369   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
370   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
402   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_GAMBLE_LOW )   PORT_NAME("Small / DIP Test (In Book Mode)")
403   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_GAMBLE_PAYOUT )   // payout (hopper jam)
404   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_GAMBLE_TAKE )
405   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_GAMBLE_HIGH )  PORT_NAME("Big")
406   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN )
407   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
408   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
409   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
371410
372411   PORT_START("IN3")
373   PORT_DIPNAME( 0x01, 0x00, "3" )
374   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
375   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
376   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) )
377   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
378   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
379   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) )
380   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
381   PORT_DIPSETTING(    0x04, DEF_STR( On ) )
382   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) )
383   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
384   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
385   PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) )
386   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
387   PORT_DIPSETTING(    0x10, DEF_STR( On ) )
388   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) )
389   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
390   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
391   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
392   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
393   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
394   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
395   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
396   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
412   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNKNOWN )
413   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN1 )   PORT_IMPULSE(3) PORT_NAME("Coin A")
414   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
415   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_SERVICE1 ) PORT_CODE(KEYCODE_R) PORT_NAME("Reset")
416   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_COIN2 )   PORT_IMPULSE(3) PORT_NAME("Coin B")
417   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SERVICE1 ) PORT_CODE(KEYCODE_8) PORT_NAME("Flip Screen 1")   /* unknown purpose */
418   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SERVICE1 ) PORT_CODE(KEYCODE_9) PORT_NAME("Flip Screen 2")   /* unknown purpose */
419   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_GAMBLE_KEYIN)
397420INPUT_PORTS_END
398421
422
399423static const gfx_layout tiles8x8_layout =
400424{
401425   16,8,
r15253r15254
413437GFXDECODE_END
414438
415439
416
417440static MACHINE_START( chance32 )
418441{
419442
r15253r15254
424447
425448}
426449
450
427451static const mc6845_interface mc6845_intf =
428452{
429453   "screen",   /* screen we are acting on */
r15253r15254
452476
453477   /* video hardware */
454478   MCFG_SCREEN_ADD("screen", RASTER)
455   MCFG_SCREEN_REFRESH_RATE(60)
479   MCFG_SCREEN_REFRESH_RATE(52.786)
480//  MCFG_SCREEN_REFRESH_RATE(60)
456481   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
457482   MCFG_SCREEN_SIZE(40*16, 32*8)
458483   MCFG_SCREEN_VISIBLE_AREA(0, 35*16-1, 0, 29*8-1)
459484   MCFG_SCREEN_UPDATE_STATIC(chance32)
460485
461   MCFG_MC6845_ADD("crtc", H46505, 12000000/14, mc6845_intf)   /* hand tuned to get ~60 fps */
486   MCFG_MC6845_ADD("crtc", H46505, 12000000/16, mc6845_intf)   /* 52.786 Hz (similar to Major Poker) */
462487
463488   MCFG_GFXDECODE(chance32)
464489   MCFG_PALETTE_LENGTH(0x800)
r15253r15254
468493   /* sound hardware */
469494   MCFG_SPEAKER_STANDARD_MONO("mono")
470495
471   MCFG_OKIM6295_ADD("oki", 12000000/12, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified
496   /* clock at 1050 kHz match the 8000 Hz samples stored inside the ROM */
497   MCFG_OKIM6295_ADD("oki", XTAL_1_056MHz, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified
472498   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
473499MACHINE_CONFIG_END
474500
475501
476
477502ROM_START( chance32 )
478503   ROM_REGION( 0x10000, "maincpu", 0 )
479504   ROM_LOAD( "0.u52", 0x00000, 0x10000, CRC(331048b2) SHA1(deb4da570b3efe6e15deefb6351f925b642b4614)  )
r15253r15254
508533ROM_END
509534
510535
536/*************************
537*      Game Drivers      *
538*************************/
511539
512
513
514GAME( 19??, chance32,  0,    chance32, chance32,  0, ROT0, "Pal Company", "Chance Thirty Two", GAME_NOT_WORKING )
540/*     YEAR  NAME      PARENT  MACHINE   INPUT     INIT  ROT    COMPANY                FULLNAME            FLAGS  LAYOUT */
541GAMEL( 19??, chance32, 0,      chance32, chance32, 0,    ROT0, "PAL System Co, Ltd.", "Chance Thirty Two", 0,     layout_chance32 )
src/mame/drivers/crimfght.c
r15253r15254
2626static INTERRUPT_GEN( crimfght_interrupt )
2727{
2828   crimfght_state *state = device->machine().driver_data<crimfght_state>();
29
29
3030   if (k051960_is_irq_enabled(state->m_k051960))
3131      device_set_input_line(device, KONAMI_IRQ_LINE, HOLD_LINE);
3232}
src/emu/cpu/i386/i386.c
r15253r15254
107107   UINT8 rights;
108108   if(!(selector & ~3))
109109      return;
110   
110
111111   if ( selector & 0x4 )
112112      base = cpustate->ldtr.base;
113113   else
r15253r15254
458458      i386_load_segment_descriptor(cpustate, reg);
459459      if(fault) *fault = false;
460460      return;
461   }     
462   
461   }
462
463463   if(fault) *fault = true;
464464   if(reg == SS)
465465   {
r15253r15254
10301030   WRITE16(cpustate,tss+0x28,cpustate->sreg[DS].selector);
10311031
10321032   old_task = cpustate->task.segment;
1033   
1033
10341034   /* Load task register with the selector of the incoming task */
10351035   cpustate->task.segment = selector;
10361036   memset(&seg, 0, sizeof(seg));
src/emu/cpu/powerpc/ppccom.h
r15253r15254
567567   ppcimp_state *   impstate;
568568
569569   read32_device_func   dcr_read_func;
570   write32_device_func   dcr_write_func;   
570   write32_device_func   dcr_write_func;
571571};
572572
573573
src/emu/cpu/powerpc/ppc.h
r15253r15254
152152{
153153   UINT32      bus_frequency;
154154   read32_device_func   dcr_read_func;
155   write32_device_func   dcr_write_func;   
155   write32_device_func   dcr_write_func;
156156};
157157
158158
src/emu/rendlay.c
r15253r15254
821821      case CTYPE_DOTMATRIXDOT:
822822         draw_dotmatrix(1, dest, bounds, state);
823823         break;
824         
824
825825      case CTYPE_SIMPLECOUNTER:
826826         draw_simplecounter(machine, dest, bounds, state);
827827         break;
src/emu/rendlay.h
r15253r15254
122122         CTYPE_LED16SEGSC,
123123         CTYPE_DOTMATRIX,
124124         CTYPE_DOTMATRIX5DOT,
125         CTYPE_DOTMATRIXDOT,         
125         CTYPE_DOTMATRIXDOT,
126126         CTYPE_SIMPLECOUNTER,
127127         CTYPE_REEL,
128128         CTYPE_MAX
src/emu/sound/tc8830f.c
r15253r15254
22
33    tc8830f.c - Toshiba TC8830F, CMOS voice recording/reproducing LSI
44    1-bit ADM (Adaptive Delta Modulation), similar to TC8801 and T6668.
5   
5
66    Very preliminary...
77
88    TODO:
r15253r15254
3636
3737   m_mem_base = (UINT8 *)device().machine().root_device().memregion(":tc8830f")->base();
3838   m_mem_mask = device().machine().root_device().memregion(":tc8830f")->bytes() - 1;
39   
39
4040   // register for savestates
4141   save_item(NAME(m_playing));
4242   save_item(NAME(m_address));
r15253r15254
4646   save_item(NAME(m_command));
4747   save_item(NAME(m_cmd_rw));
4848   save_item(NAME(m_phrase));
49   
49
5050   reset();
5151}
5252
r15253r15254
8181            if (m_address == m_stop_address)
8282               m_playing = false;
8383         }
84         
84
8585         // compute sample
8686         // this is a placeholder until ADM is implemented
8787         mix = bit * 0x7fff;
r15253r15254
111111{
112112   m_stream->update();
113113   data &= 0xf;
114   
114
115115   if (m_cmd_rw == 0)
116116   {
117117      // select command
r15253r15254
138138         case 0x8: case 0x9: case 0xa: case 0xb:
139139            logerror("tc8830f: Unemulated command %X\n", m_command);
140140            break;
141         
141
142142         default:
143143            logerror("tc8830f: Invalid command %X\n", m_command);
144144            break;
145145      }
146146   }
147   
147
148148   else
149149   {
150150      // write command
r15253r15254
170170               m_cmd_rw = -1;
171171            }
172172            break;
173         
173
174174         case 0x6:
175175            // CNDT: d0-d1: bitrate, d2: enable overflow
176176            m_bitrate = data & 3;
177177            device_clock_changed();
178178            m_cmd_rw = -1;
179179            break;
180         
180
181181         case 0x7:
182182            // LABEL: set phrase
183183            if (m_cmd_rw == 1)
r15253r15254
199199               m_cmd_rw = -1;
200200            }
201201            break;
202         
202
203203         default:
204204            m_cmd_rw = -1;
205205            break;
src/emu/sound/tc8830f.h
r15253r15254
5454    UINT8 m_command;
5555    int m_cmd_rw;
5656    UINT8 m_phrase;
57   
57
5858    UINT8 *m_mem_base;
5959    UINT32 m_mem_mask;
6060};
src/emu/sound/pokey.c
r15253r15254
5959#include "emu.h"
6060#include "pokey.h"
6161
62/*
63 * Defining this produces much more (about twice as much)
64 * but also more efficient code. Ideally this should be set
65 * for processors with big code cache and for healthy compilers :)
66 */
67#ifndef BIG_SWITCH
68#ifndef HEAVY_MACRO_USAGE
69#define HEAVY_MACRO_USAGE   1
70#endif
71#else
72#define HEAVY_MACRO_USAGE   BIG_SWITCH
73#endif
74
75#define SUPPRESS_INAUDIBLE   1
76
7762/* Four channels with a range of 0..32767 and volume 0..15 */
7863//#define POKEY_DEFAULT_GAIN (32767/15/4)
7964
r15253r15254
8368 * 6 * 15 * 4 = 360, 360/256 = 1.40625
8469 * I use 15/11 = 1.3636, so this is a little lower.
8570 */
71
8672#define POKEY_DEFAULT_GAIN (32767/11/4)
8773
8874#define VERBOSE       1
r15253r15254
161147#define DIV_64      28       /* divisor for 1.78979 MHz clock to 63.9211 kHz */
162148#define DIV_15      114     /* divisor for 1.78979 MHz clock to 15.6999 kHz */
163149
164typedef struct _pokey_state pokey_state;
165struct _pokey_state
166{
167   INT32 clock_cnt[3];      /* clock counters */
168   INT32 borrow_cnt[4];   /* borrow counters */
169
170   INT32 counter[4];      /* channel counter */
171   INT32 divisor[4];      /* channel divisor (modulo value) */
172   UINT32 volume[4];      /* channel volume - derived */
173   UINT8 output[4];      /* channel output signal (1 active, 0 inactive) */
174   UINT8 filter_sample[4];  /* hi-pass filter sample */
175   UINT32 p4;              /* poly4 index */
176   UINT32 p5;              /* poly5 index */
177   UINT32 p9;              /* poly9 index */
178   UINT32 p17;             /* poly17 index */
179   UINT32 r9;            /* rand9 index */
180   UINT32 r17;             /* rand17 index */
181   UINT32 clockmult;      /* clock multiplier */
182   device_t *device;
183   sound_stream * m_stream; /* streams channel */
184   emu_timer *timer[3];   /* timers for channel 1,2 and 4 events */
185   attotime timer_period[3];   /* computed periods for these timers */
186   int timer_param[3];      /* computed parameters for these timers */
187   emu_timer *rtimer;     /* timer for calculating the random offset */
188   emu_timer *ptimer[8];   /* pot timers */
189   devcb_resolved_read8 pot_r[8];
190   devcb_resolved_read8 allpot_r;
191   devcb_resolved_read8 serin_r;
192   devcb_resolved_write8 serout_w;
193   void (*interrupt_cb)(device_t *device, int mask);
194   UINT8 AUDF[4];          /* AUDFx (D200, D202, D204, D206) */
195   UINT8 AUDC[4];         /* AUDCx (D201, D203, D205, D207) */
196   UINT8 POTx[8];         /* POTx   (R/D200-D207) */
197   UINT8 AUDCTL;         /* AUDCTL (W/D208) */
198   UINT8 ALLPOT;         /* ALLPOT (R/D208) */
199   UINT8 KBCODE;         /* KBCODE (R/D209) */
200   UINT8 RANDOM;         /* RANDOM (R/D20A) */
201   UINT8 SERIN;         /* SERIN  (R/D20D) */
202   UINT8 SEROUT;         /* SEROUT (W/D20D) */
203   UINT8 IRQST;         /* IRQST  (R/D20E) */
204   UINT8 IRQEN;         /* IRQEN  (W/D20E) */
205   UINT8 SKSTAT;         /* SKSTAT (R/D20F) */
206   UINT8 SKCTL;         /* SKCTL  (W/D20F) */
207   pokey_interface intf;
208   attotime clock_period;
209   attotime ad_time_fast;
210   attotime ad_time_slow;
211
212   UINT8 poly4[0x0f];
213   UINT8 poly5[0x1f];
214   UINT8 poly9[0x1ff];
215   UINT8 poly17[0x1ffff];
216
217   UINT8 rand9[0x1ff];
218   UINT8 rand17[0x1ffff];
219};
220
221
222150#define P4(chip)  chip->poly4[chip->p4]
223151#define P5(chip)  chip->poly5[chip->p5]
224152#define P9(chip)  chip->poly9[chip->p9]
225153#define P17(chip) chip->poly17[chip->p17]
226154
227static TIMER_CALLBACK( pokey_timer_expire );
228static TIMER_CALLBACK( pokey_pot_trigger );
229
230155#define CLK_1 0
231156#define CLK_28 1
232157#define CLK_114 2
233158
234159static const int clock_divisors[3] = {1, 28, 114};
235160
236INLINE pokey_state *get_safe_token(device_t *device)
237{
238   assert(device != NULL);
239#ifdef OLDDEVICE_FOR_MESS
240   assert(device->type() == POKEY);
241#endif
242   return (pokey_state *)downcast<legacy_device_base *>(device)->token();
243}
244161
245INLINE void reset_channel(pokey_state *chip, int ch)
246{
247   chip->counter[ch] = chip->AUDF[ch] ^ 0xff;
248}
249162
250163
251INLINE void process_channel(pokey_state *chip, int ch)
252{
253   int toggle = 0;
254
255   if( (chip->AUDC[ch] & NOTPOLY5) || P5(chip) )
256   {
257      if( chip->AUDC[ch] & PURE )
258         toggle = 1;
259      else
260      if( chip->AUDC[ch] & POLY4 )
261         toggle = chip->output[ch] == !P4(chip);
262      else
263      if( chip->AUDCTL & POLY9 )
264         toggle = chip->output[ch] == !P9(chip);
265      else
266         toggle = chip->output[ch] == !P17(chip);
267   }
268   if( toggle )
269   {
270      chip->output[ch] ^= 1;
271   }
272}
273
274/*
275 * http://www.atariage.com/forums/topic/3328-sio-protocol/page__st__100#entry1680190:
276 * I noticed that the Pokey counters have clocked carry (actually, "borrow") positions that delay the
277 * counter by 3 cycles, plus the 1 reset clock. So 16 bit mode has 6 carry delays and a reset clock.
278 * I'm sure this was done because the propagation delays limited the number of cells the subtraction could ripple though.
279 *
280 */
281
282INLINE void inc_chan(pokey_state *chip, int ch)
283{
284   chip->counter[ch] = (chip->counter[ch] + 1) & 0xff;
285   if (chip->counter[ch] == 0 && chip->borrow_cnt[ch] == 0)
286      chip->borrow_cnt[ch] = 3;
287}
288
289INLINE int check_borrow(pokey_state *chip, int ch)
290{
291   if (chip->borrow_cnt[ch] > 0)
292   {
293      chip->borrow_cnt[ch]--;
294      return (chip->borrow_cnt[ch] == 0);
295   }
296   return 0;
297}
298
299static STREAM_UPDATE( pokey_update )
300{
301   pokey_state *chip = (pokey_state *)param;
302   stream_sample_t *buffer = outputs[0];
303   int base_clock = (chip->AUDCTL & CLK_15KHZ) ? CLK_114 : CLK_28;
304
305   while( samples > 0 )
306   {
307      int ch, clk;
308      UINT32 sum = 0;
309      int clock_triggered[3] = {0,0,0};
310
311      for (clk = 0; clk < 3; clk++)
312      {
313         chip->clock_cnt[clk]++;
314         if (chip->clock_cnt[clk] >= clock_divisors[clk])
315         {
316            chip->clock_cnt[clk] = 0;
317            clock_triggered[clk] = 1;
318         }
319      }
320
321      chip->p4 = (chip->p4 + 1) % 0x0000f;
322      chip->p5 = (chip->p5 + 1) % 0x0001f;
323      chip->p9 = (chip->p9 + 1) % 0x001ff;
324      chip->p17 = (chip->p17 + 1 ) % 0x1ffff;
325
326
327      clk = (chip->AUDCTL & CH1_HICLK) ? CLK_1 : base_clock;
328      if (clock_triggered[clk])
329         inc_chan(chip, CHAN1);
330
331      clk = (chip->AUDCTL & CH3_HICLK) ? CLK_1 : base_clock;
332      if (clock_triggered[clk])
333         inc_chan(chip, CHAN3);
334
335      if (clock_triggered[base_clock])
336      {
337         if (!(chip->AUDCTL & CH12_JOINED))
338            inc_chan(chip, CHAN2);
339         if (!(chip->AUDCTL & CH34_JOINED))
340            inc_chan(chip, CHAN4);
341      }
342
343      /* do CHAN2 before CHAN1 because CHAN1 may set borrow! */
344      if (check_borrow(chip, CHAN2))
345      {
346         int isJoined = (chip->AUDCTL & CH12_JOINED);
347         if (isJoined)
348            reset_channel(chip, CHAN1);
349         reset_channel(chip, CHAN2);
350         process_channel(chip, CHAN2);
351      }
352
353      if (check_borrow(chip, CHAN1))
354      {
355         int isJoined = (chip->AUDCTL & CH12_JOINED);
356         if (isJoined)
357            inc_chan(chip, CHAN2);
358         else
359            reset_channel(chip, CHAN1);
360         process_channel(chip, CHAN1);
361      }
362
363      /* do CHAN4 before CHAN3 because CHAN3 may set borrow! */
364      if (check_borrow(chip, CHAN4))
365      {
366         int isJoined = (chip->AUDCTL & CH34_JOINED);
367         if (isJoined)
368            reset_channel(chip, CHAN3);
369         reset_channel(chip, CHAN4);
370         process_channel(chip, CHAN4);
371         /* is this a filtering channel (3/4) and is the filter active? */
372         if (chip->AUDCTL & CH2_FILTER)
373            chip->filter_sample[CHAN2] = chip->output[CHAN2];
374         else
375            chip->filter_sample[CHAN2] = 1;
376      }
377
378      if (check_borrow(chip, CHAN3))
379      {
380         int isJoined = (chip->AUDCTL & CH34_JOINED);
381         if (isJoined)
382            inc_chan(chip, CHAN4);
383         else
384            reset_channel(chip, CHAN3);
385         process_channel(chip, CHAN3);
386         /* is this a filtering channel (3/4) and is the filter active? */
387         if (chip->AUDCTL & CH1_FILTER)
388            chip->filter_sample[CHAN1] = chip->output[CHAN1];
389         else
390            chip->filter_sample[CHAN1] = 1;
391      }
392
393      for (ch = 0; ch < 4; ch++)
394      {
395         sum += (((chip->output[ch] ^ chip->filter_sample[ch]) || (chip->AUDC[ch] & VOLUME_ONLY)) ? chip->volume[ch] : 0 );
396      }
397
398          /* store sum of output signals into the buffer */
399          *buffer++ = (sum > 0x7fff) ? 0x7fff : sum;
400          samples--;
401
402   }
403   chip->rtimer->adjust(attotime::never);
404
405}
406
407
408static void poly_init(UINT8 *poly, int size, int left, int right, int add)
409{
410   int mask = (1 << size) - 1;
411    int i, x = 0;
412
413   LOG_POLY(("poly %d\n", size));
414   for( i = 0; i < mask; i++ )
415   {
416      *poly++ = x & 1;
417      LOG_POLY(("%05x: %d\n", x, x&1));
418        /* calculate next bit */
419      x = ((x << left) + (x >> right) + add) & mask;
420   }
421}
422
423static void rand_init(UINT8 *rng, int size, int left, int right, int add)
424{
425    int mask = (1 << size) - 1;
426    int i;
427    UINT32 lfsr = 0;
428
429   LOG_RAND(("rand %d\n", size));
430
431   if (size == 17)
432   {
433       for( i = 0; i < mask; i++ )
434      {
435           /* calculate next bit @ 7 */
436          int in8 = !((lfsr >> 8) & 1) ^ ((lfsr >> 13) & 1);
437          int in = (lfsr & 1);
438          lfsr = lfsr >> 1;
439          lfsr = (lfsr & 0xff7f) | (in8 << 7);
440          lfsr = (in << 16) | lfsr;
441         *rng = (lfsr >> 8)  & 0xff;      /* use bits 0..7 */
442           LOG_RAND(("%05x: %02x\n", lfsr, *rng));
443           rng++;
444      }
445   }
446   else
447   {
448       for( i = 0; i < mask; i++ )
449      {
450           /* calculate next bit */
451          int in = !((lfsr >> 0) & 1) ^ ((lfsr >> 5) & 1);
452          lfsr = lfsr >> 1;
453          lfsr = (in << 8) | lfsr;
454         *rng = lfsr & 0xff;      /* use bits 0..7 */
455           LOG_RAND(("%05x: %02x\n", lfsr, *rng));
456           rng++;
457      }
458   }
459
460}
461
462
463static void register_for_save(pokey_state *chip, device_t *device)
464{
465   device->save_item(NAME(chip->counter));
466   device->save_item(NAME(chip->divisor));
467   device->save_item(NAME(chip->volume));
468   device->save_item(NAME(chip->output));
469   device->save_item(NAME(chip->filter_sample));
470   device->save_item(NAME(chip->clock_cnt));
471   device->save_item(NAME(chip->p4));
472   device->save_item(NAME(chip->p5));
473   device->save_item(NAME(chip->p9));
474   device->save_item(NAME(chip->p17));
475   device->save_item(NAME(chip->r9));
476   device->save_item(NAME(chip->r17));
477   device->save_item(NAME(chip->clockmult));
478   device->save_item(NAME(chip->timer_period[0]));
479   device->save_item(NAME(chip->timer_period[1]));
480   device->save_item(NAME(chip->timer_period[2]));
481   device->save_item(NAME(chip->timer_param));
482   device->save_item(NAME(chip->AUDF));
483   device->save_item(NAME(chip->AUDC));
484   device->save_item(NAME(chip->POTx));
485   device->save_item(NAME(chip->AUDCTL));
486   device->save_item(NAME(chip->ALLPOT));
487   device->save_item(NAME(chip->KBCODE));
488   device->save_item(NAME(chip->RANDOM));
489   device->save_item(NAME(chip->SERIN));
490   device->save_item(NAME(chip->SEROUT));
491   device->save_item(NAME(chip->IRQST));
492   device->save_item(NAME(chip->IRQEN));
493   device->save_item(NAME(chip->SKSTAT));
494   device->save_item(NAME(chip->SKCTL));
495}
496
497
498static DEVICE_START( pokey )
499{
500   pokey_state *chip = get_safe_token(device);
501   int sample_rate = device->clock();
502   int i;
503
504   if (device->static_config())
505      memcpy(&chip->intf, device->static_config(), sizeof(pokey_interface));
506   chip->device = device;
507   chip->clock_period = attotime::from_hz(device->clock());
508
509   /* calculate the A/D times
510     * In normal, slow mode (SKCTL bit SK_PADDLE is clear) the conversion
511     * takes N scanlines, where N is the paddle value. A single scanline
512     * takes approximately 64us to finish (1.78979MHz clock).
513     * In quick mode (SK_PADDLE set) the conversion is done very fast
514     * (takes two scanlines) but the result is not as accurate.
515     */
516   chip->ad_time_fast = (attotime::from_nsec(64000*2/228) * FREQ_17_EXACT) / device->clock();
517   chip->ad_time_slow = (attotime::from_nsec(64000      ) * FREQ_17_EXACT) / device->clock();
518
519   /* initialize the poly counters */
520   poly_init(chip->poly4,   4, 3, 1, 0x00004);
521   poly_init(chip->poly5,   5, 3, 2, 0x00008);
522   poly_init(chip->poly9,   9, 8, 1, 0x00180);
523   poly_init(chip->poly17, 17,16, 1, 0x1c000);
524
525   /* initialize the random arrays */
526   rand_init(chip->rand9,   9, 8, 1, 0x00180);
527   rand_init(chip->rand17, 17,16, 1, 0x1c000);
528
529   chip->divisor[CHAN1] = 4;
530   chip->divisor[CHAN2] = 4;
531   chip->divisor[CHAN3] = 4;
532   chip->divisor[CHAN4] = 4;
533
534   chip->clockmult = DIV_64;
535   chip->KBCODE = 0x09;       /* Atari 800 'no key' */
536   chip->SKCTL = SK_RESET;    /* let the RNG run after reset */
537   chip->rtimer = device->machine().scheduler().timer_alloc(FUNC_NULL);
538
539   chip->timer[0] = device->machine().scheduler().timer_alloc(FUNC(pokey_timer_expire), chip);
540   chip->timer[1] = device->machine().scheduler().timer_alloc(FUNC(pokey_timer_expire), chip);
541   chip->timer[2] = device->machine().scheduler().timer_alloc(FUNC(pokey_timer_expire), chip);
542
543   for (i=0; i<8; i++)
544   {
545      chip->ptimer[i] = device->machine().scheduler().timer_alloc(FUNC(pokey_pot_trigger), chip);
546      chip->pot_r[i].resolve(chip->intf.pot_r[i], *device);
547   }
548   chip->allpot_r.resolve(chip->intf.allpot_r, *device);
549   chip->serin_r.resolve(chip->intf.serin_r, *device);
550   chip->serout_w.resolve(chip->intf.serout_w, *device);
551   chip->interrupt_cb = chip->intf.interrupt_cb;
552
553   chip->m_stream = device->machine().sound().stream_alloc(*device, 0, 1, sample_rate, chip, pokey_update);
554
555   register_for_save(chip, device);
556}
557
558static TIMER_CALLBACK( pokey_timer_expire )
559{
560   pokey_state *p = (pokey_state *)ptr;
561   int timers = param;
562
563   LOG_TIMER(("POKEY #%p timer %d with IRQEN $%02x\n", p, timers, p->IRQEN));
564
565    /* check if some of the requested timer interrupts are enabled */
566   timers &= p->IRQEN;
567
568    if( timers )
569    {
570      /* set the enabled timer irq status bits */
571      p->IRQST |= timers;
572        /* call back an application supplied function to handle the interrupt */
573      if( p->interrupt_cb )
574         (*p->interrupt_cb)(p->device, timers);
575    }
576}
577
578static char *audc2str(int val)
579{
580   static char buff[80];
581   if( val & NOTPOLY5 )
582   {
583      if( val & PURE )
584         strcpy(buff,"pure");
585      else
586      if( val & POLY4 )
587         strcpy(buff,"poly4");
588      else
589         strcpy(buff,"poly9/17");
590   }
591   else
592   {
593      if( val & PURE )
594         strcpy(buff,"poly5");
595      else
596      if( val & POLY4 )
597         strcpy(buff,"poly4+poly5");
598      else
599         strcpy(buff,"poly9/17+poly5");
600    }
601   return buff;
602}
603
604static char *audctl2str(int val)
605{
606   static char buff[80];
607   if( val & POLY9 )
608      strcpy(buff,"poly9");
609   else
610      strcpy(buff,"poly17");
611   if( val & CH1_HICLK )
612      strcat(buff,"+ch1hi");
613   if( val & CH3_HICLK )
614      strcat(buff,"+ch3hi");
615   if( val & CH12_JOINED )
616      strcat(buff,"+ch1/2");
617   if( val & CH34_JOINED )
618      strcat(buff,"+ch3/4");
619   if( val & CH1_FILTER )
620      strcat(buff,"+ch1filter");
621   if( val & CH2_FILTER )
622      strcat(buff,"+ch2filter");
623   if( val & CLK_15KHZ )
624      strcat(buff,"+clk15");
625    return buff;
626}
627
628static TIMER_CALLBACK( pokey_serin_ready_cb )
629{
630   pokey_state *p = (pokey_state *)ptr;
631    if( p->IRQEN & IRQ_SERIN )
632   {
633      /* set the enabled timer irq status bits */
634      p->IRQST |= IRQ_SERIN;
635      /* call back an application supplied function to handle the interrupt */
636      if( p->interrupt_cb )
637         (*p->interrupt_cb)(p->device, IRQ_SERIN);
638   }
639}
640
641static TIMER_CALLBACK( pokey_serout_ready_cb )
642{
643   pokey_state *p = (pokey_state *)ptr;
644    if( p->IRQEN & IRQ_SEROR )
645   {
646      p->IRQST |= IRQ_SEROR;
647      if( p->interrupt_cb )
648         (*p->interrupt_cb)(p->device, IRQ_SEROR);
649   }
650}
651
652static TIMER_CALLBACK( pokey_serout_complete )
653{
654   pokey_state *p = (pokey_state *)ptr;
655    if( p->IRQEN & IRQ_SEROC )
656   {
657      p->IRQST |= IRQ_SEROC;
658      if( p->interrupt_cb )
659         (*p->interrupt_cb)(p->device, IRQ_SEROC);
660   }
661}
662
663static TIMER_CALLBACK( pokey_pot_trigger )
664{
665   pokey_state *p = (pokey_state *)ptr;
666   int pot = param;
667   LOG(("POKEY #%p POT%d triggers after %dus\n", p, pot, (int)(1000000 * p->ptimer[pot]->elapsed().as_double())));
668   p->ALLPOT &= ~(1 << pot);   /* set the enabled timer irq status bits */
669}
670
671#define AD_TIME  ((p->SKCTL & SK_PADDLE) ? p->ad_time_fast : p->ad_time_slow)
672
673static void pokey_potgo(pokey_state *p)
674{
675    int pot;
676
677   LOG(("POKEY #%p pokey_potgo\n", p));
678
679    p->ALLPOT = 0xff;
680
681    for( pot = 0; pot < 8; pot++ )
682   {
683      p->POTx[pot] = 0xff;
684      if( !p->pot_r[pot].isnull() )
685      {
686         int r = p->pot_r[pot](pot);
687
688         LOG(("POKEY %s pot_r(%d) returned $%02x\n", p->device->tag(), pot, r));
689         if( r != -1 )
690         {
691            if (r > 228)
692                    r = 228;
693
694                /* final value */
695                p->POTx[pot] = r;
696            p->ptimer[pot]->adjust(AD_TIME * r, pot);
697         }
698      }
699   }
700}
701
702READ8_DEVICE_HANDLER( pokey_r )
703{
704   pokey_state *p = get_safe_token(device);
705   int data = 0, pot;
706   UINT32 adjust = 0;
707
708   switch (offset & 15)
709   {
710   case POT0_C: case POT1_C: case POT2_C: case POT3_C:
711   case POT4_C: case POT5_C: case POT6_C: case POT7_C:
712      pot = offset & 7;
713      if( !p->pot_r[pot].isnull() )
714      {
715         /*
716             * If the conversion is not yet finished (ptimer running),
717             * get the current value by the linear interpolation of
718             * the final value using the elapsed time.
719             */
720         if( p->ALLPOT & (1 << pot) )
721         {
722            data = p->ptimer[pot]->elapsed().attoseconds / AD_TIME.attoseconds;
723            LOG(("POKEY '%s' read POT%d (interpolated) $%02x\n", p->device->tag(), pot, data));
724            }
725         else
726         {
727            data = p->POTx[pot];
728            LOG(("POKEY '%s' read POT%d (final value)  $%02x\n", p->device->tag(), pot, data));
729         }
730      }
731      else
732         logerror("%s: warning - read '%s' POT%d\n", p->device->machine().describe_context(), p->device->tag(), pot);
733      break;
734
735    case ALLPOT_C:
736      /****************************************************************
737         * If the 2 least significant bits of SKCTL are 0, the ALLPOTs
738         * are disabled (SKRESET). Thanks to MikeJ for pointing this out.
739         ****************************************************************/
740      if( (p->SKCTL & SK_RESET) == 0)
741      {
742         data = 0;
743         LOG(("POKEY '%s' ALLPOT internal $%02x (reset)\n", p->device->tag(), data));
744      }
745      else if( !p->allpot_r.isnull() )
746      {
747         data = p->allpot_r(offset);
748         LOG(("POKEY '%s' ALLPOT callback $%02x\n", p->device->tag(), data));
749      }
750      else
751      {
752         data = p->ALLPOT;
753         LOG(("POKEY '%s' ALLPOT internal $%02x\n", p->device->tag(), data));
754      }
755      break;
756
757   case KBCODE_C:
758      data = p->KBCODE;
759      break;
760
761   case RANDOM_C:
762      /****************************************************************
763         * If the 2 least significant bits of SKCTL are 0, the random
764         * number generator is disabled (SKRESET). Thanks to Eric Smith
765         * for pointing out this critical bit of info! If the random
766         * number generator is enabled, get a new random number. Take
767         * the time gone since the last read into account and read the
768         * new value from an appropriate offset in the rand17 table.
769         ****************************************************************/
770      if( p->SKCTL & SK_RESET )
771      {
772         adjust = p->rtimer->elapsed().as_double() / p->clock_period.as_double();
773         p->r9 = (p->r9 + adjust) % 0x001ff;
774         p->r17 = (p->r17 + adjust) % 0x1ffff;
775      }
776      else
777      {
778         adjust = 1;
779         p->r9 = 0;
780         p->r17 = 0;
781            LOG_RAND(("POKEY '%s' rand17 frozen (SKCTL): $%02x\n", p->device->tag(), p->RANDOM));
782      }
783      if( p->AUDCTL & POLY9 )
784      {
785         p->RANDOM = p->rand9[p->r9];
786         LOG_RAND(("POKEY '%s' adjust %u rand9[$%05x]: $%02x\n", p->device->tag(), adjust, p->r9, p->RANDOM));
787      }
788      else
789      {
790         p->RANDOM = p->rand17[p->r17];
791         LOG_RAND(("POKEY '%s' adjust %u rand17[$%05x]: $%02x\n", p->device->tag(), adjust, p->r17, p->RANDOM));
792      }
793      if (adjust > 0)
794         p->rtimer->adjust(attotime::never);
795      data = p->RANDOM ^ 0xff;
796      break;
797
798   case SERIN_C:
799      if( !p->serin_r.isnull() )
800         p->SERIN = p->serin_r(offset);
801      data = p->SERIN;
802      LOG(("POKEY '%s' SERIN  $%02x\n", p->device->tag(), data));
803      break;
804
805   case IRQST_C:
806      /* IRQST is an active low input port; we keep it active high */
807      /* internally to ease the (un-)masking of bits */
808      data = p->IRQST ^ 0xff;
809      LOG(("POKEY '%s' IRQST  $%02x\n", p->device->tag(), data));
810      break;
811
812   case SKSTAT_C:
813      /* SKSTAT is also an active low input port */
814      data = p->SKSTAT ^ 0xff;
815      LOG(("POKEY '%s' SKSTAT $%02x\n", p->device->tag(), data));
816      break;
817
818   default:
819      LOG(("POKEY '%s' register $%02x\n", p->device->tag(), offset));
820        break;
821    }
822    return data;
823}
824
825READ8_HANDLER( quad_pokey_r )
826{
827   static const char *const devname[4] = { "pokey1", "pokey2", "pokey3", "pokey4" };
828   int pokey_num = (offset >> 3) & ~0x04;
829   int control = (offset & 0x20) >> 2;
830   int pokey_reg = (offset % 8) | control;
831
832   return pokey_r(space->machine().device(devname[pokey_num]), pokey_reg);
833}
834
835
836WRITE8_DEVICE_HANDLER( pokey_w )
837{
838   pokey_state *p = get_safe_token(device);
839   int ch_mask = 0, new_val;
840
841   p->m_stream->update();
842
843    /* determine which address was changed */
844   switch (offset & 15)
845    {
846    case AUDF1_C:
847      if( data == p->AUDF[CHAN1] )
848            return;
849      LOG_SOUND(("POKEY '%s' AUDF1  $%02x\n", p->device->tag(), data));
850      p->AUDF[CHAN1] = data;
851        ch_mask = 1 << CHAN1;
852      if( p->AUDCTL & CH12_JOINED )      /* if ch 1&2 tied together */
853            ch_mask |= 1 << CHAN2;    /* then also change on ch2 */
854        break;
855
856    case AUDC1_C:
857      if( data == p->AUDC[CHAN1] )
858            return;
859      LOG_SOUND(("POKEY '%s' AUDC1  $%02x (%s)\n", p->device->tag(), data, audc2str(data)));
860      p->AUDC[CHAN1] = data;
861        ch_mask = 1 << CHAN1;
862        break;
863
864    case AUDF2_C:
865      if( data == p->AUDF[CHAN2] )
866            return;
867      LOG_SOUND(("POKEY '%s' AUDF2  $%02x\n", p->device->tag(), data));
868      p->AUDF[CHAN2] = data;
869        ch_mask = 1 << CHAN2;
870        break;
871
872    case AUDC2_C:
873      if( data == p->AUDC[CHAN2] )
874            return;
875      LOG_SOUND(("POKEY '%s' AUDC2  $%02x (%s)\n", p->device->tag(), data, audc2str(data)));
876      p->AUDC[CHAN2] = data;
877        ch_mask = 1 << CHAN2;
878        break;
879
880    case AUDF3_C:
881      if( data == p->AUDF[CHAN3] )
882            return;
883      LOG_SOUND(("POKEY '%s' AUDF3  $%02x\n", p->device->tag(), data));
884      p->AUDF[CHAN3] = data;
885        ch_mask = 1 << CHAN3;
886
887      if( p->AUDCTL & CH34_JOINED )   /* if ch 3&4 tied together */
888            ch_mask |= 1 << CHAN4;  /* then also change on ch4 */
889        break;
890
891    case AUDC3_C:
892      if( data == p->AUDC[CHAN3] )
893            return;
894      LOG_SOUND(("POKEY '%s' AUDC3  $%02x (%s)\n", p->device->tag(), data, audc2str(data)));
895      p->AUDC[CHAN3] = data;
896        ch_mask = 1 << CHAN3;
897        break;
898
899    case AUDF4_C:
900      if( data == p->AUDF[CHAN4] )
901            return;
902      LOG_SOUND(("POKEY '%s' AUDF4  $%02x\n", p->device->tag(), data));
903      p->AUDF[CHAN4] = data;
904        ch_mask = 1 << CHAN4;
905        break;
906
907    case AUDC4_C:
908      if( data == p->AUDC[CHAN4] )
909            return;
910      LOG_SOUND(("POKEY '%s' AUDC4  $%02x (%s)\n", p->device->tag(), data, audc2str(data)));
911      p->AUDC[CHAN4] = data;
912        ch_mask = 1 << CHAN4;
913        break;
914
915    case AUDCTL_C:
916      if( data == p->AUDCTL )
917            return;
918      LOG_SOUND(("POKEY '%s' AUDCTL $%02x (%s)\n", p->device->tag(), data, audctl2str(data)));
919      p->AUDCTL = data;
920        ch_mask = 15;       /* all channels */
921        /* determine the base multiplier for the 'div by n' calculations */
922      p->clockmult = (p->AUDCTL & CLK_15KHZ) ? DIV_15 : DIV_64;
923        break;
924
925    case STIMER_C:
926        /* first remove any existing timers */
927      LOG_TIMER(("POKEY '%s' STIMER $%02x\n", p->device->tag(), data));
928
929      p->timer[TIMER1]->adjust(attotime::never, p->timer_param[TIMER1]);
930      p->timer[TIMER2]->adjust(attotime::never, p->timer_param[TIMER2]);
931      p->timer[TIMER4]->adjust(attotime::never, p->timer_param[TIMER4]);
932
933        /* reset all counters to zero (side effect) */
934
935      reset_channel(p, CHAN1);
936      reset_channel(p, CHAN2);
937      reset_channel(p, CHAN3);
938      reset_channel(p, CHAN4);
939      /* From the pokey documentation */
940      p->output[CHAN1] = 0;
941      p->output[CHAN2] = 0;
942      p->output[CHAN3] = 0;
943      p->output[CHAN4] = 0;
944      p->filter_sample[CHAN1] = 1;
945      p->filter_sample[CHAN2] = 1;
946      p->filter_sample[CHAN3] = 0;
947      p->filter_sample[CHAN4] = 0;
948
949        /* joined chan#1 and chan#2 ? */
950      if( p->AUDCTL & CH12_JOINED )
951        {
952         if( p->divisor[CHAN2] > 4 )
953         {
954            LOG_TIMER(("POKEY '%s' timer1+2 after %d clocks\n", p->device->tag(), p->divisor[CHAN2]));
955            /* set timer #1 _and_ #2 event after timer_div clocks of joined CHAN1+CHAN2 */
956            p->timer_period[TIMER2] = p->clock_period * p->divisor[CHAN2];
957            p->timer_param[TIMER2] = IRQ_TIMR2|IRQ_TIMR1;
958            p->timer[TIMER2]->adjust(p->timer_period[TIMER2], p->timer_param[TIMER2], p->timer_period[TIMER2]);
959         }
960        }
961        else
962        {
963         if( p->divisor[CHAN1] > 4 )
964         {
965            LOG_TIMER(("POKEY '%s' timer1 after %d clocks\n", p->device->tag(), p->divisor[CHAN1]));
966            /* set timer #1 event after timer_div clocks of CHAN1 */
967            p->timer_period[TIMER1] = p->clock_period * p->divisor[CHAN1];
968            p->timer_param[TIMER1] = IRQ_TIMR1;
969            p->timer[TIMER1]->adjust(p->timer_period[TIMER1], p->timer_param[TIMER1], p->timer_period[TIMER1]);
970         }
971
972         if( p->divisor[CHAN2] > 4 )
973         {
974            LOG_TIMER(("POKEY '%s' timer2 after %d clocks\n", p->device->tag(), p->divisor[CHAN2]));
975            /* set timer #2 event after timer_div clocks of CHAN2 */
976            p->timer_period[TIMER2] = p->clock_period * p->divisor[CHAN2];
977            p->timer_param[TIMER2] = IRQ_TIMR2;
978            p->timer[TIMER2]->adjust(p->timer_period[TIMER2], p->timer_param[TIMER2], p->timer_period[TIMER2]);
979         }
980        }
981
982      /* Note: p[chip] does not have a timer #3 */
983
984      if( p->AUDCTL & CH34_JOINED )
985        {
986            /* not sure about this: if audc4 == 0000xxxx don't start timer 4 ? */
987         if( p->AUDC[CHAN4] & 0xf0 )
988            {
989            if( p->divisor[CHAN4] > 4 )
990            {
991               LOG_TIMER(("POKEY '%s' timer4 after %d clocks\n", p->device->tag(), p->divisor[CHAN4]));
992               /* set timer #4 event after timer_div clocks of CHAN4 */
993               p->timer_period[TIMER4] = p->clock_period * p->divisor[CHAN4];
994               p->timer_param[TIMER4] = IRQ_TIMR4;
995               p->timer[TIMER4]->adjust(p->timer_period[TIMER4], p->timer_param[TIMER4], p->timer_period[TIMER4]);
996            }
997            }
998        }
999        else
1000        {
1001         if( p->divisor[CHAN4] > 4 )
1002         {
1003            LOG_TIMER(("POKEY '%s' timer4 after %d clocks\n", p->device->tag(), p->divisor[CHAN4]));
1004            /* set timer #4 event after timer_div clocks of CHAN4 */
1005            p->timer_period[TIMER4] = p->clock_period * p->divisor[CHAN4];
1006            p->timer_param[TIMER4] = IRQ_TIMR4;
1007            p->timer[TIMER4]->adjust(p->timer_period[TIMER4], p->timer_param[TIMER4], p->timer_period[TIMER4]);
1008         }
1009        }
1010
1011      p->timer[TIMER1]->enable(p->IRQEN & IRQ_TIMR1);
1012      p->timer[TIMER2]->enable(p->IRQEN & IRQ_TIMR2);
1013      p->timer[TIMER4]->enable(p->IRQEN & IRQ_TIMR4);
1014        break;
1015
1016    case SKREST_C:
1017        /* reset SKSTAT */
1018      LOG(("POKEY '%s' SKREST $%02x\n", p->device->tag(), data));
1019      p->SKSTAT &= ~(SK_FRAME|SK_OVERRUN|SK_KBERR);
1020        break;
1021
1022    case POTGO_C:
1023      LOG(("POKEY '%s' POTGO  $%02x\n", p->device->tag(), data));
1024      pokey_potgo(p);
1025        break;
1026
1027    case SEROUT_C:
1028      LOG(("POKEY '%s' SEROUT $%02x\n", p->device->tag(), data));
1029      p->serout_w(offset, data);
1030      p->SKSTAT |= SK_SEROUT;
1031        /*
1032         * These are arbitrary values, tested with some custom boot
1033         * loaders from Ballblazer and Escape from Fractalus
1034         * The real times are unknown
1035         */
1036        device->machine().scheduler().timer_set(attotime::from_usec(200), FUNC(pokey_serout_ready_cb), 0, p);
1037        /* 10 bits (assumption 1 start, 8 data and 1 stop bit) take how long? */
1038        device->machine().scheduler().timer_set(attotime::from_usec(2000), FUNC(pokey_serout_complete), 0, p);
1039        break;
1040
1041    case IRQEN_C:
1042      LOG(("POKEY '%s' IRQEN  $%02x\n", p->device->tag(), data));
1043
1044        /* acknowledge one or more IRQST bits ? */
1045      if( p->IRQST & ~data )
1046        {
1047            /* reset IRQST bits that are masked now */
1048         p->IRQST &= data;
1049        }
1050        else
1051        {
1052         /* enable/disable timers now to avoid unneeded
1053               breaking of the CPU cores for masked timers */
1054         if( p->timer[TIMER1] && ((p->IRQEN^data) & IRQ_TIMR1) )
1055            p->timer[TIMER1]->enable(data & IRQ_TIMR1);
1056         if( p->timer[TIMER2] && ((p->IRQEN^data) & IRQ_TIMR2) )
1057            p->timer[TIMER2]->enable(data & IRQ_TIMR2);
1058         if( p->timer[TIMER4] && ((p->IRQEN^data) & IRQ_TIMR4) )
1059            p->timer[TIMER4]->enable(data & IRQ_TIMR4);
1060        }
1061      /* store irq enable */
1062      p->IRQEN = data;
1063        break;
1064
1065    case SKCTL_C:
1066      if( data == p->SKCTL )
1067            return;
1068      LOG(("POKEY '%s' SKCTL  $%02x\n", p->device->tag(), data));
1069      p->SKCTL = data;
1070        if( !(data & SK_RESET) )
1071        {
1072            pokey_w(device, IRQEN_C,  0);
1073            pokey_w(device, SKREST_C, 0);
1074        }
1075        break;
1076    }
1077
1078   /************************************************************
1079     * As defined in the manual, the exact counter values are
1080     * different depending on the frequency and resolution:
1081     *    64 kHz or 15 kHz - AUDF + 1
1082     *    1.79 MHz, 8-bit  - AUDF + 4
1083     *    1.79 MHz, 16-bit - AUDF[CHAN1]+256*AUDF[CHAN2] + 7
1084     ************************************************************/
1085
1086    /* only reset the channels that have changed */
1087
1088    if( ch_mask & (1 << CHAN1) )
1089    {
1090        /* process channel 1 frequency */
1091      if( p->AUDCTL & CH1_HICLK )
1092         new_val = p->AUDF[CHAN1] + DIVADD_HICLK;
1093        else
1094         new_val = (p->AUDF[CHAN1] + DIVADD_LOCLK) * p->clockmult;
1095
1096      LOG_SOUND(("POKEY '%s' chan1 %d\n", p->device->tag(), new_val));
1097
1098      p->volume[CHAN1] = (p->AUDC[CHAN1] & VOLUME_MASK) * POKEY_DEFAULT_GAIN;
1099        p->divisor[CHAN1] = new_val;
1100      if( p->interrupt_cb && p->timer[TIMER1] )
1101         p->timer[TIMER1]->adjust(p->clock_period * new_val, p->timer_param[TIMER1], p->timer_period[TIMER1]);
1102    }
1103
1104    if( ch_mask & (1 << CHAN2) )
1105    {
1106        /* process channel 2 frequency */
1107      if( p->AUDCTL & CH12_JOINED )
1108        {
1109         if( p->AUDCTL & CH1_HICLK )
1110            new_val = p->AUDF[CHAN2] * 256 + p->AUDF[CHAN1] + DIVADD_HICLK_JOINED;
1111            else
1112            new_val = (p->AUDF[CHAN2] * 256 + p->AUDF[CHAN1] + DIVADD_LOCLK) * p->clockmult;
1113         LOG_SOUND(("POKEY '%s' chan1+2 %d\n", p->device->tag(), new_val));
1114        }
1115        else
1116      {
1117         new_val = (p->AUDF[CHAN2] + DIVADD_LOCLK) * p->clockmult;
1118         LOG_SOUND(("POKEY '%s' chan2 %d\n", p->device->tag(), new_val));
1119      }
1120
1121      p->volume[CHAN2] = (p->AUDC[CHAN2] & VOLUME_MASK) * POKEY_DEFAULT_GAIN;
1122      p->divisor[CHAN2] = new_val;
1123      if( p->interrupt_cb && p->timer[TIMER2] )
1124         p->timer[TIMER2]->adjust(p->clock_period * new_val, p->timer_param[TIMER2], p->timer_period[TIMER2]);
1125    }
1126
1127    if( ch_mask & (1 << CHAN3) )
1128    {
1129        /* process channel 3 frequency */
1130      if( p->AUDCTL & CH3_HICLK )
1131         new_val = p->AUDF[CHAN3] + DIVADD_HICLK;
1132        else
1133         new_val = (p->AUDF[CHAN3] + DIVADD_LOCLK) * p->clockmult;
1134
1135      LOG_SOUND(("POKEY '%s' chan3 %d\n", p->device->tag(), new_val));
1136
1137      p->volume[CHAN3] = (p->AUDC[CHAN3] & VOLUME_MASK) * POKEY_DEFAULT_GAIN;
1138      p->divisor[CHAN3] = new_val;
1139      /* channel 3 does not have a timer associated */
1140    }
1141
1142    if( ch_mask & (1 << CHAN4) )
1143    {
1144        /* process channel 4 frequency */
1145      if( p->AUDCTL & CH34_JOINED )
1146        {
1147         if( p->AUDCTL & CH3_HICLK )
1148            new_val = p->AUDF[CHAN4] * 256 + p->AUDF[CHAN3] + DIVADD_HICLK_JOINED;
1149            else
1150            new_val = (p->AUDF[CHAN4] * 256 + p->AUDF[CHAN3] + DIVADD_LOCLK) * p->clockmult;
1151         LOG_SOUND(("POKEY '%s' chan3+4 %d\n", p->device->tag(), new_val));
1152        }
1153        else
1154      {
1155         new_val = (p->AUDF[CHAN4] + DIVADD_LOCLK) * p->clockmult;
1156         LOG_SOUND(("POKEY '%s' chan4 %d\n", p->device->tag(), new_val));
1157      }
1158
1159      p->volume[CHAN4] = (p->AUDC[CHAN4] & VOLUME_MASK) * POKEY_DEFAULT_GAIN;
1160      p->divisor[CHAN4] = new_val;
1161      if( p->interrupt_cb && p->timer[TIMER4] )
1162         p->timer[TIMER4]->adjust(p->clock_period * new_val, p->timer_param[TIMER4], p->timer_period[TIMER4]);
1163    }
1164}
1165
1166WRITE8_HANDLER( quad_pokey_w )
1167{
1168   static const char *const devname[4] = { "pokey1", "pokey2", "pokey3", "pokey4" };
1169    int pokey_num = (offset >> 3) & ~0x04;
1170    int control = (offset & 0x20) >> 2;
1171    int pokey_reg = (offset % 8) | control;
1172
1173    pokey_w(space->machine().device(devname[pokey_num]), pokey_reg, data);
1174}
1175
1176void pokey_serin_ready(device_t *device, int after)
1177{
1178   pokey_state *p = get_safe_token(device);
1179   device->machine().scheduler().timer_set(p->clock_period * after, FUNC(pokey_serin_ready_cb), 0, p);
1180}
1181
1182void pokey_break_w(device_t *device, int shift)
1183{
1184   pokey_state *p = get_safe_token(device);
1185   if( shift )                     /* shift code ? */
1186      p->SKSTAT |= SK_SHIFT;
1187   else
1188      p->SKSTAT &= ~SK_SHIFT;
1189   /* check if the break IRQ is enabled */
1190   if( p->IRQEN & IRQ_BREAK )
1191   {
1192      /* set break IRQ status and call back the interrupt handler */
1193      p->IRQST |= IRQ_BREAK;
1194      if( p->interrupt_cb )
1195         (*p->interrupt_cb)(device, IRQ_BREAK);
1196   }
1197}
1198
1199void pokey_kbcode_w(device_t *device, int kbcode, int make)
1200{
1201   pokey_state *p = get_safe_token(device);
1202    /* make code ? */
1203   if( make )
1204   {
1205      p->KBCODE = kbcode;
1206      p->SKSTAT |= SK_KEYBD;
1207      if( kbcode & 0x40 )       /* shift code ? */
1208         p->SKSTAT |= SK_SHIFT;
1209      else
1210         p->SKSTAT &= ~SK_SHIFT;
1211
1212      if( p->IRQEN & IRQ_KEYBD )
1213      {
1214         /* last interrupt not acknowledged ? */
1215         if( p->IRQST & IRQ_KEYBD )
1216            p->SKSTAT |= SK_KBERR;
1217         p->IRQST |= IRQ_KEYBD;
1218         if( p->interrupt_cb )
1219            (*p->interrupt_cb)(device, IRQ_KEYBD);
1220      }
1221   }
1222   else
1223   {
1224      p->KBCODE = kbcode;
1225      p->SKSTAT &= ~SK_KEYBD;
1226    }
1227}
1228
1229
1230
1231
1232/**************************************************************************
1233 * Generic get_info
1234 **************************************************************************/
1235
1236DEVICE_GET_INFO( pokey )
1237{
1238   switch (state)
1239   {
1240      /* --- the following bits of info are returned as 64-bit signed integers --- */
1241      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(pokey_state);      break;
1242
1243      /* --- the following bits of info are returned as pointers to data or functions --- */
1244      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME( pokey );         break;
1245      case DEVINFO_FCT_STOP:                     /* Nothing */                           break;
1246      case DEVINFO_FCT_RESET:                     /* Nothing */                           break;
1247
1248      /* --- the following bits of info are returned as NULL-terminated strings --- */
1249      case DEVINFO_STR_NAME:                     strcpy(info->s, "POKEY");                  break;
1250      case DEVINFO_STR_FAMILY:               strcpy(info->s, "Atari custom");            break;
1251      case DEVINFO_STR_VERSION:               strcpy(info->s, "4.6");                  break;
1252      case DEVINFO_STR_SOURCE_FILE:                  strcpy(info->s, __FILE__);                  break;
1253      case DEVINFO_STR_CREDITS:               strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
1254   }
1255}
1256
1257#ifdef OLDDEVICE_FOR_MESS
1258
1259DEFINE_LEGACY_SOUND_DEVICE(POKEY, pokey);
1260
1261#endif
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276164// device type definition
1277165const device_type POKEYN = &device_creator<pokeyn_device>;
1278166
r15253r15254
1344232   m_timer[2] = timer_alloc(1);
1345233
1346234   /* reset more internal state */
1347   for (i=0; i<4; i++)
235   for (i=0; i<3; i++)
1348236   {
1349      m_AUDC[i] = 0;
1350      m_AUDF[i] = 0;
1351      m_volume[i] = 0;
1352      m_borrow_cnt[i] = 0;
1353      m_counter[i] = 0;
1354      if (i<3) m_clock_cnt[i] = 0;
1355      m_filter_sample[i] = 0;
1356      m_output[i] = 0;
237      m_clock_cnt[i] = 0;
1357238   }
1358239
1359240   for (i=0; i<8; i++)
r15253r15254
1368249
1369250   m_stream = stream_alloc(0, 1, clock());
1370251
1371   save_item(NAME(m_counter));
252   for (i=0; i<POKEY_CHANNELS; i++)
253   {
254      save_item(NAME(m_channel[i].m_borrow_cnt), i);
255      save_item(NAME(m_channel[i].m_counter), i);
256      save_item(NAME(m_channel[i].m_filter_sample), i);
257      save_item(NAME(m_channel[i].m_output), i);
258      save_item(NAME(m_channel[i].m_volume), i);
259      save_item(NAME(m_channel[i].m_AUDF), i);
260      save_item(NAME(m_channel[i].m_AUDC), i);
261   }
1372262   save_item(NAME(m_divisor));
1373   save_item(NAME(m_volume));
1374   save_item(NAME(m_output));
1375   save_item(NAME(m_filter_sample));
1376263   save_item(NAME(m_clock_cnt));
1377   save_item(NAME(m_borrow_cnt));
1378264   save_item(NAME(m_p4));
1379265   save_item(NAME(m_p5));
1380266   save_item(NAME(m_p9));
r15253r15254
1386272   save_item(NAME(m_timer_period[1]));
1387273   save_item(NAME(m_timer_period[2]));
1388274   save_item(NAME(m_timer_param));
1389   save_item(NAME(m_AUDF));
1390   save_item(NAME(m_AUDC));
1391275   save_item(NAME(m_POTx));
1392276   save_item(NAME(m_AUDCTL));
1393277   save_item(NAME(m_ALLPOT));
r15253r15254
1547431
1548432      clk = (m_AUDCTL & CH1_HICLK) ? CLK_1 : base_clock;
1549433      if (clock_triggered[clk])
1550         inc_chan(CHAN1);
434         m_channel[CHAN1].inc_chan();
1551435
1552436      clk = (m_AUDCTL & CH3_HICLK) ? CLK_1 : base_clock;
1553437      if (clock_triggered[clk])
1554         inc_chan(CHAN3);
438         m_channel[CHAN3].inc_chan();
1555439
1556440      if (clock_triggered[base_clock])
1557441      {
1558442         if (!(m_AUDCTL & CH12_JOINED))
1559            inc_chan(CHAN2);
443            m_channel[CHAN2].inc_chan();
1560444         if (!(m_AUDCTL & CH34_JOINED))
1561            inc_chan(CHAN4);
445            m_channel[CHAN4].inc_chan();
1562446      }
1563447
1564448      /* do CHAN2 before CHAN1 because CHAN1 may set borrow! */
1565      if (check_borrow(CHAN2))
449      if (m_channel[CHAN2].check_borrow())
1566450      {
1567451         int isJoined = (m_AUDCTL & CH12_JOINED);
1568452         if (isJoined)
1569            reset_channel(CHAN1);
1570         reset_channel(CHAN2);
453            m_channel[CHAN1].reset_channel();
454         m_channel[CHAN2].reset_channel();
1571455         process_channel(CHAN2);
1572456      }
1573457
1574      if (check_borrow(CHAN1))
458      if (m_channel[CHAN1].check_borrow())
1575459      {
1576460         int isJoined = (m_AUDCTL & CH12_JOINED);
1577461         if (isJoined)
1578            inc_chan(CHAN2);
462            m_channel[CHAN2].inc_chan();
1579463         else
1580            reset_channel(CHAN1);
464            m_channel[CHAN1].reset_channel();
1581465         process_channel(CHAN1);
1582466      }
1583467
1584468      /* do CHAN4 before CHAN3 because CHAN3 may set borrow! */
1585      if (check_borrow(CHAN4))
469      if (m_channel[CHAN4].check_borrow())
1586470      {
1587471         int isJoined = (m_AUDCTL & CH34_JOINED);
1588472         if (isJoined)
1589            reset_channel(CHAN3);
1590         reset_channel(CHAN4);
473            m_channel[CHAN3].reset_channel();
474         m_channel[CHAN4].reset_channel();
1591475         process_channel(CHAN4);
1592476         /* is this a filtering channel (3/4) and is the filter active? */
1593477         if (m_AUDCTL & CH2_FILTER)
1594            m_filter_sample[CHAN2] = m_output[CHAN2];
478            m_channel[CHAN2].sample();
1595479         else
1596            m_filter_sample[CHAN2] = 1;
480            m_channel[CHAN2].m_filter_sample = 1;
1597481      }
1598482
1599      if (check_borrow(CHAN3))
483      if (m_channel[CHAN3].check_borrow())
1600484      {
1601485         int isJoined = (m_AUDCTL & CH34_JOINED);
1602486         if (isJoined)
1603            inc_chan(CHAN4);
487            m_channel[CHAN4].inc_chan();
1604488         else
1605            reset_channel(CHAN3);
489            m_channel[CHAN3].reset_channel();
1606490         process_channel(CHAN3);
1607491         /* is this a filtering channel (3/4) and is the filter active? */
1608492         if (m_AUDCTL & CH1_FILTER)
1609            m_filter_sample[CHAN1] = m_output[CHAN1];
493            m_channel[CHAN1].sample();
1610494         else
1611            m_filter_sample[CHAN1] = 1;
495            m_channel[CHAN1].m_filter_sample = 1;
1612496      }
1613497
1614498      for (ch = 0; ch < 4; ch++)
1615499      {
1616         sum += (((m_output[ch] ^ m_filter_sample[ch]) || (m_AUDC[ch] & VOLUME_ONLY)) ? m_volume[ch] : 0 );
500         sum += (((m_channel[ch].m_output ^ m_channel[ch].m_filter_sample) || (m_channel[ch].m_AUDC & VOLUME_ONLY)) ? m_channel[ch].m_volume : 0 );
1617501      }
1618502
1619#if 0
1620      {
1621         static int old_sum = 0;
1622         if (sum != old_sum)
1623         {
1624            old_sum = sum;
1625            printf("sum %d\n", sum);
1626         }
1627      }
1628#endif
503       /* store sum of output signals into the buffer */
1629504
1630          /* store sum of output signals into the buffer */
505       *buffer++ = (sum > 0x7fff) ? 0x7fff : sum;
506       samples--;
1631507
1632          *buffer++ = (sum > 0x7fff) ? 0x7fff : sum;
1633          samples--;
1634
1635508   }
1636509   m_rtimer->adjust(attotime::never);
1637510
r15253r15254
1791664   switch (offset & 15)
1792665    {
1793666    case AUDF1_C:
1794      if( data == m_AUDF[CHAN1] )
667      if( data == m_channel[CHAN1].m_AUDF )
1795668            return;
1796669      LOG_SOUND(("POKEY '%s' AUDF1  $%02x\n", tag(), data));
1797      m_AUDF[CHAN1] = data;
670      m_channel[CHAN1].m_AUDF = data;
1798671        ch_mask = 1 << CHAN1;
1799672      if( m_AUDCTL & CH12_JOINED )      /* if ch 1&2 tied together */
1800673            ch_mask |= 1 << CHAN2;    /* then also change on ch2 */
1801674        break;
1802675
1803676    case AUDC1_C:
1804      if( data == m_AUDC[CHAN1] )
677      if( data == m_channel[CHAN1].m_AUDC )
1805678            return;
1806679      LOG_SOUND(("POKEY '%s' AUDC1  $%02x (%s)\n", tag(), data, audc2str(data)));
1807      m_AUDC[CHAN1] = data;
680      m_channel[CHAN1].m_AUDC = data;
1808681        ch_mask = 1 << CHAN1;
1809682        break;
1810683
1811684    case AUDF2_C:
1812      if( data == m_AUDF[CHAN2] )
685      if( data == m_channel[CHAN2].m_AUDF )
1813686            return;
1814687      LOG_SOUND(("POKEY '%s' AUDF2  $%02x\n", tag(), data));
1815      m_AUDF[CHAN2] = data;
688      m_channel[CHAN2].m_AUDF = data;
1816689        ch_mask = 1 << CHAN2;
1817690        break;
1818691
1819692    case AUDC2_C:
1820      if( data == m_AUDC[CHAN2] )
693      if( data == m_channel[CHAN2].m_AUDC )
1821694            return;
1822695      LOG_SOUND(("POKEY '%s' AUDC2  $%02x (%s)\n", tag(), data, audc2str(data)));
1823      m_AUDC[CHAN2] = data;
696      m_channel[CHAN2].m_AUDC = data;
1824697        ch_mask = 1 << CHAN2;
1825698        break;
1826699
1827700    case AUDF3_C:
1828      if( data == m_AUDF[CHAN3] )
701      if( data == m_channel[CHAN3].m_AUDF )
1829702            return;
1830703      LOG_SOUND(("POKEY '%s' AUDF3  $%02x\n", tag(), data));
1831      m_AUDF[CHAN3] = data;
704      m_channel[CHAN3].m_AUDF = data;
1832705        ch_mask = 1 << CHAN3;
1833706
1834707      if( m_AUDCTL & CH34_JOINED )   /* if ch 3&4 tied together */
r15253r15254
1836709        break;
1837710
1838711    case AUDC3_C:
1839      if( data == m_AUDC[CHAN3] )
712      if( data == m_channel[CHAN3].m_AUDC )
1840713            return;
1841714      LOG_SOUND(("POKEY '%s' AUDC3  $%02x (%s)\n", tag(), data, audc2str(data)));
1842      m_AUDC[CHAN3] = data;
715      m_channel[CHAN3].m_AUDC = data;
1843716        ch_mask = 1 << CHAN3;
1844717        break;
1845718
1846719    case AUDF4_C:
1847      if( data == m_AUDF[CHAN4] )
720      if( data == m_channel[CHAN4].m_AUDF )
1848721            return;
1849722      LOG_SOUND(("POKEY '%s' AUDF4  $%02x\n", tag(), data));
1850      m_AUDF[CHAN4] = data;
723      m_channel[CHAN4].m_AUDF = data;
1851724        ch_mask = 1 << CHAN4;
1852725        break;
1853726
1854727    case AUDC4_C:
1855      if( data == m_AUDC[CHAN4] )
728      if( data == m_channel[CHAN4].m_AUDC )
1856729            return;
1857730      LOG_SOUND(("POKEY '%s' AUDC4  $%02x (%s)\n", tag(), data, audc2str(data)));
1858      m_AUDC[CHAN4] = data;
731      m_channel[CHAN4].m_AUDC = data;
1859732        ch_mask = 1 << CHAN4;
1860733        break;
1861734
r15253r15254
1877750      m_timer[TIMER2]->adjust(attotime::never, m_timer_param[TIMER2]);
1878751      m_timer[TIMER4]->adjust(attotime::never, m_timer_param[TIMER4]);
1879752
1880        /* reset all counters to zero (side effect) */
1881      reset_channel(CHAN1);
1882      reset_channel(CHAN2);
1883      reset_channel(CHAN3);
1884      reset_channel(CHAN4);
1885753      /* From the pokey documentation */
1886      m_output[CHAN1] = 0;
1887      m_output[CHAN2] = 0;
1888      m_output[CHAN3] = 0;
1889      m_output[CHAN4] = 0;
1890      m_filter_sample[CHAN1] = 1;
1891      m_filter_sample[CHAN2] = 1;
1892      m_filter_sample[CHAN3] = 0;
1893      m_filter_sample[CHAN4] = 0;
1894        /* joined chan#1 and chan#2 ? */
754        /* reset all counters to zero (side effect) */
755      for (int i = 0; i < POKEY_CHANNELS; i++)
756      {
757         m_channel[i].reset_channel();
758         m_channel[i].m_output = 0;
759         m_channel[i].m_filter_sample = (i<2 ? 1 : 0);
760      }
761
762      /* joined chan#1 and chan#2 ? */
1895763      if( m_AUDCTL & CH12_JOINED )
1896764        {
1897765         if( m_divisor[CHAN2] > 4 )
r15253r15254
1929797      if( m_AUDCTL & CH34_JOINED )
1930798        {
1931799            /* not sure about this: if audc4 == 0000xxxx don't start timer 4 ? */
1932         if( m_AUDC[CHAN4] & 0xf0 )
800         if( m_channel[CHAN4].m_AUDC & 0xf0 )
1933801            {
1934802            if( m_divisor[CHAN4] > 4 )
1935803            {
r15253r15254
2034902    {
2035903        /* process channel 1 frequency */
2036904      if( m_AUDCTL & CH1_HICLK )
2037         new_val = m_AUDF[CHAN1] + DIVADD_HICLK;
905         new_val = m_channel[CHAN1].m_AUDF + DIVADD_HICLK;
2038906        else
2039         new_val = (m_AUDF[CHAN1] + DIVADD_LOCLK) * m_clockmult;
907         new_val = (m_channel[CHAN1].m_AUDF + DIVADD_LOCLK) * m_clockmult;
2040908
2041909      LOG_SOUND(("POKEY '%s' chan1 %d\n", tag(), new_val));
2042910
2043      m_volume[CHAN1] = (m_AUDC[CHAN1] & VOLUME_MASK) * POKEY_DEFAULT_GAIN;
911      m_channel[CHAN1].m_volume = (m_channel[CHAN1].m_AUDC & VOLUME_MASK) * POKEY_DEFAULT_GAIN;
2044912        m_divisor[CHAN1] = new_val;
2045913      if( m_interrupt_cb && m_timer[TIMER1] )
2046914         m_timer[TIMER1]->adjust(m_clock_period * new_val, m_timer_param[TIMER1], m_timer_period[TIMER1]);
r15253r15254
2052920      if( m_AUDCTL & CH12_JOINED )
2053921        {
2054922         if( m_AUDCTL & CH1_HICLK )
2055            new_val = m_AUDF[CHAN2] * 256 + m_AUDF[CHAN1] + DIVADD_HICLK_JOINED;
923            new_val = m_channel[CHAN2].m_AUDF * 256 + m_channel[CHAN1].m_AUDF + DIVADD_HICLK_JOINED;
2056924            else
2057            new_val = (m_AUDF[CHAN2] * 256 + m_AUDF[CHAN1] + DIVADD_LOCLK) * m_clockmult;
925            new_val = (m_channel[CHAN2].m_AUDF * 256 + m_channel[CHAN1].m_AUDF + DIVADD_LOCLK) * m_clockmult;
2058926         LOG_SOUND(("POKEY '%s' chan1+2 %d\n", tag(), new_val));
2059927        }
2060928        else
2061929      {
2062         new_val = (m_AUDF[CHAN2] + DIVADD_LOCLK) * m_clockmult;
930         new_val = (m_channel[CHAN2].m_AUDF + DIVADD_LOCLK) * m_clockmult;
2063931         LOG_SOUND(("POKEY '%s' chan2 %d\n", tag(), new_val));
2064932      }
2065933
2066      m_volume[CHAN2] = (m_AUDC[CHAN2] & VOLUME_MASK) * POKEY_DEFAULT_GAIN;
934      m_channel[CHAN2].m_volume = (m_channel[CHAN2].m_AUDC & VOLUME_MASK) * POKEY_DEFAULT_GAIN;
2067935      m_divisor[CHAN2] = new_val;
2068936      if( m_interrupt_cb && m_timer[TIMER2] )
2069937         m_timer[TIMER2]->adjust(m_clock_period * new_val, m_timer_param[TIMER2], m_timer_period[TIMER2]);
r15253r15254
2073941    {
2074942        /* process channel 3 frequency */
2075943      if( m_AUDCTL & CH3_HICLK )
2076         new_val = m_AUDF[CHAN3] + DIVADD_HICLK;
944         new_val = m_channel[CHAN3].m_AUDF + DIVADD_HICLK;
2077945        else
2078         new_val = (m_AUDF[CHAN3] + DIVADD_LOCLK) * m_clockmult;
946         new_val = (m_channel[CHAN3].m_AUDF + DIVADD_LOCLK) * m_clockmult;
2079947
2080948      LOG_SOUND(("POKEY '%s' chan3 %d\n", tag(), new_val));
2081949
2082      m_volume[CHAN3] = (m_AUDC[CHAN3] & VOLUME_MASK) * POKEY_DEFAULT_GAIN;
950      m_channel[CHAN3].m_volume = (m_channel[CHAN3].m_AUDC & VOLUME_MASK) * POKEY_DEFAULT_GAIN;
2083951      m_divisor[CHAN3] = new_val;
2084952      /* channel 3 does not have a timer associated */
2085953    }
r15253r15254
2090958      if( m_AUDCTL & CH34_JOINED )
2091959        {
2092960         if( m_AUDCTL & CH3_HICLK )
2093            new_val = m_AUDF[CHAN4] * 256 + m_AUDF[CHAN3] + DIVADD_HICLK_JOINED;
961            new_val = m_channel[CHAN4].m_AUDF * 256 + m_channel[CHAN3].m_AUDF + DIVADD_HICLK_JOINED;
2094962            else
2095            new_val = (m_AUDF[CHAN4] * 256 + m_AUDF[CHAN3] + DIVADD_LOCLK) * m_clockmult;
963            new_val = (m_channel[CHAN4].m_AUDF * 256 + m_channel[CHAN3].m_AUDF + DIVADD_LOCLK) * m_clockmult;
2096964         LOG_SOUND(("POKEY '%s' chan3+4 %d\n", tag(), new_val));
2097965        }
2098966        else
2099967      {
2100         new_val = (m_AUDF[CHAN4] + DIVADD_LOCLK) * m_clockmult;
968         new_val = (m_channel[CHAN4].m_AUDF + DIVADD_LOCLK) * m_clockmult;
2101969         LOG_SOUND(("POKEY '%s' chan4 %d\n", tag(), new_val));
2102970      }
2103971
2104      m_volume[CHAN4] = (m_AUDC[CHAN4] & VOLUME_MASK) * POKEY_DEFAULT_GAIN;
972      m_channel[CHAN4].m_volume = (m_channel[CHAN4].m_AUDC & VOLUME_MASK) * POKEY_DEFAULT_GAIN;
2105973      m_divisor[CHAN4] = new_val;
2106974      if( m_interrupt_cb && m_timer[TIMER4] )
2107975         m_timer[TIMER4]->adjust(m_clock_period * new_val, m_timer_param[TIMER4], m_timer_period[TIMER4]);
r15253r15254
21681036{
21691037   int toggle = 0;
21701038
2171   if( (m_AUDC[ch] & NOTPOLY5) || (m_poly5[m_p5] & 1) )
1039   if( (m_channel[ch].m_AUDC & NOTPOLY5) || (m_poly5[m_p5] & 1) )
21721040   {
2173      if( m_AUDC[ch] & PURE )
1041      if( m_channel[ch].m_AUDC & PURE )
21741042         toggle = 1;
21751043      else
2176      if( m_AUDC[ch] & POLY4 )
2177         toggle = m_output[ch] == !(m_poly4[m_p4] & 1);
1044      if( m_channel[ch].m_AUDC & POLY4 )
1045         toggle = m_channel[ch].m_output == !(m_poly4[m_p4] & 1);
21781046      else
21791047      if( m_AUDCTL & POLY9 )
2180         toggle = m_output[ch] == !(m_poly9[m_p9] & 1);
1048         toggle = m_channel[ch].m_output == !(m_poly9[m_p9] & 1);
21811049      else
2182         toggle = m_output[ch] == !(m_poly17[m_p17] & 1);
1050         toggle = m_channel[ch].m_output == !(m_poly17[m_p17] & 1);
21831051   }
21841052   if( toggle )
21851053   {
2186      m_output[ch] ^= 1;
1054      m_channel[ch].m_output ^= 1;
21871055   }
2188   /* is this a filtering channel (3/4) and is the filter active? */
2189
2190   if( m_AUDCTL & ((CH1_FILTER|CH2_FILTER) & (0x10 >> ch)) )
2191    {
2192      if( ch >= 2)
2193        {
2194         m_filter_sample[ch-2] = m_output[ch-2];
2195        }
2196    }
2197
21981056}
21991057
22001058
2201inline void pokeyn_device::reset_channel(int ch)
2202{
2203   m_counter[ch] = m_AUDF[ch] ^ 0xff;
2204}
22051059
22061060
2207inline void pokeyn_device::inc_chan(int ch)
2208{
2209   m_counter[ch] = (m_counter[ch] + 1) & 0xff;
2210   if (m_counter[ch] == 0 && m_borrow_cnt[ch] == 0)
2211      m_borrow_cnt[ch] = 3;
2212}
22131061
2214inline int pokeyn_device::check_borrow(int ch)
2215{
2216   if (m_borrow_cnt[ch] > 0)
2217   {
2218      m_borrow_cnt[ch]--;
2219      return (m_borrow_cnt[ch] == 0);
2220   }
2221   return 0;
2222}
2223
22241062void pokeyn_device::pokey_potgo(void)
22251063{
22261064    int pot;
r15253r15254
23091147
23101148}
23111149
1150char *pokeyn_device::audc2str(int val)
1151{
1152   static char buff[80];
1153   if( val & NOTPOLY5 )
1154   {
1155      if( val & PURE )
1156         strcpy(buff,"pure");
1157      else
1158      if( val & POLY4 )
1159         strcpy(buff,"poly4");
1160      else
1161         strcpy(buff,"poly9/17");
1162   }
1163   else
1164   {
1165      if( val & PURE )
1166         strcpy(buff,"poly5");
1167      else
1168      if( val & POLY4 )
1169         strcpy(buff,"poly4+poly5");
1170      else
1171         strcpy(buff,"poly9/17+poly5");
1172    }
1173   return buff;
1174}
1175
1176char *pokeyn_device::audctl2str(int val)
1177{
1178   static char buff[80];
1179   if( val & POLY9 )
1180      strcpy(buff,"poly9");
1181   else
1182      strcpy(buff,"poly17");
1183   if( val & CH1_HICLK )
1184      strcat(buff,"+ch1hi");
1185   if( val & CH3_HICLK )
1186      strcat(buff,"+ch3hi");
1187   if( val & CH12_JOINED )
1188      strcat(buff,"+ch1/2");
1189   if( val & CH34_JOINED )
1190      strcat(buff,"+ch3/4");
1191   if( val & CH1_FILTER )
1192      strcat(buff,"+ch1filter");
1193   if( val & CH2_FILTER )
1194      strcat(buff,"+ch2filter");
1195   if( val & CLK_15KHZ )
1196      strcat(buff,"+clk15");
1197    return buff;
1198}
1199
1200pokeyn_device::pokey_channel::pokey_channel()
1201   :   m_AUDF(0),
1202      m_AUDC(0),
1203      m_borrow_cnt(0),
1204      m_counter(0),
1205      m_volume(0),
1206      m_output(0),
1207      m_filter_sample(0)
1208{
1209}
1210
23121211//-------------------------------------------------
23131212//  Quad Pokey support - should be in game drivers, really
23141213//-------------------------------------------------
src/emu/sound/pokey.h
r15253r15254
3030
3131/* CONSTANT DEFINITIONS */
3232
33/* POKEY WRITE LOGICALS */
34#define AUDF1_C     0x00
35#define AUDC1_C     0x01
36#define AUDF2_C     0x02
37#define AUDC2_C     0x03
38#define AUDF3_C     0x04
39#define AUDC3_C     0x05
40#define AUDF4_C     0x06
41#define AUDC4_C     0x07
42#define AUDCTL_C    0x08
43#define STIMER_C    0x09
44#define SKREST_C    0x0A
45#define POTGO_C     0x0B
46#define SEROUT_C    0x0D
47#define IRQEN_C     0x0E
48#define SKCTL_C     0x0F
4933
50/* POKEY READ LOGICALS */
51#define POT0_C      0x00
52#define POT1_C      0x01
53#define POT2_C      0x02
54#define POT3_C      0x03
55#define POT4_C      0x04
56#define POT5_C      0x05
57#define POT6_C      0x06
58#define POT7_C      0x07
59#define ALLPOT_C    0x08
60#define KBCODE_C    0x09
61#define RANDOM_C    0x0A
62#define SERIN_C     0x0D
63#define IRQST_C     0x0E
64#define SKSTAT_C    0x0F
65
6634/* exact 1.79 MHz clock freq (of the Atari 800 that is) */
6735#define FREQ_17_EXACT   1789790
6836
r15253r15254
7543 *  New function pointers for serial input/output and a interrupt callback.
7644 *****************************************************************************/
7745
46class pokeyn_device;
47
7848typedef struct _pokey_interface pokey_interface;
7949struct _pokey_interface
8050{
r15253r15254
8252   devcb_read8 allpot_r;
8353   devcb_read8 serin_r;
8454   devcb_write8 serout_w;
85   void (*interrupt_cb)(device_t *device, int mask);
55   void (*interrupt_cb)(pokeyn_device *device, int mask);
8656};
8757
88#ifdef OLDDEVICE_FOR_MESS
89READ8_DEVICE_HANDLER( pokey_r );
90WRITE8_DEVICE_HANDLER( pokey_w );
9158
92/* fix me: eventually this should be a single device with pokey subdevices */
93READ8_HANDLER( quad_pokey_r );
94WRITE8_HANDLER( quad_pokey_w );
95
96void pokey_serin_ready (device_t *device, int after);
97void pokey_break_w (device_t *device, int shift);
98void pokey_kbcode_w (device_t *device, int kbcode, int make);
99
100DECLARE_LEGACY_SOUND_DEVICE(POKEY, pokey);
101
102#endif
103
10459//**************************************************************************
10560//  TYPE DEFINITIONS
10661//**************************************************************************
r15253r15254
11469#endif
11570{
11671public:
72
73   enum
74   {
75      /* POKEY WRITE LOGICALS */
76      AUDF1_C  =   0x00,
77      AUDC1_C  =   0x01,
78      AUDF2_C  =   0x02,
79      AUDC2_C  =   0x03,
80      AUDF3_C  =   0x04,
81      AUDC3_C  =   0x05,
82      AUDF4_C  =   0x06,
83      AUDC4_C  =   0x07,
84      AUDCTL_C =   0x08,
85      STIMER_C =   0x09,
86      SKREST_C =   0x0A,
87      POTGO_C  =   0x0B,
88      SEROUT_C =   0x0D,
89      IRQEN_C  =   0x0E,
90      SKCTL_C  =   0x0F
91   };
92
93   enum
94   {
95      /* POKEY READ LOGICALS */
96      POT0_C   =  0x00,
97      POT1_C   =  0x01,
98      POT2_C   =  0x02,
99      POT3_C   =  0x03,
100      POT4_C   =  0x04,
101      POT5_C   =  0x05,
102      POT6_C   =  0x06,
103      POT7_C   =  0x07,
104      ALLPOT_C =  0x08,
105      KBCODE_C =  0x09,
106      RANDOM_C =  0x0A,
107      SERIN_C  =  0x0D,
108      IRQST_C  =  0x0E,
109      SKSTAT_C =  0x0F
110   };
111
117112   // construction/destruction
118113   pokeyn_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
119114
r15253r15254
150145
151146private:
152147
148
149    class pokey_channel
150    {
151    public:
152       pokey_channel();
153       UINT8 m_AUDF;           /* AUDFx (D200, D202, D204, D206) */
154       UINT8 m_AUDC;         /* AUDCx (D201, D203, D205, D207) */
155       INT32 m_borrow_cnt;      /* borrow counter */
156       INT32 m_counter;      /* channel counter */
157       UINT32 m_volume;      /* channel volume - derived */
158       UINT8 m_output;         /* channel output signal (1 active, 0 inactive) */
159       UINT8 m_filter_sample;  /* high-pass filter sample */
160
161       inline void sample(void)         { m_filter_sample = m_output; }
162       inline void reset_channel(void)      { m_counter = m_AUDF ^ 0xff; }
163       inline void inc_chan(void)
164       {
165          m_counter = (m_counter + 1) & 0xff;
166          if (m_counter == 0 && m_borrow_cnt == 0)
167             m_borrow_cnt = 3;
168       }
169       inline int check_borrow()
170       {
171          if (m_borrow_cnt > 0)
172          {
173             m_borrow_cnt--;
174             return (m_borrow_cnt == 0);
175          }
176          return 0;
177       }
178    };
179
180   static const int POKEY_CHANNELS = 4;
181
153182   void poly_init_4_5(UINT32 *poly, int size, int xorbit, int invert);
154183   void poly_init_9_17(UINT32 *poly, int size);
155184   inline void process_channel(int ch);
156   inline void reset_channel(int ch);
157   inline void inc_chan(int ch);
158   inline int check_borrow(int ch);
159185   void pokey_potgo(void);
186   char *audc2str(int val);
187   char *audctl2str(int val);
160188
161189   // internal state
162190   sound_stream* m_stream;
163191
164   INT32 m_clock_cnt[3];      /* clock counters */
165   INT32 m_borrow_cnt[4];   /* borrow counters */
192   pokey_channel m_channel[POKEY_CHANNELS];
166193
167   INT32 m_counter[4];      /* channel counter */
168194   INT32 m_divisor[4];      /* channel divisor (modulo value) */
169   UINT32 m_volume[4];      /* channel volume - derived */
170   UINT8 m_output[4];      /* channel output signal (1 active, 0 inactive) */
171   UINT8 m_filter_sample[4];  /* hi-pass filter sample */
195   INT32 m_clock_cnt[3];      /* clock counters */
172196   UINT32 m_p4;              /* poly4 index */
173197   UINT32 m_p5;              /* poly5 index */
174198   UINT32 m_p9;              /* poly9 index */
r15253r15254
185209   devcb_resolved_read8 m_allpot_r;
186210   devcb_resolved_read8 m_serin_r;
187211   devcb_resolved_write8 m_serout_w;
188   void (*m_interrupt_cb)(device_t *device, int mask);
189   UINT8 m_AUDF[4];          /* AUDFx (D200, D202, D204, D206) */
190   UINT8 m_AUDC[4];         /* AUDCx (D201, D203, D205, D207) */
212   void (*m_interrupt_cb)(pokeyn_device *device, int mask);
191213   UINT8 m_POTx[8];         /* POTx   (R/D200-D207) */
192214   UINT8 m_AUDCTL;         /* AUDCTL (W/D208) */
193215   UINT8 m_ALLPOT;         /* ALLPOT (R/D208) */
src/emu/ioport.c
r15253r15254
992992     m_timer(NULL),
993993     m_current_rate(attotime::zero)
994994{
995     m_queue_chars = ioport_queue_chars_delegate();
995   m_queue_chars = ioport_queue_chars_delegate();
996996   m_accept_char = ioport_accept_char_delegate();
997997   m_charqueue_empty = ioport_charqueue_empty_delegate();
998998
r15253r15254
18331833unicode_char ioport_field::keyboard_code(int which) const
18341834{
18351835   unicode_char ch;
1836   
1836
18371837   if (which >= ARRAY_LENGTH(m_chars))
18381838      throw emu_fatalerror("Tried to access keyboard_code with out-of-range index %d\n", which);
1839   
1839
18401840   ch = m_chars[which];
18411841
18421842   // special hack to allow for PORT_CODE('\xA3')
r15253r15254
38493849         m_curfield->m_chars[index] = ch;
38503850         return;
38513851      }
3852     
3853   throw emu_fatalerror("PORT_CHAR(%d) could not be added - maximum amount exceeded\n", ch);
3852
3853   throw emu_fatalerror("PORT_CHAR(%d) could not be added - maximum amount exceeded\n", ch);
38543854}
38553855
38563856
r15253r15254
38753875      throw emu_fatalerror("alloc_setting called with no active field (value=%X name=%s)\n", value, name);
38763876
38773877   m_cursetting = global_alloc(ioport_setting(*m_curfield, value & m_curfield->mask(), string_from_token(name)));
3878   // append a new setting   
3878   // append a new setting
38793879   m_curfield->m_settinglist.append(*m_cursetting);
38803880}
38813881
src/emu/ioport.h
r15253r15254
833833   natural_keyboard(running_machine &machine);
834834
835835   void initialize();
836   
836
837837   // getters and queries
838838   running_machine &machine() const { return m_machine; }
839839   bool empty() const { return (m_bufbegin == m_bufend); }
src/emu/info.c
r15253r15254
690690      {
691691         astring newtag(screendev->tag()), oldtag(":");
692692         newtag.substr(newtag.find(oldtag.cat(root_tag)) + oldtag.len());
693         
693
694694         fprintf(m_output, "\t\t<display");
695695         fprintf(m_output, " tag=\"%s\"", xml_normalize_string(newtag));
696         
696
697697         switch (screendev->screen_type())
698698         {
699699            case SCREEN_TYPE_RASTER:   fprintf(m_output, " type=\"raster\"");   break;
r15253r15254
701701            case SCREEN_TYPE_LCD:      fprintf(m_output, " type=\"lcd\"");      break;
702702            default:               fprintf(m_output, " type=\"unknown\"");   break;
703703         }
704         
704
705705         // output the orientation as a string
706706         switch (m_drivlist.driver().flags & ORIENTATION_MASK)
707707         {
r15253r15254
730730               fprintf(m_output, " rotate=\"0\"");
731731               break;
732732         }
733         
733
734734         // output width and height only for games that are not vector
735735         if (screendev->screen_type() != SCREEN_TYPE_VECTOR)
736736         {
r15253r15254
738738            fprintf(m_output, " width=\"%d\"", visarea.width());
739739            fprintf(m_output, " height=\"%d\"", visarea.height());
740740         }
741         
741
742742         // output refresh rate
743743         fprintf(m_output, " refresh=\"%f\"", ATTOSECONDS_TO_HZ(screendev->refresh_attoseconds()));
744         
744
745745         // output raw video parameters only for games that are not vector
746746         // and had raw parameters specified
747747         if (screendev->screen_type() != SCREEN_TYPE_VECTOR && !screendev->oldstyle_vblank_supplied())
748748         {
749749            int pixclock = screendev->width() * screendev->height() * ATTOSECONDS_TO_HZ(screendev->refresh_attoseconds());
750           
750
751751            fprintf(m_output, " pixclock=\"%d\"", pixclock);
752752            fprintf(m_output, " htotal=\"%d\"", screendev->width());
753753            fprintf(m_output, " hbend=\"%d\"", screendev->visible_area().min_x);
src/emu/device.h
r15253r15254
631631
632632protected:
633633   // internal state
634   shared_ptr_type *m_array[_Count];
635   astring m_tag[_Count];
634   shared_ptr_type *m_array[_Count+1];
635   astring m_tag[_Count+1];
636636};
637637
638638// optional shared pointer array finder
src/emu/machine/68681.c
r15253r15254
660660                            rate = attotime::from_hz(2*device->clock()/(2*16*16*0x10000));
661661                        }
662662                    }
663                       
663
664664                    //hz = ATTOSECONDS_TO_HZ(rate.attoseconds);
665665
666666                    duart68681->duart_timer->adjust(rate, 0, rate);
src/emu/timer.c
r15253r15254
199199            mame_printf_warning("Scanline timer specified parameters for a periodic timer\n");
200200         if (m_param != 0)
201201            mame_printf_warning("Scanline timer specified parameter which is ignored\n");
202//         if (m_first_vpos < 0)
203//            mame_printf_error("Scanline timer specified invalid initial position\n");
204//         if (m_increment < 0)
205//            mame_printf_error("Scanline timer specified invalid increment\n");
202//          if (m_first_vpos < 0)
203//              mame_printf_error("Scanline timer specified invalid initial position\n");
204//          if (m_increment < 0)
205//              mame_printf_error("Scanline timer specified invalid increment\n");
206206         break;
207207
208208      default:
src/version.c
r15253r15254
3838***************************************************************************/
3939
4040extern const char build_version[];
41const char build_version[] = "0.145u8 ("__DATE__")";
41const char build_version[] = "0.146 ("__DATE__")";
src/mess/machine/c64_cpm.c
r15253r15254
1111 
1212/*
1313 
14   TODO:
14    TODO:
1515 
16   - Z80 clock speed
16    - Z80 clock speed
1717 
1818*/
1919 
src/mess/machine/kb_msnat.c
r15253r15254
9696   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD )   PORT_CODE(KEYCODE_F4)         PORT_CHAR(UCHAR_MAMEKEY(F4))      // 3E
9797
9898   PORT_START( "P2.7" )
99   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD )   PORT_CODE(KEYCODE_SLASH_PAD)   PORT_CHAR(UCHAR_MAMEKEY(SLASH_PAD))   // E0
99   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD )   PORT_CODE(KEYCODE_SLASH_PAD)   PORT_CHAR(UCHAR_MAMEKEY(SLASH_PAD))   // E0
100100   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD )   PORT_CODE(KEYCODE_7_PAD)      PORT_CHAR(UCHAR_MAMEKEY(7_PAD))      // 47
101101   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD )   PORT_CODE(KEYCODE_4_PAD)      PORT_CHAR(UCHAR_MAMEKEY(4_PAD))      // 4B
102102   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD )   PORT_CODE(KEYCODE_PLUS_PAD)      PORT_CHAR(UCHAR_MAMEKEY(PLUS_PAD))   // 4E
103103   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD )   PORT_CODE(KEYCODE_1_PAD)      PORT_CHAR(UCHAR_MAMEKEY(1_PAD))      // 4F
104   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD )   PORT_CODE(KEYCODE_ASTERISK)      PORT_CHAR(UCHAR_MAMEKEY(ASTERISK))   // 37   TODO
105   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD )   PORT_CODE(KEYCODE_PRTSCR)      PORT_CHAR(UCHAR_MAMEKEY(PRTSCR))   // E0 2A E0 37
104   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD )   PORT_CODE(KEYCODE_ASTERISK)      PORT_CHAR(UCHAR_MAMEKEY(ASTERISK))   // 37   TODO
105   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD )   PORT_CODE(KEYCODE_PRTSCR)      PORT_CHAR(UCHAR_MAMEKEY(PRTSCR))   // E0 2A E0 37
106106   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD )   PORT_CODE(KEYCODE_MENU)         PORT_CHAR(UCHAR_MAMEKEY(MENU))      // E0 5D
107107
108108   PORT_START( "P1.0" )
src/mess/machine/kaypro.c
r15253r15254
229229
230230WRITE8_MEMBER( kaypro_state::kaypro_baud_a_w )   /* channel A - RS232C */
231231{
232//   data &= 0x0f;
232//  data &= 0x0f;
233233
234234//  z80sio_set_rx_clock( m_sio, baud_clock[data], 0);
235235//  z80sio_set_tx_clock( m_sio, baud_clock[data], 0);
r15253r15254
237237
238238WRITE8_MEMBER( kaypro_state::kayproii_baud_b_w )   /* Channel B - Keyboard - only usable speed is 300 baud */
239239{
240//   data &= 0x0f;
240//  data &= 0x0f;
241241
242242//  z80sio_set_rx_clock( m_sio, baud_clock[data], 1);
243243//  z80sio_set_tx_clock( m_sio, baud_clock[data], 1);
r15253r15254
245245
246246WRITE8_MEMBER( kaypro_state::kaypro2x_baud_a_w )   /* Channel A on 2nd SIO - Serial Printer */
247247{
248//   data &= 0x0f;
248//  data &= 0x0f;
249249
250250//  z80sio_set_rx_clock( m_sio2x, baud_clock[data], 0);
251251//  z80sio_set_tx_clock( m_sio2x, baud_clock[data], 0);
src/mess/machine/8530scc.c
r15253r15254
226226
227227      rv |= (ourCh->txUnderrun) ? 0x40 : 0;
228228      rv |= (ourCh->syncHunt) ? 0x10 : 0;
229      rv |= channel[0].reg_val[0] & 0x05; // pick up TXBE and RXBF bits
229      rv |= channel[0].reg_val[0] & 0x05; // pick up TXBE and RXBF bits
230230
231231      return rv;
232232   }
r15253r15254
257257
258258      rv |= (ourCh->txUnderrun) ? 0x40 : 0;
259259      rv |= (ourCh->syncHunt) ? 0x10 : 0;
260      rv |= channel[1].reg_val[0] & 0x05; // pick up TXBE and RXBF bits
260      rv |= channel[1].reg_val[0] & 0x05; // pick up TXBE and RXBF bits
261261
262262      return rv;
263263   }
src/mess/machine/vic20user.c
r15253r15254
1/**********************************************************************
2
3    Commodore VIC-20 User Port emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "machine/vic20user.h"
11
12
13
14//**************************************************************************
15//  GLOBAL VARIABLES
16//**************************************************************************
17
18const device_type VIC20_USER_PORT = &device_creator<vic20_user_port_device>;
19
20
21
22//**************************************************************************
23//  CARD INTERFACE
24//**************************************************************************
25
26//-------------------------------------------------
27//  device_vic20_user_port_interface - constructor
28//-------------------------------------------------
29
30device_vic20_user_port_interface::device_vic20_user_port_interface(const machine_config &mconfig, device_t &device)
31   : device_slot_card_interface(mconfig,device)
32{
33   m_slot = dynamic_cast<vic20_user_port_device *>(device.owner());
34}
35
36
37//-------------------------------------------------
38//  ~device_vic20_user_port_interface - destructor
39//-------------------------------------------------
40
41device_vic20_user_port_interface::~device_vic20_user_port_interface()
42{
43}
44
45
46
47//**************************************************************************
48//  LIVE DEVICE
49//**************************************************************************
50
51//-------------------------------------------------
52//  vic20_user_port_device - constructor
53//-------------------------------------------------
54
55vic20_user_port_device::vic20_user_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
56        device_t(mconfig, VIC20_USER_PORT, "VIC-20 user port", tag, owner, clock),
57      device_slot_interface(mconfig, *this)
58{
59}
60
61
62//-------------------------------------------------
63//  vic20_user_port_device - destructor
64//-------------------------------------------------
65
66vic20_user_port_device::~vic20_user_port_device()
67{
68}
69
70
71//-------------------------------------------------
72//  device_config_complete - perform any
73//  operations now that the configuration is
74//  complete
75//-------------------------------------------------
76
77void vic20_user_port_device::device_config_complete()
78{
79   // inherit a copy of the static data
80   const vic20_user_port_interface *intf = reinterpret_cast<const vic20_user_port_interface *>(static_config());
81   if (intf != NULL)
82   {
83      *static_cast<vic20_user_port_interface *>(this) = *intf;
84   }
85
86   // or initialize to defaults if none provided
87   else
88   {
89       memset(&m_out_cb1_cb, 0, sizeof(m_out_cb1_cb));
90       memset(&m_out_cb2_cb, 0, sizeof(m_out_cb2_cb));
91       memset(&m_out_reset_cb, 0, sizeof(m_out_reset_cb));
92   }
93}
94
95
96//-------------------------------------------------
97//  device_start - device-specific startup
98//-------------------------------------------------
99
100void vic20_user_port_device::device_start()
101{
102   m_cart = dynamic_cast<device_vic20_user_port_interface *>(get_card_device());
103
104   // resolve callbacks
105   m_out_cb1_func.resolve(m_out_cb1_cb, *this);
106   m_out_cb2_func.resolve(m_out_cb2_cb, *this);
107   m_out_reset_func.resolve(m_out_reset_cb, *this);
108}
109
110
111//-------------------------------------------------
112//  device_reset - device-specific reset
113//-------------------------------------------------
114
115void vic20_user_port_device::device_reset()
116{
117}
118
119
120READ8_MEMBER( vic20_user_port_device::pb_r ) { UINT8 data = 0xff; if (m_cart != NULL) data = m_cart->vic20_pb_r(space, offset); return data; }
121WRITE8_MEMBER( vic20_user_port_device::pb_w ) { if (m_cart != NULL) m_cart->vic20_pb_w(space, offset, data); }
122READ_LINE_MEMBER( vic20_user_port_device::joy0_r ) { int state = 1; if (m_cart != NULL) state = m_cart->vic20_joy0_r(); return state; }
123READ_LINE_MEMBER( vic20_user_port_device::joy1_r ) { int state = 1; if (m_cart != NULL) state = m_cart->vic20_joy1_r(); return state; }
124READ_LINE_MEMBER( vic20_user_port_device::joy2_r ) { int state = 1; if (m_cart != NULL) state = m_cart->vic20_joy2_r(); return state; }
125READ_LINE_MEMBER( vic20_user_port_device::light_pen_r ) { int state = 1; if (m_cart != NULL) state = m_cart->vic20_light_pen_r(); return state; }
126READ_LINE_MEMBER( vic20_user_port_device::cassette_switch_r ) { int state = 1; if (m_cart != NULL) state = m_cart->vic20_cassette_switch_r(); return state; }
127WRITE_LINE_MEMBER( vic20_user_port_device::cb1_w ) { if (m_cart != NULL) m_cart->vic20_cb1_w(state); }
128WRITE_LINE_MEMBER( vic20_user_port_device::cb2_w ) { if (m_cart != NULL) m_cart->vic20_cb2_w(state); }
129WRITE_LINE_MEMBER( vic20_user_port_device::atn_w ) { if (m_cart != NULL) m_cart->vic20_atn_w(state); }
130
131WRITE_LINE_MEMBER( vic20_user_port_device::via_cb1_w ) { m_out_cb1_func(state); }
132WRITE_LINE_MEMBER( vic20_user_port_device::via_cb2_w ) { m_out_cb2_func(state); }
133WRITE_LINE_MEMBER( vic20_user_port_device::reset_w ) { m_out_reset_func(state); }
1/**********************************************************************
2 
3    Commodore VIC-20 User Port emulation
4 
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7 
8**********************************************************************/
9 
10#include "machine/vic20user.h"
11 
12 
13 
14//**************************************************************************
15//  GLOBAL VARIABLES
16//**************************************************************************
17 
18const device_type VIC20_USER_PORT = &device_creator<vic20_user_port_device>;
19 
20 
21 
22//**************************************************************************
23//  CARD INTERFACE
24//**************************************************************************
25 
26//-------------------------------------------------
27//  device_vic20_user_port_interface - constructor
28//-------------------------------------------------
29 
30device_vic20_user_port_interface::device_vic20_user_port_interface(const machine_config &mconfig, device_t &device)
31   : device_slot_card_interface(mconfig,device)
32{
33   m_slot = dynamic_cast<vic20_user_port_device *>(device.owner());
34}
35 
36 
37//-------------------------------------------------
38//  ~device_vic20_user_port_interface - destructor
39//-------------------------------------------------
40 
41device_vic20_user_port_interface::~device_vic20_user_port_interface()
42{
43}
44 
45 
46 
47//**************************************************************************
48//  LIVE DEVICE
49//**************************************************************************
50 
51//-------------------------------------------------
52//  vic20_user_port_device - constructor
53//-------------------------------------------------
54 
55vic20_user_port_device::vic20_user_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
56        device_t(mconfig, VIC20_USER_PORT, "VIC-20 user port", tag, owner, clock),
57      device_slot_interface(mconfig, *this)
58{
59}
60 
61 
62//-------------------------------------------------
63//  vic20_user_port_device - destructor
64//-------------------------------------------------
65 
66vic20_user_port_device::~vic20_user_port_device()
67{
68}
69 
70 
71//-------------------------------------------------
72//  device_config_complete - perform any
73//  operations now that the configuration is
74//  complete
75//-------------------------------------------------
76 
77void vic20_user_port_device::device_config_complete()
78{
79   // inherit a copy of the static data
80   const vic20_user_port_interface *intf = reinterpret_cast<const vic20_user_port_interface *>(static_config());
81   if (intf != NULL)
82   {
83      *static_cast<vic20_user_port_interface *>(this) = *intf;
84   }
85 
86   // or initialize to defaults if none provided
87   else
88   {
89       memset(&m_out_cb1_cb, 0, sizeof(m_out_cb1_cb));
90       memset(&m_out_cb2_cb, 0, sizeof(m_out_cb2_cb));
91       memset(&m_out_reset_cb, 0, sizeof(m_out_reset_cb));
92   }
93}
94 
95 
96//-------------------------------------------------
97//  device_start - device-specific startup
98//-------------------------------------------------
99 
100void vic20_user_port_device::device_start()
101{
102   m_cart = dynamic_cast<device_vic20_user_port_interface *>(get_card_device());
103 
104   // resolve callbacks
105   m_out_cb1_func.resolve(m_out_cb1_cb, *this);
106   m_out_cb2_func.resolve(m_out_cb2_cb, *this);
107   m_out_reset_func.resolve(m_out_reset_cb, *this);
108}
109 
110 
111//-------------------------------------------------
112//  device_reset - device-specific reset
113//-------------------------------------------------
114 
115void vic20_user_port_device::device_reset()
116{
117}
118 
119 
120READ8_MEMBER( vic20_user_port_device::pb_r ) { UINT8 data = 0xff; if (m_cart != NULL) data = m_cart->vic20_pb_r(space, offset); return data; }
121WRITE8_MEMBER( vic20_user_port_device::pb_w ) { if (m_cart != NULL) m_cart->vic20_pb_w(space, offset, data); }
122READ_LINE_MEMBER( vic20_user_port_device::joy0_r ) { int state = 1; if (m_cart != NULL) state = m_cart->vic20_joy0_r(); return state; }
123READ_LINE_MEMBER( vic20_user_port_device::joy1_r ) { int state = 1; if (m_cart != NULL) state = m_cart->vic20_joy1_r(); return state; }
124READ_LINE_MEMBER( vic20_user_port_device::joy2_r ) { int state = 1; if (m_cart != NULL) state = m_cart->vic20_joy2_r(); return state; }
125READ_LINE_MEMBER( vic20_user_port_device::light_pen_r ) { int state = 1; if (m_cart != NULL) state = m_cart->vic20_light_pen_r(); return state; }
126READ_LINE_MEMBER( vic20_user_port_device::cassette_switch_r ) { int state = 1; if (m_cart != NULL) state = m_cart->vic20_cassette_switch_r(); return state; }
127WRITE_LINE_MEMBER( vic20_user_port_device::cb1_w ) { if (m_cart != NULL) m_cart->vic20_cb1_w(state); }
128WRITE_LINE_MEMBER( vic20_user_port_device::cb2_w ) { if (m_cart != NULL) m_cart->vic20_cb2_w(state); }
129WRITE_LINE_MEMBER( vic20_user_port_device::atn_w ) { if (m_cart != NULL) m_cart->vic20_atn_w(state); }
130 
131WRITE_LINE_MEMBER( vic20_user_port_device::via_cb1_w ) { m_out_cb1_func(state); }
132WRITE_LINE_MEMBER( vic20_user_port_device::via_cb2_w ) { m_out_cb2_func(state); }
133WRITE_LINE_MEMBER( vic20_user_port_device::reset_w ) { m_out_reset_func(state); }
src/mess/machine/vic20user.h
r15253r15254
1/**********************************************************************
2
3    Commodore VIC-20 User Port emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************
9
10                    GND       1      A       GND
11                    +5V       2      B       CB1
12                 /RESET       3      C       PB0
13                   JOY0       4      D       PB1
14                   JOY1       5      E       PB2
15                   JOY2       6      F       PB3
16              LIGHT PEN       7      H       PB4
17        CASSETTE SWITCH       8      J       PB5
18                    ATN       9      K       PB6
19                  +9VAC      10      L       PB7
20                  +9VAC      11      M       CB2
21                    GND      12      N       GND
22
23**********************************************************************/
24
25#pragma once
26
27#ifndef __VIC20_USER_PORT__
28#define __VIC20_USER_PORT__
29
30#include "emu.h"
31
32
33
34//**************************************************************************
35//  CONSTANTS
36//**************************************************************************
37
38#define VIC20_USER_PORT_TAG      "user"
39
40
41
42//**************************************************************************
43//  INTERFACE CONFIGURATION MACROS
44//**************************************************************************
45
46#define VIC20_USER_PORT_INTERFACE(_name) \
47   const vic20_user_port_interface (_name) =
48
49
50#define MCFG_VIC20_USER_PORT_ADD(_tag, _config, _slot_intf, _def_slot, _def_inp) \
51    MCFG_DEVICE_ADD(_tag, VIC20_USER_PORT, 0) \
52    MCFG_DEVICE_CONFIG(_config) \
53   MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _def_inp)
54
55
56
57//**************************************************************************
58//  TYPE DEFINITIONS
59//**************************************************************************
60
61// ======================> vic20_user_port_interface
62
63struct vic20_user_port_interface
64{
65   devcb_write_line   m_out_cb1_cb;
66   devcb_write_line   m_out_cb2_cb;
67    devcb_write_line   m_out_reset_cb;
68};
69
70
71// ======================> vic20_user_port_device
72
73class device_vic20_user_port_interface;
74
75class vic20_user_port_device : public device_t,
76                         public vic20_user_port_interface,
77                         public device_slot_interface
78{
79public:
80   // construction/destruction
81   vic20_user_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
82   virtual ~vic20_user_port_device();
83
84   // computer interface
85   DECLARE_READ8_MEMBER( pb_r );
86   DECLARE_WRITE8_MEMBER( pb_w );
87   DECLARE_READ_LINE_MEMBER( joy0_r );
88   DECLARE_READ_LINE_MEMBER( joy1_r );
89   DECLARE_READ_LINE_MEMBER( joy2_r );
90   DECLARE_READ_LINE_MEMBER( light_pen_r );
91   DECLARE_READ_LINE_MEMBER( cassette_switch_r );
92   DECLARE_WRITE_LINE_MEMBER( cb1_w );
93   DECLARE_WRITE_LINE_MEMBER( cb2_w );
94   DECLARE_WRITE_LINE_MEMBER( atn_w );
95
96   // cartridge interface
97   DECLARE_WRITE_LINE_MEMBER( via_cb1_w );
98   DECLARE_WRITE_LINE_MEMBER( via_cb2_w );
99   DECLARE_WRITE_LINE_MEMBER( reset_w );
100
101protected:
102   // device-level overrides
103   virtual void device_start();
104   virtual void device_reset();
105   virtual void device_config_complete();
106
107   devcb_resolved_write_line   m_out_cb1_func;
108   devcb_resolved_write_line   m_out_cb2_func;
109    devcb_resolved_write_line   m_out_reset_func;
110
111   device_vic20_user_port_interface *m_cart;
112};
113
114
115// ======================> device_vic20_user_port_interface
116
117// class representing interface-specific live vic20_expansion card
118class device_vic20_user_port_interface : public device_slot_card_interface
119{
120public:
121   // construction/destruction
122   device_vic20_user_port_interface(const machine_config &mconfig, device_t &device);
123   virtual ~device_vic20_user_port_interface();
124
125   virtual UINT8 vic20_pb_r(address_space &space, offs_t offset) { return 0xff; };
126   virtual void vic20_pb_w(address_space &space, offs_t offset, UINT8 data) { };
127
128   virtual int vic20_joy0_r() { return 1; };
129   virtual int vic20_joy1_r() { return 1; };
130   virtual int vic20_joy2_r() { return 1; };
131   virtual int vic20_light_pen_r() { return 1; };
132   virtual int vic20_cassette_switch_r() { return 1; };
133   virtual void vic20_cb1_w(int state) { };
134   virtual void vic20_cb2_w(int state) { };
135   virtual void vic20_atn_w(int state) { };
136
137   // reset
138   virtual void vic20_reset_w(int state) { };
139
140protected:
141   vic20_user_port_device *m_slot;
142};
143
144
145// device type definition
146extern const device_type VIC20_USER_PORT;
147
148
149
150#endif
1/**********************************************************************
2 
3    Commodore VIC-20 User Port emulation
4 
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7 
8**********************************************************************
9 
10                    GND       1      A       GND
11                    +5V       2      B       CB1
12                 /RESET       3      C       PB0
13                   JOY0       4      D       PB1
14                   JOY1       5      E       PB2
15                   JOY2       6      F       PB3
16              LIGHT PEN       7      H       PB4
17        CASSETTE SWITCH       8      J       PB5
18                    ATN       9      K       PB6
19                  +9VAC      10      L       PB7
20                  +9VAC      11      M       CB2
21                    GND      12      N       GND
22 
23**********************************************************************/
24 
25#pragma once
26 
27#ifndef __VIC20_USER_PORT__
28#define __VIC20_USER_PORT__
29 
30#include "emu.h"
31 
32 
33 
34//**************************************************************************
35//  CONSTANTS
36//**************************************************************************
37 
38#define VIC20_USER_PORT_TAG      "user"
39 
40 
41 
42//**************************************************************************
43//  INTERFACE CONFIGURATION MACROS
44//**************************************************************************
45 
46#define VIC20_USER_PORT_INTERFACE(_name) \
47   const vic20_user_port_interface (_name) =
48 
49 
50#define MCFG_VIC20_USER_PORT_ADD(_tag, _config, _slot_intf, _def_slot, _def_inp) \
51    MCFG_DEVICE_ADD(_tag, VIC20_USER_PORT, 0) \
52    MCFG_DEVICE_CONFIG(_config) \
53   MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _def_inp)
54 
55 
56 
57//**************************************************************************
58//  TYPE DEFINITIONS
59//**************************************************************************
60 
61// ======================> vic20_user_port_interface
62 
63struct vic20_user_port_interface
64{
65   devcb_write_line   m_out_cb1_cb;
66   devcb_write_line   m_out_cb2_cb;
67    devcb_write_line   m_out_reset_cb;
68};
69 
70 
71// ======================> vic20_user_port_device
72 
73class device_vic20_user_port_interface;
74 
75class vic20_user_port_device : public device_t,
76                         public vic20_user_port_interface,
77                         public device_slot_interface
78{
79public:
80   // construction/destruction
81   vic20_user_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
82   virtual ~vic20_user_port_device();
83 
84   // computer interface
85   DECLARE_READ8_MEMBER( pb_r );
86   DECLARE_WRITE8_MEMBER( pb_w );
87   DECLARE_READ_LINE_MEMBER( joy0_r );
88   DECLARE_READ_LINE_MEMBER( joy1_r );
89   DECLARE_READ_LINE_MEMBER( joy2_r );
90   DECLARE_READ_LINE_MEMBER( light_pen_r );
91   DECLARE_READ_LINE_MEMBER( cassette_switch_r );
92   DECLARE_WRITE_LINE_MEMBER( cb1_w );
93   DECLARE_WRITE_LINE_MEMBER( cb2_w );
94   DECLARE_WRITE_LINE_MEMBER( atn_w );
95 
96   // cartridge interface
97   DECLARE_WRITE_LINE_MEMBER( via_cb1_w );
98   DECLARE_WRITE_LINE_MEMBER( via_cb2_w );
99   DECLARE_WRITE_LINE_MEMBER( reset_w );
100 
101protected:
102   // device-level overrides
103   virtual void device_start();
104   virtual void device_reset();
105   virtual void device_config_complete();
106 
107   devcb_resolved_write_line   m_out_cb1_func;
108   devcb_resolved_write_line   m_out_cb2_func;
109    devcb_resolved_write_line   m_out_reset_func;
110 
111   device_vic20_user_port_interface *m_cart;
112};
113 
114 
115// ======================> device_vic20_user_port_interface
116 
117// class representing interface-specific live vic20_expansion card
118class device_vic20_user_port_interface : public device_slot_card_interface
119{
120public:
121   // construction/destruction
122   device_vic20_user_port_interface(const machine_config &mconfig, device_t &device);
123   virtual ~device_vic20_user_port_interface();
124 
125   virtual UINT8 vic20_pb_r(address_space &space, offs_t offset) { return 0xff; };
126   virtual void vic20_pb_w(address_space &space, offs_t offset, UINT8 data) { };
127 
128   virtual int vic20_joy0_r() { return 1; };
129   virtual int vic20_joy1_r() { return 1; };
130   virtual int vic20_joy2_r() { return 1; };
131   virtual int vic20_light_pen_r() { return 1; };
132   virtual int vic20_cassette_switch_r() { return 1; };
133   virtual void vic20_cb1_w(int state) { };
134   virtual void vic20_cb2_w(int state) { };
135   virtual void vic20_atn_w(int state) { };
136 
137   // reset
138   virtual void vic20_reset_w(int state) { };
139 
140protected:
141   vic20_user_port_device *m_slot;
142};
143 
144 
145// device type definition
146extern const device_type VIC20_USER_PORT;
147 
148 
149 
150#endif
src/mess/machine/lisa.c
r15253r15254
271271#endif
272272
273273   {
274//      printf("Adding %d bytes of data to FIFO\n", len);
274//      printf("Adding %d bytes of data to FIFO\n", len);
275275
276276      while (len--)
277277      {
src/mess/includes/vidbrain.h
r15253r15254
6868   int m_sound_clk;
6969
7070   // timers
71   emu_timer *m_timer_ne555;   
71   emu_timer *m_timer_ne555;
7272};
7373
7474//----------- defined in video/vidbrain.c -----------
src/mess/includes/cxhumax.h
r15253r15254
4141
4242   DECLARE_WRITE32_MEMBER ( flash_w );
4343   DECLARE_READ32_MEMBER ( flash_r );
44   
44
4545   DECLARE_WRITE32_MEMBER ( cx_hsx_w );
4646   DECLARE_READ32_MEMBER ( cx_hsx_r );
4747
r15253r15254
8787
8888   DECLARE_WRITE32_MEMBER ( cx_ss_w );
8989   DECLARE_READ32_MEMBER ( cx_ss_r );
90   
90
9191   DECLARE_WRITE32_MEMBER ( cx_i2c0_w );
9292   DECLARE_READ32_MEMBER ( cx_i2c0_r );
9393   DECLARE_WRITE32_MEMBER ( cx_i2c1_w );
9494   DECLARE_READ32_MEMBER ( cx_i2c1_r );
9595   DECLARE_WRITE32_MEMBER ( cx_i2c2_w );
9696   DECLARE_READ32_MEMBER ( cx_i2c2_r );
97   
97
9898   DECLARE_WRITE32_MEMBER ( cx_mc_cfg_w );
9999   DECLARE_READ32_MEMBER ( cx_mc_cfg_r );
100   
100
101101   DECLARE_WRITE32_MEMBER ( cx_drm0_w );
102102   DECLARE_READ32_MEMBER ( cx_drm0_r );
103103   DECLARE_WRITE32_MEMBER ( cx_drm1_w );
104104   DECLARE_READ32_MEMBER ( cx_drm1_r );
105   
105
106106   DECLARE_WRITE32_MEMBER ( cx_hdmi_w );
107107   DECLARE_READ32_MEMBER ( cx_hdmi_r );
108   
108
109109   DECLARE_WRITE32_MEMBER ( cx_gxa_w );
110110   DECLARE_READ32_MEMBER ( cx_gxa_r );
111111
112112   DECLARE_READ32_MEMBER ( dummy_flash_r );
113   
113
114114   UINT32 m_romdescr_reg;
115115   UINT32 m_isaromdescr_regs[0x0C/4];
116116   UINT32 m_isadescr_regs[0x10/4];
r15253r15254
129129   UINT32 m_pllprescale_reg;
130130
131131   UINT32 m_intctrl_regs[0x38/4];
132   
132
133133   UINT32 m_ss_regs[0x18/4];
134134   UINT8 m_ss_tx_fifo[8];            // 8 entries (size hardcoded to 8 bits per entry - TODO)
135135
r15253r15254
141141   UINT32 m_mccfg_regs[0x0C/4];
142142
143143   UINT32 m_chipcontrol_regs[0x74/4];
144   
144
145145   UINT32 m_drm0_regs[0xfc/4];
146146   UINT32 m_drm1_regs[0xfc/4];
147   
147
148148   UINT32 m_hdmi_regs[0x400/4];
149   
149
150150   UINT32 m_gxa_cmd_regs[0x130/4];
151151};
152152
153153#define INTDEST         0   // Interrupt destination (1=IRQ, 0=FIQ)
154154#define INTENABLE      1   // Enables the interrupt generation
155#define INTIRQ         2   // Normal interrupt
155#define INTIRQ         2   // Normal interrupt
156156#define INTFIQ         3   // Fast interrupt
157157#define INTSTATCLR      4   // Read: interrupt status, Write: clear pending interrupt
158158#define INTSTATSET      5   // Read: interrupt status, Write: sets a pending interrupt
159159#define INTGROUP1      0
160160#define INTGROUP2      1
161161
162#define INTREG(group, index)   (((group) << 3) | (index))
162#define INTREG(group, index)   (((group) << 3) | (index))
163163
164164#define GXA_CMD_RW_REGISTER            0x00
165165#define GXA_CMD_QMARK               0x02
src/mess/includes/dm7000.h
r15253r15254
1515
1616   required_device<cpu_device> m_maincpu;
1717   required_device<generic_terminal_device> m_terminal;
18   
18
1919   DECLARE_WRITE8_MEMBER ( dm7000_iic0_w );
2020   DECLARE_READ8_MEMBER ( dm7000_iic0_r );
2121   DECLARE_WRITE8_MEMBER ( dm7000_iic1_w );
2222   DECLARE_READ8_MEMBER ( dm7000_iic1_r );
23   
23
2424   DECLARE_WRITE8_MEMBER ( dm7000_scc0_w );
2525   DECLARE_READ8_MEMBER ( dm7000_scc0_r );
2626   UINT8 m_scc0_lcr;
2727   UINT8 m_scc0_lsr;
28   
28
2929   DECLARE_WRITE8_MEMBER ( dm7000_gpio0_w );
3030   DECLARE_READ8_MEMBER ( dm7000_gpio0_r );
31   
31
3232   DECLARE_WRITE8_MEMBER ( dm7000_scp0_w );
3333   DECLARE_READ8_MEMBER ( dm7000_scp0_r );
34   
35   UINT32         dcr[1024];   
34
35   UINT32         dcr[1024];
3636};
3737
3838/* */
src/mess/video/uv201.c
r15253r15254
1/**********************************************************************
2
3    VideoBrain UV201/UV202 video chip emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "uv201.h"
11
12
13
14//**************************************************************************
15//  MACROS / CONSTANTS
16//**************************************************************************
17
18#define LOG       1
19
20
21// write-only registers
22#define REGISTER_COMMAND         0xf7
23#define REGISTER_BACKGROUND         0xf5
24#define REGISTER_FINAL_MODIFIER      0xf2
25#define REGISTER_Y_INTERRUPT      0xf0
26
27
28// read-only registers
29#define REGISTER_X_FREEZE         0xf8
30#define REGISTER_Y_FREEZE_LOW      0xf9
31#define REGISTER_Y_FREEZE_HIGH      0xfa
32#define REGISTER_CURRENT_Y_LOW      0xfb
33
34
35// read/write registers - RAM memory
36#define RAM_RP_LO               0x00   // cartridge pointer low order
37#define RAM_RP_HI_COLOR            0x10   // cartridge pointer high order and color
38#define RAM_DX_INT_XCOPY         0x20   // dX, intensity, X-copy
39#define RAM_DY                  0x30   // dY
40#define RAM_X                  0x40   // X value
41#define RAM_Y_LO_A               0x50   // Y value low order list A
42#define RAM_Y_LO_B               0x60   // Y value low order list B
43#define RAM_XY_HI_A               0x70   // Y value high order and X order list A
44#define RAM_XY_HI_B               0x80   // Y value high order and X order list B
45
46
47// command register bits
48#define COMMAND_YINT_H_O         0x80
49#define COMMAND_A_B               0x40
50#define COMMAND_Y_ZM            0x20
51#define COMMAND_KBD               0x10
52#define COMMAND_INT               0x08
53#define COMMAND_ENB               0x04
54#define COMMAND_FRZ               0x02
55#define COMMAND_X_ZM            0x01
56
57
58#define IS_CHANGED(_bit) \
59   ((m_cmd & _bit) != (data & _bit))
60
61#define RAM(_offset) \
62   m_ram[_offset + i]
63
64#define RAM_XORD(_offset) \
65   m_ram[_offset + xord]
66
67#define IS_VISIBLE(_y) \
68   ((_y >= cliprect.min_y) && (_y <= cliprect.max_y))
69
70#define DRAW_PIXEL(_scanline, _dot) \
71   if (IS_VISIBLE(_scanline)) bitmap.pix16((_scanline), _dot) = pixel;
72
73
74
75//**************************************************************************
76//  LIVE DEVICE
77//**************************************************************************
78
79// device type definition
80const device_type UV201 = &device_creator<uv201_device>;
81
82
83//-------------------------------------------------
84//  uv201_device - constructor
85//-------------------------------------------------
86
87uv201_device::uv201_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
88    : device_t(mconfig, UV201, "UV201", tag, owner, clock)
89{
90}
91
92
93//-------------------------------------------------
94//  device_config_complete - perform any
95//  operations now that the configuration is
96//  complete
97//-------------------------------------------------
98
99void uv201_device::device_config_complete()
100{
101   // inherit a copy of the static data
102   const uv201_interface *intf = reinterpret_cast<const uv201_interface *>(static_config());
103   if (intf != NULL)
104      *static_cast<uv201_interface *>(this) = *intf;
105
106   // or initialize to defaults if none provided
107   else
108   {
109      memset(&m_out_ext_int_cb, 0, sizeof(m_out_ext_int_cb));
110      memset(&m_out_hblank_cb, 0, sizeof(m_out_hblank_cb));
111      memset(&m_in_db_cb, 0, sizeof(m_in_db_cb));
112   }
113}
114
115
116//-------------------------------------------------
117//  device_start - device-specific startup
118//-------------------------------------------------
119
120void uv201_device::device_start()
121{
122   // resolve callbacks
123   m_out_ext_int_func.resolve(m_out_ext_int_cb, *this);
124   m_out_hblank_func.resolve(m_out_hblank_cb, *this);
125   m_in_db_func.resolve(m_in_db_cb, *this);
126
127   // allocate timers
128   m_timer_y_odd = timer_alloc(TIMER_Y_ODD);
129   m_timer_y_even = timer_alloc(TIMER_Y_EVEN);
130   m_timer_hblank_on = timer_alloc(TIMER_HBLANK_ON);
131   m_timer_hblank_off = timer_alloc(TIMER_HBLANK_OFF);
132
133   // find devices
134   m_screen = machine().device<screen_device>(m_screen_tag);
135
136   initialize_palette();
137
138   // state saving
139   save_item(NAME(m_ram));
140   save_item(NAME(m_y_int));
141   save_item(NAME(m_fmod));
142   save_item(NAME(m_bg));
143   save_item(NAME(m_cmd));
144   save_item(NAME(m_freeze_x));
145   save_item(NAME(m_freeze_y));
146   save_item(NAME(m_field));
147}
148
149
150//-------------------------------------------------
151//  device_reset - device-specific reset
152//-------------------------------------------------
153
154void uv201_device::device_reset()
155{
156   m_out_ext_int_func(CLEAR_LINE);
157}
158
159
160//-------------------------------------------------
161//  device_timer - handle timer events
162//-------------------------------------------------
163
164void uv201_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
165{
166   if ((m_cmd & COMMAND_INT) && !(m_cmd & COMMAND_FRZ))
167   {
168      int scanline = get_field_vpos();
169
170      if (LOG) logerror("Y-Interrupt at scanline %u\n", scanline);
171
172      m_freeze_y = scanline;
173
174      m_out_ext_int_func(ASSERT_LINE);
175      m_out_ext_int_func(CLEAR_LINE);
176   }
177}
178
179
180//-------------------------------------------------
181//  initialize_palette -
182//-------------------------------------------------
183
184void uv201_device::initialize_palette()
185{
186   static const UINT8 INTENSITY[] = { 0x90, 0xb0, 0xd0, 0xff };
187
188   for (int i = 0; i < 4; i++)
189   {
190      int offset = i * 8;
191      UINT8 value = INTENSITY[i];
192
193      palette_set_color_rgb(machine(), offset + 0, 0,      0,      0);      // black
194      palette_set_color_rgb(machine(), offset + 1, value,   0,      0);      // red
195      palette_set_color_rgb(machine(), offset + 2, 0,      value,   0);      // green
196      palette_set_color_rgb(machine(), offset + 3, value,   value,   0);      // red-green
197      palette_set_color_rgb(machine(), offset + 4, 0,      0,      value); // blue
198      palette_set_color_rgb(machine(), offset + 5, value,   0,      value); // red-blue
199      palette_set_color_rgb(machine(), offset + 6, 0,      value,   value); // green-blue
200      palette_set_color_rgb(machine(), offset + 7, value,   value,   value); // white
201   }
202}
203
204
205//-------------------------------------------------
206//  get_field_vpos - get scanline within field
207//-------------------------------------------------
208
209int uv201_device::get_field_vpos()
210{
211   int vpos = m_screen->vpos();
212
213   if (vpos >= 262)
214   {
215      // even field
216      vpos -= 262;
217   }
218
219   return vpos;
220}
221
222
223//-------------------------------------------------
224//  get_field - get video field
225//-------------------------------------------------
226
227int uv201_device::get_field()
228{
229   return m_screen->vpos() < 262;
230}
231
232
233//-------------------------------------------------
234//  set_y_interrupt - set Y interrupt timer
235//-------------------------------------------------
236
237void uv201_device::set_y_interrupt()
238{
239   int scanline = ((m_cmd & COMMAND_YINT_H_O) << 1) | m_y_int;
240
241   m_timer_y_odd->adjust(m_screen->time_until_pos(scanline), 0, m_screen->frame_period());
242   m_timer_y_even->adjust(m_screen->time_until_pos(scanline + 262), 0, m_screen->frame_period());
243}
244
245
246//-------------------------------------------------
247//  do_partial_update - update screen
248//-------------------------------------------------
249
250void uv201_device::do_partial_update()
251{
252   int vpos = m_screen->vpos();
253
254   if (LOG) logerror("Partial screen update at scanline %u\n", vpos);
255
256   m_screen->update_partial(vpos);
257}
258
259
260//-------------------------------------------------
261//  read -
262//-------------------------------------------------
263
264READ8_MEMBER( uv201_device::read )
265{
266   UINT8 data = 0xff;
267
268   switch (offset)
269   {
270   case REGISTER_X_FREEZE:
271      data = m_freeze_x;
272
273      if (LOG) logerror("X-Freeze %02x\n", data);
274      break;
275
276   case REGISTER_Y_FREEZE_LOW:
277      data = m_freeze_y & 0xff;
278
279      if (LOG) logerror("Y-Freeze Low %02x\n", data);
280      break;
281
282   case REGISTER_Y_FREEZE_HIGH:
283      /*
284
285            bit     signal      description
286
287            0       Y-C8        current Y counter high order (MSB) bit
288            1       Y-F8        Y freeze high order (MSB) bit
289            2
290            3
291            4
292            5
293            6
294            7       O/_E        odd/even field
295
296        */
297
298      data = (get_field() << 7) | BIT(m_freeze_y, 8) << 1 | BIT(get_field_vpos(), 8);
299
300      if (LOG) logerror("Y-Freeze High %02x\n", data);
301      break;
302
303   case REGISTER_CURRENT_Y_LOW:
304      data = get_field_vpos() & 0xff;
305
306      if (LOG) logerror("Current-Y Low %02x\n", data);
307      break;
308
309   default:
310      if (offset < 0x90)
311         data = m_ram[offset];
312      else
313         if (LOG) logerror("Unknown VLSI read from %02x!\n", offset);
314   }
315
316   return data;
317}
318
319
320//-------------------------------------------------
321//  write -
322//-------------------------------------------------
323
324WRITE8_MEMBER( uv201_device::write )
325{
326   switch (offset)
327   {
328   case REGISTER_Y_INTERRUPT:
329      if (LOG) logerror("Y-Interrupt %02x\n", data);
330
331      if (m_y_int != data)
332      {
333         m_y_int = data;
334         set_y_interrupt();
335      }
336      break;
337
338   case REGISTER_FINAL_MODIFIER:
339      /*
340
341            bit     signal      description
342
343            0       RED         red
344            1       GREEN       green
345            2       BLUE        blue
346            3       INT 0       intensity 0
347            4       INT 1       intensity 1
348            5       not used
349            6       not used
350            7       not used
351
352        */
353
354      if (LOG) logerror("Final Modifier %02x\n", data);
355
356      do_partial_update();
357      m_fmod = data & 0x1f;
358      break;
359
360   case REGISTER_BACKGROUND:
361      /*
362
363            bit     signal      description
364
365            0       RED         red
366            1       GREEN       green
367            2       BLUE        blue
368            3       INT 0       intensity 0
369            4       INT 1       intensity 1
370            5       not used
371            6       not used
372            7       not used
373
374        */
375
376      if (LOG) logerror("Background %02x\n", data);
377
378      do_partial_update();
379      m_bg = data & 0x1f;
380      break;
381
382   case REGISTER_COMMAND:
383      /*
384
385            bit     signal      description
386
387            0       X-ZM        X zoom
388            1       FRZ         freeze
389            2       ENB         video enable
390            3       INT         interrupt enable
391            4       KBD         general purpose output
392            5       Y-ZM        Y zoom
393            6       A/_B        list selection
394            7       YINT H.O.   Y COMMAND_INT register high order bit
395
396        */
397
398      if (LOG) logerror("Command %02x\n", data);
399
400      if (IS_CHANGED(COMMAND_YINT_H_O))
401      {
402         set_y_interrupt();
403      }
404
405      if (IS_CHANGED(COMMAND_A_B) || IS_CHANGED(COMMAND_Y_ZM) || IS_CHANGED(COMMAND_X_ZM))
406      {
407         do_partial_update();
408      }
409
410      m_cmd = data;
411      break;
412
413   default:
414      if (offset < 0x90)
415         m_ram[offset] = data;
416      else
417         logerror("Unknown VLSI write %02x to %02x!\n", data, offset);
418   }
419}
420
421
422//-------------------------------------------------
423//  ext_int_w - external interrupt write
424//-------------------------------------------------
425
426WRITE_LINE_MEMBER( uv201_device::ext_int_w )
427{
428   if (!state && (m_cmd & COMMAND_FRZ))
429   {
430      m_freeze_y = get_field_vpos();
431      m_freeze_x = m_screen->hpos();
432   }
433}
434
435
436//-------------------------------------------------
437//  kbd_r - keyboard select read
438//-------------------------------------------------
439
440READ_LINE_MEMBER( uv201_device::kbd_r )
441{
442   return (m_cmd & COMMAND_KBD) ? 1 : 0;
443}
444
445
446//-------------------------------------------------
447//  screen_update -
448//-------------------------------------------------
449
450UINT32 uv201_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
451{
452   if (!(m_cmd & COMMAND_ENB))
453   {
454      bitmap.fill(get_black_pen(machine()), cliprect);
455      return 0;
456   }
457
458   bitmap.fill(m_bg, cliprect);
459
460   for (int i = 0; i < 16; i++)
461   {
462      UINT8 xy_hi = (m_cmd & COMMAND_A_B) ? RAM(RAM_XY_HI_A) : RAM(RAM_XY_HI_B);
463      UINT8 y_lo = (m_cmd & COMMAND_A_B) ? RAM(RAM_Y_LO_A) : RAM(RAM_Y_LO_B);
464      UINT16 y = (BIT(xy_hi, 7) << 8) | y_lo;
465      int xord = xy_hi & 0x0f;
466
467      UINT8 rp_hi_color = RAM_XORD(RAM_RP_HI_COLOR);
468      UINT8 rp_lo = RAM_XORD(RAM_RP_LO);
469      UINT16 rp = ((rp_hi_color << 8) | rp_lo) & 0x1fff;
470
471      UINT8 dx_int_xcopy = RAM_XORD(RAM_DX_INT_XCOPY);
472      int color = ((dx_int_xcopy & 0x60) >> 2) | (BIT(rp_hi_color, 5) << 2) | (BIT(rp_hi_color, 6) << 1) | (BIT(rp_hi_color, 7));
473      UINT8 dx = dx_int_xcopy & 0x1f;
474      UINT8 dy = RAM_XORD(RAM_DY);
475      int xcopy = BIT(dx_int_xcopy, 7);
476      UINT8 x = RAM_XORD(RAM_X);
477
478      if (LOG) logerror("Object %u xord %u y %u x %u dy %u dx %u xcopy %u color %u rp %04x\n", i, xord, y, x, dy, dx, xcopy, color, rp);
479
480      if (rp == 0) continue;
481      if (y > 262) continue;
482
483      for (int sy = 0; sy < dy; sy++)
484      {
485         for (int sx = 0; sx < dx; sx++)
486         {
487            UINT8 data = m_in_db_func(rp);
488
489            for (int bit = 0; bit < 8; bit++)
490            {
491               int pixel = ((BIT(data, 7) ? color : m_bg) ^ m_fmod) & 0x1f;
492
493               if (m_cmd & COMMAND_Y_ZM)
494               {
495                  int scanline = y + (sy * 2);
496
497                  if (m_cmd & COMMAND_X_ZM)
498                  {
499                     int dot = (x * 2) + (sx * 16) + (bit * 2);
500
501                     DRAW_PIXEL(scanline, dot);
502                     DRAW_PIXEL(scanline, dot + 1);
503                     DRAW_PIXEL(scanline + 1, dot);
504                     DRAW_PIXEL(scanline + 1, dot + 1);
505                  }
506                  else
507                  {
508                     int dot = x + (sx * 8) + bit;
509
510                     DRAW_PIXEL(scanline, dot);
511                     DRAW_PIXEL(scanline + 1, dot);
512                  }
513               }
514               else
515               {
516                  int scanline = y + sy;
517
518                  if (m_cmd & COMMAND_X_ZM)
519                  {
520                     int dot = (x * 2) + (sx * 16) + (bit * 2);
521
522                     DRAW_PIXEL(scanline, dot);
523                     DRAW_PIXEL(scanline, dot + 1);
524                  }
525                  else
526                  {
527                     int dot = x + (sx * 8) + bit;
528
529                     DRAW_PIXEL(scanline, dot);
530                  }
531               }
532
533               data <<= 1;
534            }
535
536            if (!xcopy) rp++;
537         }
538
539         if (xcopy) rp++;
540      }
541   }
542
543   return 0;
544}
1/**********************************************************************
2 
3    VideoBrain UV201/UV202 video chip emulation
4 
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7 
8**********************************************************************/
9 
10#include "uv201.h"
11 
12 
13 
14//**************************************************************************
15//  MACROS / CONSTANTS
16//**************************************************************************
17 
18#define LOG       1
19 
20 
21// write-only registers
22#define REGISTER_COMMAND         0xf7
23#define REGISTER_BACKGROUND         0xf5
24#define REGISTER_FINAL_MODIFIER      0xf2
25#define REGISTER_Y_INTERRUPT      0xf0
26 
27 
28// read-only registers
29#define REGISTER_X_FREEZE         0xf8
30#define REGISTER_Y_FREEZE_LOW      0xf9
31#define REGISTER_Y_FREEZE_HIGH      0xfa
32#define REGISTER_CURRENT_Y_LOW      0xfb
33 
34 
35// read/write registers - RAM memory
36#define RAM_RP_LO               0x00   // cartridge pointer low order
37#define RAM_RP_HI_COLOR            0x10   // cartridge pointer high order and color
38#define RAM_DX_INT_XCOPY         0x20   // dX, intensity, X-copy
39#define RAM_DY                  0x30   // dY
40#define RAM_X                  0x40   // X value
41#define RAM_Y_LO_A               0x50   // Y value low order list A
42#define RAM_Y_LO_B               0x60   // Y value low order list B
43#define RAM_XY_HI_A               0x70   // Y value high order and X order list A
44#define RAM_XY_HI_B               0x80   // Y value high order and X order list B
45 
46 
47// command register bits
48#define COMMAND_YINT_H_O         0x80
49#define COMMAND_A_B               0x40
50#define COMMAND_Y_ZM            0x20
51#define COMMAND_KBD               0x10
52#define COMMAND_INT               0x08
53#define COMMAND_ENB               0x04
54#define COMMAND_FRZ               0x02
55#define COMMAND_X_ZM            0x01
56 
57 
58#define IS_CHANGED(_bit) \
59   ((m_cmd & _bit) != (data & _bit))
60 
61#define RAM(_offset) \
62   m_ram[_offset + i]
63 
64#define RAM_XORD(_offset) \
65   m_ram[_offset + xord]
66 
67#define IS_VISIBLE(_y) \
68   ((_y >= cliprect.min_y) && (_y <= cliprect.max_y))
69 
70#define DRAW_PIXEL(_scanline, _dot) \
71   if (IS_VISIBLE(_scanline)) bitmap.pix16((_scanline), _dot) = pixel;
72 
73 
74 
75//**************************************************************************
76//  LIVE DEVICE
77//**************************************************************************
78 
79// device type definition
80const device_type UV201 = &device_creator<uv201_device>;
81 
82 
83//-------------------------------------------------
84//  uv201_device - constructor
85//-------------------------------------------------
86 
87uv201_device::uv201_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
88    : device_t(mconfig, UV201, "UV201", tag, owner, clock)
89{
90}
91 
92 
93//-------------------------------------------------
94//  device_config_complete - perform any
95//  operations now that the configuration is
96//  complete
97//-------------------------------------------------
98 
99void uv201_device::device_config_complete()
100{
101   // inherit a copy of the static data
102   const uv201_interface *intf = reinterpret_cast<const uv201_interface *>(static_config());
103   if (intf != NULL)
104      *static_cast<uv201_interface *>(this) = *intf;
105 
106   // or initialize to defaults if none provided
107   else
108   {
109      memset(&m_out_ext_int_cb, 0, sizeof(m_out_ext_int_cb));
110      memset(&m_out_hblank_cb, 0, sizeof(m_out_hblank_cb));
111      memset(&m_in_db_cb, 0, sizeof(m_in_db_cb));
112   }
113}
114 
115 
116//-------------------------------------------------
117//  device_start - device-specific startup
118//-------------------------------------------------
119 
120void uv201_device::device_start()
121{
122   // resolve callbacks
123   m_out_ext_int_func.resolve(m_out_ext_int_cb, *this);
124   m_out_hblank_func.resolve(m_out_hblank_cb, *this);
125   m_in_db_func.resolve(m_in_db_cb, *this);
126 
127   // allocate timers
128   m_timer_y_odd = timer_alloc(TIMER_Y_ODD);
129   m_timer_y_even = timer_alloc(TIMER_Y_EVEN);
130   m_timer_hblank_on = timer_alloc(TIMER_HBLANK_ON);
131   m_timer_hblank_off = timer_alloc(TIMER_HBLANK_OFF);
132 
133   // find devices
134   m_screen = machine().device<screen_device>(m_screen_tag);
135 
136   initialize_palette();
137 
138   // state saving
139   save_item(NAME(m_ram));
140   save_item(NAME(m_y_int));
141   save_item(NAME(m_fmod));
142   save_item(NAME(m_bg));
143   save_item(NAME(m_cmd));
144   save_item(NAME(m_freeze_x));
145   save_item(NAME(m_freeze_y));
146   save_item(NAME(m_field));
147}
148 
149 
150//-------------------------------------------------
151//  device_reset - device-specific reset
152//-------------------------------------------------
153 
154void uv201_device::device_reset()
155{
156   m_out_ext_int_func(CLEAR_LINE);
157}
158 
159 
160//-------------------------------------------------
161//  device_timer - handle timer events
162//-------------------------------------------------
163 
164void uv201_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
165{
166   if ((m_cmd & COMMAND_INT) && !(m_cmd & COMMAND_FRZ))
167   {
168      int scanline = get_field_vpos();
169 
170      if (LOG) logerror("Y-Interrupt at scanline %u\n", scanline);
171 
172      m_freeze_y = scanline;
173 
174      m_out_ext_int_func(ASSERT_LINE);
175      m_out_ext_int_func(CLEAR_LINE);
176   }
177}
178 
179 
180//-------------------------------------------------
181//  initialize_palette -
182//-------------------------------------------------
183 
184void uv201_device::initialize_palette()
185{
186   static const UINT8 INTENSITY[] = { 0x90, 0xb0, 0xd0, 0xff };
187 
188   for (int i = 0; i < 4; i++)
189   {
190      int offset = i * 8;
191      UINT8 value = INTENSITY[i];
192 
193      palette_set_color_rgb(machine(), offset + 0, 0,      0,      0);      // black
194      palette_set_color_rgb(machine(), offset + 1, value,   0,      0);      // red
195      palette_set_color_rgb(machine(), offset + 2, 0,      value,   0);      // green
196      palette_set_color_rgb(machine(), offset + 3, value,   value,   0);      // red-green
197      palette_set_color_rgb(machine(), offset + 4, 0,      0,      value); // blue
198      palette_set_color_rgb(machine(), offset + 5, value,   0,      value); // red-blue
199      palette_set_color_rgb(machine(), offset + 6, 0,      value,   value); // green-blue
200      palette_set_color_rgb(machine(), offset + 7, value,   value,   value); // white
201   }
202}
203 
204 
205//-------------------------------------------------
206//  get_field_vpos - get scanline within field
207//-------------------------------------------------
208 
209int uv201_device::get_field_vpos()
210{
211   int vpos = m_screen->vpos();
212 
213   if (vpos >= 262)
214   {
215      // even field
216      vpos -= 262;
217   }
218 
219   return vpos;
220}
221 
222 
223//-------------------------------------------------
224//  get_field - get video field
225//-------------------------------------------------
226 
227int uv201_device::get_field()
228{
229   return m_screen->vpos() < 262;
230}
231 
232 
233//-------------------------------------------------
234//  set_y_interrupt - set Y interrupt timer
235//-------------------------------------------------
236 
237void uv201_device::set_y_interrupt()
238{
239   int scanline = ((m_cmd & COMMAND_YINT_H_O) << 1) | m_y_int;
240 
241   m_timer_y_odd->adjust(m_screen->time_until_pos(scanline), 0, m_screen->frame_period());
242   m_timer_y_even->adjust(m_screen->time_until_pos(scanline + 262), 0, m_screen->frame_period());
243}
244 
245 
246//-------------------------------------------------
247//  do_partial_update - update screen
248//-------------------------------------------------
249 
250void uv201_device::do_partial_update()
251{
252   int vpos = m_screen->vpos();
253 
254   if (LOG) logerror("Partial screen update at scanline %u\n", vpos);
255 
256   m_screen->update_partial(vpos);
257}
258 
259 
260//-------------------------------------------------
261//  read -
262//-------------------------------------------------
263 
264READ8_MEMBER( uv201_device::read )
265{
266   UINT8 data = 0xff;
267 
268   switch (offset)
269   {
270   case REGISTER_X_FREEZE:
271      data = m_freeze_x;
272 
273      if (LOG) logerror("X-Freeze %02x\n", data);
274      break;
275 
276   case REGISTER_Y_FREEZE_LOW:
277      data = m_freeze_y & 0xff;
278 
279      if (LOG) logerror("Y-Freeze Low %02x\n", data);
280      break;
281 
282   case REGISTER_Y_FREEZE_HIGH:
283      /*
284 
285            bit     signal      description
286 
287            0       Y-C8        current Y counter high order (MSB) bit
288            1       Y-F8        Y freeze high order (MSB) bit
289            2
290            3
291            4
292            5
293            6
294            7       O/_E        odd/even field
295 
296        */
297 
298      data = (get_field() << 7) | BIT(m_freeze_y, 8) << 1 | BIT(get_field_vpos(), 8);
299 
300      if (LOG) logerror("Y-Freeze High %02x\n", data);
301      break;
302 
303   case REGISTER_CURRENT_Y_LOW:
304      data = get_field_vpos() & 0xff;
305 
306      if (LOG) logerror("Current-Y Low %02x\n", data);
307      break;
308 
309   default:
310      if (offset < 0x90)
311         data = m_ram[offset];
312      else
313         if (LOG) logerror("Unknown VLSI read from %02x!\n", offset);
314   }
315 
316   return data;
317}
318 
319 
320//-------------------------------------------------
321//  write -
322//-------------------------------------------------
323 
324WRITE8_MEMBER( uv201_device::write )
325{
326   switch (offset)
327   {
328   case REGISTER_Y_INTERRUPT:
329      if (LOG) logerror("Y-Interrupt %02x\n", data);
330 
331      if (m_y_int != data)
332      {
333         m_y_int = data;
334         set_y_interrupt();
335      }
336      break;
337 
338   case REGISTER_FINAL_MODIFIER:
339      /*
340 
341            bit     signal      description
342 
343            0       RED         red
344            1       GREEN       green
345            2       BLUE        blue
346            3       INT 0       intensity 0
347            4       INT 1       intensity 1
348            5       not used
349            6       not used
350            7       not used
351 
352        */
353 
354      if (LOG) logerror("Final Modifier %02x\n", data);
355 
356      do_partial_update();
357      m_fmod = data & 0x1f;
358      break;
359 
360   case REGISTER_BACKGROUND:
361      /*
362 
363            bit     signal      description
364 
365            0       RED         red
366            1       GREEN       green
367            2       BLUE        blue
368            3       INT 0       intensity 0
369            4       INT 1       intensity 1
370            5       not used
371            6       not used
372            7       not used
373 
374        */
375 
376      if (LOG) logerror("Background %02x\n", data);
377 
378      do_partial_update();
379      m_bg = data & 0x1f;
380      break;
381 
382   case REGISTER_COMMAND:
383      /*
384 
385            bit     signal      description
386 
387            0       X-ZM        X zoom
388            1       FRZ         freeze
389            2       ENB         video enable
390            3       INT         interrupt enable
391            4       KBD         general purpose output
392            5       Y-ZM        Y zoom
393            6       A/_B        list selection
394            7       YINT H.O.   Y COMMAND_INT register high order bit
395 
396        */
397 
398      if (LOG) logerror("Command %02x\n", data);
399 
400      if (IS_CHANGED(COMMAND_YINT_H_O))
401      {
402         set_y_interrupt();
403      }
404 
405      if (IS_CHANGED(COMMAND_A_B) || IS_CHANGED(COMMAND_Y_ZM) || IS_CHANGED(COMMAND_X_ZM))
406      {
407         do_partial_update();
408      }
409 
410      m_cmd = data;
411      break;
412 
413   default:
414      if (offset < 0x90)
415         m_ram[offset] = data;
416      else
417         logerror("Unknown VLSI write %02x to %02x!\n", data, offset);
418   }
419}
420 
421 
422//-------------------------------------------------
423//  ext_int_w - external interrupt write
424//-------------------------------------------------
425 
426WRITE_LINE_MEMBER( uv201_device::ext_int_w )
427{
428   if (!state && (m_cmd & COMMAND_FRZ))
429   {
430      m_freeze_y = get_field_vpos();
431      m_freeze_x = m_screen->hpos();
432   }
433}
434 
435 
436//-------------------------------------------------
437//  kbd_r - keyboard select read
438//-------------------------------------------------
439 
440READ_LINE_MEMBER( uv201_device::kbd_r )
441{
442   return (m_cmd & COMMAND_KBD) ? 1 : 0;
443}
444 
445 
446//-------------------------------------------------
447//  screen_update -
448//-------------------------------------------------
449 
450UINT32 uv201_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
451{
452   if (!(m_cmd & COMMAND_ENB))
453   {
454      bitmap.fill(get_black_pen(machine()), cliprect);
455      return 0;
456   }
457 
458   bitmap.fill(m_bg, cliprect);
459 
460   for (int i = 0; i < 16; i++)
461   {
462      UINT8 xy_hi = (m_cmd & COMMAND_A_B) ? RAM(RAM_XY_HI_A) : RAM(RAM_XY_HI_B);
463      UINT8 y_lo = (m_cmd & COMMAND_A_B) ? RAM(RAM_Y_LO_A) : RAM(RAM_Y_LO_B);
464      UINT16 y = (BIT(xy_hi, 7) << 8) | y_lo;
465      int xord = xy_hi & 0x0f;
466 
467      UINT8 rp_hi_color = RAM_XORD(RAM_RP_HI_COLOR);
468      UINT8 rp_lo = RAM_XORD(RAM_RP_LO);
469      UINT16 rp = ((rp_hi_color << 8) | rp_lo) & 0x1fff;
470 
471      UINT8 dx_int_xcopy = RAM_XORD(RAM_DX_INT_XCOPY);
472      int color = ((dx_int_xcopy & 0x60) >> 2) | (BIT(rp_hi_color, 5) << 2) | (BIT(rp_hi_color, 6) << 1) | (BIT(rp_hi_color, 7));
473      UINT8 dx = dx_int_xcopy & 0x1f;
474      UINT8 dy = RAM_XORD(RAM_DY);
475      int xcopy = BIT(dx_int_xcopy, 7);
476      UINT8 x = RAM_XORD(RAM_X);
477 
478      if (LOG) logerror("Object %u xord %u y %u x %u dy %u dx %u xcopy %u color %u rp %04x\n", i, xord, y, x, dy, dx, xcopy, color, rp);
479 
480      if (rp == 0) continue;
481      if (y > 262) continue;
482 
483      for (int sy = 0; sy < dy; sy++)
484      {
485         for (int sx = 0; sx < dx; sx++)
486         {
487            UINT8 data = m_in_db_func(rp);
488 
489            for (int bit = 0; bit < 8; bit++)
490            {
491               int pixel = ((BIT(data, 7) ? color : m_bg) ^ m_fmod) & 0x1f;
492 
493               if (m_cmd & COMMAND_Y_ZM)
494               {
495                  int scanline = y + (sy * 2);
496 
497                  if (m_cmd & COMMAND_X_ZM)
498                  {
499                     int dot = (x * 2) + (sx * 16) + (bit * 2);
500 
501                     DRAW_PIXEL(scanline, dot);
502                     DRAW_PIXEL(scanline, dot + 1);
503                     DRAW_PIXEL(scanline + 1, dot);
504                     DRAW_PIXEL(scanline + 1, dot + 1);
505                  }
506                  else
507                  {
508                     int dot = x + (sx * 8) + bit;
509 
510                     DRAW_PIXEL(scanline, dot);
511                     DRAW_PIXEL(scanline + 1, dot);
512                  }
513               }
514               else
515               {
516                  int scanline = y + sy;
517 
518                  if (m_cmd & COMMAND_X_ZM)
519                  {
520                     int dot = (x * 2) + (sx * 16) + (bit * 2);
521 
522                     DRAW_PIXEL(scanline, dot);
523                     DRAW_PIXEL(scanline, dot + 1);
524                  }
525                  else
526                  {
527                     int dot = x + (sx * 8) + bit;
528 
529                     DRAW_PIXEL(scanline, dot);
530                  }
531               }
532 
533               data <<= 1;
534            }
535 
536            if (!xcopy) rp++;
537         }
538 
539         if (xcopy) rp++;
540      }
541   }
542 
543   return 0;
544}
src/mess/video/uv201.h
r15253r15254
1/**********************************************************************
2
3    VideoBrain UV201/UV202 video chip emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************
9 
10**********************************************************************/
11
12#pragma once
13
14#ifndef __UV201__
15#define __UV201__
16
17#include "emu.h"
18
19
20
21//**************************************************************************
22//  INTERFACE CONFIGURATION MACROS
23//**************************************************************************
24
25#define MCFG_UV201_ADD(_tag, _screen_tag, _clock, _config) \
26   MCFG_DEVICE_ADD(_tag, UV201, _clock) \
27   MCFG_DEVICE_CONFIG(_config) \
28    MCFG_SCREEN_ADD(_screen_tag, RASTER) \
29   MCFG_SCREEN_UPDATE_DEVICE(_tag, uv201_device, screen_update) \
30   MCFG_SCREEN_RAW_PARAMS(_clock, 455, 0, 190, 525, 0, 243) \
31    MCFG_PALETTE_LENGTH(32)
32
33
34#define UV201_INTERFACE(name) \
35   const uv201_interface (name) =
36
37
38
39//**************************************************************************
40//  TYPE DEFINITIONS
41//**************************************************************************
42
43// ======================> uv201_interface
44
45struct uv201_interface
46{
47   const char *m_screen_tag;
48   
49   devcb_write_line      m_out_ext_int_cb;
50   devcb_write_line      m_out_hblank_cb;
51   devcb_read8            m_in_db_cb;
52};
53
54
55// ======================> uv201_device
56
57class uv201_device :   public device_t,
58                        public uv201_interface
59{
60public:
61    // construction/destruction
62    uv201_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
63
64    DECLARE_READ8_MEMBER( read );
65    DECLARE_WRITE8_MEMBER( write );
66
67    DECLARE_WRITE_LINE_MEMBER( ext_int_w );
68    DECLARE_READ_LINE_MEMBER( kbd_r );
69
70   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
71
72protected:
73    // device-level overrides
74   virtual void device_config_complete();
75    virtual void device_start();
76    virtual void device_reset();
77   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
78
79private:
80   enum
81   {
82      TIMER_Y_ODD,
83      TIMER_Y_EVEN,
84      TIMER_HBLANK_ON,
85      TIMER_HBLANK_OFF
86   };
87
88   void initialize_palette();
89   int get_field_vpos();
90   int get_field();
91   void set_y_interrupt();
92   void do_partial_update();
93
94   devcb_resolved_write_line   m_out_ext_int_func;
95   devcb_resolved_write_line   m_out_hblank_func;
96   devcb_resolved_read8      m_in_db_func;
97
98   screen_device *m_screen;
99
100   UINT8 m_ram[0x90];
101   UINT8 m_y_int;
102   UINT8 m_fmod;
103   UINT8 m_bg;
104   UINT8 m_cmd;
105   UINT8 m_freeze_x;
106   UINT16 m_freeze_y;
107   int m_field;
108
109   // timers
110   emu_timer *m_timer_y_odd;
111   emu_timer *m_timer_y_even;
112   emu_timer *m_timer_hblank_on;
113   emu_timer *m_timer_hblank_off;
114};
115
116
117// device type definition
118extern const device_type UV201;
119
120
121
122#endif
1/**********************************************************************
2 
3    VideoBrain UV201/UV202 video chip emulation
4 
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7 
8**********************************************************************
9 
10**********************************************************************/
11 
12#pragma once
13 
14#ifndef __UV201__
15#define __UV201__
16 
17#include "emu.h"
18 
19 
20 
21//**************************************************************************
22//  INTERFACE CONFIGURATION MACROS
23//**************************************************************************
24 
25#define MCFG_UV201_ADD(_tag, _screen_tag, _clock, _config) \
26   MCFG_DEVICE_ADD(_tag, UV201, _clock) \
27   MCFG_DEVICE_CONFIG(_config) \
28    MCFG_SCREEN_ADD(_screen_tag, RASTER) \
29   MCFG_SCREEN_UPDATE_DEVICE(_tag, uv201_device, screen_update) \
30   MCFG_SCREEN_RAW_PARAMS(_clock, 455, 0, 190, 525, 0, 243) \
31    MCFG_PALETTE_LENGTH(32)
32 
33 
34#define UV201_INTERFACE(name) \
35   const uv201_interface (name) =
36 
37 
38 
39//**************************************************************************
40//  TYPE DEFINITIONS
41//**************************************************************************
42 
43// ======================> uv201_interface
44 
45struct uv201_interface
46{
47   const char *m_screen_tag;
48 
49   devcb_write_line      m_out_ext_int_cb;
50   devcb_write_line      m_out_hblank_cb;
51   devcb_read8            m_in_db_cb;
52};
53 
54 
55// ======================> uv201_device
56 
57class uv201_device :   public device_t,
58                        public uv201_interface
59{
60public:
61    // construction/destruction
62    uv201_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
63 
64    DECLARE_READ8_MEMBER( read );
65    DECLARE_WRITE8_MEMBER( write );
66 
67    DECLARE_WRITE_LINE_MEMBER( ext_int_w );
68    DECLARE_READ_LINE_MEMBER( kbd_r );
69 
70   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
71 
72protected:
73    // device-level overrides
74   virtual void device_config_complete();
75    virtual void device_start();
76    virtual void device_reset();
77   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
78 
79private:
80   enum
81   {
82      TIMER_Y_ODD,
83      TIMER_Y_EVEN,
84      TIMER_HBLANK_ON,
85      TIMER_HBLANK_OFF
86   };
87 
88   void initialize_palette();
89   int get_field_vpos();
90   int get_field();
91   void set_y_interrupt();
92   void do_partial_update();
93 
94   devcb_resolved_write_line   m_out_ext_int_func;
95   devcb_resolved_write_line   m_out_hblank_func;
96   devcb_resolved_read8      m_in_db_func;
97 
98   screen_device *m_screen;
99 
100   UINT8 m_ram[0x90];
101   UINT8 m_y_int;
102   UINT8 m_fmod;
103   UINT8 m_bg;
104   UINT8 m_cmd;
105   UINT8 m_freeze_x;
106   UINT16 m_freeze_y;
107   int m_field;
108 
109   // timers
110   emu_timer *m_timer_y_odd;
111   emu_timer *m_timer_y_even;
112   emu_timer *m_timer_hblank_on;
113   emu_timer *m_timer_hblank_off;
114};
115 
116 
117// device type definition
118extern const device_type UV201;
119 
120 
121 
122#endif
src/mess/mess.lst
r15253r15254
176176//sq80        // 1988 SQ-80 Digital Wave Synthesizer
177177vfx         // 1989 VFX
178178eps16       // 1990 EPS-16 Plus
179sq1         // 1990 SQ-1
179sq1         // 1990 SQ-1
180180
181181// Fairchild
182182channelf  // Fairchild Channel F VES - 1976
src/mess/drivers/vic20.c
r15253r15254
433433        PA4     JOY 2
434434        PA5     LITE PEN
435435        PA6     CASS SWITCH
436        PA7     
436        PA7
437437
438438    */
439439
r15253r15254
468468
469469        bit     description
470470
471        PA0     
472        PA1     
473        PA2     
474        PA3     
475        PA4     
476        PA5     
477        PA6     
471        PA0
472        PA1
473        PA2
474        PA3
475        PA4
476        PA5
477        PA6
478478        PA7     SERIAL ATN OUT
479479
480480    */
src/mess/drivers/test_t400.c
r15253r15254
11/*
22
3   T400 uController test suite for COP410/420 series CPUs
3    T400 uController test suite for COP410/420 series CPUs
44
5   http://opencores.org/project,t400
5    http://opencores.org/project,t400
66
77*/
88
src/mess/drivers/m20.c
r15253r15254
212212   AM_RANGE(0x120, 0x127) AM_DEVREADWRITE8_LEGACY("pit8253", pit8253_r, pit8253_w, 0x00ff)
213213
214214   AM_RANGE(0x140, 0x143) AM_READWRITE(m20_i8259_r, m20_i8259_w)
215//   AM_RANGE(0x140, 0x143) AM_DEVREADWRITE8_LEGACY("i8259", pic8259_r, pic8259_w, 0xffff)
215//  AM_RANGE(0x140, 0x143) AM_DEVREADWRITE8_LEGACY("i8259", pic8259_r, pic8259_w, 0xffff)
216216
217217   // 0x21?? / 0x21? - fdc ... seems to control the screen colors???
218218ADDRESS_MAP_END
src/mess/drivers/vidbrain.c
r15253r15254
1616
1717    TODO:
1818
19   - video interrupts
20   - R-2R ladder DAC
21   - reset on cartridge unload
19    - video interrupts
20    - R-2R ladder DAC
21    - reset on cartridge unload
2222    - use machine/f3853.h
2323    - joystick scan timer 555
2424    - expander 1 (cassette, RS-232)
r15253r15254
122122        2
123123        3
124124        4       sound clock
125        5      accessory jack pin 5
126        6      accessory jack pin 1
125        5       accessory jack pin 5
126        6       accessory jack pin 1
127127        7       joystick enable
128128
129129    */
r15253r15254
423423      // C = 0.003uF
424424      // t = 1.1 * R * C
425425      double t = 1.1 * (RES_K(3.9) + RES_K(joydata)) * 3;
426     
426
427427      timer_set(attotime::from_nsec(t), TIMER_JOYSTICK);
428428   }
429429}
r15253r15254
494494{
495495   // register IRQ callback
496496   device_set_irq_callback(m_maincpu, vidbrain_int_ack);
497   
497
498498   // allocate timers
499499   m_timer_ne555 = timer_alloc(TIMER_JOYSTICK);
500500
r15253r15254
537537
538538   // video hardware
539539   MCFG_UV201_ADD(UV201_TAG, SCREEN_TAG, XTAL_14_31818MHz, uv_intf)
540   
540
541541   // sound hardware
542542   MCFG_SPEAKER_STANDARD_MONO("mono")
543543
src/mess/drivers/cxhumax.c
r15253r15254
11/***************************************************************************
2   HUMAX HDCI-2000 ( Conexant CX2417x )
3   
4   http://www.humaxdigital.com/global/products/product_stb_satellite_hdci2000.asp
5   
6   Running on Nucleus PLUS - ARM7TDMI ADS v. 1.14
7   some Conexant/Nucleus goodies may be found at http://code.google.com/p/cherices/
8   
9   runs up to frame 280 or so...
10   
2    HUMAX HDCI-2000 ( Conexant CX2417x )
3
4    http://www.humaxdigital.com/global/products/product_stb_satellite_hdci2000.asp
5
6    Running on Nucleus PLUS - ARM7TDMI ADS v. 1.14
7    some Conexant/Nucleus goodies may be found at http://code.google.com/p/cherices/
8
9    runs up to frame 280 or so...
10
1111****************************************************************************/
1212
1313#include "emu.h"
r15253r15254
3232{
3333   UINT32 res = m_gxa_cmd_regs[offset];
3434   verboselog( machine(), 9, "(GXA) %08X -> %08X\n", 0xE0600000 + (offset << 2), res);
35/*   UINT8 gxa_command_number = (offset >> 9) & 0x7F;
36   verboselog( machine(), 9, "      Command: %08X\n", gxa_command_number);
37   switch (gxa_command_number) {
38      case GXA_CMD_RW_REGISTER:
39         switch(offset) {
40            case GXA_CFG2_REG:
41               break;
42            default:
43               verboselog( machine(), 9, "      Unimplemented register - TODO?\n");
44               break;
45         }
46         break;
47      default:
48         // do we need it?
49         verboselog( machine(), 9, "      Unimplemented read command - TODO?\n");
50         break;
51   }*/
35/*  UINT8 gxa_command_number = (offset >> 9) & 0x7F;
36    verboselog( machine(), 9, "      Command: %08X\n", gxa_command_number);
37    switch (gxa_command_number) {
38        case GXA_CMD_RW_REGISTER:
39            switch(offset) {
40                case GXA_CFG2_REG:
41                    break;
42                default:
43                    verboselog( machine(), 9, "      Unimplemented register - TODO?\n");
44                    break;
45            }
46            break;
47        default:
48            // do we need it?
49            verboselog( machine(), 9, "      Unimplemented read command - TODO?\n");
50            break;
51    }*/
5252   return res;
5353}
5454
r15253r15254
8989         m_gxa_cmd_regs[GXA_CMD_REG] = (m_gxa_cmd_regs[GXA_CMD_REG] & 0x3ffff) | (data<<24) | ((data&0x10)?1<<23:0);
9090
9191         /* QMARK command has completed */
92         m_gxa_cmd_regs[GXA_CFG2_REG] |= (1<<IRQ_STAT_QMARK);           
92         m_gxa_cmd_regs[GXA_CFG2_REG] |= (1<<IRQ_STAT_QMARK);
9393
9494         // Interrupt
9595         if (m_gxa_cmd_regs[GXA_CFG2_REG] & (1<<IRQ_EN_QMARK)) {
r15253r15254
149149{
150150   UINT32 data = m_scratch_reg;
151151   verboselog( machine(), 9, "(SCRATCH) %08X -> %08X\n", 0xE0400024 + (offset << 2), data);
152   
152
153153   if((cpu_get_pc(m_maincpu)==0xF0003BB8) || (cpu_get_pc(m_maincpu)==0x01003724) || (cpu_get_pc(m_maincpu)==0x00005d8c)) { // HDCI-2000
154154      //we're in disabled debug_printf
155155      unsigned char* buf = (unsigned char *)alloca(200);
r15253r15254
157157      address_space *program = m_maincpu->memory().space(AS_PROGRAM);
158158
159159      memset(buf,0,200);
160     
160
161161      int i = 0;
162162      while ((temp=program->read_byte(cpu_get_reg(m_maincpu, ARM7_R0)+i))) {
163163         buf[i++]=temp;
r15253r15254
379379         case TIMER_TIMEBASE:
380380            COMBINE_DATA(&m_timer_regs.timer[index].timebase); break;
381381      }
382      /* A timer will hold an interrupt active until any one of that timer’s registers is written. */
382      /* A timer will hold an interrupt active until any one of that timer?s registers is written. */
383383      if(m_timer_regs.timer_irq & (1<<index)) {
384384         m_timer_regs.timer_irq &= ~(1<<index);
385385      }
r15253r15254
408408         if(!(m_uart2_regs[UART_FRMC_REG]&UART_FRMC_BDS_BIT)) {
409409            /* Sending byte... add logging */
410410            m_terminal->write(space, 0, data);
411           
411
412412            /* Transmitter Idle Interrupt Enable */
413413            if(m_uart2_regs[UART_IRQE_REG]&UART_IRQE_TIDE_BIT) {
414414               /* Signal pending INT */
415415               m_intctrl_regs[INTREG(INTGROUP1, INTIRQ)] |= INT_UART2_BIT;
416416               m_intctrl_regs[INTREG(INTGROUP1, INTSTATCLR)] |= INT_UART2_BIT;
417417               m_intctrl_regs[INTREG(INTGROUP1, INTSTATSET)] |= INT_UART2_BIT;
418               
418
419419               /* If INT is enabled at INT Ctrl raise it */
420420               if(m_intctrl_regs[INTREG(INTGROUP1, INTENABLE)]&INT_UART2_BIT) {
421421                  device_set_input_line(machine().device("maincpu"), ARM7_IRQ_LINE, ASSERT_LINE);
r15253r15254
494494         switch(offset & 7) {
495495            case INTSTATCLR:   // ITC_INTSTATCLR_REG Group 1
496496               /*
497                  Bits 15 (PWM), 14 (PIO103) of Group 1 are the logical OR of their lower level interrupt
498                  status bits down within the interrupting module and are not registered.
499                 
500                  The source registers must be cleared to clear these interrupt bits.
501               */
497                        Bits 15 (PWM), 14 (PIO103) of Group 1 are the logical OR of their lower level interrupt
498                        status bits down within the interrupting module and are not registered.
499
500                        The source registers must be cleared to clear these interrupt bits.
501                    */
502502               data &= ~(INT_PWM_BIT|INT_PIO103_BIT);
503               
503
504504               m_intctrl_regs[INTREG(INTGROUP1, INTSTATCLR)] &= ~data;
505505               m_intctrl_regs[INTREG(INTGROUP1, INTSTATSET)] &= ~data;
506506               m_intctrl_regs[INTREG(INTGROUP1, INTIRQ)] &= ~data;
r15253r15254
514514         switch(offset & 7) {
515515            case INTSTATCLR:   // ITC_INTSTATCLR_REG Group 2
516516               /*
517                  The timer interrupt service routine must write to one of the timer
518                  registers before clearing the corresponding Interrupt Controller ISR timer
519                  interrupt bit.
520                 
521                  Bit 7 (Timers) of Group 2 is the logical OR of its lower level interrupt
522                  status bits down within the interrupting module and are not registered.
523                 
524                  The source registers must be cleared to clear these interrupt bits.
525               */
517                        The timer interrupt service routine must write to one of the timer
518                        registers before clearing the corresponding Interrupt Controller ISR timer
519                        interrupt bit.
520
521                        Bit 7 (Timers) of Group 2 is the logical OR of its lower level interrupt
522                        status bits down within the interrupting module and are not registered.
523
524                        The source registers must be cleared to clear these interrupt bits.
525                    */
526526               if(m_timer_regs.timer_irq) data &= ~INT_TIMER_BIT;
527               
527
528528               m_intctrl_regs[INTREG(INTGROUP2, INTSTATCLR)] &= ~data;
529529               m_intctrl_regs[INTREG(INTGROUP2, INTSTATSET)] &= ~data;
530530               m_intctrl_regs[INTREG(INTGROUP2, INTIRQ)] &= ~data;
r15253r15254
537537      default:
538538         break;
539539   }
540   
540
541541   if(m_i2c1_regs[I2C_STAT_REG]&I2C_INT_BIT)
542542   {
543543      m_intctrl_regs[INTREG(INTGROUP1, INTIRQ)] |= 1<<7;
r15253r15254
551551      device_set_input_line(machine().device("maincpu"), ARM7_IRQ_LINE, ASSERT_LINE);
552552   else
553553      device_set_input_line(machine().device("maincpu"), ARM7_IRQ_LINE, CLEAR_LINE);
554   
554
555555}
556556
557557READ32_MEMBER( cxhumax_state::cx_ss_r )
r15253r15254
724724         if(data&0x20) {// STOP
725725            i2cmem_stop(machine().device("eeprom"));
726726         }
727         
727
728728         /* The interrupt status bit is set at the end of an I2C read or write operation. */
729729         m_i2c1_regs[I2C_STAT_REG] |= I2C_INT_BIT;
730730         m_i2c1_regs[I2C_STAT_REG] |= I2C_WACK_BIT;
731         
731
732732         m_intctrl_regs[INTREG(INTGROUP1, INTIRQ)] |= 1<<7;
733733         m_intctrl_regs[INTREG(INTGROUP1, INTSTATCLR)] |= 1<<7;
734734         m_intctrl_regs[INTREG(INTGROUP1, INTSTATSET)] |= 1<<7;
r15253r15254
891891}
892892
893893static SCREEN_UPDATE_RGB32( cxhumax )
894{   
894{
895895   int i, j;
896896
897897   cxhumax_state *state = screen.machine().driver_data<cxhumax_state>();
r15253r15254
917917      UINT32 ydisp_last = (y_position_and_region_alpha >> 12) & 0x7ff;
918918      UINT32 ydisp_start = y_position_and_region_alpha & 0x7ff;
919919
920   /*   UINT32 first_x = state->m_drm0_regs[DRM_ACTIVE_X_REG] & 0xffff;
921      UINT32 last_x = (state->m_drm0_regs[DRM_ACTIVE_X_REG] >> 16) & 0xffff;
920   /*  UINT32 first_x = state->m_drm0_regs[DRM_ACTIVE_X_REG] & 0xffff;
921        UINT32 last_x = (state->m_drm0_regs[DRM_ACTIVE_X_REG] >> 16) & 0xffff;
922922
923      UINT32 first_y = state->m_drm0_regs[DRM_ACTIVE_Y_REG] & 0xfff;
924      UINT32 last_y = (state->m_drm0_regs[DRM_ACTIVE_Y_REG] >> 16) & 0xfff;*/
923        UINT32 first_y = state->m_drm0_regs[DRM_ACTIVE_Y_REG] & 0xfff;
924        UINT32 last_y = (state->m_drm0_regs[DRM_ACTIVE_Y_REG] >> 16) & 0xfff;*/
925925
926926      for (j=ydisp_start; j <= ydisp_last; j++)
927927      {
928         UINT32 *bmp = &bitmap.pix32(j);   
929     
928         UINT32 *bmp = &bitmap.pix32(j);
929
930930         for (i=xdisp_start; i <= (xdisp_start + xdisp_width); i++)
931931         {
932932            if ((i <= (xdisp_start + ximg_width)) && (j <= (ydisp_start + yimg_height))) {
r15253r15254
10141014      0 << 30 | /* 0=using SC1 (TDA8004) 1=not using SC1 */
10151015      1 << 31;  /* 0=Ext clk for boot 1=Int PLL for boot OK */
10161016   state->m_chipcontrol_regs[SREG_MODE_REG] = 0x0000020F;
1017   
1017
10181018   memset(state->m_isaromdescr_regs,0,sizeof(state->m_isaromdescr_regs));
10191019   memset(state->m_isadescr_regs,0,sizeof(state->m_isadescr_regs));
10201020   state->m_rommode_reg=0;
10211021   state->m_xoemask_reg=0;
10221022   memset(state->m_extdesc_regs,0,sizeof(state->m_extdesc_regs));
10231023
1024   state->m_pll_regs[SREG_MPG_0_INTFRAC_REG] = (0x1A << 25) /* integer */ | 0x5D1764 /* fraction */;
1024   state->m_pll_regs[SREG_MPG_0_INTFRAC_REG] = (0x1A << 25) /* integer */ | 0x5D1764 /* fraction */;
10251025   state->m_pll_regs[SREG_MPG_1_INTFRAC_REG] = (0x1A << 25) /* integer */ | 0x5D1764 /* fraction */;
10261026   state->m_pll_regs[SREG_ARM_INTFRAC_REG] = (0x28 << 25) /* integer */ | 0xCEDE62 /* fraction */;
10271027   state->m_pll_regs[SREG_MEM_INTFRAC_REG] = (0x13 << 25) /* integer */ | 0xC9B26D /* fraction */;
r15253r15254
10421042
10431043   // UART2
10441044   state->m_uart2_regs[UART_FIFC_REG] = 0x30;
1045   
1045
10461046   // Clear SS TX FIFO
10471047   memset(state->m_ss_tx_fifo,0,sizeof(state->m_ss_tx_fifo));
10481048   state->m_ss_regs[SS_BAUD_REG] = 1; // Default SS clock = 13,5MHz
10491049
10501050   memset(state->m_intctrl_regs,0,sizeof(state->m_intctrl_regs));
1051   
1051
10521052   memset(state->m_hdmi_regs,0,sizeof(state->m_hdmi_regs));
10531053
10541054   memset(state->m_gxa_cmd_regs,0,sizeof(state->m_gxa_cmd_regs));
r15253r15254
10861086    MCFG_PALETTE_INIT(black_and_white)
10871087
10881088   MCFG_GENERIC_TERMINAL_ADD(TERMINAL_TAG, terminal_intf)
1089   
1089
10901090   MCFG_VIDEO_START(cxhumax)
10911091MACHINE_CONFIG_END
10921092
r15253r15254
11001100ROM_END
11011101
11021102/*    YEAR  NAME    PARENT  COMPAT   MACHINE    INPUT    INIT     COMPANY   FULLNAME       FLAGS */
1103SYST( 2008, hxhdci2k, 0,       0,   cxhumax,    cxhumax,     0,   "HUMAX",   "HUMAX HDCI-2000",      GAME_NOT_WORKING | GAME_NO_SOUND)
1103SYST( 2008, hxhdci2k, 0,       0,   cxhumax,   cxhumax,    0,   "HUMAX",   "HUMAX HDCI-2000",      GAME_NOT_WORKING | GAME_NO_SOUND)
src/mess/drivers/dm7000.c
r15253r15254
156156 400b 000x   iic
157157 400c 000x   scp
158158 400d 000x   modem
159
159
160160 STBx25xx
161
161
162162 4000 000x   Serial1 Controller
163163 4001 000x   Serial2 Controller
164164 4002 00xx   Smart Card Interface 0
r15253r15254
169169 4007 00xx   Smart Card Interface 1
170170 400c 000x   Serial Controller Port
171171 400d 00xx   Synchronous Serial Port
172
172
173173 STB04xxx
174
174
175175 4000 00xx   Serial1/Infrared Controller
176176 4001 00xx   Universal Serial Bus
177177 4002 00xx   Smart Card Interface 0
r15253r15254
185185 400d 00xx   Synchronous Serial Port
186186 400e 000x   Serial2/UART750 Controller
187187 400f 0xxx   IDE Controller
188 
188
189189*/
190190static ADDRESS_MAP_START( dm7000_mem, AS_PROGRAM, 32, dm7000_state )
191191   ADDRESS_MAP_UNMAP_HIGH
192192   AM_RANGE(0x00000000, 0x01ffffff) AM_RAM                              // RAM page 0 - 32MB
193193   AM_RANGE(0x20000000, 0x21ffffff) AM_RAM                              // RAM page 1 - 32MB
194   
194
195195   AM_RANGE(0x40030000, 0x4003000f) AM_READWRITE8(dm7000_iic0_r, dm7000_iic0_w, 0xffffffff)
196196   AM_RANGE(0x40040000, 0x40040007) AM_READWRITE8(dm7000_scc0_r, dm7000_scc0_w, 0xffffffff)
197197   AM_RANGE(0x40060000, 0x40060047) AM_READWRITE8(dm7000_gpio0_r, dm7000_gpio0_w, 0xffffffff)
198198   AM_RANGE(0x400b0000, 0x400b000f) AM_READWRITE8(dm7000_iic1_r, dm7000_iic1_w, 0xffffffff)
199199   AM_RANGE(0x400c0000, 0x400c0007) AM_READWRITE8(dm7000_scp0_r, dm7000_scp0_w, 0xffffffff)
200   
200
201201   AM_RANGE(0x7f800000, 0x7ffdffff) AM_ROM AM_REGION("user2",0)
202202   AM_RANGE(0x7ffe0000, 0x7fffffff) AM_ROM AM_REGION("user1",0)
203203   //AM_RANGE(0xfffe0000, 0xffffffff) AM_ROM AM_REGION("user1",0)
r15253r15254
211211static MACHINE_RESET(dm7000)
212212{
213213   dm7000_state *state = machine.driver_data<dm7000_state>();
214   
214
215215   state->dcr[DCRSTB045_CICVCR] = 0x00000001;
216216   state->dcr[DCRSTB045_SCCR] = 0x00420080 /* default for serial divs */ | 0x3f /* undocumented?? used to print clocks */;
217217   state->dcr[DCRSTB045_VIDEO_CNTL] = 0x00009000;
r15253r15254
279279
280280   MCFG_PALETTE_LENGTH(2)
281281   MCFG_PALETTE_INIT(black_and_white)
282   
282
283283   MCFG_GENERIC_TERMINAL_ADD(TERMINAL_TAG, terminal_intf)
284284
285285   MCFG_VIDEO_START(dm7000)
src/mess/drivers/esq5505.c
r15253r15254
44
55    Ensoniq VFX, EPS-16 Plus, and SQ-1 (VFX-SD, SD-1, SQ-1 Plus, SQ-2,
66    and KS-32 are known to also be this architecture).
7
7
88    The Taito sound system in taito_en.c is directly derived from the SQ-1.
9
9
1010    Driver by R. Belmont
11
11
1212    00 - harsh piano
1313    01 - bells/chimes
1414    04 - organ
r15253r15254
2828    73 - orch hit with strings
2929    74 - bell tone
3030    80 - drums
31
31
3232***************************************************************************/
3333
3434#include "emu.h"
r15253r15254
199199   AM_RANGE(0x000000, 0x03ffff) AM_RAM AM_SHARE("osram")
200200   AM_RANGE(0x200000, 0x20001f) AM_DEVREADWRITE_LEGACY("ensoniq", es5505_r, es5505_w)
201201   AM_RANGE(0x260000, 0x2601ff) AM_READWRITE(es5510_dsp_r, es5510_dsp_w)
202    AM_RANGE(0x280000, 0x28001f) AM_DEVREADWRITE8_LEGACY("duart", duart68681_r, duart68681_w, 0x00ff)
202    AM_RANGE(0x280000, 0x28001f) AM_DEVREADWRITE8_LEGACY("duart", duart68681_r, duart68681_w, 0x00ff)
203203    AM_RANGE(0xc00000, 0xc1ffff) AM_ROM AM_REGION("osrom", 0)
204204    AM_RANGE(0xfc0000, 0xffffff) AM_RAM AM_SHARE("osram")
205205ADDRESS_MAP_END
r15253r15254
207207static ADDRESS_MAP_START( eps16_map, AS_PROGRAM, 16, esq5505_state )
208208   AM_RANGE(0x000000, 0x03ffff) AM_RAM AM_SHARE("osram")
209209   AM_RANGE(0x200000, 0x20001f) AM_DEVREADWRITE_LEGACY("ensoniq", es5505_r, es5505_w)
210    AM_RANGE(0x280000, 0x28001f) AM_DEVREADWRITE8_LEGACY("duart", duart68681_r, duart68681_w, 0x00ff)
210    AM_RANGE(0x280000, 0x28001f) AM_DEVREADWRITE8_LEGACY("duart", duart68681_r, duart68681_w, 0x00ff)
211211    AM_RANGE(0x580000, 0x77ffff) AM_RAM         // sample RAM (2 MB max represented here)
212212    AM_RANGE(0xc00000, 0xc0ffff) AM_ROM AM_REGION("osrom", 0)
213213ADDRESS_MAP_END
r15253r15254
350350
351351ROM_START( vfx )
352352    ROM_REGION(0x20000, "osrom", 0)
353    ROM_LOAD16_BYTE( "vfx210b-low.bin",  0x000000, 0x010000, CRC(c51b19cd) SHA1(2a125b92ffa02ae9d7fb88118d525491d785e87e) )
354    ROM_LOAD16_BYTE( "vfx210b-high.bin", 0x000001, 0x010000, CRC(59853be8) SHA1(8e07f69d53f80885d15f624e0b912aeaf3212ee4) )
353    ROM_LOAD16_BYTE( "vfx210b-low.bin",  0x000000, 0x010000, CRC(c51b19cd) SHA1(2a125b92ffa02ae9d7fb88118d525491d785e87e) )
354    ROM_LOAD16_BYTE( "vfx210b-high.bin", 0x000001, 0x010000, CRC(59853be8) SHA1(8e07f69d53f80885d15f624e0b912aeaf3212ee4) )
355355
356356    ROM_REGION(0x200000, "waverom", ROMREGION_ERASE00)
357    ROM_LOAD( "vfx-waves-1.bin",  0x000000, 0x080000, NO_DUMP )
358    ROM_LOAD( "vfx-waves-2.bin",  0x100000, 0x080000, NO_DUMP )
357    ROM_LOAD( "vfx-waves-1.bin",  0x000000, 0x080000, NO_DUMP )
358    ROM_LOAD( "vfx-waves-2.bin",  0x100000, 0x080000, NO_DUMP )
359359ROM_END
360360
361361ROM_START( sq1 )
362362    ROM_REGION(0x20000, "osrom", 0)
363    ROM_LOAD16_BYTE( "esq5505lo.bin",    0x000000, 0x010000, CRC(b004cf05) SHA1(567b0dae2e35b06e39da108f9c041fd9bc38fa35) )
364    ROM_LOAD16_BYTE( "esq5505up.bin",    0x000001, 0x010000, CRC(2e927873) SHA1(06a948cb71fa254b23f4b9236f29035d10778da1) )
363    ROM_LOAD16_BYTE( "esq5505lo.bin",    0x000000, 0x010000, CRC(b004cf05) SHA1(567b0dae2e35b06e39da108f9c041fd9bc38fa35) )
364    ROM_LOAD16_BYTE( "esq5505up.bin",    0x000001, 0x010000, CRC(2e927873) SHA1(06a948cb71fa254b23f4b9236f29035d10778da1) )
365365
366366    ROM_REGION(0x200000, "waverom", 0)
367    ROM_LOAD16_BYTE( "sq1-u25.bin",  0x000001, 0x080000, CRC(26312451) SHA1(9f947a11592fd8420fc581914bf16e7ade75390c) )
368    ROM_LOAD16_BYTE( "sq1-u26.bin",  0x100001, 0x080000, CRC(2edaa9dc) SHA1(72fead505c4f44e5736ff7d545d72dfa37d613e2) )
367    ROM_LOAD16_BYTE( "sq1-u25.bin",  0x000001, 0x080000, CRC(26312451) SHA1(9f947a11592fd8420fc581914bf16e7ade75390c) )
368    ROM_LOAD16_BYTE( "sq1-u26.bin",  0x100001, 0x080000, CRC(2edaa9dc) SHA1(72fead505c4f44e5736ff7d545d72dfa37d613e2) )
369369ROM_END
370370
371371ROM_START( eps16 )
372372    ROM_REGION(0x10000, "osrom", 0)
373    ROM_LOAD16_BYTE( "eps-l.bin",    0x000000, 0x008000, CRC(382beac1) SHA1(110e31edb03fcf7bbde3e17423b21929e5b32db2) )
374    ROM_LOAD16_BYTE( "eps-h.bin",    0x000001, 0x008000, CRC(d8747420) SHA1(460597751386eb5f08465699b61381c4acd78065) )
373    ROM_LOAD16_BYTE( "eps-l.bin",    0x000000, 0x008000, CRC(382beac1) SHA1(110e31edb03fcf7bbde3e17423b21929e5b32db2) )
374    ROM_LOAD16_BYTE( "eps-h.bin",    0x000001, 0x008000, CRC(d8747420) SHA1(460597751386eb5f08465699b61381c4acd78065) )
375375
376376    ROM_REGION(0x200000, "waverom", ROMREGION_ERASE00)      // did the EPS-16 have ROM sounds or is it a pure sampler?
377377ROM_END
src/mess/drivers/e01.c
r15253r15254
3939
4040    TODO:
4141
42   - centronics strobe
43   - VIA CB2 -> econet rx/tx clock terminator
42    - centronics strobe
43    - VIA CB2 -> econet rx/tx clock terminator
4444    - ADLC interrupts
4545    - ECONET device
4646    - artwork
4747    - hard disk
4848
49       E20: Rodime RO652 (-chs 306,4,17,512)
50       E40S:
51       E60S:
49        E20: Rodime RO652 (-chs 306,4,17,512)
50        E40S:
51        E60S:
5252
5353*/
5454
r15253r15254
135135        5       floppy master reset
136136        6       floppy test
137137        7       mode LED
138   
139   */
140   
138
139    */
140
141141   // floppy 1 select
142142   if (!BIT(data, 0)) wd17xx_set_drive(m_fdc, 0);
143143
r15253r15254
215215READ8_MEMBER( e01_state::hdc_data_r )
216216{
217217   UINT8 data = scsi_data_r(m_scsibus, 0);
218   
218
219219   scsi_ack_w(m_scsibus, 0);
220220
221221   return data;
r15253r15254
241241READ8_MEMBER( e01_state::hdc_status_r )
242242{
243243   /*
244   
245       bit     description
246   
247       0       MSG
248       1       BSY
249       2       0
250       3       0
251       4       NIRQ
252       5       REQ
253       6       I/O
254       7       C/D
255   
256   */
257244
245        bit     description
246
247        0       MSG
248        1       BSY
249        2       0
250        3       0
251        4       NIRQ
252        5       REQ
253        6       I/O
254        7       C/D
255
256    */
257
258258   UINT8 data = 0;
259259
260260   data |= !scsi_msg_r(m_scsibus);
r15253r15254
391391    update_interrupts();
392392}
393393
394static mc146818_interface rtc_intf =
394static mc146818_interface rtc_intf =
395395{
396396   DEVCB_DRIVER_LINE_MEMBER(e01_state, rtc_irq_w)
397397};
r15253r15254
535535//  centronics_interface e01_centronics_intf
536536//-------------------------------------------------
537537
538static centronics_interface e01_centronics_intf =
538static centronics_interface e01_centronics_intf =
539539{
540540   DEVCB_DEVICE_LINE_MEMBER(R6522_TAG, via6522_device, write_ca1),
541541   DEVCB_NULL,
src/mess/mess.mak
r15253r15254
18101810
18111811$(MESSOBJ)/vidbrain.a:         \
18121812   $(MESS_DRIVERS)/vidbrain.o   \
1813   $(MESS_VIDEO)/uv201.o       \
1813   $(MESS_VIDEO)/uv201.o      \
18141814
18151815$(MESSOBJ)/videoton.a:         \
18161816   $(MESS_DRIVERS)/tvc.o      \
src/ldplayer/ldplayer.c
r15253r15254
402402         // if we have bits, process
403403         if (bitsleft != 0)
404404         {
405            // assert the line and set a timer for deassertion           
405            // assert the line and set a timer for deassertion
406406            m_laserdisc->control_w(ASSERT_LINE);
407407            timer_set(attotime::from_usec(250), TIMER_ID_BIT_OFF);
408408
r15253r15254
437437void pr8210_state::machine_start()
438438{
439439   ldplayer_state::machine_start();
440   m_bit_timer = timer_alloc(TIMER_ID_BIT);   
440   m_bit_timer = timer_alloc(TIMER_ID_BIT);
441441}
442442
443443void pr8210_state::machine_reset()

Previous 15994 Revisions Next


© 1998-2018 The MESS Team