Previous 199869 Revisions Next

r30917 Monday 9th June, 2014 at 19:56:51 UTC by James Wallace
Made MPU4Vid chips properly 8-bit where possible, still doesn't fix 6850 issues though, but does fix CHR regression (nw)
[src/mame/drivers]mpu4vid.c
[src/mame/video]scn2674.c scn2674.h

trunk/src/mame/drivers/mpu4vid.c
r30916r30917
195195#include "crmaze2p.lh"
196196#include "crmaze4p.lh"
197197#include "includes/mpu4.h"
198   #include "cpu/m68000/m68000.h"
198#include "cpu/m68000/m68000.h"
199199
200200
201201struct ef9369_t
r30916r30917
289289   DECLARE_WRITE_LINE_MEMBER(update_mpu68_interrupts);
290290   DECLARE_READ16_MEMBER( mpu4_vid_vidram_r );
291291   DECLARE_WRITE16_MEMBER( mpu4_vid_vidram_w );
292   DECLARE_WRITE16_MEMBER( ef9369_w );
293   DECLARE_READ16_MEMBER( ef9369_r );
294   DECLARE_WRITE16_MEMBER( bt471_w );
295   DECLARE_READ16_MEMBER( bt471_r );
296   DECLARE_WRITE16_MEMBER( characteriser16_w );
297   DECLARE_READ16_MEMBER( characteriser16_r );
298   DECLARE_WRITE16_MEMBER( bwb_characteriser16_w );
299   DECLARE_READ16_MEMBER( bwb_characteriser16_r );
292   DECLARE_WRITE8_MEMBER( ef9369_w );
293   DECLARE_READ8_MEMBER( ef9369_r );
294   DECLARE_WRITE8_MEMBER( bt471_w );
295   DECLARE_READ8_MEMBER( bt471_r );
296   DECLARE_WRITE8_MEMBER( vidcharacteriser_w );
297   DECLARE_READ8_MEMBER( vidcharacteriser_r );
300298   DECLARE_WRITE_LINE_MEMBER(mpu_video_reset);
301299};
302300
r30916r30917
491489
492490/* Non-multiplexed mode */
493491
494WRITE16_MEMBER(mpu4vid_state::ef9369_w )
492WRITE8_MEMBER(mpu4vid_state::ef9369_w )
495493{
496494   struct ef9369_t &pal = m_pal;
497   data &= 0x00ff;
498495
499496   /* Address register */
500497   if (offset & 1)
r30916r30917
532529}
533530
534531
535READ16_MEMBER(mpu4vid_state::ef9369_r )
532READ8_MEMBER(mpu4vid_state::ef9369_r )
536533{
537534   struct ef9369_t &pal = m_pal;
538535   if ((offset & 1) == 0)
539536   {
540537      UINT16 col = pal.clut[pal.addr >> 1];
541538
542      if ((pal.addr & 1) == 0)
539/*      if ((pal.addr & 1) == 0)
543540         return col & 0xff;
544541      else
545542         return col >> 8;
543         */
544         
545   return col;
546546   }
547547   else
548548   {
549549      /* Address register is write only */
550      return 0xffff;
550      return 0xff;
551551   }
552552}
553553
r30916r30917
568568 *  1 0 1    Overlay register
569569 */
570570
571WRITE16_MEMBER(mpu4vid_state::bt471_w )
571WRITE8_MEMBER(mpu4vid_state::bt471_w )
572572{
573573   struct bt471_t &bt471 = m_bt471;
574   UINT8 val = data & 0xff;
575      {
576         popmessage("Bt471: Unhandled write access (offset:%x, data:%x)", offset, val);
577      }
578574
579575   switch (offset)
580576   {
581577      case 0x0:
582578      {
583         bt471.address = val;
579         bt471.address = data;
584580         bt471.addr_cnt = 0;
585581         break;
586582      }
r30916r30917
589585         UINT8 *addr_cnt = &bt471.addr_cnt;
590586         rgb_t *color = &bt471.color;
591587
592         color[*addr_cnt] = val;
588         color[*addr_cnt] = data;
593589
594590         if (++*addr_cnt == 3)
595591         {
r30916r30917
603599      }
604600      case 0x2:
605601      {
606         bt471.pixmask = val;
602         bt471.pixmask = data;
607603         break;
608604      }
609605
610//      default:
606      default:
611607      {
612         popmessage("Bt471: Unhandled write access (offset:%x, data:%x)", offset, val);
608         popmessage("Bt471: Unhandled write access (offset:%x, data:%x)", offset, data);
613609      }
614610   }
615611}
616612
617READ16_MEMBER(mpu4vid_state::bt471_r )
613READ8_MEMBER(mpu4vid_state::bt471_r )
618614{
619615   popmessage("Bt471: Unhandled read access (offset:%x)", offset);
620616   return 0;
r30916r30917
12901286//  AM_RANGE(0x810000, 0x81ffff) AM_RAM /* ? */
12911287   AM_RANGE(0x900000, 0x900001) AM_DEVWRITE8("saa", saa1099_device, saa1099_data_w, 0x00ff)
12921288   AM_RANGE(0x900002, 0x900003) AM_DEVWRITE8("saa", saa1099_device, saa1099_control_w, 0x00ff)
1293   AM_RANGE(0xa00000, 0xa00003) AM_READWRITE(ef9369_r, ef9369_w)
1289   AM_RANGE(0xa00000, 0xa00003) AM_READWRITE8(ef9369_r, ef9369_w,0x00ff)
12941290/*  AM_RANGE(0xa00004, 0xa0000f) AM_READWRITE(mpu4_vid_unmap_r, mpu4_vid_unmap_w) */
12951291
12961292
1297   AM_RANGE(0xb00000, 0xb0000f) AM_DEVREADWRITE("scn2674_vid", scn2674_device, mpu4_vid_scn2674_r, mpu4_vid_scn2674_w)
1293   AM_RANGE(0xb00000, 0xb0000f) AM_DEVREADWRITE8("scn2674_vid", scn2674_device, mpu4_vid_scn2674_r, mpu4_vid_scn2674_w,0x00ff)
12981294
12991295   AM_RANGE(0xc00000, 0xc1ffff) AM_READWRITE(mpu4_vid_vidram_r, mpu4_vid_vidram_w) AM_SHARE("vid_vidram")
1300   AM_RANGE(0xff8000, 0xff8001) AM_DEVREADWRITE8("acia6850_1", acia6850_device, status_r, control_w, 0xff)
1301   AM_RANGE(0xff8002, 0xff8003) AM_DEVREADWRITE8("acia6850_1", acia6850_device, data_r, data_w, 0xff)
1302   AM_RANGE(0xff9000, 0xff900f) AM_DEVREADWRITE8("6840ptm_68k", ptm6840_device, read, write, 0xff)
1303   AM_RANGE(0xffd000, 0xffd00f) AM_READWRITE(characteriser16_r, characteriser16_w)
1296   AM_RANGE(0xff8000, 0xff8001) AM_DEVREADWRITE8("acia6850_1", acia6850_device, status_r, control_w, 0x00ff)
1297   AM_RANGE(0xff8002, 0xff8003) AM_DEVREADWRITE8("acia6850_1", acia6850_device, data_r, data_w, 0x00ff)
1298   AM_RANGE(0xff9000, 0xff900f) AM_DEVREADWRITE8("6840ptm_68k", ptm6840_device, read, write, 0x00ff)
1299   AM_RANGE(0xffd000, 0xffd00f) AM_READWRITE8(vidcharacteriser_r, vidcharacteriser_w,0x00ff)
13041300ADDRESS_MAP_END
13051301
13061302static ADDRESS_MAP_START( mpu4oki_68k_map, AS_PROGRAM, 16, mpu4vid_state )
r30916r30917
13101306   AM_RANGE(0x800000, 0x80ffff) AM_RAM AM_SHARE("vid_mainram")
13111307   AM_RANGE(0x900000, 0x900001) AM_DEVWRITE8("saa", saa1099_device, saa1099_data_w, 0x00ff)
13121308   AM_RANGE(0x900002, 0x900003) AM_DEVWRITE8("saa", saa1099_device, saa1099_control_w, 0x00ff)
1313   AM_RANGE(0xa00000, 0xa00003) AM_READWRITE(ef9369_r, ef9369_w)
1309   AM_RANGE(0xa00000, 0xa00003) AM_READWRITE8(ef9369_r, ef9369_w,0x00ff)
13141310
1315   AM_RANGE(0xb00000, 0xb0000f) AM_DEVREADWRITE("scn2674_vid", scn2674_device, mpu4_vid_scn2674_r, mpu4_vid_scn2674_w)
1311   AM_RANGE(0xb00000, 0xb0000f) AM_DEVREADWRITE8("scn2674_vid", scn2674_device, mpu4_vid_scn2674_r, mpu4_vid_scn2674_w,0x00ff)
13161312
13171313   AM_RANGE(0xc00000, 0xc1ffff) AM_READWRITE(mpu4_vid_vidram_r, mpu4_vid_vidram_w) AM_SHARE("vid_vidram")
1318   AM_RANGE(0xff8000, 0xff8001) AM_DEVREADWRITE8("acia6850_1", acia6850_device, status_r, control_w, 0xff)
1319   AM_RANGE(0xff8002, 0xff8003) AM_DEVREADWRITE8("acia6850_1", acia6850_device, data_r, data_w, 0xff)
1320   AM_RANGE(0xff9000, 0xff900f) AM_DEVREADWRITE8("6840ptm_68k", ptm6840_device, read, write, 0xff)
1321   AM_RANGE(0xffa040, 0xffa04f) AM_DEVREAD8("ptm_ic3ss", ptm6840_device, read,0xff)  // 6840PTM on sampled sound board
1314   AM_RANGE(0xff8000, 0xff8001) AM_DEVREADWRITE8("acia6850_1", acia6850_device, status_r, control_w, 0x00ff)
1315   AM_RANGE(0xff8002, 0xff8003) AM_DEVREADWRITE8("acia6850_1", acia6850_device, data_r, data_w, 0x00ff)
1316   AM_RANGE(0xff9000, 0xff900f) AM_DEVREADWRITE8("6840ptm_68k", ptm6840_device, read, write, 0x00ff)
1317   AM_RANGE(0xffa040, 0xffa04f) AM_DEVREAD8("ptm_ic3ss", ptm6840_device, read,0x00ff)  // 6840PTM on sampled sound board
13221318   AM_RANGE(0xffa040, 0xffa04f) AM_WRITE8(ic3ss_w,0x00ff)  // 6840PTM on sampled sound board
13231319   AM_RANGE(0xffa060, 0xffa067) AM_DEVREADWRITE8("pia_ic4ss", pia6821_device, read, write,0x00ff)    // PIA6821 on sampled sound board
1324   AM_RANGE(0xffd000, 0xffd00f) AM_READWRITE(characteriser16_r, characteriser16_w)
1320   AM_RANGE(0xffd000, 0xffd00f) AM_READWRITE8(vidcharacteriser_r, vidcharacteriser_w, 0x00ff)
13251321//  AM_RANGE(0xfff000, 0xffffff) AM_NOP /* Possible bug, reads and writes here */
13261322ADDRESS_MAP_END
13271323
r30916r30917
13321328   AM_RANGE(0x810000, 0x81ffff) AM_RAM /* ? */
13331329   AM_RANGE(0x900000, 0x900001) AM_DEVWRITE8("saa", saa1099_device, saa1099_data_w, 0x00ff)
13341330   AM_RANGE(0x900002, 0x900003) AM_DEVWRITE8("saa", saa1099_device, saa1099_control_w, 0x00ff)
1335   AM_RANGE(0xa00000, 0xa00003) AM_READWRITE(ef9369_r, ef9369_w)
1331   AM_RANGE(0xa00000, 0xa00003) AM_READWRITE8(ef9369_r, ef9369_w,0x00ff)
13361332//  AM_RANGE(0xa00000, 0xa0000f) AM_READWRITE(bt471_r,bt471_w) //Some games use this
13371333/*  AM_RANGE(0xa00004, 0xa0000f) AM_READWRITE(mpu4_vid_unmap_r, mpu4_vid_unmap_w) */
13381334
1339   AM_RANGE(0xb00000, 0xb0000f) AM_DEVREADWRITE("scn2674_vid", scn2674_device, mpu4_vid_scn2674_r, mpu4_vid_scn2674_w)
1335   AM_RANGE(0xb00000, 0xb0000f) AM_DEVREADWRITE8("scn2674_vid", scn2674_device, mpu4_vid_scn2674_r, mpu4_vid_scn2674_w,0x00ff)
13401336   AM_RANGE(0xc00000, 0xc1ffff) AM_READWRITE(mpu4_vid_vidram_r, mpu4_vid_vidram_w) AM_SHARE("vid_vidram")
1341   AM_RANGE(0xe00000, 0xe00001) AM_DEVREADWRITE8("acia6850_1", acia6850_device, status_r, control_w, 0xff)
1342   AM_RANGE(0xe00002, 0xe00003) AM_DEVREADWRITE8("acia6850_1", acia6850_device, data_r, data_w, 0xff)
1343   AM_RANGE(0xe01000, 0xe0100f) AM_DEVREADWRITE8("6840ptm_68k", ptm6840_device, read, write, 0xff)
1337   AM_RANGE(0xe00000, 0xe00001) AM_DEVREADWRITE8("acia6850_1", acia6850_device, status_r, control_w, 0x00ff)
1338   AM_RANGE(0xe00002, 0xe00003) AM_DEVREADWRITE8("acia6850_1", acia6850_device, data_r, data_w, 0x00ff)
1339   AM_RANGE(0xe01000, 0xe0100f) AM_DEVREADWRITE8("6840ptm_68k", ptm6840_device, read, write, 0x00ff)
13441340   //AM_RANGE(0xa00004, 0xa0000f) AM_READWRITE(bwb_characteriser16_r, bwb_characteriser16_w)//AM_READWRITE(adpcm_r, adpcm_w)  CHR ?
13451341ADDRESS_MAP_END
13461342
r30916r30917
13501346   AM_RANGE(0x810000, 0x81ffff) AM_RAM /* ? */
13511347   AM_RANGE(0x900000, 0x900001) AM_DEVWRITE8("saa", saa1099_device, saa1099_data_w, 0x00ff)
13521348   AM_RANGE(0x900002, 0x900003) AM_DEVWRITE8("saa", saa1099_device, saa1099_control_w, 0x00ff)
1353   AM_RANGE(0xa00000, 0xa00003) AM_READWRITE(ef9369_r, ef9369_w)
1354   //AM_RANGE(0xa00000, 0xa00003) AM_READWRITE(bt471_r,bt471_w) Some games use this
1349   AM_RANGE(0xa00000, 0xa00003) AM_READWRITE8(ef9369_r, ef9369_w,0x00ff)
1350   //AM_RANGE(0xa00000, 0xa00003) AM_READWRITE8(bt471_r,bt471_w,0x00ff) Some games use this
13551351/*  AM_RANGE(0xa00004, 0xa0000f) AM_READWRITE(mpu4_vid_unmap_r, mpu4_vid_unmap_w) */
13561352
1357   AM_RANGE(0xb00000, 0xb0000f) AM_DEVREADWRITE("scn2674_vid", scn2674_device, mpu4_vid_scn2674_r, mpu4_vid_scn2674_w)
1353   AM_RANGE(0xb00000, 0xb0000f) AM_DEVREADWRITE8("scn2674_vid", scn2674_device, mpu4_vid_scn2674_r, mpu4_vid_scn2674_w,0x00ff)
13581354   AM_RANGE(0xc00000, 0xc1ffff) AM_READWRITE(mpu4_vid_vidram_r, mpu4_vid_vidram_w) AM_SHARE("vid_vidram")
1359   AM_RANGE(0xe00000, 0xe00001) AM_DEVREADWRITE8("acia6850_1", acia6850_device, status_r, control_w, 0xff)
1360   AM_RANGE(0xe00002, 0xe00003) AM_DEVREADWRITE8("acia6850_1", acia6850_device, data_r, data_w, 0xff)
1355   AM_RANGE(0xe00000, 0xe00001) AM_DEVREADWRITE8("acia6850_1", acia6850_device, status_r, control_w, 0x00ff)
1356   AM_RANGE(0xe00002, 0xe00003) AM_DEVREADWRITE8("acia6850_1", acia6850_device, data_r, data_w, 0x00ff)
13611357   AM_RANGE(0xe01000, 0xe0100f) AM_DEVREADWRITE8("6840ptm_68k", ptm6840_device, read, write, 0x00ff)
1362   AM_RANGE(0xe02000, 0xe02007) AM_DEVREADWRITE8("pia_ic4ss", pia6821_device, read, write, 0xff00)
1358   AM_RANGE(0xe02000, 0xe02007) AM_DEVREADWRITE8("pia_ic4ss", pia6821_device, read, write, 0xff00) //Seems odd...
13631359   AM_RANGE(0xe03000, 0xe0300f) AM_DEVREAD8("ptm_ic3ss", ptm6840_device, read,0xff00)  // 6840PTM on sampled sound board
13641360   AM_RANGE(0xe03000, 0xe0300f) AM_WRITE8(ic3ss_w,0xff00)  // 6840PTM on sampled sound board
1365   AM_RANGE(0xe04000, 0xe0400f) AM_READWRITE(bwb_characteriser16_r, bwb_characteriser16_w)//AM_READWRITE(adpcm_r, adpcm_w)  CHR ?
1361   AM_RANGE(0xe04000, 0xe0400f) AM_READWRITE8(bwb_characteriser_r, bwb_characteriser_w, 0x00ff)//AM_READWRITE(adpcm_r, adpcm_w)  CHR ?
13661362ADDRESS_MAP_END
13671363
13681364
r30916r30917
15041500 the 'challenge' part of the startup check is always the same
15051501*/
15061502
1507WRITE16_MEMBER(mpu4vid_state::characteriser16_w )
1503WRITE8_MEMBER(mpu4vid_state::vidcharacteriser_w )
15081504{
15091505   int x;
15101506   int call=(data&0xff);
r30916r30917
15351531}
15361532
15371533
1538READ16_MEMBER(mpu4vid_state::characteriser16_r )
1534READ8_MEMBER(mpu4vid_state::vidcharacteriser_r )
15391535{
15401536   LOG_CHR_FULL(("%04x Characteriser read offset %02X,data %02X", space.device().safe_pcbase(),offset,m_current_chr_table[m_prot_col].response));
15411537   LOG_CHR(("Characteriser read offset %02X \n",offset));
r30916r30917
15581554}
15591555
15601556
1561/*
1562BwB Characteriser (CHR)
15631557
1564The BwB method of protection is considerably different to the Barcrest one, with any
1565incorrect behaviour manifesting in ridiculously large payouts.
1566
1567In fact, the software seems deliberately designed to mislead, but is (fortunately for
1568us) prone to similar weaknesses that allow a per game solution.
1569
1570See mpu4hw.c for more info
1571
1572As BwB games aren't yet booting on the 16-bit board, we're duplicating the 8-bit program
1573Precedent suggests this is not that dangerous an assumption to make.
1574*/
1575
1576
1577WRITE16_MEMBER(mpu4vid_state::bwb_characteriser16_w )
1578{
1579   int x;
1580   int call=(data &0xff);
1581   LOG_CHR_FULL(("%04x Characteriser write offset %02X data %02X \n", space.device().safe_pcbase(),offset,data));
1582   if (!m_current_chr_table)
1583   {
1584      logerror("No Characteriser Table @ %04x\n", space.device().safe_pcbase());
1585      return;
1586   }
1587
1588   if (offset == 0)
1589   {
1590      if (!m_chr_state)
1591      {
1592         m_chr_state=1;
1593         m_chr_counter=0;
1594      }
1595      if (call == 0)
1596      {
1597         m_init_col ++;
1598      }
1599      else
1600      {
1601         m_init_col =0;
1602      }
1603   }
1604   m_chr_value = space.machine().rand();
1605   for (x = 0; x < 4; x++)
1606   {
1607      if  (m_current_chr_table[(x)].call == call)
1608      {
1609         if (x == 0) // reinit
1610         {
1611            m_bwb_return = 0;
1612         }
1613         m_chr_value = bwb_chr_table_common[(m_bwb_return)];
1614         m_bwb_return++;
1615         break;
1616      }
1617   }
1618}
1619
1620READ16_MEMBER(mpu4vid_state::bwb_characteriser16_r )
1621{
1622   LOG_CHR(("Characteriser read offset %02X \n",offset));
1623
1624
1625   if (offset ==0)
1626   {
1627      switch (m_chr_counter)
1628      {
1629         case 6:
1630         case 13:
1631         case 20:
1632         case 27:
1633         case 34:
1634         {
1635            return m_bwb_chr_table1[(((m_chr_counter + 1) / 7) - 1)].response;
1636         }
1637         default:
1638         {
1639            if (m_chr_counter > 34)
1640            {
1641               m_chr_counter = 35;
1642               m_chr_state = 2;
1643            }
1644            m_chr_counter ++;
1645            return m_chr_value;
1646         }
1647      }
1648   }
1649   else
1650   {
1651      return m_chr_value;
1652   }
1653}
1654
16551558static mpu4_chr_table adders_data[64] = {
16561559   {0x00, 0x00}, {0x1A, 0x8C}, {0x04, 0x64}, {0x10, 0x84}, {0x18, 0x84}, {0x0F, 0xC4}, {0x13, 0x84}, {0x1B, 0x84},
16571560   {0x03, 0x9C}, {0x07, 0xF4}, {0x17, 0x04}, {0x1D, 0xCC}, {0x36, 0x24}, {0x35, 0x84}, {0x2B, 0xC4}, {0x28, 0x94},
trunk/src/mame/video/scn2674.c
r30916r30917
496496}
497497
498498
499READ16_MEMBER( scn2674_device::mpu4_vid_scn2674_r )
499READ8_MEMBER( scn2674_device::mpu4_vid_scn2674_r )
500500{
501501   /*
502502   Offset:  Purpose
r30916r30917
541541      case 7: LOG2674(("Read Screen2_h Register %06x\n",space.device().safe_pc()));return m_scn2674_screen2_h;
542542   }
543543
544   return 0xffff;
544   return 0xff;
545545}
546546
547547
548WRITE16_MEMBER( scn2674_device::mpu4_vid_scn2674_w )
548WRITE8_MEMBER( scn2674_device::mpu4_vid_scn2674_w )
549549{
550550   /*
551551   Offset:  Purpose
r30916r30917
559559    7       Screen Start 2 Upper Register
560560   */
561561
562   data &=0x00ff; /* it's an 8-bit chip on a 16-bit board, feel the cheapness. */
563
564562   switch (offset)
565563   {
566564      case 0:
trunk/src/mame/video/scn2674.h
r30916r30917
3131   }
3232//  int m_gfx_index;
3333
34   DECLARE_READ16_MEMBER( mpu4_vid_scn2674_r );
35   DECLARE_WRITE16_MEMBER( mpu4_vid_scn2674_w );
34   DECLARE_READ8_MEMBER( mpu4_vid_scn2674_r );
35   DECLARE_WRITE8_MEMBER( mpu4_vid_scn2674_w );
3636
3737   UINT8 get_irq_state( void )
3838   {

Previous 199869 Revisions Next


© 1997-2024 The MAME Team