Previous 199869 Revisions Next

r20801 Thursday 7th February, 2013 at 15:25:11 UTC by Angelo Salese
State-ized CD block, and finished state-izing VDP1, thanks to OG & Micko
[src/mame/drivers]saturn.c
[src/mame/includes]stv.h
[src/mame/machine]stvcd.c stvcd.h
[src/mame/video]stvvdp1.c

trunk/src/mame/machine/stvcd.c
r20800r20801
2323
2424#include "emu.h"
2525#include "imagedev/chd_cd.h"
26#include "includes/stv.h"
2627#include "cdrom.h"
2728#include "stvcd.h"
2829#include "sound/cdda.h"
r20800r20801
3637#define CDROM_LOG(x)
3738#endif
3839
39static cdrom_file *cdrom = (cdrom_file *)NULL;
40
41static void cd_readTOC(void);
42static void cd_readblock(UINT32 fad, UINT8 *dat);
43static void cd_playdata(running_machine &machine);
44
45#define MAX_FILTERS (24)
46#define MAX_BLOCKS  (200)
47#define MAX_DIR_SIZE    (256*1024)
48
49struct direntryT
50{
51   UINT8 record_size;
52   UINT8 xa_record_size;
53   UINT32 firstfad;        // first sector of file
54   UINT32 length;      // length of file
55   UINT8 year;
56   UINT8 month;
57   UINT8 day;
58   UINT8 hour;
59   UINT8 minute;
60   UINT8 second;
61   UINT8 gmt_offset;
62   UINT8 flags;        // iso9660 flags
63   UINT8 file_unit_size;
64   UINT8 interleave_gap_size;
65   UINT16 volume_sequencer_number;
66   UINT8 name[128];
67};
68
69struct filterT
70{
71   UINT8 mode;
72   UINT8 chan;
73   UINT8 smmask;
74   UINT8 cimask;
75   UINT8 fid;
76   UINT8 smval;
77   UINT8 cival;
78   UINT8 condtrue;
79   UINT8 condfalse;
80   UINT32 fad;
81   UINT32 range;
82};
83
84struct blockT
85{
86   INT32 size; // size of block
87   INT32 FAD;  // FAD on disc
88   UINT8 data[CD_MAX_SECTOR_DATA];
89   UINT8 chan; // channel
90   UINT8 fnum; // file number
91   UINT8 subm; // subchannel mode
92   UINT8 cinf; // coding information
93};
94
95struct partitionT
96{
97   INT32 size;
98   blockT *blocks[MAX_BLOCKS];
99   UINT8 bnum[MAX_BLOCKS];
100   UINT8 numblks;
101};
102
103// 16-bit transfer types
104enum transT
105{
106   XFERTYPE_INVALID,
107   XFERTYPE_TOC,
108   XFERTYPE_FILEINFO_1,
109   XFERTYPE_FILEINFO_254,
110   XFERTYPE_SUBQ,
111   XFERTYPE_SUBRW
112};
113
114// 32-bit transfer types
115enum trans32T
116{
117   XFERTYPE32_INVALID,
118   XFERTYPE32_GETSECTOR,
119   XFERTYPE32_GETDELETESECTOR
120};
121
122// local variables
123static timer_device *sector_timer;
124static timer_device *sh1_timer;
125static partitionT partitions[MAX_FILTERS];
126static partitionT *transpart;
127
128static blockT blocks[MAX_BLOCKS];
129static blockT curblock;
130
131static UINT8 tocbuf[102*4];
132static UINT8 subqbuf[5*2];
133static UINT8 subrwbuf[12*2];
134static UINT8 finfbuf[256];
135
136static INT32 sectlenin, sectlenout;
137
138static UINT8 lastbuf, playtype;
139
140static transT xfertype;
141static trans32T xfertype32;
142static UINT32 xfercount, calcsize;
143static UINT32 xferoffs, xfersect, xfersectpos, xfersectnum, xferdnum;
144
145static filterT filters[MAX_FILTERS];
146static filterT *cddevice;
147static int cddevicenum;
148
149static UINT16 cr1, cr2, cr3, cr4;
150static UINT16 hirqmask, hirqreg;
151static UINT16 cd_stat;
152static UINT32 cd_curfad = 0;
153static UINT32 fadstoplay = 0;
154static UINT32 in_buffer = 0;    // amount of data in the buffer
155static int oddframe = 0;
156static int buffull, sectorstore, freeblocks;
157static int cur_track;
158static UINT8 cmd_pending;
159static UINT8 cd_speed;
160static UINT8 cdda_maxrepeat;
161static UINT8 cdda_repeat_count;
162static UINT8 tray_is_closed;
163
164// iso9660 utilities
165static void read_new_dir(running_machine &machine, UINT32 fileno);
166static void make_dir_current(running_machine &machine, UINT32 fad);
167
168static direntryT curroot;       // root entry of current filesystem
169static direntryT *curdir;       // current directory
170static int numfiles;            // # of entries in current directory
171static int firstfile;           // first non-directory file
172
17340// HIRQ definitions
17441#define CMOK 0x0001 // command dispatch possible
17542#define DRDY 0x0002 // data transfer preparations complete
r20800r20801
20572#define CD_STAT_REJECT   0xff00     // ultra-fatal error.
20673
20774/* FIXME: assume Saturn CD-ROMs to have a 2 secs pre-gap for now. */
208static int get_track_index(void)
75int saturn_state::get_track_index(void)
20976{
21077   UINT32 rel_fad;
21178   UINT8 track;
r20800r20801
22390   return 1;
22491}
22592
226static void cr_standard_return(UINT16 cur_status)
93void saturn_state::cr_standard_return(UINT16 cur_status)
22794{
22895   cr1 = cur_status | (playtype << 7) | 0x00 | (cdda_repeat_count & 0xf); //options << 4 | repeat & 0xf
22996   cr2 = (cur_track == 0xff) ? 0xffff : (cdrom_get_adr_control(cdrom, cur_track)<<8 | cur_track); // TODO: fix current track
r20800r20801
23299   cd_stat |= CD_STAT_PERI;
233100}
234101
235static void cd_free_block(blockT *blktofree);
236static void cd_defragblocks(partitionT *part);
237static void cd_getsectoroffsetnum(UINT32 bufnum, UINT32 *sectoffs, UINT32 *sectnum);
238
239static void cd_exec_command(running_machine &machine)
102void saturn_state::cd_exec_command( void )
240103{
241104   UINT32 temp;
242105
r20800r20801
537400         // cdda
538401         if(cdrom_get_track_type(cdrom, cdrom_get_track(cdrom, cd_curfad)) == CD_TRACK_AUDIO)
539402         {
540            cdda_pause_audio( machine.device( "cdda" ), 0 );
403            cdda_pause_audio( machine().device( "cdda" ), 0 );
541404            //cdda_start_audio( machine.device( "cdda" ), cd_curfad, fadstoplay  );
542405            //cdda_repeat_count = 0;
543406         }
r20800r20801
564427            if (temp == 0xffffff)
565428            {
566429               cd_stat = CD_STAT_PAUSE;
567               cdda_pause_audio( machine.device( "cdda" ), 1 );
430               cdda_pause_audio( machine().device( "cdda" ), 1 );
568431            }
569432            else
570433            {
r20800r20801
580443               cd_stat = CD_STAT_PAUSE;
581444               cur_track = cr2>>8;;
582445               cd_curfad = cdrom_get_track_start(cdrom, cur_track-1);
583               cdda_pause_audio( machine.device( "cdda" ), 1 );
446               cdda_pause_audio( machine().device( "cdda" ), 1 );
584447               // (index is cr2 low byte)
585448            }
586449            else // error!
r20800r20801
588451               cd_stat = CD_STAT_STANDBY;
589452               cd_curfad = 0xffffffff;
590453               cur_track = 0xff;
591               cdda_stop_audio( machine.device( "cdda" ) ); //stop any pending CD-DA
454               cdda_stop_audio( machine().device( "cdda" ) ); //stop any pending CD-DA
592455            }
593456         }
594457
r20800r20801
12241087         temp = (cr3&0xff)<<16;
12251088         temp |= cr4;
12261089
1227         read_new_dir(machine, temp);
1090         read_new_dir(temp);
12281091         cr_standard_return(cd_stat);
12291092         break;
12301093
r20800r20801
12401103            cddevice = (filterT *)NULL;
12411104
12421105         /* TODO:  */
1243         //read_new_dir(machine, read_dir - 2);
1106         //read_new_dir(read_dir - 2);
12441107
12451108         cr_standard_return(cd_stat);
12461109         hirqreg |= (CMOK|EFLS);
r20800r20801
13871250   }
13881251}
13891252
1390TIMER_DEVICE_CALLBACK( stv_sh1_sim )
1253TIMER_DEVICE_CALLBACK_MEMBER( saturn_state::stv_sh1_sim )
13911254{
13921255   sh1_timer->adjust(attotime::from_hz(16667));
13931256
13941257   if((cmd_pending == 0xf) && (!(hirqreg & CMOK)))
13951258   {
1396      cd_exec_command(timer.machine());
1259      cd_exec_command();
13971260      return;
13981261   }
13991262
r20800r20801
14081271   }
14091272}
14101273
1411TIMER_DEVICE_CALLBACK( stv_sector_cb )
1274TIMER_DEVICE_CALLBACK_MEMBER( saturn_state::stv_sector_cb )
14121275{
14131276   //sector_timer->reset();
14141277
14151278   //popmessage("%08x %08x %d %d",cd_curfad,fadstoplay,cmd_pending,cd_speed);
14161279
1417   cd_playdata(timer.machine());
1280   cd_playdata();
14181281
14191282   if(cdrom_get_track_type(cdrom, cdrom_get_track(cdrom, cd_curfad)) == CD_TRACK_AUDIO)
14201283      sector_timer->adjust(attotime::from_hz(75));    // 75 sectors / second = 150kBytes/second (cdda track ignores cd_speed setting)
r20800r20801
14231286}
14241287
14251288// global functions
1426void stvcd_reset(running_machine &machine)
1289void saturn_state::stvcd_reset( void )
14271290{
14281291   INT32 i, j;
14291292
r20800r20801
14381301   cur_track = 0xff;
14391302
14401303   if (curdir != (direntryT *)NULL)
1441      auto_free(machine, curdir);
1304      auto_free(machine(), curdir);
14421305   curdir = (direntryT *)NULL;     // no directory yet
14431306
14441307   xfertype = XFERTYPE_INVALID;
r20800r20801
14801343      cdrom = (cdrom_file *)NULL;
14811344   }
14821345
1483   cdrom_image_device *cddevice = machine.device<cdrom_image_device>("cdrom");
1346   cdrom_image_device *cddevice = machine().device<cdrom_image_device>("cdrom");
14841347   if (cddevice!=NULL)
14851348   {
14861349      // MESS case
r20800r20801
14891352   else
14901353   {
14911354      // MAME case
1492      cdrom = cdrom_open(get_disk_handle(machine, "cdrom"));
1355      cdrom = cdrom_open(get_disk_handle(machine(), "cdrom"));
14931356   }
14941357
1495   cdda_set_cdrom( machine.device("cdda"), cdrom );
1358   cdda_set_cdrom( machine().device("cdda"), cdrom );
14961359
14971360   if (cdrom)
14981361   {
14991362      CDROM_LOG(("Opened CD-ROM successfully, reading root directory\n"))
1500      read_new_dir(machine, 0xffffff);    // read root directory
1363      read_new_dir(0xffffff);    // read root directory
15011364   }
15021365   else
15031366   {
r20800r20801
15081371   cdda_repeat_count = 0;
15091372   tray_is_closed = 1;
15101373
1511   sector_timer = machine.device<timer_device>("sector_timer");
1374   sector_timer = machine().device<timer_device>("sector_timer");
15121375   sector_timer->adjust(attotime::from_hz(150));   // 150 sectors / second = 300kBytes/second
1513   sh1_timer = machine.device<timer_device>("sh1_cmd");
1376   sh1_timer = machine().device<timer_device>("sh1_cmd");
15141377   sh1_timer->adjust(attotime::from_hz(16667));
15151378}
15161379
1517static blockT *cd_alloc_block(UINT8 *blknum)
1380saturn_state::blockT *saturn_state::cd_alloc_block(UINT8 *blknum)
15181381{
15191382   INT32 i;
15201383
r20800r20801
15421405   return (blockT *)NULL;
15431406}
15441407
1545static void cd_free_block(blockT *blktofree)
1408void saturn_state::cd_free_block(blockT *blktofree)
15461409{
15471410   INT32 i;
15481411
r20800r20801
15671430   hirqreg &= ~BFUL;
15681431}
15691432
1570static void cd_getsectoroffsetnum(UINT32 bufnum, UINT32 *sectoffs, UINT32 *sectnum)
1433void saturn_state::cd_getsectoroffsetnum(UINT32 bufnum, UINT32 *sectoffs, UINT32 *sectnum)
15711434{
15721435   if (*sectoffs == 0xffff)
15731436   {
r20800r20801
15801443   }
15811444}
15821445
1583static void cd_defragblocks(partitionT *part)
1446void saturn_state::cd_defragblocks(partitionT *part)
15841447{
15851448   UINT32 i, j;
15861449   blockT *temp;
r20800r20801
16041467   }
16051468}
16061469
1607static UINT16 cd_readWord(UINT32 addr)
1470UINT16 saturn_state::cd_readWord(UINT32 addr)
16081471{
16091472   UINT16 rv;
16101473
r20800r20801
17581621
17591622}
17601623
1761static UINT32 cd_readLong(UINT32 addr)
1624UINT32 saturn_state::cd_readLong(UINT32 addr)
17621625{
17631626   UINT32 rv = 0;
17641627
r20800r20801
17731636               if (xfersect < xfersectnum)
17741637               {
17751638                  // get next longword
1776                  rv = transpart->blocks[xfersectpos+xfersect]->data[xferoffs]<<24 |
1777                        transpart->blocks[xfersectpos+xfersect]->data[xferoffs + 1]<<16 |
1778                        transpart->blocks[xfersectpos+xfersect]->data[xferoffs + 2]<<8 |
1779                        transpart->blocks[xfersectpos+xfersect]->data[xferoffs + 3];
1639                  rv = (transpart->blocks[xfersectpos+xfersect]->data[xferoffs + 0]<<24) |
1640                       (transpart->blocks[xfersectpos+xfersect]->data[xferoffs + 1]<<16) |
1641                       (transpart->blocks[xfersectpos+xfersect]->data[xferoffs + 2]<<8)  |
1642                       (transpart->blocks[xfersectpos+xfersect]->data[xferoffs + 3]<<0);
17801643
17811644                  xferdnum += 4;
17821645                  xferoffs += 4;
r20800r20801
18311694   }
18321695}
18331696
1834static void cd_writeWord(running_machine &machine, UINT32 addr, UINT16 data)
1697void saturn_state::cd_writeWord(UINT32 addr, UINT16 data)
18351698{
18361699   switch(addr & 0xffff)
18371700   {
18381701   case 0x0008:
18391702   case 0x000a:
1840//              CDROM_LOG(("%s:WW HIRQ: %04x & %04x => %04x\n", machine.describe_context(), hirqreg, data, hirqreg & data))
1703//      CDROM_LOG(("%s:WW HIRQ: %04x & %04x => %04x\n", machine().describe_context(), hirqreg, data, hirqreg & data))
18411704      hirqreg &= data;
18421705      if(!(hirqreg & CMOK))
18431706      {
r20800r20801
18531716      return;
18541717   case 0x0018:
18551718   case 0x001a:
1856//              CDROM_LOG(("WW CR1: %04x\n", data))
1719//      CDROM_LOG(("WW CR1: %04x\n", data))
18571720      cr1 = data;
18581721      cd_stat &= ~CD_STAT_PERI;
18591722      cmd_pending |= 1;
18601723      break;
18611724   case 0x001c:
18621725   case 0x001e:
1863//              CDROM_LOG(("WW CR2: %04x\n", data))
1726//      CDROM_LOG(("WW CR2: %04x\n", data))
18641727      cr2 = data;
18651728      cmd_pending |= 2;
18661729      break;
18671730   case 0x0020:
18681731   case 0x0022:
1869//              CDROM_LOG(("WW CR3: %04x\n", data))
1732//      CDROM_LOG(("WW CR3: %04x\n", data))
18701733      cr3 = data;
18711734      cmd_pending |= 4;
18721735      break;
18731736   case 0x0024:
18741737   case 0x0026:
1875//              CDROM_LOG(("WW CR4: %04x\n", data))
1738//      CDROM_LOG(("WW CR4: %04x\n", data))
18761739      cr4 = data;
18771740      cmd_pending |= 8;
18781741      break;
r20800r20801
18821745   }
18831746}
18841747
1885READ32_HANDLER( stvcd_r )
1748READ32_MEMBER( saturn_state::stvcd_r )
18861749{
18871750   UINT32 rv = 0;
18881751
r20800r20801
19341797   return rv;
19351798}
19361799
1937WRITE32_HANDLER( stvcd_w )
1800WRITE32_MEMBER( saturn_state::stvcd_w )
19381801{
19391802   offset <<= 2;
19401803
r20800r20801
19521815      case 0x90022:
19531816      case 0x90024:
19541817      case 0x90026:
1955         cd_writeWord(space.machine(), offset, data>>16);
1818         cd_writeWord(offset, data>>16);
19561819         break;
19571820
19581821      default:
r20800r20801
19621825}
19631826
19641827// iso9660 parsing
1965static void read_new_dir(running_machine &machine, UINT32 fileno)
1828void saturn_state::read_new_dir(UINT32 fileno)
19661829{
19671830   int foundpd, i;
19681831   UINT32 cfad;//, dirfad;
r20800r20801
20291892         }
20301893
20311894         // done with all that, read the root directory now
2032         make_dir_current(machine, curroot.firstfad);
1895         make_dir_current(curroot.firstfad);
20331896      }
20341897   }
20351898   else
r20800r20801
20381901      {
20391902         mame_printf_error("ERROR: new directory too big (%d)!\n", curdir[fileno].length);
20401903      }
2041      make_dir_current(machine, curdir[fileno].firstfad);
1904      make_dir_current(curdir[fileno].firstfad);
20421905   }
20431906}
20441907
20451908// makes the directory pointed to by FAD current
2046static void make_dir_current(running_machine &machine, UINT32 fad)
1909void saturn_state::make_dir_current(UINT32 fad)
20471910{
20481911   int i;
20491912   UINT32 nextent, numentries;
r20800r20801
20771940
20781941   if (curdir != (direntryT *)NULL)
20791942   {
2080      auto_free(machine, curdir);
1943      auto_free(machine(), curdir);
20811944   }
20821945
2083   curdir = auto_alloc_array(machine, direntryT, numentries);
1946   curdir = auto_alloc_array(machine(), direntryT, numentries);
20841947   curentry = curdir;
20851948   numfiles = numentries;
20861949
r20800r20801
21492012   free(sect);
21502013}
21512014
2152void stvcd_exit(running_machine& machine)
2015void saturn_state::stvcd_exit( void )
21532016{
21542017   if (curdir != (direntryT *)NULL)
21552018   {
2156      auto_free(machine, curdir);
2019      auto_free(machine(), curdir);
21572020      curdir = (direntryT *)NULL;
21582021   }
21592022
21602023   if (cdrom)
21612024   {
2162      cdrom_image_device *cddevice = machine.device<cdrom_image_device>("cdrom");
2025      cdrom_image_device *cddevice = machine().device<cdrom_image_device>("cdrom");
21632026      if (cddevice==NULL)
21642027      {
21652028         cdrom_close(cdrom);
r20800r20801
21682031   }
21692032}
21702033
2171static void cd_readTOC(void)
2034void saturn_state::cd_readTOC(void)
21722035{
21732036   int i, ntrks, tocptr, fad;
21742037
r20800r20801
22582121   tocbuf[tocptr+11] = fad&0xff;
22592122}
22602123
2261static partitionT *cd_filterdata(filterT *flt, int trktype, UINT8 *p_ok)
2124saturn_state::partitionT *saturn_state::cd_filterdata(filterT *flt, int trktype, UINT8 *p_ok)
22622125{
22632126   int match = 1, keepgoing = 2;
22642127   partitionT *filterprt = (partitionT *)NULL;
r20800r20801
24112274}
24122275
24132276// read a single sector off the CD, applying the current filter(s) as necessary
2414static partitionT *cd_read_filtered_sector(INT32 fad, UINT8 *p_ok)
2277saturn_state::partitionT *saturn_state::cd_read_filtered_sector(INT32 fad, UINT8 *p_ok)
24152278{
24162279   int trktype;
24172280
r20800r20801
24602323}
24612324
24622325// loads in data set up by a CD-block PLAY command
2463static void cd_playdata(running_machine &machine)
2326void saturn_state::cd_playdata( void )
24642327{
24652328   if ((cd_stat & 0x0f00) == CD_STAT_PLAY)
24662329   {
r20800r20801
24752338            if(cdrom_get_track_type(cdrom, cdrom_get_track(cdrom, cd_curfad)) != CD_TRACK_AUDIO)
24762339            {
24772340               cd_read_filtered_sector(cd_curfad,&p_ok);
2478               cdda_stop_audio( machine.device( "cdda" ) ); //stop any pending CD-DA
2341               cdda_stop_audio( machine().device( "cdda" ) ); //stop any pending CD-DA
24792342            }
24802343            else
24812344            {
24822345               p_ok = 1; // TODO
2483               cdda_start_audio( machine.device( "cdda" ), cd_curfad, 1  );
2346               cdda_start_audio( machine().device( "cdda" ), cd_curfad, 1  );
24842347            }
24852348
24862349            if(p_ok)
r20800r20801
25212384}
25222385
25232386// loads a single sector off the CD, anywhere from FAD 150 on up
2524static void cd_readblock(UINT32 fad, UINT8 *dat)
2387void saturn_state::cd_readblock(UINT32 fad, UINT8 *dat)
25252388{
25262389   if (cdrom)
25272390   {
r20800r20801
25292392   }
25302393}
25312394
2532void stvcd_set_tray_open(running_machine &machine)
2395void saturn_state::stvcd_set_tray_open( void )
25332396{
25342397   if(!tray_is_closed)
25352398      return;
r20800r20801
25432406   popmessage("Tray Open");
25442407}
25452408
2546void stvcd_set_tray_close(running_machine &machine)
2409void saturn_state::stvcd_set_tray_close( void )
25472410{
25482411   /* avoid user attempts to load a CD-ROM without opening the tray first (emulation asserts anyway with current framework) */
25492412   if(tray_is_closed)
r20800r20801
25512414
25522415   hirqreg |= DCHG;
25532416
2554   cdrom_image_device *cddevice = machine.device<cdrom_image_device>("cdrom");
2417   cdrom_image_device *cddevice = machine().device<cdrom_image_device>("cdrom");
25552418   if (cddevice!=NULL)
25562419   {
25572420      // MESS case
r20800r20801
25602423   else
25612424   {
25622425      // MAME case
2563      cdrom = cdrom_open(get_disk_handle(machine, "cdrom"));
2426      cdrom = cdrom_open(get_disk_handle(machine(), "cdrom"));
25642427   }
25652428
2566   cdda_set_cdrom( machine.device("cdda"), cdrom );
2429   cdda_set_cdrom( machine().device("cdda"), cdrom );
25672430
25682431   if (cdrom)
25692432   {
25702433      CDROM_LOG(("Opened CD-ROM successfully, reading root directory\n"))
2571      //read_new_dir(machine, 0xffffff);  // read root directory
2434      //read_new_dir(0xffffff);  // read root directory
25722435      cd_stat = CD_STAT_PAUSE;
25732436   }
25742437   else
trunk/src/mame/machine/stvcd.h
r20800r20801
99#ifndef __STVCD_H__
1010#define __STVCD_H__
1111
12void stvcd_reset(running_machine& machine);
13void stvcd_exit(running_machine& machine);
1412
15TIMER_DEVICE_CALLBACK( stv_sector_cb );
16TIMER_DEVICE_CALLBACK( stv_sh1_sim );
17
18DECLARE_READ32_HANDLER( stvcd_r );
19DECLARE_WRITE32_HANDLER( stvcd_w );
20
21void stvcd_set_tray_open(running_machine &machine);
22void stvcd_set_tray_close(running_machine &machine);
23
2413#endif
trunk/src/mame/includes/stv.h
r20800r20801
11/*----------- defined in drivers/stv.c -----------*/
2#include "cdrom.h"
23
4#define MAX_FILTERS (24)
5#define MAX_BLOCKS  (200)
6#define MAX_DIR_SIZE    (256*1024)
7
38class saturn_state : public driver_device
49{
510public:
r20800r20801
284289   int y2s(int v);
285290   void vdp1_fill_quad(const rectangle &cliprect, int patterndata, int xsize, const struct spoint *q);
286291   void vdp1_fill_line(const rectangle &cliprect, int patterndata, int xsize, INT32 y, INT32 x1, INT32 x2, INT32 u1, INT32 u2, INT32 v1, INT32 v2);
287//   void (*drawpixel)(int x, int y, int patterndata, int offsetcnt);
288//   void drawpixel_poly(int x, int y, int patterndata, int offsetcnt);
289//   void drawpixel_8bpp_trans(int x, int y, int patterndata, int offsetcnt);
290//   void drawpixel_4bpp_notrans(int x, int y, int patterndata, int offsetcnt);
291//   void drawpixel_4bpp_trans(int x, int y, int patterndata, int offsetcnt);
292//   void drawpixel_generic(int x, int y, int patterndata, int offsetcnt);
292   void (saturn_state::*drawpixel)(int x, int y, int patterndata, int offsetcnt);
293   void drawpixel_poly(int x, int y, int patterndata, int offsetcnt);
294   void drawpixel_8bpp_trans(int x, int y, int patterndata, int offsetcnt);
295   void drawpixel_4bpp_notrans(int x, int y, int patterndata, int offsetcnt);
296   void drawpixel_4bpp_trans(int x, int y, int patterndata, int offsetcnt);
297   void drawpixel_generic(int x, int y, int patterndata, int offsetcnt);
293298   void vdp1_fill_slope(const rectangle &cliprect, int patterndata, int xsize,
294299                          INT32 x1, INT32 x2, INT32 sl1, INT32 sl2, INT32 *nx1, INT32 *nx2,
295300                     INT32 u1, INT32 u2, INT32 slu1, INT32 slu2, INT32 *nu1, INT32 *nu2,
r20800r20801
515520
516521   } stv_rbg_cache_data;
517522
523   /* stvcd */
524   DECLARE_READ32_MEMBER( stvcd_r );
525   DECLARE_WRITE32_MEMBER( stvcd_w );
518526
527   TIMER_DEVICE_CALLBACK_MEMBER( stv_sector_cb );
528   TIMER_DEVICE_CALLBACK_MEMBER( stv_sh1_sim );
529
530   struct direntryT
531   {
532      UINT8 record_size;
533      UINT8 xa_record_size;
534      UINT32 firstfad;        // first sector of file
535      UINT32 length;      // length of file
536      UINT8 year;
537      UINT8 month;
538      UINT8 day;
539      UINT8 hour;
540      UINT8 minute;
541      UINT8 second;
542      UINT8 gmt_offset;
543      UINT8 flags;        // iso9660 flags
544      UINT8 file_unit_size;
545      UINT8 interleave_gap_size;
546      UINT16 volume_sequencer_number;
547      UINT8 name[128];
548   };
549
550   struct filterT
551   {
552      UINT8 mode;
553      UINT8 chan;
554      UINT8 smmask;
555      UINT8 cimask;
556      UINT8 fid;
557      UINT8 smval;
558      UINT8 cival;
559      UINT8 condtrue;
560      UINT8 condfalse;
561      UINT32 fad;
562      UINT32 range;
563   };
564
565   struct blockT
566   {
567      INT32 size; // size of block
568      INT32 FAD;  // FAD on disc
569      UINT8 data[CD_MAX_SECTOR_DATA];
570      UINT8 chan; // channel
571      UINT8 fnum; // file number
572      UINT8 subm; // subchannel mode
573      UINT8 cinf; // coding information
574   };
575
576   struct partitionT
577   {
578      INT32 size;
579      blockT *blocks[MAX_BLOCKS];
580      UINT8 bnum[MAX_BLOCKS];
581      UINT8 numblks;
582   };
583
584   // 16-bit transfer types
585   enum transT
586   {
587      XFERTYPE_INVALID,
588      XFERTYPE_TOC,
589      XFERTYPE_FILEINFO_1,
590      XFERTYPE_FILEINFO_254,
591      XFERTYPE_SUBQ,
592      XFERTYPE_SUBRW
593   };
594
595   // 32-bit transfer types
596   enum trans32T
597   {
598      XFERTYPE32_INVALID,
599      XFERTYPE32_GETSECTOR,
600      XFERTYPE32_GETDELETESECTOR
601   };
602
603
604   void stvcd_reset(void);
605   void stvcd_exit(void);
606   void stvcd_set_tray_open(void);
607   void stvcd_set_tray_close(void);
608
609   int get_track_index(void);
610   void cr_standard_return(UINT16 cur_status);
611   void cd_free_block(blockT *blktofree);
612   void cd_defragblocks(partitionT *part);
613   void cd_getsectoroffsetnum(UINT32 bufnum, UINT32 *sectoffs, UINT32 *sectnum);
614
615   UINT16 cd_readWord(UINT32 addr);
616   void cd_writeWord(UINT32 addr, UINT16 data);
617   UINT32 cd_readLong(UINT32 addr);
618
619   void cd_readTOC(void);
620   void cd_readblock(UINT32 fad, UINT8 *dat);
621   void cd_playdata(void);
622
623   void cd_exec_command( void );
624   // iso9660 utilities
625   void make_dir_current(UINT32 fad);
626   void read_new_dir(UINT32 fileno);
627
628   blockT *cd_alloc_block(UINT8 *blknum);
629   partitionT *cd_filterdata(filterT *flt, int trktype, UINT8 *p_ok);
630   partitionT *cd_read_filtered_sector(INT32 fad, UINT8 *p_ok);
631
632   cdrom_file *cdrom;// = (cdrom_file *)NULL;
633
634   // local variables
635   timer_device *sector_timer;
636   timer_device *sh1_timer;
637   partitionT partitions[MAX_FILTERS];
638   partitionT *transpart;
639
640   blockT blocks[MAX_BLOCKS];
641   blockT curblock;
642
643   UINT8 tocbuf[102*4];
644   UINT8 subqbuf[5*2];
645   UINT8 subrwbuf[12*2];
646   UINT8 finfbuf[256];
647
648   INT32 sectlenin, sectlenout;
649
650   UINT8 lastbuf, playtype;
651
652   transT xfertype;
653   trans32T xfertype32;
654   UINT32 xfercount, calcsize;
655   UINT32 xferoffs, xfersect, xfersectpos, xfersectnum, xferdnum;
656
657   filterT filters[MAX_FILTERS];
658   filterT *cddevice;
659   int cddevicenum;
660
661   UINT16 cr1, cr2, cr3, cr4;
662   UINT16 hirqmask, hirqreg;
663   UINT16 cd_stat;
664   UINT32 cd_curfad;// = 0;
665   UINT32 fadstoplay;// = 0;
666   UINT32 in_buffer;// = 0;    // amount of data in the buffer
667   int oddframe;// = 0;
668   int buffull, sectorstore, freeblocks;
669   int cur_track;
670   UINT8 cmd_pending;
671   UINT8 cd_speed;
672   UINT8 cdda_maxrepeat;
673   UINT8 cdda_repeat_count;
674   UINT8 tray_is_closed;
675
676   direntryT curroot;       // root entry of current filesystem
677   direntryT *curdir;       // current directory
678   int numfiles;            // # of entries in current directory
679   int firstfile;           // first non-directory file
519680};
520681
521682#define MASTER_CLOCK_352 57272720
r20800r20801
552713
553714/*----------- defined in video/stvvdp1.c -----------*/
554715
555extern UINT16   **stv_framebuffer_display_lines;
556extern int stv_framebuffer_double_interlace;
557extern int stv_framebuffer_mode;
558extern UINT8* stv_vdp1_gfx_decode;
716//extern UINT16   **stv_framebuffer_display_lines;
717//extern int stv_framebuffer_double_interlace;
718//extern int stv_framebuffer_mode;
719//extern UINT8* stv_vdp1_gfx_decode;
559720
560int stv_vdp1_start ( running_machine &machine );
561void video_update_vdp1(running_machine &machine);
562void stv_vdp2_dynamic_res_change(running_machine &machine);
721//int stv_vdp1_start ( running_machine &machine );
722//void video_update_vdp1(running_machine &machine);
723//void stv_vdp2_dynamic_res_change(running_machine &machine);
563724
trunk/src/mame/video/stvvdp1.c
r20800r20801
826826why they would want to */
827827
828828
829static void (*drawpixel)(running_machine &machine, int x, int y, int patterndata, int offsetcnt);
830829
831static void drawpixel_poly(running_machine &machine, int x, int y, int patterndata, int offsetcnt)
830void saturn_state::drawpixel_poly(int x, int y, int patterndata, int offsetcnt)
832831{
833   saturn_state *state = machine.driver_data<saturn_state>();
834
835832   /* Capcom Collection Dai 4 uses a dummy polygon to clear VDP1 framebuffer that goes over our current max size ... */
836833   if(x >= 1024 || y >= 512)
837834      return;
838835
839   state->m_vdp1.framebuffer_draw_lines[y][x] = state->stv2_current_sprite.CMDCOLR;
836   m_vdp1.framebuffer_draw_lines[y][x] = stv2_current_sprite.CMDCOLR;
840837}
841838
842static void drawpixel_8bpp_trans(running_machine &machine, int x, int y, int patterndata, int offsetcnt)
839void saturn_state::drawpixel_8bpp_trans(int x, int y, int patterndata, int offsetcnt)
843840{
844   saturn_state *state = machine.driver_data<saturn_state>();
845841   UINT16 pix;
846842
847   pix = state->m_vdp1.gfx_decode[patterndata+offsetcnt];
843   pix = m_vdp1.gfx_decode[patterndata+offsetcnt];
848844   if ( pix & 0xff )
849845   {
850      state->m_vdp1.framebuffer_draw_lines[y][x] = pix | state->m_sprite_colorbank;
846      m_vdp1.framebuffer_draw_lines[y][x] = pix | m_sprite_colorbank;
851847   }
852848}
853849
854static void drawpixel_4bpp_notrans(running_machine &machine, int x, int y, int patterndata, int offsetcnt)
850void saturn_state::drawpixel_4bpp_notrans(int x, int y, int patterndata, int offsetcnt)
855851{
856   saturn_state *state = machine.driver_data<saturn_state>();
857852   UINT16 pix;
858853
859   pix = state->m_vdp1.gfx_decode[patterndata+offsetcnt/2];
854   pix = m_vdp1.gfx_decode[patterndata+offsetcnt/2];
860855   pix = offsetcnt&1 ? (pix & 0x0f):((pix & 0xf0)>>4) ;
861   state->m_vdp1.framebuffer_draw_lines[y][x] = pix | state->m_sprite_colorbank;
856   m_vdp1.framebuffer_draw_lines[y][x] = pix | m_sprite_colorbank;
862857}
863858
864static void drawpixel_4bpp_trans(running_machine &machine, int x, int y, int patterndata, int offsetcnt)
859void saturn_state::drawpixel_4bpp_trans(int x, int y, int patterndata, int offsetcnt)
865860{
866   saturn_state *state = machine.driver_data<saturn_state>();
867861   UINT16 pix;
868862
869   pix = state->m_vdp1.gfx_decode[patterndata+offsetcnt/2];
863   pix = m_vdp1.gfx_decode[patterndata+offsetcnt/2];
870864   pix = offsetcnt&1 ? (pix & 0x0f):((pix & 0xf0)>>4) ;
871865   if ( pix )
872      state->m_vdp1.framebuffer_draw_lines[y][x] = pix | state->m_sprite_colorbank;
866      m_vdp1.framebuffer_draw_lines[y][x] = pix | m_sprite_colorbank;
873867}
874868
875static void drawpixel_generic(running_machine &machine, int x, int y, int patterndata, int offsetcnt)
869void saturn_state::drawpixel_generic(int x, int y, int patterndata, int offsetcnt)
876870{
877   saturn_state *state = machine.driver_data<saturn_state>();
878   int pix,mode,transmask, spd = state->stv2_current_sprite.CMDPMOD & 0x40;
879   int mesh = state->stv2_current_sprite.CMDPMOD & 0x100;
871   int pix,mode,transmask, spd = stv2_current_sprite.CMDPMOD & 0x40;
872   int mesh = stv2_current_sprite.CMDPMOD & 0x100;
880873   int pix2;
881874
882875   if ( mesh && !((x ^ y) & 1) )
r20800r20801
884877      return;
885878   }
886879
887   if ( state->stv2_current_sprite.ispoly )
880   if ( stv2_current_sprite.ispoly )
888881   {
889      pix = state->stv2_current_sprite.CMDCOLR&0xffff;
882      pix = stv2_current_sprite.CMDCOLR&0xffff;
890883
891884      transmask = 0xffff;
892885      if ( pix & 0x8000 )
r20800r20801
900893   }
901894   else
902895   {
903      switch (state->stv2_current_sprite.CMDPMOD&0x0038)
896      switch (stv2_current_sprite.CMDPMOD&0x0038)
904897      {
905898         case 0x0000: // mode 0 16 colour bank mode (4bits) (hanagumi blocks)
906899            // most of the shienryu sprites use this mode
907            pix = state->m_vdp1.gfx_decode[(patterndata+offsetcnt/2) & 0xfffff];
900            pix = m_vdp1.gfx_decode[(patterndata+offsetcnt/2) & 0xfffff];
908901            pix = offsetcnt&1 ? (pix & 0x0f):((pix & 0xf0)>>4) ;
909            pix = pix+((state->stv2_current_sprite.CMDCOLR&0xfff0));
902            pix = pix+((stv2_current_sprite.CMDCOLR&0xfff0));
910903            mode = 0;
911904            transmask = 0xf;
912905            break;
913906         case 0x0008: // mode 1 16 colour lookup table mode (4bits)
914907            // shienryu explosisons (and some enemies) use this mode
915            pix2 = state->m_vdp1.gfx_decode[(patterndata+offsetcnt/2) & 0xfffff];
908            pix2 = m_vdp1.gfx_decode[(patterndata+offsetcnt/2) & 0xfffff];
916909            pix2 = offsetcnt&1 ?  (pix2 & 0x0f):((pix2 & 0xf0)>>4);
917910            pix = pix2&1 ?
918            ((((state->m_vdp1_vram[(((state->stv2_current_sprite.CMDCOLR&0xffff)*8)>>2)+((pix2&0xfffe)/2)])) & 0x0000ffff) >> 0):
919            ((((state->m_vdp1_vram[(((state->stv2_current_sprite.CMDCOLR&0xffff)*8)>>2)+((pix2&0xfffe)/2)])) & 0xffff0000) >> 16);
911            ((((m_vdp1_vram[(((stv2_current_sprite.CMDCOLR&0xffff)*8)>>2)+((pix2&0xfffe)/2)])) & 0x0000ffff) >> 0):
912            ((((m_vdp1_vram[(((stv2_current_sprite.CMDCOLR&0xffff)*8)>>2)+((pix2&0xfffe)/2)])) & 0xffff0000) >> 16);
920913
921914            mode = 5;
922915            transmask = 0xffff;
r20800r20801
934927            }
935928            break;
936929         case 0x0010: // mode 2 64 colour bank mode (8bits) (character select portraits on hanagumi)
937            pix = state->m_vdp1.gfx_decode[(patterndata+offsetcnt) & 0xfffff];
930            pix = m_vdp1.gfx_decode[(patterndata+offsetcnt) & 0xfffff];
938931            mode = 2;
939            pix = pix+(state->stv2_current_sprite.CMDCOLR&0xffc0);
932            pix = pix+(stv2_current_sprite.CMDCOLR&0xffc0);
940933            transmask = 0x3f;
941934            break;
942935         case 0x0018: // mode 3 128 colour bank mode (8bits) (little characters on hanagumi use this mode)
943            pix = state->m_vdp1.gfx_decode[(patterndata+offsetcnt) & 0xfffff];
944            pix = pix+(state->stv2_current_sprite.CMDCOLR&0xff80);
936            pix = m_vdp1.gfx_decode[(patterndata+offsetcnt) & 0xfffff];
937            pix = pix+(stv2_current_sprite.CMDCOLR&0xff80);
945938            transmask = 0x7f;
946939            mode = 3;
947940            break;
948941         case 0x0020: // mode 4 256 colour bank mode (8bits) (hanagumi title)
949            pix = state->m_vdp1.gfx_decode[(patterndata+offsetcnt) & 0xfffff];
950            pix = pix+(state->stv2_current_sprite.CMDCOLR&0xff00);
942            pix = m_vdp1.gfx_decode[(patterndata+offsetcnt) & 0xfffff];
943            pix = pix+(stv2_current_sprite.CMDCOLR&0xff00);
951944            transmask = 0xff;
952945            mode = 4;
953946            break;
954947         case 0x0028: // mode 5 32,768 colour RGB mode (16bits)
955            pix = state->m_vdp1.gfx_decode[(patterndata+offsetcnt*2+1) & 0xfffff] | (state->m_vdp1.gfx_decode[(patterndata+offsetcnt*2) & 0xfffff]<<8) ;
948            pix = m_vdp1.gfx_decode[(patterndata+offsetcnt*2+1) & 0xfffff] | (m_vdp1.gfx_decode[(patterndata+offsetcnt*2) & 0xfffff]<<8) ;
956949            mode = 5;
957950            transmask = -1; /* TODO: check me */
958951            break;
959952         default: // other settings illegal
960            pix = machine.rand();
953            pix = machine().rand();
961954            mode = 0;
962955            transmask = 0xff;
963956            popmessage("Illegal Sprite Mode, contact MAMEdev");
r20800r20801
965958
966959
967960      // preliminary end code disable support
968      if ( ((state->stv2_current_sprite.CMDPMOD & 0x80) == 0) &&
961      if ( ((stv2_current_sprite.CMDPMOD & 0x80) == 0) &&
969962         ((pix & transmask) == transmask) )
970963      {
971964         return;
r20800r20801
973966   }
974967
975968   /* MSBON */
976   pix |= state->stv2_current_sprite.CMDPMOD & 0x8000;
969   pix |= stv2_current_sprite.CMDPMOD & 0x8000;
977970   if ( mode != 5 )
978971   {
979972      if ( (pix & transmask) || spd )
980973      {
981         state->m_vdp1.framebuffer_draw_lines[y][x] = pix;
974         m_vdp1.framebuffer_draw_lines[y][x] = pix;
982975      }
983976   }
984977   else
985978   {
986979      if ( (pix & transmask) || spd )
987980      {
988         switch( state->stv2_current_sprite.CMDPMOD & 0x7 )
981         switch( stv2_current_sprite.CMDPMOD & 0x7 )
989982         {
990983            case 0: /* replace */
991               state->m_vdp1.framebuffer_draw_lines[y][x] = pix;
984               m_vdp1.framebuffer_draw_lines[y][x] = pix;
992985               break;
993986            case 1: /* shadow */
994               if ( state->m_vdp1.framebuffer_draw_lines[y][x] & 0x8000 )
987               if ( m_vdp1.framebuffer_draw_lines[y][x] & 0x8000 )
995988               {
996                  state->m_vdp1.framebuffer_draw_lines[y][x] = ((state->m_vdp1.framebuffer_draw_lines[y][x] & ~0x8421) >> 1) | 0x8000;
989                  m_vdp1.framebuffer_draw_lines[y][x] = ((m_vdp1.framebuffer_draw_lines[y][x] & ~0x8421) >> 1) | 0x8000;
997990               }
998991               break;
999992            case 2: /* half luminance */
1000               state->m_vdp1.framebuffer_draw_lines[y][x] = ((pix & ~0x8421) >> 1) | 0x8000;
993               m_vdp1.framebuffer_draw_lines[y][x] = ((pix & ~0x8421) >> 1) | 0x8000;
1001994               break;
1002995            case 3: /* half transparent */
1003               if ( state->m_vdp1.framebuffer_draw_lines[y][x] & 0x8000 )
996               if ( m_vdp1.framebuffer_draw_lines[y][x] & 0x8000 )
1004997               {
1005                  state->m_vdp1.framebuffer_draw_lines[y][x] = alpha_blend_r16( state->m_vdp1.framebuffer_draw_lines[y][x], pix, 0x80 ) | 0x8000;
998                  m_vdp1.framebuffer_draw_lines[y][x] = alpha_blend_r16( m_vdp1.framebuffer_draw_lines[y][x], pix, 0x80 ) | 0x8000;
1006999               }
10071000               else
10081001               {
1009                  state->m_vdp1.framebuffer_draw_lines[y][x] = pix;
1002                  m_vdp1.framebuffer_draw_lines[y][x] = pix;
10101003               }
10111004               break;
10121005            case 4: /* Gouraud shading */
1013               state->m_vdp1.framebuffer_draw_lines[y][x] = state->stv_vdp1_apply_gouraud_shading( x, y, pix );
1006               m_vdp1.framebuffer_draw_lines[y][x] = stv_vdp1_apply_gouraud_shading( x, y, pix );
10141007               break;
10151008            default:
1016               state->m_vdp1.framebuffer_draw_lines[y][x] = pix;
1009               m_vdp1.framebuffer_draw_lines[y][x] = pix;
10171010               break;
10181011         }
10191012      }
r20800r20801
10311024
10321025   if ( mesh || !ecd || ((stv2_current_sprite.CMDPMOD & 0x7) != 0) )
10331026   {
1034      drawpixel = drawpixel_generic;
1027      drawpixel = &saturn_state::drawpixel_generic;
10351028      return;
10361029   }
10371030
10381031   if (sprite_type == 4 && ((stv2_current_sprite.CMDPMOD & 0x7) == 0))
10391032   {
1040      drawpixel = drawpixel_poly;
1033      drawpixel = &saturn_state::drawpixel_poly;
10411034   }
10421035   else if ( (sprite_mode == 0x20) && !spd )
10431036   {
10441037      m_sprite_colorbank = (stv2_current_sprite.CMDCOLR&0xff00);
1045      drawpixel = drawpixel_8bpp_trans;
1038      drawpixel = &saturn_state::drawpixel_8bpp_trans;
10461039   }
10471040   else if ((sprite_mode == 0x00) && spd)
10481041   {
10491042      m_sprite_colorbank = (stv2_current_sprite.CMDCOLR&0xfff0);
1050      drawpixel = drawpixel_4bpp_notrans;
1043      drawpixel = &saturn_state::drawpixel_4bpp_notrans;
10511044   }
10521045   else if (sprite_mode == 0x00 && !spd )
10531046   {
10541047      m_sprite_colorbank = (stv2_current_sprite.CMDCOLR&0xfff0);
1055      drawpixel = drawpixel_4bpp_trans;
1048      drawpixel = &saturn_state::drawpixel_4bpp_trans;
10561049   }
10571050   else
10581051   {
1059      drawpixel = drawpixel_generic;
1052      drawpixel = &saturn_state::drawpixel_generic;
10601053   }
10611054}
10621055
r20800r20801
11511144               xx2 = cliprect.max_x;
11521145
11531146            while(xx1 <= xx2) {
1154               drawpixel(machine(),xx1,_y1,
1155                        patterndata,
1156                        (v>>FRAC_SHIFT)*xsize+(u>>FRAC_SHIFT));
1147               (this->*drawpixel)(xx1,_y1, patterndata, (v>>FRAC_SHIFT)*xsize+(u>>FRAC_SHIFT));
11571148               xx1++;
11581149               u += slux;
11591150               v += slvx;
r20800r20801
12051196         xx2 = cliprect.max_x;
12061197
12071198      while(xx1 <= xx2) {
1208         drawpixel(machine(), xx1,y,
1209                  patterndata,
1210                  (v>>FRAC_SHIFT)*xsize+(u>>FRAC_SHIFT));
1199         (this->*drawpixel)(xx1,y,patterndata,(v>>FRAC_SHIFT)*xsize+(u>>FRAC_SHIFT));
12111200         xx1++;
12121201         u += slux;
12131202         v += slvx;
r20800r20801
17251714      su = u;
17261715      for (drawxpos = x; drawxpos <= maxdrawxpos; drawxpos++ )
17271716      {
1728         drawpixel( machine(), drawxpos, drawypos, patterndata, u );
1717         (this->*drawpixel)( drawxpos, drawypos, patterndata, u );
17291718         u += dux;
17301719      }
17311720      u = su + duy;
trunk/src/mame/drivers/saturn.c
r20800r20801
781781//  AM_RANGE(0x02400000, 0x027fffff) AM_RAM //cart RAM area, dynamically allocated
782782//  AM_RANGE(0x04000000, 0x047fffff) AM_RAM //backup RAM area, dynamically allocated
783783   AM_RANGE(0x04fffffc, 0x04ffffff) AM_READ8(saturn_cart_type_r,0x000000ff)
784   AM_RANGE(0x05800000, 0x0589ffff) AM_READWRITE_LEGACY(stvcd_r, stvcd_w)
784   AM_RANGE(0x05800000, 0x0589ffff) AM_READWRITE(stvcd_r, stvcd_w)
785785   /* Sound */
786786   AM_RANGE(0x05a00000, 0x05a7ffff) AM_READWRITE16(saturn_soundram_r, saturn_soundram_w,0xffffffff)
787787   AM_RANGE(0x05b00000, 0x05b00fff) AM_DEVREADWRITE16_LEGACY("scsp", scsp_r, scsp_w, 0xffffffff)
r20800r20801
810810   AM_RANGE(0x01000000, 0x017fffff) AM_WRITE(minit_w)
811811   AM_RANGE(0x01800000, 0x01ffffff) AM_WRITE(sinit_w)
812812   AM_RANGE(0x02000000, 0x04ffffff) AM_ROM AM_SHARE("share7") AM_REGION("abus", 0) // cartridge
813   AM_RANGE(0x05800000, 0x0589ffff) AM_READWRITE_LEGACY(stvcd_r, stvcd_w)
813   AM_RANGE(0x05800000, 0x0589ffff) AM_READWRITE(stvcd_r, stvcd_w)
814814   /* Sound */
815815   AM_RANGE(0x05a00000, 0x05afffff) AM_READWRITE16(saturn_soundram_r, saturn_soundram_w,0xffffffff)
816816   AM_RANGE(0x05b00000, 0x05b00fff) AM_DEVREADWRITE16_LEGACY("scsp", scsp_r, scsp_w, 0xffffffff)
r20800r20801
930930INPUT_CHANGED_MEMBER(saturn_state::tray_open)
931931{
932932   if(newval)
933      stvcd_set_tray_open(machine());
933      stvcd_set_tray_open();
934934}
935935
936936INPUT_CHANGED_MEMBER(saturn_state::tray_close)
937937{
938938   if(newval)
939      stvcd_set_tray_close(machine());
939      stvcd_set_tray_close();
940940}
941941
942942static INPUT_PORTS_START( saturn )
r20800r20801
17971797
17981798   stv_register_protection_savestates(machine()); // machine/stvprot.c
17991799
1800   machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(stvcd_exit), &machine()));
1800   machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(saturn_state::stvcd_exit), this));
18011801
18021802   m_smpc.rtc_data[0] = DectoBCD(systime.local_time.year /100);
18031803   m_smpc.rtc_data[1] = DectoBCD(systime.local_time.year %100);
r20800r20801
18421842   state_save_register_global_array(machine(), m_smpc.SMEM);
18431843   state_save_register_global_pointer(machine(), m_cart_dram, 0x400000/4);
18441844
1845   machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(stvcd_exit), &machine()));
1845   machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(saturn_state::stvcd_exit), this));
18461846
18471847   m_smpc.rtc_data[0] = DectoBCD(systime.local_time.year /100);
18481848   m_smpc.rtc_data[1] = DectoBCD(systime.local_time.year %100);
r20800r20801
20622062   machine().device("maincpu")->set_unscaled_clock(MASTER_CLOCK_320/2);
20632063   machine().device("slave")->set_unscaled_clock(MASTER_CLOCK_320/2);
20642064
2065   stvcd_reset( machine() );
2065   stvcd_reset();
20662066
20672067   m_cart_type = ioport("CART_AREA")->read() & 7;
20682068
r20800r20801
21382138   machine().device("maincpu")->set_unscaled_clock(MASTER_CLOCK_320/2);
21392139   machine().device("slave")->set_unscaled_clock(MASTER_CLOCK_320/2);
21402140
2141   stvcd_reset(machine());
2141   stvcd_reset();
21422142
21432143   m_stv_rtc_timer->adjust(attotime::zero, 0, attotime::from_seconds(1));
21442144   m_prev_bankswitch = 0xff;
r20800r20801
22132213
22142214   MCFG_NVRAM_HANDLER(saturn)
22152215
2216   MCFG_TIMER_ADD("sector_timer", stv_sector_cb)
2217   MCFG_TIMER_ADD("sh1_cmd", stv_sh1_sim)
2216   MCFG_TIMER_DRIVER_ADD("sector_timer", saturn_state, stv_sector_cb)
2217   MCFG_TIMER_DRIVER_ADD("sh1_cmd", saturn_state, stv_sh1_sim)
22182218
22192219   /* video hardware */
22202220   MCFG_SCREEN_ADD("screen", RASTER)
r20800r20801
22962296
22972297   MCFG_EEPROM_93C46_ADD("eeprom") /* Actually 93c45 */
22982298
2299   MCFG_TIMER_ADD("sector_timer", stv_sector_cb)
2300   MCFG_TIMER_ADD("sh1_cmd", stv_sh1_sim)
2299   MCFG_TIMER_DRIVER_ADD("sector_timer", saturn_state, stv_sector_cb)
2300   MCFG_TIMER_DRIVER_ADD("sh1_cmd", saturn_state, stv_sh1_sim)
23012301
23022302   /* video hardware */
23032303   MCFG_VIDEO_ATTRIBUTES(VIDEO_UPDATE_AFTER_VBLANK)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team