Previous 15994 Revisions Next

r7925 Wednesday 28th April, 2010 at 13:29:34 UTC by Angelo Salese
[DC]: Updated to the latest source tree, added idle skip to the Dreamcast US BIOS
[src/mame/machine]dc.c
[src/mame/video]dc.c
[src/mess/drivers]dc.c

src/mame/machine/dc.c
r7924r7925
2020#define DEBUG_MAPLE   (0)
2121#define DEBUG_MAPLE_REGS   (0)
2222#define DEBUG_AICA_DMA (0)
23#define DEBUG_PVRCTRL   (0)
2324
24#define ENABLE_MAPLE_IRQ (0)
25static UINT8 mp_mux_data;
2526
2627#if DEBUG_SYSCTRL
2728static const char *const sysctrl_names[] =
r7924r7925
165166   0x05200083,0x5245544e,0x53495250,0x43205345,0x544c2c4f,0x20202e44,0x38393931,0x5c525043
166167};
167168
169static struct {
170   UINT32 aica_addr;
171   UINT32 root_addr;
172   UINT32 size;
173   UINT8 dir;
174   UINT8 flag;
175   UINT8 indirect;
176   UINT8 start;
177   UINT8 sel;
178}wave_dma;
179
180static struct {
181   UINT32 pvr_addr;
182   UINT32 sys_addr;
183   UINT32 size;
184   UINT8 sel;
185   UINT8 dir;
186   UINT8 flag;
187   UINT8 start;
188}pvr_dma;
189
190static TIMER_CALLBACK( aica_dma_irq )
191{
192   wave_dma.start = g2bus_regs[SB_ADST] = 0;
193   dc_sysctrl_regs[SB_ISTNRM] |= IST_DMA_AICA;
194   dc_update_interrupt_status(machine);
195}
196
197static TIMER_CALLBACK( pvr_dma_irq )
198{
199   pvr_dma.start = pvrctrl_regs[SB_PDST] = 0;
200   dc_sysctrl_regs[SB_ISTNRM] |= IST_DMA_PVR;
201   dc_update_interrupt_status(machine);
202}
203
204static TIMER_CALLBACK( gdrom_dma_irq )
205{
206   g1bus_regs[SB_GDST] = 0;
207   dc_sysctrl_regs[SB_ISTNRM] |= IST_DMA_GDROM;
208   dc_update_interrupt_status(machine);
209}
210
211static TIMER_CALLBACK( maple_dma_irq )
212{
213   maple_regs[SB_MDST] = 0;
214   dc_sysctrl_regs[SB_ISTNRM] |= IST_DMA_MAPLE;
215   dc_update_interrupt_status(machine);
216}
217
218static void wave_dma_execute(const address_space *space)
219{
220   UINT32 src,dst,size;
221   dst = wave_dma.aica_addr;
222   src = wave_dma.root_addr;
223   size = 0;
224
225   /* 0 rounding size = 32 Mbytes */
226   if(wave_dma.size == 0) { wave_dma.size = 0x200000; }
227
228   if(wave_dma.dir == 0)
229   {
230      for(;size<wave_dma.size;size+=4)
231      {
232         memory_write_dword_64le(space,dst,memory_read_dword(space,src));
233         src+=4;
234         dst+=4;
235      }
236   }
237   else
238   {
239      for(;size<wave_dma.size;size+=4)
240      {
241         memory_write_dword_64le(space,src,memory_read_dword(space,dst));
242         src+=4;
243         dst+=4;
244      }
245   }
246
247   /* update the params*/
248   wave_dma.aica_addr = g2bus_regs[SB_ADSTAG] = dst;
249   wave_dma.root_addr = g2bus_regs[SB_ADSTAR] = src;
250   wave_dma.size = g2bus_regs[SB_ADLEN] = 0;
251   wave_dma.flag = (wave_dma.indirect & 1) ? 1 : 0;
252   /* Note: if you trigger an instant DMA IRQ trigger, sfz3upper doesn't play any bgm. */
253   /* TODO: timing of this */
254   timer_set(space->machine, ATTOTIME_IN_USEC(300), NULL, 0, aica_dma_irq);
255}
256
257static void pvr_dma_execute(const address_space *space)
258{
259   UINT32 src,dst,size;
260   dst = pvr_dma.pvr_addr;
261   src = pvr_dma.sys_addr;
262   size = 0;
263
264   /* used so far by usagui and sprtjam*/
265   //printf("PVR-DMA start\n");
266   //printf("%08x %08x %08x\n",pvr_dma.pvr_addr,pvr_dma.sys_addr,pvr_dma.size);
267   //printf("src %s dst %08x\n",pvr_dma.dir ? "->" : "<-",pvr_dma.sel);
268
269   /* 0 rounding size = 16 Mbytes */
270   if(pvr_dma.size == 0) { pvr_dma.size = 0x100000; }
271
272   if(pvr_dma.dir == 0)
273   {
274      for(;size<pvr_dma.size;size+=4)
275      {
276         memory_write_dword_64le(space,dst,memory_read_dword(space,src));
277         src+=4;
278         dst+=4;
279      }
280   }
281   else
282   {
283      for(;size<pvr_dma.size;size+=4)
284      {
285         memory_write_dword_64le(space,src,memory_read_dword(space,dst));
286         src+=4;
287         dst+=4;
288      }
289   }
290   /* Note: do not update the params, since this DMA type doesn't support it. */
291   /* TODO: timing of this */
292   timer_set(space->machine, ATTOTIME_IN_USEC(250), NULL, 0, pvr_dma_irq);
293}
294
168295// register decode helpers
169296
170297// this accepts only 32-bit accesses
r7924r7925
247374
248375void dc_update_interrupt_status(running_machine *machine)
249376{
250int level;
377   int level;
251378
252379   if (dc_sysctrl_regs[SB_ISTERR])
253380   {
r7924r7925
269396
270397   level=dc_compute_interrupt_level(machine);
271398   sh4_set_irln_input(devtag_get_device(machine, "maincpu"), 15-level);
399
400   /* Wave DMA HW trigger */
401   if(wave_dma.flag && ((wave_dma.sel & 2) == 2))
402   {
403      if((dc_sysctrl_regs[SB_G2DTNRM] & dc_sysctrl_regs[SB_ISTNRM]) || (dc_sysctrl_regs[SB_G2DTEXT] & dc_sysctrl_regs[SB_ISTEXT]))
404      {
405         const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
406
407         printf("Wave DMA HW trigger\n");
408         wave_dma_execute(space);
409      }
410   }
411
412   /* PVR-DMA HW trigger */
413   if(pvr_dma.flag && ((pvr_dma.sel & 1) == 1))
414   {
415      if((dc_sysctrl_regs[SB_PDTNRM] & dc_sysctrl_regs[SB_ISTNRM]) || (dc_sysctrl_regs[SB_PDTEXT] & dc_sysctrl_regs[SB_ISTEXT]))
416      {
417         const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
418
419         printf("PVR-DMA HW trigger\n");
420         pvr_dma_execute(space);
421      }
422   }
272423}
273424
274425/******************************************************
r7924r7925
279430[2] Parameter of the device
280431[3] End flag (always zero)
281432******************************************************/
282static int jvs_mux_data;
283
284433static int jvsboard_init(int pos)
285434{
286435   // four bytes for every available function
r7924r7925
290439   {
291440      maple0x86data2[pos+11]=1; // number of players
292441      maple0x86data2[pos+12]=22; // switches per player (27 = mahjong)
293      jvs_mux_data = 1;
294442   }
295443   else //if JVSBD_DEFAULT
296444   {
r7924r7925
334482   if(jvsboard_type == JVSBD_MAHJONG)
335483   {
336484      maple0x86data2[pos+11]=0;
337      switch(jvs_mux_data)
485      switch(mp_mux_data)
338486      {
339         case 0x01: maple0x86data2[pos+12]=input_port_read(machine, "IN1"); break;
340         case 0x02: maple0x86data2[pos+12]=input_port_read(machine, "IN2"); break;
341         case 0x04: maple0x86data2[pos+12]=input_port_read(machine, "IN3"); break;
342         case 0x08: maple0x86data2[pos+12]=input_port_read(machine, "IN4"); break;
343         case 0x10: maple0x86data2[pos+12]=0; break;
487         case 0x01: maple0x86data2[pos+12]=input_port_read(machine, "KEY1"); break;
488         case 0x02: maple0x86data2[pos+12]=input_port_read(machine, "KEY2"); break;
489         case 0x04: maple0x86data2[pos+12]=input_port_read(machine, "KEY3"); break;
490         case 0x08: maple0x86data2[pos+12]=input_port_read(machine, "KEY4"); break;
491         case 0x10: maple0x86data2[pos+12]=input_port_read(machine, "KEY5"); break;
344492      }
345493      maple0x86data2[pos+13]=0;
346494      maple0x86data2[pos+14]=0;
347495
348      jvs_mux_data<<=1;
349      if(jvs_mux_data >= 0x20) { jvs_mux_data = 1; }
496      mp_mux_data<<=1;
497      if(mp_mux_data >= 0x20) { mp_mux_data = 1; }
350498   }
351499   else
352500   {
r7924r7925
403551      maple0x86data2[0x1b]=2; //number of players
404552   if(jvsboard_type == JVSBD_MAHJONG)
405553   {
406      maple0x86data2[0x1c]=input_port_read(machine, "IN1");
407      maple0x86data2[0x1d]=input_port_read(machine, "IN2");
408      maple0x86data2[0x1e]=input_port_read(machine, "IN3");
409      maple0x86data2[0x1f]=input_port_read(machine, "IN4");
554      maple0x86data2[0x1c]=0;
555      switch(mp_mux_data)
556      {
557         case 0x01: maple0x86data2[0x1d]=input_port_read(machine, "KEY1"); break;
558         case 0x02: maple0x86data2[0x1d]=input_port_read(machine, "KEY2"); break;
559         case 0x04: maple0x86data2[0x1d]=input_port_read(machine, "KEY3"); break;
560         case 0x08: maple0x86data2[0x1d]=input_port_read(machine, "KEY4"); break;
561         case 0x10: maple0x86data2[0x1d]=input_port_read(machine, "KEY5"); break;
562      }
563      maple0x86data2[0x1e]=0;
564      maple0x86data2[0x1f]=0;
565
566      mp_mux_data<<=1;
567      if(mp_mux_data >= 0x20) { mp_mux_data = 1; }
410568   }
411569   else
412570   {
r7924r7925
478636         address=dc_sysctrl_regs[SB_C2DSTAT];
479637         ddtdata.destination=address;
480638         /* 0 rounding size = 16 Mbytes */
481         if(dc_sysctrl_regs[SB_C2DLEN] == 0) { dc_sysctrl_regs[SB_C2DLEN] = 0x1000000; }
482         ddtdata.length=dc_sysctrl_regs[SB_C2DLEN];
639         if(dc_sysctrl_regs[SB_C2DLEN] == 0)
640            ddtdata.length = 0x1000000;
641         else
642            ddtdata.length = dc_sysctrl_regs[SB_C2DLEN];
483643         ddtdata.size=1;
484644         ddtdata.direction=0;
485645         ddtdata.channel=2;
r7924r7925
529689         dc_sysctrl_regs[SB_ISTERR] = old & ~dat;
530690         break;
531691      case SB_SDST:
532         #if DEBUG_SYSCTRL
533         mame_printf_verbose("SYSCTRL: Sort-DMA not supported yet !!!\n");
534         #endif
692         //#if DEBUG_SYSCTRL
693         //mame_printf_verbose("SYSCTRL: Sort-DMA not supported yet !!!\n");
694         //#endif
695         if(dat & 1)
696         {
697            // TODO: Sort-DMA routine goes here
698            printf("Sort-DMA irq\n");
699
700            dc_sysctrl_regs[SB_ISTNRM] |= IST_DMA_SORT;
701            dc_sysctrl_regs[SB_SDST] = 0;
702         }
535703         break;
536704   }
537705   dc_update_interrupt_status(space->machine);
r7924r7925
583751   maple_regs[reg] = dat; // 5f6c00+reg*4=dat
584752   switch (reg)
585753   {
754   case SB_MDTSEL:
755      if((dat & 1) == 1)
756         printf("MAPLE: hardware trigger not supported yet\n");
757      break;
586758   case SB_MDST:
587      maple_regs[reg] = old;
759      maple_regs[SB_MDST] = old;
588760      if (!(old & 1) && (dat & 1) && maple_regs[SB_MDEN] & 1) // 0 -> 1
589761      {
590         if (!(maple_regs[SB_MDTSEL] & 1))
762         if (!(maple_regs[SB_MDTSEL] & 1)) // SW trigger
591763         {
592            maple_regs[reg] = 1;
764            maple_regs[SB_MDST] = dat & 1;
593765            dat=maple_regs[SB_MDSTAR];
594766//              printf("Maple DMA: %08x %08x %08x %08x\n",maple_regs[SB_MDSTAR],maple_regs[SB_MDTSEL],maple_regs[SB_MDEN],maple_regs[SB_MDST]);
595767//              printf("           %08x %08x %08x %08x\n",maple_regs[SB_MSYS],maple_regs[SB_MST],maple_regs[SB_MSHTCL],maple_regs[SB_MMSEL]);
r7924r7925
604776               ddtdata.mode= -1;      // copy from/to buffer
605777               sh4_dma_ddt(devtag_get_device(space->machine, "maincpu"), &ddtdata);
606778
607               maple_regs[reg] = 0;
608779               endflag=buff[0] & 0x80000000;
609780               port=(buff[0] >> 16) & 3;
610781               pattern=(buff[0] >> 8) & 7;
r7924r7925
632803                     case 3:
633804                        ddtdata.length=1;
634805                        #if DEBUG_MAPLE
806                        if(port == 0)
635807                        printf("MAPLE: transfer command %x port %x length %x\n", command, port, length);
636808                        #endif
637809                        break;
r7924r7925
764936                                 case 0x14:
765937                                    {
766938                                       tocopy += jvsboard_init(pos);
939
940                                       //TODO: something sets 0 in the mux data, dunno what yet
941                                       if(jvsboard_type == JVSBD_MAHJONG)
942                                          mp_mux_data = 1;
767943                                    }
768944                                    break;
769945                                 case 0x21:
r7924r7925
8711047
8721048               if (endflag)
8731049               {
874                  #if 1 //ENABLE_MAPLE_IRQ
875                  /*TODO: this fixes moeru but breaks other games, understand why.*/
876                  dc_sysctrl_regs[SB_ISTNRM] |= IST_DMA_MAPLE;
877                  dc_update_interrupt_status(space->machine);
878                  #endif
1050                  timer_set(space->machine, ATTOTIME_IN_USEC(200), NULL, 0, maple_dma_irq);
8791051                  break;
8801052               }
8811053               // skip fixed packet header
r7924r7925
8831055               // skip transfer data
8841056               dat += (length + 1) * 4;
8851057            } // do transfers
886            maple_regs[reg] = 0;
1058
8871059         }
888         else
889         {
890            #if DEBUG_MAPLE
891            printf("MAPLE: hardware trigger not supported yet\n");
892            #endif
893         }
1060
8941061      }
8951062      break;
8961063   }
r7924r7925
9301097   maple_regs[reg] = dat; // 5f6c00+reg*4=dat
9311098   switch (reg)
9321099   {
1100   case SB_MDTSEL:
1101      if((dat & 1) == 1)
1102         printf("MAPLE: hardware trigger not supported yet\n");
1103      break;
9331104   case SB_MDST:
934      maple_regs[reg] = old;
1105      maple_regs[SB_MDST] = old;
9351106      if (!(old & 1) && (dat & 1) && maple_regs[SB_MDEN] & 1) // 0 -> 1
9361107      {
9371108         if (!(maple_regs[SB_MDTSEL] & 1))
9381109         {
939            maple_regs[reg] = 1;
1110            maple_regs[SB_MDST] = dat & 1;
9401111            dat=maple_regs[SB_MDSTAR];
9411112//              printf("Maple DMA: %08x %08x %08x %08x\n",maple_regs[SB_MDSTAR],maple_regs[SB_MDTSEL],maple_regs[SB_MDEN],maple_regs[SB_MDST]);
9421113//              printf("           %08x %08x %08x %08x\n",maple_regs[SB_MSYS],maple_regs[SB_MST],maple_regs[SB_MSHTCL],maple_regs[SB_MMSEL]);
r7924r7925
9511122               ddtdata.mode= -1;      // copy from/to buffer
9521123               sh4_dma_ddt(devtag_get_device(space->machine, "maincpu"), &ddtdata);
9531124
954               maple_regs[reg] = 0;
9551125               endflag=buff[0] & 0x80000000;
9561126               port=(buff[0] >> 16) & 3;
9571127               pattern=(buff[0] >> 8) & 7;
r7924r7925
10261196
10271197               if (endflag)
10281198               {
1029                  #if ENABLE_MAPLE_IRQ
1030                  dc_sysctrl_regs[SB_ISTNRM] |= IST_DMA_MAPLE;
1031                  dc_update_interrupt_status(space->machine);
1032                  #endif
1199                  timer_set(space->machine, ATTOTIME_IN_USEC(200), NULL, 0, maple_dma_irq);
10331200                  break;
10341201               }
10351202               // skip fixed packet header
r7924r7925
10371204               // skip transfer data
10381205               dat += (length + 1) * 4;
10391206            } // do transfers
1040            maple_regs[reg] = 0;
1207
10411208         }
1042         else
1043         {
1044            #if DEBUG_MAPLE
1045            printf("MAPLE: hardware trigger not supported yet\n");
1046            #endif
1047         }
10481209      }
10491210      break;
10501211   }
r7924r7925
11261287   switch (reg)
11271288   {
11281289   case SB_GDST:
1129      if (dat & 1 && g1bus_regs[SB_GDEN] == 1) // 0 -> 1
1290      g1bus_regs[SB_GDST] = old;
1291      if (((old & 1) == 0) && (dat & 1) && g1bus_regs[SB_GDEN] == 1) // 0 -> 1
11301292      {
11311293         if (g1bus_regs[SB_GDDIR] == 0)
11321294         {
1133            mame_printf_verbose("G1CTRL: unsupported transfer\n");
1295            printf("G1CTRL: unsupported transfer\n");
11341296            return;
11351297         }
1298         g1bus_regs[SB_GDST] = dat & 1;
11361299//          printf("ROM board DMA to %x len %x (PC %x)\n", g1bus_regs[SB_GDSTAR], g1bus_regs[SB_GDLEN], cpu_get_pc(space->cpu));
11371300         ROM = (UINT8 *)space->machine->device("rom_board")->get_runtime_ptr(DEVINFO_PTR_MEMORY);
11381301         dmaoffset = (UINT32)space->machine->device("rom_board")->get_runtime_int(DEVINFO_INT_DMAOFFSET);
11391302         ddtdata.destination=g1bus_regs[SB_GDSTAR];      // destination address
11401303         ddtdata.length=g1bus_regs[SB_GDLEN] >> 5;      // words to transfer
1304         /* data in the lower 5 bits makes the length size to round by 32 bytes, this'll be needed by Virtua Tennis to boot (according to Deunan) */
1305         if(g1bus_regs[SB_GDLEN] & 0x1c)
1306            ddtdata.length++;
1307
11411308         ddtdata.size=32;         // bytes per word
11421309         ddtdata.buffer=ROM+dmaoffset;   // buffer address
11431310         ddtdata.direction=1;   // 0 source to buffer, 1 buffer to destination
r7924r7925
11451312         ddtdata.mode= -1;      // copy from/to buffer
11461313         mame_printf_verbose("G1CTRL: transfer %x from ROM %08x to sdram %08x\n", g1bus_regs[SB_GDLEN], dmaoffset, g1bus_regs[SB_GDSTAR]);
11471314         sh4_dma_ddt(devtag_get_device(space->machine, "maincpu"), &ddtdata);
1148         g1bus_regs[SB_GDST]=0;
1149         dc_sysctrl_regs[SB_ISTNRM] |= IST_DMA_GDROM;
1150         dc_update_interrupt_status(space->machine);
1315         /* Note: KOF Neowave definitely wants this to be delayed (!) */
1316         /* FIXME: timing of this */
1317         timer_set(space->machine, ATTOTIME_IN_USEC(500), NULL, 0, gdrom_dma_irq);
11511318      }
11521319      break;
11531320   }
r7924r7925
11681335   int reg;
11691336   UINT64 shift;
11701337   UINT32 dat;
1171   static struct {
1172      UINT32 aica_addr;
1173      UINT32 root_addr;
1174      UINT32 size;
1175      UINT8 dir;
1176      UINT8 flag;
1177      UINT8 indirect;
1178      UINT8 start;
1179      UINT8 sel;
1180   }wave_dma;
1338   UINT8 old;
11811339
11821340   reg = decode_reg32_64(space->machine, offset, mem_mask, &shift);
11831341   dat = (UINT32)(data >> shift);
r7924r7925
11991357      case SB_ADDIR: wave_dma.dir = (dat & 1); break;
12001358      /*dma flag (active HIGH, bug in docs)*/
12011359      case SB_ADEN: wave_dma.flag = (dat & 1); break;
1360      /*
1361      SB_ADTSEL
1362      bit 1: (0) Wave DMA thru SB_ADST flag (1) Wave DMA thru irq trigger, defined by SB_G2DTNRM / SB_G2DTEXT
1363      */
12021364      case SB_ADTSEL: wave_dma.sel = dat & 7; break;
12031365      /*ready for dma'ing*/
12041366      case SB_ADST:
1367         old = wave_dma.start & 1;
12051368         wave_dma.start = dat & 1;
12061369
12071370         #if DEBUG_AICA_DMA
r7924r7925
12111374         #endif
12121375
12131376         //mame_printf_verbose("SB_ADST data %08x\n",dat);
1214         if(wave_dma.flag && wave_dma.start)
1215         {
1216            UINT32 src,dst,size;
1217            dst = wave_dma.aica_addr;
1218            src = wave_dma.root_addr;
1219            size = 0;
1220            /* 0 rounding size = 32 Mbytes */
1221            if(wave_dma.size == 0) { wave_dma.size = 0x200000; }
1222
1223            if(wave_dma.dir == 0)
1224            {
1225               for(;size<wave_dma.size;size+=4)
1226               {
1227                  memory_write_dword_64le(space,dst,memory_read_dword(space,src));
1228                  src+=4;
1229                  dst+=4;
1230               }
1231            }
1232            else
1233            {
1234               for(;size<wave_dma.size;size+=4)
1235               {
1236                  memory_write_dword_64le(space,src,memory_read_dword(space,dst));
1237                  src+=4;
1238                  dst+=4;
1239               }
1240            }
1241            /* update the params*/
1242            wave_dma.aica_addr = g2bus_regs[SB_ADSTAG] = dst;
1243            wave_dma.root_addr = g2bus_regs[SB_ADSTAR] = src;
1244            wave_dma.size = g2bus_regs[SB_ADLEN] = 0;
1245            wave_dma.flag = (wave_dma.indirect & 1) ? 1 : 0;
1246            wave_dma.start = g2bus_regs[SB_ADST] = 0;
1247            /*TODO: this makes the sfz3upper to not play any bgm, understand why. */
1248            //dc_sysctrl_regs[SB_ISTNRM] |= IST_DMA_AICA;
1249            //dc_update_interrupt_status(space->machine);
1250         }
1377         if(((old & 1) == 0) && wave_dma.flag && wave_dma.start && ((wave_dma.sel & 2) == 0)) // 0 -> 1
1378            wave_dma_execute(space);
12511379         break;
12521380
12531381      case SB_ADSUSP:
r7924r7925
12641392   }
12651393}
12661394
1395INLINE int decode_reg_64(UINT32 offset, UINT64 mem_mask, UINT64 *shift)
1396{
1397   int reg = offset * 2;
1398
1399   *shift = 0;
1400
1401   // non 32-bit accesses have not yet been seen here, we need to know when they are
1402   if ((mem_mask != U64(0xffffffff00000000)) && (mem_mask != U64(0x00000000ffffffff)))
1403   {
1404      /*assume to return the lower 32-bits ONLY*/
1405      return reg & 0xffffffff;
1406   }
1407
1408   if (mem_mask == U64(0xffffffff00000000))
1409   {
1410      reg++;
1411      *shift = 32;
1412   }
1413
1414   return reg;
1415}
1416
1417READ64_HANDLER( pvr_ctrl_r )
1418{
1419   int reg;
1420   UINT64 shift;
1421
1422   reg = decode_reg_64(offset, mem_mask, &shift);
1423
1424   #if DEBUG_PVRCTRL
1425   mame_printf_verbose("PVRCTRL: [%08x] read %x @ %x (reg %x), mask %" I64FMT "x (PC=%x)\n", 0x5f7c00+reg*4, pvrctrl_regs[reg], offset, reg, mem_mask, cpu_get_pc(space->cpu));
1426   #endif
1427
1428   return (UINT64)pvrctrl_regs[reg] << shift;
1429}
1430
1431WRITE64_HANDLER( pvr_ctrl_w )
1432{
1433   int reg;
1434   UINT64 shift;
1435   UINT32 dat;
1436   UINT8 old;
1437
1438   reg = decode_reg_64(offset, mem_mask, &shift);
1439   dat = (UINT32)(data >> shift);
1440
1441   switch (reg)
1442   {
1443      case SB_PDSTAP: pvr_dma.pvr_addr = dat; break;
1444      case SB_PDSTAR: pvr_dma.sys_addr = dat; break;
1445      case SB_PDLEN: pvr_dma.size = dat; break;
1446      case SB_PDDIR: pvr_dma.dir = dat & 1; break;
1447      case SB_PDTSEL:
1448         pvr_dma.sel = dat & 1;
1449         //if(pvr_dma.sel & 1)
1450         //   printf("Warning: Unsupported irq mode trigger PVR-DMA\n");
1451         break;
1452      case SB_PDEN: pvr_dma.flag = dat & 1; break;
1453      case SB_PDST:
1454         old = pvr_dma.start & 1;
1455         pvr_dma.start = dat & 1;
1456
1457         if(((old & 1) == 0) && pvr_dma.flag && pvr_dma.start && ((pvr_dma.sel & 1) == 0)) // 0 -> 1
1458            pvr_dma_execute(space);
1459         break;
1460   }
1461
1462   #if DEBUG_PVRCTRL
1463   mame_printf_verbose("PVRCTRL: [%08x=%x] write %" I64FMT "x to %x (reg %x), mask %" I64FMT "x\n", 0x5f7c00+reg*4, dat, data>>shift, offset, reg, mem_mask);
1464   #endif
1465
1466//  pvrctrl_regs[reg] |= dat;
1467   pvrctrl_regs[reg] = dat;
1468
1469}
1470
12671471READ64_HANDLER( dc_modem_r )
12681472{
12691473   int reg;
r7924r7925
13591563   timer_adjust_periodic(dc_rtc_timer, attotime_zero, 0, ATTOTIME_IN_SEC(1));
13601564
13611565   dc_sysctrl_regs[SB_SBREV] = 0x0b;
1566
1567   mp_mux_data = 0;
13621568}
13631569
13641570READ64_DEVICE_HANDLER( dc_aica_reg_r )
src/mame/video/dc.c
r7924r7925
1313
1414static int vblc=0;
1515#define DEBUG_FIFO_POLY (0)
16#define DEBUG_PVRCTRL   (0)
1716#define DEBUG_PVRTA   (0)
1817#define DEBUG_PVRTA_REGS (0)
1918#define DEBUG_PVRDLIST   (1)
r7924r7925
112111#define vo_vert_start_pos_f2 ((pvrta_regs[VO_STARTY] & 0x03ff0000) >> 16)
113112#define vo_vert_start_pos_f1 ((pvrta_regs[VO_STARTY] & 0x000003ff) >> 0)
114113
114/*
115SPG_STATUS
116---- ---- ---- ---- --x- ---- ---- ---- vsync
117---- ---- ---- ---- ---x ---- ---- ---- hsync
118---- ---- ---- ---- ---- x--- ---- ---- blank
119---- ---- ---- ---- ---- -x-- ---- ---- field number
120---- ---- ---- ---- ---- --xx xxxx xxxx scanline
121*/
115122
116
117123UINT32 pvrctrl_regs[0x100/4];
118124static UINT32 pvrta_regs[0x2000/4];
119125static const int pvr_parconfseq[] = {1,2,3,2,3,4,5,6,5,6,7,8,9,10,11,12,13,14,13,14,15,16,17,16,17,0,0,0,0,0,18,19,20,19,20,21,22,23,22,23};
r7924r7925
975981   return reg;
976982}
977983
978READ64_HANDLER( pvr_ctrl_r )
979{
980   int reg;
981   UINT64 shift;
982
983   reg = decode_reg_64(offset, mem_mask, &shift);
984
985   #if DEBUG_PVRCTRL
986   mame_printf_verbose("PVRCTRL: [%08x] read %x @ %x (reg %x), mask %" I64FMT "x (PC=%x)\n", 0x5f7c00+reg*4, pvrctrl_regs[reg], offset, reg, mem_mask, cpu_get_pc(space->cpu));
987   #endif
988
989   return (UINT64)pvrctrl_regs[reg] << shift;
990}
991
992WRITE64_HANDLER( pvr_ctrl_w )
993{
994   int reg;
995   UINT64 shift;
996   UINT32 dat;
997   static struct {
998      UINT32 pvr_addr;
999      UINT32 sys_addr;
1000      UINT32 size;
1001      UINT8 sel;
1002      UINT8 dir;
1003      UINT8 flag;
1004      UINT8 start;
1005   }pvr_dma;
1006
1007   reg = decode_reg_64(offset, mem_mask, &shift);
1008   dat = (UINT32)(data >> shift);
1009
1010   switch (reg)
1011   {
1012      case SB_PDSTAP: pvr_dma.pvr_addr = dat; break;
1013      case SB_PDSTAR: pvr_dma.sys_addr = dat; break;
1014      case SB_PDLEN: pvr_dma.size = dat; break;
1015      case SB_PDDIR: pvr_dma.dir = dat & 1; break;
1016      case SB_PDTSEL:
1017         pvr_dma.sel = dat & 1;
1018         if(pvr_dma.sel & 1)
1019            printf("Warning: Unsupported irq mode trigger PVR-DMA\n");
1020         break;
1021      case SB_PDEN: pvr_dma.flag = dat & 1; break;
1022      case SB_PDST:
1023         pvr_dma.start = dat & 1;
1024
1025         if(pvr_dma.flag && pvr_dma.start)
1026         {
1027            UINT32 src,dst,size;
1028            dst = pvr_dma.pvr_addr;
1029            src = pvr_dma.sys_addr;
1030            size = 0;
1031
1032            /* used by usagui and sprtjam*/
1033            printf("PVR-DMA start\n");
1034            printf("%08x %08x %08x\n",pvr_dma.pvr_addr,pvr_dma.sys_addr,pvr_dma.size);
1035            printf("src %s dst %08x\n",pvr_dma.dir ? "->" : "<-",pvr_dma.sel);
1036
1037            /* 0 rounding size = 16 Mbytes */
1038            if(pvr_dma.size == 0) { pvr_dma.size = 0x100000; }
1039
1040            if(pvr_dma.dir == 0)
1041            {
1042               for(;size<pvr_dma.size;size+=4)
1043               {
1044                  memory_write_dword_64le(space,dst,memory_read_dword(space,src));
1045                  src+=4;
1046                  dst+=4;
1047               }
1048            }
1049            else
1050            {
1051               for(;size<pvr_dma.size;size+=4)
1052               {
1053                  memory_write_dword_64le(space,src,memory_read_dword(space,dst));
1054                  src+=4;
1055                  dst+=4;
1056               }
1057            }
1058            /*Note: do not update the params, since this DMA type doesn't support it. */
1059
1060            dc_sysctrl_regs[SB_ISTNRM] |= IST_DMA_PVR;
1061            dc_update_interrupt_status(space->machine);
1062         }
1063         break;
1064   }
1065
1066   #if DEBUG_PVRCTRL
1067   mame_printf_verbose("PVRCTRL: [%08x=%x] write %" I64FMT "x to %x (reg %x), mask %" I64FMT "x\n", 0x5f7c00+reg*4, dat, data>>shift, offset, reg, mem_mask);
1068   #endif
1069
1070//  pvrctrl_regs[reg] |= dat;
1071   pvrctrl_regs[reg] = dat;
1072
1073}
1074
1075984READ64_HANDLER( pvr_ta_r )
1076985{
1077986   int reg;
r7924r7925
10971006         blank = (video_screen_get_vblank(space->machine->primary_screen) | video_screen_get_hblank(space->machine->primary_screen)) ? 0 : 1;
10981007         if(spg_blank_pol) { blank^=1; }
10991008
1100         pvrta_regs[reg] = (vsync << 13) | (hsync << 12) | (blank << 11) | (fieldnum << 10) | (video_screen_get_vpos(space->machine->primary_screen) & 0x1ff);
1009         pvrta_regs[reg] = (vsync << 13) | (hsync << 12) | (blank << 11) | (fieldnum << 10) | (video_screen_get_vpos(space->machine->primary_screen) & 0x3ff);
11011010         break;
11021011      }
11031012   case SPG_TRIGGER_POS:
11041013      printf("Warning: read at h/v counter ext latches\n");
11051014      break;
1015   case TA_LIST_INIT:
1016      return 0; //bit 31 always return 0, a probable left-over in Crazy Taxi reads this and discards the read (?)
11061017   }
11071018
11081019   #if DEBUG_PVRTA_REGS
r7924r7925
12611172      assert_always(0, "TA grabber error A!\n");
12621173      break;
12631174   case TA_LIST_INIT:
1264      state_ta.tafifo_pos=0;
1265      state_ta.tafifo_mask=7;
1266      state_ta.tafifo_vertexwords=8;
1267      state_ta.tafifo_listtype= -1;
1175      if(dat & 0x80000000)
1176      {
1177         state_ta.tafifo_pos=0;
1178         state_ta.tafifo_mask=7;
1179         state_ta.tafifo_vertexwords=8;
1180         state_ta.tafifo_listtype= -1;
12681181   #if DEBUG_PVRTA
1269      mame_printf_verbose("TA_OL_BASE       %08x TA_OL_LIMIT  %08x\n", pvrta_regs[TA_OL_BASE], pvrta_regs[TA_OL_LIMIT]);
1270      mame_printf_verbose("TA_ISP_BASE      %08x TA_ISP_LIMIT %08x\n", pvrta_regs[TA_ISP_BASE], pvrta_regs[TA_ISP_LIMIT]);
1271      mame_printf_verbose("TA_ALLOC_CTRL    %08x\n", pvrta_regs[TA_ALLOC_CTRL]);
1272      mame_printf_verbose("TA_NEXT_OPB_INIT %08x\n", pvrta_regs[TA_NEXT_OPB_INIT]);
1182         mame_printf_verbose("TA_OL_BASE       %08x TA_OL_LIMIT  %08x\n", pvrta_regs[TA_OL_BASE], pvrta_regs[TA_OL_LIMIT]);
1183         mame_printf_verbose("TA_ISP_BASE      %08x TA_ISP_LIMIT %08x\n", pvrta_regs[TA_ISP_BASE], pvrta_regs[TA_ISP_LIMIT]);
1184         mame_printf_verbose("TA_ALLOC_CTRL    %08x\n", pvrta_regs[TA_ALLOC_CTRL]);
1185         mame_printf_verbose("TA_NEXT_OPB_INIT %08x\n", pvrta_regs[TA_NEXT_OPB_INIT]);
12731186   #endif
1274      pvrta_regs[TA_NEXT_OPB] = pvrta_regs[TA_NEXT_OPB_INIT];
1275      pvrta_regs[TA_ITP_CURRENT] = pvrta_regs[TA_ISP_BASE];
1276      state_ta.alloc_ctrl_OPB_Mode = pvrta_regs[TA_ALLOC_CTRL] & 0x100000; // 0 up 1 down
1277      state_ta.alloc_ctrl_PT_OPB = (4 << ((pvrta_regs[TA_ALLOC_CTRL] >> 16) & 3)) & 0x38; // number of 32 bit words (0,8,16,32)
1278      state_ta.alloc_ctrl_TM_OPB = (4 << ((pvrta_regs[TA_ALLOC_CTRL] >> 12) & 3)) & 0x38;
1279      state_ta.alloc_ctrl_T_OPB = (4 << ((pvrta_regs[TA_ALLOC_CTRL] >> 8) & 3)) & 0x38;
1280      state_ta.alloc_ctrl_OM_OPB = (4 << ((pvrta_regs[TA_ALLOC_CTRL] >> 4) & 3)) & 0x38;
1281      state_ta.alloc_ctrl_O_OPB = (4 << ((pvrta_regs[TA_ALLOC_CTRL] >> 0) & 3)) & 0x38;
1282      state_ta.listtype_used |= (1+4);
1283      // use TA_ISP_BASE and select buffer for grab data
1284      state_ta.grabsel = -1;
1285      // try to find already used buffer but not busy
1286      for (a=0;a < NUM_BUFFERS;a++)
1287      {
1288         if ((state_ta.grab[a].ispbase == pvrta_regs[TA_ISP_BASE]) && (state_ta.grab[a].busy == 0) && (state_ta.grab[a].valid == 1))
1289         {
1290            state_ta.grabsel=a;
1291            break;
1292         }
1293      }
1294      // try a buffer not used yet
1295      if (state_ta.grabsel < 0)
1296      {
1187         pvrta_regs[TA_NEXT_OPB] = pvrta_regs[TA_NEXT_OPB_INIT];
1188         pvrta_regs[TA_ITP_CURRENT] = pvrta_regs[TA_ISP_BASE];
1189         state_ta.alloc_ctrl_OPB_Mode = pvrta_regs[TA_ALLOC_CTRL] & 0x100000; // 0 up 1 down
1190         state_ta.alloc_ctrl_PT_OPB = (4 << ((pvrta_regs[TA_ALLOC_CTRL] >> 16) & 3)) & 0x38; // number of 32 bit words (0,8,16,32)
1191         state_ta.alloc_ctrl_TM_OPB = (4 << ((pvrta_regs[TA_ALLOC_CTRL] >> 12) & 3)) & 0x38;
1192         state_ta.alloc_ctrl_T_OPB = (4 << ((pvrta_regs[TA_ALLOC_CTRL] >> 8) & 3)) & 0x38;
1193         state_ta.alloc_ctrl_OM_OPB = (4 << ((pvrta_regs[TA_ALLOC_CTRL] >> 4) & 3)) & 0x38;
1194         state_ta.alloc_ctrl_O_OPB = (4 << ((pvrta_regs[TA_ALLOC_CTRL] >> 0) & 3)) & 0x38;
1195         state_ta.listtype_used |= (1+4);
1196         // use TA_ISP_BASE and select buffer for grab data
1197         state_ta.grabsel = -1;
1198         // try to find already used buffer but not busy
12971199         for (a=0;a < NUM_BUFFERS;a++)
12981200         {
1299            if (state_ta.grab[a].valid == 0)
1201            if ((state_ta.grab[a].ispbase == pvrta_regs[TA_ISP_BASE]) && (state_ta.grab[a].busy == 0) && (state_ta.grab[a].valid == 1))
13001202            {
13011203               state_ta.grabsel=a;
13021204               break;
13031205            }
13041206         }
1305      }
1306      // find a non busy buffer starting from the last one used
1307      if (state_ta.grabsel < 0)
1308      {
1309         for (a=0;a < 3;a++)
1207         // try a buffer not used yet
1208         if (state_ta.grabsel < 0)
13101209         {
1311            if (state_ta.grab[(state_ta.grabsellast+1+a) & 3].busy == 0)
1210            for (a=0;a < NUM_BUFFERS;a++)
13121211            {
1313               state_ta.grabsel=a;
1314               break;
1212               if (state_ta.grab[a].valid == 0)
1213               {
1214                  state_ta.grabsel=a;
1215                  break;
1216               }
13151217            }
13161218         }
1317      }
1318      if (state_ta.grabsel < 0)
1319         assert_always(0, "TA grabber error B!\n");
1320      state_ta.grabsellast=state_ta.grabsel;
1321      state_ta.grab[state_ta.grabsel].ispbase=pvrta_regs[TA_ISP_BASE];
1322      state_ta.grab[state_ta.grabsel].busy=0;
1323      state_ta.grab[state_ta.grabsel].valid=1;
1324      state_ta.grab[state_ta.grabsel].verts_size=0;
1325      state_ta.grab[state_ta.grabsel].strips_size=0;
1219         // find a non busy buffer starting from the last one used
1220         if (state_ta.grabsel < 0)
1221         {
1222            for (a=0;a < 3;a++)
1223            {
1224               if (state_ta.grab[(state_ta.grabsellast+1+a) & 3].busy == 0)
1225               {
1226                  state_ta.grabsel=a;
1227                  break;
1228               }
1229            }
1230         }
1231         if (state_ta.grabsel < 0)
1232            assert_always(0, "TA grabber error B!\n");
1233         state_ta.grabsellast=state_ta.grabsel;
1234         state_ta.grab[state_ta.grabsel].ispbase=pvrta_regs[TA_ISP_BASE];
1235         state_ta.grab[state_ta.grabsel].busy=0;
1236         state_ta.grab[state_ta.grabsel].valid=1;
1237         state_ta.grab[state_ta.grabsel].verts_size=0;
1238         state_ta.grab[state_ta.grabsel].strips_size=0;
13261239
1327      profiler_mark_end();
1240         profiler_mark_end();
1241      }
13281242      break;
13291243//#define TA_YUV_TEX_BASE       ((0x005f8148-0x005f8000)/4)
13301244   case TA_YUV_TEX_BASE:
r7924r7925
13571271         visarea.min_y = 0;
13581272         visarea.max_y = ((spg_vbstart - spg_vbend - vo_vert_start_pos_f1) <= 0x100 ? 240 : 480) - 1;
13591273
1274
13601275         video_screen_configure(space->machine->primary_screen, spg_hbstart, spg_vbstart, &visarea, video_screen_get_frame_period(space->machine->primary_screen).attoseconds );
13611276      }
13621277      break;
src/mess/drivers/dc.c
r7924r7925
4242
4343int jvsboard_type;
4444
45static READ64_HANDLER( dcus_idle_skip_r )
46{
47   if (cpu_get_pc(space->cpu)==0xc0ba52a)
48      cpu_spinuntil_time(space->cpu, ATTOTIME_IN_USEC(2500));
49
50   return dc_ram[0x2303b0/8];
51}
52
4553static DRIVER_INIT(dc)
4654{
4755   dreamcast_atapi_init(machine);
4856}
4957
58static DRIVER_INIT(dcus)
59{
60   memory_install_read64_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc2303b0, 0xc2303b7, 0, 0, dcus_idle_skip_r);
61
62   DRIVER_INIT_CALL(dc);
63}
64
5065static UINT64 PDTRA, PCTRA;
5166static READ64_HANDLER( dc_pdtra_r )
5267{
r7924r7925
339354
340355
341356/*    YEAR  NAME    PARENT  COMPAT  MACHINE INPUT   INIT      COMPANY FULLNAME */
342CONS( 1999, dc,      dcjp,   0,   dc,   dc,   dc,   "Sega", "Dreamcast (US NTSC)", GAME_NOT_WORKING )
357CONS( 1999, dc,      dcjp,   0,   dc,   dc,   dcus,   "Sega", "Dreamcast (US NTSC)", GAME_NOT_WORKING )
343358CONS( 1998, dcjp,   0,      0,   dc,   dc,   dc,   "Sega", "Dreamcast (Japan NTSC)", GAME_NOT_WORKING )
344359CONS( 1999, dceu,   dcjp,   0,   dc,   dc,   dc,   "Sega", "Dreamcast (European PAL)", GAME_NOT_WORKING )
345360CONS( 1998, dcdev,   dcjp,   0,   dc,   dc,   dc,   "Sega", "HKT-0120 Sega Dreamcast Development Box", GAME_NOT_WORKING )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team