Previous 15994 Revisions Next

r3659 Thursday 27th November, 2008 at 17:07:02 UTC by Fabio Priuli
[THOMSON][GAMECOM] fixed and re-enabled
[src/mess]mess.mak messdriv.c
[src/mess/audio]mea8000.c mea8000.h
[src/mess/devices]thomflop.c
[src/mess/includes]thomson.h
[src/mess/machine]gamecom.c mc6843.c mc6846.c mc6846.h mc6854.c thomson.c
[src/mess/video]thomson.c

src/mess/audio/mea8000.c
r3658r3659
7575   /* configuration parameters */
7676
7777   int channel;                  /* first argument for dac_data_w */
78   write8_machine_func req_out_func;  /* 1-bit 'ready' output, not negated */
78   write8_space_func req_out_func;  /* 1-bit 'ready' output, not negated */
7979
8080   /* state */
8181
r3658r3659
200200      frame end to compose a new frame.
201201   */
202202   if (mea8000.req_out_func)
203      mea8000.req_out_func(machine, 0, mea8000_accept_byte());
203      mea8000.req_out_func(cputag_get_address_space(machine,"main",ADDRESS_SPACE_PROGRAM), 0, mea8000_accept_byte());
204204}
205205
206206
r3658r3659
551551      return mea8000_accept_byte() << 7;
552552
553553   default:
554      logerror( "$%04x mea8000_r invalid read offset %i\n", activecpu_get_previouspc(), offset );
554      logerror( "$%04x mea8000_r invalid read offset %i\n", cpu_get_previouspc(space->cpu), offset );
555555   }
556556   return 0;
557557}
r3658r3659
566566      {
567567         /* got pitch byte before first frame */
568568         mea8000.pitch = 2 * data;
569         LOG(( "$%04x %f: mea8000_w pitch %i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), mea8000.pitch ));
569         LOG(( "$%04x %f: mea8000_w pitch %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), mea8000.pitch ));
570570         mea8000.state = MEA8000_WAIT_FIRST;
571571         mea8000.bufpos = 0;
572572      }
573573      else if (mea8000.bufpos == 4)
574574      {
575575         /* overflow */
576         LOG(( "$%04x %f: mea8000_w data overflow %02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ));
576         LOG(( "$%04x %f: mea8000_w data overflow %02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data ));
577577      }
578578      else
579579      {
580580         /* enqueue frame byte */
581         LOG(( "$%04x %f: mea8000_w data %02X in frame pos %i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()),
581         LOG(( "$%04x %f: mea8000_w data %02X in frame pos %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()),
582582               data, mea8000.bufpos ));
583583         mea8000.buf[mea8000.bufpos] = data;
584584         mea8000.bufpos++;
r3658r3659
595595            mea8000.state = MEA8000_STARTED;
596596         }
597597      }
598      mea8000_update_req(machine);
598      mea8000_update_req(space->machine);
599599      break;
600600
601601   case 1: /* command register */
r3658r3659
612612         mea8000_stop_frame();
613613
614614      LOG(( "$%04x %f: mea8000_w command %02X stop=%i cont=%i roe=%i\n",
615            activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data,
615            cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data,
616616            stop, mea8000.cont, mea8000.roe ));
617617
618      mea8000_update_req(machine);
618      mea8000_update_req(space->machine);
619619      break;
620620   }
621621
622622   default:
623      logerror( "$%04x mea8000_w invalid write offset %i\n", activecpu_get_previouspc(), offset );
623      logerror( "$%04x mea8000_w invalid write offset %i\n", cpu_get_previouspc(space->cpu), offset );
624624   }
625625}
626626
r3658r3659
654654
655655
656656
657void mea8000_config ( running_machine *machine, int channel, write8_machine_func req_out_func )
657void mea8000_config ( running_machine *machine, int channel, write8_space_func req_out_func )
658658{
659659   int i;
660660   mea8000_init_tables(machine);
r3658r3659
662662   mea8000.req_out_func = req_out_func;
663663   mea8000.timer = timer_alloc( mea8000_timer_expire , NULL);
664664
665   state_save_register_item( "mea8000", 0, mea8000.state );
666   state_save_register_item_array( "mea8000", 0, mea8000.buf );
667   state_save_register_item( "mea8000", 0, mea8000.bufpos );
668   state_save_register_item( "mea8000", 0, mea8000.cont );
669   state_save_register_item( "mea8000", 0, mea8000.roe );
670   state_save_register_item( "mea8000", 0, mea8000.framelength );
671   state_save_register_item( "mea8000", 0, mea8000.framepos );
672   state_save_register_item( "mea8000", 0, mea8000.framelog );
673   state_save_register_item( "mea8000", 0, mea8000.lastsample );
674   state_save_register_item( "mea8000", 0, mea8000.sample );
675   state_save_register_item( "mea8000", 0, mea8000.phi );
665   state_save_register_item( "mea8000", NULL, 0, mea8000.state );
666   state_save_register_item_array( "mea8000", NULL, 0, mea8000.buf );
667   state_save_register_item( "mea8000", NULL, 0, mea8000.bufpos );
668   state_save_register_item( "mea8000", NULL, 0, mea8000.cont );
669   state_save_register_item( "mea8000", NULL, 0, mea8000.roe );
670   state_save_register_item( "mea8000", NULL, 0, mea8000.framelength );
671   state_save_register_item( "mea8000", NULL, 0, mea8000.framepos );
672   state_save_register_item( "mea8000", NULL, 0, mea8000.framelog );
673   state_save_register_item( "mea8000", NULL, 0, mea8000.lastsample );
674   state_save_register_item( "mea8000", NULL, 0, mea8000.sample );
675   state_save_register_item( "mea8000", NULL, 0, mea8000.phi );
676676   for (i=0; i<4; i++)
677677   {
678      state_save_register_item( "mea8000", i, mea8000.f[i].fm );
679      state_save_register_item( "mea8000", i, mea8000.f[i].last_fm );
680      state_save_register_item( "mea8000", i, mea8000.f[i].bw );
681      state_save_register_item( "mea8000", i, mea8000.f[i].last_bw );
682      state_save_register_item( "mea8000", i, mea8000.f[i].output );
683      state_save_register_item( "mea8000", i, mea8000.f[i].last_output );
678      state_save_register_item( "mea8000", NULL, i, mea8000.f[i].fm );
679      state_save_register_item( "mea8000", NULL, i, mea8000.f[i].last_fm );
680      state_save_register_item( "mea8000", NULL, i, mea8000.f[i].bw );
681      state_save_register_item( "mea8000", NULL, i, mea8000.f[i].last_bw );
682      state_save_register_item( "mea8000", NULL, i, mea8000.f[i].output );
683      state_save_register_item( "mea8000", NULL, i, mea8000.f[i].last_output );
684684   }
685   state_save_register_item( "mea8000", 0, mea8000.last_ampl );
686   state_save_register_item( "mea8000", 0, mea8000.ampl );
687   state_save_register_item( "mea8000", 0, mea8000.last_pitch );
688   state_save_register_item( "mea8000", 0, mea8000.pitch );
689   state_save_register_item( "mea8000", 0, mea8000.noise );
685   state_save_register_item( "mea8000", NULL, 0, mea8000.last_ampl );
686   state_save_register_item( "mea8000", NULL, 0, mea8000.ampl );
687   state_save_register_item( "mea8000", NULL, 0, mea8000.last_pitch );
688   state_save_register_item( "mea8000", NULL, 0, mea8000.pitch );
689   state_save_register_item( "mea8000", NULL, 0, mea8000.noise );
690690
691691   mea8000_reset(machine);
692692}
src/mess/audio/mea8000.h
r3658r3659
99#ifndef MEA8000
1010#define MEA8000
1111
12extern void mea8000_config ( running_machine *machine, int channel, write8_machine_func req_out_func );
12extern void mea8000_config ( running_machine *machine, int channel, write8_space_func req_out_func );
1313
1414/* reset by external signal */
1515extern void mea8000_reset ( running_machine *machine );
src/mess/video/thomson.c
r3658r3659
864864
865865
866866
867void thom_set_mode_point ( int point )
867void thom_set_mode_point ( running_machine *machine, int point )
868868{
869869   assert( point >= 0 && point <= 1 );
870870   thom_mode_point = ( ! point ) * 0x2000;
871   memory_set_bank( THOM_VRAM_BANK, ! point );
871   memory_set_bank( machine, THOM_VRAM_BANK, ! point );
872872}
873873
874874
r3658r3659
11431143
11441144   thom_mode_point = 0;
11451145   state_save_register_global( thom_mode_point );
1146   memory_set_bank( THOM_VRAM_BANK, 0 );
1146   memory_set_bank( machine, THOM_VRAM_BANK, 0 );
11471147
11481148   thom_floppy_rcount = 0;
11491149   thom_floppy_wcount = 0;
src/mess/includes/thomson.h
r3658r3659
268268extern void thom_set_init_callback ( void (*cb) ( int init ) );
269269
270270/* TO7 TO7/70 MO5 video bank switch */
271extern void thom_set_mode_point ( int point );
271extern void thom_set_mode_point ( running_machine *machine, int point );
272272
273273/* set the palette index for the border color */
274274extern void thom_set_border_color ( unsigned color );
src/mess/messdriv.c
r3658r3659
916916//128u4   DRIVER( bebox2 )   /* BeBox Dual603-133                        */
917917
918918   /* Tiger Electronics */
919//128u4   DRIVER( gamecom )   /* Tiger Game.com                           */
919   DRIVER( gamecom )   /* Tiger Game.com                           */
920920
921921   /* Thomson */
922//128u4   DRIVER( t9000 )      /* 1980 Thomson T9000 (TO7 prototype)            */
923//128u4   DRIVER( to7 )      /* 1982 Thomson TO7                           */
924//128u4   DRIVER( to770 )      /* 1984 Thomson TO7/70                        */
925//128u4   DRIVER( to770a )   /* 198? Thomson TO7/70 arabic version            */
926//128u4   DRIVER( mo5 )      /* 1984 Thomson MO5                           */
927//128u4   DRIVER( mo5e )      /* 1986 Thomson MO5E (export version)            */
928//128u4   DRIVER( to9 )      /* 1985 Thomson T09                           */
929//128u4   DRIVER( to8 )      /* 1986 Thomson T08                           */
930//128u4   DRIVER( to8d )      /* 1987 Thomson T08D                        */
931//128u4   DRIVER( to9p )      /* 1986 Thomson T09+                        */
932//128u4   DRIVER( mo6 )      /* 1986 Thomson MO6                           */
933//128u4   DRIVER( mo5nr )      /* 1986 Thomson MO5 NR                        */
934//128u4   DRIVER( pro128 )   /* 1986 Olivetti Prodest PC 128                  */
922   DRIVER( t9000 )      /* 1980 Thomson T9000 (TO7 prototype)            */
923   DRIVER( to7 )      /* 1982 Thomson TO7                           */
924   DRIVER( to770 )      /* 1984 Thomson TO7/70                        */
925   DRIVER( to770a )   /* 198? Thomson TO7/70 arabic version            */
926   DRIVER( mo5 )      /* 1984 Thomson MO5                           */
927   DRIVER( mo5e )      /* 1986 Thomson MO5E (export version)            */
928   DRIVER( to9 )      /* 1985 Thomson T09                           */
929   DRIVER( to8 )      /* 1986 Thomson T08                           */
930   DRIVER( to8d )      /* 1987 Thomson T08D                        */
931   DRIVER( to9p )      /* 1986 Thomson T09+                        */
932   DRIVER( mo6 )      /* 1986 Thomson MO6                           */
933   DRIVER( mo5nr )      /* 1986 Thomson MO5 NR                        */
934   DRIVER( pro128 )   /* 1986 Olivetti Prodest PC 128                  */
935935
936936   /* Cybiko, Inc. */
937937//128u4   DRIVER( cybikov1 )   /* Cybiko Wireless Intertainment System - Classic V1 */
src/mess/machine/mc6854.c
r3658r3659
777777   case 0: /* status register 1 */
778778      mc6854_update_sr1();
779779      LOG(( "%f $%04x mc6854_r: get SR1=$%02X (rda=%i,s2rq=%i,fd=%i,cts=%i,tu=%i,tdra=%i,irq=%i)\n",
780            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6854->sr1,
780            attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), mc6854->sr1,
781781            ( mc6854->sr1 & RDA) ? 1 : 0, ( mc6854->sr1 & S2RQ) ? 1 : 0,
782782            ( mc6854->sr1 & FD ) ? 1 : 0, ( mc6854->sr1 & CTS ) ? 1 : 0,
783783            ( mc6854->sr1 & TU ) ? 1 : 0, ( mc6854->sr1 & TDRA) ? 1 : 0,
r3658r3659
787787   case 1: /* status register 2 */
788788      mc6854_update_sr2();
789789      LOG(( "%f $%04x mc6854_r: get SR2=$%02X (ap=%i,fv=%i,ridle=%i,rabt=%i,err=%i,dcd=%i,ovrn=%i,rda2=%i)\n",
790            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6854->sr2,
790            attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), mc6854->sr2,
791791            ( mc6854->sr2 & AP   ) ? 1 : 0, ( mc6854->sr2 & FV  ) ? 1 : 0,
792792            ( mc6854->sr2 & RIDLE) ? 1 : 0, ( mc6854->sr2 & RABT) ? 1 : 0,
793793            ( mc6854->sr2 & ERR  ) ? 1 : 0, ( mc6854->sr2 & DCD ) ? 1 : 0,
r3658r3659
799799   {
800800      UINT8 data = mc6854_rfifo_pop();
801801      LOG(( "%f $%04x mc6854_r: get data $%02X\n",
802            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
802            attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data ));
803803      return data;
804804   }
805805
806806   default:
807      logerror( "$%04x mc6854 invalid read offset %i\n", activecpu_get_previouspc(), offset );
807      logerror( "$%04x mc6854 invalid read offset %i\n", cpu_get_previouspc(space->cpu), offset );
808808   }
809809   return 0;
810810}
r3658r3659
819819   case 0: /* control register 1 */
820820      mc6854->cr1 = data;
821821      LOG(( "%f $%04x mc6854_w: set CR1=$%02X (ac=%i,irq=%c%c,%sreset=%c%c)\n",
822            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6854->cr1,
822            attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), mc6854->cr1,
823823            AC ? 1 : 0,
824824            RIE ? 'r' : '-', TIE ? 't' : '-',
825825            DISCONTINUE ? "discontinue," : "",
r3658r3659
827827             ));
828828      if ( mc6854->cr1 & 0xc )
829829         logerror( "$%04x mc6854 DMA not handled (CR1=$%02X)\n",
830              activecpu_get_previouspc(), mc6854->cr1 );
830              cpu_get_previouspc(space->cpu), mc6854->cr1 );
831831      if ( DISCONTINUE )
832832      {
833833         /* abort receive FIFO but keeps shift register & synchro */
r3658r3659
856856         /* control register 3 */
857857         mc6854->cr3 = data;
858858         LOG(( "%f $%04x mc6854_w: set CR3=$%02X (lcf=%i,aex=%i,idl=%i,fdse=%i,loop=%i,tst=%i,dtr=%i)\n",
859               attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6854->cr3,
859               attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), mc6854->cr3,
860860               LCF ? (CEX ? 16 : 8) : 0,  AEX ? 1 : 0,
861861               IDL0 ? 0 : 1, FDSE ? 1 : 0, LOOP ? 1 : 0,
862862               TST ? 1 : 0, DTR ? 1 : 0
863863                ));
864864         if ( LOOP )
865            logerror( "$%04x mc6854 loop mode not handled (CR3=$%02X)\n", activecpu_get_previouspc(), mc6854->cr3 );
865            logerror( "$%04x mc6854 loop mode not handled (CR3=$%02X)\n", cpu_get_previouspc(space->cpu), mc6854->cr3 );
866866         if ( TST )
867            logerror( "$%04x mc6854 test mode not handled (CR3=$%02X)\n", activecpu_get_previouspc(), mc6854->cr3 );
867            logerror( "$%04x mc6854 test mode not handled (CR3=$%02X)\n", cpu_get_previouspc(space->cpu), mc6854->cr3 );
868868
869869         if ( mc6854->iface->out_dtr )
870870            mc6854->iface->out_dtr( DTR ? 1 : 0 );
r3658r3659
875875         /* control register 2 */
876876         mc6854->cr2 = data;
877877         LOG(( "%f $%04x mc6854_w: set CR2=$%02X (pse=%i,bytes=%i,fmidle=%i,%s,tlast=%i,clr=%c%c,rts=%i)\n",
878               attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6854->cr2,
878               attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), mc6854->cr2,
879879               PSE ? 1 : 0,  TWOBYTES ? 2 : 1,  FMIDLE ? 1 : 0,
880880               FCTDRA ? "fc" : "tdra", TLAST ? 1 : 0,
881881               data & 0x20 ? 'r' : '-',  data & 0x40 ? 't' : '-',
882882               RTS ? 1 : 0 ));
883883         if ( PSE )
884            logerror( "$%04x mc6854 status prioritization not handled (CR2=$%02X)\n", activecpu_get_previouspc(), mc6854->cr2 );
884            logerror( "$%04x mc6854 status prioritization not handled (CR2=$%02X)\n", cpu_get_previouspc(space->cpu), mc6854->cr2 );
885885         if ( TLAST )
886886            mc6854_tfifo_terminate();
887887         if ( data & 0x20 )
r3658r3659
906906      break;
907907
908908   case 2: /* transmitter data: continue data */
909      LOG(( "%f $%04xmc6854_w: push data=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
909      LOG(( "%f $%04xmc6854_w: push data=$%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data ));
910910      mc6854_tfifo_push( data );
911911      break;
912912
r3658r3659
915915      {
916916         /* control register 4 */
917917         mc6854->cr4 = data;
918         LOG(( "%f $%04x mc6854_w: set CR4=$%02X (interframe=%i,tlen=%i,rlen=%i,%s%s)\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6854->cr4,
918         LOG(( "%f $%04x mc6854_w: set CR4=$%02X (interframe=%i,tlen=%i,rlen=%i,%s%s)\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), mc6854->cr4,
919919               TWOINTER ? 2 : 1,
920920               TWL, RWL,
921921               ABT ? ( ABTEX ? "abort-ext," : "abort,") : "",
r3658r3659
930930      else
931931      {
932932         /* transmitter data: last data */
933         LOG(( "%f $%04x mc6854_w: push last-data=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
933         LOG(( "%f $%04x mc6854_w: push last-data=$%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data ));
934934         mc6854_tfifo_push( data );
935935         mc6854_tfifo_terminate();
936936      }
937937      break;
938938
939939   default:
940      logerror( "$%04x mc6854 invalid write offset %i (data=$%02X)\n", activecpu_get_previouspc(), offset, data );
940      logerror( "$%04x mc6854 invalid write offset %i (data=$%02X)\n", cpu_get_previouspc(space->cpu), offset, data );
941941   }
942942}
943943
r3658r3659
975975   assert( mc6854 );
976976   mc6854->iface = iface;
977977   mc6854->ttimer = timer_alloc( mc6854_tfifo_cb , NULL);
978   state_save_register_item( "mc6854", 0, mc6854->cr1 );
979   state_save_register_item( "mc6854", 0, mc6854->cr2 );
980   state_save_register_item( "mc6854", 0, mc6854->cr3 );
981   state_save_register_item( "mc6854", 0, mc6854->cr4 );
982   state_save_register_item( "mc6854", 0, mc6854->sr1 );
983   state_save_register_item( "mc6854", 0, mc6854->sr2 );
984   state_save_register_item( "mc6854", 0, mc6854->cts );
985   state_save_register_item( "mc6854", 0, mc6854->dcd );
986   state_save_register_item( "mc6854", 0, mc6854->tstate );
987   state_save_register_item_array( "mc6854", 0, mc6854->tfifo );
988   state_save_register_item( "mc6854", 0, mc6854->tones );
989   state_save_register_item( "mc6854", 0, mc6854->rstate );
990   state_save_register_item( "mc6854", 0, mc6854->rreg );
991   state_save_register_item( "mc6854", 0, mc6854->rones );
992   state_save_register_item( "mc6854", 0, mc6854->rsize );
993   state_save_register_item_array( "mc6854", 0, mc6854->rfifo );
994   state_save_register_item_array( "mc6854", 0, mc6854->frame );
995   state_save_register_item( "mc6854", 0, mc6854->flen );
996   state_save_register_item( "mc6854", 0, mc6854->fpos );
978   state_save_register_item( "mc6854", NULL, 0, mc6854->cr1 );
979   state_save_register_item( "mc6854", NULL, 0, mc6854->cr2 );
980   state_save_register_item( "mc6854", NULL, 0, mc6854->cr3 );
981   state_save_register_item( "mc6854", NULL, 0, mc6854->cr4 );
982   state_save_register_item( "mc6854", NULL, 0, mc6854->sr1 );
983   state_save_register_item( "mc6854", NULL, 0, mc6854->sr2 );
984   state_save_register_item( "mc6854", NULL, 0, mc6854->cts );
985   state_save_register_item( "mc6854", NULL, 0, mc6854->dcd );
986   state_save_register_item( "mc6854", NULL, 0, mc6854->tstate );
987   state_save_register_item_array( "mc6854", NULL, 0, mc6854->tfifo );
988   state_save_register_item( "mc6854", NULL, 0, mc6854->tones );
989   state_save_register_item( "mc6854", NULL, 0, mc6854->rstate );
990   state_save_register_item( "mc6854", NULL, 0, mc6854->rreg );
991   state_save_register_item( "mc6854", NULL, 0, mc6854->rones );
992   state_save_register_item( "mc6854", NULL, 0, mc6854->rsize );
993   state_save_register_item_array( "mc6854", NULL, 0, mc6854->rfifo );
994   state_save_register_item_array( "mc6854", NULL, 0, mc6854->frame );
995   state_save_register_item( "mc6854", NULL, 0, mc6854->flen );
996   state_save_register_item( "mc6854", NULL, 0, mc6854->fpos );
997997   mc6854_reset();
998998}
src/mess/machine/gamecom.c
r3658r3659
7272MACHINE_RESET( gamecom )
7373{
7474   UINT8 *rom = memory_region(machine, "user1");
75   memory_set_bankptr( 1, rom );
76   memory_set_bankptr( 2, rom );
77   memory_set_bankptr( 3, rom );
78   memory_set_bankptr( 4, rom );
75   memory_set_bankptr( machine, 1, rom );
76   memory_set_bankptr( machine, 2, rom );
77   memory_set_bankptr( machine, 3, rom );
78   memory_set_bankptr( machine, 4, rom );
7979
8080   /* should possibly go in a DRIVER_INIT piece? */
8181   gamecom_clock_timer = timer_alloc( gamecom_clock_timer_callback , NULL);
8282
8383   /* intialize the empty dummy bank */
84   if ( dummy_bank == NULL ) {
84   if ( dummy_bank == NULL )
85   {
8586      dummy_bank = auto_malloc( 8 * 1024 );
8687   }
8788   memset( dummy_bank, 0xff, 8 * 1024 );
r3658r3659
9091   gamecom_dma.enabled = 0;
9192
9293   memset( internal_registers, 0x00, sizeof(internal_registers) );
93   gamecom_internal_w( machine, SM8521_URTT, 0xFF );
94   gamecom_internal_w( machine, SM8521_URTS, 0x42 );
95   gamecom_internal_w( machine, SM8521_WDTC, 0x38 );
94   gamecom_internal_w( cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), SM8521_URTT, 0xFF );
95   gamecom_internal_w( cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), SM8521_URTS, 0x42 );
96   gamecom_internal_w( cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), SM8521_WDTC, 0x38 );
9697}
9798
98static void gamecom_set_mmu( running_machine *machine, int mmu, UINT8 data ) {
99   if ( data < 32 ) {
99static void gamecom_set_mmu( running_machine *machine, int mmu, UINT8 data )
100{
101   if ( data < 32 )
102   {
100103      /* select internal ROM bank */
101      memory_set_bankptr( mmu, memory_region(machine, "user1") + (data << 13) );
102   } else {
104      memory_set_bankptr( machine, mmu, memory_region(machine, "user1") + (data << 13) );
105   }
106   else
107   {
103108      /* select cartridge bank */
104      if ( cartridge == NULL ) {
105         memory_set_bankptr( mmu, dummy_bank );
106      } else {
107         memory_set_bankptr( mmu, cartridge + ( data << 13 ) );
109      if ( cartridge == NULL )
110      {
111         memory_set_bankptr( machine, mmu, dummy_bank );
112      }
113      else
114      {
115         memory_set_bankptr( machine, mmu, cartridge + ( data << 13 ) );
108116      }
109117   }
110118}
111119
112static void handle_stylus_press( running_machine *machine, UINT8 column ) {
120static void handle_stylus_press( running_machine *machine, UINT8 column )
121{
113122   static const UINT16 row_data[10] = { 0x3FE, 0x3FD, 0x3FB, 0x3F7, 0x3EF, 0x3DF, 0x3BF, 0x37F, 0x2FF, 0x1FF };
114123   static UINT32 stylus_x;
115124   static UINT32 stylus_y;
116125
117   if ( column == 0 ) {
118      if ( ! ( input_port_read(machine, "IN2") & 0x04 ) ) {
126   if ( column == 0 )
127   {
128      if ( ! ( input_port_read(machine, "IN2") & 0x04 ) )
129      {
119130         stylus_x = input_port_read(machine, "IN3") >> 4;
120131         stylus_y = input_port_read(machine, "IN4") >> 4;
121      } else {
132      }
133      else
134      {
122135         stylus_x = 16;
123136         stylus_y = 16;
124137      }
125138   }
126139
127   if ( stylus_x == column ) {
128      cpunum_set_reg( 0, SM8500_P0, row_data[stylus_y] & 0xFF );
129      cpunum_set_reg( 0, SM8500_P1, ( cpunum_get_reg( 0, SM8500_P1 ) & 0xFC ) | ( ( row_data[stylus_y] >> 8 ) & 0x03 ) );
130   } else {
131      cpunum_set_reg( 0, SM8500_P0, 0xFF );
132      cpunum_set_reg( 0, SM8500_P1, ( cpunum_get_reg( 0, SM8500_P1 ) & 0xFC ) | 0x03 );
140   if ( stylus_x == column )
141   {
142      cpu_set_reg( machine->cpu[0], SM8500_P0, row_data[stylus_y] & 0xFF );
143      cpu_set_reg( machine->cpu[0], SM8500_P1, ( cpu_get_reg( machine->cpu[0], SM8500_P1 ) & 0xFC ) | ( ( row_data[stylus_y] >> 8 ) & 0x03 ) );
144   }
145   else
146   {
147      cpu_set_reg( machine->cpu[0], SM8500_P0, 0xFF );
148      cpu_set_reg( machine->cpu[0], SM8500_P1, ( cpu_get_reg( machine->cpu[0], SM8500_P1 ) & 0xFC ) | 0x03 );
133149   }
134150}
135151
136152WRITE8_HANDLER( gamecom_internal_w )
137153{
138   if ( offset >= 0x80 ) {
154   if ( offset >= 0x80 )
155   {
139156      internal_ram[offset] = data;
140157      return;
141158   }
142159
143   switch( offset ) {
144   case SM8521_IE0:   cpunum_set_reg( 0, SM8500_IE0, data ); return;
145   case SM8521_IE1:   cpunum_set_reg( 0, SM8500_IE1, data ); return;
146   case SM8521_IR0:   cpunum_set_reg( 0, SM8500_IR0, data ); return;
147   case SM8521_IR1:   cpunum_set_reg( 0, SM8500_IR1, data ); return;
148   case SM8521_P0:      cpunum_set_reg( 0, SM8500_P0, data ); return;
149   case SM8521_P1:      cpunum_set_reg( 0, SM8500_P1, data ); return;
150   case SM8521_P2:      cpunum_set_reg( 0, SM8500_P2, data );
151            switch( ( cpunum_get_reg( 0, SM8500_P1 ) << 8 ) | data ) {
160   switch( offset )
161   {
162   case SM8521_IE0:   cpu_set_reg( space->machine->cpu[0], SM8500_IE0, data ); return;
163   case SM8521_IE1:   cpu_set_reg( space->machine->cpu[0], SM8500_IE1, data ); return;
164   case SM8521_IR0:   cpu_set_reg( space->machine->cpu[0], SM8500_IR0, data ); return;
165   case SM8521_IR1:   cpu_set_reg( space->machine->cpu[0], SM8500_IR1, data ); return;
166   case SM8521_P0:      cpu_set_reg( space->machine->cpu[0], SM8500_P0, data ); return;
167   case SM8521_P1:      cpu_set_reg( space->machine->cpu[0], SM8500_P1, data ); return;
168   case SM8521_P2:      cpu_set_reg( space->machine->cpu[0], SM8500_P2, data );
169            switch( ( cpu_get_reg( space->machine->cpu[0], SM8500_P1 ) << 8 ) | data )
170            {
152171            case 0xFBFF:   /* column #0 */
153172                  /* P0 bit 0 cleared => 01 */
154173                  /* P0 bit 1 cleared => 0E */
r3658r3659
160179                  /* P0 bit 7 cleared => */
161180                  /* P1 bit 0 cleared => */
162181                  /* P1 bit 1 cleared => */
163               handle_stylus_press( machine, 0 );
182               handle_stylus_press( space->machine, 0 );
164183               break;
165184            case 0xF7FF:   /* column #1 */
166               handle_stylus_press( machine, 1 );
185               handle_stylus_press( space->machine, 1 );
167186               break;
168187            case 0xEFFF:   /* column #2 */
169               handle_stylus_press( machine, 2 );
188               handle_stylus_press( space->machine, 2 );
170189               break;
171190            case 0xDFFF:   /* column #3 */
172               handle_stylus_press( machine, 3 );
191               handle_stylus_press( space->machine, 3 );
173192               break;
174193            case 0xBFFF:   /* column #4 */
175               handle_stylus_press( machine, 4 );
194               handle_stylus_press( space->machine, 4 );
176195               break;
177196            case 0x7FFF:   /* column #5 */
178               handle_stylus_press( machine, 5 );
197               handle_stylus_press( space->machine, 5 );
179198               break;
180199            case 0xFFFE:   /* column #6 */
181               handle_stylus_press( machine, 6 );
200               handle_stylus_press( space->machine, 6 );
182201               break;
183202            case 0xFFFD:   /* column #7 */
184               handle_stylus_press( machine, 7 );
203               handle_stylus_press( space->machine, 7 );
185204               break;
186205            case 0xFFFB:   /* column #8 */
187               handle_stylus_press( machine, 8 );
206               handle_stylus_press( space->machine, 8 );
188207               break;
189208            case 0xFFF7:   /* column #9 */
190               handle_stylus_press( machine, 9 );
209               handle_stylus_press( space->machine, 9 );
191210               break;
192211            case 0xFFEF:   /* column #10 */
193               handle_stylus_press( machine, 10 );
212               handle_stylus_press( space->machine, 10 );
194213               break;
195214            case 0xFFDF:   /* column #11 */
196               handle_stylus_press( machine, 11 );
215               handle_stylus_press( space->machine, 11 );
197216               break;
198217            case 0xFFBF:   /* column #12 */
199               handle_stylus_press( machine, 12 );
218               handle_stylus_press( space->machine, 12 );
200219               break;
201220            case 0xFF7F:   /* keys #1 */
202221                  /* P0 bit 0 cleared => 83 (up) */
r3658r3659
209228                  /* P0 bit 7 cleared => 8B (button A) */
210229                  /* P1 bit 0 cleared => 8C (button B) */
211230                  /* P1 bit 1 cleared => 8D (button C) */
212               cpunum_set_reg( 0, SM8500_P0, input_port_read(machine, "IN0") );
213               cpunum_set_reg( 0, SM8500_P1, ( cpunum_get_reg( 0, SM8500_P1 ) & 0xFC ) | ( input_port_read(machine, "IN1") & 0x03 ) );
231               cpu_set_reg( space->machine->cpu[0], SM8500_P0, input_port_read(space->machine, "IN0") );
232               cpu_set_reg( space->machine->cpu[0], SM8500_P1, ( cpu_get_reg( space->machine->cpu[0], SM8500_P1 ) & 0xFC ) | ( input_port_read(space->machine, "IN1") & 0x03 ) );
214233               break;
215234            case 0xFFFF:   /* keys #2 */
216235                  /* P0 bit 0 cleared => 88 (power) */
r3658r3659
223242                  /* P0 bit 7 cleared => A0 */
224243                  /* P1 bit 0 cleared => A0 */
225244                  /* P1 bit 1 cleared => A0 */
226               cpunum_set_reg( 0, SM8500_P0, ( cpunum_get_reg( 0, SM8500_P0 ) & 0xFC ) | ( input_port_read(machine, "IN2") & 0x03 ) );
227               cpunum_set_reg( 0, SM8500_P1, 0xFF );
245               cpu_set_reg( space->machine->cpu[0], SM8500_P0, ( cpu_get_reg( space->machine->cpu[0], SM8500_P0 ) & 0xFC ) | ( input_port_read(space->machine, "IN2") & 0x03 ) );
246               cpu_set_reg( space->machine->cpu[0], SM8500_P1, 0xFF );
228247               break;
229248            }
230249            return;
231250   case SM8521_P3:
232251            /* P3 bit7 clear, bit6 set -> enable cartridge port #0? */
233252            /* P3 bit6 clear, bit7 set -> enable cartridge port #1? */
234            cpunum_set_reg( 0, SM8500_P3, data );
235            switch( data & 0xc0 ) {
253            cpu_set_reg( space->machine->cpu[0], SM8500_P3, data );
254            switch( data & 0xc0 )
255            {
236256            case 0x40: cartridge = cartridge1; break;
237257            case 0x80: cartridge = cartridge2; break;
238258            default:   cartridge = NULL;       break;
239259            }
240260            /* update banks to reflect possible change of cartridge slot */
241            gamecom_set_mmu( machine, 1, internal_registers[SM8521_MMU1] );
242            gamecom_set_mmu( machine, 2, internal_registers[SM8521_MMU2] );
243            gamecom_set_mmu( machine, 3, internal_registers[SM8521_MMU3] );
244            gamecom_set_mmu( machine, 4, internal_registers[SM8521_MMU4] );
261            gamecom_set_mmu( space->machine, 1, internal_registers[SM8521_MMU1] );
262            gamecom_set_mmu( space->machine, 2, internal_registers[SM8521_MMU2] );
263            gamecom_set_mmu( space->machine, 3, internal_registers[SM8521_MMU3] );
264            gamecom_set_mmu( space->machine, 4, internal_registers[SM8521_MMU4] );
245265            return;
246   case SM8521_SYS:   cpunum_set_reg( 0, SM8500_SYS, data ); return;
247   case SM8521_CKC:   cpunum_set_reg( 0, SM8500_CKC, data ); return;
248   case SM8521_SPH:   cpunum_set_reg( 0, SM8500_SPH, data ); return;
249   case SM8521_SPL:   cpunum_set_reg( 0, SM8500_SPL, data ); return;
250   case SM8521_PS0:   cpunum_set_reg( 0, SM8500_PS0, data ); return;
251   case SM8521_PS1:   cpunum_set_reg( 0, SM8500_PS1, data ); return;
252   case SM8521_P0C:   cpunum_set_reg( 0, SM8500_P0C, data ); return;
253   case SM8521_P1C:   cpunum_set_reg( 0, SM8500_P1C, data ); return;
254   case SM8521_P2C:   cpunum_set_reg( 0, SM8500_P2C, data ); return;
255   case SM8521_P3C:   cpunum_set_reg( 0, SM8500_P3C, data ); return;
266   case SM8521_SYS:   cpu_set_reg( space->machine->cpu[0], SM8500_SYS, data ); return;
267   case SM8521_CKC:   cpu_set_reg( space->machine->cpu[0], SM8500_CKC, data ); return;
268   case SM8521_SPH:   cpu_set_reg( space->machine->cpu[0], SM8500_SPH, data ); return;
269   case SM8521_SPL:   cpu_set_reg( space->machine->cpu[0], SM8500_SPL, data ); return;
270   case SM8521_PS0:   cpu_set_reg( space->machine->cpu[0], SM8500_PS0, data ); return;
271   case SM8521_PS1:   cpu_set_reg( space->machine->cpu[0], SM8500_PS1, data ); return;
272   case SM8521_P0C:   cpu_set_reg( space->machine->cpu[0], SM8500_P0C, data ); return;
273   case SM8521_P1C:   cpu_set_reg( space->machine->cpu[0], SM8500_P1C, data ); return;
274   case SM8521_P2C:   cpu_set_reg( space->machine->cpu[0], SM8500_P2C, data ); return;
275   case SM8521_P3C:   cpu_set_reg( space->machine->cpu[0], SM8500_P3C, data ); return;
256276   case SM8521_MMU0:   /* disable bootstrap ROM? most likely not written to on game.com */
257277      logerror( "Write to MMU0\n" );
258278      break;
259279   case SM8521_MMU1:
260      gamecom_set_mmu( machine, 1, data );
280      gamecom_set_mmu( space->machine, 1, data );
261281      break;
262282   case SM8521_MMU2:
263      gamecom_set_mmu( machine, 2, data );
283      gamecom_set_mmu( space->machine, 2, data );
264284      break;
265285   case SM8521_MMU3:
266      gamecom_set_mmu( machine, 3, data );
286      gamecom_set_mmu( space->machine, 3, data );
267287      break;
268288   case SM8521_MMU4:
269      gamecom_set_mmu( machine, 4, data );
289      gamecom_set_mmu( space->machine, 4, data );
270290      break;
271291
272292   /* Video hardware and DMA */
r3658r3659
283303      gamecom_dma.decrement_x = data & 0x08;
284304      gamecom_dma.decrement_y = data & 0x10;
285305      gamecom_dma.enabled = data & 0x80;
286      if ( gamecom_dma.enabled ) {
287         gamecom_dma_init(machine);
306      if ( gamecom_dma.enabled )
307      {
308         gamecom_dma_init(space->machine);
288309      }
289310      break;
290311   case SM8521_DMX1:
r3658r3659
324345      gamecom_timer[1].counter = 0;
325346      break;
326347   case SM8521_CLKT:   /* bit 6-7 */
327      if ( data & 0x80 ) {
348      if ( data & 0x80 )
349      {
328350         /* timer run */
329         if ( data & 0x40 ) {
351         if ( data & 0x40 )
352         {
330353            /* timer resolution 1 minute */
331354            timer_adjust_periodic(gamecom_clock_timer, ATTOTIME_IN_SEC(1), 0, ATTOTIME_IN_SEC(60));
332         } else {
355         }
356         else
357         {
333358            /* TImer resolution 1 second */
334359            timer_adjust_periodic(gamecom_clock_timer, ATTOTIME_IN_SEC(1), 0, ATTOTIME_IN_SEC(1));
335360         }
336      } else {
361      }
362      else
363      {
337364         /* disable timer reset */
338365         timer_enable( gamecom_clock_timer, 0 );
339366         data &= 0xC0;
r3658r3659
349376   case SM8521_55: case SM8521_56: case SM8521_57: case SM8521_58:
350377   case SM8521_59: case SM8521_5A: case SM8521_5B: case SM8521_5C:
351378   case SM8521_5D:
352      logerror( "%X: Write to reserved address (0x%02X). Value written: 0x%02X\n", activecpu_get_pc(), offset, data );
379      logerror( "%X: Write to reserved address (0x%02X). Value written: 0x%02X\n", cpu_get_pc(space->cpu), offset, data );
353380      break;
354381   }
355382   internal_registers[offset] = data;
r3658r3659
357384
358385READ8_HANDLER( gamecom_internal_r )
359386{
360   if ( offset >= 0x80 ) {
387   if ( offset >= 0x80 )
388   {
361389      return internal_ram[offset];
362390   }
363391
364   switch( offset ) {
392   switch( offset )
393   {
365394   case SM8521_R0:  case SM8521_R1:  case SM8521_R2:  case SM8521_R3:
366395   case SM8521_R4:  case SM8521_R5:  case SM8521_R6:  case SM8521_R7:
367396   case SM8521_R8:  case SM8521_R9:  case SM8521_R10: case SM8521_R11:
368397   case SM8521_R12: case SM8521_R13: case SM8521_R14: case SM8521_R15:
369398      return sm85cpu_mem_readbyte( offset );
370   case SM8521_IE0:   return cpunum_get_reg( 0, SM8500_IE0 );
371   case SM8521_IE1:   return cpunum_get_reg( 0, SM8500_IE1 );
372   case SM8521_IR0:   return cpunum_get_reg( 0, SM8500_IR0 );
373   case SM8521_IR1:   return cpunum_get_reg( 0, SM8500_IR1 );
374   case SM8521_P0:      /* logerror( "%X: Read from P0\n", activecpu_get_pc() ); */ return cpunum_get_reg( 0, SM8500_P0 );
375   case SM8521_P1:      /* logerror( "%X: Read from P1\n", activecpu_get_pc() ); */ return cpunum_get_reg( 0, SM8500_P1 );
376   case SM8521_P2:      /* logerror( "%X: Read from P2\n", activecpu_get_pc() ); */ return cpunum_get_reg( 0, SM8500_P2 );
377   case SM8521_P3:      return cpunum_get_reg( 0, SM8500_P3 );
378   case SM8521_SYS:   return cpunum_get_reg( 0, SM8500_SYS );
379   case SM8521_CKC:   return cpunum_get_reg( 0, SM8500_CKC );
380   case SM8521_SPH:   return cpunum_get_reg( 0, SM8500_SPH );
381   case SM8521_SPL:   return cpunum_get_reg( 0, SM8500_SPL );
382   case SM8521_PS0:   return cpunum_get_reg( 0, SM8500_PS0 );
383   case SM8521_PS1:   return cpunum_get_reg( 0, SM8500_PS1 );
384   case SM8521_P0C:   return cpunum_get_reg( 0, SM8500_P0C );
385   case SM8521_P1C:   return cpunum_get_reg( 0, SM8500_P1C );
386   case SM8521_P2C:   return cpunum_get_reg( 0, SM8500_P2C );
387   case SM8521_P3C:   return cpunum_get_reg( 0, SM8500_P3C );
399   case SM8521_IE0:   return cpu_get_reg( space->machine->cpu[0], SM8500_IE0 );
400   case SM8521_IE1:   return cpu_get_reg( space->machine->cpu[0], SM8500_IE1 );
401   case SM8521_IR0:   return cpu_get_reg( space->machine->cpu[0], SM8500_IR0 );
402   case SM8521_IR1:   return cpu_get_reg( space->machine->cpu[0], SM8500_IR1 );
403   case SM8521_P0:      /* logerror( "%X: Read from P0\n", cpu_get_pc(space->cpu) ); */ return cpu_get_reg( space->machine->cpu[0], SM8500_P0 );
404   case SM8521_P1:      /* logerror( "%X: Read from P1\n", cpu_get_pc(space->cpu) ); */ return cpu_get_reg( space->machine->cpu[0], SM8500_P1 );
405   case SM8521_P2:      /* logerror( "%X: Read from P2\n", cpu_get_pc(space->cpu) ); */ return cpu_get_reg( space->machine->cpu[0], SM8500_P2 );
406   case SM8521_P3:      return cpu_get_reg( space->machine->cpu[0], SM8500_P3 );
407   case SM8521_SYS:   return cpu_get_reg( space->machine->cpu[0], SM8500_SYS );
408   case SM8521_CKC:   return cpu_get_reg( space->machine->cpu[0], SM8500_CKC );
409   case SM8521_SPH:   return cpu_get_reg( space->machine->cpu[0], SM8500_SPH );
410   case SM8521_SPL:   return cpu_get_reg( space->machine->cpu[0], SM8500_SPL );
411   case SM8521_PS0:   return cpu_get_reg( space->machine->cpu[0], SM8500_PS0 );
412   case SM8521_PS1:   return cpu_get_reg( space->machine->cpu[0], SM8500_PS1 );
413   case SM8521_P0C:   return cpu_get_reg( space->machine->cpu[0], SM8500_P0C );
414   case SM8521_P1C:   return cpu_get_reg( space->machine->cpu[0], SM8500_P1C );
415   case SM8521_P2C:   return cpu_get_reg( space->machine->cpu[0], SM8500_P2C );
416   case SM8521_P3C:   return cpu_get_reg( space->machine->cpu[0], SM8500_P3C );
388417   case SM8521_TM0D:   return gamecom_timer[0].counter;
389418   case SM8521_TM1D:   return gamecom_timer[1].counter;
390419//   case SM8521_CLKT:   /* bit 0-5 read only, 6-7 read/write */
r3658r3659
399428   case SM8521_55: case SM8521_56: case SM8521_57: case SM8521_58:
400429   case SM8521_59: case SM8521_5A: case SM8521_5B: case SM8521_5C:
401430   case SM8521_5D:
402//      logerror( "%X: Read from reserved address (0x%02X)\n", activecpu_get_pc(), offset );
431//      logerror( "%X: Read from reserved address (0x%02X)\n", cpu_get_pc(space->cpu), offset );
403432      break;
404433
405434   }
r3658r3659
408437
409438/* The manual is not conclusive as to which bit of the DMVP register (offset 0x3D) determines
410439   which page for source or destination is used */
411static void gamecom_dma_init(running_machine *machine) {
412   if ( gamecom_dma.decrement_x || gamecom_dma.decrement_y ) {
440static void gamecom_dma_init(running_machine *machine)
441{
442   if ( gamecom_dma.decrement_x || gamecom_dma.decrement_y )
443   {
413444      logerror( "TODO: Decrement-x and decrement-y are not supported yet\n" );
414445   }
415446   gamecom_dma.width_x = internal_registers[SM8521_DMDX];
r3658r3659
432463   gamecom_dma.dest_mask = 0x1FFF;
433464//   logerror("DMA: width %Xx%X, source (%X,%X), dest (%X,%X), transfer_mode %X, banks %X \n", gamecom_dma.width_x, gamecom_dma.width_y, gamecom_dma.source_x, gamecom_dma.source_y, gamecom_dma.dest_x, gamecom_dma.dest_y, gamecom_dma.transfer_mode, internal_registers[SM8521_DMVP] );
434465//   logerror( "   Palette: %d, %d, %d, %d\n", gamecom_dma.palette[0], gamecom_dma.palette[1], gamecom_dma.palette[2], gamecom_dma.palette[3] );
435   switch( gamecom_dma.transfer_mode ) {
466   switch( gamecom_dma.transfer_mode )
467   {
436468   case 0x00:
437469      /* VRAM->VRAM */
438470      gamecom_dma.source_bank = &gamecom_vram[(internal_registers[SM8521_DMVP] & 0x01) ? 0x2000 : 0x0000];
r3658r3659
442474      /* ROM->VRAM */
443475//      logerror( "DMA DMBR = %X\n", internal_registers[SM8521_DMBR] );
444476      gamecom_dma.source_width = 64;
445      if ( internal_registers[SM8521_DMBR] < 16 ) {
477      if ( internal_registers[SM8521_DMBR] < 16 )
478      {
446479         gamecom_dma.source_bank = memory_region(machine, "user1") + (internal_registers[SM8521_DMBR] << 14);
447480         gamecom_dma.source_mask = 0x3FFF;
448      } else {
481      }
482      else
483      {
449484         logerror( "TODO: Reading from external ROMs not supported yet\n" );
450485         gamecom_dma.source_bank = memory_region(machine, "user1");
451486      }
r3658r3659
454489   case 0x04:
455490      /* Extend RAM->VRAM */
456491      gamecom_dma.source_width = 64;
457      gamecom_dma.source_bank = memory_get_read_ptr(0, ADDRESS_SPACE_PROGRAM,  0xE000 );
492      gamecom_dma.source_bank = memory_get_read_ptr(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM),  0xE000 );
458493      gamecom_dma.dest_bank = &gamecom_vram[(internal_registers[SM8521_DMVP] & 0x02) ? 0x2000 : 0x0000];
459494      break;
460495   case 0x06:
461496      /* VRAM->Extend RAM */
462497      gamecom_dma.source_bank = &gamecom_vram[(internal_registers[SM8521_DMVP] & 0x01) ? 0x2000 : 0x0000];
463498      gamecom_dma.dest_width = 64;
464      gamecom_dma.dest_bank = memory_get_read_ptr(0, ADDRESS_SPACE_PROGRAM, 0xE000 );
499      gamecom_dma.dest_bank = memory_get_read_ptr(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xE000 );
465500      break;
466501   }
467502   gamecom_dma.source_current = gamecom_dma.source_width * gamecom_dma.source_y;
r3658r3659
477512   Their usage is also not explained properly in the manuals. Guess we'll have to wait
478513   for them to show up in some rom images...
479514 */
480void gamecom_handle_dma( int cycles ) {
515void gamecom_handle_dma( int cycles )
516{
481517   unsigned y_count, x_count;
482518   /* If not enabled, ignore */
483   if ( ! gamecom_dma.enabled ) {
519   if ( ! gamecom_dma.enabled )
520   {
484521      return;
485522   }
486   for( y_count = 0; y_count <= gamecom_dma.width_y; y_count++ ) {
487      for( x_count = 0; x_count <= gamecom_dma.width_x; x_count++ ) {
523   for( y_count = 0; y_count <= gamecom_dma.width_y; y_count++ )
524   {
525      for( x_count = 0; x_count <= gamecom_dma.width_x; x_count++ )
526      {
488527         int source_pixel = 0;
489528         int dest_pixel = 0;
490529         int src_addr = gamecom_dma.source_current & gamecom_dma.source_mask;
491530         int dest_addr = gamecom_dma.dest_current & gamecom_dma.dest_mask;
492531         /* handle DMA for 1 pixel */
493532         /* Read pixel data */
494         switch ( gamecom_dma.source_x_current & 0x03 ) {
533         switch ( gamecom_dma.source_x_current & 0x03 )
534         {
495535         case 0x00: source_pixel = ( gamecom_dma.source_bank[src_addr] & 0xC0 ) >> 6; break;
496536         case 0x01: source_pixel = ( gamecom_dma.source_bank[src_addr] & 0x30 ) >> 4; break;
497537         case 0x02: source_pixel = ( gamecom_dma.source_bank[src_addr] & 0x0C ) >> 2; break;
498538         case 0x03: source_pixel = ( gamecom_dma.source_bank[src_addr] & 0x03 );      break;
499539         }
500540
501         if ( !gamecom_dma.overwrite_mode && source_pixel == 0 ) {
502            switch ( gamecom_dma.dest_x_current & 0x03 ) {
541         if ( !gamecom_dma.overwrite_mode && source_pixel == 0 )
542         {
543            switch ( gamecom_dma.dest_x_current & 0x03 )
544            {
503545            case 0x00: dest_pixel = ( gamecom_dma.dest_bank[dest_addr] & 0xC0 ) >> 6; break;
504546            case 0x01: dest_pixel = ( gamecom_dma.dest_bank[dest_addr] & 0x30 ) >> 4; break;
505547            case 0x02: dest_pixel = ( gamecom_dma.dest_bank[dest_addr] & 0x0C ) >> 2; break;
r3658r3659
512554         /* Not sure if this should be done before the compound stuff - WP */
513555         source_pixel = gamecom_dma.palette[ source_pixel ];
514556         /* Write pixel data */
515         switch( gamecom_dma.dest_x_current & 0x03 ) {
557         switch( gamecom_dma.dest_x_current & 0x03 )
558         {
516559         case 0x00:
517560            gamecom_dma.dest_bank[dest_addr] = ( gamecom_dma.dest_bank[dest_addr] & 0x3F ) | ( source_pixel << 6 );
518561            break;
r3658r3659
528571         }
529572
530573         /* Advance a pixel */
531         if ( gamecom_dma.decrement_x ) {
574         if ( gamecom_dma.decrement_x )
575         {
532576            gamecom_dma.source_x_current--;
533            if ( ( gamecom_dma.source_x_current & 0x03 ) == 0x03 ) {
577            if ( ( gamecom_dma.source_x_current & 0x03 ) == 0x03 )
578            {
534579               gamecom_dma.source_current--;
535580            }
536         } else {
581         }
582         else
583         {
537584            gamecom_dma.source_x_current++;
538            if ( ( gamecom_dma.source_x_current & 0x03 ) == 0x00 ) {
585            if ( ( gamecom_dma.source_x_current & 0x03 ) == 0x00 )
586            {
539587               gamecom_dma.source_current++;
540588            }
541589         }
542590         gamecom_dma.dest_x_current++;
543         if ( ( gamecom_dma.dest_x_current & 0x03 ) == 0x00 ) {
591         if ( ( gamecom_dma.dest_x_current & 0x03 ) == 0x00 )
592         {
544593            gamecom_dma.dest_current++;
545594         }
546595      }
r3658r3659
557606   cpu_set_input_line(Machine->cpu[0], DMA_INT, HOLD_LINE );
558607}
559608
560void gamecom_update_timers( int cycles ) {
561   if ( gamecom_timer[0].enabled ) {
609void gamecom_update_timers( int cycles )
610{
611   if ( gamecom_timer[0].enabled )
612   {
562613      gamecom_timer[0].state_count += cycles;
563      while ( gamecom_timer[0].state_count >= gamecom_timer[0].state_limit ) {
614      while ( gamecom_timer[0].state_count >= gamecom_timer[0].state_limit )
615      {
564616         gamecom_timer[0].state_count -= gamecom_timer[0].state_limit;
565617         gamecom_timer[0].counter++;
566         if ( gamecom_timer[0].counter == gamecom_timer[0].check_value ) {
618         if ( gamecom_timer[0].counter == gamecom_timer[0].check_value )
619         {
567620            gamecom_timer[0].counter = 0;
568621            cpu_set_input_line(Machine->cpu[0], TIM0_INT, HOLD_LINE );
569622         }
570623      }
571624   }
572   if ( gamecom_timer[1].enabled ) {
625   if ( gamecom_timer[1].enabled )
626   {
573627      gamecom_timer[1].state_count += cycles;
574      while ( gamecom_timer[1].state_count >= gamecom_timer[1].state_limit ) {
628      while ( gamecom_timer[1].state_count >= gamecom_timer[1].state_limit )
629      {
575630         gamecom_timer[1].state_count -= gamecom_timer[1].state_limit;
576631         gamecom_timer[1].counter++;
577         if ( gamecom_timer[1].counter == gamecom_timer[1].check_value ) {
632         if ( gamecom_timer[1].counter == gamecom_timer[1].check_value )
633         {
578634            gamecom_timer[1].counter = 0;
579635            cpu_set_input_line(Machine->cpu[0], TIM1_INT, HOLD_LINE );
580636         }
r3658r3659
582638   }
583639}
584640
585WRITE8_HANDLER( gamecom_vram_w ) {
641WRITE8_HANDLER( gamecom_vram_w )
642{
586643   gamecom_vram[offset] = data;
587644}
588645
589READ8_HANDLER( gamecom_vram_r ) {
646READ8_HANDLER( gamecom_vram_r )
647{
590648   return gamecom_vram[offset];
591649}
592650
r3658r3659
602660   int load_offset = 0;
603661
604662   /* allocate memory on first load of a cartridge */
605   if ( cartridge1 == NULL ) {
663   if ( cartridge1 == NULL )
664   {
606665      cartridge1 = auto_malloc( 2048 * 1024 );
607666   }
608667   filesize = image_length( image );
609   switch( filesize ) {
668   switch( filesize )
669   {
610670   case 0x008000: load_offset = 0;        break;  /* 32 KB */
611671   case 0x040000: load_offset = 0;        break;  /* 256KB */
612672   case 0x080000: load_offset = 0;        break;  /* 512KB */
r3658r3659
617677      logerror( "Error loading cartridge: Invalid file size.\n" );
618678      return INIT_FAIL;
619679   }
620   if ( image_fread( image, cartridge1 + load_offset, filesize ) != filesize ) {
680   if ( image_fread( image, cartridge1 + load_offset, filesize ) != filesize )
681   {
621682      logerror( "Error loading cartridge: Unable to read from file: %s.\n", image_filename(image) );
622683      return INIT_FAIL;
623684   }
src/mess/machine/thomson.c
r3658r3659
105105         /* hack, feed existing bits */
106106         if ( bitpos >= to7_k7_bitsize )
107107            bitpos = to7_k7_bitsize -1;
108         VLOG (( "$%04x %f to7_get_cassette: state=$%X pos=%f samppos=%i bit=%i\n",
109            activecpu_get_previouspc(), attotime_to_double(timer_get_time()), state, pos, bitpos,
110            to7_k7_bits[ bitpos ] ));
108//         VLOG (( "$%04x %f to7_get_cassette: state=$%X pos=%f samppos=%i bit=%i\n",
109//            cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), state, pos, bitpos,
110//            to7_k7_bits[ bitpos ] ));
111111         return to7_k7_bits[ bitpos ];
112112      }
113113      else
r3658r3659
126126               chg++;
127127         }
128128         k = ( chg >= 13 ) ? 1 : 0;
129         VLOG (( "$%04x %f to7_get_cassette: state=$%X pos=%f samppos=%i bit=%i (%i)\n",
130            activecpu_get_previouspc(), attotime_to_double(timer_get_time()), state, pos, bitpos,
131            k, chg ));
129//         VLOG (( "$%04x %f to7_get_cassette: state=$%X pos=%f samppos=%i bit=%i (%i)\n",
130//            cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), state, pos, bitpos,
131//            k, chg ));
132132         return k;
133133      }
134134
r3658r3659
150150
151151static WRITE8_HANDLER ( to7_set_cassette_motor )
152152{
153   const device_config* img = thom_cassette_img(machine);
153   const device_config* img = thom_cassette_img(space->machine);
154154   cassette_state state = cassette_get_state( img );
155155   double pos = cassette_get_position(img);
156156
157157   LOG (( "$%04x %f to7_set_cassette_motor: cassette motor %s bitpos=%i\n",
158          activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ? "off" : "on",
158          cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data ? "off" : "on",
159159          (int) (pos / TO7_BIT_LENGTH) ));
160160
161161   if ( (state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_DISABLED && !data && pos > 0.3 )
r3658r3659
204204      cassette_get_sample( cass, 0, pos, 0, &hbit );
205205      hbit = hbit >= 0;
206206
207      VLOG (( "$%04x %f mo5_get_cassette: state=$%X pos=%f hbitpos=%i hbit=%i\n",
208         activecpu_get_previouspc(), attotime_to_double(timer_get_time()), state, pos,
209         (int) (pos / MO5_HBIT_LENGTH), hbit ));
207//      VLOG (( "$%04x %f mo5_get_cassette: state=$%X pos=%f hbitpos=%i hbit=%i\n",
208//         cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), state, pos,
209//         (int) (pos / MO5_HBIT_LENGTH), hbit ));
210210      return hbit;
211211   }
212212   else
r3658r3659
225225
226226static WRITE8_HANDLER ( mo5_set_cassette_motor )
227227{
228   const device_config* img = thom_cassette_img(machine);
228   const device_config* img = thom_cassette_img(space->machine);
229229   cassette_state state = cassette_get_state( img );
230230   double pos = cassette_get_position(img);
231231
232232   LOG (( "$%04x %f mo5_set_cassette_motor: cassette motor %s hbitpos=%i\n",
233          activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ? "off" : "on",
233          cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data ? "off" : "on",
234234          (int) (pos / MO5_HBIT_LENGTH) ));
235235
236236   if ( (state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_DISABLED &&  !data && pos > 0.3 )
r3658r3659
514514   if ( thom_cart_nb_banks )
515515   {
516516      bank = thom_cart_bank % thom_cart_nb_banks;
517      memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x0003, 0, 0, to7_cartridge_r );
517      memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x0003, 0, 0, to7_cartridge_r );
518518   }
519519
520520   if ( bank != old_bank )
521521      LOG_BANK(( "to7_update_cart_bank: CART is cartridge bank %i\n", bank ));
522522
523   memory_set_bank( THOM_CART_BANK, bank );
523   memory_set_bank( machine, THOM_CART_BANK, bank );
524524   old_bank = bank;
525525}
526526
r3658r3659
540540      return;
541541
542542   thom_cart_bank = offset & 3;
543   to7_update_cart_bank(machine);
543   to7_update_cart_bank(space->machine);
544544}
545545
546546
r3658r3659
548548/* read signal to 0000-0003 generates a bank switch */
549549READ8_HANDLER ( to7_cartridge_r )
550550{
551   UINT8* pos = memory_region( machine, "main" ) + 0x10000;
551   UINT8* pos = memory_region( space->machine, "main" ) + 0x10000;
552552   UINT8 data = pos[offset + (thom_cart_bank % thom_cart_nb_banks) * 0x4000];
553553   thom_cart_bank = offset & 3;
554   to7_update_cart_bank(machine);
554   to7_update_cart_bank(space->machine);
555555   return data;
556556}
557557
r3658r3659
563563
564564static WRITE8_HANDLER ( to7_timer_port_out )
565565{
566   thom_set_mode_point( data & 1 );          /* bit 0: video bank switch */
566   thom_set_mode_point( space->machine, data & 1 );          /* bit 0: video bank switch */
567567   thom_set_caps_led( (data & 8) ? 1 : 0 ) ; /* bit 3: keyboard led */
568568   thom_set_border_color( ((data & 0x10) ? 1 : 0) | /* bits 4-6: border color */
569569                ((data & 0x20) ? 2 : 0) |
r3658r3659
581581
582582static READ8_HANDLER ( to7_timer_port_in )
583583{
584   int lightpen = (input_port_read(machine, "lightpen_button") & 1) ? 2 : 0;
585   int cass = to7_get_cassette(machine) ? 0x80 : 0;
584   int lightpen = (input_port_read(space->machine, "lightpen_button") & 1) ? 2 : 0;
585   int cass = to7_get_cassette(space->machine) ? 0x80 : 0;
586586   return lightpen | cass;
587587}
588588
r3658r3659
591591static WRITE8_HANDLER ( to7_timer_tco_out )
592592{
593593   /* 1-bit cassette output */
594   to7_set_cassette( machine, data );
594   to7_set_cassette( space->machine, data );
595595}
596596
597597
r3658r3659
669669   if ( to7_lightpen )
670670   {
671671      /* lightpen hi */
672      return to7_lightpen_gpl( machine, TO7_LIGHTPEN_DECAL, to7_lightpen_step ) >> 8;
672      return to7_lightpen_gpl( space->machine, TO7_LIGHTPEN_DECAL, to7_lightpen_step ) >> 8;
673673   }
674674   else
675675   {
r3658r3659
683683      for ( i = 0; i < 8; i++ )
684684      {
685685         if ( ! (keyline & (1 << i)) )
686            val &= input_port_read(machine, keynames[i]);
686            val &= input_port_read(space->machine, keynames[i]);
687687      }
688688      return val;
689689   }
r3658r3659
694694static READ8_HANDLER ( to7_sys_portb_in )
695695{
696696   /* lightpen low */
697   return to7_lightpen_gpl( machine, TO7_LIGHTPEN_DECAL, to7_lightpen_step ) & 0xff;
697   return to7_lightpen_gpl( space->machine, TO7_LIGHTPEN_DECAL, to7_lightpen_step ) & 0xff;
698698}
699699
700700
r3658r3659
764764   int tx  = data & 1;
765765   int dtr = ( data & 2 ) ? 1 : 0;
766766
767   LOG_IO(( "$%04x %f to7_io_porta_out: tx=%i, dtr=%i\n",  activecpu_get_previouspc(), attotime_to_double(timer_get_time()), tx, dtr ));
767   LOG_IO(( "$%04x %f to7_io_porta_out: tx=%i, dtr=%i\n",  cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), tx, dtr ));
768768   if ( dtr )
769769      to7_io_line.State |=  SERIAL_STATE_DTR;
770770   else
r3658r3659
782782   int dsr = ( to7_io_line.input_state & SERIAL_STATE_DSR ) ? 0 : 1;
783783   int rd  = get_in_data_bit( to7_io_line.input_state );
784784
785   if ( to7_io_mode(machine) == TO7_IO_RS232 )
785   if ( to7_io_mode(space->machine) == TO7_IO_RS232 )
786786      cts = to7_io_line.input_state & SERIAL_STATE_CTS ? 0 : 1;
787787   else
788788      cts = ( centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY ) ? 1 : 0;
789789
790   LOG_IO(( "$%04x %f to7_io_porta_in: mode=%i cts=%i, dsr=%i, rd=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), to7_io_mode(machine), cts, dsr, rd ));
790   LOG_IO(( "$%04x %f to7_io_porta_in: mode=%i cts=%i, dsr=%i, rd=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), to7_io_mode(space->machine), cts, dsr, rd ));
791791
792792   return (dsr ? 0x20 : 0) | (cts ? 0x40 : 0) | (rd ? 0x80: 0);
793793}
r3658r3659
798798{
799799   /* set 8-bit data */
800800
801   LOG_IO(( "$%04x %f to7_io_portb_out: CENTRONICS set data=$%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ));
801   LOG_IO(( "$%04x %f to7_io_portb_out: CENTRONICS set data=$%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data ));
802802
803803   centronics_write_data( 0, data );
804804}
r3658r3659
809809{
810810   /* send STROBE to printer */
811811
812   LOG_IO(( "$%04x %f to7_io_cb2_out: CENTRONICS set strobe=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ));
812   LOG_IO(( "$%04x %f to7_io_cb2_out: CENTRONICS set strobe=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data ));
813813
814814   centronics_write_handshake( 0, data ? CENTRONICS_STROBE : 0, CENTRONICS_STROBE );
815815}
r3658r3659
975975
976976READ8_HANDLER ( to7_modem_mea8000_r )
977977{
978   if ( input_port_read(machine, "mconfig") & 1 )
979      return mea8000_r( machine, offset );
978   if ( input_port_read(space->machine, "mconfig") & 1 )
979      return mea8000_r( space, offset );
980980   else
981981   {
982982      switch ( offset ) {
983      case 0: return acia6850_0_stat_r( machine, 0 );
984      case 1: return acia6850_0_data_r( machine, 0 );
983      case 0: return acia6850_0_stat_r( space, 0 );
984      case 1: return acia6850_0_data_r( space, 0 );
985985      default: return 0;
986986      }
987987   }
r3658r3659
991991
992992WRITE8_HANDLER ( to7_modem_mea8000_w )
993993{
994   if ( input_port_read(machine, "mconfig") & 1 )
995      mea8000_w( machine, offset, data );
994   if ( input_port_read(space->machine, "mconfig") & 1 )
995      mea8000_w( space, offset, data );
996996   else
997997   {
998998      switch ( offset ) {
999      case 0: acia6850_0_ctrl_w( machine, 0, data ); break;
1000      case 1: acia6850_0_data_w( machine, 0, data ); break;
999      case 0: acia6850_0_ctrl_w( space, 0, data ); break;
1000      case 1: acia6850_0_data_w( space, 0, data ); break;
10011001      }
10021002   }
10031003}
r3658r3659
10601060static READ8_HANDLER ( to7_game_porta_in )
10611061{
10621062   UINT8 data;
1063   if ( input_port_read(machine, "config") & 1 )
1063   if ( input_port_read(space->machine, "config") & 1 )
10641064   {
10651065      /* mouse */
1066      data = to7_get_mouse_signal(machine) & 0x0c;             /* XB, YB */
1067      data |= input_port_read(machine, "mouse_button") & 3; /* buttons */
1066      data = to7_get_mouse_signal(space->machine) & 0x0c;             /* XB, YB */
1067      data |= input_port_read(space->machine, "mouse_button") & 3; /* buttons */
10681068   }
10691069   else
10701070   {
10711071      /* joystick */
1072      data = input_port_read(machine, "game_port_directions");
1072      data = input_port_read(space->machine, "game_port_directions");
10731073      /* bit 0=0 => P1 up      bit 4=0 => P2 up
10741074         bit 1=0 => P1 down    bit 5=0 => P2 down
10751075         bit 2=0 => P1 left    bit 6=0 => P2 left
r3658r3659
11011101static READ8_HANDLER ( to7_game_portb_in )
11021102{
11031103   UINT8 data;
1104   if ( input_port_read(machine, "config") & 1 )
1104   if ( input_port_read(space->machine, "config") & 1 )
11051105   {
11061106      /* mouse */
1107      UINT8 mouse =  to7_get_mouse_signal(machine);
1107      UINT8 mouse =  to7_get_mouse_signal(space->machine);
11081108      data = 0;
11091109      if ( mouse & 1 )
11101110         data |= 0x04; /* XA */
r3658r3659
11181118      /* bits 2-3: action buttons B (0=pressed) */
11191119      /* bits 4-5: unused (ouput) */
11201120      /* bits 0-1: unknown! */
1121      data = input_port_read(machine, "game_port_buttons");
1121      data = input_port_read(space->machine, "game_port_buttons");
11221122   }
11231123   return data;
11241124}
r3658r3659
12951295      /* bit 6:     parity error (ignored) */
12961296      /* bit 7:     interrupt */
12971297      LOG_MIDI(( "$%04x %f to7_midi_r: status $%02X (rdrf=%i, tdre=%i, ovrn=%i, irq=%i)\n",
1298           activecpu_get_previouspc(), attotime_to_double(timer_get_time()), to7_midi_status,
1298           cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), to7_midi_status,
12991299           (to7_midi_status & ACIA_6850_RDRF) ? 1 : 0,
13001300           (to7_midi_status & ACIA_6850_TDRE) ? 1 : 0,
13011301           (to7_midi_status & ACIA_6850_OVRN) ? 1 : 0,
r3658r3659
13131313         to7_midi_status &= ~ACIA_6850_OVRN;
13141314      to7_midi_overrun = 0;
13151315      LOG_MIDI(( "$%04x %f to7_midi_r: read data $%02X\n",
1316           activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ));
1316           cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data ));
13171317      to7_midi_update_irq();
13181318      return data;
13191319   }
r3658r3659
13211321
13221322   default:
13231323      logerror( "$%04x to7_midi_r: invalid offset %i\n",
1324           activecpu_get_previouspc(),  offset );
1324           cpu_get_previouspc(space->cpu),  offset );
13251325      return 0;
13261326   }
13271327}
r3658r3659
13401340      if ( (data & 3) == 3 )
13411341      {
13421342         /* reset */
1343         LOG_MIDI(( "$%04x %f to7_midi_w: reset (data=$%02X)\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ));
1343         LOG_MIDI(( "$%04x %f to7_midi_w: reset (data=$%02X)\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data ));
13441344         to7_midi_overrun = 0;
13451345         to7_midi_status = 2;
13461346         to7_midi_intr = 0;
r3658r3659
13571357            static const int stop[8] = { 2,2,1,1,2,1,1,1 };
13581358            static const char parity[8] = { 'e','o','e','o','-','-','e','o' };
13591359            LOG_MIDI(( "$%04x %f to7_midi_w: set control to $%02X (bits=%i, stop=%i, parity=%c, intr in=%i out=%i)\n",
1360                 activecpu_get_previouspc(), attotime_to_double(timer_get_time()),
1360                 cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()),
13611361                 data,
13621362                 bits[ (data >> 2) & 7 ],
13631363                 stop[ (data >> 2) & 7 ],
r3658r3659
13711371
13721372
13731373   case 1: /* output data */
1374      LOG_MIDI(( "$%04x %f to7_midi_w: write data $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ));
1374      LOG_MIDI(( "$%04x %f to7_midi_w: write data $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data ));
13751375      if ( data == 0x55 )
13761376         /* cable-detect: shortcut */
13771377         chardev_fake_in( to7_midi_chardev, 0x55 );
r3658r3659
13851385
13861386
13871387   default:
1388      logerror( "$%04x to7_midi_w: invalid offset %i (data=$%02X) \n", activecpu_get_previouspc(), offset, data );
1388      logerror( "$%04x to7_midi_w: invalid offset %i (data=$%02X) \n", cpu_get_previouspc(space->cpu), offset, data );
13891389   }
13901390}
13911391
r3658r3659
14821482   thom_set_video_mode( THOM_VMODE_TO770 );
14831483   thom_set_init_callback( to7_set_init );
14841484   thom_set_lightpen_callback( 3, to7_lightpen_cb );
1485   thom_set_mode_point( 0 );
1485   thom_set_mode_point( machine, 0 );
14861486   thom_set_border_color( 0 );
14871487   pia_set_input_cb1( THOM_PIA_SYS, 0 );
14881488
r3658r3659
15171517   /* memory */
15181518   thom_cart_bank = 0;
15191519   thom_vram = mess_ram;
1520   memory_configure_bank( THOM_BASE_BANK, 0, 1, mess_ram + 0x4000, 0x2000 );
1521   memory_configure_bank( THOM_VRAM_BANK, 0, 2, thom_vram, 0x2000 );
1522   memory_configure_bank( THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 );
1523   memory_set_bank( THOM_BASE_BANK, 0 );
1524   memory_set_bank( THOM_VRAM_BANK, 0 );
1525   memory_set_bank( THOM_CART_BANK, 0 );
1520   memory_configure_bank( machine, THOM_BASE_BANK, 0, 1, mess_ram + 0x4000, 0x2000 );
1521   memory_configure_bank( machine, THOM_VRAM_BANK, 0, 2, thom_vram, 0x2000 );
1522   memory_configure_bank( machine, THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 );
1523   memory_set_bank( machine, THOM_BASE_BANK, 0 );
1524   memory_set_bank( machine, THOM_VRAM_BANK, 0 );
1525   memory_set_bank( machine, THOM_CART_BANK, 0 );
15261526
15271527   if ( mess_ram_size > 24*1024 )
15281528   {
15291529      /* install 16 KB or 16 KB + 8 KB memory extensions */
15301530      /* BASIC instruction to see free memory: ?FRE(0) */
15311531      int extram = mess_ram_size - 24*1024;
1532      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x8000, 0x8000 + extram - 1, 0, 0,
1533                      (write8_machine_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) );
1534      memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x8000, 0x8000 + extram - 1, 0, 0,
1535                      (read8_machine_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) );
1536      memory_configure_bank( THOM_RAM_BANK,  0, 1, mess_ram + 0x6000, extram );
1537      memory_set_bank( THOM_RAM_BANK, 0 );
1532      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x8000, 0x8000 + extram - 1, 0, 0,
1533                      (write8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) );
1534      memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x8000, 0x8000 + extram - 1, 0, 0,
1535                      (read8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) );
1536      memory_configure_bank( machine, THOM_RAM_BANK,  0, 1, mess_ram + 0x6000, extram );
1537      memory_set_bank( machine, THOM_RAM_BANK, 0 );
15381538   }
15391539
15401540   /* force 2 topmost color bits to 1 */
r3658r3659
15621562static WRITE8_HANDLER ( to770_sys_cb2_out )
15631563{
15641564   /* video overlay: black pixels are transparent and show TV image underneath */
1565   LOG(( "$%04x to770_sys_cb2_out: video overlay %i\n", activecpu_get_previouspc(), data ));
1565   LOG(( "$%04x to770_sys_cb2_out: video overlay %i\n", cpu_get_previouspc(space->cpu), data ));
15661566}
15671567
15681568
r3658r3659
15741574                              "keyboard_4", "keyboard_5", "keyboard_6", "keyboard_7" };
15751575   int keyline = pia_get_output_b( THOM_PIA_SYS ) & 7;
15761576   
1577   return input_port_read(machine, keynames[7 - keyline]);
1577   return input_port_read(space->machine, keynames[7 - keyline]);
15781578}
15791579
15801580
r3658r3659
16101610
16111611   if ( mess_ram_size == 128*1024 || bank < 2 )
16121612   {
1613      memory_set_bank( THOM_RAM_BANK, bank );
1614      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xdfff, 0, 0, (write8_machine_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) );
1613      memory_set_bank( machine, THOM_RAM_BANK, bank );
1614      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xdfff, 0, 0, (write8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) );
16151615   }
16161616   else
16171617   {
1618      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xdfff, 0, 0, SMH_UNMAP );
1618      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xdfff, 0, 0, SMH_UNMAP );
16191619   }
16201620
16211621   old_bank = bank;
r3658r3659
16321632
16331633static WRITE8_HANDLER ( to770_sys_portb_out )
16341634{
1635   to770_update_ram_bank(machine);
1635   to770_update_ram_bank(space->machine);
16361636}
16371637
16381638
r3658r3659
16531653
16541654static WRITE8_HANDLER ( to770_timer_port_out )
16551655{
1656   thom_set_mode_point( data & 1 );          /* bit 0: video bank switch */
1656   thom_set_mode_point( space->machine, data & 1 );          /* bit 0: video bank switch */
16571657   thom_set_caps_led( (data & 8) ? 1 : 0 ) ; /* bit 3: keyboard led */
16581658   thom_set_border_color( ((data & 0x10) ? 1 : 0) | /* 4-bit border color */
16591659                ((data & 0x20) ? 2 : 0) |
r3658r3659
16791679READ8_HANDLER ( to770_gatearray_r )
16801680{
16811681   struct thom_vsignal v = thom_get_vsignal();
1682   struct thom_vsignal l = thom_get_lightpen_vsignal( machine, TO7_LIGHTPEN_DECAL, to7_lightpen_step - 1, 0 );
1682   struct thom_vsignal l = thom_get_lightpen_vsignal( space->machine, TO7_LIGHTPEN_DECAL, to7_lightpen_step - 1, 0 );
16831683   int count, inil, init, lt3;
16841684   count = to7_lightpen ? l.count : v.count;
16851685   inil  = to7_lightpen ? l.inil  : v.inil;
r3658r3659
16931693   case 2: return (lt3 << 7) | (inil << 6);
16941694   case 3: return (init << 7);
16951695   default:
1696      logerror( "$%04x to770_gatearray_r: invalid offset %i\n", activecpu_get_previouspc(), offset );
1696      logerror( "$%04x to770_gatearray_r: invalid offset %i\n", cpu_get_previouspc(space->cpu), offset );
16971697      return 0;
16981698   }
16991699}
r3658r3659
17321732   thom_set_video_mode( THOM_VMODE_TO770 );
17331733   thom_set_init_callback( to7_set_init );
17341734   thom_set_lightpen_callback( 3, to7_lightpen_cb );
1735   thom_set_mode_point( 0 );
1735   thom_set_mode_point( machine, 0 );
17361736   thom_set_border_color( 8 );
17371737   pia_set_input_cb1( THOM_PIA_SYS, 0 );
17381738
r3658r3659
17681768   /* memory */
17691769   thom_cart_bank = 0;
17701770   thom_vram = mess_ram;
1771   memory_configure_bank( THOM_BASE_BANK, 0, 1, mess_ram + 0x4000, 0x4000 );
1772   memory_configure_bank( THOM_RAM_BANK,  0, 6, mess_ram + 0x8000, 0x4000 );
1773   memory_configure_bank( THOM_VRAM_BANK, 0, 2, thom_vram, 0x2000 );
1774   memory_configure_bank( THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 );
1775   memory_set_bank( THOM_BASE_BANK, 0 );
1776   memory_set_bank( THOM_RAM_BANK,  0 );
1777   memory_set_bank( THOM_VRAM_BANK, 0 );
1778   memory_set_bank( THOM_CART_BANK, 0 );
1771   memory_configure_bank( machine, THOM_BASE_BANK, 0, 1, mess_ram + 0x4000, 0x4000 );
1772   memory_configure_bank( machine, THOM_RAM_BANK,  0, 6, mess_ram + 0x8000, 0x4000 );
1773   memory_configure_bank( machine, THOM_VRAM_BANK, 0, 2, thom_vram, 0x2000 );
1774   memory_configure_bank( machine, THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 );
1775   memory_set_bank( machine, THOM_BASE_BANK, 0 );
1776   memory_set_bank( machine, THOM_RAM_BANK,  0 );
1777   memory_set_bank( machine, THOM_VRAM_BANK, 0 );
1778   memory_set_bank( machine, THOM_CART_BANK, 0 );
17791779
17801780   /* save-state */
17811781   state_save_register_global( thom_cart_nb_banks );
r3658r3659
18441844
18451845static WRITE8_HANDLER ( mo5_sys_porta_out )
18461846{
1847   thom_set_mode_point( data & 1 );                  /* bit 0: video bank switch */
1847   thom_set_mode_point( space->machine, data & 1 );                  /* bit 0: video bank switch */
18481848   thom_set_border_color( (data >> 1) & 15 );            /* bit 1-4: border color */
1849   mo5_set_cassette( machine, (data & 0x40) ? 1 : 0 );      /* bit 6: cassette output */
1849   mo5_set_cassette( space->machine, (data & 0x40) ? 1 : 0 );      /* bit 6: cassette output */
18501850}
18511851
18521852
r3658r3659
18541854static READ8_HANDLER ( mo5_sys_porta_in )
18551855{
18561856   return
1857      (mo5_get_cassette(machine) ? 0x80 : 0) |     /* bit 7: cassette input */
1858      ((input_port_read(machine, "lightpen_button") & 1) ? 0x20 : 0)
1857      (mo5_get_cassette(space->machine) ? 0x80 : 0) |     /* bit 7: cassette input */
1858      ((input_port_read(space->machine, "lightpen_button") & 1) ? 0x20 : 0)
18591859      /* bit 5: lightpen button */;
18601860}
18611861
r3658r3659
18761876   static const char *keynames[] = { "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3",
18771877                              "keyboard_4", "keyboard_5", "keyboard_6", "keyboard_7" };
18781878   
1879   return ( input_port_read(machine, keynames[lin]) & (1 << col) ) ? 0x80 : 0;
1879   return ( input_port_read(space->machine, keynames[lin]) & (1 << col) ) ? 0x80 : 0;
18801880}
18811881
18821882
r3658r3659
19021902READ8_HANDLER ( mo5_gatearray_r )
19031903{
19041904   struct thom_vsignal v = thom_get_vsignal();
1905   struct thom_vsignal l = thom_get_lightpen_vsignal( machine, MO5_LIGHTPEN_DECAL, to7_lightpen_step - 1, 0 );
1905   struct thom_vsignal l = thom_get_lightpen_vsignal( space->machine, MO5_LIGHTPEN_DECAL, to7_lightpen_step - 1, 0 );
19061906   int count, inil, init, lt3;
19071907   count = to7_lightpen ? l.count : v.count;
19081908   inil  = to7_lightpen ? l.inil  : v.inil;
r3658r3659
19151915   case 2: return (lt3 << 7) | (inil << 6);
19161916   case 3: return (init << 7);
19171917   default:
1918      logerror( "$%04x mo5_gatearray_r: invalid offset %i\n",  activecpu_get_previouspc(), offset );
1918      logerror( "$%04x mo5_gatearray_r: invalid offset %i\n",  cpu_get_previouspc(space->cpu), offset );
19191919      return 0;
19201920   }
19211921}
r3658r3659
19901990   int rom_is_ram = mo5_reg_cart & 4;
19911991   int bank = 0;
19921992
1993   memory_install_read8_handler(machine,  0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0,
1994                  (read8_machine_func)(STATIC_BANK1 + THOM_CART_BANK - 1) );
1993   memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0,
1994                  (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) );
19951995
19961996   if ( rom_is_ram && thom_cart_nb_banks == 4 )
19971997   {
19981998      /* 64 KB ROM from "JANE" cartridge */
1999      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, SMH_NOP );
1999      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, SMH_NOP );
20002000      bank = mo5_reg_cart & 3;
20012001      if ( bank != old_bank )
20022002         LOG_BANK(( "mo5_update_cart_bank: CART is cartridge bank %i (A7CB style)\n", bank ));
r3658r3659
20062006      /* 64 KB RAM from network extension */
20072007      int write_enable = mo5_reg_cart & 8;
20082008      bank = 4 + ( mo5_reg_cart & 3 );
2009      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, write_enable ?
2010                      (write8_machine_func)(STATIC_BANK1 + THOM_CART_BANK - 1) :  SMH_NOP );
2009      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, write_enable ?
2010                      (write8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) :  SMH_NOP );
20112011      if ( bank != old_bank )
20122012         LOG_BANK(( "mo5_update_cart_bank: CART is nanonetwork RAM bank %i (write-enable=%i)\n", mo5_reg_cart & 3, write_enable ? 1 : 0 ));
20132013   }
20142014   else
20152015   {
20162016      /* regular cartridge bank switch */
2017      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, mo5_cartridge_w );
2017      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, mo5_cartridge_w );
20182018      if ( thom_cart_nb_banks )
20192019      {
20202020         bank = thom_cart_bank % thom_cart_nb_banks;
2021         memory_install_read8_handler(machine,  0, ADDRESS_SPACE_PROGRAM, 0xbffc, 0xbfff, 0, 0, mo5_cartridge_r );
2021         memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xbffc, 0xbfff, 0, 0, mo5_cartridge_r );
20222022      }
20232023      if ( bank != old_bank )
20242024         LOG_BANK(( "mo5_update_cart_bank: CART is internal / cartridge bank %i\n", thom_cart_bank ));
20252025   }
2026   memory_set_bank( THOM_CART_BANK, bank );
2026   memory_set_bank( machine, THOM_CART_BANK, bank );
20272027   old_bank = bank;
20282028}
20292029
r3658r3659
20432043      return;
20442044
20452045   thom_cart_bank = offset & 3;
2046   mo5_update_cart_bank(machine);
2046   mo5_update_cart_bank(space->machine);
20472047}
20482048
20492049
r3658r3659
20512051/* read signal to bffc-bfff generates a bank switch */
20522052READ8_HANDLER ( mo5_cartridge_r )
20532053{
2054   UINT8* pos = memory_region( machine, "main" ) + 0x10000;
2054   UINT8* pos = memory_region( space->machine, "main" ) + 0x10000;
20552055   UINT8 data = pos[offset + 0xbffc + (thom_cart_bank % thom_cart_nb_banks) * 0x4000];
20562056   thom_cart_bank = offset & 3;
2057   mo5_update_cart_bank(machine);
2057   mo5_update_cart_bank(space->machine);
20582058   return data;
20592059}
20602060
r3658r3659
20642064WRITE8_HANDLER ( mo5_ext_w )
20652065{
20662066   mo5_reg_cart = data;
2067   mo5_update_cart_bank(machine);
2067   mo5_update_cart_bank(space->machine);
20682068}
20692069
20702070
r3658r3659
20932093   /* video */
20942094   thom_set_video_mode( THOM_VMODE_MO5 );
20952095   thom_set_lightpen_callback( 3, mo5_lightpen_cb );
2096   thom_set_mode_point( 0 );
2096   thom_set_mode_point( machine, 0 );
20972097   thom_set_border_color( 0 );
20982098   pia_set_input_ca1( THOM_PIA_SYS, 0 );
20992099
r3658r3659
21302130   thom_cart_bank = 0;
21312131   mo5_reg_cart = 0;
21322132   thom_vram = mess_ram;
2133   memory_configure_bank( THOM_BASE_BANK, 0, 1, mess_ram + 0x4000, 0x8000 );
2134   memory_configure_bank( THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 );
2135   memory_configure_bank( THOM_CART_BANK, 4, 4, mess_ram + 0xc000, 0x4000 );
2136   memory_configure_bank( THOM_VRAM_BANK, 0, 2, thom_vram, 0x2000 );
2137   memory_set_bank( THOM_BASE_BANK, 0 );
2138   memory_set_bank( THOM_CART_BANK, 0 );
2139   memory_set_bank( THOM_VRAM_BANK, 0 );
2133   memory_configure_bank( machine, THOM_BASE_BANK, 0, 1, mess_ram + 0x4000, 0x8000 );
2134   memory_configure_bank( machine, THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 );
2135   memory_configure_bank( machine, THOM_CART_BANK, 4, 4, mess_ram + 0xc000, 0x4000 );
2136   memory_configure_bank( machine, THOM_VRAM_BANK, 0, 2, thom_vram, 0x2000 );
2137   memory_set_bank( machine, THOM_BASE_BANK, 0 );
2138   memory_set_bank( machine, THOM_CART_BANK, 0 );
2139   memory_set_bank( machine, THOM_VRAM_BANK, 0 );
21402140
21412141   /* save-state */
21422142   state_save_register_global( thom_cart_nb_banks );
r3658r3659
21642164
21652165WRITE8_HANDLER ( to9_ieee_w )
21662166{
2167   logerror( "$%04x %f to9_ieee_w: unhandled write $%02X to register %i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data, offset );
2167   logerror( "$%04x %f to9_ieee_w: unhandled write $%02X to register %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data, offset );
21682168}
21692169
21702170
21712171
21722172READ8_HANDLER  ( to9_ieee_r )
21732173{
2174   logerror( "$%04x %f to9_ieee_r: unhandled read from register %i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), offset );
2174   logerror( "$%04x %f to9_ieee_r: unhandled read from register %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), offset );
21752175   return 0;
21762176}
21772177
r3658r3659
21882188READ8_HANDLER ( to9_gatearray_r )
21892189{
21902190   struct thom_vsignal v = thom_get_vsignal();
2191   struct thom_vsignal l = thom_get_lightpen_vsignal( machine, TO9_LIGHTPEN_DECAL, to7_lightpen_step - 1, 0 );
2191   struct thom_vsignal l = thom_get_lightpen_vsignal( space->machine, TO9_LIGHTPEN_DECAL, to7_lightpen_step - 1, 0 );
21922192   int count, inil, init, lt3;
21932193   count = to7_lightpen ? l.count : v.count;
21942194   inil  = to7_lightpen ? l.inil  : v.inil;
r3658r3659
22022202   case 2: return (lt3 << 7) | (inil << 6);
22032203   case 3: return (v.init << 7) | (init << 6); /* != TO7/70 */
22042204   default:
2205      logerror( "$%04x to9_gatearray_r: invalid offset %i\n", activecpu_get_previouspc(), offset );
2205      logerror( "$%04x to9_gatearray_r: invalid offset %i\n", cpu_get_previouspc(space->cpu), offset );
22062206      return 0;
22072207   }
22082208}
r3658r3659
22972297
22982298WRITE8_HANDLER ( to9_vreg_w )
22992299{
2300   LOG_VIDEO(( "$%04x %f to9_vreg_w: off=%i ($%04X) data=$%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), offset, 0xe7da + offset, data ));
2300   LOG_VIDEO(( "$%04x %f to9_vreg_w: off=%i ($%04X) data=$%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), offset, 0xe7da + offset, data ));
23012301
23022302   switch ( offset )
23032303   {
r3658r3659
23572357   int slot = ( mc6846_get_output_port(machine) >> 4 ) & 3; /* bits 4-5: ROM bank */
23582358
23592359   /* reset cartridge read handler */
2360   memory_install_read8_handler(machine,  0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x0003, 0, 0, (read8_machine_func)(STATIC_BANK1 + THOM_CART_BANK - 1) );
2360   memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x0003, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) );
23612361
23622362   switch ( slot )
23632363   {
r3658r3659
23842384      if ( thom_cart_nb_banks )
23852385      {
23862386         bank = thom_cart_bank % thom_cart_nb_banks;
2387         memory_install_read8_handler(machine,  0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x0003, 0, 0, to7_cartridge_r );
2387         memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x0003, 0, 0, to7_cartridge_r );
23882388      }
23892389      if ( bank != old_bank )
23902390         LOG_BANK(( "to9_update_cart_bank: CART is cartridge bank %i\n",  thom_cart_bank ));
23912391      break;
23922392   }
23932393
2394   memory_set_bank( THOM_CART_BANK, bank );
2394   memory_set_bank( machine, THOM_CART_BANK, bank );
23952395   old_bank = bank;
23962396}
23972397
r3658r3659
24072407/* write signal to 0000-1fff generates a bank switch */
24082408WRITE8_HANDLER ( to9_cartridge_w )
24092409{
2410   int slot = ( mc6846_get_output_port(machine) >> 4 ) & 3; /* bits 4-5: ROM bank */
2410   int slot = ( mc6846_get_output_port(space->machine) >> 4 ) & 3; /* bits 4-5: ROM bank */
24112411
24122412   if ( offset >= 0x2000 )
24132413      return;
r3658r3659
24162416      thom_cart_bank = offset & 3;
24172417   else
24182418      to9_soft_bank = offset & 3;
2419   to9_update_cart_bank(machine);
2419   to9_update_cart_bank(space->machine);
24202420}
24212421
24222422
r3658r3659
24242424/* read signal to 0000-0003 generates a bank switch */
24252425READ8_HANDLER ( to9_cartridge_r )
24262426{
2427   UINT8* pos = memory_region( machine, "main" ) + 0x10000;
2427   UINT8* pos = memory_region( space->machine, "main" ) + 0x10000;
24282428   UINT8 data = pos[offset + (thom_cart_bank % thom_cart_nb_banks) * 0x4000];
24292429   thom_cart_bank = offset & 3;
2430   to9_update_cart_bank(machine);
2430   to9_update_cart_bank(space->machine);
24312431   return data;
24322432}
24332433
r3658r3659
24672467
24682468   if ( mess_ram_size == 192*1024 || bank < 6 )
24692469   {
2470      memory_set_bank( THOM_RAM_BANK, bank );
2471      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xdfff, 0, 0, (write8_machine_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) );
2470      memory_set_bank( machine, THOM_RAM_BANK, bank );
2471      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xdfff, 0, 0, (write8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) );
24722472   }
24732473   else
24742474   {
2475      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xdfff, 0, 0, SMH_NOP );
2475      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xdfff, 0, 0, SMH_NOP );
24762476   }
24772477
24782478   old_bank = bank;
r3658r3659
25922592      /* bit 7:     interrupt */
25932593
25942594      LOG_KBD(( "$%04x %f to9_kbd_r: status $%02X (rdrf=%i, tdre=%i, ovrn=%i, pe=%i, irq=%i)\n",
2595           activecpu_get_previouspc(), attotime_to_double(timer_get_time()), to9_kbd_status,
2595           cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), to9_kbd_status,
25962596           (to9_kbd_status & ACIA_6850_RDRF) ? 1 : 0,
25972597           (to9_kbd_status & ACIA_6850_TDRE) ? 1 : 0,
25982598           (to9_kbd_status & ACIA_6850_OVRN) ? 1 : 0,
r3658r3659
26072607      else
26082608         to9_kbd_status &= ~(ACIA_6850_OVRN | ACIA_6850_RDRF);
26092609      to9_kbd_overrun = 0;
2610      LOG_KBD(( "$%04x %f to9_kbd_r: read data $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), to9_kbd_in ));
2611      to9_kbd_update_irq(machine);
2610      LOG_KBD(( "$%04x %f to9_kbd_r: read data $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), to9_kbd_in ));
2611      to9_kbd_update_irq(space->machine);
26122612      return to9_kbd_in;
26132613
26142614   default:
2615      logerror( "$%04x to9_kbd_r: invalid offset %i\n", activecpu_get_previouspc(),  offset );
2615      logerror( "$%04x to9_kbd_r: invalid offset %i\n", cpu_get_previouspc(space->cpu),  offset );
26162616      return 0;
26172617   }
26182618}
r3658r3659
26342634         to9_kbd_overrun = 0;
26352635         to9_kbd_status = ACIA_6850_TDRE;
26362636         to9_kbd_intr = 0;
2637         LOG_KBD(( "$%04x %f to9_kbd_w: reset (data=$%02X)\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ));
2637         LOG_KBD(( "$%04x %f to9_kbd_w: reset (data=$%02X)\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data ));
26382638      }
26392639      else
26402640      {
r3658r3659
26482648         to9_kbd_intr = data >> 5;
26492649
26502650         LOG_KBD(( "$%04x %f to9_kbd_w: set control to $%02X (parity=%i, intr in=%i out=%i)\n",
2651              activecpu_get_previouspc(), attotime_to_double(timer_get_time()),
2651              cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()),
26522652              data, to9_kbd_parity, to9_kbd_intr >> 2,
26532653              (to9_kbd_intr & 3) ? 1 : 0 ));
26542654      }
2655      to9_kbd_update_irq(machine);
2655      to9_kbd_update_irq(space->machine);
26562656      break;
26572657
26582658   case 1: /* output data */
26592659      to9_kbd_status &= ~(ACIA_6850_irq | ACIA_6850_TDRE);
2660      to9_kbd_update_irq(machine);
2660      to9_kbd_update_irq(space->machine);
26612661      /* TODO: 1 ms delay here ? */
26622662      to9_kbd_status |= ACIA_6850_TDRE; /* data transmit ready again */
2663      to9_kbd_update_irq(machine);
2663      to9_kbd_update_irq(space->machine);
26642664
26652665      switch ( data )
26662666      {
r3658r3659
26792679      case 0xFE: to9_kbd_periph = 0; break;
26802680
26812681      default:
2682         logerror( "$%04x %f to9_kbd_w: unknown kbd command %02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data );
2682         logerror( "$%04x %f to9_kbd_w: unknown kbd command %02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data );
26832683      }
26842684
26852685      thom_set_caps_led( ! to9_kbd_caps );
26862686
26872687      LOG(( "$%04x %f to9_kbd_w: kbd command %02X (caps=%i, pad=%i, periph=%i)\n",
2688            activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data,
2688            cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data,
26892689            to9_kbd_caps, to9_kbd_pad, to9_kbd_periph ));
26902690
26912691      break;
26922692
26932693   default:
2694      logerror( "$%04x to9_kbd_w: invalid offset %i (data=$%02X) \n", activecpu_get_previouspc(), offset, data );
2694      logerror( "$%04x to9_kbd_w: invalid offset %i (data=$%02X) \n", cpu_get_previouspc(space->cpu), offset, data );
26952695   }
26962696}
26972697
r3658r3659
29632963   centronics_write_data( 0, data );
29642964   centronics_write_handshake( 0, (b & 2) ? CENTRONICS_STROBE : 0, CENTRONICS_STROBE );
29652965
2966   LOG_IO(( "$%04x %f to9_update_centronics: data=$%02X strobe=%i\n",
2967        activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data,
2968        (b & 2) ? 1 : 0 ));
2966//   LOG_IO(( "$%04x %f to9_update_centronics: data=$%02X strobe=%i\n",
2967//        cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data,
2968//        (b & 2) ? 1 : 0 ));
29692969}
29702970
29712971
29722972
29732973static READ8_HANDLER ( to9_sys_porta_in )
29742974{
2975   UINT8 ktest = to9_kbd_ktest(machine);
2975   UINT8 ktest = to9_kbd_ktest(space->machine);
29762976
29772977   LOG_KBD(( "to9_sys_porta_in: ktest=%i\n", ktest ));
29782978
r3658r3659
29832983
29842984static WRITE8_HANDLER ( to9_sys_porta_out )
29852985{
2986   to9_update_centronics(machine); /* bits 1-7: printer */
2986   to9_update_centronics(space->machine); /* bits 1-7: printer */
29872987}
29882988
29892989
29902990
29912991static WRITE8_HANDLER ( to9_sys_portb_out )
29922992{
2993   to9_update_centronics(machine); /* bits 0-1: printer */
2994   to9_update_ram_bank(machine);
2993   to9_update_centronics(space->machine); /* bits 0-1: printer */
2994   to9_update_ram_bank(space->machine);
29952995
29962996   if ( data & 4 ) /* bit 2: video overlay (TODO) */
29972997      LOG(( "to9_sys_portb_out: video overlay not handled\n" ));
r3658r3659
30183018
30193019static WRITE8_HANDLER ( to9_timer_port_out )
30203020{
3021   thom_set_mode_point( data & 1 ); /* bit 0: video bank */
3022   to9_update_ram_bank(machine);
3023   to9_update_cart_bank(machine);
3021   thom_set_mode_point( space->machine, data & 1 ); /* bit 0: video bank */
3022   to9_update_ram_bank(space->machine);
3023   to9_update_cart_bank(space->machine);
30243024}
30253025
30263026
r3658r3659
30603060   thom_set_video_mode( THOM_VMODE_TO9 );
30613061   thom_set_lightpen_callback( 3, to7_lightpen_cb );
30623062   thom_set_border_color( 8 );
3063   thom_set_mode_point( 0 );
3063   thom_set_mode_point( machine, 0 );
30643064   pia_set_input_cb1( THOM_PIA_SYS, 0 );
30653065
30663066   /* memory */
r3658r3659
30983098   /* memory */
30993099   thom_vram = mess_ram;
31003100   thom_cart_bank = 0;
3101   memory_configure_bank( THOM_VRAM_BANK, 0,  2, thom_vram, 0x2000 );
3102   memory_configure_bank( THOM_CART_BANK, 0, 12, mem + 0x10000, 0x4000 );
3103   memory_configure_bank( THOM_BASE_BANK, 0,  1, mess_ram + 0x4000, 0x4000 );
3104   memory_configure_bank( THOM_RAM_BANK,  0, 10, mess_ram + 0x8000, 0x4000 );
3105   memory_set_bank( THOM_VRAM_BANK, 0 );
3106   memory_set_bank( THOM_CART_BANK, 0 );
3107   memory_set_bank( THOM_BASE_BANK, 0 );
3108   memory_set_bank( THOM_RAM_BANK,  0 );
3101   memory_configure_bank( machine, THOM_VRAM_BANK, 0,  2, thom_vram, 0x2000 );
3102   memory_configure_bank( machine, THOM_CART_BANK, 0, 12, mem + 0x10000, 0x4000 );
3103   memory_configure_bank( machine, THOM_BASE_BANK, 0,  1, mess_ram + 0x4000, 0x4000 );
3104   memory_configure_bank( machine, THOM_RAM_BANK,  0, 10, mess_ram + 0x8000, 0x4000 );
3105   memory_set_bank( machine, THOM_VRAM_BANK, 0 );
3106   memory_set_bank( machine, THOM_CART_BANK, 0 );
3107   memory_set_bank( machine, THOM_BASE_BANK, 0 );
3108   memory_set_bank( machine, THOM_RAM_BANK,  0 );
31093109
31103110   /* save-state */
31113111   state_save_register_global( thom_cart_nb_banks );
r3658r3659
34713471
34723472
34733473
3474static void to8_update_floppy_bank( void )
3474static void to8_update_floppy_bank(running_machine *machine)
34753475{
34763476   static int old_bank = -1;
34773477   int bank = (to8_reg_sys1 & 0x80) ? to7_floppy_bank : (to8_bios_bank + TO7_NB_FLOP_BANK);
r3658r3659
34803480      LOG_BANK(( "to8_update_floppy_bank: floppy ROM is %s bank %i\n",
34813481           (to8_reg_sys1 & 0x80) ? "external" : "internal",
34823482           bank % TO7_NB_FLOP_BANK ));
3483   memory_set_bank( THOM_FLOP_BANK, bank );
3483   memory_set_bank( machine, THOM_FLOP_BANK, bank );
34843484   old_bank = bank;
34853485}
34863486
r3658r3659
34883488
34893489static STATE_POSTLOAD( to8_update_floppy_bank_postload )
34903490{
3491   to8_update_floppy_bank();
3491   to8_update_floppy_bank(machine);
34923492}
34933493
34943494
r3658r3659
35353535   to8_data_vpage = bank;
35363536   if ( mess_ram_size == 512*1024 || to8_data_vpage < 16 )
35373537   {
3538      memory_set_bank( TO8_DATA_LO, to8_data_vpage );
3539      memory_set_bank( TO8_DATA_HI, to8_data_vpage );
3540      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xbfff, 0, 0, to8_data_vpage <= 4 ? to8_data_lo_w : (write8_machine_func)(STATIC_BANK1 + TO8_DATA_LO - 1) );
3541      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc000, 0xdfff, 0, 0, to8_data_vpage <= 4 ? to8_data_hi_w : (write8_machine_func)(STATIC_BANK1 + TO8_DATA_HI - 1) );
3538      memory_set_bank( machine, TO8_DATA_LO, to8_data_vpage );
3539      memory_set_bank( machine, TO8_DATA_HI, to8_data_vpage );
3540      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xbfff, 0, 0, to8_data_vpage <= 4 ? to8_data_lo_w : (write8_space_func)(STATIC_BANK1 + TO8_DATA_LO - 1) );
3541      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xc000, 0xdfff, 0, 0, to8_data_vpage <= 4 ? to8_data_hi_w : (write8_space_func)(STATIC_BANK1 + TO8_DATA_HI - 1) );
35423542   }
35433543   else
35443544   {
3545      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xbfff, 0, 0, SMH_NOP );
3546      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc000, 0xdfff, 0, 0, SMH_NOP );
3545      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xbfff, 0, 0, SMH_NOP );
3546      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xc000, 0xdfff, 0, 0, SMH_NOP );
35473547   }
35483548}
35493549
r3658r3659
35623562   int bank = 0;
35633563
35643564   /* reset bank switch */
3565   memory_install_read8_handler(machine,  0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x0003, 0, 0, (read8_machine_func)(STATIC_BANK1 + THOM_CART_BANK - 1) );
3565   memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x0003, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) );
35663566
35673567   if ( to8_reg_cart & 0x20 )
35683568   {
35693569      /* RAM space */
35703570      to8_cart_vpage = to8_reg_cart & 31;
35713571      bank = 8 + to8_cart_vpage;
3572      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0,
3572      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x3fff, 0, 0,
35733573                      ((to8_cart_vpage < 8 || mess_ram_size == 512*1024) && (to8_reg_cart & 0x40)) ?
35743574                      (to8_cart_vpage <= 4) ? to8_vcart_w :
3575                      (write8_machine_func)(STATIC_BANK1 + THOM_CART_BANK - 1) :
3575                      (write8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) :
35763576                      SMH_NOP );
35773577      if ( bank != old_bank )
35783578         LOG_BANK(( "to8_update_cart_bank: CART is RAM bank %i (write-enable=%i)\n", to8_cart_vpage, (to8_reg_cart & 0x40) ? 1 : 0 ));
35793579   }
35803580   else
35813581   {
3582      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, to8_cartridge_w );
3582      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x3fff, 0, 0, to8_cartridge_w );
35833583      if ( to8_soft_select )
35843584      {
35853585         /* internal software ROM space */
r3658r3659
35943594         if ( thom_cart_nb_banks )
35953595         {
35963596            bank = thom_cart_bank % thom_cart_nb_banks;
3597            memory_install_read8_handler(machine,  0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x0003, 0, 0, to8_cartridge_r );
3597            memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x0003, 0, 0, to8_cartridge_r );
35983598
35993599         }
36003600
r3658r3659
36053605
36063606   if ( mess_ram_size == 512*1024 || bank < 16 )
36073607   {
3608      memory_set_bank( THOM_CART_BANK, bank );
3608      memory_set_bank( machine, THOM_CART_BANK, bank );
36093609   }
36103610
36113611   old_bank = bank;
r3658r3659
36313631   else
36323632      thom_cart_bank = offset & 3;
36333633
3634   to8_update_cart_bank(machine);
3634   to8_update_cart_bank(space->machine);
36353635}
36363636
36373637
r3658r3659
36393639/* read signal to 0000-0003 generates a bank switch */
36403640READ8_HANDLER ( to8_cartridge_r )
36413641{
3642   UINT8* pos = memory_region( machine, "main" ) + 0x10000;
3642   UINT8* pos = memory_region( space->machine, "main" ) + 0x10000;
36433643   UINT8 data = pos[offset + (thom_cart_bank % thom_cart_nb_banks) * 0x4000];
36443644   thom_cart_bank = offset & 3;
3645   to8_update_cart_bank(machine);
3645   to8_update_cart_bank(space->machine);
36463646   return data;
36473647}
36483648
r3658r3659
36653665   to7_floppy_reset(machine);
36663666   if ( THOM_FLOPPY_INT )
36673667      thmfc_floppy_reset(machine);
3668   memory_configure_bank( THOM_FLOP_BANK, TO7_NB_FLOP_BANK, 2, mem + 0x30000, 0x2000 );
3668   memory_configure_bank( machine, THOM_FLOP_BANK, TO7_NB_FLOP_BANK, 2, mem + 0x30000, 0x2000 );
36693669}
36703670
36713671
r3658r3659
36743674{
36753675   if ( (to8_reg_sys1 & 0x80) && THOM_FLOPPY_EXT )
36763676      /* external controller */
3677      return to7_floppy_r( machine, offset );
3677      return to7_floppy_r( space, offset );
36783678   else if ( ! (to8_reg_sys1 & 0x80) && THOM_FLOPPY_INT )
36793679      /* internal controller */
3680      return thmfc_floppy_r( machine, offset );
3680      return thmfc_floppy_r( space, offset );
36813681   else
36823682      /* no controller */
36833683      return 0;
r3658r3659
36893689{
36903690   if ( (to8_reg_sys1 & 0x80) && THOM_FLOPPY_EXT )
36913691      /* external controller */
3692      to7_floppy_w( machine, offset, data );
3692      to7_floppy_w( space, offset, data );
36933693   else if ( ! (to8_reg_sys1 & 0x80) && THOM_FLOPPY_INT )
36943694      /* internal controller */
3695      thmfc_floppy_w( machine, offset, data );
3695      thmfc_floppy_w( space, offset, data );
36963696}
36973697
36983698
r3658r3659
37083708READ8_HANDLER ( to8_gatearray_r )
37093709{
37103710   struct thom_vsignal v = thom_get_vsignal();
3711   struct thom_vsignal l = thom_get_lightpen_vsignal( machine, TO8_LIGHTPEN_DECAL, to7_lightpen_step - 1, 6 );
3711   struct thom_vsignal l = thom_get_lightpen_vsignal( space->machine, TO8_LIGHTPEN_DECAL, to7_lightpen_step - 1, 6 );
37123712   int count, inil, init, lt3;
37133713   UINT8 res;
37143714   count = to7_lightpen ? l.count : v.count;
r3658r3659
37293729   case 1: /* ram register / lightpen register 2 */
37303730      if ( to7_lightpen )
37313731      {
3732         thom_firq_2( machine, 0 );
3732         thom_firq_2( space->machine, 0 );
37333733         to8_lightpen_intr = 0;
37343734         res = count & 0xff;
37353735      }
r3658r3659
37493749      break;
37503750
37513751   default:
3752      logerror( "$%04x to8_gatearray_r: invalid offset %i\n", activecpu_get_previouspc(), offset );
3752      logerror( "$%04x to8_gatearray_r: invalid offset %i\n", cpu_get_previouspc(space->cpu), offset );
37533753      res = 0;
37543754   }
37553755
37563756   LOG_VIDEO(( "$%04x %f to8_gatearray_r: off=%i ($%04X) res=$%02X lightpen=%i\n",
3757        activecpu_get_previouspc(), attotime_to_double(timer_get_time()),
3757        cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()),
37583758        offset, 0xe7e4 + offset, res, to7_lightpen ));
37593759
37603760   return res;
r3658r3659
37653765WRITE8_HANDLER ( to8_gatearray_w )
37663766{
37673767   LOG_VIDEO(( "$%04x %f to8_gatearray_w: off=%i ($%04X) data=$%02X\n",
3768        activecpu_get_previouspc(), attotime_to_double(timer_get_time()),
3768        cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()),
37693769        offset, 0xe7e4 + offset, data ));
37703770
37713771   switch ( offset )
r3658r3659
37793779      if ( to8_reg_sys1 & 0x10 )
37803780      {
37813781         to8_reg_ram = data;
3782         to8_update_ram_bank(machine);
3782         to8_update_ram_bank(space->machine);
37833783      }
37843784      break;
37853785
37863786   case 2: /* cartridge register */
37873787      to8_reg_cart = data;
3788      to8_update_cart_bank(machine);
3788      to8_update_cart_bank(space->machine);
37893789      break;
37903790
37913791   case 3: /* system register 1 */
37923792      to8_reg_sys1 = data;
3793      to8_update_floppy_bank();
3794      to8_update_ram_bank(machine);
3795      to8_update_cart_bank(machine);
3793      to8_update_floppy_bank(space->machine);
3794      to8_update_ram_bank(space->machine);
3795      to8_update_cart_bank(space->machine);
37963796      break;
37973797
37983798   default:
37993799      logerror( "$%04x to8_gatearray_w: invalid offset %i (data=$%02X)\n",
3800           activecpu_get_previouspc(), offset, data );
3800           cpu_get_previouspc(space->cpu), offset, data );
38013801   }
38023802}
38033803
r3658r3659
38133813   if ( ( offset == 3 ) && ( to8_reg_ram & 0x80 ) && ( to8_reg_sys1 & 0x80 ) )
38143814   {
38153815      if ( THOM_FLOPPY_EXT )
3816         return to7_floppy_r( machine, 0xc );
3816         return to7_floppy_r( space, 0xc );
38173817      else
38183818         return 0;
38193819   }
r3658r3659
38463846WRITE8_HANDLER ( to8_vreg_w )
38473847{
38483848   LOG_VIDEO(( "$%04x %f to8_vreg_w: off=%i ($%04X) data=$%02X\n",
3849        activecpu_get_previouspc(), attotime_to_double(timer_get_time()),
3849        cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()),
38503850        offset, 0xe7da + offset, data ));
38513851
38523852   switch ( offset )
r3658r3659
38773877      if ( ( offset == 3 ) && ( to8_reg_ram & 0x80 ) && ( to8_reg_sys1 & 0x80 ) )
38783878      {
38793879         if ( THOM_FLOPPY_EXT )
3880            to7_floppy_w( machine, 0xc, data );
3880            to7_floppy_w( space, 0xc, data );
38813881      }
38823882      else
38833883      {
r3658r3659
39003900
39013901static READ8_HANDLER ( to8_sys_porta_in )
39023902{
3903   int ktest = to8_kbd_ktest (machine);
3903   int ktest = to8_kbd_ktest (space->machine);
39043904
3905   LOG_KBD(( "$%04x %f: to8_sys_porta_in ktest=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), ktest ));
3905   LOG_KBD(( "$%04x %f: to8_sys_porta_in ktest=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), ktest ));
39063906
39073907   return ktest;
39083908}
r3658r3659
39113911
39123912static WRITE8_HANDLER ( to8_sys_portb_out )
39133913{
3914   to9_update_centronics(machine); /* bits 0-1: printer */
3915   to8_update_ram_bank(machine);
3914   to9_update_centronics(space->machine); /* bits 0-1: printer */
3915   to8_update_ram_bank(space->machine);
39163916
39173917   if ( data & 4 ) /* bit 2: video overlay (TODO) */
39183918      LOG(( "to8_sys_portb_out: video overlay not handled\n" ));
r3658r3659
39363936
39373937static READ8_HANDLER ( to8_timer_port_in )
39383938{
3939   int lightpen = (input_port_read(machine, "lightpen_button") & 1) ? 2 : 0;
3940   int cass = to7_get_cassette(machine) ? 0x80 : 0;
3939   int lightpen = (input_port_read(space->machine, "lightpen_button") & 1) ? 2 : 0;
3940   int cass = to7_get_cassette(space->machine) ? 0x80 : 0;
39413941   int dtr = (centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY) ? 0 : 0x40;
39423942   int lock = to8_kbd_caps ? 0 : 8; /* undocumented! */
39433943   return lightpen | cass | dtr | lock;
r3658r3659
39493949{
39503950   int ack = (data & 0x20) ? 1 : 0;       /* bit 5: keyboard ACK */
39513951   to8_bios_bank = (data & 0x10) ? 1 : 0; /* bit 4: BIOS bank*/
3952   thom_set_mode_point( data & 1 );       /* bit 0: video bank switch */
3953   memory_set_bank( TO8_BIOS_BANK, to8_bios_bank );
3952   thom_set_mode_point( space->machine, data & 1 );       /* bit 0: video bank switch */
3953   memory_set_bank( space->machine, TO8_BIOS_BANK, to8_bios_bank );
39543954   to8_soft_select = (data & 0x04) ? 1 : 0; /* bit 2: internal ROM select */
3955   to8_update_floppy_bank();
3956   to8_update_cart_bank(machine);
3955   to8_update_floppy_bank(space->machine);
3956   to8_update_cart_bank(space->machine);
39573957   to8_kbd_set_ack( ack );
39583958}
39593959
r3658r3659
40294029   thom_set_video_mode( THOM_VMODE_TO770 );
40304030   thom_set_lightpen_callback( 4, to8_lightpen_cb );
40314031   thom_set_border_color( 0 );
4032   thom_set_mode_point( 0 );
4032   thom_set_mode_point( machine, 0 );
40334033   pia_set_input_cb1( THOM_PIA_SYS, 0 );
40344034
40354035   /* memory */
r3658r3659
40394039   to8_bios_bank = 0;
40404040   to8_update_ram_bank(machine);
40414041   to8_update_cart_bank(machine);
4042   to8_update_floppy_bank();
4043   memory_set_bank( TO8_BIOS_BANK, 0 );
4042   to8_update_floppy_bank(machine);
4043   memory_set_bank( machine, TO8_BIOS_BANK, 0 );
40444044   /* thom_cart_bank not reset */
40454045}
40464046
r3658r3659
40694069   /* memory */
40704070   thom_cart_bank = 0;
40714071   thom_vram = mess_ram;
4072   memory_configure_bank( THOM_CART_BANK, 0,  8, mem + 0x10000, 0x4000 );
4073   memory_configure_bank( THOM_CART_BANK, 8, 32, mess_ram, 0x4000 );
4074   memory_configure_bank( THOM_VRAM_BANK, 0,  2, mess_ram, 0x2000 );
4075   memory_configure_bank( TO8_SYS_LO,     0,  1, mess_ram + 0x6000, 0x4000 );
4076   memory_configure_bank( TO8_SYS_HI,     0,  1, mess_ram + 0x4000, 0x4000 );
4077   memory_configure_bank( TO8_DATA_LO,    0, 32, mess_ram + 0x2000, 0x4000 );
4078   memory_configure_bank( TO8_DATA_HI,    0, 32, mess_ram + 0x0000, 0x4000 );
4079   memory_configure_bank( TO8_BIOS_BANK,  0,  2, mem + 0x30800, 0x2000 );
4080   memory_set_bank( THOM_CART_BANK, 0 );
4081   memory_set_bank( THOM_VRAM_BANK, 0 );
4082   memory_set_bank( TO8_SYS_LO,  0 );
4083   memory_set_bank( TO8_SYS_HI,  0 );
4084   memory_set_bank( TO8_DATA_LO, 0 );
4085   memory_set_bank( TO8_DATA_HI, 0 );
4086   memory_set_bank( TO8_BIOS_BANK, 0 );
4072   memory_configure_bank( machine, THOM_CART_BANK, 0,  8, mem + 0x10000, 0x4000 );
4073   memory_configure_bank( machine, THOM_CART_BANK, 8, 32, mess_ram, 0x4000 );
4074   memory_configure_bank( machine, THOM_VRAM_BANK, 0,  2, mess_ram, 0x2000 );
4075   memory_configure_bank( machine, TO8_SYS_LO,     0,  1, mess_ram + 0x6000, 0x4000 );
4076   memory_configure_bank( machine, TO8_SYS_HI,     0,  1, mess_ram + 0x4000, 0x4000 );
4077   memory_configure_bank( machine, TO8_DATA_LO,    0, 32, mess_ram + 0x2000, 0x4000 );
4078   memory_configure_bank( machine, TO8_DATA_HI,    0, 32, mess_ram + 0x0000, 0x4000 );
4079   memory_configure_bank( machine, TO8_BIOS_BANK,  0,  2, mem + 0x30800, 0x2000 );
4080   memory_set_bank( machine, THOM_CART_BANK, 0 );
4081   memory_set_bank( machine, THOM_VRAM_BANK, 0 );
4082   memory_set_bank( machine, TO8_SYS_LO,  0 );
4083   memory_set_bank( machine, TO8_SYS_HI,  0 );
4084   memory_set_bank( machine, TO8_DATA_LO, 0 );
4085   memory_set_bank( machine, TO8_DATA_HI, 0 );
4086   memory_set_bank( machine, TO8_BIOS_BANK, 0 );
40874087
40884088   /* save-state */
40894089   state_save_register_global( thom_cart_nb_banks );
r3658r3659
41324132
41334133static READ8_HANDLER ( to9p_timer_port_in )
41344134{
4135   int lightpen = (input_port_read(machine, "lightpen_button") & 1) ? 2 : 0;
4136   int cass = to7_get_cassette(machine) ? 0x80 : 0;
4135   int lightpen = (input_port_read(space->machine, "lightpen_button") & 1) ? 2 : 0;
4136   int cass = to7_get_cassette(space->machine) ? 0x80 : 0;
41374137   int dtr = (centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY) ? 0 : 0x40;
41384138   return lightpen | cass | dtr;
41394139}
r3658r3659
41434143static WRITE8_HANDLER ( to9p_timer_port_out )
41444144{
41454145   int bios_bank = (data & 0x10) ? 1 : 0; /* bit 4: BIOS bank */
4146   thom_set_mode_point( data & 1 );       /* bit 0: video bank switch */
4147   memory_set_bank( TO8_BIOS_BANK, bios_bank );
4146   thom_set_mode_point( space->machine, data & 1 );       /* bit 0: video bank switch */
4147   memory_set_bank( space->machine, TO8_BIOS_BANK, bios_bank );
41484148   to8_soft_select = (data & 0x04) ? 1 : 0; /* bit 2: internal ROM select */
4149   to8_update_floppy_bank();
4150   to8_update_cart_bank(machine);
4149   to8_update_floppy_bank(space->machine);
4150   to8_update_cart_bank(space->machine);
41514151}
41524152
41534153
r3658r3659
41964196   thom_set_video_mode( THOM_VMODE_TO770 );
41974197   thom_set_lightpen_callback( 4, to8_lightpen_cb );
41984198   thom_set_border_color( 0 );
4199   thom_set_mode_point( 0 );
4199   thom_set_mode_point( machine, 0 );
42004200   pia_set_input_cb1( THOM_PIA_SYS, 0 );
42014201
42024202   /* memory */
r3658r3659
42064206   to8_bios_bank = 0;
42074207   to8_update_ram_bank(machine);
42084208   to8_update_cart_bank(machine);
4209   to8_update_floppy_bank();
4210   memory_set_bank( TO8_BIOS_BANK, 0 );
4209   to8_update_floppy_bank(machine);
4210   memory_set_bank( machine, TO8_BIOS_BANK, 0 );
42114211   /* thom_cart_bank not reset */
42124212}
42134213
r3658r3659
42364236   /* memory */
42374237   thom_cart_bank = 0;
42384238   thom_vram = mess_ram;
4239   memory_configure_bank( THOM_CART_BANK, 0,  8, mem + 0x10000, 0x4000 );
4240   memory_configure_bank( THOM_CART_BANK, 8, 32, mess_ram, 0x4000 );
4241   memory_configure_bank( THOM_VRAM_BANK, 0,  2, mess_ram, 0x2000 );
4242   memory_configure_bank( TO8_SYS_LO,     0,  1, mess_ram + 0x6000, 0x4000 );
4243   memory_configure_bank( TO8_SYS_HI,     0,  1, mess_ram + 0x4000, 0x4000 );
4244   memory_configure_bank( TO8_DATA_LO,    0, 32, mess_ram + 0x2000, 0x4000 );
4245   memory_configure_bank( TO8_DATA_HI,    0, 32, mess_ram + 0x0000, 0x4000 );
4246   memory_configure_bank( TO8_BIOS_BANK,  0,  2, mem + 0x30800, 0x2000 );
4247   memory_set_bank( THOM_CART_BANK, 0 );
4248   memory_set_bank( THOM_VRAM_BANK, 0 );
4249   memory_set_bank( TO8_SYS_LO,  0 );
4250   memory_set_bank( TO8_SYS_HI,  0 );
4251   memory_set_bank( TO8_DATA_LO, 0 );
4252   memory_set_bank( TO8_DATA_HI, 0 );
4253   memory_set_bank( TO8_BIOS_BANK, 0 );
4239   memory_configure_bank( machine, THOM_CART_BANK, 0,  8, mem + 0x10000, 0x4000 );
4240   memory_configure_bank( machine, THOM_CART_BANK, 8, 32, mess_ram, 0x4000 );
4241   memory_configure_bank( machine, THOM_VRAM_BANK, 0,  2, mess_ram, 0x2000 );
4242   memory_configure_bank( machine, TO8_SYS_LO,     0,  1, mess_ram + 0x6000, 0x4000 );
4243   memory_configure_bank( machine, TO8_SYS_HI,     0,  1, mess_ram + 0x4000, 0x4000 );
4244   memory_configure_bank( machine, TO8_DATA_LO,    0, 32, mess_ram + 0x2000, 0x4000 );
4245   memory_configure_bank( machine, TO8_DATA_HI,    0, 32, mess_ram + 0x0000, 0x4000 );
4246   memory_configure_bank( machine, TO8_BIOS_BANK,  0,  2, mem + 0x30800, 0x2000 );
4247   memory_set_bank( machine, THOM_CART_BANK, 0 );
4248   memory_set_bank( machine, THOM_VRAM_BANK, 0 );
4249   memory_set_bank( machine, TO8_SYS_LO,  0 );
4250   memory_set_bank( machine, TO8_SYS_HI,  0 );
4251   memory_set_bank( machine, TO8_DATA_LO, 0 );
4252   memory_set_bank( machine, TO8_DATA_HI, 0 );
4253   memory_set_bank( machine, TO8_BIOS_BANK, 0 );
42544254
42554255   /* save-state */
42564256   state_save_register_global( thom_cart_nb_banks );
r3658r3659
42834283
42844284
42854285
4286static void mo6_update_ram_bank ( void )
4286static void mo6_update_ram_bank (running_machine *machine)
42874287{
42884288   UINT8 bank = 0;
42894289
r3658r3659
42944294         LOG_BANK(( "mo6_update_ram_bank: select bank %i (new style)\n", bank ));
42954295   }
42964296   to8_data_vpage = bank;
4297   memory_set_bank( TO8_DATA_LO, to8_data_vpage );
4298   memory_set_bank( TO8_DATA_HI, to8_data_vpage );
4297   memory_set_bank( machine, TO8_DATA_LO, to8_data_vpage );
4298   memory_set_bank( machine, TO8_DATA_HI, to8_data_vpage );
42994299}
43004300
43014301
43024302
43034303static STATE_POSTLOAD( mo6_update_ram_bank_postload )
43044304{
4305   mo6_update_ram_bank();
4305   mo6_update_ram_bank(machine);
43064306}
43074307
43084308
r3658r3659
43134313   static int old_bank = -1;
43144314   int bank = 0;
43154315
4316   memory_install_read8_handler(machine,  0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, (read8_machine_func)(STATIC_BANK1 + THOM_CART_BANK - 1) );
4316   memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) );
43174317
43184318   if ( ( ( to8_reg_sys1 & 0x40 ) && ( to8_reg_cart & 0x20 ) ) || ( ! ( to8_reg_sys1 & 0x40 ) && ( mo5_reg_cart & 4 ) ) )
43194319   {
r3658r3659
43234323         /* use a7e6 */
43244324         to8_cart_vpage = to8_reg_cart & 7; /* 128 KB RAM only = 8 pages */
43254325         bank = 8 + to8_cart_vpage;
4326         memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0,
4326         memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0,
43274327                         (to8_reg_cart & 0x40) ? (to8_cart_vpage <= 4) ? to8_vcart_w :
4328                         (write8_machine_func)(STATIC_BANK1 + THOM_CART_BANK - 1) : SMH_NOP );
4328                         (write8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) : SMH_NOP );
43294329         if ( bank != old_bank )
43304330            LOG_BANK(( "mo6_update_cart_bank: CART is RAM bank %i (write-enable=%i)\n", to8_cart_vpage, (to8_reg_cart & 0x40) ? 1 : 0 ));
43314331      }
43324332      else if ( thom_cart_nb_banks == 4 )
43334333      {
43344334         /* "JANE"-style cartridge bank switching */
4335         memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, SMH_NOP );
4335         memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, SMH_NOP );
43364336         bank = mo5_reg_cart & 3;
43374337         if ( bank != old_bank )
43384338            LOG_BANK(( "mo6_update_cart_bank: CART is external cartridge bank %i (A7CB style)\n", bank ));
r3658r3659
43434343         int write_enable = mo5_reg_cart & 8;
43444344         to8_cart_vpage = (mo5_reg_cart & 3) | 4;
43454345         bank = 8 + to8_cart_vpage;
4346         memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, write_enable ?
4347                         (write8_machine_func)(STATIC_BANK1 + THOM_CART_BANK - 1) :  SMH_NOP );
4346         memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, write_enable ?
4347                         (write8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) :  SMH_NOP );
43484348         if ( bank != old_bank )
43494349            LOG_BANK(( "mo6_update_cart_bank: CART is RAM bank %i (write-enable=%i) (MO5 compat.)\n", to8_cart_vpage, write_enable ? 1 : 0 ));
43504350      }
r3658r3659
43524352   else
43534353   {
43544354      /* ROM space */
4355      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, SMH_NOP );
4355      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, SMH_NOP );
43564356      if ( to8_reg_sys2 & 0x20 )
43574357      {
43584358         /* internal ROM */
r3658r3659
43664366      else
43674367      {
43684368         /* cartridge */
4369         memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb000, 0xefff, 0, 0, mo6_cartridge_w );
4369         memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, mo6_cartridge_w );
43704370         if ( thom_cart_nb_banks )
43714371         {
43724372            bank = thom_cart_bank % thom_cart_nb_banks;
4373            memory_install_read8_handler(machine,  0, ADDRESS_SPACE_PROGRAM, 0xbffc, 0xbfff, 0, 0, mo6_cartridge_r );
4373            memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xbffc, 0xbfff, 0, 0, mo6_cartridge_r );
43744374         }
43754375         if ( bank != old_bank )
43764376            LOG_BANK(( "mo6_update_cart_bank: CART is external cartridge bank %i\n", bank ));
r3658r3659
43784378   }
43794379
43804380   old_bank = bank;
4381   memory_set_bank( THOM_CART_BANK, bank );
4382   memory_set_bank( TO8_BIOS_BANK, b );
4381   memory_set_bank( machine, THOM_CART_BANK, bank );
4382   memory_set_bank( machine, TO8_BIOS_BANK, b );
43834383}
43844384
43854385
r3658r3659
43984398      return;
43994399
44004400   thom_cart_bank = offset & 3;
4401   mo6_update_cart_bank(machine);
4401   mo6_update_cart_bank(space->machine);
44024402}
44034403
44044404
r3658r3659
44064406/* read signal generates a bank switch */
44074407READ8_HANDLER ( mo6_cartridge_r )
44084408{
4409   UINT8* pos = memory_region( machine, "main" ) + 0x10000;
4409   UINT8* pos = memory_region( space->machine, "main" ) + 0x10000;
44104410   UINT8 data = pos[offset + 0xbffc + (thom_cart_bank % thom_cart_nb_banks) * 0x4000];
44114411   thom_cart_bank = offset & 3;
4412   mo6_update_cart_bank(machine);
4412   mo6_update_cart_bank(space->machine);
44134413   return data;
44144414}
44154415
r3658r3659
44194419{
44204420   /* MO5 network extension compatible */
44214421   mo5_reg_cart = data;
4422   mo6_update_cart_bank(machine);
4422   mo6_update_cart_bank(space->machine);
44234423}
44244424
44254425
r3658r3659
44334433static WRITE8_HANDLER ( mo6_game_porta_out )
44344434{
44354435   /* centronics data */
4436   LOG (( "$%04x %f mo6_game_porta_out: CENTRONICS set data=$%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ));
4436   LOG (( "$%04x %f mo6_game_porta_out: CENTRONICS set data=$%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data ));
44374437   centronics_write_data( 0, data );
44384438}
44394439
r3658r3659
44434443{
44444444   int dtr = ( centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY ) ? 0 : 1;
44454445   /* note: printer busy signal replaces button */
4446   LOG (( "$%04x %f mo6_game_cb1_in: CENTRONICS get dtr=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), dtr ));
4446   LOG (( "$%04x %f mo6_game_cb1_in: CENTRONICS get dtr=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), dtr ));
44474447   return dtr;
44484448}
44494449
r3658r3659
44524452static WRITE8_HANDLER ( mo6_game_cb2_out )
44534453{
44544454   /* centronics strobe */
4455   LOG (( "$%04x %f mo6_game_cb2_out: CENTRONICS set strobe=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ));
4455   LOG (( "$%04x %f mo6_game_cb2_out: CENTRONICS set strobe=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data ));
44564456   centronics_write_handshake( 0, data ? CENTRONICS_STROBE : 0,
44574457                CENTRONICS_STROBE );
44584458}
r3658r3659
45194519static READ8_HANDLER ( mo6_sys_porta_in )
45204520{
45214521   return
4522      (mo5_get_cassette(machine) ? 0x80 : 0) |     /* bit 7: cassette input */
4522      (mo5_get_cassette(space->machine) ? 0x80 : 0) |     /* bit 7: cassette input */
45234523      8 |                                   /* bit 3: kbd-line float up to 1 */
4524      ((input_port_read(machine, "lightpen_button") & 1) ? 2 : 0);
4524      ((input_port_read(space->machine, "lightpen_button") & 1) ? 2 : 0);
45254525   /* bit 1: lightpen button */;
45264526}
45274527
r3658r3659
45414541      lin = 8;     /* A bit 3: 9-th kbd line select */
45424542
45434543   return
4544      ( input_port_read(machine, keynames[lin]) & (1 << col) ) ?  0x80 : 0;
4544      ( input_port_read(space->machine, keynames[lin]) & (1 << col) ) ?  0x80 : 0;
45454545   /* bit 7: key up */
45464546}
45474547
r3658r3659
45494549
45504550static WRITE8_HANDLER ( mo6_sys_porta_out )
45514551{
4552   thom_set_mode_point( data & 1 );                  /* bit 0: video bank switch */
4552   thom_set_mode_point( space->machine, data & 1 );                  /* bit 0: video bank switch */
45534553   to7_game_mute = data & 4;                        /* bit 2: sound mute */
45544554   thom_set_caps_led( (data & 16) ? 0 : 1 ) ;            /* bit 4: keyboard led */
4555   mo5_set_cassette( machine, (data & 0x40) ? 1 : 0 );      /* bit 6: cassette output */
4556   mo6_update_cart_bank(machine);                     /* bit 5: rom bank */
4555   mo5_set_cassette( space->machine, (data & 0x40) ? 1 : 0 );      /* bit 6: cassette output */
4556   mo6_update_cart_bank(space->machine);                     /* bit 5: rom bank */
45574557   to7_game_sound_update();
45584558}
45594559
r3658r3659
45934593READ8_HANDLER ( mo6_gatearray_r )
45944594{
45954595   struct thom_vsignal v = thom_get_vsignal();
4596   struct thom_vsignal l = thom_get_lightpen_vsignal( machine, MO6_LIGHTPEN_DECAL, to7_lightpen_step - 1, 6 );
4596   struct thom_vsignal l = thom_get_lightpen_vsignal( space->machine, MO6_LIGHTPEN_DECAL, to7_lightpen_step - 1, 6 );
45974597   int count, inil, init, lt3;
45984598   UINT8 res;
45994599   count = to7_lightpen ? l.count : v.count;
r3658r3659
46144614   case 1: /* ram register / lightpen register 2 */
46154615      if ( to7_lightpen )
46164616      {
4617         thom_firq_2( machine, 0 );
4617         thom_firq_2( space->machine, 0 );
46184618         to8_lightpen_intr = 0;
46194619         res =  count & 0xff;
46204620      }
r3658r3659
46344634      break;
46354635
46364636   default:
4637      logerror( "$%04x mo6_gatearray_r: invalid offset %i\n", activecpu_get_previouspc(), offset );
4637      logerror( "$%04x mo6_gatearray_r: invalid offset %i\n", cpu_get_previouspc(space->cpu), offset );
46384638      res = 0;
46394639   }
46404640
46414641   LOG_VIDEO(( "$%04x %f mo6_gatearray_r: off=%i ($%04X) res=$%02X lightpen=%i\n",
4642        activecpu_get_previouspc(), attotime_to_double(timer_get_time()),
4642        cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()),
46434643        offset, 0xa7e4 + offset, res, to7_lightpen ));
46444644
46454645   return res;
r3658r3659
46504650WRITE8_HANDLER ( mo6_gatearray_w )
46514651{
46524652   LOG_VIDEO(( "$%04x %f mo6_gatearray_w: off=%i ($%04X) data=$%02X\n",
4653        activecpu_get_previouspc(), attotime_to_double(timer_get_time()),
4653        cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()),
46544654        offset, 0xa7e4 + offset, data ));
46554655
46564656   switch ( offset )
r3658r3659
46644664      if ( to8_reg_sys1 & 0x10 )
46654665      {
46664666         to8_reg_ram = data;
4667         mo6_update_ram_bank();
4667         mo6_update_ram_bank(space->machine);
46684668      }
46694669      break;
46704670
46714671   case 2: /* cartridge register */
46724672      to8_reg_cart = data;
4673      mo6_update_cart_bank(machine);
4673      mo6_update_cart_bank(space->machine);
46744674      break;
46754675
46764676   case 3: /* system register 1 */
46774677      to8_reg_sys1 = data;
4678      mo6_update_ram_bank();
4679      mo6_update_cart_bank(machine);
4678      mo6_update_ram_bank(space->machine);
4679      mo6_update_cart_bank(space->machine);
46804680      break;
46814681
46824682   default:
4683      logerror( "$%04x mo6_gatearray_w: invalid offset %i (data=$%02X)\n", activecpu_get_previouspc(), offset, data );
4683      logerror( "$%04x mo6_gatearray_w: invalid offset %i (data=$%02X)\n", cpu_get_previouspc(space->cpu), offset, data );
46844684   }
46854685}
46864686
r3658r3659
46934693{
46944694   /* 0xa7dc from external floppy drive aliases the video gate-array */
46954695   if ( ( offset == 3 ) && ( to8_reg_ram & 0x80 ) )
4696      return to7_floppy_r( machine, 0xc );
4696      return to7_floppy_r( space, 0xc );
46974697
46984698   switch ( offset )
46994699   {
47004700
47014701   case 0: /* palette data */
47024702   case 1: /* palette address */
4703      return to8_vreg_r( machine, offset );
4703      return to8_vreg_r( space, offset );
47044704
47054705   case 2:
47064706   case 3:
r3658r3659
47174717WRITE8_HANDLER ( mo6_vreg_w )
47184718{
47194719   LOG_VIDEO(( "$%04x %f mo6_vreg_w: off=%i ($%04X) data=$%02X\n",
4720        activecpu_get_previouspc(), attotime_to_double(timer_get_time()),
4720        cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()),
47214721        offset, 0xa7da + offset, data ));
47224722
47234723   switch ( offset )
r3658r3659
47254725
47264726   case 0: /* palette data */
47274727   case 1: /* palette address */
4728      to8_vreg_w( machine, offset, data );
4728      to8_vreg_w( space, offset, data );
47294729      return;
47304730
47314731   case 2: /* display / external floppy register */
47324732      if ( ( to8_reg_sys1 & 0x80 ) && ( to8_reg_ram & 0x80 ) )
4733         to7_floppy_w( machine, 0xc, data );
4733         to7_floppy_w( space, 0xc, data );
47344734      else
47354735         to9_set_video_mode( data, 2 );
47364736      break;
r3658r3659
47384738   case 3: /* system register 2 */
47394739      /* 0xa7dc from external floppy drive aliases the video gate-array */
47404740      if ( ( offset == 3 ) && ( to8_reg_ram & 0x80 ) )
4741         to7_floppy_w( machine, 0xc, data );
4741         to7_floppy_w( space, 0xc, data );
47424742      else
47434743      {
47444744         to8_reg_sys2 = data;
47454745         thom_set_video_page( data >> 6 );
47464746         thom_set_border_color( data & 15 );
4747         mo6_update_cart_bank(machine);
4747         mo6_update_cart_bank(space->machine);
47484748      }
47494749      break;
47504750
r3658r3659
47884788   thom_set_video_mode( THOM_VMODE_MO5 );
47894789   thom_set_lightpen_callback( 3, to8_lightpen_cb );
47904790   thom_set_border_color( 0 );
4791   thom_set_mode_point( 0 );
4791   thom_set_mode_point( machine, 0 );
47924792   pia_set_input_ca1( THOM_PIA_SYS, 0 );
47934793
47944794   /* memory */
47954795   to8_cart_vpage = 0;
47964796   to8_data_vpage = 0;
4797   mo6_update_ram_bank();
4797   mo6_update_ram_bank(machine);
47984798   mo6_update_cart_bank(machine);
47994799   /* mo5_reg_cart not reset */
48004800   /* thom_cart_bank not reset */
r3658r3659
48254825   thom_cart_bank = 0;
48264826   mo5_reg_cart = 0;
48274827   thom_vram = mess_ram;
4828   memory_configure_bank( THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 );
4829   memory_configure_bank( THOM_CART_BANK, 4, 2, mem + 0x1f000, 0x4000 );
4830   memory_configure_bank( THOM_CART_BANK, 6, 2, mem + 0x28000, 0x4000 );
4831   memory_configure_bank( THOM_CART_BANK, 8, 8, mess_ram, 0x4000 );
4832   memory_configure_bank( THOM_VRAM_BANK, 0, 2, mess_ram, 0x2000 );
4833   memory_configure_bank( TO8_SYS_LO,     0, 1, mess_ram + 0x6000, 0x4000 );
4834   memory_configure_bank( TO8_SYS_HI,     0, 1, mess_ram + 0x4000, 0x4000 );
4835   memory_configure_bank( TO8_DATA_LO,    0, 8, mess_ram + 0x2000, 0x4000 );
4836   memory_configure_bank( TO8_DATA_HI,    0, 8, mess_ram + 0x0000, 0x4000 );
4837   memory_configure_bank( TO8_BIOS_BANK,  0, 2, mem + 0x23000, 0x4000 );
4838   memory_set_bank( THOM_CART_BANK, 0 );
4839   memory_set_bank( THOM_VRAM_BANK, 0 );
4840   memory_set_bank( TO8_SYS_LO,  0 );
4841   memory_set_bank( TO8_SYS_HI,  0 );
4842   memory_set_bank( TO8_DATA_LO, 0 );
4843   memory_set_bank( TO8_DATA_HI, 0 );
4844   memory_set_bank( TO8_BIOS_BANK, 0 );
4828   memory_configure_bank( machine, THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 );
4829   memory_configure_bank( machine, THOM_CART_BANK, 4, 2, mem + 0x1f000, 0x4000 );
4830   memory_configure_bank( machine, THOM_CART_BANK, 6, 2, mem + 0x28000, 0x4000 );
4831   memory_configure_bank( machine, THOM_CART_BANK, 8, 8, mess_ram, 0x4000 );
4832   memory_configure_bank( machine, THOM_VRAM_BANK, 0, 2, mess_ram, 0x2000 );
4833   memory_configure_bank( machine, TO8_SYS_LO,     0, 1, mess_ram + 0x6000, 0x4000 );
4834   memory_configure_bank( machine, TO8_SYS_HI,     0, 1, mess_ram + 0x4000, 0x4000 );
4835   memory_configure_bank( machine, TO8_DATA_LO,    0, 8, mess_ram + 0x2000, 0x4000 );
4836   memory_configure_bank( machine, TO8_DATA_HI,    0, 8, mess_ram + 0x0000, 0x4000 );
4837   memory_configure_bank( machine, TO8_BIOS_BANK,  0, 2, mem + 0x23000, 0x4000 );
4838   memory_set_bank( machine, THOM_CART_BANK, 0 );
4839   memory_set_bank( machine, THOM_VRAM_BANK, 0 );
4840   memory_set_bank( machine, TO8_SYS_LO,  0 );
4841   memory_set_bank( machine, TO8_SYS_HI,  0 );
4842   memory_set_bank( machine, TO8_DATA_LO, 0 );
4843   memory_set_bank( machine, TO8_DATA_HI, 0 );
4844   memory_set_bank( machine, TO8_BIOS_BANK, 0 );
48454845
48464846   /* save-state */
48474847   state_save_register_global( thom_cart_nb_banks );
r3658r3659
48744874READ8_HANDLER ( mo5nr_net_r )
48754875{
48764876   if ( to7_controller_type )
4877      return to7_floppy_r ( machine, offset );
4877      return to7_floppy_r ( space, offset );
48784878
4879   logerror( "$%04x %f mo5nr_net_r: read from reg %i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), offset );
4879   logerror( "$%04x %f mo5nr_net_r: read from reg %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), offset );
48804880
48814881   if ( to7_controller_type )
4882      return to7_floppy_r ( machine, offset );
4882      return to7_floppy_r ( space, offset );
48834883
48844884   return 0;
48854885}
r3658r3659
48894889WRITE8_HANDLER ( mo5nr_net_w )
48904890{
48914891   if ( to7_controller_type )
4892      to7_floppy_w ( machine, offset, data );
4892      to7_floppy_w ( space, offset, data );
48934893   else
48944894      logerror( "$%04x %f mo5nr_net_w: write $%02X to reg %i\n",
4895           activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data, offset );
4895           cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data, offset );
48964896}
48974897
48984898
r3658r3659
49204920         return 0x80;
49214921
49224922   default:
4923      logerror( "$%04x %f mo5nr_prn_r: unhandled read from reg %i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), offset );
4923      logerror( "$%04x %f mo5nr_prn_r: unhandled read from reg %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), offset );
49244924      return 0;
49254925   }
49264926}
r3658r3659
49424942      break;
49434943
49444944   default:
4945      logerror( "$%04x %f mo5nr_prn_w: unhandled to reg %i (data=$%02X)\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), offset, data );
4945      logerror( "$%04x %f mo5nr_prn_w: unhandled to reg %i (data=$%02X)\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), offset, data );
49464946   }
49474947}
49484948
r3658r3659
49614961   static const char *keynames[] = { "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3",
49624962                              "keyboard_4", "keyboard_5", "keyboard_6", "keyboard_7" };
49634963   
4964   return ( input_port_read(machine, keynames[lin]) & (1 << col) ) ? 0x80 : 0;
4964   return ( input_port_read(space->machine, keynames[lin]) & (1 << col) ) ? 0x80 : 0;
49654965   /* bit 7: key up */
49664966}
49674967
r3658r3659
49704970static WRITE8_HANDLER ( mo5nr_sys_porta_out )
49714971{
49724972   /* no keyboard LED */
4973   thom_set_mode_point( data & 1 );                  /* bit 0: video bank switch */
4973   thom_set_mode_point( space->machine, data & 1 );                  /* bit 0: video bank switch */
49744974   to7_game_mute = data & 4;                        /* bit 2: sound mute */
4975   mo5_set_cassette( machine, (data & 0x40) ? 1 : 0 );      /* bit 6: cassette output */
4976   mo6_update_cart_bank(machine);                     /* bit 5: rom bank */
4975   mo5_set_cassette( space->machine, (data & 0x40) ? 1 : 0 );      /* bit 6: cassette output */
4976   mo6_update_cart_bank(space->machine);                     /* bit 5: rom bank */
49774977   to7_game_sound_update();
49784978}
49794979
r3658r3659
50625062   thom_set_video_mode( THOM_VMODE_MO5 );
50635063   thom_set_lightpen_callback( 3, to8_lightpen_cb );
50645064   thom_set_border_color( 0 );
5065   thom_set_mode_point( 0 );
5065   thom_set_mode_point( machine, 0 );
50665066   pia_set_input_ca1( THOM_PIA_SYS, 0 );
50675067
50685068   /* memory */
50695069   to8_cart_vpage = 0;
50705070   to8_data_vpage = 0;
5071   mo6_update_ram_bank();
5071   mo6_update_ram_bank(machine);
50725072   mo6_update_cart_bank(machine);
50735073   /* mo5_reg_cart not reset */
50745074   /* thom_cart_bank not reset */
r3658r3659
50995099   thom_cart_bank = 0;
51005100   mo5_reg_cart = 0;
51015101   thom_vram = mess_ram;
5102   memory_configure_bank( THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 );
5103   memory_configure_bank( THOM_CART_BANK, 4, 2, mem + 0x1f000, 0x4000 );
5104   memory_configure_bank( THOM_CART_BANK, 6, 2, mem + 0x28000, 0x4000 );
5105   memory_configure_bank( THOM_CART_BANK, 8, 8, mess_ram, 0x4000 );
5106   memory_configure_bank( THOM_VRAM_BANK, 0, 2, mess_ram, 0x2000 );
5107   memory_configure_bank( TO8_SYS_LO,     0, 1, mess_ram + 0x6000, 0x4000 );
5108   memory_configure_bank( TO8_SYS_HI,     0, 1, mess_ram + 0x4000, 0x4000 );
5109   memory_configure_bank( TO8_DATA_LO,    0, 8, mess_ram + 0x2000, 0x4000 );
5110   memory_configure_bank( TO8_DATA_HI,    0, 8, mess_ram + 0x0000, 0x4000 );
5111   memory_configure_bank( TO8_BIOS_BANK,  0, 2, mem + 0x23000, 0x4000 );
5112   memory_set_bank( THOM_CART_BANK, 0 );
5113   memory_set_bank( THOM_VRAM_BANK, 0 );
5114   memory_set_bank( TO8_SYS_LO,  0 );
5115   memory_set_bank( TO8_SYS_HI,  0 );
5116   memory_set_bank( TO8_DATA_LO, 0 );
5117   memory_set_bank( TO8_DATA_HI, 0 );
5118   memory_set_bank( TO8_BIOS_BANK, 0 );
5102   memory_configure_bank( machine, THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 );
5103   memory_configure_bank( machine, THOM_CART_BANK, 4, 2, mem + 0x1f000, 0x4000 );
5104   memory_configure_bank( machine, THOM_CART_BANK, 6, 2, mem + 0x28000, 0x4000 );
5105   memory_configure_bank( machine, THOM_CART_BANK, 8, 8, mess_ram, 0x4000 );
5106   memory_configure_bank( machine, THOM_VRAM_BANK, 0, 2, mess_ram, 0x2000 );
5107   memory_configure_bank( machine, TO8_SYS_LO,     0, 1, mess_ram + 0x6000, 0x4000 );
5108   memory_configure_bank( machine, TO8_SYS_HI,     0, 1, mess_ram + 0x4000, 0x4000 );
5109   memory_configure_bank( machine, TO8_DATA_LO,    0, 8, mess_ram + 0x2000, 0x4000 );
5110   memory_configure_bank( machine, TO8_DATA_HI,    0, 8, mess_ram + 0x0000, 0x4000 );
5111   memory_configure_bank( machine, TO8_BIOS_BANK,  0, 2, mem + 0x23000, 0x4000 );
5112   memory_set_bank( machine, THOM_CART_BANK, 0 );
5113   memory_set_bank( machine, THOM_VRAM_BANK, 0 );
5114   memory_set_bank( machine, TO8_SYS_LO,  0 );
5115   memory_set_bank( machine, TO8_SYS_HI,  0 );
5116   memory_set_bank( machine, TO8_DATA_LO, 0 );
5117   memory_set_bank( machine, TO8_DATA_HI, 0 );
5118   memory_set_bank( machine, TO8_BIOS_BANK, 0 );
51195119
51205120   /* save-state */
51215121   state_save_register_global( thom_cart_nb_banks );
src/mess/machine/mc6846.c
r3658r3659
6767
6868#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
6969
70#define PORT                        \
70#define PORT_SPACE                        \
7171   ((mc6846.pdr & mc6846.ddr) |               \
72    ((mc6846.iface->in_port_func ? mc6846.iface->in_port_func(machine, 0) : 0) & \
72    ((mc6846.iface->in_port_func ? mc6846.iface->in_port_func(space, 0) : 0) & \
7373     ~mc6846.ddr))
7474
75#define PORT_MACHINE                        \
76   ((mc6846.pdr & mc6846.ddr) |               \
77    ((mc6846.iface->in_port_func ? mc6846.iface->in_port_func(cputag_get_address_space(machine,"main",ADDRESS_SPACE_PROGRAM), 0) : 0) & \
78     ~mc6846.ddr))
79
7580#define CTO                        \
7681   ((MODE == 0x30 || (mc6846.tcr & 0x80)) ? mc6846.cto : 0)
7782
r3658r3659
136141      old_cto = cto;
137142   }
138143   if ( mc6846.iface->out_cto_func )
139      mc6846.iface->out_cto_func( machine, 0, cto );
144      mc6846.iface->out_cto_func( cputag_get_address_space(machine,"main",ADDRESS_SPACE_PROGRAM), 0, cto );
140145}
141146
142147
r3658r3659
251256   case 0:
252257   case 4:
253258      LOG (( "$%04x %f: mc6846 CSR read $%02X intr=%i (timer=%i, cp1=%i, cp2=%i)\n",
254             activecpu_get_previouspc(), attotime_to_double(timer_get_time()),
259             cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()),
255260             mc6846.csr, (mc6846.csr >> 7) & 1,
256261             mc6846.csr & 1, (mc6846.csr >> 1) & 1, (mc6846.csr >> 2) & 1 ));
257262      mc6846.csr0_to_be_cleared = mc6846.csr & 1;
r3658r3659
260265      return mc6846.csr;
261266
262267   case 1:
263      LOG (( "$%04x %f: mc6846 PCR read $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), mc6846.pcr ));
268      LOG (( "$%04x %f: mc6846 PCR read $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), mc6846.pcr ));
264269      return mc6846.pcr;
265270
266271   case 2:
267      LOG (( "$%04x %f: mc6846 DDR read $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), mc6846.ddr ));
272      LOG (( "$%04x %f: mc6846 DDR read $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), mc6846.ddr ));
268273      return mc6846.ddr;
269274
270275   case 3:
271      LOG (( "$%04x %f: mc6846 PORT read $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), PORT ));
276      LOG (( "$%04x %f: mc6846 PORT read $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), PORT_SPACE ));
272277      if ( ! (mc6846.pcr & 0x80) )
273278      {
274279         if ( mc6846.csr1_to_be_cleared )
275280            mc6846.csr &= ~2;
276281         if ( mc6846.csr2_to_be_cleared )
277282            mc6846.csr &= ~4;
278         mc6846_update_irq(machine);
283         mc6846_update_irq(space->machine);
279284         mc6846.csr1_to_be_cleared = 0;
280285         mc6846.csr2_to_be_cleared = 0;
281286      }
282      return PORT;
287      return PORT_SPACE;
283288
284289   case 5:
285      LOG (( "$%04x %f: mc6846 TCR read $%02X\n",activecpu_get_previouspc(), attotime_to_double(timer_get_time()), mc6846.tcr ));
290      LOG (( "$%04x %f: mc6846 TCR read $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), mc6846.tcr ));
286291      return mc6846.tcr;
287292
288293   case 6:
289      LOG (( "$%04x %f: mc6846 COUNTER hi read $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), mc6846_counter() >> 8 ));
294      LOG (( "$%04x %f: mc6846 COUNTER hi read $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), mc6846_counter() >> 8 ));
290295      if ( mc6846.csr0_to_be_cleared )
291296      {
292297         mc6846.csr &= ~1;
293         mc6846_update_irq(machine);
298         mc6846_update_irq(space->machine);
294299      }
295300      mc6846.csr0_to_be_cleared = 0;
296301      return mc6846_counter() >> 8;
297302
298303   case 7:
299      LOG (( "$%04x %f: mc6846 COUNTER low read $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), mc6846_counter() & 0xff ));
304      LOG (( "$%04x %f: mc6846 COUNTER low read $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), mc6846_counter() & 0xff ));
300305      if ( mc6846.csr0_to_be_cleared )
301306      {
302307         mc6846.csr &= ~1;
303         mc6846_update_irq(machine);
308         mc6846_update_irq(space->machine);
304309      }
305310      mc6846.csr0_to_be_cleared = 0;
306311      return mc6846_counter() & 0xff;
307312
308313   default:
309      logerror( "$%04x mc6846 invalid read offset %i\n", activecpu_get_previouspc(), offset );
314      logerror( "$%04x mc6846 invalid read offset %i\n", cpu_get_previouspc(space->cpu), offset );
310315   }
311316   return 0;
312317}
r3658r3659
335340         "latcged,pos-edge", "latcged,pos-edge,intr"
336341      };
337342      LOG (( "$%04x %f: mc6846 PCR write $%02X reset=%i cp2=%s cp1=%s\n",
338             activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data,
343             cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data,
339344             (data >> 7) & 1, cp2[ (data >> 3) & 7 ], cp1[ data & 7 ] ));
340345
341346   }
r3658r3659
345350      mc6846.pdr = 0;
346351      mc6846.ddr = 0;
347352      mc6846.csr &= ~6;
348      mc6846_update_irq(machine);
353      mc6846_update_irq(space->machine);
349354   }
350355   if ( data & 4 )
351      logerror( "$%04x mc6846 CP1 latching not implemented\n", activecpu_get_previouspc() );
356      logerror( "$%04x mc6846 CP1 latching not implemented\n", cpu_get_previouspc(space->cpu) );
352357   if (data & 0x20)
353358   {
354359      if (data & 0x10)
355360      {
356361         mc6846.cp2_cpu = (data >> 3) & 1;
357362         if ( mc6846.iface->out_cp2_func )
358            mc6846.iface->out_cp2_func( machine, 0, mc6846.cp2_cpu );
363            mc6846.iface->out_cp2_func( space, 0, mc6846.cp2_cpu );
359364      }
360365      else
361         logerror( "$%04x mc6846 acknowledge not implemented\n", activecpu_get_previouspc() );
366         logerror( "$%04x mc6846 acknowledge not implemented\n", cpu_get_previouspc(space->cpu) );
362367   }
363368   break;
364369
365370   case 2:
366      LOG (( "$%04x %f: mc6846 DDR write $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ));
371      LOG (( "$%04x %f: mc6846 DDR write $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data ));
367372      if ( ! (mc6846.pcr & 0x80) )
368373      {
369374         mc6846.ddr = data;
370375         if ( mc6846.iface->out_port_func )
371            mc6846.iface->out_port_func( machine, 0, mc6846.pdr & mc6846.ddr );
376            mc6846.iface->out_port_func( space, 0, mc6846.pdr & mc6846.ddr );
372377      }
373378      break;
374379
375380   case 3:
376      LOG (( "$%04x %f: mc6846 PORT write $%02X (mask=$%02X)\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data,mc6846.ddr ));
381      LOG (( "$%04x %f: mc6846 PORT write $%02X (mask=$%02X)\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data,mc6846.ddr ));
377382      if ( ! (mc6846.pcr & 0x80) )
378383      {
379384         mc6846.pdr = data;
380385         if ( mc6846.iface->out_port_func )
381            mc6846.iface->out_port_func( machine, 0, mc6846.pdr & mc6846.ddr );
386            mc6846.iface->out_port_func( space, 0, mc6846.pdr & mc6846.ddr );
382387         if ( mc6846.csr1_to_be_cleared && (mc6846.csr & 2) )
383388         {
384389            mc6846.csr &= ~2;
385            LOG (( "$%04x %f: mc6846 CP1 intr reset\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()) ));
390            LOG (( "$%04x %f: mc6846 CP1 intr reset\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()) ));
386391         }
387392         if ( mc6846.csr2_to_be_cleared && (mc6846.csr & 4) )
388393         {
389394            mc6846.csr &= ~4;
390            LOG (( "$%04x %f: mc6846 CP2 intr reset\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()) ));
395            LOG (( "$%04x %f: mc6846 CP2 intr reset\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()) ));
391396         }
392397         mc6846.csr1_to_be_cleared = 0;
393398         mc6846.csr2_to_be_cleared = 0;
394         mc6846_update_irq(machine);
399         mc6846_update_irq(space->machine);
395400      }
396401      break;
397402
r3658r3659
403408            "freq-cmp", "freq-cmp", "pulse-cmp", "pulse-cmp"
404409         };
405410      LOG (( "$%04x %f: mc6846 TCR write $%02X reset=%i clock=%s scale=%i mode=%s out=%s\n",
406             activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data,
411             cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), data,
407412             (data >> 7) & 1, (data & 0x40) ? "extern" : "sys",
408413             (data & 0x40) ? 1 : 8, mode[ (data >> 1) & 7 ],
409414             (data & 1) ? "enabled" : "0" ));
r3658r3659
416421         mc6846.csr &= ~1;
417422         if ( MODE != 0x30 )
418423            mc6846.cto = 0;
419         mc6846_update_cto(machine);
424         mc6846_update_cto(space->machine);
420425         timer_reset( mc6846.interval, attotime_never );
421426         timer_reset( mc6846.one_shot, attotime_never );
422427         mc6846.timer_started = 0;
r3658r3659
425430      {
426431         /* timer launch */
427432         if ( ! mc6846.timer_started )
428            mc6846_timer_launch(machine);
433            mc6846_timer_launch(space->machine);
429434      }
430      mc6846_update_irq(machine);
435      mc6846_update_irq(space->machine);
431436   }
432437   break;
433438
r3658r3659
437442
438443   case 7:
439444      mc6846.latch = ( ((UINT16) mc6846.time_MSB) << 8 ) + data;
440      LOG (( "$%04x %f: mc6846 COUNT write %i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), mc6846.latch  ));
445      LOG (( "$%04x %f: mc6846 COUNT write %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time()), mc6846.latch  ));
441446      if (!(mc6846.tcr & 0x38))
442447      {
443448         /* timer initialization */
444449         mc6846.preset = mc6846.latch;
445450         mc6846.csr &= ~1;
446         mc6846_update_irq(machine);
451         mc6846_update_irq(space->machine);
447452         mc6846.cto = 0;
448         mc6846_update_cto(machine);
453         mc6846_update_cto(space->machine);
449454         /* launch only if started */
450455         if (!(mc6846.tcr & 1))
451            mc6846_timer_launch(machine);
456            mc6846_timer_launch(space->machine);
452457      }
453458      break;
454459
455460   default:
456      logerror( "$%04x mc6846 invalid write offset %i\n", activecpu_get_previouspc(), offset );
461      logerror( "$%04x mc6846 invalid write offset %i\n", cpu_get_previouspc(space->cpu), offset );
457462   }
458463}
459464
r3658r3659
502507
503508UINT8 mc6846_get_output_port ( running_machine *machine )
504509{
505   return PORT;
510   return PORT_MACHINE;
506511}
507512
508513
r3658r3659
565570   mc6846.interval = timer_alloc( mc6846_timer_expire , NULL);
566571   mc6846.one_shot = timer_alloc( mc6846_timer_one_shot , NULL);
567572
568   state_save_register_item( "mc6846", 0, mc6846.csr );
569   state_save_register_item( "mc6846", 0, mc6846.pcr );
570   state_save_register_item( "mc6846", 0, mc6846.ddr );
571   state_save_register_item( "mc6846", 0, mc6846.pdr );
572   state_save_register_item( "mc6846", 0, mc6846.tcr );
573   state_save_register_item( "mc6846", 0, mc6846.cp1 );
574   state_save_register_item( "mc6846", 0, mc6846.cp2 );
575   state_save_register_item( "mc6846", 0, mc6846.cp2_cpu );
576   state_save_register_item( "mc6846", 0, mc6846.cto );
577   state_save_register_item( "mc6846", 0, mc6846.time_MSB );
578   state_save_register_item( "mc6846", 0, mc6846.csr0_to_be_cleared );
579   state_save_register_item( "mc6846", 0, mc6846.csr1_to_be_cleared );
580   state_save_register_item( "mc6846", 0, mc6846.csr2_to_be_cleared );
581   state_save_register_item( "mc6846", 0, mc6846.latch );
582   state_save_register_item( "mc6846", 0, mc6846.preset );
583   state_save_register_item( "mc6846", 0, mc6846.timer_started );
573   state_save_register_item( "mc6846", NULL, 0, mc6846.csr );
574   state_save_register_item( "mc6846", NULL, 0, mc6846.pcr );
575   state_save_register_item( "mc6846", NULL, 0, mc6846.ddr );
576   state_save_register_item( "mc6846", NULL, 0, mc6846.pdr );
577   state_save_register_item( "mc6846", NULL, 0, mc6846.tcr );
578   state_save_register_item( "mc6846", NULL, 0, mc6846.cp1 );
579   state_save_register_item( "mc6846", NULL, 0, mc6846.cp2 );
580   state_save_register_item( "mc6846", NULL, 0, mc6846.cp2_cpu );
581   state_save_register_item( "mc6846", NULL, 0, mc6846.cto );
582   state_save_register_item( "mc6846", NULL, 0, mc6846.time_MSB );
583   state_save_register_item( "mc6846", NULL, 0, mc6846.csr0_to_be_cleared );
584   state_save_register_item( "mc6846", NULL, 0, mc6846.csr1_to_be_cleared );
585   state_save_register_item( "mc6846", NULL, 0, mc6846.csr2_to_be_cleared );
586   state_save_register_item( "mc6846", NULL, 0, mc6846.latch );
587   state_save_register_item( "mc6846", NULL, 0, mc6846.preset );
588   state_save_register_item( "mc6846", NULL, 0, mc6846.timer_started );
584589
585590   mc6846_reset();
586591}
src/mess/machine/mc6846.h
r3658r3659
1616struct _mc6846_interface
1717{
1818  /* CPU write to the outside through chip */
19  write8_machine_func out_port_func;  /* 8-bit output */
20  write8_machine_func out_cp1_func;   /* 1-bit output */
21  write8_machine_func out_cp2_func;   /* 1-bit output */
19  write8_space_func out_port_func;  /* 8-bit output */
20  write8_space_func out_cp1_func;   /* 1-bit output */
21  write8_space_func out_cp2_func;   /* 1-bit output */
2222
2323  /* CPU read from the outside through chip */
24  read8_machine_func in_port_func; /* 8-bit input */
24  read8_space_func in_port_func; /* 8-bit input */
2525
2626  /* asynchronous timer output to outside world */
27  write8_machine_func out_cto_func; /* 1-bit output */
27  write8_space_func out_cto_func; /* 1-bit output */
2828
2929  /* timer interrupt */
3030  void ( * irq_func ) ( running_machine *machine, int state );
src/mess/machine/mc6843.c
r3658r3659
407407      int cmd = mc6843->CMR & 0x0f;
408408
409409      LOG(( "%f $%04x mc6843_r: data input cmd=%s(%i), pos=%i/%i, GCR=%i, ",
410            attotime_to_double(timer_get_time()), activecpu_get_previouspc(),
410            attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu),
411411            mc6843_cmd[cmd], cmd, mc6843->data_idx,
412412            mc6843->data_size, mc6843->GCR ));
413413
r3658r3659
460460      {
461461         /* XXX TODO: other read modes */
462462         data = mc6843->data[0];
463         logerror( "$%04x mc6843 read in unsupported command mode %i\n", activecpu_get_previouspc(), cmd );
463         logerror( "$%04x mc6843 read in unsupported command mode %i\n", cpu_get_previouspc(space->cpu), cmd );
464464      }
465465
466466      LOG(( "data=%02X\n", data ));
r3658r3659
471471   case 1: /* Current-Track Address Register (CTAR) */
472472      data = mc6843->CTAR;
473473      LOG(( "%f $%04x mc6843_r: read CTAR %i (actual=%i)\n",
474            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
474            attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data,
475475            floppy_drive_get_current_track( mc6843_floppy_image() ) ));
476476      break;
477477
478478   case 2: /* Interrupt Status Register (ISR) */
479479      data = mc6843->ISR;
480480      LOG(( "%f $%04x mc6843_r: read ISR %02X: cmd=%scomplete settle=%scomplete sense-rq=%i STRB=%i\n",
481            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
481            attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data,
482482            (data & 1) ? "" : "not-" , (data & 2) ? "" : "not-",
483483            (data >> 2) & 1, (data >> 3) & 1 ));
484484
r3658r3659
504504
505505      data = mc6843->STRA;
506506      LOG(( "%f $%04x mc6843_r: read STRA %02X: data-rq=%i del-dta=%i ready=%i t0=%i wp=%i trk-dif=%i idx=%i busy=%i\n",
507            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
507            attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data,
508508            data & 1, (data >> 1) & 1, (data >> 2) & 1, (data >> 3) & 1,
509509            (data >> 4) & 1, (data >> 5) & 1, (data >> 6) & 1, (data >> 7) & 1 ));
510510      break;
r3658r3659
513513   case 4: /* Status Register B (STRB) */
514514      data = mc6843->STRB;
515515      LOG(( "%f $%04x mc6843_r: read STRB %02X: data-err=%i CRC-err=%i dta--mrk-err=%i sect-mrk-err=%i seek-err=%i fi=%i wr-err=%i hard-err=%i\n",
516            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
516            attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data,
517517            data & 1, (data >> 1) & 1, (data >> 2) & 1, (data >> 3) & 1,
518518            (data >> 4) & 1, (data >> 5) & 1, (data >> 6) & 1, (data >> 7) & 1 ));
519519
r3658r3659
525525   case 7: /* Logical-Track Address Register (LTAR) */
526526      data = mc6843->LTAR;
527527      LOG(( "%f $%04x mc6843_r: read LTAR %i (actual=%i)\n",
528            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
528            attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data,
529529            floppy_drive_get_current_track( mc6843_floppy_image() ) ));
530530      break;
531531
532532   default:
533      logerror( "$%04x mc6843 invalid read offset %i\n", activecpu_get_previouspc(), offset );
533      logerror( "$%04x mc6843 invalid read offset %i\n", cpu_get_previouspc(space->cpu), offset );
534534   }
535535
536536   return data;
r3658r3659
546546      int FWF = (mc6843->CMR >> 4) & 1;
547547
548548      LOG(( "%f $%04x mc6843_w: data output cmd=%s(%i), pos=%i/%i, GCR=%i, data=%02X\n",
549            attotime_to_double(timer_get_time()), activecpu_get_previouspc(),
549            attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu),
550550            mc6843_cmd[cmd], cmd, mc6843->data_idx,
551551            mc6843->data_size, mc6843->GCR, data ));
552552
r3658r3659
563563            /* end of sector write */
564564            const device_config* img = mc6843_floppy_image();
565565
566            LOG(( "%f $%04x mc6843_w: write sector %i\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6843->data_id ));
566            LOG(( "%f $%04x mc6843_w: write sector %i\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), mc6843->data_id ));
567567
568568            floppy_drive_write_sector_data(
569569               img, mc6843->side, mc6843->data_id,
r3658r3659
627627               UINT8 track  = mc6843->data[1];
628628               UINT8 sector = mc6843->data[3];
629629               UINT8 filler = 0xe5; /* standard Thomson filler */
630               LOG(( "%f $%04x mc6843_w: address id detected track=%i sector=%i\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), track, sector));
630               LOG(( "%f $%04x mc6843_w: address id detected track=%i sector=%i\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), track, sector));
631631               floppy_drive_format_sector( img, mc6843->side, sector, track, 0, sector, 0, filler );
632632            }
633633            else
r3658r3659
649649      else
650650      {
651651         /* XXX TODO: other write modes */
652         logerror( "$%04x mc6843 write %02X in unsupported command mode %i (FWF=%i)\n", activecpu_get_previouspc(), data, cmd, FWF );
652         logerror( "$%04x mc6843 write %02X in unsupported command mode %i (FWF=%i)\n", cpu_get_previouspc(space->cpu), data, cmd, FWF );
653653      }
654654      break;
655655   }
r3658r3659
657657   case 1: /* Current-Track Address Register (CTAR) */
658658      mc6843->CTAR = data & 0x7f;
659659      LOG(( "%f $%04x mc6843_w: set CTAR to %i %02X (actual=%i) \n",
660            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6843->CTAR, data,
660            attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), mc6843->CTAR, data,
661661            floppy_drive_get_current_track( mc6843_floppy_image() ) ));
662662      break;
663663
r3658r3659
666666      int cmd = data & 15;
667667
668668      LOG(( "%f $%04x mc6843_w: set CMR to $%02X: cmd=%s(%i) FWF=%i DMA=%i ISR3-intr=%i fun-intr=%i\n",
669            attotime_to_double(timer_get_time()), activecpu_get_previouspc(),
669            attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu),
670670            data, mc6843_cmd[cmd], cmd, (data >> 4) & 1, (data >> 5) & 1,
671671            (data >> 6) & 1, (data >> 7) & 1 ));
672672
r3658r3659
713713
714714      /* assume CLK freq = 1MHz (IBM 3740 compatibility) */
715715      LOG(( "%f $%04x mc6843_w: set SUR to $%02X: head settling time=%fms, track-to-track seek time=%f\n",
716            attotime_to_double(timer_get_time()), activecpu_get_previouspc(),
716            attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu),
717717            data, 4.096 * (data & 15), 1.024 * ((data >> 4) & 15) ));
718718      break;
719719
720720   case 4: /* Sector Address Register (SAR) */
721721      mc6843->SAR = data & 0x1f;
722      LOG(( "%f $%04x mc6843_w: set SAR to %i (%02X)\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6843->SAR, data ));
722      LOG(( "%f $%04x mc6843_w: set SAR to %i (%02X)\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), mc6843->SAR, data ));
723723      break;
724724
725725   case 5: /* General Count Register (GCR) */
726726      mc6843->GCR = data & 0x7f;
727      LOG(( "%f $%04x mc6843_w: set GCR to %i (%02X)\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6843->GCR, data ));
727      LOG(( "%f $%04x mc6843_w: set GCR to %i (%02X)\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), mc6843->GCR, data ));
728728      break;
729729
730730   case 6: /* CRC Control Register (CCR) */
731731      mc6843->CCR = data & 3;
732732      LOG(( "%f $%04x mc6843_w: set CCR to %02X: CRC=%s shift=%i\n",
733            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
733            attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data,
734734            (data & 1) ? "enabled" : "disabled", (data >> 1) & 1 ));
735735      break;
736736
737737   case 7: /* Logical-Track Address Register (LTAR) */
738738      mc6843->LTAR = data & 0x7f;
739739      LOG(( "%f $%04x mc6843_w: set LTAR to %i %02X (actual=%i)\n",
740            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6843->LTAR, data,
740            attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), mc6843->LTAR, data,
741741            floppy_drive_get_current_track( mc6843_floppy_image() ) ));
742742      break;
743743
744744   default:
745      logerror( "$%04x mc6843 invalid write offset %i (data=$%02X)\n", activecpu_get_previouspc(), offset, data );
745      logerror( "$%04x mc6843 invalid write offset %i (data=$%02X)\n", cpu_get_previouspc(space->cpu), offset, data );
746746   }
747747}
748748
r3658r3659
795795   mc6843->iface = iface;
796796   mc6843->timer_cont = timer_alloc( mc6843_cont , NULL);
797797
798   state_save_register_item( "mc6843", 0, mc6843->CTAR );
799   state_save_register_item( "mc6843", 0, mc6843->CMR );
800   state_save_register_item( "mc6843", 0, mc6843->ISR );
801   state_save_register_item( "mc6843", 0, mc6843->SUR );
802   state_save_register_item( "mc6843", 0, mc6843->STRA );
803   state_save_register_item( "mc6843", 0, mc6843->STRB );
804   state_save_register_item( "mc6843", 0, mc6843->SAR );
805   state_save_register_item( "mc6843", 0, mc6843->GCR );
806   state_save_register_item( "mc6843", 0, mc6843->CCR );
807   state_save_register_item( "mc6843", 0, mc6843->LTAR );
808   state_save_register_item( "mc6843", 0, mc6843->drive );
809   state_save_register_item( "mc6843", 0, mc6843->side );
810   state_save_register_item_array( "mc6843", 0, mc6843->data );
811   state_save_register_item( "mc6843", 0, mc6843->data_size );
812   state_save_register_item( "mc6843", 0, mc6843->data_idx );
813   state_save_register_item( "mc6843", 0, mc6843->data_id );
814   state_save_register_item( "mc6843", 0, mc6843->index_pulse );
798   state_save_register_item( "mc6843", NULL, 0, mc6843->CTAR );
799   state_save_register_item( "mc6843", NULL, 0, mc6843->CMR );
800   state_save_register_item( "mc6843", NULL, 0, mc6843->ISR );
801   state_save_register_item( "mc6843", NULL, 0, mc6843->SUR );
802   state_save_register_item( "mc6843", NULL, 0, mc6843->STRA );
803   state_save_register_item( "mc6843", NULL, 0, mc6843->STRB );
804   state_save_register_item( "mc6843", NULL, 0, mc6843->SAR );
805   state_save_register_item( "mc6843", NULL, 0, mc6843->GCR );
806   state_save_register_item( "mc6843", NULL, 0, mc6843->CCR );
807   state_save_register_item( "mc6843", NULL, 0, mc6843->LTAR );
808   state_save_register_item( "mc6843", NULL, 0, mc6843->drive );
809   state_save_register_item( "mc6843", NULL, 0, mc6843->side );
810   state_save_register_item_array( "mc6843", NULL, 0, mc6843->data );
811   state_save_register_item( "mc6843", NULL, 0, mc6843->data_size );
812   state_save_register_item( "mc6843", NULL, 0, mc6843->data_idx );
813   state_save_register_item( "mc6843", NULL, 0, mc6843->data_id );
814   state_save_register_item( "mc6843", NULL, 0, mc6843->index_pulse );
815815
816816   mc6843_reset(machine);
817817}
src/mess/mess.mak
r3658r3659
430430   $(MESSOBJ)/ssystem3.a \
431431   $(MESSOBJ)/super80.a \
432432   $(MESSOBJ)/telmac.a \
433   $(MESSOBJ)/thomson.a \
434   $(MESSOBJ)/tiger.a \
433435   $(MESSOBJ)/trs80.a \
434436   $(MESSOBJ)/ut88.a \
435437   $(MESSOBJ)/vc4000.a \
r3658r3659
480482#   $(MESSOBJ)/tangerin.a \
481483#   $(MESSOBJ)/tatung.a \
482484#   $(MESSOBJ)/teamconc.a \
483#   $(MESSOBJ)/thomson.a \
484485#   $(MESSOBJ)/ti85.a \
485486#   $(MESSOBJ)/ti99.a \
486#   $(MESSOBJ)/tiger.a \
487487#   $(MESSOBJ)/tutor.a \
488488#   $(MESSOBJ)/tx0.a \
489489#   $(MESSOBJ)/veb.a \
src/mess/devices/thomflop.c
r3658r3659
278278static READ8_HANDLER ( to7_5p14_r )
279279{
280280   if ( offset < 4 )
281      return wd17xx_r( machine, offset );
281      return wd17xx_r( space, offset );
282282   else if ( offset == 8 )
283283      return to7_5p14_select;
284284   else
285      logerror ( "%f $%04x to7_5p14_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset );
285      logerror ( "%f $%04x to7_5p14_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), offset );
286286   return 0;
287287}
288288
r3658r3659
291291static WRITE8_HANDLER( to7_5p14_w )
292292{
293293   if ( offset < 4 )
294      wd17xx_w( machine, offset, data );
294      wd17xx_w( space, offset, data );
295295   else if ( offset == 8 )
296296   {
297297      /* drive select */
r3658r3659
306306      case 4: drive = 2; side = 0; break;
307307      case 5: drive = 3; side = 1; break;
308308      default:
309         logerror( "%f $%04x to7_5p14_w: invalid drive select pattern $%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data );
309         logerror( "%f $%04x to7_5p14_w: invalid drive select pattern $%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data );
310310      }
311311
312312      dens = (data & 0x80) ? DEN_FM_LO : DEN_MFM_LO;
r3658r3659
321321         wd17xx_set_drive( drive );
322322         wd17xx_set_side( side );
323323         LOG(( "%f $%04x to7_5p14_w: $%02X set drive=%i side=%i density=%s\n",
324               attotime_to_double(timer_get_time()), activecpu_get_previouspc(),
324               attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu),
325325               data, drive, side, (dens == DEN_FM_LO) ? "FM" : "MFM" ));
326326      }
327327   }
328328   else
329329      logerror ( "%f $%04x to7_5p14_w: invalid write offset %i (data=$%02X)\n",
330            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data );
330            attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), offset, data );
331331}
332332
333333
r3658r3659
375375static READ8_HANDLER ( to7_5p14sd_r )
376376{
377377   if ( offset < 8 )
378      return mc6843_r( machine, offset );
378      return mc6843_r( space, offset );
379379   else if ( offset >= 8 && offset <= 9 )
380380      return to7_5p14sd_select;
381381   else
382      logerror ( "%f $%04x to7_5p14sd_r: invalid read offset %i\n",  attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset );
382      logerror ( "%f $%04x to7_5p14sd_r: invalid read offset %i\n",  attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), offset );
383383   return 0;
384384}
385385
r3658r3659
388388static WRITE8_HANDLER( to7_5p14sd_w )
389389{
390390   if ( offset < 8 )
391      mc6843_w( machine, offset, data );
391      mc6843_w( space, offset, data );
392392   else if ( offset >= 8 && offset <= 9 )
393393   {
394394      /* drive select */
r3658r3659
423423         mc6843_set_drive( drive );
424424         mc6843_set_side( side );
425425         LOG(( "%f $%04x to7_5p14sd_w: $%02X set drive=%i side=%i\n",
426               attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data, drive, side ));
426               attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data, drive, side ));
427427      }
428428   }
429429   else
430430      logerror ( "%f $%04x to7_5p14sd_w: invalid write offset %i (data=$%02X)\n",
431            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data );
431            attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), offset, data );
432432}
433433
434434
r3658r3659
604604   else
605605      data = to7qdd->data[ to7qdd->data_idx ];
606606
607   VLOG(( "%f $%04x to7_qdd_read_byte: RDATA off=%i/%i data=$%02X\n",
608          attotime_to_double(timer_get_time()), activecpu_get_previouspc(),
609          to7qdd->data_idx, to7qdd->data_size, data ));
607//   VLOG(( "%f $%04x to7_qdd_read_byte: RDATA off=%i/%i data=$%02X\n",
608//          attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu),
609//          to7qdd->data_idx, to7qdd->data_size, data ));
610610
611611   to7qdd->data_idx++;
612612   to7qdd->start_idx = to7qdd->data_idx;
r3658r3659
645645      to7qdd->data[ to7qdd->data_idx ] = data;
646646      to7qdd->data_idx++;
647647
648      VLOG (( "%f $%04x to7_qdd_write_byte: got $%02X offs=%i-%i\n",
649         attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
650         to7qdd->start_idx, to7qdd->data_idx ));
648//      VLOG (( "%f $%04x to7_qdd_write_byte: got $%02X offs=%i-%i\n",
649//         attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data,
650//         to7qdd->start_idx, to7qdd->data_idx ));
651651
652652      /* end of tentative id field */
653653      if ( to7qdd->data_idx == to7qdd->start_idx + 4 &&
r3658r3659
659659         int sector = (int) to7qdd->data[ to7qdd->start_idx + 1 ] * 256 + (int) to7qdd->data[ to7qdd->start_idx + 2 ];
660660         UINT8 filler = 0xff;
661661
662         LOG(( "%f $%04x to7_qdd_write_byte: got id field for sector=%i\n",
663               attotime_to_double(timer_get_time()), activecpu_get_previouspc(), sector ));
662//         LOG(( "%f $%04x to7_qdd_write_byte: got id field for sector=%i\n",
663//               attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), sector ));
664664
665665         floppy_drive_format_sector( to7_qdd_image(),
666666                      0, sector, 0, 0, sector, 128, filler );
r3658r3659
688688            /* got an id & a data field => write */
689689            int sector = (int) to7qdd->data[ i + 1 ] * 256 + (int) to7qdd->data[ i + 2 ];
690690
691            LOG(( "%f $%04x to7_qdd_write_byte: goto data field for sector=%i\n",
692                  attotime_to_double(timer_get_time()), activecpu_get_previouspc(), sector ));
691//            LOG(( "%f $%04x to7_qdd_write_byte: goto data field for sector=%i\n",
692//                  attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), sector ));
693693
694694            floppy_drive_write_sector_data( to7_qdd_image(), 0, sector, to7qdd->data + to7qdd->start_idx + 1, 128, 0 );
695695         }
r3658r3659
711711   case 0: /* MC6852 status */
712712      to7_qdd_stat_update();
713713      VLOG(( "%f $%04x to7_qdd_r: STAT=$%02X irq=%i pe=%i ovr=%i und=%i tr=%i rd=%i ncts=%i\n",
714             attotime_to_double(timer_get_time()), activecpu_get_previouspc(), to7qdd->status,
714             attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), to7qdd->status,
715715             to7qdd->status & QDD_S_IRQ  ? 1 : 0,
716716             to7qdd->status & QDD_S_PE   ? 1 : 0,
717717             to7qdd->status & QDD_S_OVR  ? 1 : 0,
r3658r3659
734734         data |= 0x40; /* disk present */
735735      if ( to7qdd->index_pulse )
736736         data |= 0x80; /* disk start */
737      VLOG(( "%f $%04x to7_qdd_r: STATUS8 $%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
737      VLOG(( "%f $%04x to7_qdd_r: STATUS8 $%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data ));
738738      return data;
739739   }
740740
741741   default:
742      logerror ( "%f $%04x to7_qdd_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset );
742      logerror ( "%f $%04x to7_qdd_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), offset );
743743      return 0;
744744   }
745745}
r3658r3659
761761      to7qdd->ctrl1 = ( data & ~(QDD_C1_RRESET | QDD_C1_TRESET) ) |( data &  (QDD_C1_RRESET | QDD_C1_TRESET) & to7qdd->ctrl1 );
762762      to7_qdd_stat_update();
763763      VLOG(( "%f $%04x to7_qdd_w: CTRL1=$%02X reset=%c%c %s%sirq=%c%c\n",
764             attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
764             attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data,
765765             data & QDD_C1_RRESET ? 'r' : '-', data & QDD_C1_TRESET ? 't' : '-',
766766             data & QDD_C1_STRIPSYNC ? "strip-sync " : "",
767767             data & QDD_C1_CLRSYNC ? "clear-sync " : "",
r3658r3659
785785         parity = par[ (data >> 3) & 7 ];
786786         to7_qdd_stat_update();
787787         VLOG(( "%f $%04x to7_qdd_w: CTRL2=$%02X bits=%i par=%s blen=%i under=%s%s\n",
788                attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
788                attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data,
789789                bits, parname[ parity ], data & QDD_C2_BLEN ? 1 : 2,
790790                data & QDD_C2_TSYNC ? "sync" : "ff",
791791                data & QDD_C2_EIE ? "irq-err" : "" ));
r3658r3659
803803            to7qdd->status &= ~QDD_S_NCTS;
804804         to7_qdd_stat_update();
805805         VLOG(( "%f $%04x to7_qdd_w: CTRL3=$%02X %s%ssync-len=%i sync-mode=%s\n",
806                attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
806                attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data,
807807                data & QDD_C3_CLRTUF ? "clr-tuf " : "",
808808                data & QDD_C3_CLRCTS ? "clr-cts " : "",
809809                data & QDD_C3_SYNCLEN ? 1 : 2,
r3658r3659
815815         break;
816816
817817      case 3: /* MC6852 data out => does not seem to be used */
818         VLOG(( "%f $%04x to7_qdd_w: ignored WDATA=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
818         VLOG(( "%f $%04x to7_qdd_w: ignored WDATA=$%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data ));
819819         break;
820820
821821      }
r3658r3659
823823
824824   case 8: /* set drive */
825825      to7qdd->drive = data;
826      VLOG(( "%f $%04x to7_qdd_w: DRIVE=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
826      VLOG(( "%f $%04x to7_qdd_w: DRIVE=$%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data ));
827827      break;
828828
829829   case 12: /* motor pulse ? */
830830      thom_floppy_active( 0 );
831      VLOG(( "%f $%04x to7_qdd_w: MOTOR=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
831      VLOG(( "%f $%04x to7_qdd_w: MOTOR=$%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data ));
832832      break;
833833
834834   default:
835      logerror ( "%f $%04x to7_qdd_w: invalid write offset %i (data=$%02X)\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data );
835      logerror ( "%f $%04x to7_qdd_w: invalid write offset %i (data=$%02X)\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), offset, data );
836836   }
837837}
838838
r3658r3659
10581058{
10591059   UINT8 data = thmfc1->data[ thmfc1->data_idx ];
10601060
1061   VLOG(( "%f $%04x thmfc_floppy_read_byte: off=%i/%i/%i data=$%02X\n",
1062          attotime_to_double(timer_get_time()), activecpu_get_previouspc(),
1063          thmfc1->data_idx, thmfc1->data_finish - 1, thmfc1->data_size - 1,
1064          data ));
1061//   VLOG(( "%f $%04x thmfc_floppy_read_byte: off=%i/%i/%i data=$%02X\n",
1062//          attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu),
1063//          thmfc1->data_idx, thmfc1->data_finish - 1, thmfc1->data_size - 1,
1064//          data ));
10651065
10661066   if ( thmfc1->data_idx >= thmfc1->data_size - 1 )
10671067      thmfc_floppy_cmd_complete();
r3658r3659
11011101   else
11021102      data = thmfc1->data[ thmfc1->data_raw_idx ];
11031103
1104   VLOG(( "%f $%04x thmfc_floppy_raw_read_byte: off=%i/%i data=$%02X\n",
1105          attotime_to_double(timer_get_time()), activecpu_get_previouspc(),
1106          thmfc1->data_raw_idx, thmfc1->data_raw_size, data ));
1104//   VLOG(( "%f $%04x thmfc_floppy_raw_read_byte: off=%i/%i data=$%02X\n",
1105//          attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu),
1106//          thmfc1->data_raw_idx, thmfc1->data_raw_size, data ));
11071107
11081108   thmfc1->data_raw_idx++;
11091109
r3658r3659
11391139         thmfc1->data_idx = thmfc1->data_raw_idx;
11401140      }
11411141
1142      VLOG (( "%f $%04x thmfc_floppy_qdd_write_byte: $%02X offs=%i-%i\n",
1143         attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
1144         thmfc1->data_idx,thmfc1->data_raw_idx ));
1142//      VLOG (( "%f $%04x thmfc_floppy_qdd_write_byte: $%02X offs=%i-%i\n",
1143//         attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data,
1144//         thmfc1->data_idx,thmfc1->data_raw_idx ));
11451145
11461146      if ( thmfc1->data_raw_idx == thmfc1->data_idx + 3 &&
11471147           thmfc1->data[ thmfc1->data_idx - 1 ] == 0xA5 &&
r3658r3659
11521152         int sector = (int) thmfc1->data[ thmfc1->data_idx ] * 256 + (int) thmfc1->data[ thmfc1->data_idx + 1 ];
11531153         UINT8 filler = 0xff;
11541154
1155         LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: id field, sector=%i\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), sector ));
1155//         LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: id field, sector=%i\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), sector ));
11561156
11571157         floppy_drive_format_sector( thmfc_floppy_image(), 0, sector, 0, 0, sector, 128, filler );
11581158         thmfc1->data_idx = 0;
r3658r3659
11801180            int sector = (int) thmfc1->data[ i + 1 ] * 256 +
11811181               (int) thmfc1->data[ i + 2 ];
11821182
1183            LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: data field, sector=%i\n",
1184                  attotime_to_double(timer_get_time()), activecpu_get_previouspc(), sector ));
1183//            LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: data field, sector=%i\n",
1184//                  attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), sector ));
11851185
11861186            floppy_drive_write_sector_data( img, 0, sector, thmfc1->data + thmfc1->data_idx, 128, 0 );
11871187         }
r3658r3659
11951195   else
11961196   {
11971197      thmfc1->data_raw_idx++;
1198      VLOG (( "%f $%04x thmfc_floppy_qdd_write_byte: ignored $%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
1198//      VLOG (( "%f $%04x thmfc_floppy_qdd_write_byte: ignored $%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data ));
11991199   }
12001200
12011201}
r3658r3659
12051205/* intelligent writing */
12061206static void thmfc_floppy_write_byte ( UINT8 data )
12071207{
1208   VLOG (( "%f $%04x thmfc_floppy_write_byte: off=%i/%i data=$%02X\n",
1209      attotime_to_double(timer_get_time()), activecpu_get_previouspc(),
1210      thmfc1->data_idx, thmfc1->data_size - 1, data ));
1208//   VLOG (( "%f $%04x thmfc_floppy_write_byte: off=%i/%i data=$%02X\n",
1209//      attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu),
1210//      thmfc1->data_idx, thmfc1->data_size - 1, data ));
12111211
12121212   thmfc1->data_raw_size = 0;
12131213   thmfc1->data[ thmfc1->data_idx ] = data;
r3658r3659
12201220/* intelligent formatting */
12211221static void thmfc_floppy_format_byte ( UINT8 data )
12221222{
1223   VLOG (( "%f $%04x thmfc_floppy_format_byte: $%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
1223//   VLOG (( "%f $%04x thmfc_floppy_format_byte: $%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data ));
12241224
12251225   thmfc1->data_raw_size = 0;
12261226
r3658r3659
12601260
12611261   case 0: /* STAT0 */
12621262      thmfc1->stat0 ^= THMFC1_STAT0_SYNCHRO | THMFC1_STAT0_BYTE_READY_POL;
1263      VLOG(( "%f $%04x thmfc_floppy_r: STAT0=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), thmfc1->stat0 ));
1263      VLOG(( "%f $%04x thmfc_floppy_r: STAT0=$%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), thmfc1->stat0 ));
12641264      return thmfc1->stat0;
12651265
12661266   case 1: /* STAT1 */
r3658r3659
12911291         data |= 0x10;
12921292      if ( flags & FLOPPY_DRIVE_DISK_WRITE_PROTECTED )
12931293         data |= 0x04;
1294      VLOG(( "%f $%04x thmfc_floppy_r: STAT1=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
1294      VLOG(( "%f $%04x thmfc_floppy_r: STAT1=$%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data ));
12951295      return data;
12961296   }
12971297
r3658r3659
13091309   {
13101310      /* undocumented => emulate TO7 QDD controller ? */
13111311      UINT8 data = thmfc1->ipl << 7;
1312      VLOG(( "%f $%04x thmfc_floppy_r: STAT8=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
1312      VLOG(( "%f $%04x thmfc_floppy_r: STAT8=$%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data ));
13131313      return data;
13141314   }
13151315
13161316   default:
1317      logerror ( "%f $%04x thmfc_floppy_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset );
1317      logerror ( "%f $%04x thmfc_floppy_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), offset );
13181318      return 0;
13191319   }
13201320}
r3658r3659
13341334      thom_floppy_set_density( dens );
13351335      thmfc1->formatting = (data >> 2) & 1;
13361336      LOG (( "%f $%04x thmfc_floppy_w: CMD0=$%02X dens=%s wsync=%i dsync=%i fmt=%i op=%i\n",
1337             attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
1337             attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data,
13381338             (dens == DEN_FM_LO) ? "MF" : "MFM",
13391339             wsync, (data >> 3) & 1,
13401340             thmfc1->formatting, data & 3 ));
r3658r3659
14191419      if ( thmfc1->sector_size > 256 )
14201420      {
14211421         logerror( "$%04x thmfc_floppy_w: sector size %i > 256 not handled\n",
1422              activecpu_get_previouspc(), thmfc1->sector_size );
1422              cpu_get_previouspc(space->cpu), thmfc1->sector_size );
14231423         thmfc1->sector_size = 256;
14241424      }
14251425
14261426      LOG (( "%f $%04x thmfc_floppy_w: CMD1=$%02X sect-size=%i comp=%i head=%i\n",
1427             attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
1427             attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data,
14281428             thmfc1->sector_size, (data >> 1) & 7, thmfc1->side ));
14291429      break;
14301430
r3658r3659
14521452      thom_floppy_active( 0 );
14531453
14541454      LOG (( "%f $%04x thmfc_floppy_w: CMD2=$%02X drv=%i step=%i motor=%i\n",
1455             attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
1455             attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data,
14561456             thmfc1->drive, seek, motor ));
14571457
14581458      if ( seek )
r3658r3659
14821482      {
14831483         /* TODO: implement other forms of raw track writing */
14841484         LOG (( "%f $%04x thmfc_floppy_w: ignored raw WDATA $%02X\n",
1485                attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
1485                attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data ));
14861486      }
14871487      break;
14881488
r3658r3659
14901490   case 4: /* WCLK (unemulated) */
14911491      /* clock configuration: FF for data, 0A for synchro */
14921492      LOG (( "%f $%04x thmfc_floppy_w: WCLK=$%02X (%s)\n",
1493             attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
1493             attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data,
14941494             (data == 0xff) ? "data" : (data == 0x0A) ? "synchro" : "?" ));
14951495      break;
14961496
14971497   case 5: /* WSECT */
14981498      thmfc1->sector = data;
14991499      LOG (( "%f $%04x thmfc_floppy_w: WSECT=%i\n",
1500             attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
1500             attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data ));
15011501      break;
15021502
15031503   case 6: /* WTRCK */
15041504      thmfc1->track = data;
15051505      LOG (( "%f $%04x thmfc_floppy_w: WTRCK=%i (real=%i)\n",
1506             attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
1506             attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data,
15071507             floppy_drive_get_current_track( thmfc_floppy_image() ) ));
15081508      break;
15091509
15101510   case 7: /* WCELL */
15111511      /* precompensation (unemulated) */
15121512      LOG (( "%f $%04x thmfc_floppy_w: WCELL=$%02X\n",
1513             attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
1513             attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), data ));
15141514      break;
15151515
15161516   default:
15171517      logerror ( "%f $%04x thmfc_floppy_w: invalid write offset %i (data=$%02X)\n",
1518            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data );
1518            attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), offset, data );
15191519   }
15201520}
15211521
r3658r3659
17111711static READ8_HANDLER ( to7_network_r )
17121712{
17131713   if ( offset >= 0 && offset < 4 )
1714      return mc6854_r( machine, offset );
1714      return mc6854_r( space, offset );
17151715
17161716   if ( offset == 8 )
17171717   {
17181718      /* network ID of the computer */
1719      UINT8 id = input_port_read(machine, "fconfig") >> 3;
1720      VLOG(( "%f $%04x to7_network_r: read id $%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), id ));
1719      UINT8 id = input_port_read(space->machine, "fconfig") >> 3;
1720      VLOG(( "%f $%04x to7_network_r: read id $%02X\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), id ));
17211721      return id;
17221722   }
17231723
1724   logerror( "%f $%04x to7_network_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset );
1724   logerror( "%f $%04x to7_network_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), offset );
17251725   return 0;
17261726}
17271727
r3658r3659
17301730static WRITE8_HANDLER ( to7_network_w )
17311731{
17321732   if ( offset >= 0 && offset < 4 )
1733      mc6854_w( machine, offset, data );
1733      mc6854_w( space, offset, data );
17341734   else
17351735   {
17361736      logerror( "%f $%04x to7_network_w: invalid write offset %i (data=$%02X)\n",
1737           attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data );
1737           attotime_to_double(timer_get_time()), cpu_get_previouspc(space->cpu), offset, data );
17381738   }
17391739}
17401740
r3658r3659
17601760
17611761void to7_floppy_init ( running_machine *machine, void* base )
17621762{
1763   memory_configure_bank( THOM_FLOP_BANK, 0, TO7_NB_FLOP_BANK, base, 0x800 );
1763   memory_configure_bank( machine, THOM_FLOP_BANK, 0, TO7_NB_FLOP_BANK, base, 0x800 );
17641764   state_save_register_global( to7_controller_type );
17651765   state_save_register_global( to7_floppy_bank );
17661766   to7_5p14sd_init(machine);
r3658r3659
18091809      break;
18101810   }
18111811
1812   memory_set_bank( THOM_FLOP_BANK, to7_floppy_bank );
1812   memory_set_bank( machine, THOM_FLOP_BANK, to7_floppy_bank );
18131813}
18141814
18151815
r3658r3659
18201820   {
18211821
18221822   case 1:
1823      return to7_5p14sd_r( machine, offset );
1823      return to7_5p14sd_r( space, offset );
18241824
18251825   case 2:
1826      return to7_5p14_r( machine, offset );
1826      return to7_5p14_r( space, offset );
18271827
18281828   case 3:
1829      return thmfc_floppy_r( machine, offset );
1829      return thmfc_floppy_r( space, offset );
18301830
18311831   case 4:
1832      return to7_qdd_r( machine, offset );
1832      return to7_qdd_r( space, offset );
18331833
18341834   case 5:
1835      return to7_network_r( machine, offset );
1835      return to7_network_r( space, offset );
18361836   }
18371837
18381838   return 0;
r3658r3659
18461846   {
18471847
18481848   case 1:
1849      to7_5p14sd_w( machine, offset, data );
1849      to7_5p14sd_w( space, offset, data );
18501850      return;
18511851
18521852   case 2:
1853      to7_5p14_w( machine, offset, data );
1853      to7_5p14_w( space, offset, data );
18541854      break;
18551855
18561856   case 3:
18571857      if ( offset == 8 )
18581858      {
18591859         to7_floppy_bank = 3 + (data & 3);
1860         memory_set_bank( THOM_FLOP_BANK,  to7_floppy_bank );
1860         memory_set_bank( space->machine, THOM_FLOP_BANK,  to7_floppy_bank );
18611861         VLOG (( "to7_floppy_w: set CD 90-351 ROM bank to %i\n", data & 3 ));
18621862      }
18631863      else
1864         thmfc_floppy_w( machine, offset, data );
1864         thmfc_floppy_w( space, offset, data );
18651865      break;
18661866
18671867   case 4:
1868      to7_qdd_w( machine, offset, data );
1868      to7_qdd_w( space, offset, data );
18691869      break;
18701870
18711871   case 5:
1872      to7_network_w( machine, offset, data );
1872      to7_network_w( space, offset, data );
18731873      break;
18741874   }
18751875}
r3658r3659
18871887void to9_floppy_init( running_machine *machine, void* int_base, void* ext_base )
18881888{
18891889   to7_floppy_init( machine, ext_base );
1890   memory_configure_bank( THOM_FLOP_BANK, TO7_NB_FLOP_BANK, 1, int_base, 0x800 );
1890   memory_configure_bank( machine, THOM_FLOP_BANK, TO7_NB_FLOP_BANK, 1, int_base, 0x800 );
18911891}
18921892
18931893
r3658r3659
19031903   {
19041904      LOG(( "to9_floppy_reset: internal controller\n" ));
19051905      to7_5p14_reset(machine);
1906      memory_set_bank( THOM_FLOP_BANK, TO7_NB_FLOP_BANK );
1906      memory_set_bank( machine, THOM_FLOP_BANK, TO7_NB_FLOP_BANK );
19071907   }
19081908}
19091909
r3658r3659
19121912READ8_HANDLER ( to9_floppy_r )
19131913{
19141914   if ( THOM_FLOPPY_EXT )
1915      return to7_floppy_r( machine, offset );
1915      return to7_floppy_r( space, offset );
19161916   else
1917      return  to7_5p14_r( machine, offset );
1917      return  to7_5p14_r( space, offset );
19181918}
19191919
19201920WRITE8_HANDLER ( to9_floppy_w )
19211921{
19221922   if ( THOM_FLOPPY_EXT )
1923      to7_floppy_w( machine, offset, data );
1923      to7_floppy_w( space, offset, data );
19241924   else
1925      to7_5p14_w( machine, offset, data );
1925      to7_5p14_w( space, offset, data );
19261926}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team