Previous 15994 Revisions Next

r4577 Monday 27th April, 2009 at 21:36:43 UTC by Fabio Priuli
A last round for today
[src/mess/drivers]mac.c mephisto.c mk1.c mk2.c mpf1.c mtx.c
[src/mess/machine]kaypro.c kc.c lisa.c lviv.c lynx.c mac.c mc10.c microtan.c mikro80.c msx.c msx_slot.c mtx.c mz700.c mz80.c
[src/mess/video]kramermc.c mz80.c

src/mess/video/kramermc.c
r4576r4577
3030VIDEO_UPDATE( kramermc )
3131{
3232   int x,y;
33   const address_space *space = cpu_get_address_space(screen->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
33   const address_space *space = cputag_get_address_space(screen->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
3434   
3535   for(y = 0; y < 16; y++ )
3636   {
src/mess/video/mz80.c
r4576r4577
4141VIDEO_UPDATE( mz80k )
4242{
4343   int x,y;
44   const address_space *space = cpu_get_address_space(screen->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
44   const address_space *space = cputag_get_address_space(screen->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
4545   mz80k_vertical = mz80k_vertical ? 0 : 1;   
4646   mz80k_cursor_cnt++;
4747   if (mz80k_cursor_cnt==64) mz80k_cursor_cnt = 0;
src/mess/machine/msx_slot.c
r4576r4577
2929
3030static void msx_cpu_setbank (running_machine *machine, int page, UINT8 *mem)
3131{
32   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
33   switch (page) {
32   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
33   switch (page)
34   {
3435   case 1:
3536   case 2:
3637   case 3:
r4576r4577
135136
136137   nsize = 0x10000; /* 64 kb */
137138   mask = 3;
138   for (i=0; i<6; i++) {
139      if (size == nsize) {
139   for (i=0; i<6; i++)
140   {
141      if (size == nsize)
142      {
140143         break;
141144      }
142145      mask = (mask << 1) | 1;
143146      nsize <<= 1;
144147   }
145   if (i == 6) {
148   if (i == 6)
149   {
146150      logerror ("ram mapper: error: must be 64kb, 128kb, 256kb, 512kb, "
147151              "1mb, 2mb or 4mb\n");
148152      return 1;
r4576r4577
152156
153157#ifdef MONMSX
154158   f = fopen ("/home/sean/msx/hack/monmsx.bin", "r");
155   if (f) {
159   if (f)
160   {
156161      fseek (f, 6L, SEEK_SET);
157162      fread (state->mem, 1, 6151 - 6, f);
158163      fclose (f);
r4576r4577
171176{
172177   int i;
173178
174   for (i=0; i<4; i++) {
179   for (i=0; i<4; i++)
180   {
175181      msx1.ram_mapper[i] = 3 - i;
176182   }
177183}
r4576r4577
188194
189195MSX_SLOT_INIT(msxdos2)
190196{
191   if (size != 0x10000) {
197   if (size != 0x10000)
198   {
192199      logerror ("msxdos2: error: rom file must be 64kb\n");
193200      return 1;
194201   }
r4576r4577
206213
207214MSX_SLOT_MAP(msxdos2)
208215{
209   if (page != 1) {
216   if (page != 1)
217   {
210218      msx_cpu_setbank (machine, page * 2 + 1, msx1.empty);
211219      msx_cpu_setbank (machine, page * 2 + 2, msx1.empty);
212   } else {
220   }
221   else
222   {
213223      msx_cpu_setbank (machine, 3, state->mem + state->banks[0] * 0x4000);
214224      msx_cpu_setbank (machine, 4, state->mem + state->banks[0] * 0x4000 + 0x2000);
215225   }
r4576r4577
217227
218228MSX_SLOT_WRITE(msxdos2)
219229{
220   if (addr == 0x6000) {
230   if (addr == 0x6000)
231   {
221232      state->banks[0] = val & 3;
222233      slot_msxdos2_map (machine, state, 1);
223234   }
r4576r4577
227238{
228239   int banks;
229240
230   if (size > 0x200000) {
241   if (size > 0x200000)
242   {
231243      logerror ("konami: warning: truncating to 2mb\n");
232244      size = 0x200000;
233245      return 1;
234246   }
235247   banks = size / 0x2000;
236   if (size != banks * 0x2000 || (~(banks - 1) % banks)) {
248   if (size != banks * 0x2000 || (~(banks - 1) % banks))
249   {
237250      logerror ("konami: error: must be a 2 power of 8kb\n");
238251      return 1;
239252   }
r4576r4577
254267
255268MSX_SLOT_MAP(konami)
256269{
257   switch (page) {
270   switch (page)
271   {
258272   case 0:
259273      msx_cpu_setbank (machine, 1, state->mem);
260274      msx_cpu_setbank (machine, 2, state->mem + state->banks[1] * 0x2000);
r4576r4577
275289
276290MSX_SLOT_WRITE(konami)
277291{
278   switch (addr) {
292   switch (addr)
293   {
279294   case 0x6000:
280295      state->banks[1] = val & state->bank_mask;
281296      slot_konami_map (machine, state, 1);
282      if (msx1.state[0] == state) {
297      if (msx1.state[0] == state)
298      {
283299         slot_konami_map (machine, state, 0);
284300      }
285301      break;
286302   case 0x8000:
287303      state->banks[2] = val & state->bank_mask;
288304      slot_konami_map (machine, state, 2);
289      if (msx1.state[3] == state) {
305      if (msx1.state[3] == state)
306      {
290307         slot_konami_map (machine, state, 3);
291308      }
292309      break;
293310   case 0xa000:
294311      state->banks[3] = val & state->bank_mask;
295312      slot_konami_map (machine, state, 2);
296      if (msx1.state[3] == state) {
313      if (msx1.state[3] == state)
314      {
297315         slot_konami_map (machine, state, 3);
298316      }
299317   }
r4576r4577
303321{
304322   int banks;
305323
306   if (size > 0x200000) {
324   if (size > 0x200000)
325   {
307326      logerror ("konami_scc: warning: truncating to 2mb\n");
308327      size = 0x200000;
309328      return 1;
310329   }
311330   banks = size / 0x2000;
312   if (size != banks * 0x2000 || (~(banks - 1) % banks)) {
331   if (size != banks * 0x2000 || (~(banks - 1) % banks))
332   {
313333      logerror ("konami_scc: error: must be a 2 power of 8kb\n");
314334      return 1;
315335   }
r4576r4577
332352
333353static READ8_HANDLER (konami_scc_bank5)
334354{
335   if (offset & 0x80) {
355   if (offset & 0x80)
356   {
336357#if 0
337      if ((offset & 0xff) >= 0xe0) {
358      if ((offset & 0xff) >= 0xe0)
359      {
338360         /* write 0xff to deformation register */
339361      }
340362#endif
341363      return 0xff;
342364   }
343   else {
365   else
366   {
344367      return k051649_waveform_r (devtag_get_device(space->machine, "k051649"), offset & 0x7f);
345368   }
346369}
347370
348371MSX_SLOT_MAP(konami_scc)
349372{
350   switch (page) {
373   switch (page)
374   {
351375   case 0:
352376      msx_cpu_setbank (machine, 1, state->mem + state->banks[2] * 0x2000);
353377      msx_cpu_setbank (machine, 2, state->mem + state->banks[3] * 0x2000);
r4576r4577
359383   case 2:
360384      msx_cpu_setbank (machine, 5, state->mem + state->banks[2] * 0x2000);
361385      msx_cpu_setbank (machine, 6, state->mem + state->banks[3] * 0x2000);
362      memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x9800, 0x9fff, 0, 0,
386      memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x9800, 0x9fff, 0, 0,
363387            state->cart.scc.active ? konami_scc_bank5 : SMH_BANK7);
364388      break;
365389   case 3:
r4576r4577
370394
371395MSX_SLOT_WRITE(konami_scc)
372396{
373   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
374   if (addr >= 0x5000 && addr < 0x5800) {
397   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
398   if (addr >= 0x5000 && addr < 0x5800)
399   {
375400      state->banks[0] = val & state->bank_mask;
376401      slot_konami_scc_map (machine, state, 1);
377      if (msx1.state[3] == state) {
402      if (msx1.state[3] == state)
403      {
378404         slot_konami_scc_map (machine, state, 3);
379405      }
380406   }
381   else if (addr >= 0x7000 && addr < 0x7800) {
407   else if (addr >= 0x7000 && addr < 0x7800)
408   {
382409      state->banks[1] = val & state->bank_mask;
383410      slot_konami_scc_map (machine, state, 1);
384      if (msx1.state[3] == state) {
411      if (msx1.state[3] == state)
412      {
385413         slot_konami_scc_map (machine, state, 3);
386414      }
387415   }
388   else if (addr >= 0x9000 && addr < 0x9800) {
416   else if (addr >= 0x9000 && addr < 0x9800)
417   {
389418      state->banks[2] = val & state->bank_mask;
390419      state->cart.scc.active = ((val & 0x3f) == 0x3f);
391420      slot_konami_scc_map (machine, state, 2);
392      if (msx1.state[0] == state) {
421      if (msx1.state[0] == state)
422      {
393423         slot_konami_scc_map (machine, state, 0);
394424      }
395425   }
396   else if (state->cart.scc.active && addr >= 0x9800 && addr < 0xa000) {
426   else if (state->cart.scc.active && addr >= 0x9800 && addr < 0xa000)
427   {
397428      const device_config *k051649 = devtag_get_device(space->machine, "k051649");
398429      int offset = addr & 0xff;
399430
400      if (offset < 0x80) {
431      if (offset < 0x80)
432      {
401433         k051649_waveform_w (k051649, offset, val);
402434      }
403      else if (offset < 0xa0) {
435      else if (offset < 0xa0)
436      {
404437         offset &= 0xf;
405         if (offset < 0xa) {
438         if (offset < 0xa)
439         {
406440            k051649_frequency_w (k051649, offset, val);
407441         }
408         else if (offset < 0xf) {
442         else if (offset < 0xf)
443         {
409444            k051649_volume_w (k051649, offset - 0xa, val);
410445         }
411         else {
446         else
447         {
412448            k051649_keyonoff_w (k051649, 0, val);
413449         }
414450      }
415451#if 0
416      else if (offset >= 0xe0) {
452      else if (offset >= 0xe0)
453      {
417454         /* deformation register */
418455      }
419456#endif
420457   }
421   else if (addr >= 0xb000 && addr < 0xb800) {
458   else if (addr >= 0xb000 && addr < 0xb800)
459   {
422460      state->banks[3] = val & state->bank_mask;
423461      slot_konami_scc_map (machine, state, 2);
424      if (msx1.state[0] == state) {
462      if (msx1.state[0] == state)
463      {
425464         slot_konami_scc_map (machine, state, 0);
426465      }
427466   }
r4576r4577
431470{
432471   int banks;
433472
434   if (size > 0x200000) {
473   if (size > 0x200000)
474   {
435475      logerror ("ascii8: warning: truncating to 2mb\n");
436476      size = 0x200000;
437477      return 1;
438478   }
439479   banks = size / 0x2000;
440   if (size != banks * 0x2000 || (~(banks - 1) % banks)) {
480   if (size != banks * 0x2000 || (~(banks - 1) % banks))
481   {
441482      logerror ("ascii8: error: must be a 2 power of 8kb\n");
442483      return 1;
443484   }
r4576r4577
458499
459500MSX_SLOT_MAP(ascii8)
460501{
461   switch (page) {
502   switch (page)
503   {
462504   case 0:
463505      msx_cpu_setbank (machine, 1, msx1.empty);
464506      msx_cpu_setbank (machine, 2, msx1.empty);
r4576r4577
481523{
482524   int bank;
483525
484   if (addr >= 0x6000 && addr < 0x8000) {
526   if (addr >= 0x6000 && addr < 0x8000)
527   {
485528      bank = (addr / 0x800) & 3;
486529
487530      state->banks[bank] = val & state->bank_mask;
488      if (bank <= 1) {
531      if (bank <= 1)
532      {
489533         slot_ascii8_map (machine, state, 1);
490534      }
491      else if (msx1.state[2] == state) {
535      else if (msx1.state[2] == state)
536      {
492537         slot_ascii8_map (machine, state, 2);
493538      }
494539   }
r4576r4577
498543{
499544   int banks;
500545
501   if (size > 0x400000) {
546   if (size > 0x400000)
547   {
502548      logerror ("ascii16: warning: truncating to 4mb\n");
503549      size = 0x400000;
504550   }
505551   banks = size / 0x4000;
506   if (size != banks * 0x4000 || (~(banks - 1) % banks)) {
552   if (size != banks * 0x4000 || (~(banks - 1) % banks))
553   {
507554      logerror ("ascii16: error: must be a 2 power of 16kb\n");
508555      return 1;
509556   }
r4576r4577
527574{
528575   UINT8 *mem;
529576
530   switch (page) {
577   switch (page)
578   {
531579   case 0:
532580      msx_cpu_setbank (machine, 1, msx1.empty);
533581      msx_cpu_setbank (machine, 2, msx1.empty);
r4576r4577
550598
551599MSX_SLOT_WRITE(ascii16)
552600{
553   if (addr >= 0x6000 && addr < 0x6800) {
601   if (addr >= 0x6000 && addr < 0x6800)
602   {
554603      state->banks[0] = val & state->bank_mask;
555604      slot_ascii16_map (machine, state, 1);
556605   }
557   else if (addr >= 0x7000 && addr < 0x7800) {
606   else if (addr >= 0x7000 && addr < 0x7800)
607   {
558608      state->banks[1] = val & state->bank_mask;
559      if (msx1.state[2] == state) {
609      if (msx1.state[2] == state)
610      {
560611         slot_ascii16_map (machine, state, 2);
561612      }
562613   }
r4576r4577
568619   int banks;
569620
570621   state->cart.sram.mem = auto_malloc (0x2000);
571   if (size > 0x100000) {
622   if (size > 0x100000)
623   {
572624      logerror ("ascii8_sram: warning: truncating to 1mb\n");
573625      size = 0x100000;
574626      return 1;
575627   }
576628   banks = size / 0x2000;
577   if (size != banks * 0x2000 || (~(banks - 1) % banks)) {
629   if (size != banks * 0x2000 || (~(banks - 1) % banks))
630   {
578631      logerror ("ascii8_sram: error: must be a 2 power of 8kb\n");
579632      return 1;
580633   }
r4576r4577
585638   state->bank_mask = banks - 1;
586639   state->cart.sram.sram_mask = banks;
587640   state->cart.sram.empty_mask = ~(banks | (banks - 1));
588   if (!state->sramfile) {
641   if (!state->sramfile)
642   {
589643      state->sramfile = sramfile;
590644   }
591645
r4576r4577
603657{
604658   int bank = state->banks[bankno];
605659
606   if (bank & state->cart.sram.empty_mask) {
660   if (bank & state->cart.sram.empty_mask)
661   {
607662      return msx1.empty;
608663   }
609   else if (bank & state->cart.sram.sram_mask) {
664   else if (bank & state->cart.sram.sram_mask)
665   {
610666      return state->cart.sram.mem;
611667   }
612   else {
668   else
669   {
613670      return state->mem + (bank & state->bank_mask) * 0x2000;
614671   }
615672}
616673
617674MSX_SLOT_MAP(ascii8_sram)
618675{
619   switch (page) {
676   switch (page)
677   {
620678   case 0:
621679      msx_cpu_setbank (machine, 1, msx1.empty);
622680      msx_cpu_setbank (machine, 2, msx1.empty);
r4576r4577
639697{
640698   int bank;
641699
642   if (addr >= 0x6000 && addr < 0x8000) {
700   if (addr >= 0x6000 && addr < 0x8000)
701   {
643702      bank = (addr / 0x800) & 3;
644703
645704      state->banks[bank] = val;
646      if (bank <= 1) {
705      if (bank <= 1)
706      {
647707         slot_ascii8_sram_map (machine, state, 1);
648708      }
649      else if (msx1.state[2] == state) {
709      else if (msx1.state[2] == state)
710      {
650711         slot_ascii8_sram_map (machine, state, 2);
651712      }
652713   }
653   if (addr >= 0x8000 && addr < 0xc000) {
714   if (addr >= 0x8000 && addr < 0xc000)
715   {
654716      bank = addr < 0xa000 ? 2 : 3;
655717      if (!(state->banks[bank] & state->cart.sram.empty_mask) &&
656           (state->banks[bank] & state->cart.sram.sram_mask)) {
718           (state->banks[bank] & state->cart.sram.sram_mask))
719      {
657720         state->cart.sram.mem[addr & 0x1fff] = val;
658721      }
659722   }
r4576r4577
664727   file_error filerr;
665728   mame_file *f;
666729
667   if (!state->sramfile) {
730   if (!state->sramfile)
731   {
668732      logerror ("ascii8_sram: error: no sram filename provided\n");
669733      return 1;
670734   }
r4576r4577
672736   filerr = mame_fopen(SEARCHPATH_MEMCARD, state->sramfile, OPEN_FLAG_READ, &f);
673737   if (filerr == FILERR_NONE)
674738   {
675      if (mame_fread (f, state->cart.sram.mem, 0x2000) == 0x2000) {
739      if (mame_fread (f, state->cart.sram.mem, 0x2000) == 0x2000)
740      {
676741         mame_fclose (f);
677742         logerror ("ascii8_sram: info: sram loaded\n");
678743         return 0;
r4576r4577
693758   file_error filerr;
694759   mame_file *f;
695760
696   if (!state->sramfile) {
761   if (!state->sramfile)
762   {
697763      return 0;
698764   }
699765
r4576r4577
719785
720786   state->cart.sram.mem = auto_malloc (0x4000);
721787
722   if (size > 0x200000) {
788   if (size > 0x200000)
789   {
723790      logerror ("ascii16_sram: warning: truncating to 2mb\n");
724791      size = 0x200000;
725792   }
726793   banks = size / 0x4000;
727   if (size != banks * 0x4000 || (~(banks - 1) % banks)) {
794   if (size != banks * 0x4000 || (~(banks - 1) % banks))
795   {
728796      logerror ("ascii16_sram: error: must be a 2 power of 16kb\n");
729797      return 1;
730798   }
r4576r4577
736804   state->bank_mask = banks - 1;
737805   state->cart.sram.sram_mask = banks;
738806   state->cart.sram.empty_mask = ~(banks | (banks - 1));
739   if (!state->sramfile) {
807   if (!state->sramfile)
808   {
740809      state->sramfile = sramfile;
741810   }
742811
r4576r4577
754823{
755824   int bank = state->banks[bankno];
756825
757   if (bank & state->cart.sram.empty_mask) {
826   if (bank & state->cart.sram.empty_mask)
827   {
758828      return msx1.empty;
759829   }
760   else if (bank & state->cart.sram.sram_mask) {
830   else if (bank & state->cart.sram.sram_mask)
831   {
761832      return state->cart.sram.mem;
762833   }
763   else {
834   else
835   {
764836      return state->mem + (bank & state->bank_mask) * 0x4000;
765837   }
766838}
r4576r4577
769841{
770842   UINT8 *mem;
771843
772   switch (page) {
844   switch (page)
845   {
773846   case 0:
774847      msx_cpu_setbank (machine, 1, msx1.empty);
775848      msx_cpu_setbank (machine, 2, msx1.empty);
r4576r4577
792865
793866MSX_SLOT_WRITE(ascii16_sram)
794867{
795   if (addr >= 0x6000 && addr < 0x6800) {
868   if (addr >= 0x6000 && addr < 0x6800)
869   {
796870      state->banks[0] = val;
797871      slot_ascii16_sram_map (machine, state, 1);
798872   }
799   else if (addr >= 0x7000 && addr < 0x7800) {
873   else if (addr >= 0x7000 && addr < 0x7800)
874   {
800875      state->banks[1] = val;
801      if (msx1.state[2] == state) {
876      if (msx1.state[2] == state)
877      {
802878         slot_ascii16_sram_map (machine, state, 2);
803879      }
804880   }
805   else if (addr >= 0x8000 && addr < 0xc000) {
881   else if (addr >= 0x8000 && addr < 0xc000)
882   {
806883      if (!(state->banks[1] & state->cart.sram.empty_mask) &&
807           (state->banks[1] & state->cart.sram.sram_mask)) {
884           (state->banks[1] & state->cart.sram.sram_mask))
885      {
808886         int offset, i;
809887
810888         offset = addr & 0x07ff;
811         for (i=0; i<8; i++) {
889         for (i=0; i<8; i++)
890         {
812891            state->cart.sram.mem[offset] = val;
813892            offset += 0x0800;
814893         }
r4576r4577
822901   mame_file *f;
823902   UINT8 *p;
824903
825   if (!state->sramfile) {
904   if (!state->sramfile)
905   {
826906      logerror ("ascii16_sram: error: no sram filename provided\n");
827907      return 1;
828908   }
r4576r4577
832912   {
833913      p = state->cart.sram.mem;
834914
835      if (mame_fread (f, state->cart.sram.mem, 0x200) == 0x200) {
915      if (mame_fread (f, state->cart.sram.mem, 0x200) == 0x200)
916      {
836917         int /*offset,*/ i;
837918
838919         mame_fclose (f);
839920
840921         //offset = 0;
841         for (i=0; i<7; i++) {
922         for (i=0; i<7; i++)
923         {
842924            memcpy (p + 0x800, p, 0x800);
843925            p += 0x800;
844926         }
r4576r4577
862944   file_error filerr;
863945   mame_file *f;
864946
865   if (!state->sramfile) {
947   if (!state->sramfile)
948   {
866949      return 0;
867950   }
868951
r4576r4577
883966
884967MSX_SLOT_INIT(rtype)
885968{
886   if (!(size == 0x60000 || size == 0x80000)) {
969   if (!(size == 0x60000 || size == 0x80000))
970   {
887971      logerror ("rtype: error: rom file should be exactly 384kb\n");
888972      return 1;
889973   }
r4576r4577
904988{
905989   UINT8 *mem;
906990
907   switch (page) {
991   switch (page)
992   {
908993   case 0:
909994      msx_cpu_setbank (machine, 1, msx1.empty);
910995      msx_cpu_setbank (machine, 2, msx1.empty);
r4576r4577
9271012
9281013MSX_SLOT_WRITE(rtype)
9291014{
930   if (addr >= 0x7000 && addr < 0x8000) {
1015   if (addr >= 0x7000 && addr < 0x8000)
1016   {
9311017      int data ;
9321018
933      if (val & 0x10) {
1019      if (val & 0x10)
1020      {
9341021         data = 0x10 | (val & 7);
9351022      }
936      else {
1023      else
1024      {
9371025         data = val & 0x0f;
9381026      }
9391027      state->banks[0] = data;
940      if (msx1.state[2] == state) {
1028      if (msx1.state[2] == state)
1029      {
9411030         slot_rtype_map (machine, state, 2);
9421031      }
9431032   }
r4576r4577
9481037   UINT8 *p;
9491038   static const char sramfile[] = "GameMaster2";
9501039
951   if (size != 0x20000) {
1040   if (size != 0x20000)
1041   {
9521042      logerror ("gmaster2: error: rom file should be 128kb\n");
9531043      return 1;
9541044   }
r4576r4577
9591049   p = auto_malloc (0x4000);
9601050   memset (p, 0, 0x4000);
9611051   state->cart.sram.mem = p;
962   if (!state->sramfile) {
1052   if (!state->sramfile)
1053   {
9631054      state->sramfile = sramfile;
9641055   }
9651056
r4576r4577
9701061{
9711062   int i;
9721063
973   for (i=0; i<4; i++) {
1064   for (i=0; i<4; i++)
1065   {
9741066      state->banks[i] = i;
9751067   }
9761068}
9771069
9781070MSX_SLOT_MAP(gmaster2)
9791071{
980   switch (page) {
1072   switch (page)
1073   {
9811074   case 0:
9821075   case 1:
9831076      msx_cpu_setbank (machine, 1 + page * 2, state->mem); /* bank 0 is hardwired */
984      if (state->banks[1] > 15) {
1077      if (state->banks[1] > 15)
1078      {
9851079         msx_cpu_setbank (machine, 2 + page * 2, state->cart.sram.mem +
9861080               (state->banks[1] - 16) * 0x2000);
9871081      }
988      else {
1082      else
1083      {
9891084         msx_cpu_setbank (machine, 2 + page * 2, state->mem + state->banks[1] * 0x2000);
9901085      }
9911086      break;
9921087   case 2:
9931088   case 3:
994      if (state->banks[2] > 15) {
1089      if (state->banks[2] > 15)
1090      {
9951091         msx_cpu_setbank (machine, 5 + page * 2, state->cart.sram.mem +
9961092               (state->banks[2] - 16) * 0x2000);
9971093      }
998      else {
1094      else
1095      {
9991096         msx_cpu_setbank (machine, 5 + page * 2, state->mem + state->banks[2] * 0x2000);
10001097      }
1001      if (state->banks[3] > 15) {
1098      if (state->banks[3] > 15)
1099      {
10021100         msx_cpu_setbank (machine, 6 + page * 2, state->cart.sram.mem +
10031101               (state->banks[3] - 16) * 0x2000);
10041102      }
1005      else {
1103      else
1104      {
10061105         msx_cpu_setbank (machine, 6 + page * 2, state->mem + state->banks[3] * 0x2000);
10071106      }
10081107      break;
r4576r4577
10111110
10121111MSX_SLOT_WRITE(gmaster2)
10131112{
1014   if (addr >= 0x6000 && addr < 0x7000) {
1015      if (val & 0x10) {
1113   if (addr >= 0x6000 && addr < 0x7000)
1114   {
1115      if (val & 0x10)
1116      {
10161117         val = val & 0x20 ? 17 : 16;
10171118      }
1018      else {
1119      else
1120      {
10191121         val = val & 15;
10201122      }
10211123      state->banks[1] = val;
10221124      slot_gmaster2_map (machine, state, 1);
1023      if (msx1.state[0] == state) {
1125      if (msx1.state[0] == state)
1126      {
10241127         slot_gmaster2_map (machine, state, 0);
10251128      }
10261129   }
1027   else if (addr >= 0x8000 && addr < 0x9000) {
1028      if (val & 0x10) {
1130   else if (addr >= 0x8000 && addr < 0x9000)
1131   {
1132      if (val & 0x10)
1133      {
10291134         val = val & 0x20 ? 17 : 16;
10301135      }
1031      else {
1136      else
1137      {
10321138         val = val & 15;
10331139      }
10341140      state->banks[2] = val;
10351141      slot_gmaster2_map (machine, state, 2);
1036      if (msx1.state[3] == state) {
1142      if (msx1.state[3] == state)
1143      {
10371144         slot_gmaster2_map (machine, state, 3);
10381145      }
10391146   }
1040   else if (addr >= 0xa000 && addr < 0xb000) {
1041      if (val & 0x10) {
1147   else if (addr >= 0xa000 && addr < 0xb000)
1148   {
1149      if (val & 0x10)
1150      {
10421151         val = val & 0x20 ? 17 : 16;
10431152      }
1044      else {
1153      else
1154      {
10451155         val = val & 15;
10461156      }
10471157      state->banks[3] = val;
10481158      slot_gmaster2_map (machine, state, 2);
1049      if (msx1.state[3] == state) {
1159      if (msx1.state[3] == state)
1160      {
10501161         slot_gmaster2_map (machine, state, 3);
10511162      }
10521163   }
1053   else if (addr >= 0xb000 && addr < 0xc000) {
1164   else if (addr >= 0xb000 && addr < 0xc000)
1165   {
10541166      addr &= 0x0fff;
1055      switch (state->banks[3]) {
1167      switch (state->banks[3])
1168      {
10561169      case 16:
10571170         state->cart.sram.mem[addr] = val;
10581171         state->cart.sram.mem[addr + 0x1000] = val;
r4576r4577
10751188   filerr = mame_fopen(SEARCHPATH_MEMCARD, state->sramfile, OPEN_FLAG_READ, &f);
10761189   if (filerr == FILERR_NONE)
10771190   {
1078      if (mame_fread (f, p + 0x1000, 0x2000) == 0x2000) {
1191      if (mame_fread (f, p + 0x1000, 0x2000) == 0x2000)
1192      {
10791193         memcpy (p, p + 0x1000, 0x1000);
10801194         memcpy (p + 0x3000, p + 0x2000, 0x1000);
10811195         mame_fclose (f);
r4576r4577
11151229
11161230MSX_SLOT_INIT(diskrom)
11171231{
1118   if (size != 0x4000) {
1232   if (size != 0x4000)
1233   {
11191234      logerror ("diskrom: error: the diskrom should be 16kb\n");
11201235      return 1;
11211236   }
r4576r4577
11361251static READ8_HANDLER (msx_diskrom_page1_r)
11371252{
11381253   const device_config *fdc = devtag_get_device(space->machine, "wd179x");
1139   switch (offset) {
1254   switch (offset)
1255   {
11401256   case 0: return wd17xx_status_r (fdc, 0);
11411257   case 1: return wd17xx_track_r (fdc, 0);
11421258   case 2: return wd17xx_sector_r (fdc, 0);
r4576r4577
11501266static READ8_HANDLER (msx_diskrom_page2_r)
11511267{
11521268   const device_config *fdc = devtag_get_device(space->machine, "wd179x");
1153   if (offset >= 0x7f8) {
1154      switch (offset) {
1269   if (offset >= 0x7f8)
1270   {
1271      switch (offset)
1272      {
11551273      case 0x7f8:
11561274         return wd17xx_status_r (fdc, 0);
11571275      case 0x7f9:
r4576r4577
11661284         return msx1.state[2]->mem[offset + 0x3800];
11671285      }
11681286   }
1169   else {
1287   else
1288   {
11701289      return 0xff;
11711290   }
11721291}
11731292
11741293MSX_SLOT_MAP(diskrom)
11751294{
1176   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
1177   switch (page) {
1295   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
1296   switch (page)
1297   {
11781298   case 0:
11791299      msx_cpu_setbank (machine, 1, msx1.empty);
11801300      msx_cpu_setbank (machine, 2, msx1.empty);
r4576r4577
11991319MSX_SLOT_WRITE(diskrom)
12001320{
12011321   const device_config *fdc = devtag_get_device(machine, "wd179x");
1202   if (addr >= 0xa000 && addr < 0xc000) {
1322   if (addr >= 0xa000 && addr < 0xc000)
1323   {
12031324      addr -= 0x4000;
12041325   }
1205   switch (addr) {
1326   switch (addr)
1327   {
12061328   case 0x7ff8:
12071329      wd17xx_command_w (fdc, 0, val);
12081330      break;
r4576r4577
12211343      break;
12221344   case 0x7ffd:
12231345      wd17xx_set_drive (fdc,val & 1);
1224      if ((state->mem[0x3ffd] ^ val) & 0x40) {
1346      if ((state->mem[0x3ffd] ^ val) & 0x40)
1347      {
12251348         set_led_status (0, !(val & 0x40));
12261349      }
12271350      state->mem[0x3ffd] = (val | 0x7c) & ~0x04;
r4576r4577
12311354
12321355MSX_SLOT_INIT(diskrom2)
12331356{
1234   if (size != 0x4000) {
1357   if (size != 0x4000)
1358   {
12351359      logerror ("diskrom2: error: the diskrom2 should be 16kb\n");
12361360      return 1;
12371361   }
r4576r4577
12521376static READ8_HANDLER (msx_diskrom2_page1_r)
12531377{
12541378   const device_config *fdc = devtag_get_device(space->machine, "wd179x");
1255   switch (offset) {
1379   switch (offset)
1380   {
12561381   case 0: return wd17xx_status_r(fdc, 0);
12571382   case 1: return wd17xx_track_r(fdc, 0);
12581383   case 2: return wd17xx_sector_r(fdc, 0);
r4576r4577
12661391static  READ8_HANDLER (msx_diskrom2_page2_r)
12671392{
12681393   const device_config *fdc = devtag_get_device(space->machine, "wd179x");
1269   if (offset >= 0x7b8) {
1270      switch (offset) {
1394   if (offset >= 0x7b8)
1395   {
1396      switch (offset)
1397      {
12711398      case 0x7b8:
12721399         return wd17xx_status_r (fdc, 0);
12731400      case 0x7b9:
r4576r4577
12821409         return msx1.state[2]->mem[offset + 0x3800];
12831410      }
12841411   }
1285   else {
1412   else
1413   {
12861414      return 0xff;
12871415   }
12881416}
12891417
12901418MSX_SLOT_MAP(diskrom2)
12911419{
1292   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
1293   switch (page) {
1420   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
1421   switch (page)
1422   {
12941423   case 0:
12951424      msx_cpu_setbank (machine, 1, msx1.empty);
12961425      msx_cpu_setbank (machine, 2, msx1.empty);
r4576r4577
13141443MSX_SLOT_WRITE(diskrom2)
13151444{
13161445   const device_config *fdc = devtag_get_device(machine, "wd179x");
1317   if (addr >= 0xa000 && addr < 0xc000) {
1446   if (addr >= 0xa000 && addr < 0xc000)
1447   {
13181448      addr -= 0x4000;
13191449   }
1320   switch (addr) {
1450   switch (addr)
1451   {
13211452   case 0x7fb8:
13221453      wd17xx_command_w (fdc, 0, val);
13231454      break;
r4576r4577
13341465      wd17xx_set_side (fdc,val & 1);
13351466      state->mem[0x3fbc] = val | 0xfe;
13361467      wd17xx_set_drive (fdc,val & 1);
1337      if ((state->mem[0x3fbc] ^ val) & 0x40) {
1468      if ((state->mem[0x3fbc] ^ val) & 0x40)
1469      {
13381470         set_led_status (0, !(val & 0x40));
13391471      }
13401472      state->mem[0x3fbc] = (val | 0x7c) & ~0x04;
r4576r4577
13441476
13451477MSX_SLOT_INIT(synthesizer)
13461478{
1347   if (size != 0x8000) {
1479   if (size != 0x8000)
1480   {
13481481      logerror ("synthesizer: error: rom file must be 32kb\n");
13491482      return 1;
13501483   }
r4576r4577
13621495
13631496MSX_SLOT_MAP(synthesizer)
13641497{
1365   switch (page) {
1498   switch (page)
1499   {
13661500   case 0:
13671501      msx_cpu_setbank (machine, 1, msx1.empty);
13681502      msx_cpu_setbank (machine, 2, msx1.empty);
r4576r4577
13831517
13841518MSX_SLOT_WRITE(synthesizer)
13851519{
1386   if (addr >= 0x4000 && addr < 0x8000 && !(addr & 0x0010)) {
1520   if (addr >= 0x4000 && addr < 0x8000 && !(addr & 0x0010))
1521   {
13871522      dac_data_w (devtag_get_device(machine, "dac"), val);
13881523   }
13891524}
13901525
13911526MSX_SLOT_INIT(majutsushi)
13921527{
1393   if (size != 0x20000) {
1528   if (size != 0x20000)
1529   {
13941530      logerror ("majutsushi: error: rom file must be 128kb\n");
13951531      return 1;
13961532   }
r4576r4577
14061542{
14071543   int i;
14081544
1409   for (i=0; i<4; i++) {
1545   for (i=0; i<4; i++)
1546   {
14101547      state->banks[i] = i;
14111548   }
14121549}
14131550
14141551MSX_SLOT_MAP(majutsushi)
14151552{
1416   switch (page) {
1553   switch (page)
1554   {
14171555   case 0:
14181556      msx_cpu_setbank (machine, 1, state->mem + state->banks[0] * 0x2000);
14191557      msx_cpu_setbank (machine, 2, state->mem + state->banks[1] * 0x2000);
r4576r4577
14351573
14361574MSX_SLOT_WRITE(majutsushi)
14371575{
1438   if (addr >= 0x5000 && addr < 0x6000) {
1576   if (addr >= 0x5000 && addr < 0x6000)
1577   {
14391578      dac_data_w (devtag_get_device(machine, "dac"), val);
14401579   }
1441   else if (addr >= 0x6000 && addr < 0x8000) {
1580   else if (addr >= 0x6000 && addr < 0x8000)
1581   {
14421582      state->banks[1] = val & 0x0f;
14431583      slot_majutsushi_map (machine, state, 1);
1444      if (msx1.state[0] == state) {
1584      if (msx1.state[0] == state)
1585      {
14451586         slot_konami_map (machine, state, 0);
14461587      }
14471588   }
1448   else if (addr >= 0x8000 && addr < 0xc000) {
1589   else if (addr >= 0x8000 && addr < 0xc000)
1590   {
14491591      state->banks[addr < 0xa000 ? 2 : 3] = val & 0x0f;
14501592      slot_majutsushi_map (machine, state, 2);
1451      if (msx1.state[3] == state) {
1593      if (msx1.state[3] == state)
1594      {
14521595         slot_konami_map (machine, state, 3);
14531596      }
14541597   }
r4576r4577
14601603   UINT8 *p;
14611604   int banks;
14621605
1463   if (size > 0x400000) {
1606   if (size > 0x400000)
1607   {
14641608      logerror ("fmpac: warning: truncating rom to 4mb\n");
14651609      size = 0x400000;
14661610   }
14671611   banks = size / 0x4000;
1468   if (size != banks * 0x4000 || (~(banks - 1) % banks)) {
1612   if (size != banks * 0x4000 || (~(banks - 1) % banks))
1613   {
14691614      logerror ("fmpac: error: must be a 2 power of 16kb\n");
14701615      return 1;
14711616   }
14721617
1473   if (!strncmp ((char*)mem + 0x18, "PAC2", 4)) {
1618   if (!strncmp ((char*)mem + 0x18, "PAC2", 4))
1619   {
14741620      state->cart.fmpac.sram_support = 1;
14751621      p = auto_malloc (0x4000);
14761622      memset (p, 0, 0x2000);
14771623      memset (p + 0x2000, 0xff, 0x2000);
14781624      state->cart.fmpac.mem = p;
14791625   }
1480   else {
1626   else
1627   {
14811628      state->cart.fmpac.sram_support = 0;
14821629      state->cart.fmpac.mem = NULL;
14831630   }
r4576r4577
14861633   state->size = size;
14871634   state->mem = mem;
14881635   state->bank_mask = banks - 1;
1489   if (!state->sramfile) {
1636   if (!state->sramfile)
1637   {
14901638      state->sramfile = sramfile;
14911639   }
14921640
r4576r4577
15011649   state->cart.fmpac.sram_active = 0;
15021650   state->cart.fmpac.opll_active = 0;
15031651   msx1.opll_active = 0;
1504   for (i=0; i<=state->bank_mask; i++) {
1652   for (i=0; i<=state->bank_mask; i++)
1653   {
15051654      state->mem[0x3ff6 + i * 0x4000] = 0;
15061655   }
15071656
r4576r4577
15171666
15181667MSX_SLOT_MAP(fmpac)
15191668{
1520   if (page == 1) {
1521      if (state->cart.fmpac.sram_active) {
1669   if (page == 1)
1670   {
1671      if (state->cart.fmpac.sram_active)
1672      {
15221673         msx_cpu_setbank (machine, 3, state->cart.fmpac.mem);
15231674         msx_cpu_setbank (machine, 4, state->cart.fmpac.mem + 0x2000);
15241675      }
1525      else {
1676      else
1677      {
15261678         msx_cpu_setbank (machine, 3, state->mem + state->banks[0] * 0x4000);
15271679         msx_cpu_setbank (machine, 4, state->mem + state->banks[0] * 0x4000 + 0x2000);
15281680      }
15291681   }
1530   else {
1682   else
1683   {
15311684      msx_cpu_setbank (machine, page * 2 + 1, msx1.empty);
15321685      msx_cpu_setbank (machine, page * 2 + 2, msx1.empty);
15331686   }
r4576r4577
15351688
15361689MSX_SLOT_WRITE(fmpac)
15371690{
1538   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
1691   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
15391692   int i, data;
15401693
1541   if (addr >= 0x4000 && addr < 0x6000 && state->cart.fmpac.sram_support) {
1542      if (state->cart.fmpac.sram_active || addr >= 0x5ffe) {
1694   if (addr >= 0x4000 && addr < 0x6000 && state->cart.fmpac.sram_support)
1695   {
1696      if (state->cart.fmpac.sram_active || addr >= 0x5ffe)
1697      {
15431698         state->cart.fmpac.mem[addr & 0x1fff] = val;
15441699      }
15451700
r4576r4577
15481703             state->cart.fmpac.mem[0x1fff] == 0x69);
15491704   }
15501705
1551   switch (addr) {
1706   switch (addr)
1707   {
15521708   case 0x7ff4:
1553      if (state->cart.fmpac.opll_active) {
1709      if (state->cart.fmpac.opll_active)
1710      {
15541711         ym2413_w (devtag_get_device(space->machine, "ay8910"), 0, val);
15551712      }
15561713      break;
15571714   case 0x7ff5:
1558      if (state->cart.fmpac.opll_active) {
1715      if (state->cart.fmpac.opll_active)
1716      {
15591717         ym2413_w (devtag_get_device(space->machine, "ay8910"), 1, val);
15601718      }
15611719      break;
15621720   case 0x7ff6:
15631721      data = val & 0x11;
1564      for (i=0; i<=state->bank_mask; i++) {
1722      for (i=0; i<=state->bank_mask; i++)
1723      {
15651724         state->mem[0x3ff6 + i * 0x4000] = data;
15661725      }
15671726      state->cart.fmpac.mem[0x3ff6] = data;
15681727      state->cart.fmpac.opll_active = val & 1;
1569      if ((msx1.opll_active ^ val) & 1) {
1728      if ((msx1.opll_active ^ val) & 1)
1729      {
15701730         logerror ("FM-PAC: OPLL %sactivated\n", val & 1 ? "" : "de");
15711731      }
15721732      msx1.opll_active = val & 1;
r4576r4577
15881748   mame_file *f;
15891749   char buf[PAC_HEADER_LEN];
15901750
1591   if (!state->cart.fmpac.sram_support) {
1751   if (!state->cart.fmpac.sram_support)
1752   {
15921753      logerror ("Your fmpac.rom does not support sram\n");
15931754      return 1;
15941755   }
15951756
1596   if (!state->sramfile) {
1757   if (!state->sramfile)
1758   {
15971759      logerror ("No sram filename provided\n");
15981760      return 1;
15991761   }
r4576r4577
16031765   {
16041766      if ((mame_fread (f, buf, PAC_HEADER_LEN) == PAC_HEADER_LEN) &&
16051767         !strncmp (buf, PAC_HEADER, PAC_HEADER_LEN) &&
1606         mame_fread (f, state->cart.fmpac.mem, 0x1ffe)) {
1768         mame_fread (f, state->cart.fmpac.mem, 0x1ffe))
1769         {
16071770         logerror ("fmpac: info: sram loaded\n");
16081771         mame_fclose (f);
16091772         return 0;
16101773      }
1611      else {
1774      else
1775      {
16121776         logerror ("fmpac: warning: failed to load sram\n");
16131777         mame_fclose (f);
16141778         return 1;
r4576r4577
16241788   file_error filerr;
16251789   mame_file *f;
16261790
1627   if (!state->cart.fmpac.sram_support || !state->sramfile) {
1791   if (!state->cart.fmpac.sram_support || !state->sramfile)
1792   {
16281793      return 0;
16291794   }
16301795
r4576r4577
16321797   if (filerr == FILERR_NONE)
16331798   {
16341799      if ((mame_fwrite (f, PAC_HEADER, PAC_HEADER_LEN) == PAC_HEADER_LEN) &&
1635         (mame_fwrite (f, state->cart.fmpac.mem, 0x1ffe) == 0x1ffe)) {
1800         (mame_fwrite (f, state->cart.fmpac.mem, 0x1ffe) == 0x1ffe))
1801         {
16361802         logerror ("fmpac: info: sram saved\n");
16371803         mame_fclose (f);
16381804         return 0;
16391805      }
1640      else {
1806      else
1807      {
16411808         logerror ("fmpac: warning: sram save to file failed\n");
16421809         mame_fclose (f);
16431810         return 1;
r4576r4577
16511818
16521819MSX_SLOT_INIT(superloadrunner)
16531820{
1654   if (size != 0x20000) {
1821   if (size != 0x20000)
1822   {
16551823      logerror ("superloadrunner: error: rom file should be exactly "
16561824              "128kb\n");
16571825      return 1;
r4576r4577
16721840
16731841MSX_SLOT_MAP(superloadrunner)
16741842{
1675   if (page == 2) {
1843   if (page == 2)
1844   {
16761845      UINT8 *mem = state->mem +
16771846            (msx1.superloadrunner_bank & state->bank_mask) * 0x4000;
16781847
16791848      msx_cpu_setbank (machine, 5, mem);
16801849      msx_cpu_setbank (machine, 6, mem + 0x2000);
16811850   }
1682   else {
1851   else
1852   {
16831853      msx_cpu_setbank (machine, page * 2 + 1, msx1.empty);
16841854      msx_cpu_setbank (machine, page * 2 + 2, msx1.empty);
16851855   }
r4576r4577
16871857
16881858MSX_SLOT_INIT(crossblaim)
16891859{
1690   if (size != 0x10000) {
1860   if (size != 0x10000)
1861   {
16911862      logerror ("crossblaim: error: rom file should be exactly 64kb\n");
16921863      return 1;
16931864   }
r4576r4577
17091880
17101881   /* This might look odd, but it's what happens on the real cartridge */
17111882
1712   switch (page) {
1883   switch (page)
1884   {
17131885   case 0:
17141886      if (state->banks[0] < 2){
17151887         mem = state->mem + state->banks[0] * 0x4000;
17161888         msx_cpu_setbank (machine, 1, mem);
17171889         msx_cpu_setbank (machine, 2, mem + 0x2000);
1718      } else {
1890      }
1891      else
1892      {
17191893         msx_cpu_setbank (machine, 1, msx1.empty);
17201894         msx_cpu_setbank (machine, 2, msx1.empty);
17211895      }
r4576r4577
17341908         mem = state->mem + state->banks[0] * 0x4000;
17351909         msx_cpu_setbank (machine, 7, mem);
17361910         msx_cpu_setbank (machine, 8, mem + 0x2000);
1737      } else {
1911      }
1912      else
1913      {
17381914         msx_cpu_setbank (machine, 7, msx1.empty);
17391915         msx_cpu_setbank (machine, 8, msx1.empty);
17401916      }
r4576r4577
17481924   if (!block) block = 1;
17491925   state->banks[0] = block;
17501926
1751   if (msx1.state[0] == state) {
1927   if (msx1.state[0] == state)
1928   {
17521929      slot_crossblaim_map (machine, state, 0);
17531930   }
1754   if (msx1.state[2] == state) {
1931   if (msx1.state[2] == state)
1932   {
17551933      slot_crossblaim_map (machine, state, 2);
17561934   }
1757   if (msx1.state[3] == state) {
1935   if (msx1.state[3] == state)
1936   {
17581937      slot_crossblaim_map (machine, state, 3);
17591938   }
17601939}
r4576r4577
17631942{
17641943   int banks;
17651944
1766   if (size > 0x200000) {
1945   if (size > 0x200000)
1946   {
17671947      logerror ("korean-80in1: warning: truncating to 2mb\n");
17681948      size = 0x200000;
17691949   }
17701950   banks = size / 0x2000;
1771   if (size != banks * 0x2000 || (~(banks - 1) % banks)) {
1951   if (size != banks * 0x2000 || (~(banks - 1) % banks))
1952   {
17721953      logerror ("korean-80in1: error: must be a 2 power of 8kb\n");
17731954      return 1;
17741955   }
r4576r4577
17841965{
17851966   int i;
17861967
1787   for (i=0; i<4; i++) {
1968   for (i=0; i<4; i++)
1969   {
17881970      state->banks[i] = i;
17891971   }
17901972}
17911973
17921974MSX_SLOT_MAP(korean80in1)
17931975{
1794   switch (page) {
1976   switch (page)
1977   {
17951978   case 0:
17961979      msx_cpu_setbank (machine, 1, msx1.empty);
17971980      msx_cpu_setbank (machine, 2, msx1.empty);
r4576r4577
18141997{
18151998   int bank;
18161999
1817   if (addr >= 0x4000 && addr < 0x4004) {
2000   if (addr >= 0x4000 && addr < 0x4004)
2001   {
18182002      bank = addr & 3;
18192003
18202004      state->banks[bank] = val & state->bank_mask;
1821      if (bank <= 1) {
2005      if (bank <= 1)
2006      {
18222007         slot_korean80in1_map (machine, state, 1);
18232008      }
1824      else if (msx1.state[2] == state) {
2009      else if (msx1.state[2] == state)
2010      {
18252011         slot_korean80in1_map (machine, state, 2);
18262012      }
18272013   }
r4576r4577
18312017{
18322018   int banks;
18332019
1834   if (size > 0x100000) {
2020   if (size > 0x100000)
2021   {
18352022      logerror ("korean-90in1: warning: truncating to 1mb\n");
18362023      size = 0x100000;
18372024   }
18382025   banks = size / 0x4000;
1839   if (size != banks * 0x4000 || (~(banks - 1) % banks)) {
2026   if (size != banks * 0x4000 || (~(banks - 1) % banks))
2027   {
18402028      logerror ("korean-90in1: error: must be a 2 power of 16kb\n");
18412029      return 1;
18422030   }
r4576r4577
18602048   mem = state->mem +
18612049      ((msx1.korean90in1_bank & mask) & state->bank_mask) * 0x4000;
18622050
1863   switch (page) {
2051   switch (page)
2052   {
18642053   case 0:
18652054      msx_cpu_setbank (machine, 1, msx1.empty);
18662055      msx_cpu_setbank (machine, 2, msx1.empty);
r4576r4577
18702059      msx_cpu_setbank (machine, 4, mem + 0x2000);
18712060      break;
18722061   case 2:
1873      switch (msx1.korean90in1_bank & 0xc0) {
2062      switch (msx1.korean90in1_bank & 0xc0)
2063      {
18742064      case 0x80: /* 32 kb mode */
18752065         mem += 0x4000;
18762066      default: /* ie. 0x00 and 0x40: same memory as page 1 */
r4576r4577
18932083{
18942084   int banks;
18952085
1896   if (size > 0x400000) {
2086   if (size > 0x400000)
2087   {
18972088      logerror ("korean-126in1: warning: truncating to 4mb\n");
18982089      size = 0x400000;
18992090   }
19002091   banks = size / 0x4000;
1901   if (size != banks * 0x4000 || (~(banks - 1) % banks)) {
2092   if (size != banks * 0x4000 || (~(banks - 1) % banks))
2093   {
19022094      logerror ("korean-126in1: error: must be a 2 power of 16kb\n");
19032095      return 1;
19042096   }
r4576r4577
19222114{
19232115   UINT8 *mem;
19242116
1925   switch (page) {
2117   switch (page)
2118   {
19262119   case 0:
19272120      msx_cpu_setbank (machine, 1, msx1.empty);
19282121      msx_cpu_setbank (machine, 2, msx1.empty);
r4576r4577
19452138
19462139MSX_SLOT_WRITE(korean126in1)
19472140{
1948   if (addr >= 0x4000 && addr < 0x4002) {
2141   if (addr >= 0x4000 && addr < 0x4002)
2142   {
19492143      int bank = addr & 1;
19502144      state->banks[bank] = val & state->bank_mask;
1951      if (bank == 0) {
2145      if (bank == 0)
2146      {
19522147         slot_korean126in1_map (machine, state, 1);
19532148      }
1954      else if (msx1.state[2] == state) {
2149      else if (msx1.state[2] == state)
2150      {
19552151         slot_korean126in1_map (machine, state, 2);
19562152      }
19572153   }
r4576r4577
19762172{
19772173   int i;
19782174
1979   for (i=0; i<4; i++) {
2175   for (i=0; i<4; i++)
2176   {
19802177      state->banks[i] = i;
19812178      state->cart.sccp.ram_mode[i] = 0;
19822179      state->cart.sccp.banks_saved[i] = i;
r4576r4577
19912188   int reg;
19922189
19932190
1994   if (offset >= 0x7e0) {
2191   if (offset >= 0x7e0)
2192   {
19952193      return msx1.state[2]->mem[
19962194            msx1.state[2]->banks[2] * 0x2000 + 0x1800 + offset];
19972195   }
19982196
19992197   reg = offset & 0xff;
20002198
2001   if (reg < 0x80) {
2199   if (reg < 0x80)
2200   {
20022201      return k051649_waveform_r (devtag_get_device(space->machine, "k051649"), reg);
20032202   }
2004   else if (reg < 0xa0) {
2203   else if (reg < 0xa0)
2204   {
20052205      /* nothing */
20062206   }
2007   else if (reg < 0xc0) {
2207   else if (reg < 0xc0)
2208   {
20082209      /* read wave 5 */
20092210      return k051649_waveform_r (devtag_get_device(space->machine, "k051649"), 0x80 + (reg & 0x1f));
20102211   }
20112212#if 0
2012   else if (reg < 0xe0) {
2213   else if (reg < 0xe0)
2214   {
20132215      /* write 0xff to deformation register */
20142216   }
20152217#endif
r4576r4577
20212223{
20222224   int reg;
20232225
2024   if (offset >= 0x7e0) {
2226   if (offset >= 0x7e0)
2227   {
20252228      return msx1.state[2]->mem[
20262229            msx1.state[2]->banks[3] * 0x2000 + 0x1800 + offset];
20272230   }
20282231
20292232   reg = offset & 0xff;
20302233
2031   if (reg < 0xa0) {
2234   if (reg < 0xa0)
2235   {
20322236      return k051649_waveform_r (devtag_get_device(space->machine, "k051649"), reg);
20332237   }
20342238#if 0
2035   else if (reg >= 0xc0 && reg < 0xe0) {
2239   else if (reg >= 0xc0 && reg < 0xe0)
2240   {
20362241      /* write 0xff to deformation register */
20372242   }
20382243#endif
r4576r4577
20422247
20432248MSX_SLOT_MAP(soundcartridge)
20442249{
2045   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
2046   switch (page) {
2250   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
2251   switch (page)
2252   {
20472253   case 0:
20482254      msx_cpu_setbank (machine, 1, state->mem + state->banks[2] * 0x2000);
20492255      msx_cpu_setbank (machine, 2, state->mem + state->banks[3] * 0x2000);
r4576r4577
20692275
20702276MSX_SLOT_WRITE(soundcartridge)
20712277{
2072   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
2278   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
20732279   int i;
20742280
2075   if (addr < 0x4000) {
2281   if (addr < 0x4000)
2282   {
20762283      return;
20772284   }
2078   else if (addr < 0x6000) {
2079      if (state->cart.sccp.ram_mode[0]) {
2285   else if (addr < 0x6000)
2286   {
2287      if (state->cart.sccp.ram_mode[0])
2288      {
20802289         state->mem[state->banks[0] * 0x2000 + (addr & 0x1fff)] = val;
20812290      }
2082      else if (addr >= 0x5000 && addr < 0x5800) {
2291      else if (addr >= 0x5000 && addr < 0x5800)
2292      {
20832293         state->banks[0] = val & state->bank_mask;
20842294         state->cart.sccp.banks_saved[0] = val;
20852295         slot_soundcartridge_map (machine, state, 1);
2086         if (msx1.state[3] == state) {
2296         if (msx1.state[3] == state)
2297         {
20872298            slot_soundcartridge_map (machine, state, 3);
20882299         }
20892300      }
20902301   }
2091   else if (addr < 0x8000) {
2092      if (state->cart.sccp.ram_mode[1]) {
2302   else if (addr < 0x8000)
2303   {
2304      if (state->cart.sccp.ram_mode[1])
2305      {
20932306         state->mem[state->banks[1] * 0x2000 + (addr & 0x1fff)] = val;
20942307      }
2095      else if (addr >= 0x7000 && addr < 0x7800) {
2308      else if (addr >= 0x7000 && addr < 0x7800)
2309      {
20962310         state->banks[1] = val & state->bank_mask;
20972311         state->cart.sccp.banks_saved[1] = val;
2098         if (msx1.state[3] == state) {
2312         if (msx1.state[3] == state)
2313         {
20992314            slot_soundcartridge_map (machine, state, 3);
21002315         }
21012316         slot_soundcartridge_map (machine, state, 1);
21022317      }
21032318   }
2104   else if (addr < 0xa000) {
2105      if (state->cart.sccp.ram_mode[2]) {
2319   else if (addr < 0xa000)
2320   {
2321      if (state->cart.sccp.ram_mode[2])
2322      {
21062323         state->mem[state->banks[2] * 0x2000 + (addr & 0x1fff)] = val;
21072324      }
2108      else if (addr >= 0x9000 && addr < 0x9800) {
2325      else if (addr >= 0x9000 && addr < 0x9800)
2326      {
21092327         state->banks[2] = val & state->bank_mask;
21102328         state->cart.sccp.banks_saved[2] = val;
21112329         state->cart.sccp.scc_active =
21122330               (((val & 0x3f) == 0x3f) && !(state->cart.sccp.mode & 0x20));
21132331
21142332         slot_soundcartridge_map (machine, state, 2);
2115         if (msx1.state[0] == state) {
2333         if (msx1.state[0] == state)
2334         {
21162335            slot_soundcartridge_map (machine, state, 0);
21172336         }
21182337      }
2119      else if (addr >= 0x9800 && state->cart.sccp.scc_active) {
2338      else if (addr >= 0x9800 && state->cart.sccp.scc_active)
2339      {
21202340         const device_config *k051649 = devtag_get_device(space->machine, "k051649");
21212341         int offset = addr & 0xff;
21222342
2123         if (offset < 0x80) {
2343         if (offset < 0x80)
2344         {
21242345            k051649_waveform_w (k051649, offset, val);
21252346         }
2126         else if (offset < 0xa0) {
2347         else if (offset < 0xa0)
2348         {
21272349            offset &= 0xf;
21282350
2129            if (offset < 0xa) {
2351            if (offset < 0xa)
2352            {
21302353               k051649_frequency_w (k051649, offset, val);
21312354            }
2132            else if (offset < 0x0f) {
2355            else if (offset < 0x0f)
2356            {
21332357               k051649_volume_w (k051649, offset - 0xa, val);
21342358            }
2135            else if (offset == 0x0f) {
2359            else if (offset == 0x0f)
2360            {
21362361               k051649_keyonoff_w (k051649, 0, val);
21372362            }
21382363         }
21392364#if 0
2140         else if (offset < 0xe0) {
2365         else if (offset < 0xe0)
2366         {
21412367            /* write to deformation register */
21422368         }
21432369#endif
21442370      }
21452371   }
2146   else if (addr < 0xbffe) {
2147      if (state->cart.sccp.ram_mode[3]) {
2372   else if (addr < 0xbffe)
2373   {
2374      if (state->cart.sccp.ram_mode[3])
2375      {
21482376         state->mem[state->banks[3] * 0x2000 + (addr & 0x1fff)] = val;
21492377      }
2150      else if (addr >= 0xb000 && addr < 0xb800) {
2378      else if (addr >= 0xb000 && addr < 0xb800)
2379      {
21512380         state->cart.sccp.banks_saved[3] = val;
21522381         state->banks[3] = val & state->bank_mask;
21532382         state->cart.sccp.sccp_active =
21542383               (val & 0x80) && (state->cart.sccp.mode & 0x20);
21552384         slot_soundcartridge_map (machine, state, 2);
2156         if (msx1.state[0] == state) {
2385         if (msx1.state[0] == state)
2386         {
21572387            slot_soundcartridge_map (machine, state, 0);
21582388         }
21592389      }
2160      else if (addr >= 0xb800 && state->cart.sccp.sccp_active) {
2390      else if (addr >= 0xb800 && state->cart.sccp.sccp_active)
2391      {
21612392         const device_config *k051649 = devtag_get_device(space->machine, "k051649");
21622393         int offset = addr & 0xff;
21632394
2164         if (offset < 0xa0) {
2395         if (offset < 0xa0)
2396         {
21652397            k052539_waveform_w (k051649, offset, val);
21662398         }
2167         else if (offset < 0xc0) {
2399         else if (offset < 0xc0)
2400         {
21682401            offset &= 0x0f;
21692402
2170            if (offset < 0x0a) {
2403            if (offset < 0x0a)
2404            {
21712405               k051649_frequency_w (k051649, offset, val);
21722406            }
2173            else if (offset < 0x0f) {
2407            else if (offset < 0x0f)
2408            {
21742409               k051649_volume_w (k051649, offset - 0x0a, val);
21752410            }
2176            else if (offset == 0x0f) {
2411            else if (offset == 0x0f)
2412            {
21772413               k051649_keyonoff_w (k051649, 0, val);
21782414            }
21792415         }
21802416#if 0
2181         else if (offset < 0xe0) {
2417         else if (offset < 0xe0)
2418         {
21822419            /* write to deformation register */
21832420         }
21842421#endif
21852422      }
21862423   }
2187   else if (addr < 0xc000) {
2424   else if (addr < 0xc000)
2425   {
21882426      /* write to mode register */
2189      if ((state->cart.sccp.mode ^ val) & 0x20) {
2427      if ((state->cart.sccp.mode ^ val) & 0x20)
2428      {
21902429         logerror ("soundcartrige: changed to %s mode\n",
21912430                     val & 0x20 ? "scc+" : "scc");
21922431      }
21932432      state->cart.sccp.mode = val;
2194      if (val & 0x10) {
2433      if (val & 0x10)
2434      {
21952435         /* all ram mode */
2196         for (i=0; i<4; i++) {
2436         for (i=0; i<4; i++)
2437         {
21972438            state->cart.sccp.ram_mode[i] = 1;
21982439         }
21992440      }
2200      else {
2441      else
2442      {
22012443         state->cart.sccp.ram_mode[0] = val & 1;
22022444         state->cart.sccp.ram_mode[1] = val & 2;
22032445         state->cart.sccp.ram_mode[2] = (val & 4) && (val & 0x20);
src/mess/machine/microtan.c
r4576r4577
156156    /* The 6502 IRQ line is active low and probably driven
157157       by open collector outputs (guess). Since MAME/MESS use
158158       a non-0 value for ASSERT_LINE we OR the signals here */
159    cpu_set_input_line(machine->cpu[0], 0, via_0_irq_line | via_1_irq_line | kbd_irq_line);
159    cputag_set_input_line(machine, "maincpu", 0, via_0_irq_line | via_1_irq_line | kbd_irq_line);
160160}
161161
162162static const device_config *cassette_device_image(running_machine *machine)
r4576r4577
388388/* This callback is called one clock cycle after BFF2 is written (delayed nmi) */
389389static TIMER_CALLBACK(microtan_pulse_nmi)
390390{
391    cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, PULSE_LINE);
391    cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE);
392392}
393393
394394WRITE8_HANDLER ( microtan_bffx_w )
r4576r4577
404404        break;
405405    case 1: /* BFF1: write delayed NMI */
406406        LOG(("microtan_bff1_w: %d <- %02x (delayed NMI)\n", offset, data));
407        timer_set(space->machine, cpu_clocks_to_attotime(space->machine->cpu[0], 8), NULL, 0, microtan_pulse_nmi);
407        timer_set(space->machine, cputag_clocks_to_attotime(space->machine, "maincpu", 8), NULL, 0, microtan_pulse_nmi);
408408        break;
409409    case 2: /* BFF2: write keypad column write (what is this meant for?) */
410410        LOG(("microtan_bff2_w: %d <- %02x (keypad column)\n", offset, data));
r4576r4577
702702    LOG(("microtan_snapshot_copy: PC:%02X%02X P:%02X A:%02X X:%02X Y:%02X SP:1%02X",
703703        snapshot_buff[base+1], snapshot_buff[base+0], snapshot_buff[base+2], snapshot_buff[base+3],
704704        snapshot_buff[base+4], snapshot_buff[base+5], snapshot_buff[base+6]);
705    cpu_set_reg(machine->cpu[0], M6502_PC, snapshot_buff[base+0] + 256 * snapshot_buff[base+1]));
706    cpu_set_reg(machine->cpu[0], M6502_P, snapshot_buff[base+2]);
707    cpu_set_reg(machine->cpu[0], M6502_A, snapshot_buff[base+3]);
708    cpu_set_reg(machine->cpu[0], M6502_X, snapshot_buff[base+4]);
709    cpu_set_reg(machine->cpu[0], M6502_Y, snapshot_buff[base+5]);
710    cpu_set_reg(machine->cpu[0], M6502_S, snapshot_buff[base+6]);
705    cpu_set_reg(cputag_get_cpu(machine, "maincpu"), M6502_PC, snapshot_buff[base+0] + 256 * snapshot_buff[base+1]));
706    cpu_set_reg(cputag_get_cpu(machine, "maincpu"), M6502_P, snapshot_buff[base+2]);
707    cpu_set_reg(cputag_get_cpu(machine, "maincpu"), M6502_A, snapshot_buff[base+3]);
708    cpu_set_reg(cputag_get_cpu(machine, "maincpu"), M6502_X, snapshot_buff[base+4]);
709    cpu_set_reg(cputag_get_cpu(machine, "maincpu"), M6502_Y, snapshot_buff[base+5]);
710    cpu_set_reg(cputag_get_cpu(machine, "maincpu"), M6502_S, snapshot_buff[base+6]);
711711}
712712
713713static void microtan_snapshot_copy(running_machine *machine, UINT8 *snapshot_buff, int snapshot_size)
714714{
715715    UINT8 *RAM = memory_region(machine, "maincpu");
716   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
716   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
717717   const device_config *via_0 = devtag_get_device(machine, "via6522_0");
718718   const device_config *via_1 = devtag_get_device(machine, "via6522_1");
719719   const device_config *ay8910 = devtag_get_device(machine, "ay8910.1");
r4576r4577
869869{
870870    UINT8 *dst = memory_region(machine, "gfx2");
871871    int i;
872    const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
872    const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
873873
874874    for (i = 0; i < 256; i++)
875875    {
src/mess/machine/mac.c
r4576r4577
226226static void mac_install_memory(running_machine *machine, offs_t memory_begin, offs_t memory_end,
227227   offs_t memory_size, void *memory_data, int is_rom, int bank)
228228{
229   const address_space* space = cpu_get_address_space(machine->cpu[0],ADDRESS_SPACE_PROGRAM);
229   const address_space* space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
230230   offs_t memory_mask;
231231   read16_space_func rh;
232232   write16_space_func wh;
r4576r4577
290290
291291   if (last_taken_interrupt != -1)
292292   {
293      cpu_set_input_line(machine->cpu[0], last_taken_interrupt, CLEAR_LINE);
293      cputag_set_input_line(machine, "maincpu", last_taken_interrupt, CLEAR_LINE);
294294      last_taken_interrupt = -1;
295295   }
296296
297297   if (take_interrupt != -1)
298298   {
299      cpu_set_input_line(machine->cpu[0], take_interrupt, ASSERT_LINE);
299      cputag_set_input_line(machine, "maincpu", take_interrupt, ASSERT_LINE);
300300      last_taken_interrupt = take_interrupt;
301301   }
302302}
r4576r4577
910910         scc_set_status(scc, 0x02);
911911   }
912912
913   //cpu_set_input_line(machine->cpu[0], 2, ASSERT_LINE);
913   //cputag_set_input_line(machine, "maincpu", 2, ASSERT_LINE);
914914   set_scc_interrupt(machine, 1);
915915}
916916
r4576r4577
17701770static void mac_via_irq(const device_config *device, int state)
17711771{
17721772   /* interrupt the 68k (level 1) */
1773   //cpu_set_input_line(machine->cpu[0], 1, state);
1773   //cputag_set_input_line(machine, "maincpu", 1, state);
17741774   set_via_interrupt(device->machine, state);
17751775}
17761776
r4576r4577
18431843
18441844static READ8_DEVICE_HANDLER(mac_via2_in_a)
18451845{
1846   logerror("VIA2 IN A (PC %x)\n", cpu_get_pc(device->machine->cpu[0]));
1846   logerror("VIA2 IN A (PC %x)\n", cpu_get_pc(cputag_get_cpu(device->machine, "maincpu")));
18471847
18481848   return 0;
18491849}
18501850
18511851static READ8_DEVICE_HANDLER(mac_via2_in_b)
18521852{
1853   logerror("VIA2 IN B (PC %x)\n", cpu_get_pc(device->machine->cpu[0]));
1853   logerror("VIA2 IN B (PC %x)\n", cpu_get_pc(cputag_get_cpu(device->machine, "maincpu")));
18541854
18551855   return 0;
18561856}
18571857
18581858static WRITE8_DEVICE_HANDLER(mac_via2_out_a)
18591859{
1860   logerror("VIA2 OUT A: %02x (PC %x)\n", data, cpu_get_pc(device->machine->cpu[0]));
1860   logerror("VIA2 OUT A: %02x (PC %x)\n", data, cpu_get_pc(cputag_get_cpu(device->machine, "maincpu")));
18611861}
18621862
18631863static WRITE8_DEVICE_HANDLER(mac_via2_out_b)
18641864{
1865   logerror("VIA2 OUT B: %02x (PC %x)\n", data, cpu_get_pc(device->machine->cpu[0]));
1865   logerror("VIA2 OUT B: %02x (PC %x)\n", data, cpu_get_pc(cputag_get_cpu(device->machine, "maincpu")));
18661866}
18671867
18681868/* *************************************************************************
r4576r4577
19601960      // classic will fail RAM test and try to boot appletalk if RAM is not all zero
19611961      memset(mess_ram, 0, mess_ram_size);
19621962
1963      memory_set_direct_update_handler(cpu_get_address_space(machine->cpu[0],ADDRESS_SPACE_PROGRAM), overlay_opbaseoverride);
1963      memory_set_direct_update_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), overlay_opbaseoverride);
19641964      mac_overlay = 1;
19651965   }
19661966
r4576r4577
19691969
19701970   inquiry_timeout = timer_alloc(machine, inquiry_timeout_func, NULL);
19711971
1972   debug_cpu_set_dasm_override(machine->cpu[0], mac_dasm_override);
1972   debug_cpu_set_dasm_override(cputag_get_cpu(machine, "maincpu"), mac_dasm_override);
19731973
19741974   /* save state stuff */
19751975   state_save_register_global(machine, mac_overlay);
r4576r4577
30573057   logerror("mac_trace_trap: %s at 0x%08x: %s\n",cpu_name_local, addr, buf);
30583058}
30593059#endif
3060
3061
3062
src/mess/machine/msx.c
r4576r4577
299299
300300void msx_vdp_interrupt(running_machine *machine, int i)
301301{
302   cpu_set_input_line (machine->cpu[0], 0, (i ? HOLD_LINE : CLEAR_LINE));
302   cputag_set_input_line (machine, "maincpu", 0, (i ? HOLD_LINE : CLEAR_LINE));
303303}
304304
305305static void msx_ch_reset_core (running_machine *machine)
r4576r4577
473473
474474   memset (&msx1, 0, sizeof (MSX));
475475   /* LOAD_DEVICE is called before DRIVER_INIT */
476   for (i=0; i<MSX_MAX_CARTS; i++) {
476   for (i=0; i<MSX_MAX_CARTS; i++)
477   {
477478      msx1.cart_state[i] = cart_state[i];
478479   }
479480
480   cpu_set_input_line_vector (machine->cpu[0], 0, 0xff);
481   cpu_set_input_line_vector (cputag_get_cpu(machine, "maincpu"), 0, 0xff);
481482
482483   msx_memory_init (machine);
483484
484   z80_set_cycle_tables( machine->cpu[0], cc_op, cc_cb, cc_ed, cc_xy, cc_xycb, cc_ex );
485   z80_set_cycle_tables( cputag_get_cpu(machine, "maincpu"), cc_op, cc_cb, cc_ed, cc_xy, cc_xycb, cc_ex );
485486}
486487
487488INTERRUPT_GEN( msx2_interrupt )
src/mess/machine/mz700.c
r4576r4577
670670/* port EB */
671671WRITE8_HANDLER( mz800_ramaddr_w )
672672{
673   mz800_ramaddr = (cpu_get_reg(space->machine->cpu[0], Z80_BC) & 0xff00) | (data & 0xff);
673   mz800_ramaddr = (cpu_get_reg(cputag_get_cpu(space->machine, "maincpu"), Z80_BC) & 0xff00) | (data & 0xff);
674674   LOG(1,"mz800_ramaddr_w",("%04X\n", mz800_ramaddr),space->machine);
675675}
676676
src/mess/machine/lisa.c
r4576r4577
224224
225225   /*if (RSIR)
226226      // serial interrupt
227      cpu_set_input_line_and_vector(machine->cpu[0], M68K_IRQ_6, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
227      cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_6, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
228228   else if (int0)
229229      // external interrupt
230      cpu_set_input_line_and_vector(machine->cpu[0], M68K_IRQ_5, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
230      cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_5, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
231231   else if (int1)
232232      // external interrupt
233      cpu_set_input_line_and_vector(machine->cpu[0], M68K_IRQ_4, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
233      cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
234234   else if (int2)
235235      // external interrupt
236      cpu_set_input_line_and_vector(machine->cpu[0], M68K_IRQ_3, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
236      cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_3, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
237237   else*/ if (KBIR)
238238      /* COPS VIA interrupt */
239      cpu_set_input_line_and_vector(machine->cpu[0], M68K_IRQ_2, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
239      cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_2, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
240240   else if (FDIR || VTIR)
241241      /* floppy disk or VBl */
242      cpu_set_input_line_and_vector(machine->cpu[0], M68K_IRQ_1, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
242      cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_1, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
243243   else
244244      /* clear all interrupts */
245      cpu_set_input_line_and_vector(machine->cpu[0], M68K_IRQ_1, CLEAR_LINE, M68K_INT_ACK_AUTOVECTOR);
245      cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_1, CLEAR_LINE, M68K_INT_ACK_AUTOVECTOR);
246246}
247247
248248static void set_parity_error_pending(running_machine *machine, int value)
r4576r4577
252252   parity_error_pending = value;
253253   if (parity_error_pending)
254254   {
255      cpu_set_input_line_and_vector(machine->cpu[0], M68K_IRQ_7, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
255      cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_7, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
256256   }
257257   else
258258   {
259      cpu_set_input_line(machine->cpu[0], M68K_IRQ_7, CLEAR_LINE);
259      cputag_set_input_line(machine, "maincpu", M68K_IRQ_7, CLEAR_LINE);
260260   }
261261#else
262262   /* work-around... */
263263   if ((! parity_error_pending) && value)
264264   {
265265      parity_error_pending = 1;
266      cpu_set_input_line_and_vector(machine->cpu[0], M68K_IRQ_7, PULSE_LINE, M68K_INT_ACK_AUTOVECTOR);
266      cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_7, PULSE_LINE, M68K_INT_ACK_AUTOVECTOR);
267267   }
268268   else if (parity_error_pending && (! value))
269269   {
r4576r4577
426426#if 0
427427                  if (keycode == NMIcode)
428428                  {   /* generate NMI interrupt */
429                     cpu_set_input_line(machine->cpu[0], M68K_IRQ_7, PULSE_LINE);
430                     cpu_set_input_line_vector(machine->cpu[0], M68K_IRQ_7, M68K_INT_ACK_AUTOVECTOR);
429                     cputag_set_input_line(machine, "maincpu", M68K_IRQ_7, PULSE_LINE);
430                     cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_7, M68K_INT_ACK_AUTOVECTOR);
431431                  }
432432#endif
433433                  COPS_queue_data(machine, & keycode, 1);
r4576r4577
969969
970970   }
971971
972   if (cpu_get_reg(space->machine->cpu[0], M68K_SR) & 0x2000)
972   if (cpu_get_reg(cputag_get_cpu(space->machine, "maincpu"), M68K_SR) & 0x2000)
973973      /* supervisor mode -> force register file 0 */
974974      the_seg = 0;
975975
r4576r4577
11391139
11401140   videoROM_ptr = memory_region(machine, "gfx1");
11411141
1142   memory_set_direct_update_handler(cpu_get_address_space(machine->cpu[0],ADDRESS_SPACE_PROGRAM), lisa_OPbaseoverride);
1143   memory_set_direct_update_handler(cpu_get_address_space(machine->cpu[1],ADDRESS_SPACE_PROGRAM), lisa_fdc_OPbaseoverride);
1142   memory_set_direct_update_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), lisa_OPbaseoverride);
1143   memory_set_direct_update_handler(cputag_get_address_space(machine, "fdccpu",  ADDRESS_SPACE_PROGRAM), lisa_fdc_OPbaseoverride);
11441144
1145   device_set_info_fct(machine->cpu[0], CPUINFO_FCT_M68K_RESET_CALLBACK, (genf *)/*lisa_reset_instr_callback*/NULL);
1145   devtag_set_info_fct(machine, "maincpu", CPUINFO_FCT_M68K_RESET_CALLBACK, (genf *)/*lisa_reset_instr_callback*/NULL);
11461146
11471147   /* init MMU */
11481148
r4576r4577
14991499      }
15001500   }
15011501
1502   if (cpu_get_reg(space->machine->cpu[0], M68K_SR) & 0x2000)
1502   if (cpu_get_reg(cputag_get_cpu(space->machine, "maincpu"), M68K_SR) & 0x2000)
15031503      /* supervisor mode -> force register file 0 */
15041504      the_seg = 0;
15051505
r4576r4577
16031603               if ((time_in_frame >= 364) && (time_in_frame <= 375))
16041604               {
16051605                  answer = videoROM_ptr[videoROM_address|0x80] << 8;
1606              logerror("reading1 %06X=%04x PC=%06x time=%d\n", address, answer, cpu_get_pc(space->machine->cpu[0]), time_in_frame);
1606              logerror("reading1 %06X=%04x PC=%06x time=%d\n", address, answer, cpu_get_pc(cputag_get_cpu(space->machine, "maincpu")), time_in_frame);
16071607               }
16081608               else
16091609               {
16101610                  answer = videoROM_ptr[videoROM_address] << 8;
1611              logerror("reading2 %06X=%04x PC=%06x time=%d\n", address, answer, cpu_get_pc(space->machine->cpu[0]), time_in_frame);
1611              logerror("reading2 %06X=%04x PC=%06x time=%d\n", address, answer, cpu_get_pc(cputag_get_cpu(space->machine, "maincpu")), time_in_frame);
16121612               }
16131613            }
16141614
r4576r4577
17071707      }
17081708   }
17091709
1710   if (cpu_get_reg(space->machine->cpu[0], M68K_SR) & 0x2000)
1710   if (cpu_get_reg(cputag_get_cpu(space->machine, "maincpu"), M68K_SR) & 0x2000)
17111711      /* supervisor mode -> force register file 0 */
17121712      the_seg = 0;
17131713
r4576r4577
18691869      seg &= ~2;
18701870      break;
18711871   case 0x0010:   /* SETUP register SET */
1872       logerror("setup SET PC=%x\n", cpu_get_pc(machine->cpu[0]));
1872       logerror("setup SET PC=%x\n", cpu_get_pc(cputag_get_cpu(machine, "maincpu")));
18731873      setup = 1;
18741874      break;
18751875   case 0x0012:   /* SETUP register RESET */
1876       logerror("setup UNSET PC=%x\n", cpu_get_pc(machine->cpu[0]));
1876       logerror("setup UNSET PC=%x\n", cpu_get_pc(cputag_get_cpu(machine, "maincpu")));
18771877      setup = 0;
18781878      break;
18791879   case 0x001A:   /* Enable Vertical Retrace Interrupt */
1880       logerror("enable retrace PC=%x\n", cpu_get_pc(machine->cpu[0]));
1880       logerror("enable retrace PC=%x\n", cpu_get_pc(cputag_get_cpu(machine, "maincpu")));
18811881      VTMSK = 1;
18821882      break;
18831883   case 0x0018:   /* Disable Vertical Retrace Interrupt */
1884       logerror("disable retrace PC=%x\n", cpu_get_pc(machine->cpu[0]));
1884       logerror("disable retrace PC=%x\n", cpu_get_pc(cputag_get_cpu(machine, "maincpu")));
18851885      VTMSK = 0;
18861886      set_VTIR(machine, 2);
18871887      break;
r4576r4577
20172017         else
20182018                  answer |= 0x04;
20192019         /* huh... we need to emulate some other bits */
2020          logerror("read status PC=%x val=%x\n", cpu_get_pc(space->machine->cpu[0]),answer);
2020          logerror("read status PC=%x val=%x\n", cpu_get_pc(cputag_get_cpu(space->machine, "maincpu")), answer);
20212021
20222022         break;
20232023      }
src/mess/machine/lynx.c
r4576r4577
785785   int i; int o;int colors;
786786
787787   blitter.memory_accesses = 0;
788   blitter.mem = memory_get_read_ptr(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000);
788   blitter.mem = memory_get_read_ptr(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000);
789789
790790   blitter.xoff   = GET_WORD(suzy.data, 0x04);
791791   blitter.yoff   = GET_WORD(suzy.data, 0x06);
r4576r4577
886886   }
887887
888888   if (0)
889      timer_set(machine, cpu_clocks_to_attotime(machine->cpu[0], blitter.memory_accesses*20), NULL, 0, lynx_blitter_timer);
889      timer_set(machine, cputag_clocks_to_attotime(machine, "maincpu", blitter.memory_accesses*20), NULL, 0, lynx_blitter_timer);
890890}
891891
892892
r4576r4577
10051005      case 0x92:   /* Better check this with docs! */
10061006         if (!attotime_compare(blitter.time, attotime_zero))
10071007         {
1008            if (cpu_attotime_to_clocks(space->machine->cpu[0], attotime_sub(timer_get_time(space->machine), blitter.time)) > blitter.memory_accesses * 20)
1008            if (cputag_attotime_to_clocks(space->machine, "maincpu", attotime_sub(timer_get_time(space->machine), blitter.time)) > blitter.memory_accesses * 20)
10091009            {
10101010               suzy.data[offset] &= ~0x01; //blitter finished
10111011               blitter.time = attotime_zero;
r4576r4577
13611361
13621362static void lynx_timer_signal_irq(running_machine *machine, int which)
13631363{
1364   if ( ( lynx_timer[which].cntrl1 & 0x80 ) && ( which != 4 ) ) { // irq flag handling later
1364   if ( ( lynx_timer[which].cntrl1 & 0x80 ) && ( which != 4 ) )
1365   { // irq flag handling later
13651366      mikey.data[0x81] |= ( 1 << which );
1366      cpu_set_input_line(machine->cpu[0], M65SC02_IRQ_LINE, ASSERT_LINE);
1367      cputag_set_input_line(machine, "maincpu", M65SC02_IRQ_LINE, ASSERT_LINE);
13671368   }
1368   switch ( which ) {
1369   switch ( which )
1370   {
13691371   case 0:
13701372      lynx_timer_count_down( machine, 2 );
13711373      lynx_line++;
r4576r4577
13921394
13931395void lynx_timer_count_down(running_machine *machine, int which)
13941396{
1395   if ( ( lynx_timer[which].cntrl1 & 0x0f ) == 0x0f ) {
1396      if ( lynx_timer[which].counter > 0 ) {
1397   if ( ( lynx_timer[which].cntrl1 & 0x0f ) == 0x0f )
1398   {
1399      if ( lynx_timer[which].counter > 0 )
1400      {
13971401         lynx_timer[which].counter--;
13981402         return;
13991403      }
1400      if ( lynx_timer[which].counter == 0 ) {
1404      if ( lynx_timer[which].counter == 0 )
1405      {
14011406         lynx_timer[which].cntrl2 |= 8;
14021407         lynx_timer_signal_irq(machine, which);
1403         if ( lynx_timer[which].cntrl1 & 0x10 ) {
1408         if ( lynx_timer[which].cntrl1 & 0x10 )
1409         {
14041410            lynx_timer[which].counter = lynx_timer[which].bakup;
1405         } else {
1411         }
1412         else
1413         {
14061414            lynx_timer[which].counter--;
14071415         }
14081416         return;
r4576r4577
15441552   if (uart.serctl & 0x80)
15451553   {
15461554      mikey.data[0x81] |= 0x10;
1547      cpu_set_input_line(machine->cpu[0], M65SC02_IRQ_LINE, ASSERT_LINE);
1555      cputag_set_input_line(machine, "maincpu", M65SC02_IRQ_LINE, ASSERT_LINE);
15481556    }
15491557}
15501558
r4576r4577
17001708      mikey.data[0x81] &= ~data; // clear interrupt source
17011709      logerror("mikey write %.2x %.2x\n", offset, data);
17021710      if (!mikey.data[0x81])
1703         cpu_set_input_line(space->machine->cpu[0], M65SC02_IRQ_LINE, CLEAR_LINE);
1711         cputag_set_input_line(space->machine, "maincpu", M65SC02_IRQ_LINE, CLEAR_LINE);
17041712      break;
17051713
17061714   /* Is this correct? */
r4576r4577
18031811static void lynx_reset(running_machine *machine)
18041812{
18051813   int i;
1806   lynx_memory_config_w(cputag_get_address_space(machine,"maincpu",ADDRESS_SPACE_PROGRAM), 0, 0);
1814   lynx_memory_config_w(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0, 0);
18071815
1808   cpu_set_input_line(machine->cpu[0], M65SC02_IRQ_LINE, CLEAR_LINE);
1816   cputag_set_input_line(machine, "maincpu", M65SC02_IRQ_LINE, CLEAR_LINE);
18091817
18101818   memset(&suzy, 0, sizeof(suzy));
18111819   memset(&mikey, 0, sizeof(mikey));
r4576r4577
18391847
18401848static STATE_POSTLOAD( lynx_postload )
18411849{
1842   lynx_memory_config_w( cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0, lynx_memory_config);
1850   lynx_memory_config_w( cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0, lynx_memory_config);
18431851}
18441852
18451853MACHINE_START( lynx )
src/mess/machine/kaypro.c
r4576r4577
2828
2929static WRITE8_DEVICE_HANDLER( kaypro_interrupt )
3030{
31   cpu_set_input_line(device->machine->cpu[0], 0, data);
31   cputag_set_input_line(device->machine, "maincpu", 0, data);
3232}
3333
3434static READ8_DEVICE_HANDLER( pio_system_r )
r4576r4577
248248/* when sio devcb'ed like pio is, change to use pio's int handler */
249249static void kaypro_int_sio(const device_config *device, int state)
250250{
251   cpu_set_input_line(device->machine->cpu[0], 0, state);
251   cputag_set_input_line(device->machine, "maincpu", 0, state);
252252}
253253
254254const z80sio_interface kaypro_sio_intf =
r4576r4577
337337   {
338338      case WD17XX_DRQ_CLR:
339339      case WD17XX_IRQ_CLR:
340         cpu_set_input_line(device->machine->cpu[0], INPUT_LINE_NMI, 0);
340         cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_NMI, 0);
341341         break;
342342      case WD17XX_DRQ_SET:
343343      case WD17XX_IRQ_SET:
344         if (cpu_get_reg(device->machine->cpu[0], Z80_HALT))
345            cpu_set_input_line(device->machine->cpu[0], INPUT_LINE_NMI, PULSE_LINE);
344         if (cpu_get_reg(cputag_get_cpu(device->machine, "maincpu"), Z80_HALT))
345            cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE);
346346         break;
347347   }
348348}
src/mess/machine/lviv.c
r4576r4577
163163
164164WRITE8_HANDLER ( lviv_io_w )
165165{
166   const address_space *cpuspace = cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
166   const address_space *cpuspace = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
167167   if (startup_mem_map)
168168   {
169169      startup_mem_map = 0;
r4576r4577
221221
222222MACHINE_RESET( lviv )
223223{
224   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
224   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
225225   memory_set_direct_update_handler(space, lviv_directoverride);
226226
227227   lviv_video_ram = mess_ram + 0xc000;
r4576r4577
266266   /* Set registers */
267267   lo = data[0x14112] & 0x0ff;
268268   hi = data[0x14111] & 0x0ff;
269   cpu_set_reg(machine->cpu[0], I8085_BC, (hi << 8) | lo);
269   cpu_set_reg(cputag_get_cpu(machine, "maincpu"), I8085_BC, (hi << 8) | lo);
270270   lo = data[0x14114] & 0x0ff;
271271   hi = data[0x14113] & 0x0ff;
272   cpu_set_reg(machine->cpu[0], I8085_DE, (hi << 8) | lo);
272   cpu_set_reg(cputag_get_cpu(machine, "maincpu"), I8085_DE, (hi << 8) | lo);
273273   lo = data[0x14116] & 0x0ff;
274274   hi = data[0x14115] & 0x0ff;
275   cpu_set_reg(machine->cpu[0], I8085_HL, (hi << 8) | lo);
275   cpu_set_reg(cputag_get_cpu(machine, "maincpu"), I8085_HL, (hi << 8) | lo);
276276   lo = data[0x14118] & 0x0ff;
277277   hi = data[0x14117] & 0x0ff;
278   cpu_set_reg(machine->cpu[0], I8085_AF, (hi << 8) | lo);
278   cpu_set_reg(cputag_get_cpu(machine, "maincpu"), I8085_AF, (hi << 8) | lo);
279279   lo = data[0x14119] & 0x0ff;
280280   hi = data[0x1411a] & 0x0ff;
281   cpu_set_reg(machine->cpu[0], I8085_SP, (hi << 8) | lo);
281   cpu_set_reg(cputag_get_cpu(machine, "maincpu"), I8085_SP, (hi << 8) | lo);
282282   lo = data[0x1411b] & 0x0ff;
283283   hi = data[0x1411c] & 0x0ff;
284   cpu_set_reg(machine->cpu[0], I8085_PC, (hi << 8) | lo);
284   cpu_set_reg(cputag_get_cpu(machine, "maincpu"), I8085_PC, (hi << 8) | lo);
285285
286286   /* Memory dump */
287287   memcpy (mess_ram, data+0x0011, 0xc000);
r4576r4577
297297
298298static void dump_registers(running_machine *machine)
299299{
300   logerror("PC   = %04x\n", (unsigned) cpu_get_reg(machine->cpu[0], I8085_PC));
301   logerror("SP   = %04x\n", (unsigned) cpu_get_reg(machine->cpu[0], I8085_SP));
302   logerror("AF   = %04x\n", (unsigned) cpu_get_reg(machine->cpu[0], I8085_AF));
303   logerror("BC   = %04x\n", (unsigned) cpu_get_reg(machine->cpu[0], I8085_BC));
304   logerror("DE   = %04x\n", (unsigned) cpu_get_reg(machine->cpu[0], I8085_DE));
305   logerror("HL   = %04x\n", (unsigned) cpu_get_reg(machine->cpu[0], I8085_HL));
300   logerror("PC   = %04x\n", (unsigned) cpu_get_reg(cputag_get_cpu(machine, "maincpu"), I8085_PC));
301   logerror("SP   = %04x\n", (unsigned) cpu_get_reg(cputag_get_cpu(machine, "maincpu"), I8085_SP));
302   logerror("AF   = %04x\n", (unsigned) cpu_get_reg(cputag_get_cpu(machine, "maincpu"), I8085_AF));
303   logerror("BC   = %04x\n", (unsigned) cpu_get_reg(cputag_get_cpu(machine, "maincpu"), I8085_BC));
304   logerror("DE   = %04x\n", (unsigned) cpu_get_reg(cputag_get_cpu(machine, "maincpu"), I8085_DE));
305   logerror("HL   = %04x\n", (unsigned) cpu_get_reg(cputag_get_cpu(machine, "maincpu"), I8085_HL));
306306}
307307
308308static int lviv_verify_snapshot (UINT8 * data, UINT32 size)
src/mess/machine/mc10.c
r4576r4577
4242   mc10_bfff = 0x00;
4343   mc10_keyboard_strobe = 0x00;
4444
45   memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM),
45   memory_install_readwrite8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM),
4646         0x4000,   0x4000 + mess_ram_size - 1,   0, 0, SMH_BANK1, SMH_BANK1);
4747   memory_set_bankptr(machine, 1, mess_ram);
4848
src/mess/machine/mtx.c
r4576r4577
220220   /* set ram bank, for invalid pages a nop-handler will be installed */
221221   if (ram_page >= mess_ram_size/0x8000)
222222   {
223      memory_install_readwrite8_handler(cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x4000, 0x7fff, 0, 0, SMH_NOP, SMH_NOP);
224      memory_install_readwrite8_handler(cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x8000, 0xbfff, 0, 0, SMH_NOP, SMH_NOP);
223      memory_install_readwrite8_handler(cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x4000, 0x7fff, 0, 0, SMH_NOP, SMH_NOP);
224      memory_install_readwrite8_handler(cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0xbfff, 0, 0, SMH_NOP, SMH_NOP);
225225   }
226226   else if (ram_page + 1 == mess_ram_size/0x8000)
227227   {
228      memory_install_readwrite8_handler(cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x4000, 0x7fff, 0, 0, SMH_NOP, SMH_NOP);
229      memory_install_readwrite8_handler(cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x8000, 0xbfff, 0, 0, SMH_BANK4, SMH_BANK4);
228      memory_install_readwrite8_handler(cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x4000, 0x7fff, 0, 0, SMH_NOP, SMH_NOP);
229      memory_install_readwrite8_handler(cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0xbfff, 0, 0, SMH_BANK4, SMH_BANK4);
230230      memory_set_bank(space->machine, 4, ram_page);
231231   }
232232   else
233233   {
234      memory_install_readwrite8_handler(cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x4000, 0x7fff, 0, 0, SMH_BANK3, SMH_BANK3);
235      memory_install_readwrite8_handler(cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x8000, 0xbfff, 0, 0, SMH_BANK4, SMH_BANK4);
234      memory_install_readwrite8_handler(cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x4000, 0x7fff, 0, 0, SMH_BANK3, SMH_BANK3);
235      memory_install_readwrite8_handler(cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0xbfff, 0, 0, SMH_BANK4, SMH_BANK4);
236236      memory_set_bank(space->machine, 3, ram_page);
237237      memory_set_bank(space->machine, 4, ram_page);
238238   }
r4576r4577
267267
268268   /* install handlers for dart interface */
269269   device = devtag_get_device(machine, "z80dart");
270   space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_IO);
270   space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO);
271271   memory_install_readwrite8_device_handler(space, device, 0x0c, 0x0d, 0, 0, z80dart_d_r, z80dart_d_w);
272272   memory_install_readwrite8_device_handler(space, device, 0x0e, 0x0f, 0, 0, z80dart_c_r, z80dart_c_w);
273273}
src/mess/machine/mikro80.c
r4576r4577
6060{
6161}
6262
63static READ8_DEVICE_HANDLER( mikro80_8255_portb_device_r ) { return mikro80_8255_portb_r(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM), offset); }
64static READ8_DEVICE_HANDLER( mikro80_8255_portc_device_r ) { return mikro80_8255_portc_r(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM), offset); }
65static WRITE8_DEVICE_HANDLER( mikro80_8255_porta_device_w ) { mikro80_8255_porta_w(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM), offset, data); }
63static READ8_DEVICE_HANDLER( mikro80_8255_portb_device_r ) { return mikro80_8255_portb_r(cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM), offset); }
64static READ8_DEVICE_HANDLER( mikro80_8255_portc_device_r ) { return mikro80_8255_portc_r(cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM), offset); }
65static WRITE8_DEVICE_HANDLER( mikro80_8255_porta_device_w ) { mikro80_8255_porta_w(cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM), offset, data); }
6666
6767const ppi8255_interface mikro80_ppi8255_interface =
6868{
src/mess/machine/mz80.c
r4576r4577
8484
8585static PIT8253_OUTPUT_CHANGED( pit_out2_changed )
8686{
87   cpu_set_input_line(device->machine->cpu[0], 0, HOLD_LINE);
87   cputag_set_input_line(device->machine, "maincpu", 0, HOLD_LINE);
8888}
8989
9090const ppi8255_interface mz80k_8255_int =
src/mess/machine/kc.c
r4576r4577
150150#if 0
151151static void kc85_disc_hw_ctc_interrupt(int state)
152152{
153   cpu_set_input_line(machine->cpu[1], 0, state);
153   cputag_set_input_line(machine, "disc", 0, state);
154154}
155155#endif
156156
r4576r4577
235235
236236static TIMER_CALLBACK(kc85_disk_reset_timer_callback)
237237{
238   cpu_set_reg(machine->cpu[1], REG_GENPC, 0x0f000);
239   cpu_set_reg(machine->cpu[0], REG_GENPC, 0x0f000);
238   cpu_set_reg(cputag_get_cpu(machine, "disc"), REG_GENPC, 0x0f000);
239   cpu_set_reg(cputag_get_cpu(machine, "maincpu"), REG_GENPC, 0x0f000);
240240}
241241
242242static void kc_disc_interface_init(running_machine *machine)
r4576r4577
244244   timer_set(machine, attotime_zero, NULL, 0, kc85_disk_reset_timer_callback);
245245
246246   /* hold cpu at reset */
247   cpu_set_input_line(machine->cpu[1], INPUT_LINE_RESET, ASSERT_LINE);
247   cputag_set_input_line(machine, "disc", INPUT_LINE_RESET, ASSERT_LINE);
248248}
249249
250250/*****************/
r4576r4577
11321132
11331133static void kc85_4_update_0x08000(running_machine *machine)
11341134{
1135   const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM );
1135   const address_space *space = cputag_get_address_space( machine, "maincpu", ADDRESS_SPACE_PROGRAM );
11361136   unsigned char *ram_page;
11371137
11381138    if (kc85_pio_data[1] & (1<<5))
r4576r4577
12011201/* update status of memory area 0x0000-0x03fff */
12021202static void kc85_4_update_0x00000(running_machine *machine)
12031203{
1204   const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM );
1204   const address_space *space = cputag_get_address_space( machine, "maincpu", ADDRESS_SPACE_PROGRAM );
12051205
12061206   /* access ram? */
12071207   if (kc85_pio_data[0] & (1<<1))
r4576r4577
12441244/* update status of memory area 0x4000-0x07fff */
12451245static void kc85_4_update_0x04000(running_machine *machine)
12461246{
1247   const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM );
1247   const address_space *space = cputag_get_address_space( machine, "maincpu", ADDRESS_SPACE_PROGRAM );
12481248   read8_space_func rh;
12491249   write8_space_func wh;
12501250
r4576r4577
12951295/* update memory address 0x0c000-0x0e000 */
12961296static void kc85_4_update_0x0c000(running_machine *machine)
12971297{
1298   const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM );
1298   const address_space *space = cputag_get_address_space( machine, "maincpu", ADDRESS_SPACE_PROGRAM );
12991299   read8_space_func rh;
13001300
13011301   if (kc85_86_data & (1<<7))
r4576r4577
13371337/* update memory address 0x0e000-0x0ffff */
13381338static void kc85_4_update_0x0e000(running_machine *machine)
13391339{
1340   const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM );
1340   const address_space *space = cputag_get_address_space( machine, "maincpu", ADDRESS_SPACE_PROGRAM );
13411341   read8_space_func rh;
13421342
13431343   if (kc85_pio_data[0] & (1<<0))
r4576r4577
14531453/* update memory region 0x0c000-0x0e000 */
14541454static void kc85_3_update_0x0c000(running_machine *machine)
14551455{
1456   const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM );
1456   const address_space *space = cputag_get_address_space( machine, "maincpu", ADDRESS_SPACE_PROGRAM );
14571457   read8_space_func rh;
14581458
14591459   if (kc85_pio_data[0] & (1<<7))
r4576r4577
14761476/* update memory address 0x0e000-0x0ffff */
14771477static void kc85_3_update_0x0e000(running_machine *machine)
14781478{
1479   const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM );
1479   const address_space *space = cputag_get_address_space( machine, "maincpu", ADDRESS_SPACE_PROGRAM );
14801480   read8_space_func rh;
14811481
14821482   if (kc85_pio_data[0] & (1<<0))
r4576r4577
15011501for write operations */
15021502static void kc85_3_update_0x00000(running_machine *machine)
15031503{
1504   const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM );
1504   const address_space *space = cputag_get_address_space( machine, "maincpu", ADDRESS_SPACE_PROGRAM );
15051505   read8_space_func rh;
15061506   write8_space_func wh;
15071507
r4576r4577
15511551/* SMH_BANK3 is used for read, SMH_BANK8 is used for write */
15521552static void kc85_3_update_0x08000(running_machine *machine)
15531553{
1554   const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM );
1554   const address_space *space = cputag_get_address_space( machine, "maincpu", ADDRESS_SPACE_PROGRAM );
15551555   read8_space_func rh;
15561556   write8_space_func wh;
15571557    unsigned char *ram_page;
r4576r4577
16991699
17001700static TIMER_CALLBACK(kc85_reset_timer_callback)
17011701{
1702   cpu_set_reg(machine->cpu[0], REG_GENPC, 0x0f000);
1702   cpu_set_reg(cputag_get_cpu(machine, "maincpu"), REG_GENPC, 0x0f000);
17031703}
17041704
17051705 READ8_HANDLER ( kc85_pio_data_r )
r4576r4577
17381738
17391739static void kc85_pio_interrupt(const device_config *device, int state)
17401740{
1741   cpu_set_input_line(device->machine->cpu[0], 0, state);
1741   cputag_set_input_line(device->machine, "maincpu", 0, state);
17421742}
17431743
17441744static void kc85_ctc_interrupt(const device_config *device, int state)
17451745{
1746   cpu_set_input_line(device->machine->cpu[0], 1, state);
1746   cputag_set_input_line(device->machine, "maincpu", 1, state);
17471747}
17481748
17491749/* callback for ardy output from PIO */
src/mess/drivers/mac.c
r4576r4577
6868
6969static READ8_HANDLER(mac_asc_r)
7070{
71   logerror("ASC: Read @ %x (PC %x)\n", offset, cpu_get_pc(space->machine->cpu[0]));
71   logerror("ASC: Read @ %x (PC %x)\n", offset, cpu_get_pc(cputag_get_cpu(space->machine, "maincpu")));
7272
7373   return mac_asc_regs[offset];
7474}
7575
7676static WRITE8_HANDLER(mac_asc_w)
7777{
78   logerror("ASC: %02x to %x (PC %x)\n", data, offset, cpu_get_pc(space->machine->cpu[0]));
78   logerror("ASC: %02x to %x (PC %x)\n", data, offset, cpu_get_pc(cputag_get_cpu(space->machine, "maincpu")));
7979
8080   mac_asc_regs[offset] = data;
8181}
r4576r4577
448448COMP( 1987,   macse,    0,      0,   macse,  macplus,  macse,          macse,      "Apple Computer",   "Macintosh SE",  0 )
449449COMP( 1990,   macclasc, 0,      0,   macse,  macplus,  macclassic,          macse,      "Apple Computer",   "Macintosh Classic",  GAME_NOT_WORKING )
450450COMP( 1990,   maclc,    0,      0,  maclc,    macplus,  maclc,      maclc,      "Apple Computer",   "Macintosh LC",  GAME_NOT_WORKING )
451
src/mess/drivers/mk1.c
r4576r4577
164164
165165static void mk1_interrupt( const device_config *device, UINT16 addr, int level )
166166{
167   cpu_set_input_line_vector(device->machine->cpu[0], 0, addr );
168   cpu_set_input_line(device->machine->cpu[0], 0, level ? F8_INT_INTR : F8_INT_NONE );
167   cpu_set_input_line_vector(cputag_get_cpu(device->machine, "maincpu"), 0, addr );
168   cputag_set_input_line(device->machine,"maincpu", 0, level ? F8_INT_INTR : F8_INT_NONE );
169169}
170170
171171
src/mess/drivers/mpf1.c
r4576r4577
6363{
6464   // halt-LED; the red one, is turned on when the processor is halted
6565   // TODO: processor seems to halt, but restarts(?) at 0x0000 after a while -> fix
66   led_halt = (UINT8) device_get_info_int(machine->cpu[0], CPUINFO_INT_REGISTER + Z80_HALT);
66   led_halt = (UINT8) devtag_get_info_int(machine, "maincpu", CPUINFO_INT_REGISTER + Z80_HALT);
6767   set_led_status(1, led_tone);
6868}
6969
r4576r4577
368368        The next statement converts this to the following assignment: (which is compatible with draw_led())
369369        bit      7 6 5 4 3 2 1 0
370370        segment  p g f e d c b a */
371   if( data | ( cpu_get_pc(device->machine->cpu[0]) != 0x63C ) )
371   if( data | ( cpu_get_pc(cputag_get_cpu(device->machine, "maincpu")) != 0x63C ) )
372372   {
373373      data = ( (data & 0x08) >> 3 ) |
374374             ( (data & 0x10) >> 3 ) |
r4576r4577
435435
436436static TIMER_CALLBACK( irq0_callback )
437437{
438   irq0_line_hold( machine->cpu[0] );
438   irq0_line_hold( cputag_get_cpu(machine, "maincpu") );
439439}
440440
441441static MACHINE_RESET( mpf1 )
src/mess/drivers/mk2.c
r4576r4577
155155      dac_data_w(dac_device,newdata&1?80:0);
156156   mk2_led[4]|=newdata;
157157
158   cpu_set_input_line( device->machine->cpu[0], M6502_IRQ_LINE, (newdata & 0x80) ? CLEAR_LINE : ASSERT_LINE );
158   cputag_set_input_line( device->machine, "maincpu", M6502_IRQ_LINE, (newdata & 0x80) ? CLEAR_LINE : ASSERT_LINE );
159159}
160160
161161
src/mess/drivers/mtx.c
r4576r4577
240240
241241static void mtx_ctc_interrupt(const device_config *device, int state)
242242{
243   cpu_set_input_line(device->machine->cpu[0], 0, state);
243   cputag_set_input_line(device->machine, "maincpu", 0, state);
244244}
245245
246246
src/mess/drivers/mephisto.c
r4576r4577
175175static TIMER_CALLBACK( update_nmi )
176176{
177177   const device_config *speaker = devtag_get_device(machine, "beep");
178   cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI,PULSE_LINE);
178   cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI,PULSE_LINE);
179179   // dac_data_w(0,led_status&64?128:0);
180180   beep_set_state(speaker,led_status&64?1:0);
181181}
r4576r4577
185185   lcd_shift_counter=3;
186186   // timer_pulse(machine, ATTOTIME_IN_HZ(60), NULL, 0, update_leds);
187187   timer_pulse(machine, ATTOTIME_IN_HZ(600), NULL, 0, update_nmi);
188   // cpu_set_input_line(machine->cpu[0], M65C02_IRQ_LINE,CLEAR_LINE);
188   // cputag_set_input_line(machine, "maincpu", M65C02_IRQ_LINE,CLEAR_LINE);
189189   //beep_set_frequency(0, 4000);
190190}
191191
192192
193193static MACHINE_RESET( mephisto )
194194{
195   lcd_shift_counter=3;
195   lcd_shift_counter = 3;
196196}
197197
198198

Previous 15994 Revisions Next


© 1998-2018 The MESS Team