Previous 15994 Revisions Next

r2823 Friday 6th June, 2008 at 01:59:34 UTC by Firewave
1. Even more Machine -> machine and deprecat.g cleanups
2. Fixed error in majutsushi (a MSX slot type) banking
[src/mess/devices]thomflop.c
[src/mess/drivers]acrnsys1.c amstrad.c nc.c newbrain.c pcw.c pcw16.c pentagon.c scorpion.c sg1000.c sord.c specpls3.c x68k.c
[src/mess/includes]c64.h c65.h msx.h msx_slot.h
[src/mess/machine]74145.c 74145.h 99_dsk.c at.c b2m.c bbc.c bebox.c beta.c c128.c c64.c c65.c coco.c compis.c corvushd.c dgn_beta.c gamecom.c geneve.c kc.c kim1.c mc6846.c mc6846.h msx.c msx_slot.c mtx.c nec765.c nec765.h oric.c orion.c pc.c pc8801.c pc_fdc.c pc_fdc.h pclpt.c sms.c special.c svi318.c sym1.c thomson.c wd17xx.c wd17xx.h

src/mess/devices/thomflop.c
r2822r2823
337337   int i;
338338   LOG(( "to7_5p14_reset: CD 90-640 controller\n" ));
339339   thom_floppy_set_density( DEN_MFM_LO );
340   wd17xx_reset();
340   wd17xx_reset(machine);
341341   for ( i = 0; i < device_count( machine, IO_FLOPPY ); i++ )
342342   {
343343      const device_config * img = image_from_devtype_and_index( IO_FLOPPY, i );
src/mess/includes/c65.h
r2822r2823
1919extern UINT8 *c65_interface;
2020/*extern UINT8 *c65_graphics; */
2121
22void c65_bankswitch (void);
22void c65_bankswitch (running_machine *machine);
2323void c65_colorram_write (int offset, int value);
2424
2525DRIVER_INIT( c65 );
src/mess/includes/msx_slot.h
r2822r2823
150150   int mem_type;
151151   char name[32];
152152   int (*init)(slot_state*, int page, UINT8 *mem, int size);
153   void (*reset)(slot_state*);
153   void (*reset)(running_machine *machine, slot_state*);
154154   void (*map)(slot_state*, int page);
155155   void (*write)(slot_state*, UINT16, UINT8);
156156   int (*loadsram)(slot_state*);
r2822r2823
221221#define MSX_SLOT_WRITE(nm)         \
222222   static void slot_##nm##_write (slot_state *state, UINT16 addr, UINT8 val)
223223#define MSX_SLOT_RESET(nm)         \
224   static void slot_##nm##_reset (slot_state *state)
224   static void slot_##nm##_reset (running_machine *machine, slot_state *state)
225225#define MSX_SLOT_LOADSRAM(nm)      \
226226   static int slot_##nm##_loadsram (slot_state *state)
227227#define MSX_SLOT_SAVESRAM(nm)      \
src/mess/includes/msx.h
r2822r2823
9999void msx_memory_map_page (int page);
100100void msx_memory_init (running_machine *machine);
101101void msx_memory_set_carts (void);
102void msx_memory_reset (void);
102void msx_memory_reset (running_machine *machine);
103103
104104
105105#endif /* MSX_H_ */
src/mess/includes/c64.h
r2822r2823
4747INTERRUPT_GEN( c64_frame_interrupt );
4848INTERRUPT_GEN( c128_frame_interrupt );
4949
50void c64_rom_load(void);
50void c64_rom_load(running_machine *machine);
5151void c64_rom_recognition (void);
5252
5353/* private area */
src/mess/machine/dgn_beta.c
r2822r2823
10661066   DMA_NMI_LAST=0x80;         /* start with DMA NMI inactive, as pulled up */
10671067//   DMA_NMI=CLEAR_LINE;         /* start with DMA NMI inactive */
10681068
1069   wd17xx_reset();
1069   wd17xx_reset(machine);
10701070   wd17xx_set_density(DEN_MFM_LO);
10711071   wd17xx_set_drive(0);
10721072
src/mess/machine/c65.c
r2822r2823
622622   old=value;
623623}
624624
625void c65_bankswitch (void)
625void c65_bankswitch (running_machine *machine)
626626{
627627   static int old = -1;
628628   int data, loram, hiram, charen;
r2822r2823
683683         memory_set_bankptr (8, c64_colorram+0x400);
684684         memory_set_bankptr (9, c64_colorram+0x400);
685685      }
686      memory_install_read8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0x0dc00, 0x0dfff, 0, 0, rh8);
687      memory_install_write8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0x0dc00, 0x0dfff, 0, 0, wh9);
686      memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0dc00, 0x0dfff, 0, 0, rh8);
687      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0dc00, 0x0dfff, 0, 0, wh9);
688688   }
689689   else
690690   {
r2822r2823
707707         memory_set_bankptr (8, c64_memory + 0xdc00);
708708      }
709709   }
710   memory_install_read8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0x0d000, 0x0d7ff, 0, 0, rh4);
711   memory_install_write8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0x0d000, 0x0d7ff, 0, 0, wh5);
710   memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0d000, 0x0d7ff, 0, 0, rh4);
711   memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0d000, 0x0d7ff, 0, 0, wh5);
712712
713713   if (!c64_game && c64_exrom)
714714   {
r2822r2823
823823   c64mode = 0;
824824
825825   c64_rom_recognition ();
826   c64_rom_load();
826   c64_rom_load(machine);
827827
828828   c65_bankswitch_interface(0xff);
829   c65_bankswitch ();
829   c65_bankswitch (machine);
830830}
src/mess/machine/msx_slot.c
r2822r2823
2929
3030extern MSX msx1;
3131
32static void msx_cpu_setbank (int page, UINT8 *mem)
32static void msx_cpu_setbank (running_machine *machine, int page, UINT8 *mem)
3333{
3434   switch (page) {
3535   case 1:
r2822r2823
4040   case 4:
4141      memory_set_bankptr (4, mem);
4242      memory_set_bankptr (5, mem + 0x1ff8);
43      memory_install_read8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0x7ff8, 0x7fff, 0, 0, SMH_BANK5);
43      memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x7ff8, 0x7fff, 0, 0, SMH_BANK5);
4444      break;
4545   case 5:
4646      memory_set_bankptr (6, mem);
4747      memory_set_bankptr (7, mem + 0x1800);
48      memory_install_read8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0x9800, 0x9fff, 0, 0, SMH_BANK7);
48      memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x9800, 0x9fff, 0, 0, SMH_BANK7);
4949      break;
5050   case 6:
5151      memory_set_bankptr (8, mem);
5252      memory_set_bankptr (9, mem + 0x1800);
53      memory_install_read8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0xb800, 0xbfff, 0, 0, SMH_BANK9);
53      memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb800, 0xbfff, 0, 0, SMH_BANK9);
5454      break;
5555   case 7:
5656      memory_set_bankptr (10, mem);
r2822r2823
7676
7777MSX_SLOT_MAP(empty)
7878{
79   msx_cpu_setbank (page * 2 + 1, msx1.empty);
80   msx_cpu_setbank (page * 2 + 2, msx1.empty);
79   running_machine *machine = Machine;
80   msx_cpu_setbank (machine, page * 2 + 1, msx1.empty);
81   msx_cpu_setbank (machine, page * 2 + 2, msx1.empty);
8182}
8283
8384MSX_SLOT_INIT(rom)
r2822r2823
9798
9899MSX_SLOT_MAP(rom)
99100{
101   running_machine *machine = Machine;
100102   UINT8 *mem = state->mem + (page - state->start_page) * 0x4000;
101103
102   msx_cpu_setbank (page * 2 + 1, mem);
103   msx_cpu_setbank (page * 2 + 2, mem + 0x2000);
104   msx_cpu_setbank (machine, page * 2 + 1, mem);
105   msx_cpu_setbank (machine, page * 2 + 2, mem + 0x2000);
104106}
105107
106108MSX_SLOT_INIT(ram)
r2822r2823
116118
117119MSX_SLOT_MAP(ram)
118120{
121   running_machine *machine = Machine;
119122   UINT8 *mem = state->mem + (page - state->start_page) * 0x4000;
120123
121124   msx1.ram_pages[page] = mem;
122   msx_cpu_setbank (page * 2 + 1, mem);
123   msx_cpu_setbank (page * 2 + 2, mem + 0x2000);
125   msx_cpu_setbank (machine, page * 2 + 1, mem);
126   msx_cpu_setbank (machine, page * 2 + 2, mem + 0x2000);
124127}
125128
126129MSX_SLOT_RESET(ram)
r2822r2823
179182
180183MSX_SLOT_MAP(rammm)
181184{
185   running_machine *machine = Machine;
182186   UINT8 *mem = state->mem +
183187         0x4000 * (msx1.ram_mapper[page] & state->bank_mask);
184188
185189   msx1.ram_pages[page] = mem;
186   msx_cpu_setbank (page * 2 + 1, mem);
187   msx_cpu_setbank (page * 2 + 2, mem + 0x2000);
190   msx_cpu_setbank (machine, page * 2 + 1, mem);
191   msx_cpu_setbank (machine, page * 2 + 2, mem + 0x2000);
188192}
189193
190194MSX_SLOT_INIT(msxdos2)
r2822r2823
207211
208212MSX_SLOT_MAP(msxdos2)
209213{
214   running_machine *machine = Machine;
210215   if (page != 1) {
211      msx_cpu_setbank (page * 2 + 1, msx1.empty);
212      msx_cpu_setbank (page * 2 + 2, msx1.empty);
216      msx_cpu_setbank (machine, page * 2 + 1, msx1.empty);
217      msx_cpu_setbank (machine, page * 2 + 2, msx1.empty);
213218   } else {
214      msx_cpu_setbank (3, state->mem + state->banks[0] * 0x4000);
215      msx_cpu_setbank (4, state->mem + state->banks[0] * 0x4000 + 0x2000);
219      msx_cpu_setbank (machine, 3, state->mem + state->banks[0] * 0x4000);
220      msx_cpu_setbank (machine, 4, state->mem + state->banks[0] * 0x4000 + 0x2000);
216221   }
217222}
218223
r2822r2823
255260
256261MSX_SLOT_MAP(konami)
257262{
263   running_machine *machine = Machine;
258264   switch (page) {
259265   case 0:
260      msx_cpu_setbank (1, state->mem);
261      msx_cpu_setbank (2, state->mem + state->banks[1] * 0x2000);
266      msx_cpu_setbank (machine, 1, state->mem);
267      msx_cpu_setbank (machine, 2, state->mem + state->banks[1] * 0x2000);
262268      break;
263269   case 1:
264      msx_cpu_setbank (3, state->mem);
265      msx_cpu_setbank (4, state->mem + state->banks[1] * 0x2000);
270      msx_cpu_setbank (machine, 3, state->mem);
271      msx_cpu_setbank (machine, 4, state->mem + state->banks[1] * 0x2000);
266272      break;
267273   case 2:
268      msx_cpu_setbank (5, state->mem + state->banks[2] * 0x2000);
269      msx_cpu_setbank (6, state->mem + state->banks[3] * 0x2000);
274      msx_cpu_setbank (machine, 5, state->mem + state->banks[2] * 0x2000);
275      msx_cpu_setbank (machine, 6, state->mem + state->banks[3] * 0x2000);
270276      break;
271277   case 3:
272      msx_cpu_setbank (7, state->mem + state->banks[2] * 0x2000);
273      msx_cpu_setbank (8, state->mem + state->banks[3] * 0x2000);
278      msx_cpu_setbank (machine, 7, state->mem + state->banks[2] * 0x2000);
279      msx_cpu_setbank (machine, 8, state->mem + state->banks[3] * 0x2000);
274280   }
275281}
276282
r2822r2823
348354
349355MSX_SLOT_MAP(konami_scc)
350356{
357   running_machine *machine = Machine;
351358   switch (page) {
352359   case 0:
353      msx_cpu_setbank (1, state->mem + state->banks[2] * 0x2000);
354      msx_cpu_setbank (2, state->mem + state->banks[3] * 0x2000);
360      msx_cpu_setbank (machine, 1, state->mem + state->banks[2] * 0x2000);
361      msx_cpu_setbank (machine, 2, state->mem + state->banks[3] * 0x2000);
355362      break;
356363   case 1:
357      msx_cpu_setbank (3, state->mem + state->banks[0] * 0x2000);
358      msx_cpu_setbank (4, state->mem + state->banks[1] * 0x2000);
364      msx_cpu_setbank (machine, 3, state->mem + state->banks[0] * 0x2000);
365      msx_cpu_setbank (machine, 4, state->mem + state->banks[1] * 0x2000);
359366      break;
360367   case 2:
361      msx_cpu_setbank (5, state->mem + state->banks[2] * 0x2000);
362      msx_cpu_setbank (6, state->mem + state->banks[3] * 0x2000);
363      memory_install_read8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0x9800, 0x9fff, 0, 0,
368      msx_cpu_setbank (machine, 5, state->mem + state->banks[2] * 0x2000);
369      msx_cpu_setbank (machine, 6, state->mem + state->banks[3] * 0x2000);
370      memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x9800, 0x9fff, 0, 0,
364371            state->cart.scc.active ? konami_scc_bank5 : SMH_BANK7);
365372      break;
366373   case 3:
367      msx_cpu_setbank (7, state->mem + state->banks[0] * 0x2000);
368      msx_cpu_setbank (8, state->mem + state->banks[1] * 0x2000);
374      msx_cpu_setbank (machine, 7, state->mem + state->banks[0] * 0x2000);
375      msx_cpu_setbank (machine, 8, state->mem + state->banks[1] * 0x2000);
369376   }
370377}
371378
r2822r2823
459466
460467MSX_SLOT_MAP(ascii8)
461468{
469   running_machine *machine = Machine;
462470   switch (page) {
463471   case 0:
464      msx_cpu_setbank (1, msx1.empty);
465      msx_cpu_setbank (2, msx1.empty);
472      msx_cpu_setbank (machine, 1, msx1.empty);
473      msx_cpu_setbank (machine, 2, msx1.empty);
466474      break;
467475   case 1:
468      msx_cpu_setbank (3, state->mem + state->banks[0] * 0x2000);
469      msx_cpu_setbank (4, state->mem + state->banks[1] * 0x2000);
476      msx_cpu_setbank (machine, 3, state->mem + state->banks[0] * 0x2000);
477      msx_cpu_setbank (machine, 4, state->mem + state->banks[1] * 0x2000);
470478      break;
471479   case 2:
472      msx_cpu_setbank (5, state->mem + state->banks[2] * 0x2000);
473      msx_cpu_setbank (6, state->mem + state->banks[3] * 0x2000);
480      msx_cpu_setbank (machine, 5, state->mem + state->banks[2] * 0x2000);
481      msx_cpu_setbank (machine, 6, state->mem + state->banks[3] * 0x2000);
474482      break;
475483   case 3:
476      msx_cpu_setbank (7, msx1.empty);
477      msx_cpu_setbank (8, msx1.empty);
484      msx_cpu_setbank (machine, 7, msx1.empty);
485      msx_cpu_setbank (machine, 8, msx1.empty);
478486   }
479487}
480488
r2822r2823
526534
527535MSX_SLOT_MAP(ascii16)
528536{
537   running_machine *machine = Machine;
529538   UINT8 *mem;
530539
531540   switch (page) {
532541   case 0:
533      msx_cpu_setbank (1, msx1.empty);
534      msx_cpu_setbank (2, msx1.empty);
542      msx_cpu_setbank (machine, 1, msx1.empty);
543      msx_cpu_setbank (machine, 2, msx1.empty);
535544      break;
536545   case 1:
537546      mem = state->mem + state->banks[0] * 0x4000;
538      msx_cpu_setbank (3, mem);
539      msx_cpu_setbank (4, mem + 0x2000);
547      msx_cpu_setbank (machine, 3, mem);
548      msx_cpu_setbank (machine, 4, mem + 0x2000);
540549      break;
541550   case 2:
542551      mem = state->mem + state->banks[1] * 0x4000;
543      msx_cpu_setbank (5, mem);
544      msx_cpu_setbank (6, mem + 0x2000);
552      msx_cpu_setbank (machine, 5, mem);
553      msx_cpu_setbank (machine, 6, mem + 0x2000);
545554      break;
546555   case 3:
547      msx_cpu_setbank (7, msx1.empty);
548      msx_cpu_setbank (8, msx1.empty);
556      msx_cpu_setbank (machine, 7, msx1.empty);
557      msx_cpu_setbank (machine, 8, msx1.empty);
549558   }
550559}
551560
r2822r2823
617626
618627MSX_SLOT_MAP(ascii8_sram)
619628{
629   running_machine *machine = Machine;
620630   switch (page) {
621631   case 0:
622      msx_cpu_setbank (1, msx1.empty);
623      msx_cpu_setbank (2, msx1.empty);
632      msx_cpu_setbank (machine, 1, msx1.empty);
633      msx_cpu_setbank (machine, 2, msx1.empty);
624634      break;
625635   case 1:
626      msx_cpu_setbank (3, ascii8_sram_bank_select (state, 0));
627      msx_cpu_setbank (4, ascii8_sram_bank_select (state, 1));
636      msx_cpu_setbank (machine, 3, ascii8_sram_bank_select (state, 0));
637      msx_cpu_setbank (machine, 4, ascii8_sram_bank_select (state, 1));
628638      break;
629639   case 2:
630      msx_cpu_setbank (5, ascii8_sram_bank_select (state, 2));
631      msx_cpu_setbank (6, ascii8_sram_bank_select (state, 3));
640      msx_cpu_setbank (machine, 5, ascii8_sram_bank_select (state, 2));
641      msx_cpu_setbank (machine, 6, ascii8_sram_bank_select (state, 3));
632642      break;
633643   case 3:
634      msx_cpu_setbank (7, msx1.empty);
635      msx_cpu_setbank (8, msx1.empty);
644      msx_cpu_setbank (machine, 7, msx1.empty);
645      msx_cpu_setbank (machine, 8, msx1.empty);
636646   }
637647}
638648
r2822r2823
768778
769779MSX_SLOT_MAP(ascii16_sram)
770780{
781   running_machine *machine = Machine;
771782   UINT8 *mem;
772783
773784   switch (page) {
774785   case 0:
775      msx_cpu_setbank (1, msx1.empty);
776      msx_cpu_setbank (2, msx1.empty);
786      msx_cpu_setbank (machine, 1, msx1.empty);
787      msx_cpu_setbank (machine, 2, msx1.empty);
777788      break;
778789   case 1:
779790      mem = ascii16_sram_bank_select (state, 0);
780      msx_cpu_setbank (3, mem);
781      msx_cpu_setbank (4, mem + 0x2000);
791      msx_cpu_setbank (machine, 3, mem);
792      msx_cpu_setbank (machine, 4, mem + 0x2000);
782793      break;
783794   case 2:
784795      mem = ascii16_sram_bank_select (state, 1);
785      msx_cpu_setbank (5, mem);
786      msx_cpu_setbank (6, mem + 0x2000);
796      msx_cpu_setbank (machine, 5, mem);
797      msx_cpu_setbank (machine, 6, mem + 0x2000);
787798      break;
788799   case 3:
789      msx_cpu_setbank (7, msx1.empty);
790      msx_cpu_setbank (8, msx1.empty);
800      msx_cpu_setbank (machine, 7, msx1.empty);
801      msx_cpu_setbank (machine, 8, msx1.empty);
791802   }
792803}
793804
r2822r2823
903914
904915MSX_SLOT_MAP(rtype)
905916{
917   running_machine *machine = Machine;
906918   UINT8 *mem;
907919
908920   switch (page) {
909921   case 0:
910      msx_cpu_setbank (1, msx1.empty);
911      msx_cpu_setbank (2, msx1.empty);
922      msx_cpu_setbank (machine, 1, msx1.empty);
923      msx_cpu_setbank (machine, 2, msx1.empty);
912924      break;
913925   case 1:
914926      mem = state->mem + 15 * 0x4000;
915      msx_cpu_setbank (3, mem);
916      msx_cpu_setbank (4, mem + 0x2000);
927      msx_cpu_setbank (machine, 3, mem);
928      msx_cpu_setbank (machine, 4, mem + 0x2000);
917929      break;
918930   case 2:
919931      mem = state->mem + state->banks[0] * 0x4000;
920      msx_cpu_setbank (5, mem);
921      msx_cpu_setbank (6, mem + 0x2000);
932      msx_cpu_setbank (machine, 5, mem);
933      msx_cpu_setbank (machine, 6, mem + 0x2000);
922934      break;
923935   case 3:
924      msx_cpu_setbank (7, msx1.empty);
925      msx_cpu_setbank (8, msx1.empty);
936      msx_cpu_setbank (machine, 7, msx1.empty);
937      msx_cpu_setbank (machine, 8, msx1.empty);
926938   }
927939}
928940
r2822r2823
978990
979991MSX_SLOT_MAP(gmaster2)
980992{
993   running_machine *machine = Machine;
981994   switch (page) {
982995   case 0:
983996   case 1:
984      msx_cpu_setbank (1 + page * 2, state->mem); /* bank 0 is hardwired */
997      msx_cpu_setbank (machine, 1 + page * 2, state->mem); /* bank 0 is hardwired */
985998      if (state->banks[1] > 15) {
986         msx_cpu_setbank (2 + page * 2, state->cart.sram.mem +
999         msx_cpu_setbank (machine, 2 + page * 2, state->cart.sram.mem +
9871000               (state->banks[1] - 16) * 0x2000);
9881001      }
9891002      else {
990         msx_cpu_setbank (2 + page * 2, state->mem + state->banks[1] * 0x2000);
1003         msx_cpu_setbank (machine, 2 + page * 2, state->mem + state->banks[1] * 0x2000);
9911004      }
9921005      break;
9931006   case 2:
9941007   case 3:
9951008      if (state->banks[2] > 15) {
996         msx_cpu_setbank (5 + page * 2, state->cart.sram.mem +
1009         msx_cpu_setbank (machine, 5 + page * 2, state->cart.sram.mem +
9971010               (state->banks[2] - 16) * 0x2000);
9981011      }
9991012      else {
1000         msx_cpu_setbank (5 + page * 2, state->mem + state->banks[2] * 0x2000);
1013         msx_cpu_setbank (machine, 5 + page * 2, state->mem + state->banks[2] * 0x2000);
10011014      }
10021015      if (state->banks[3] > 15) {
1003         msx_cpu_setbank (6 + page * 2, state->cart.sram.mem +
1016         msx_cpu_setbank (machine, 6 + page * 2, state->cart.sram.mem +
10041017               (state->banks[3] - 16) * 0x2000);
10051018      }
10061019      else {
1007         msx_cpu_setbank (6 + page * 2, state->mem + state->banks[3] * 0x2000);
1020         msx_cpu_setbank (machine, 6 + page * 2, state->mem + state->banks[3] * 0x2000);
10081021      }
10091022      break;
10101023   }
r2822r2823
11301143
11311144MSX_SLOT_RESET(diskrom)
11321145{
1133   wd17xx_reset ();
1146   wd17xx_reset (machine);
11341147}
11351148
1136static READ8_HANDLER (msx_diskrom_page1_r)
1149static READ8_HANDLER (msx_diskrom_page1_r)
11371150{
11381151   switch (offset) {
11391152   case 0: return wd17xx_status_r (machine, 0);
r2822r2823
11461159   }
11471160}
11481161
1149static READ8_HANDLER (msx_diskrom_page2_r)
1162static READ8_HANDLER (msx_diskrom_page2_r)
11501163{
11511164   if (offset >= 0x7f8) {
11521165      switch (offset) {
r2822r2823
11711184
11721185MSX_SLOT_MAP(diskrom)
11731186{
1187   running_machine *machine = Machine;
11741188   switch (page) {
11751189   case 0:
1176      msx_cpu_setbank (1, msx1.empty);
1177      msx_cpu_setbank (2, msx1.empty);
1190      msx_cpu_setbank (machine, 1, msx1.empty);
1191      msx_cpu_setbank (machine, 2, msx1.empty);
11781192      break;
11791193   case 1:
1180      msx_cpu_setbank (3, state->mem);
1181      msx_cpu_setbank (4, state->mem + 0x2000);
1182      memory_install_read8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0x7ff8, 0x7fff, 0, 0, msx_diskrom_page1_r);
1194      msx_cpu_setbank (machine, 3, state->mem);
1195      msx_cpu_setbank (machine, 4, state->mem + 0x2000);
1196      memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x7ff8, 0x7fff, 0, 0, msx_diskrom_page1_r);
11831197      break;
11841198   case 2:
1185      msx_cpu_setbank (5, msx1.empty);
1186      msx_cpu_setbank (6, msx1.empty);
1187      memory_install_read8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0xb800, 0xbfff, 0, 0, msx_diskrom_page2_r);
1199      msx_cpu_setbank (machine, 5, msx1.empty);
1200      msx_cpu_setbank (machine, 6, msx1.empty);
1201      memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb800, 0xbfff, 0, 0, msx_diskrom_page2_r);
11881202      break;
11891203   case 3:
1190      msx_cpu_setbank (7, msx1.empty);
1191      msx_cpu_setbank (8, msx1.empty);
1204      msx_cpu_setbank (machine, 7, msx1.empty);
1205      msx_cpu_setbank (machine, 8, msx1.empty);
11921206      break;
11931207   }
11941208}
r2822r2823
12431257
12441258MSX_SLOT_RESET(diskrom2)
12451259{
1246   wd17xx_reset ();
1260   wd17xx_reset (machine);
12471261}
12481262
12491263static READ8_HANDLER (msx_diskrom2_page1_r)
r2822r2823
12841298
12851299MSX_SLOT_MAP(diskrom2)
12861300{
1301   running_machine *machine = Machine;
12871302   switch (page) {
12881303   case 0:
1289      msx_cpu_setbank (1, msx1.empty);
1290      msx_cpu_setbank (2, msx1.empty);
1304      msx_cpu_setbank (machine, 1, msx1.empty);
1305      msx_cpu_setbank (machine, 2, msx1.empty);
12911306      break;
12921307   case 1:
1293      msx_cpu_setbank (3, state->mem);
1294      msx_cpu_setbank (4, state->mem + 0x2000);
1295      memory_install_read8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0x7fb8, 0x7fbc, 0, 0, msx_diskrom2_page1_r);
1308      msx_cpu_setbank (machine, 3, state->mem);
1309      msx_cpu_setbank (machine, 4, state->mem + 0x2000);
1310      memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x7fb8, 0x7fbc, 0, 0, msx_diskrom2_page1_r);
12961311      break;
12971312   case 2:
1298      msx_cpu_setbank (5, msx1.empty);
1299      msx_cpu_setbank (6, msx1.empty);
1300      memory_install_read8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0xb800, 0xbfbc, 0, 0, msx_diskrom2_page2_r);
1313      msx_cpu_setbank (machine, 5, msx1.empty);
1314      msx_cpu_setbank (machine, 6, msx1.empty);
1315      memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb800, 0xbfbc, 0, 0, msx_diskrom2_page2_r);
13011316      break;
13021317   case 3:
1303      msx_cpu_setbank (7, msx1.empty);
1304      msx_cpu_setbank (8, msx1.empty);
1318      msx_cpu_setbank (machine, 7, msx1.empty);
1319      msx_cpu_setbank (machine, 8, msx1.empty);
13051320   }
13061321}
13071322
r2822r2823
13571372
13581373MSX_SLOT_MAP(synthesizer)
13591374{
1375   running_machine *machine = Machine;
13601376   switch (page) {
13611377   case 0:
1362      msx_cpu_setbank (1, msx1.empty);
1363      msx_cpu_setbank (2, msx1.empty);
1378      msx_cpu_setbank (machine, 1, msx1.empty);
1379      msx_cpu_setbank (machine, 2, msx1.empty);
13641380      break;
13651381   case 1:
1366      msx_cpu_setbank (3, state->mem);
1367      msx_cpu_setbank (4, state->mem + 0x2000);
1382      msx_cpu_setbank (machine, 3, state->mem);
1383      msx_cpu_setbank (machine, 4, state->mem + 0x2000);
13681384      break;
13691385   case 2:
1370      msx_cpu_setbank (5, state->mem + 0x4000);
1371      msx_cpu_setbank (6, state->mem + 0x6000);
1386      msx_cpu_setbank (machine, 5, state->mem + 0x4000);
1387      msx_cpu_setbank (machine, 6, state->mem + 0x6000);
13721388      break;
13731389   case 3:
1374      msx_cpu_setbank (7, msx1.empty);
1375      msx_cpu_setbank (8, msx1.empty);
1390      msx_cpu_setbank (machine, 7, msx1.empty);
1391      msx_cpu_setbank (machine, 8, msx1.empty);
13761392   }
13771393}
13781394
r2822r2823
14081424
14091425MSX_SLOT_MAP(majutsushi)
14101426{
1427   running_machine *machine = Machine;
14111428   switch (page) {
14121429   case 0:
1413      msx_cpu_setbank (1, state->mem + state->banks[0] * 0x2000);
1414      msx_cpu_setbank (2, state->mem + state->banks[1] * 0x2000);
1430      msx_cpu_setbank (machine, 1, state->mem + state->banks[0] * 0x2000);
1431      msx_cpu_setbank (machine, 2, state->mem + state->banks[1] * 0x2000);
14151432      break;
14161433   case 1:
1417      msx_cpu_setbank (3, state->mem + state->banks[0] * 0x2000);
1418      msx_cpu_setbank (4, state->mem + state->banks[1] * 0x2000);
1434      msx_cpu_setbank (machine, 3, state->mem + state->banks[0] * 0x2000);
1435      msx_cpu_setbank (machine, 4, state->mem + state->banks[1] * 0x2000);
14191436      break;
14201437   case 2:
1421      msx_cpu_setbank (5, state->mem + state->banks[2] * 0x2000);
1422      msx_cpu_setbank (6, state->mem + state->banks[3] * 0x2000);
1438      msx_cpu_setbank (machine, 5, state->mem + state->banks[2] * 0x2000);
1439      msx_cpu_setbank (machine, 6, state->mem + state->banks[3] * 0x2000);
14231440      break;
14241441   case 3:
1425      msx_cpu_setbank (5, state->mem + state->banks[2] * 0x2000);
1426      msx_cpu_setbank (8, state->mem + state->banks[3] * 0x2000);
1442      msx_cpu_setbank (machine, 7, state->mem + state->banks[2] * 0x2000);
1443      msx_cpu_setbank (machine, 8, state->mem + state->banks[3] * 0x2000);
14271444      break;
14281445   }
14291446}
r2822r2823
15121529
15131530MSX_SLOT_MAP(fmpac)
15141531{
1532   running_machine *machine = Machine;
15151533   if (page == 1) {
15161534      if (state->cart.fmpac.sram_active) {
1517         msx_cpu_setbank (3, state->cart.fmpac.mem);
1518         msx_cpu_setbank (4, state->cart.fmpac.mem + 0x2000);
1535         msx_cpu_setbank (machine, 3, state->cart.fmpac.mem);
1536         msx_cpu_setbank (machine, 4, state->cart.fmpac.mem + 0x2000);
15191537      }
15201538      else {
1521         msx_cpu_setbank (3, state->mem + state->banks[0] * 0x4000);
1522         msx_cpu_setbank (4, state->mem + state->banks[0] * 0x4000 + 0x2000);
1539         msx_cpu_setbank (machine, 3, state->mem + state->banks[0] * 0x4000);
1540         msx_cpu_setbank (machine, 4, state->mem + state->banks[0] * 0x4000 + 0x2000);
15231541      }
15241542   }
15251543   else {
1526      msx_cpu_setbank (page * 2 + 1, msx1.empty);
1527      msx_cpu_setbank (page * 2 + 2, msx1.empty);
1544      msx_cpu_setbank (machine, page * 2 + 1, msx1.empty);
1545      msx_cpu_setbank (machine, page * 2 + 2, msx1.empty);
15281546   }
15291547}
15301548
r2822r2823
16671685
16681686MSX_SLOT_MAP(superloadrunner)
16691687{
1688   running_machine *machine = Machine;
16701689   if (page == 2) {
16711690      UINT8 *mem = state->mem +
16721691            (msx1.superloadrunner_bank & state->bank_mask) * 0x4000;
16731692
1674      msx_cpu_setbank (5, mem);
1675      msx_cpu_setbank (6, mem + 0x2000);
1693      msx_cpu_setbank (machine, 5, mem);
1694      msx_cpu_setbank (machine, 6, mem + 0x2000);
16761695   }
16771696   else {
1678      msx_cpu_setbank (page * 2 + 1, msx1.empty);
1679      msx_cpu_setbank (page * 2 + 2, msx1.empty);
1697      msx_cpu_setbank (machine, page * 2 + 1, msx1.empty);
1698      msx_cpu_setbank (machine, page * 2 + 2, msx1.empty);
16801699   }
16811700}
16821701
r2822r2823
17001719
17011720MSX_SLOT_MAP(crossblaim)
17021721{
1722   running_machine *machine = Machine;
17031723   UINT8 *mem;
17041724
17051725   /* This might look odd, but it's what happens on the real cartridge */
r2822r2823
17081728   case 0:
17091729      if (state->banks[0] < 2){
17101730         mem = state->mem + state->banks[0] * 0x4000;
1711         msx_cpu_setbank (1, mem);
1712         msx_cpu_setbank (2, mem + 0x2000);
1731         msx_cpu_setbank (machine, 1, mem);
1732         msx_cpu_setbank (machine, 2, mem + 0x2000);
17131733      } else {
1714         msx_cpu_setbank (1, msx1.empty);
1715         msx_cpu_setbank (2, msx1.empty);
1734         msx_cpu_setbank (machine, 1, msx1.empty);
1735         msx_cpu_setbank (machine, 2, msx1.empty);
17161736      }
17171737      break;
17181738   case 1:
1719      msx_cpu_setbank (3, state->mem);
1720      msx_cpu_setbank (4, state->mem + 0x2000);
1739      msx_cpu_setbank (machine, 3, state->mem);
1740      msx_cpu_setbank (machine, 4, state->mem + 0x2000);
17211741      break;
17221742   case 2:
17231743      mem = state->mem + state->banks[0] * 0x4000;
1724      msx_cpu_setbank (5, mem);
1725      msx_cpu_setbank (6, mem + 0x2000);
1744      msx_cpu_setbank (machine, 5, mem);
1745      msx_cpu_setbank (machine, 6, mem + 0x2000);
17261746      break;
17271747   case 3:
17281748      if (state->banks[0] < 2){
17291749         mem = state->mem + state->banks[0] * 0x4000;
1730         msx_cpu_setbank (7, mem);
1731         msx_cpu_setbank (8, mem + 0x2000);
1750         msx_cpu_setbank (machine, 7, mem);
1751         msx_cpu_setbank (machine, 8, mem + 0x2000);
17321752      } else {
1733         msx_cpu_setbank (7, msx1.empty);
1734         msx_cpu_setbank (8, msx1.empty);
1753         msx_cpu_setbank (machine, 7, msx1.empty);
1754         msx_cpu_setbank (machine, 8, msx1.empty);
17351755      }
17361756   }
17371757}
r2822r2823
17861806
17871807MSX_SLOT_MAP(korean80in1)
17881808{
1809   running_machine *machine = Machine;
17891810   switch (page) {
17901811   case 0:
1791      msx_cpu_setbank (1, msx1.empty);
1792      msx_cpu_setbank (2, msx1.empty);
1812      msx_cpu_setbank (machine, 1, msx1.empty);
1813      msx_cpu_setbank (machine, 2, msx1.empty);
17931814      break;
17941815   case 1:
1795      msx_cpu_setbank (3, state->mem + state->banks[0] * 0x2000);
1796      msx_cpu_setbank (4, state->mem + state->banks[1] * 0x2000);
1816      msx_cpu_setbank (machine, 3, state->mem + state->banks[0] * 0x2000);
1817      msx_cpu_setbank (machine, 4, state->mem + state->banks[1] * 0x2000);
17971818      break;
17981819   case 2:
1799      msx_cpu_setbank (5, state->mem + state->banks[2] * 0x2000);
1800      msx_cpu_setbank (6, state->mem + state->banks[3] * 0x2000);
1820      msx_cpu_setbank (machine, 5, state->mem + state->banks[2] * 0x2000);
1821      msx_cpu_setbank (machine, 6, state->mem + state->banks[3] * 0x2000);
18011822      break;
18021823   case 3:
1803      msx_cpu_setbank (7, msx1.empty);
1804      msx_cpu_setbank (8, msx1.empty);
1824      msx_cpu_setbank (machine, 7, msx1.empty);
1825      msx_cpu_setbank (machine, 8, msx1.empty);
18051826   }
18061827}
18071828
r2822r2823
18501871
18511872MSX_SLOT_MAP(korean90in1)
18521873{
1874   running_machine *machine = Machine;
18531875   UINT8 *mem;
18541876   UINT8 mask = (msx1.korean90in1_bank & 0xc0) == 0x80 ? 0x3e : 0x3f;
18551877   mem = state->mem +
r2822r2823
18571879
18581880   switch (page) {
18591881   case 0:
1860      msx_cpu_setbank (1, msx1.empty);
1861      msx_cpu_setbank (2, msx1.empty);
1882      msx_cpu_setbank (machine, 1, msx1.empty);
1883      msx_cpu_setbank (machine, 2, msx1.empty);
18621884      break;
18631885   case 1:
1864      msx_cpu_setbank (3, mem);
1865      msx_cpu_setbank (4, mem + 0x2000);
1886      msx_cpu_setbank (machine, 3, mem);
1887      msx_cpu_setbank (machine, 4, mem + 0x2000);
18661888      break;
18671889   case 2:
18681890      switch (msx1.korean90in1_bank & 0xc0) {
18691891      case 0x80: /* 32 kb mode */
18701892         mem += 0x4000;
18711893      default: /* ie. 0x00 and 0x40: same memory as page 1 */
1872         msx_cpu_setbank (5, mem);
1873         msx_cpu_setbank (6, mem + 0x2000);
1894         msx_cpu_setbank (machine, 5, mem);
1895         msx_cpu_setbank (machine, 6, mem + 0x2000);
18741896         break;
18751897      case 0xc0: /* same memory as page 1, but swap lower/upper 8kb */
1876         msx_cpu_setbank (5, mem + 0x2000);
1877         msx_cpu_setbank (6, mem);
1898         msx_cpu_setbank (machine, 5, mem + 0x2000);
1899         msx_cpu_setbank (machine, 6, mem);
18781900         break;
18791901      }
18801902      break;
18811903   case 3:
1882      msx_cpu_setbank (7, msx1.empty);
1883      msx_cpu_setbank (8, msx1.empty);
1904      msx_cpu_setbank (machine, 7, msx1.empty);
1905      msx_cpu_setbank (machine, 8, msx1.empty);
18841906   }
18851907}
18861908
r2822r2823
19151937
19161938MSX_SLOT_MAP(korean126in1)
19171939{
1940   running_machine *machine = Machine;
19181941   UINT8 *mem;
19191942
19201943   switch (page) {
19211944   case 0:
1922      msx_cpu_setbank (1, msx1.empty);
1923      msx_cpu_setbank (2, msx1.empty);
1945      msx_cpu_setbank (machine, 1, msx1.empty);
1946      msx_cpu_setbank (machine, 2, msx1.empty);
19241947      break;
19251948   case 1:
19261949      mem = state->mem + state->banks[0] * 0x4000;
1927      msx_cpu_setbank (3, mem);
1928      msx_cpu_setbank (4, mem + 0x2000);
1950      msx_cpu_setbank (machine, 3, mem);
1951      msx_cpu_setbank (machine, 4, mem + 0x2000);
19291952      break;
19301953   case 2:
19311954      mem = state->mem + state->banks[1] * 0x4000;
1932      msx_cpu_setbank (5, mem);
1933      msx_cpu_setbank (6, mem + 0x2000);
1955      msx_cpu_setbank (machine, 5, mem);
1956      msx_cpu_setbank (machine, 6, mem + 0x2000);
19341957      break;
19351958   case 3:
1936      msx_cpu_setbank (7, msx1.empty);
1937      msx_cpu_setbank (8, msx1.empty);
1959      msx_cpu_setbank (machine, 7, msx1.empty);
1960      msx_cpu_setbank (machine, 8, msx1.empty);
19381961   }
19391962}
19401963
r2822r2823
20372060
20382061MSX_SLOT_MAP(soundcartridge)
20392062{
2063   running_machine *machine = Machine;
20402064   switch (page) {
20412065   case 0:
2042      msx_cpu_setbank (1, state->mem + state->banks[2] * 0x2000);
2043      msx_cpu_setbank (2, state->mem + state->banks[3] * 0x2000);
2066      msx_cpu_setbank (machine, 1, state->mem + state->banks[2] * 0x2000);
2067      msx_cpu_setbank (machine, 2, state->mem + state->banks[3] * 0x2000);
20442068      break;
20452069   case 1:
2046      msx_cpu_setbank (3, state->mem + state->banks[0] * 0x2000);
2047      msx_cpu_setbank (4, state->mem + state->banks[1] * 0x2000);
2070      msx_cpu_setbank (machine, 3, state->mem + state->banks[0] * 0x2000);
2071      msx_cpu_setbank (machine, 4, state->mem + state->banks[1] * 0x2000);
20482072      break;
20492073   case 2:
2050      msx_cpu_setbank (5, state->mem + state->banks[2] * 0x2000);
2051      msx_cpu_setbank (6, state->mem + state->banks[3] * 0x2000);
2052      memory_install_read8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0x9800, 0x9fff, 0, 0,
2074      msx_cpu_setbank (machine, 5, state->mem + state->banks[2] * 0x2000);
2075      msx_cpu_setbank (machine, 6, state->mem + state->banks[3] * 0x2000);
2076      memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x9800, 0x9fff, 0, 0,
20532077         state->cart.sccp.scc_active ? soundcartridge_scc : SMH_BANK7);
2054      memory_install_read8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0xb800, 0xbfff, 0, 0,
2078      memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb800, 0xbfff, 0, 0,
20552079         state->cart.sccp.sccp_active ? soundcartridge_sccp : SMH_BANK9);
20562080      break;
20572081   case 3:
2058      msx_cpu_setbank (7, state->mem + state->banks[0] * 0x2000);
2059      msx_cpu_setbank (8, state->mem + state->banks[1] * 0x2000);
2082      msx_cpu_setbank (machine, 7, state->mem + state->banks[0] * 0x2000);
2083      msx_cpu_setbank (machine, 8, state->mem + state->banks[1] * 0x2000);
20602084      break;
20612085   }
20622086}
src/mess/machine/coco.c
r2822r2823
170170static WRITE8_HANDLER ( dragon64_pia1_pb_w );
171171
172172/* Dragon 64 / Alpha shared */
173static void dragon_page_rom(int   romswitch);
173static void dragon_page_rom(running_machine *machine, int romswitch);
174174
175175/* Dragon Alpha specific */
176176static WRITE8_HANDLER ( dgnalpha_pia2_pa_w );
r2822r2823
979979   which input device, if any, it is hooked up to
980980-------------------------------------------------*/
981981
982static coco_input_device get_input_device(coco_input_port port)
982static coco_input_device get_input_device(running_machine *machine, coco_input_port port)
983983{
984984   coco_input_device result = INPUTDEVICE_NA;
985985
986   switch(input_port_read_safe(Machine, "joystick_mode", 0x00))
986   switch(input_port_read_safe(machine, "joystick_mode", 0x00))
987987   {
988988      case 0x00:
989989         /* "Normal" */
r2822r2823
10551055static attotime coco_hiresjoy_xtransitiontime;
10561056static attotime coco_hiresjoy_ytransitiontime;
10571057
1058static attotime coco_hiresjoy_computetransitiontime(const char *inputport)
1058static attotime coco_hiresjoy_computetransitiontime(running_machine *machine, const char *inputport)
10591059{
10601060   double val;
10611061
1062   val = input_port_read_safe(Machine, inputport, 0) / 255.0;
1062   val = input_port_read_safe(machine, inputport, 0) / 255.0;
10631063
1064   if (get_input_device(INPUTPORT_RIGHT_JOYSTICK) == INPUTDEVICE_HIRES_CC3MAX_INTERFACE)
1064   if (get_input_device(machine, INPUTPORT_RIGHT_JOYSTICK) == INPUTDEVICE_HIRES_CC3MAX_INTERFACE)
10651065   {
10661066      /* CoCo MAX 3 Interface */
10671067      val = val * 2500.0 + 400.0;
r2822r2823
10801080   if (!data && coco_hiresjoy_ca)
10811081   {
10821082      /* Hi to lo */
1083      coco_hiresjoy_xtransitiontime = coco_hiresjoy_computetransitiontime("joystick_right_x");
1084      coco_hiresjoy_ytransitiontime = coco_hiresjoy_computetransitiontime("joystick_right_y");
1083      coco_hiresjoy_xtransitiontime = coco_hiresjoy_computetransitiontime(machine, "joystick_right_x");
1084      coco_hiresjoy_ytransitiontime = coco_hiresjoy_computetransitiontime(machine, "joystick_right_y");
10851085   }
10861086   else if (data && !coco_hiresjoy_ca)
10871087   {
r2822r2823
11381138   return image_from_devtype_and_index(IO_CASSETTE, 0);
11391139}
11401140
1141static const device_config *bitbanger_image(void)
1141static const device_config *bitbanger_image(running_machine *machine)
11421142{
1143   return device_list_find_by_tag(Machine->config->devicelist, BITBANGER, "bitbanger");
1143   return device_list_find_by_tag(machine->config->devicelist, BITBANGER, "bitbanger");
11441144}
11451145
11461146static const device_config *printer_image(void)
r2822r2823
13261326   if ((input_port_read(machine, "row5") | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x20;
13271327   if ((input_port_read(machine, "row6") | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x40;
13281328
1329   switch(get_input_device(joystick ? INPUTPORT_LEFT_JOYSTICK : INPUTPORT_RIGHT_JOYSTICK))
1329   switch(get_input_device(machine, joystick ? INPUTPORT_LEFT_JOYSTICK : INPUTPORT_RIGHT_JOYSTICK))
13301330   {
13311331      case INPUTDEVICE_RIGHT_JOYSTICK:
13321332         joyval = input_port_read_safe(machine, joystick_axis ? "joystick_right_y" : "joystick_right_x", 0x00);
r2822r2823
14191419
14201420static WRITE8_HANDLER ( d_pia0_pa_w )
14211421{
1422   if (get_input_device(INPUTPORT_RIGHT_JOYSTICK) == INPUTDEVICE_HIRES_CC3MAX_INTERFACE)
1422   if (get_input_device(machine, INPUTPORT_RIGHT_JOYSTICK) == INPUTDEVICE_HIRES_CC3MAX_INTERFACE)
14231423      coco_hiresjoy_w(machine, data & 0x04);
14241424}
14251425
r2822r2823
14561456/* Printer output for the CoCo, output to bitbanger port */
14571457static void printer_out_coco(int data)
14581458{
1459   bitbanger_output(bitbanger_image(), (data & 2) >> 1);
1459   bitbanger_output(bitbanger_image(Machine), (data & 2) >> 1);
14601460}
14611461
14621462/* Printer output for the Dragon, output to Paralel port */
r2822r2823
14831483
14841484   coco_sound_update();
14851485
1486   if (get_input_device(INPUTPORT_SERIAL) == INPUTDEVICE_DIECOM_LIGHTGUN)
1486   if (get_input_device(machine, INPUTPORT_SERIAL) == INPUTDEVICE_DIECOM_LIGHTGUN)
14871487   {
14881488      int dclg_this_bit = ((data & 2) >> 1);
14891489
r2822r2823
15311531
15321532   (*update_keyboard)(machine);
15331533
1534   if (get_input_device(INPUTPORT_RIGHT_JOYSTICK) == INPUTDEVICE_HIRES_INTERFACE)
1534   if (get_input_device(machine, INPUTPORT_RIGHT_JOYSTICK) == INPUTDEVICE_HIRES_INTERFACE)
15351535      coco_hiresjoy_w(machine, dac >= 0x80);
15361536
15371537   /* Handle printer output, serial for CoCos, Paralell for Dragons */
r2822r2823
15741574   /* always be high (enabling 32k basic rom) */
15751575   if (ddr & 0x04)
15761576   {
1577      dragon_page_rom(data & 0x04);
1577      dragon_page_rom(machine, data & 0x04);
15781578   }
15791579}
15801580
r2822r2823
15991599   /* always be high (enabling boot rom) */
16001600   /* PIA FIXME if (pia_get_ddr_a(2) & 0x04) */
16011601   {
1602      dragon_page_rom(data & 0x04);   /* bit 2 controls boot or basic rom */
1602      dragon_page_rom(machine, data & 0x04);   /* bit 2 controls boot or basic rom */
16031603   }
16041604
16051605   /* Bits 0 and 1 for pia2 port a control the BCDIR and BC1 lines of the */
r2822r2823
16251625/* Controls rom paging in Dragon 64, and Dragon Alpha */
16261626/* On 64, switches between the two versions of the basic rom mapped in at 0x8000 */
16271627/* on the alpha switches between the Boot/Diagnostic rom and the basic rom */
1628static void dragon_page_rom(int   romswitch)
1628static void dragon_page_rom(running_machine *machine, int romswitch)
16291629{
16301630   UINT8 *bank;
16311631
r2822r2823
16371637   bas_rom_bank = bank;         /* Record which rom we are using so that the irq routine */
16381638                  /* uses the vectors from the correct rom ! (alpha) */
16391639
1640   setup_memory_map(Machine);         /* Setup memory map as needed */
1640   setup_memory_map(machine);         /* Setup memory map as needed */
16411641}
16421642
16431643/********************************************************************************************/
r2822r2823
18401840      default   : bottom_32k=&mess_ram[0x00000]; break; // Just to shut the compiler up !
18411841   }
18421842
1843   setup_memory_map(Machine);
1843   setup_memory_map(machine);
18441844}
18451845
18461846
r2822r2823
22512251
22522252
22532253
2254static void coco3_mmu_update(int lowblock, int hiblock)
2254static void coco3_mmu_update(running_machine *machine, int lowblock, int hiblock)
22552255{
22562256   static const struct
22572257   {
r2822r2823
22922292
22932293      /* set up the banks */
22942294      memory_set_bankptr(i + 1, readbank);
2295      memory_install_write_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, bank_info[i].start, bank_info[i].end, 0, 0, writebank);
2295      memory_install_write_handler(machine, 0, ADDRESS_SPACE_PROGRAM, bank_info[i].start, bank_info[i].end, 0, 0, writebank);
22962296
22972297      if (LOG_MMU)
22982298      {
r2822r2823
23232323   if ((offset >> 3) == (coco3_gimereg[1] & 1))
23242324   {
23252325      offset &= 7;
2326      coco3_mmu_update(offset, (offset == 7) ? 8 : offset);
2326      coco3_mmu_update(machine, offset, (offset == 7) ? 8 : offset);
23272327   }
23282328}
23292329
r2822r2823
23932393         *        Bit 1 MC1 ROM map control
23942394         *        Bit 0 MC0 ROM map control
23952395         */
2396         coco3_mmu_update(0, 8);
2396         coco3_mmu_update(machine, 0, 8);
23972397         break;
23982398
23992399      case 1:
r2822r2823
24072407         *        Bit 1 Unused
24082408         *        Bit 0 TR Task register select
24092409         */
2410         coco3_mmu_update(0, 8);
2410         coco3_mmu_update(machine, 0, 8);
24112411         coco3_timer_reset();
24122412         break;
24132413
r2822r2823
25622562static void coco3_sam_set_maptype(int val)
25632563{
25642564   coco3_enable_64k = val;
2565   coco3_mmu_update(4, 8);
2565   coco3_mmu_update(Machine, 4, 8);
25662566}
25672567
25682568
r2822r2823
30673067      coco3_mmu[i] = coco3_mmu[i + 8] = 56 + i;
30683068      coco3_gimereg[i] = 0;
30693069   }
3070   coco3_mmu_update(0, 8);
3070   coco3_mmu_update(machine, 0, 8);
30713071}
30723072
30733073static STATE_POSTLOAD( coco3_state_postload )
30743074{
3075   coco3_mmu_update(0, 8);
3075   coco3_mmu_update(machine, 0, 8);
30763076}
30773077
30783078static void update_lightgun(running_machine *machine)
src/mess/machine/kim1.c
r2822r2823
88******************************************************************************/
99
1010#include "driver.h"
11#include "deprecat.h"
1211#include "cpu/m6502/m6502.h"
1312#include "includes/kim1.h"
1413#include "sound/dac.h"
r2822r2823
679678   }
680679}
681680
682INLINE int m6530_r(int chip, int offset)
681INLINE int m6530_r(running_machine *machine, int chip, int offset)
683682{
684683   int data = 0xff;
685   running_machine *machine = Machine;
686684
687685   switch (offset)
688686   {
r2822r2823
785783   return data;
786784}
787785
788 READ8_HANDLER ( m6530_003_r )
786READ8_HANDLER ( m6530_003_r )
789787{
790   return m6530_r(0, offset);
788   return m6530_r(machine, 0, offset);
791789}
792 READ8_HANDLER ( m6530_002_r )
790READ8_HANDLER ( m6530_002_r )
793791{
794   return m6530_r(1, offset);
792   return m6530_r(machine, 1, offset);
795793}
796794
797795static void m6530_w(int chip, int offset, int data)
src/mess/machine/99_dsk.c
r2822r2823
451451   use_80_track_drives = FALSE;
452452
453453   ti99_peb_set_card_handlers(0x1100, & fdc_handlers);
454   wd17xx_reset();      /* resets the fdc */
454   wd17xx_reset(machine);      /* resets the fdc */
455455   wd17xx_set_density(DEN_FM_LO);
456456}
457457
r2822r2823
644644   ccfdc_mem_w
645645};
646646
647void ti99_ccfdc_reset(void)
647#if HAS_99CCFDC
648void ti99_ccfdc_reset(running_machine *machine)
648649{
649650   ti99_disk_DSR = memory_region(region_dsr) + offset_ccfdc_dsr;
650651   DSEL = 0;
r2822r2823
658659
659660   ti99_peb_set_card_handlers(0x1100, & ccfdc_handlers);
660661
661   wd17xx_reset();      /* initialize the floppy disk controller */
662   wd17xx_reset(machine);      /* initialize the floppy disk controller */
662663   wd17xx_set_density(DEN_MFM_LO);
663664}
665#endif
664666
665667
666
667668/*
668669   Read disk CRU interface
669670
r2822r2823
874875       
875876   ti99_peb_set_card_handlers(0x1100, & bwg_handlers);
876877
877   wd17xx_reset();      /* initialize the floppy disk controller */
878   wd17xx_reset(machine);      /* initialize the floppy disk controller */
878879   wd17xx_set_density(DEN_MFM_LO);
879880}
880881
src/mess/machine/gamecom.c
r2822r2823
108108   }
109109}
110110
111static void handle_stylus_press( UINT8 column ) {
111static void handle_stylus_press( running_machine *machine, UINT8 column ) {
112112   static const UINT16 row_data[10] = { 0x3FE, 0x3FD, 0x3FB, 0x3F7, 0x3EF, 0x3DF, 0x3BF, 0x37F, 0x2FF, 0x1FF };
113113   static UINT32 stylus_x;
114114   static UINT32 stylus_y;
115115
116116   if ( column == 0 ) {
117      if ( ! ( input_port_read(Machine, "IN2") & 0x04 ) ) {
118         stylus_x = input_port_read(Machine, "IN3") >> 4;
119         stylus_y = input_port_read(Machine, "IN4") >> 4;
117      if ( ! ( input_port_read(machine, "IN2") & 0x04 ) ) {
118         stylus_x = input_port_read(machine, "IN3") >> 4;
119         stylus_y = input_port_read(machine, "IN4") >> 4;
120120      } else {
121121         stylus_x = 16;
122122         stylus_y = 16;
r2822r2823
159159                  /* P0 bit 7 cleared => */
160160                  /* P1 bit 0 cleared => */
161161                  /* P1 bit 1 cleared => */
162               handle_stylus_press( 0 );
162               handle_stylus_press( machine, 0 );
163163               break;
164164            case 0xF7FF:   /* column #1 */
165               handle_stylus_press( 1 );
165               handle_stylus_press( machine, 1 );
166166               break;
167167            case 0xEFFF:   /* column #2 */
168               handle_stylus_press( 2 );
168               handle_stylus_press( machine, 2 );
169169               break;
170170            case 0xDFFF:   /* column #3 */
171               handle_stylus_press( 3 );
171               handle_stylus_press( machine, 3 );
172172               break;
173173            case 0xBFFF:   /* column #4 */
174               handle_stylus_press( 4 );
174               handle_stylus_press( machine, 4 );
175175               break;
176176            case 0x7FFF:   /* column #5 */
177               handle_stylus_press( 5 );
177               handle_stylus_press( machine, 5 );
178178               break;
179179            case 0xFFFE:   /* column #6 */
180               handle_stylus_press( 6 );
180               handle_stylus_press( machine, 6 );
181181               break;
182182            case 0xFFFD:   /* column #7 */
183               handle_stylus_press( 7 );
183               handle_stylus_press( machine, 7 );
184184               break;
185185            case 0xFFFB:   /* column #8 */
186               handle_stylus_press( 8 );
186               handle_stylus_press( machine, 8 );
187187               break;
188188            case 0xFFF7:   /* column #9 */
189               handle_stylus_press( 9 );
189               handle_stylus_press( machine, 9 );
190190               break;
191191            case 0xFFEF:   /* column #10 */
192               handle_stylus_press( 10 );
192               handle_stylus_press( machine, 10 );
193193               break;
194194            case 0xFFDF:   /* column #11 */
195               handle_stylus_press( 11 );
195               handle_stylus_press( machine, 11 );
196196               break;
197197            case 0xFFBF:   /* column #12 */
198               handle_stylus_press( 12 );
198               handle_stylus_press( machine, 12 );
199199               break;
200200            case 0xFF7F:   /* keys #1 */
201201                  /* P0 bit 0 cleared => 83 (up) */
src/mess/machine/b2m.c
r2822r2823
403403
404404MACHINE_RESET(b2m)
405405{
406   wd17xx_reset();
406   wd17xx_reset(machine);
407407   msm8251_reset();
408408   
409409   b2m_side = 0;
src/mess/machine/74145.c
r2822r2823
4343 ****************************************************************************/
4444
4545#include "driver.h"
46#include "deprecat.h"
4746#include "74145.h"
4847
4948
r2822r2823
8988
9089
9190/* Config */
92void ttl74145_config(int which, const ttl74145_interface *intf)
91void ttl74145_config(running_machine *machine, int which, const ttl74145_interface *intf)
9392{
94   assert_always(mame_get_phase(Machine) == MAME_PHASE_INIT,
93   assert_always(mame_get_phase(machine) == MAME_PHASE_INIT,
9594      "Can only call ttl74145_config at init time!");
9695   assert_always(which < MAX_74145,
9796      "'which' exceeds maximum number of configured 74145s!");
src/mess/machine/thomson.c
r2822r2823
651651
652652
653653
654static void to7_io_reset( void )
654static void to7_io_reset( running_machine *machine )
655655{
656656   LOG (( "to7_io_reset called\n" ));
657657   thom_centronics_reset();
r2822r2823
835835   This is similar Atari & Amiga mouses.
836836   Returns: 0 0 0 0 0 0 YB XB YA XA
837837 */
838static UINT8 to7_get_mouse_signal( void )
838static UINT8 to7_get_mouse_signal( running_machine *machine )
839839{
840840   UINT8 xa, xb, ya, yb;
841   UINT16 dx = input_port_read(Machine, "mouse_x"); /* x axis */
842   UINT16 dy = input_port_read(Machine, "mouse_y"); /* y axis */
841   UINT16 dx = input_port_read(machine, "mouse_x"); /* x axis */
842   UINT16 dy = input_port_read(machine, "mouse_y"); /* y axis */
843843   xa = ((dx + 1) & 3) <= 1;
844844   xb = (dx & 3) <= 1;
845845   ya = ((dy + 1) & 3) <= 1;
r2822r2823
862862   if ( input_port_read(machine, "config") & 1 )
863863   {
864864      /* mouse */
865      data = to7_get_mouse_signal() & 0x0c;             /* XB, YB */
865      data = to7_get_mouse_signal(machine) & 0x0c;             /* XB, YB */
866866      data |= input_port_read(machine, "mouse_button") & 3; /* buttons */
867867   }
868868   else
r2822r2823
903903   if ( input_port_read(machine, "config") & 1 )
904904   {
905905      /* mouse */
906      UINT8 mouse =  to7_get_mouse_signal();
906      UINT8 mouse =  to7_get_mouse_signal(machine);
907907      data = 0;
908908      if ( mouse & 1 )
909909         data |= 0x04; /* XA */
r2822r2823
957957   if ( input_port_read(machine, "config") & 1 )
958958   {
959959      /* mouse */
960      UINT8 mouse = to7_get_mouse_signal();
960      UINT8 mouse = to7_get_mouse_signal(machine);
961961      pia_set_input_ca1( THOM_PIA_GAME, (mouse & 1) ? 1 : 0 ); /* XA */
962962      pia_set_input_ca2( THOM_PIA_GAME, (mouse & 2) ? 1 : 0 ); /* YA */
963963   }
r2822r2823
12711271   mc6846_reset();
12721272   to7_game_reset();
12731273   to7_floppy_reset(machine);
1274   to7_io_reset();
1274   to7_io_reset(machine);
12751275   to7_modem_reset();
12761276   to7_midi_reset();
12771277   to7_rf57932_reset();
r2822r2823
15211521   mc6846_reset();
15221522   to7_game_reset();
15231523   to7_floppy_reset(machine);
1524   to7_io_reset();
1524   to7_io_reset(machine);
15251525   to7_modem_reset();
15261526   to7_midi_reset();
15271527   to7_rf57932_reset();
r2822r2823
18821882   pia_set_port_a_z_mask( THOM_PIA_SYS, 0x5f );
18831883   to7_game_reset();
18841884   to7_floppy_reset(machine);
1885   to7_io_reset();
1885   to7_io_reset(machine);
18861886   to7_modem_reset();
18871887   to7_midi_reset();
18881888   to7_rf57932_reset();
r2822r2823
23322332
23332333
23342334/* quick keyboard scan */
2335static int to9_kbd_ktest ( void )
2335static int to9_kbd_ktest ( running_machine *machine )
23362336{
23372337   int line, bit;
23382338   UINT8 port;
r2822r2823
23412341   for ( line = 0; line < 10; line++ )
23422342   {
23432343      sprintf(tag, "keyboard_%d", line);
2344      port = input_port_read(Machine, tag);
2344      port = input_port_read(machine, tag);
23452345
23462346      if ( line == 7 || line == 9 )
23472347         port |= 1; /* shift & control */
r2822r2823
23572357
23582358
23592359
2360static void to9_kbd_update_irq ( void )
2360static void to9_kbd_update_irq ( running_machine *machine )
23612361{
23622362   if ( (to9_kbd_intr & 4) && (to9_kbd_status & ACIA_6850_RDRF) )
23632363      to9_kbd_status |= ACIA_6850_irq; /* byte received interrupt */
r2822r2823
23682368   if ( (to9_kbd_intr & 3) == 1 && (to9_kbd_status & ACIA_6850_TDRE) )
23692369      to9_kbd_status |= ACIA_6850_irq; /* ready to transmit interrupt */
23702370
2371   thom_irq_3( Machine, to9_kbd_status & ACIA_6850_irq );
2371   thom_irq_3( machine, to9_kbd_status & ACIA_6850_irq );
23722372}
23732373
23742374
r2822r2823
24072407         to9_kbd_status &= ~(ACIA_6850_OVRN | ACIA_6850_RDRF);
24082408      to9_kbd_overrun = 0;
24092409      LOG_KBD(( "$%04x %f to9_kbd_r: read data $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), to9_kbd_in ));
2410      to9_kbd_update_irq();
2410      to9_kbd_update_irq(machine);
24112411      return to9_kbd_in;
24122412
24132413   default:
r2822r2823
24512451              data, to9_kbd_parity, to9_kbd_intr >> 2,
24522452              (to9_kbd_intr & 3) ? 1 : 0 ));
24532453      }
2454      to9_kbd_update_irq();
2454      to9_kbd_update_irq(machine);
24552455      break;
24562456
24572457   case 1: /* output data */
24582458      to9_kbd_status &= ~(ACIA_6850_irq | ACIA_6850_TDRE);
2459      to9_kbd_update_irq();
2459      to9_kbd_update_irq(machine);
24602460      /* TODO: 1 ms delay here ? */
24612461      to9_kbd_status |= ACIA_6850_TDRE; /* data transmit ready again */
2462      to9_kbd_update_irq();
2462      to9_kbd_update_irq(machine);
24632463
24642464      switch ( data )
24652465      {
r2822r2823
25002500   note: parity is not used as a checksum but to actually transmit a 9-th bit
25012501   of information!
25022502*/
2503static void to9_kbd_send ( UINT8 data, int parity )
2503static void to9_kbd_send ( running_machine *machine, UINT8 data, int parity )
25042504{
25052505   if ( to9_kbd_status & ACIA_6850_RDRF )
25062506   {
r2822r2823
25192519         to9_kbd_status |= ACIA_6850_PE;  /* parity error */
25202520      LOG_KBD(( "%f to9_kbd_send: data=$%02X, parity=%i, status=$%02X\n", attotime_to_double(timer_get_time()), data, parity, to9_kbd_status ));
25212521   }
2522   to9_kbd_update_irq();
2522   to9_kbd_update_irq(machine);
25232523}
25242524
25252525
r2822r2823
26612661      {
26622662
26632663      case 0: /* key */
2664         to9_kbd_send( to9_kbd_get_key(), 0 );
2664         to9_kbd_send( machine, to9_kbd_get_key(), 0 );
26652665         break;
26662666
26672667      case 1: /* x axis */
26682668      {
26692669         int newx = input_port_read(machine, "mouse_x");
26702670         UINT8 data = ( (newx - to9_mouse_x) & 0xf ) - 8;
2671         to9_kbd_send( data, 1 );
2671         to9_kbd_send( machine, data, 1 );
26722672         to9_mouse_x = newx;
26732673         break;
26742674      }
r2822r2823
26772677      {
26782678         int newy = input_port_read(machine, "mouse_y");
26792679         UINT8 data = ( (newy - to9_mouse_y) & 0xf ) - 8;
2680         to9_kbd_send( data, 1 );
2680         to9_kbd_send( machine, data, 1 );
26812681         to9_mouse_y = newy;
26822682         break;
26832683      }
r2822r2823
26882688         UINT8 data = 0;
26892689         if ( b & 1 ) data |= 1;
26902690         if ( b & 2 ) data |= 4;
2691         to9_kbd_send( data, 1 );
2691         to9_kbd_send( machine, data, 1 );
26922692         break;
26932693      }
26942694
r2822r2823
27022702      int key = to9_kbd_get_key();
27032703      /* keyboard mode: send a byte only if a key is down */
27042704      if ( key )
2705         to9_kbd_send( key, 0 );
2705         to9_kbd_send( machine, key, 0 );
27062706      timer_adjust_oneshot(to9_kbd_timer, TO9_KBD_POLL_PERIOD, 0);
27072707   }
27082708}
27092709
27102710
27112711
2712static void to9_kbd_reset ( void )
2712static void to9_kbd_reset ( running_machine *machine )
27132713{
27142714   LOG(( "to9_kbd_reset called\n" ));
27152715   to9_kbd_overrun = 0;  /* no byte lost */
r2822r2823
27222722   thom_set_caps_led( ! to9_kbd_caps );
27232723   to9_kbd_key_count = 0;
27242724   to9_kbd_last_key = 0xff;
2725   to9_kbd_update_irq();
2725   to9_kbd_update_irq(machine);
27262726   timer_adjust_oneshot(to9_kbd_timer, TO9_KBD_POLL_PERIOD, 0);
27272727}
27282728
r2822r2823
27542754
27552755
27562756
2757static void to9_update_centronics ( void )
2757static void to9_update_centronics ( running_machine *machine )
27582758{
27592759   UINT8 a = pia_get_output_a( THOM_PIA_SYS );
27602760   UINT8 b = pia_get_output_b( THOM_PIA_SYS );
r2822r2823
27712771
27722772static READ8_HANDLER ( to9_sys_porta_in )
27732773{
2774   UINT8 ktest = to9_kbd_ktest();
2774   UINT8 ktest = to9_kbd_ktest(machine);
27752775
27762776   LOG_KBD(( "to9_sys_porta_in: ktest=%i\n", ktest ));
27772777
r2822r2823
27822782
27832783static WRITE8_HANDLER ( to9_sys_porta_out )
27842784{
2785   to9_update_centronics(); /* bits 1-7: printer */
2785   to9_update_centronics(machine); /* bits 1-7: printer */
27862786}
27872787
27882788
27892789
27902790static WRITE8_HANDLER ( to9_sys_portb_out )
27912791{
2792   to9_update_centronics(); /* bits 0-1: printer */
2792   to9_update_centronics(machine); /* bits 0-1: printer */
27932793   to9_update_ram_bank(machine);
27942794
27952795   if ( data & 4 ) /* bit 2: video overlay (TODO) */
r2822r2823
28482848   mc6846_reset();
28492849   to7_game_reset();
28502850   to9_floppy_reset(machine);
2851   to9_kbd_reset();
2851   to9_kbd_reset(machine);
28522852   thom_centronics_reset();
28532853   to7_modem_reset();
28542854   to7_midi_reset();
r2822r2823
29752975
29762976
29772977/* quick keyboard scan */
2978static int to8_kbd_ktest ( void )
2978static int to8_kbd_ktest ( running_machine *machine )
29792979{
29802980   int line, bit;
29812981   UINT8 port;
29822982   char tag[12];
29832983
2984   if ( input_port_read(Machine, "config") & 2 )
2984   if ( input_port_read(machine, "config") & 2 )
29852985      return 0; /* disabled */
29862986
29872987   for ( line = 0; line < 10; line++ )
29882988   {
29892989      sprintf(tag, "keyboard_%d", line);
2990      port = input_port_read(Machine, tag);
2990      port = input_port_read(machine, tag);
29912991
29922992      if ( line == 7 || line == 9 )
29932993         port |= 1; /* shift & control */
r2822r2823
30053005
30063006
30073007/* keyboard scan & return keycode (or -1) */
3008static int to8_kbd_get_key( void )
3008static int to8_kbd_get_key( running_machine *machine )
30093009{
3010   int control = (input_port_read(Machine, "keyboard_7") & 1) ? 0 : 0x100;
3011   int shift   = (input_port_read(Machine, "keyboard_9") & 1) ? 0 : 0x080;
3010   int control = (input_port_read(machine, "keyboard_7") & 1) ? 0 : 0x100;
3011   int shift   = (input_port_read(machine, "keyboard_9") & 1) ? 0 : 0x080;
30123012   int key = -1, line, bit;
30133013   UINT8 port;
30143014   char tag[12];
30153015   
3016   if ( input_port_read(Machine, "config") & 2 )
3016   if ( input_port_read(machine, "config") & 2 )
30173017      return -1; /* disabled */
30183018
30193019   for ( line = 0; line < 10; line++ )
30203020   {
30213021      sprintf(tag, "keyboard_%d", line);
3022      port = input_port_read(Machine, tag);
3022      port = input_port_read(machine, tag);
30233023
30243024      if ( line == 7 || line == 9 )
30253025         port |= 1; /* shift & control */
r2822r2823
30783078*/
30793079
30803080/* keyboard automaton */
3081static void to8_kbd_timer_func(void)
3081static void to8_kbd_timer_func(running_machine *machine)
30823082{
30833083   attotime d;
30843084
r2822r2823
30873087   if( ! to8_kbd_step )
30883088   {
30893089      /* key polling */
3090      int k = to8_kbd_get_key();
3090      int k = to8_kbd_get_key(machine);
30913091      /* if not in transfer, send pulse from time to time
30923092         (helps avoiding CPU lock)
30933093      */
30943094      if ( ! to8_kbd_ack )
3095         mc6846_set_input_cp1( 0 );
3096      mc6846_set_input_cp1( 1 );
3095         mc6846_set_input_cp1( machine, 0 );
3096      mc6846_set_input_cp1( machine, 1 );
30973097
30983098      if ( k == -1 )
30993099         d = TO8_KBD_POLL_PERIOD;
r2822r2823
31123112      to8_kbd_last_key = 0xff;
31133113      to8_kbd_key_count = 0;
31143114      to8_kbd_step = 0;
3115      mc6846_set_input_cp1( 1 );
3115      mc6846_set_input_cp1( machine, 1 );
31163116      d = TO8_KBD_POLL_PERIOD;
31173117   }
31183118   else if ( to8_kbd_step == 1 )
31193119   {
31203120      /* schedule timeout waiting for ack to go down */
3121      mc6846_set_input_cp1( 0 );
3121      mc6846_set_input_cp1( machine, 0 );
31223122      to8_kbd_step = 255;
31233123      d = TO8_KBD_TIMEOUT;
31243124   }
31253125   else if ( to8_kbd_step == 117 )
31263126   {
31273127      /* schedule timeout  waiting for ack to go up */
3128      mc6846_set_input_cp1( 0 );
3128      mc6846_set_input_cp1( machine, 0 );
31293129      to8_kbd_step = 255;
31303130      d = TO8_KBD_TIMEOUT;
31313131   }
31323132   else if ( to8_kbd_step & 1 )
31333133   {
31343134      /* send silence between bits */
3135      mc6846_set_input_cp1( 0 );
3135      mc6846_set_input_cp1( machine, 0 );
31363136      d = ATTOTIME_IN_USEC( 100 );
31373137      to8_kbd_step++;
31383138   }
r2822r2823
31413141      /* send bit */
31423142      int bpos = 8 - ( (to8_kbd_step - 100) / 2);
31433143      int bit = (to8_kbd_data >> bpos) & 1;
3144      mc6846_set_input_cp1( 1 );
3144      mc6846_set_input_cp1( machine, 1 );
31453145      d = ATTOTIME_IN_USEC( bit ? 56 : 38 );
31463146      to8_kbd_step++;
31473147   }
r2822r2823
31523152
31533153static TIMER_CALLBACK(to8_kbd_timer_cb)
31543154{
3155   to8_kbd_timer_func();
3155   to8_kbd_timer_func(machine);
31563156}
31573157
31583158
r2822r2823
32293229
32303230
32313231
3232static void to8_kbd_reset ( void )
3232static void to8_kbd_reset ( running_machine *machine )
32333233{
32343234   to8_kbd_last_key = 0xff;
32353235   to8_kbd_key_count = 0;
r2822r2823
32383238   to8_kbd_ack = 1;
32393239   to8_kbd_caps = 1;
32403240   thom_set_caps_led( ! to8_kbd_caps );
3241   to8_kbd_timer_func();
3241   to8_kbd_timer_func(machine);
32423242}
32433243
32443244
r2822r2823
36993699
37003700static READ8_HANDLER ( to8_sys_porta_in )
37013701{
3702   int ktest = to8_kbd_ktest ();
3702   int ktest = to8_kbd_ktest (machine);
37033703
37043704   LOG_KBD(( "$%04x %f: to8_sys_porta_in ktest=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), ktest ));
37053705
r2822r2823
37103710
37113711static WRITE8_HANDLER ( to8_sys_portb_out )
37123712{
3713   to9_update_centronics(); /* bits 0-1: printer */
3713   to9_update_centronics(machine); /* bits 0-1: printer */
37143714   to8_update_ram_bank(machine);
37153715
37163716   if ( data & 4 ) /* bit 2: video overlay (TODO) */
r2822r2823
38083808   mc6846_reset();
38093809   to7_game_reset();
38103810   to8_floppy_reset(machine);
3811   to8_kbd_reset();
3811   to8_kbd_reset(machine);
38123812   thom_centronics_reset();
38133813   to7_modem_reset();
38143814   to7_midi_reset();
r2822r2823
39753975   mc6846_reset();
39763976   to7_game_reset();
39773977   to8_floppy_reset(machine);
3978   to9_kbd_reset();
3978   to9_kbd_reset(machine);
39793979   thom_centronics_reset();
39803980   to7_modem_reset();
39813981   to7_midi_reset();
r2822r2823
42734273   /* unlike the TO8, CB1 & CB2 are not connected to buttons */
42744274   if ( input_port_read(machine, "config") & 1 )
42754275   {
4276      UINT8 mouse = to7_get_mouse_signal();
4276      UINT8 mouse = to7_get_mouse_signal(machine);
42774277      pia_set_input_ca1( THOM_PIA_GAME, mouse & 1 ); /* XA */
42784278      pia_set_input_ca2( THOM_PIA_GAME, mouse & 2 ); /* YA */
42794279   }
src/mess/machine/mc6846.c
r2822r2823
1919**********************************************************************/
2020
2121#include "driver.h"
22#include "deprecat.h"
2322#include "mc6846.h"
2423
2524#define VERBOSE 0
r2822r2823
464463
465464
466465
467void mc6846_set_input_cp1 ( int data )
466void mc6846_set_input_cp1 ( running_machine *machine, int data )
468467{
469468   data = (data != 0 );
470469   if ( data == mc6846.cp1 )
r2822r2823
474473   if (( data &&  (mc6846.pcr & 2)) || (!data && !(mc6846.pcr & 2)))
475474   {
476475      mc6846.csr |= 2;
477      mc6846_update_irq(Machine);
476      mc6846_update_irq(machine);
478477   }
479478}
480479
481void mc6846_set_input_cp2 ( int data )
480void mc6846_set_input_cp2 ( running_machine *machine, int data )
482481{
483482   data = (data != 0 );
484483   if ( data == mc6846.cp2 )
r2822r2823
490489      if (( data &&  (mc6846.pcr & 0x10)) || (!data && !(mc6846.pcr & 0x10)))
491490      {
492491         mc6846.csr |= 4;
493         mc6846_update_irq(Machine);
492         mc6846_update_irq(machine);
494493      }
495494   }
496495}
src/mess/machine/74145.h
r2822r2823
2525};
2626
2727/* Configuration */
28void ttl74145_config(int which, const ttl74145_interface *intf);
28void ttl74145_config(running_machine *machine, int which, const ttl74145_interface *intf);
2929void ttl74145_reset(int which);
3030
3131/* Standard handlers */
src/mess/machine/mc6846.h
r2822r2823
4646extern WRITE8_HANDLER ( mc6846_w );
4747
4848/* asynchronous write from outside world into interrupt-generating pins */
49extern void mc6846_set_input_cp1 ( int data );
50extern void mc6846_set_input_cp2 ( int data );
49extern void mc6846_set_input_cp1 ( running_machine *machine, int data );
50extern void mc6846_set_input_cp2 ( running_machine *machine, int data );
5151
5252/* polling from outside world */
5353extern UINT8  mc6846_get_output_port ( running_machine *machine );
src/mess/machine/c128.c
r2822r2823
863863   sndti_reset(SOUND_SID6581, 0);
864864
865865   c64_rom_recognition ();
866   c64_rom_load();
866   c64_rom_load(machine);
867867
868868   c64mode = 0;
869869   c128_mmu8722_reset (machine);
src/mess/machine/oric.c
r2822r2823
777777         break;
778778      /* any write will cause wd179x to reset */
779779      case 0x09:
780         wd17xx_reset();
780         wd17xx_reset(machine);
781781         break;
782782      case 0x0a:
783783         logerror("jasmin overlay ram w: %02x PC: %04x\n",data,activecpu_get_pc());
src/mess/machine/at.c
r2822r2823
121121}
122122
123123
124static void init_at_common(const struct kbdc8042_interface *at8042)
124static void init_at_common(running_machine *machine, const struct kbdc8042_interface *at8042)
125125{
126126   mess_init_pc_common(PCCOMMON_KEYBOARD_AT, at_set_keyb_int, at_set_irq_line);
127127   mc146818_init(MC146818_STANDARD);
r2822r2823
131131   if (mess_ram_size > 0x0a0000)
132132   {
133133      offs_t ram_limit = 0x100000 + mess_ram_size - 0x0a0000;
134      memory_install_read_handler(Machine, 0,  ADDRESS_SPACE_PROGRAM, 0x100000,  ram_limit - 1, 0, 0, 1);
135      memory_install_write_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0x100000,  ram_limit - 1, 0, 0, 1);
134      memory_install_read_handler(machine, 0,  ADDRESS_SPACE_PROGRAM, 0x100000,  ram_limit - 1, 0, 0, 1);
135      memory_install_write_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x100000,  ram_limit - 1, 0, 0, 1);
136136      memory_set_bankptr(1, mess_ram + 0xa0000);
137137   }
138138}
r2822r2823
228228
229229
230230static DMA8237_CHANNEL_READ( at_dma8237_fdc_dack_r ) {
231   return pc_fdc_dack_r();
231   return pc_fdc_dack_r(device->machine);
232232}
233233
234234
r2822r2823
238238
239239
240240static DMA8237_CHANNEL_WRITE( at_dma8237_fdc_dack_w ) {
241   pc_fdc_dack_w( data );
241   pc_fdc_dack_w( device->machine, data );
242242}
243243
244244
r2822r2823
248248
249249
250250static DMA8237_OUT_EOP( at_dma8237_out_eop ) {
251   pc_fdc_set_tc_state( state );
251   pc_fdc_set_tc_state( device->machine, state );
252252}
253253
254254
r2822r2823
386386   {
387387      KBDC8042_STANDARD, at_set_gate_a20, at_keyboard_interrupt, at_get_out2
388388   };
389   init_at_common(&at8042);
389   init_at_common(machine, &at8042);
390390}
391391
392392
r2822r2823
400400   UINT8   *src = memory_region( REGION_USER1 ) + 0x3fff;
401401   int      i;
402402
403   init_at_common(&at8042);
403   init_at_common(machine, &at8042);
404404
405405   /* Perform the EGA bios address line swaps */
406406   for( i = 0; i < 0x4000; i++ )
r2822r2823
417417   {
418418      KBDC8042_AT386, at_set_gate_a20, at_keyboard_interrupt, at_get_out2
419419   };
420   init_at_common(&at8042);
420   init_at_common(machine, &at8042);
421421}
422422
423423
r2822r2823
468468      KBDC8042_STANDARD, at_set_gate_a20, at_keyboard_interrupt, at_get_out2
469469   };
470470
471   init_at_common(&at8042);
471   init_at_common(machine, &at8042);
472472   pc_turbo_setup(0, 2, 0x02, 4.77/12, 1);
473473   pc_vga_init(machine, &vga_interface, NULL);
474474}
r2822r2823
481481   {
482482      KBDC8042_PS2, at_set_gate_a20, at_keyboard_interrupt, at_get_out2
483483   };
484   init_at_common(&at8042);
484   init_at_common(machine, &at8042);
485485   pc_turbo_setup(0, 2, 0x02, 4.77/12, 1);
486486   pc_vga_init(machine, &vga_interface, NULL);
487487}
r2822r2823
498498MACHINE_START( at )
499499{
500500   cpunum_set_irq_callback(0, at_irq_callback);
501   pc_fdc_init( &fdc_interface );
501   pc_fdc_init( machine, &fdc_interface );
502502}
503503
504504
src/mess/machine/orion.c
r2822r2823
202202
203203MACHINE_RESET ( orion128 )
204204{     
205   wd17xx_reset();
205   wd17xx_reset(machine);
206206   wd17xx_set_density (DEN_FM_HI);   
207207   orion_keyboard_mask = 0;
208208   orion128_video_page = 0;
r2822r2823
419419   memory_set_bankptr(3, mess_ram + 0xf000);     
420420   memory_set_bankptr(5, memory_region(REGION_CPU1) + 0xf800);     
421421   
422   wd17xx_reset();
422   wd17xx_reset(machine);
423423   orion_keyboard_mask = 0;
424424   orion128_video_page = 0;
425425   orion128_video_mode = 0;
r2822r2823
576576MACHINE_RESET ( orionpro )
577577{   
578578   
579   wd17xx_reset();
579   wd17xx_reset(machine);
580580
581581   orion_keyboard_mask = 0;
582582   orion128_video_page = 0;
src/mess/machine/sms.c
r2822r2823
11#include "driver.h"
2#include "deprecat.h"
32#include "image.h"
43#include "includes/sms.h"
54#include "video/smsvdp.h"
r2822r2823
115114   }
116115}
117116
118static void sms_get_inputs(void) {
117static void sms_get_inputs(running_machine *machine) {
119118   UINT8 data = 0x00;
120119   UINT32 cpu_cycles = activecpu_gettotalcycles();
121120
r2822r2823
128127   }
129128
130129   /* Player 1 */
131   switch( input_port_read(Machine, "CTRLSEL") & 0x0F ) {
130   switch( input_port_read(machine, "CTRLSEL") & 0x0F ) {
132131   case 0x00:  /* Joystick */
133      data = input_port_read(Machine, "JOY0");
132      data = input_port_read(machine, "JOY0");
134133      /* Rapid Fire setting for Button A */
135      if ( input_port_read(Machine, "RFU") & 0x01 ) {
134      if ( input_port_read(machine, "RFU") & 0x01 ) {
136135         data = ( data & 0xEF ) | ( rapid_fire_state_1 & 0x10 );
137136      }
138137      /* Check Rapid Fire setting for Button B */
139      if ( input_port_read(Machine, "RFU") & 0x02 ) {
138      if ( input_port_read(machine, "RFU") & 0x02 ) {
140139         data = ( data & 0xDF ) | ( rapid_fire_state_1 & 0x20 );
141140      }
142141      sms_input_port0 = ( sms_input_port0 & 0xC0 ) | ( data & 0x3F );
r2822r2823
145144      break;
146145   case 0x02:  /* Paddle Control */
147146      /* Get button A state */
148      data = input_port_read(Machine, "PADDLE0");
147      data = input_port_read(machine, "PADDLE0");
149148      if ( paddle_read_state ) {
150149         data = data >> 4;
151150      }
152151      sms_input_port0 = ( sms_input_port0 & 0xC0 ) | ( data & 0x0F ) | ( paddle_read_state & 0x20 )
153                      | ( ( input_port_read(Machine, "IN0") & 0x02 ) << 3 );
152                      | ( ( input_port_read(machine, "IN0") & 0x02 ) << 3 );
154153      break;
155154   case 0x03:   /* Sega Sports Pad */
156155      switch( sports_pad_state_1 ) {
r2822r2823
167166         data = sports_pad_1_y & 0x0F;
168167         break;
169168      }
170      sms_input_port0 = ( sms_input_port0 & 0xC0 ) | data | ( ( input_port_read(Machine, "IN0") & 0x0C ) << 2 );
169      sms_input_port0 = ( sms_input_port0 & 0xC0 ) | data | ( ( input_port_read(machine, "IN0") & 0x0C ) << 2 );
171170      break;
172171   }
173172
174173   /* Player 2 */
175   switch( input_port_read(Machine, "CTRLSEL") >> 4 ) {
174   switch( input_port_read(machine, "CTRLSEL") >> 4 ) {
176175   case 0x00:   /* Joystick */
177      data = input_port_read(Machine, "JOY0");
176      data = input_port_read(machine, "JOY0");
178177      sms_input_port0 = ( sms_input_port0 & 0x3F ) | ( data & 0xC0 );
179      data = input_port_read(Machine, "JOY1");
180      if ( input_port_read(Machine, "RFU") & 0x04 ) {
178      data = input_port_read(machine, "JOY1");
179      if ( input_port_read(machine, "RFU") & 0x04 ) {
181180         data = ( data & 0xFB ) | ( rapid_fire_state_2 & 0x04 );
182181      }
183      if ( input_port_read(Machine, "RFU") & 0x08 ) {
182      if ( input_port_read(machine, "RFU") & 0x08 ) {
184183         data = ( data & 0xF7 ) | ( rapid_fire_state_2 & 0x08 );
185184      }
186185      sms_input_port1 = ( sms_input_port1 & 0xF0 ) | ( data & 0x0F );
r2822r2823
189188      break;
190189   case 0x02:   /* Paddle Control */
191190      /* Get button A state */
192      data = input_port_read(Machine, "PADDLE1");
191      data = input_port_read(machine, "PADDLE1");
193192      if ( paddle_read_state ) {
194193         data = data >> 4;
195194      }
196195      sms_input_port0 = ( sms_input_port0 & 0x3F ) | ( ( data & 0x03 ) << 6 );
197196      sms_input_port1 = ( sms_input_port1 & 0xF0 ) | ( ( data & 0x0C ) >> 2 ) | ( paddle_read_state & 0x08 )
198                      | ( ( input_port_read(Machine, "IN0") & 0x20 ) >> 3 );
197                      | ( ( input_port_read(machine, "IN0") & 0x20 ) >> 3 );
199198      break;
200199   case 0x03:   /* Sega Sports Pad */
201200      switch( sports_pad_state_2 ) {
r2822r2823
212211         break;
213212      }
214213      sms_input_port0 = ( sms_input_port0 & 0x3F ) | ( ( data & 0x03 ) << 6 );
215      sms_input_port1 = ( sms_input_port1 & 0xF0 ) | ( data >> 2 ) | ( ( input_port_read(Machine, "IN0") & 0xC0 ) >> 4 );
214      sms_input_port1 = ( sms_input_port1 & 0xF0 ) | ( data >> 2 ) | ( ( input_port_read(machine, "IN0") & 0xC0 ) >> 4 );
216215      break;
217216   }
218217}
r2822r2823
230229      if ( biosPort & IO_CHIP ) {
231230         return 0xFF;
232231      } else {
233         sms_get_inputs();
232         sms_get_inputs(machine);
234233         return sms_input_port0;
235234      }
236235   }
r2822r2823
248247   }
249248}
250249
251 READ8_HANDLER(sms_version_r) {
250READ8_HANDLER(sms_version_r) {
252251   UINT8 temp;
253252
254253   if (biosPort & IO_CHIP) {
r2822r2823
264263   }
265264
266265   /* Merge version data with input port #2 data */
267   sms_get_inputs();
266   sms_get_inputs(machine);
268267   temp = (temp & 0xC0) | (sms_input_port1 & 0x3F);
269268
270269   return (temp);
r2822r2823
293292   }
294293}
295294
296 READ8_HANDLER(sms_input_port_0_r) {
295READ8_HANDLER(sms_input_port_0_r) {
297296   if (biosPort & IO_CHIP) {
298297      return (0xFF);
299298   } else {
300      sms_get_inputs();
299      sms_get_inputs(machine);
301300      return sms_input_port0;
302301   }
303302}
src/mess/machine/wd17xx.c
r2822r2823
3636
3737
3838#include "driver.h"
39#include "deprecat.h"
4039#include "machine/wd17xx.h"
4140#include "devices/flopdrv.h"
4241
r2822r2823
322321
323322/* BUSY COUNT DOESN'T WORK PROPERLY! */
324323
325static void wd17xx_restore(wd17xx_info *w)
324static void wd17xx_restore(running_machine *machine, wd17xx_info *w)
326325{
327326   UINT8 step_counter;
328327
329   if (current_drive >= device_count(Machine, IO_FLOPPY))
328   if (current_drive >= device_count(machine, IO_FLOPPY))
330329      return;
331330
332331   step_counter = 255;
r2822r2823
374373static TIMER_CALLBACK(wd17xx_write_sector_callback);
375374static void wd17xx_index_pulse_callback(const device_config *img, int state);
376375
377void wd17xx_reset(void)
376void wd17xx_reset(running_machine *machine)
378377{
379378   int i;
380   for (i = 0; i < device_count(Machine, IO_FLOPPY); i++)
379   for (i = 0; i < device_count(machine, IO_FLOPPY); i++)
381380   {
382381      const device_config *img = image_from_devtype_and_index(IO_FLOPPY, i);
383382      floppy_drive_set_index_pulse_callback(img, wd17xx_index_pulse_callback);
384383      floppy_drive_set_rpm( img, 300.);
385384   }
386385
387   wd17xx_restore(&wd);
386   wd17xx_restore(machine, &wd);
388387}
389388
390389
r2822r2823
405404   wd.timer_rs = timer_alloc(wd17xx_read_sector_callback, NULL);
406405   wd.timer_ws = timer_alloc(wd17xx_write_sector_callback, NULL);
407406   wd17xx_pause_time = 40;
408   wd17xx_reset();
407   wd17xx_reset(machine);
409408}
410409
411410
r2822r2823
13761375      if (VERBOSE)
13771376         logerror("wd17xx_command_w $%02X RESTORE\n", data);
13781377
1379      wd17xx_restore(w);
1378      wd17xx_restore(machine, w);
13801379   }
13811380
13821381   if ((data & ~FDC_MASK_TYPE_I) == FDC_SEEK)
src/mess/machine/wd17xx.h
r2822r2823
5252***************************************************************************/
5353
5454void wd17xx_init(running_machine *machine, wd17xx_type_t type, void (*callback)(running_machine *, wd17xx_state_t, void *), void *param);
55void wd17xx_reset(void);
55void wd17xx_reset(running_machine *machine);
5656
5757/* the following are not strictly part of the wd179x hardware/emulation
5858but will be put here for now until the flopdrv code has been finalised more */
src/mess/machine/svi318.c
r2822r2823
659659   svi.bank_switch = 0xff;
660660   svi318_set_banks(machine);
661661
662   wd17xx_reset();
662   wd17xx_reset(machine);
663663}
664664
665665INTERRUPT_GEN( svi318_interrupt )
src/mess/machine/compis.c
r2822r2823
289289/*-------------------------------------------------------------------------*/
290290/*  FDC iSBX-218A                                                          */
291291/*-------------------------------------------------------------------------*/
292static void compis_fdc_reset(void)
292static void compis_fdc_reset(running_machine *machine)
293293{
294   nec765_reset(0);
294   nec765_reset(machine, 0);
295295
296296   /* set FDC at reset */
297   nec765_set_reset_state(1);
297   nec765_set_reset_state(machine, 1);
298298}
299299
300static void compis_fdc_tc(int state)
300static void compis_fdc_tc(running_machine *machine, int state)
301301{
302302   /* Terminal count if iSBX-218A has DMA enabled */
303     if (input_port_read(Machine, "DSW1"))
303     if (input_port_read(machine, "DSW1"))
304304   {
305      nec765_set_tc_state(state);
305      nec765_set_tc_state(machine, state);
306306   }
307307}
308308
r2822r2823
443443
444444   /* FDC Reset */
445445   if (data & 0x40)
446      compis_fdc_reset();
446      compis_fdc_reset(machine);
447447
448448   /* FDC Terminal count */
449   compis_fdc_tc((data & 0x80)?1:0);
449   compis_fdc_tc(machine, (data & 0x80)?1:0);
450450}
451451
452452const ppi8255_interface compis_ppi_interface =
r2822r2823
15441544   compis_cpu_init();
15451545
15461546   /* FDC */
1547   nec765_init(&compis_fdc_interface, NEC765A, NEC765_RDY_PIN_CONNECTED);
1548   compis_fdc_reset();
1547   nec765_init(machine, &compis_fdc_interface, NEC765A, NEC765_RDY_PIN_CONNECTED);
1548   compis_fdc_reset(machine);
15491549
15501550   /* RTC */
15511551   mm58274c_init(machine, 0, 0);
src/mess/machine/corvushd.c
r2822r2823
6464//
6565
6666#include "driver.h"
67#include "deprecat.h"
6867#include "devices/harddriv.h"
6968#include "includes/corvushd.h"
7069#include <ctype.h>
r2822r2823
544543// Returns:
545544//      status:   Command status
546545//
547static UINT8 corvus_write_sector(UINT8 drv, UINT32 sector, UINT8 *buffer, int len) {
546static UINT8 corvus_write_sector(running_machine *machine, UINT8 drv, UINT32 sector, UINT8 *buffer, int len) {
548547
549548   corvus_hdc_t
550549         *c = &corvus_hdc;
r2822r2823
555554
556555   LOG(("corvus_write_sector: Write Drive: %d, physical sector: 0x%5.5x\n", drv, sector));
557556
558   if(drv >= device_count(Machine, IO_HARDDISK)) {
557   if(drv >= device_count(machine, IO_HARDDISK)) {
559558      logerror("corvus_write_sector: Attempt to write to non-existant drive: %d\n", drv);
560559      return STAT_FATAL_ERR | STAT_DRIVE_NOT_ONLINE;
561560   }
r2822r2823
610609// Returns:
611610//      status:   Corvus status
612611//
613static UINT8 corvus_write_logical_sector(dadr_t *dadr, UINT8 *buffer, int len) {
612static UINT8 corvus_write_logical_sector(running_machine *machine, dadr_t *dadr, UINT8 *buffer, int len) {
614613
615614   corvus_hdc_t
616615         *c = &corvus_hdc;
r2822r2823
637636   //
638637   sector += (c->tracks_per_cylinder * c->sectors_per_track * 2) + (SPARE_TRACKS * c->sectors_per_track);
639638
640   status = corvus_write_sector(drv, sector, buffer, len);
639   status = corvus_write_sector(machine, drv, sector, buffer, len);
641640
642641   if(status != STAT_SUCCESS)
643642      c->xmit_bytes = 1;
r2822r2823
660659// Returns:
661660//      status:   Corvus status
662661//
663static UINT8 corvus_read_sector(UINT8 drv, UINT32 sector, UINT8 *buffer, int len) {
662static UINT8 corvus_read_sector(running_machine *machine, UINT8 drv, UINT32 sector, UINT8 *buffer, int len) {
664663
665664   corvus_hdc_t
666665         *c = &corvus_hdc;
r2822r2823
671670
672671   LOG(("corvus_read_sector: Read Drive: %d, physical sector: 0x%5.5x\n", drv, sector));
673672
674   if(drv >= device_count(Machine, IO_HARDDISK)) {
673   if(drv >= device_count(machine, IO_HARDDISK)) {
675674      logerror("corvus_read_sector: Attempt to read from non-existant drive: %d\n", drv);
676675      return STAT_FATAL_ERR | STAT_DRIVE_NOT_ONLINE;
677676   }
r2822r2823
715714// Returns:
716715//      status:   Corvus status
717716//
718static UINT8 corvus_read_logical_sector(dadr_t *dadr, UINT8 *buffer, int len) {
717static UINT8 corvus_read_logical_sector(running_machine *machine, dadr_t *dadr, UINT8 *buffer, int len) {
719718
720719   corvus_hdc_t
721720         *c = &corvus_hdc;
r2822r2823
742741   //
743742   sector += (c->tracks_per_cylinder * c->sectors_per_track * 2) + (SPARE_TRACKS * c->sectors_per_track);
744743
745   status = corvus_read_sector(drv, sector, buffer, len);
744   status = corvus_read_sector(machine, drv, sector, buffer, len);
746745
747746   if(status != STAT_SUCCESS)
748747      c->xmit_bytes = 1;
r2822r2823
766765// Side-effects:
767766//      Fills in the semaphore result code
768767//
769static UINT8 corvus_lock_semaphore(UINT8 *name) {
768static UINT8 corvus_lock_semaphore(running_machine *machine, UINT8 *name) {
770769
771770   corvus_hdc_t
772771         *c = &corvus_hdc;
r2822r2823
780779   //
781780   // Read the semaphore table from the drive
782781   //
783   status = corvus_read_sector(0, 7, semaphore_table.semaphore_block.semaphore_table, 256);
782   status = corvus_read_sector(machine, 0, 7, semaphore_table.semaphore_block.semaphore_table, 256);
784783   if(status != STAT_SUCCESS) {
785784      logerror("corvus_lock_semaphore: Error reading semaphore table, status: 0x%2.2x\n", status);
786785      c->buffer.semaphore_locking_response.result = SEM_DISK_ERROR;
r2822r2823
814813      } else {
815814         c->buffer.semaphore_locking_response.result = SEM_PRIOR_STATE_NOT_SET;         // It wasn't there already
816815         memcpy(&semaphore_table.semaphore_block.semaphore_entry[blank_offset], name, 8);// Stick it into the table
817         status = corvus_write_sector(0, 7, semaphore_table.semaphore_block.semaphore_table, 256);
816         status = corvus_write_sector(machine, 0, 7, semaphore_table.semaphore_block.semaphore_table, 256);
818817         if(status != STAT_SUCCESS) {
819818            logerror("corvus_lock_semaphore: Error updating semaphore table, status: 0x%2.2x\n", status);
820819            c->buffer.semaphore_locking_response.result = SEM_DISK_ERROR;
r2822r2823
844843// Side-effects:
845844//      Fills in the semaphore result code
846845//
847static UINT8 corvus_unlock_semaphore(UINT8 *name) {
846static UINT8 corvus_unlock_semaphore(running_machine *machine, UINT8 *name) {
848847
849848   corvus_hdc_t
850849         *c = &corvus_hdc;
r2822r2823
857856   //
858857   // Read the semaphore table from the drive
859858   //
860   status = corvus_read_sector(0, 7, semaphore_table.semaphore_block.semaphore_table, 256);
859   status = corvus_read_sector(machine, 0, 7, semaphore_table.semaphore_block.semaphore_table, 256);
861860   if(status != STAT_SUCCESS) {
862861      logerror("corvus_unlock_semaphore: Error reading semaphore table, status: 0x%2.2x\n", status);
863862      c->buffer.semaphore_locking_response.result = SEM_DISK_ERROR;
r2822r2823
887886   } else {
888887      c->buffer.semaphore_locking_response.result = SEM_PRIOR_STATE_SET;               // It was there
889888      memcpy(&semaphore_table.semaphore_block.semaphore_entry[offset], "        ", 8);   // Clear it
890      status = corvus_write_sector(0, 7, semaphore_table.semaphore_block.semaphore_table, 256);
889      status = corvus_write_sector(machine, 0, 7, semaphore_table.semaphore_block.semaphore_table, 256);
891890      if(status != STAT_SUCCESS) {
892891         logerror("corvus_unlock_semaphore: Error updating semaphore table, status: 0x%2.2x\n", status);
893892         c->buffer.semaphore_locking_response.result = SEM_DISK_ERROR;
r2822r2823
912911//      Disk status
913912//
914913//
915static UINT8 corvus_init_semaphore_table( void ) {
914static UINT8 corvus_init_semaphore_table( running_machine *machine ) {
916915
917916   semaphore_table_block_t
918917         semaphore_table;
r2822r2823
920919
921920   memset(semaphore_table.semaphore_block.semaphore_table, 0x20, 256);
922921
923   status = corvus_write_sector(0, 7, semaphore_table.semaphore_block.semaphore_table, 256);
922   status = corvus_write_sector(machine, 0, 7, semaphore_table.semaphore_block.semaphore_table, 256);
924923   if(status != STAT_SUCCESS) {
925924      logerror("corvus_init_semaphore_table: Error updating semaphore table, status: 0x%2.2x\n", status);
926925      return status;
r2822r2823
942941// Returns:
943942//      Status of command
944943//
945static UINT8 corvus_get_drive_parameters(UINT8 drv) {
944static UINT8 corvus_get_drive_parameters(running_machine *machine, UINT8 drv) {
946945
947946   corvus_hdc_t
948947         *c = &corvus_hdc;
r2822r2823
967966   //
968967   drv -= 1;                           // Internally, drives start at 0
969968
970   if(drv >= device_count(Machine, IO_HARDDISK)) {
969   if(drv >= device_count(machine, IO_HARDDISK)) {
971970      logerror("corvus_get_drive_parameters: Attempt to retrieve parameters from non-existant drive: %d\n", drv);
972971      c->xmit_bytes = 1;
973972      return STAT_FATAL_ERR | STAT_DRIVE_NOT_ONLINE;
r2822r2823
976975   //
977976   // Read the Disk Parameter Block (Sector 1) from the drive
978977   //
979   status = corvus_read_sector(drv, 1, raw_disk_parameter_block.buffer, 512);
978   status = corvus_read_sector(machine, drv, 1, raw_disk_parameter_block.buffer, 512);
980979   if(status != STAT_SUCCESS) {
981980      logerror("corvus_get_drive_parameters: Error status returned reading Disk Parameter Block -- status: 0x%2.2x\n", status);
982981      c->xmit_bytes = 1;
r2822r2823
986985   //
987986   // Read the Constellation Parameter Block (Sector 3) from the drive
988987   //
989   status = corvus_read_sector(drv, 3, raw_constellation_parameter_block.buffer, 512);
988   status = corvus_read_sector(machine, drv, 3, raw_constellation_parameter_block.buffer, 512);
990989   if(status != STAT_SUCCESS) {
991990      logerror("corvus_get_drive_parameters: Error status returned reading Constellation Parameter Block -- status: 0x%2.2x\n", status);
992991      c->xmit_bytes = 1;
r2822r2823
10501049// Returns:
10511050//      status:   Status of read operation
10521051//
1053static UINT8 corvus_read_boot_block(UINT8 block) {
1052static UINT8 corvus_read_boot_block(running_machine *machine, UINT8 block) {
10541053
10551054   corvus_hdc_t   *c = &corvus_hdc;         // Pick up global controller structure
10561055
10571056   LOG(("corvus_read_boot_block: Reading boot block: %d\n", block));
10581057
1059   return corvus_read_sector(0, 25 + block, c->buffer.read_512_response.data, 512);
1058   return corvus_read_sector(machine, 0, 25 + block, c->buffer.read_512_response.data, 512);
10601059
10611060}
10621061
r2822r2823
10741073// Returns:
10751074//      Status of command
10761075//
1077static UINT8 corvus_read_firmware_block(UINT8 head, UINT8 sector) {
1076static UINT8 corvus_read_firmware_block(running_machine *machine, UINT8 head, UINT8 sector) {
10781077
10791078   corvus_hdc_t
10801079         *c = &corvus_hdc;   // Pick up global controller structure
r2822r2823
10861085   LOG(("corvus_read_firmware_block: Reading firmware head: 0x%2.2x, sector: 0x%2.2x, relative_sector: 0x%2.2x\n",
10871086      head, sector, relative_sector));
10881087
1089   status = corvus_read_sector(0, relative_sector, c->buffer.read_512_response.data, 512);      // TODO: Which drive should Prep Mode talk to ???
1088   status = corvus_read_sector(machine, 0, relative_sector, c->buffer.read_512_response.data, 512);      // TODO: Which drive should Prep Mode talk to ???
10901089   return status;
10911090}
10921091
r2822r2823
11051104// Returns:
11061105//      Status of command
11071106//
1108static UINT8 corvus_write_firmware_block(UINT8 head, UINT8 sector, UINT8 *buffer) {
1107static UINT8 corvus_write_firmware_block(running_machine *machine, UINT8 head, UINT8 sector, UINT8 *buffer) {
11091108
11101109   corvus_hdc_t
11111110         *c = &corvus_hdc;   // Pick up global controller structure
r2822r2823
11171116   LOG(("corvus_write_firmware_block: Writing firmware head: 0x%2.2x, sector: 0x%2.2x, relative_sector: 0x%2.2x\n",
11181117      head, sector, relative_sector));
11191118
1120   status = corvus_write_sector(0, relative_sector, buffer, 512);   // TODO: Which drive should Prep Mode talk to ???
1119   status = corvus_write_sector(machine, 0, relative_sector, buffer, 512);   // TODO: Which drive should Prep Mode talk to ???
11211120   return status;
11221121}
11231122
r2822r2823
11341133// Returns:
11351134//      Status of command
11361135//
1137static UINT8 corvus_format_drive(UINT8 *pattern, UINT16 len) {
1136static UINT8 corvus_format_drive(running_machine *machine, UINT8 *pattern, UINT16 len) {
11381137
11391138   corvus_hdc_t
11401139         *c = &corvus_hdc;
r2822r2823
11581157   LOG_BUFFER(pattern, 512);
11591158
11601159   for(sector = 0; sector <= max_sector; sector++) {
1161      status = corvus_write_sector(0, sector, pattern, 512);
1160      status = corvus_write_sector(machine, 0, sector, pattern, 512);
11621161      if(status != STAT_SUCCESS) {
11631162         logerror("corvus_format_drive: Error while formatting drive in corvus_write_sector--sector: 0x%5.5x, status: 0x%x2.2x\n",
11641163            sector, status);
r2822r2823
12061205// Returns:
12071206//      Nothing
12081207//
1209static void corvus_process_command_packet(UINT8 invalid_command_flag) {
1208static void corvus_process_command_packet(running_machine *machine, UINT8 invalid_command_flag) {
12101209
12111210   corvus_hdc_t   *c = &corvus_hdc;
12121211
r2822r2823
12241223            //
12251224            case READ_CHUNK_128:
12261225               c->buffer.read_128_response.status =
1227                  corvus_read_logical_sector(&c->buffer.read_sector_command.dadr, c->buffer.read_128_response.data, 128);
1226                  corvus_read_logical_sector(machine, &c->buffer.read_sector_command.dadr, c->buffer.read_128_response.data, 128);
12281227               break;
12291228            case READ_SECTOR_256:
12301229            case READ_CHUNK_256:
12311230               c->buffer.read_256_reponse.status =
1232                  corvus_read_logical_sector(&c->buffer.read_sector_command.dadr, c->buffer.read_256_reponse.data, 256);
1231                  corvus_read_logical_sector(machine, &c->buffer.read_sector_command.dadr, c->buffer.read_256_reponse.data, 256);
12331232               break;
12341233            case READ_CHUNK_512:
12351234               c->buffer.read_512_response.status =
1236                  corvus_read_logical_sector(&c->buffer.read_sector_command.dadr, c->buffer.read_512_response.data, 512);
1235                  corvus_read_logical_sector(machine, &c->buffer.read_sector_command.dadr, c->buffer.read_512_response.data, 512);
12371236               break;
12381237            case WRITE_CHUNK_128:
12391238               c->buffer.single_byte_response.status =
1240                  corvus_write_logical_sector(&c->buffer.write_128_command.dadr, c->buffer.write_128_command.data, 128);
1239                  corvus_write_logical_sector(machine, &c->buffer.write_128_command.dadr, c->buffer.write_128_command.data, 128);
12411240               break;
12421241            case WRITE_SECTOR_256:
12431242            case WRITE_CHUNK_256:
12441243               c->buffer.single_byte_response.status =
1245                  corvus_write_logical_sector(&c->buffer.write_256_command.dadr, c->buffer.write_256_command.data, 256);
1244                  corvus_write_logical_sector(machine, &c->buffer.write_256_command.dadr, c->buffer.write_256_command.data, 256);
12461245               break;
12471246            case WRITE_CHUNK_512:
12481247               c->buffer.single_byte_response.status =
1249                  corvus_write_logical_sector(&c->buffer.write_512_command.dadr, c->buffer.write_512_command.data, 512);
1248                  corvus_write_logical_sector(machine, &c->buffer.write_512_command.dadr, c->buffer.write_512_command.data, 512);
12501249               break;
12511250            //
12521251            // Semaphore commands
r2822r2823
12571256         //   case SEMAPHORE_STATUS_CODE:
12581257               switch(c->buffer.command.modifier) {
12591258                  case SEMAPHORE_LOCK_MOD:
1260                     c->buffer.semaphore_locking_response.status = corvus_lock_semaphore(c->buffer.lock_semaphore_command.name);
1259                     c->buffer.semaphore_locking_response.status = corvus_lock_semaphore(machine, c->buffer.lock_semaphore_command.name);
12611260                     break;
12621261                  case SEMAPHORE_UNLOCK_MOD:
12631262                     c->buffer.semaphore_locking_response.status =
1264                        corvus_unlock_semaphore(c->buffer.unlock_semaphore_command.name);
1263                        corvus_unlock_semaphore(machine, c->buffer.unlock_semaphore_command.name);
12651264                     break;
12661265                  case SEMAPHORE_INIT_MOD:
1267                     c->buffer.single_byte_response.status = corvus_init_semaphore_table();
1266                     c->buffer.single_byte_response.status = corvus_init_semaphore_table(machine);
12681267                     break;
12691268                  case SEMAPHORE_STATUS_MOD:
12701269                     c->buffer.semaphore_status_response.status =
1271                        corvus_read_sector(0, 7, c->buffer.semaphore_status_response.table, 256);
1270                        corvus_read_sector(machine, 0, 7, c->buffer.semaphore_status_response.table, 256);
12721271                     break;
12731272                  default:
12741273                     invalid_command_flag = TRUE;
r2822r2823
12791278            //
12801279            case BOOT:
12811280               c->buffer.read_512_response.status =
1282                  corvus_read_boot_block(c->buffer.old_boot_command.boot_block);
1281                  corvus_read_boot_block(machine, c->buffer.old_boot_command.boot_block);
12831282               break;
12841283            case GET_DRIVE_PARAMETERS:
12851284               c->buffer.drive_param_response.status =
1286                  corvus_get_drive_parameters(c->buffer.get_drive_parameters_command.drive);
1285                  corvus_get_drive_parameters(machine, c->buffer.get_drive_parameters_command.drive);
12871286               break;
12881287            case PREP_MODE_SELECT:
12891288               c->prep_mode = TRUE;
r2822r2823
13071306               break;
13081307            case PREP_READ_FIRMWARE:
13091308               c->buffer.drive_param_response.status =
1310                  corvus_read_firmware_block((c->buffer.read_firmware_command.encoded_h_s & 0xe0) >> 5,
1309                  corvus_read_firmware_block(machine, (c->buffer.read_firmware_command.encoded_h_s & 0xe0) >> 5,
13111310                     c->buffer.read_firmware_command.encoded_h_s & 0x1f);
13121311               break;
13131312            case PREP_WRITE_FIRMWARE:
13141313               c->buffer.drive_param_response.status =
1315                  corvus_write_firmware_block((c->buffer.write_firmware_command.encoded_h_s & 0xe0) >> 5,
1314                  corvus_write_firmware_block(machine, (c->buffer.write_firmware_command.encoded_h_s & 0xe0) >> 5,
13161315                     c->buffer.write_firmware_command.encoded_h_s & 0x1f, c->buffer.write_firmware_command.data);
13171316               break;
13181317            case PREP_FORMAT_DRIVE:
13191318               c->buffer.drive_param_response.status =
1320                  corvus_format_drive(c->buffer.format_drive_revbh_command.pattern, c->offset - 512);
1319                  corvus_format_drive(machine, c->buffer.format_drive_revbh_command.pattern, c->offset - 512);
13211320               break;
13221321            default:
13231322               c->xmit_bytes = 1;
r2822r2823
14091408            logerror("corvus_hdc_callback: Exceeded four-second timeout for data from host, resetting communications\n");
14101409         } else { // if(c->recv_bytes == 0)                This was a variable-size command
14111410            LOG(("corvus_hdc_callback: Executing variable-length command via four-second timeout\n"));
1412            corvus_process_command_packet(0);         // Process the command
1411            corvus_process_command_packet(machine, 0);         // Process the command
14131412         }
14141413         break;
14151414      default:
r2822r2823
16941693   // to the user with us Ready for more data and in Host-to-Controller mode.
16951694   //
16961695   if(c->offset == c->recv_bytes) {                  // We've received enough data to process
1697      corvus_process_command_packet(invalid_command_flag);
1696      corvus_process_command_packet(machine, invalid_command_flag);
16981697   } else {
16991698      //
17001699      // Reset the four-second timer since we received some data
src/mess/machine/nec765.c
r2822r2823
2121***************************************************************************/
2222
2323#include "driver.h"
24#include "deprecat.h"
2524#include "machine/nec765.h"
2625
2726
r2822r2823
121120} NEC765;
122121
123122//static void nec765_setup_data_request(unsigned char Data);
124static void nec765_setup_command(void);
123static void nec765_setup_command(running_machine *machine);
125124static TIMER_CALLBACK(nec765_continue_command);
126static int nec765_sector_count_complete(void);
127static void nec765_increment_sector(void);
128static void nec765_update_state(void);
125static int nec765_sector_count_complete(running_machine *machine);
126static void nec765_increment_sector(running_machine *machine);
127static void nec765_update_state(running_machine *machine);
129128static void nec765_set_dma_drq(int state);
130129static void nec765_set_int(int state);
131130
r2822r2823
144143
145144
146145
147static const device_config *current_image(void)
146static const device_config *current_image(running_machine *machine)
148147{
149148   const device_config *image = NULL;
150149
151150   if (!nec765_iface.get_image)
152151   {
153      if (fdc.drive < device_count(Machine, IO_FLOPPY))
152      if (fdc.drive < device_count(machine, IO_FLOPPY))
154153         image = image_from_devtype_and_index(IO_FLOPPY, fdc.drive);
155154   }
156155   else
r2822r2823
205204   fdc.FDC_main &= ~0x080;
206205}
207206
208static void nec765_seek_complete(void)
207static void nec765_seek_complete(running_machine *machine)
209208{
210209   /* tested on Amstrad CPC */
211210
r2822r2823
260259      This indicates it is always ready!!!!!
261260   */
262261
263   const device_config *img = current_image();
262   const device_config *img = current_image(machine);
264263
265264   if (!img)
266265      return;
r2822r2823
315314static TIMER_CALLBACK(nec765_seek_timer_callback)
316315{
317316   /* seek complete */
318   nec765_seek_complete();
317   nec765_seek_complete(machine);
319318
320319   timer_reset(fdc.seek_timer, attotime_never);
321320}
r2822r2823
435434   timer_adjust_periodic(fdc.seek_timer, attotime_zero, 0, double_to_attotime(fdc.srt_in_ms*abs(signed_tracks)*0.001));
436435}
437436
438static void nec765_seek_setup(int is_recalibrate)
437static void nec765_seek_setup(running_machine *machine, int is_recalibrate)
439438{
440439   const device_config *img;
441440   int signed_tracks;
r2822r2823
450449
451450   nec765_setup_drive_and_side();
452451
453   img = current_image();
452   img = current_image(machine);
454453
455454   fdc.FDC_main |= (1<<fdc.drive);
456455
r2822r2823
468467         )
469468      {
470469         /* seek completed */
471         nec765_seek_complete();
470         nec765_seek_complete(machine);
472471      }
473472      else
474473      {
r2822r2823
501500         }
502501         else
503502         {
504            nec765_seek_complete();
503            nec765_seek_complete(machine);
505504         }
506505      }
507506   }
r2822r2823
518517      /* if no tracks to seek, or drive is not ready, seek is complete */
519518      if ((signed_tracks==0) || (!floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY)))
520519      {
521         nec765_seek_complete();
520         nec765_seek_complete(machine);
522521      }
523522      else
524523      {
r2822r2823
677676
678677
679678
680void nec765_init(const nec765_interface *iface, NEC765_VERSION version, NEC765_RDY_PIN rdy_pin)
679void nec765_init(running_machine *machine, const nec765_interface *iface, NEC765_VERSION version, NEC765_RDY_PIN rdy_pin)
681680{
682681   int i;
683682
r2822r2823
695694
696695   fdc.nec765_flags &= NEC765_FDD_READY;
697696
698   nec765_reset(0);
697   nec765_reset(machine, 0);
699698
700   for (i = 0; i < device_count(Machine, IO_FLOPPY); i++)
699   for (i = 0; i < device_count(machine, IO_FLOPPY); i++)
701700      floppy_drive_set_ready_state_change_callback(image_from_devtype_and_index(IO_FLOPPY, i), nec765_set_ready_change_callback);
702701}
703702
704703
705704/* terminal count input */
706void nec765_set_tc_state(int state)
705void nec765_set_tc_state(running_machine *machine, int state)
707706{
708707   int old_state;
709708
r2822r2823
738737#ifdef NO_END_OF_CYLINDER
739738         timer_adjust_oneshot(fdc.command_timer, attotime_zero, 0);
740739#else
741         nec765_update_state();
740         nec765_update_state(machine);
742741#endif
743742      }
744743   }
r2822r2823
802801  - if the index is seen twice while it is searching for a sector, then the sector cannot be found
803802*/
804803
805static void nec765_get_next_id(chrn_id *id)
804static void nec765_get_next_id(running_machine *machine, chrn_id *id)
806805{
807   const device_config *img = current_image();
806   const device_config *img = current_image(machine);
808807
809808   /* get next id from disc */
810809   floppy_drive_get_next_id(img, fdc.side,id);
r2822r2823
819818   }
820819}
821820
822static int nec765_get_matching_sector(void)
821static int nec765_get_matching_sector(running_machine *machine)
823822{
824   const device_config *img = current_image();
823   const device_config *img = current_image(machine);
825824   chrn_id id;
826825
827826   /* number of times we have seen index hole */
r2822r2823
830829   /* get sector id's */
831830   do
832831    {
833      nec765_get_next_id(&id);
832      nec765_get_next_id(machine, &id);
834833
835834      /* tested on Amstrad CPC - All bytes must match, otherwise
836835      a NO DATA error is reported */
r2822r2823
930929   nec765_setup_result_phase(7);
931930}
932931
933static void nec765_read_data(void)
932static void nec765_read_data(running_machine *machine)
934933{
935   const device_config *img = current_image();
934   const device_config *img = current_image(machine);
936935
937936   if (!(floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY)))
938937   {
r2822r2823
963962      do
964963      {
965964         /* get matching sector */
966         if (nec765_get_matching_sector())
965         if (nec765_get_matching_sector(machine))
967966         {
968967
969968            /* skip it? */
r2822r2823
972971               /* yes */
973972
974973               /* check that we haven't finished reading all sectors */
975               if (nec765_sector_count_complete())
974               if (nec765_sector_count_complete(machine))
976975               {
977976                  /* read complete */
978977                  nec765_read_complete();
r2822r2823
982981               /* read not finished */
983982
984983               /* increment sector count */
985               nec765_increment_sector();
984               nec765_increment_sector(machine);
986985            }
987986            else
988987            {
r2822r2823
10121011}
10131012
10141013
1015static void nec765_format_track(void)
1014static void nec765_format_track(running_machine *machine)
10161015{
1017   const device_config *img = current_image();
1016   const device_config *img = current_image(machine);
10181017
10191018   /* write protected? */
10201019   if (floppy_drive_get_flag_state(img, FLOPPY_DRIVE_DISK_WRITE_PROTECTED))
r2822r2823
10381037    nec765_setup_execution_phase_write(&fdc.format_data[0], 4);
10391038}
10401039
1041static void     nec765_read_a_track(void)
1040static void nec765_read_a_track(running_machine *machine)
10421041{
10431042   int data_size;
10441043
r2822r2823
10471046   /* get next id */
10481047   chrn_id id;
10491048
1050   nec765_get_next_id(&id);
1049   nec765_get_next_id(machine, &id);
10511050
10521051   /* TO BE CONFIRMED! */
10531052   /* check id from disc */
r2822r2823
10701069
10711070   data_size = nec765_n_to_bytes(id.N);
10721071
1073   floppy_drive_read_sector_data(current_image(), fdc.side, fdc.sector_id,nec765_data_buffer,data_size);
1072   floppy_drive_read_sector_data(current_image(machine), fdc.side, fdc.sector_id,nec765_data_buffer,data_size);
10741073
10751074   nec765_setup_execution_phase_read(nec765_data_buffer, data_size);
10761075}
10771076
1078static int nec765_just_read_last_sector_on_track(void)
1077static int nec765_just_read_last_sector_on_track(running_machine *machine)
10791078{
1080   if (floppy_drive_get_flag_state(current_image(), FLOPPY_DRIVE_INDEX))
1079   if (floppy_drive_get_flag_state(current_image(machine), FLOPPY_DRIVE_INDEX))
10811080      return 1;
10821081   return 0;
10831082}
r2822r2823
11201119}
11211120
11221121
1123static void nec765_write_data(void)
1122static void nec765_write_data(running_machine *machine)
11241123{
1125   if (!(floppy_drive_get_flag_state(current_image(), FLOPPY_DRIVE_READY)))
1124   if (!(floppy_drive_get_flag_state(current_image(machine), FLOPPY_DRIVE_READY)))
11261125   {
11271126      fdc.nec765_status[0] = 0x0c0 | (1<<4) | fdc.drive | (fdc.side<<2);
11281127        fdc.nec765_status[1] = 0x00;
r2822r2823
11401139   }
11411140
11421141   /* write protected? */
1143   if (floppy_drive_get_flag_state(current_image(), FLOPPY_DRIVE_DISK_WRITE_PROTECTED))
1142   if (floppy_drive_get_flag_state(current_image(machine), FLOPPY_DRIVE_DISK_WRITE_PROTECTED))
11441143   {
11451144      fdc.nec765_status[1] |= NEC765_ST1_NOT_WRITEABLE;
11461145
r2822r2823
11481147      return;
11491148   }
11501149
1151   if (nec765_get_matching_sector())
1150   if (nec765_get_matching_sector(machine))
11521151   {
11531152      int data_size;
11541153
r2822r2823
11641163
11651164
11661165/* return true if we have read all sectors, false if not */
1167static int nec765_sector_count_complete(void)
1166static int nec765_sector_count_complete(running_machine *machine)
11681167{
11691168/* this is not correct?? */
11701169#if 1
r2822r2823
11931192      */
11941193
11951194      /* if just read last sector and on side 1 - finish */
1196      if ((nec765_just_read_last_sector_on_track()) &&
1195      if ((nec765_just_read_last_sector_on_track(machine)) &&
11971196         (fdc.side==1))
11981197      {
11991198         return 1;
r2822r2823
13001299   return 0;
13011300}
13021301
1303static void   nec765_increment_sector(void)
1302static void   nec765_increment_sector(running_machine *machine)
13041303{
13051304   /* multi-track? */
13061305   if (fdc.nec765_command_bytes[0] & 0x080)
13071306   {
13081307      /* reached EOT? */
13091308      /* if (fdc.nec765_command_bytes[4]==fdc.nec765_command_bytes[6])*/
1310      if (nec765_just_read_last_sector_on_track())
1309      if (nec765_just_read_last_sector_on_track(machine))
13111310      {
13121311         /* yes */
13131312
r2822r2823
14091408            }
14101409            else
14111410            {
1412               nec765_read_a_track();
1411               nec765_read_a_track(machine);
14131412            }
14141413         }
14151414         break;
r2822r2823
14171416         /* format track */
14181417         case 0x0d:
14191418         {
1420            floppy_drive_format_sector(current_image(), fdc.side, fdc.sector_counter,
1419            floppy_drive_format_sector(current_image(machine), fdc.side, fdc.sector_counter,
14211420               fdc.format_data[0], fdc.format_data[1],
14221421               fdc.format_data[2], fdc.format_data[3],
14231422               fdc.nec765_command_bytes[5]);
r2822r2823
14391438            }
14401439            else
14411440            {
1442               nec765_format_track();
1441               nec765_format_track(machine);
14431442            }
14441443         }
14451444         break;
r2822r2823
14581457            }
14591458
14601459            /* write data to disc */
1461            floppy_drive_write_sector_data(current_image(), fdc.side, fdc.sector_id,nec765_data_buffer,nec765_n_to_bytes(fdc.nec765_command_bytes[5]),ddam);
1460            floppy_drive_write_sector_data(current_image(machine), fdc.side, fdc.sector_id,nec765_data_buffer,nec765_n_to_bytes(fdc.nec765_command_bytes[5]),ddam);
14621461
1463            if (nec765_sector_count_complete())
1462            if (nec765_sector_count_complete(machine))
14641463            {
1465               nec765_increment_sector();
1464               nec765_increment_sector(machine);
14661465               nec765_write_complete();
14671466            }
14681467            else
14691468            {
1470               nec765_increment_sector();
1471               nec765_write_data();
1469               nec765_increment_sector(machine);
1470               nec765_write_data(machine);
14721471            }
14731472         }
14741473         break;
r2822r2823
14811480            /* read all sectors? */
14821481
14831482            /* sector id == EOT */
1484            if (nec765_sector_count_complete() || nec765_read_data_stop())
1483            if (nec765_sector_count_complete(machine) || nec765_read_data_stop())
14851484             {
14861485               nec765_read_complete();
14871486            }
14881487            else
14891488            {
1490               nec765_increment_sector();
1491               nec765_read_data();
1489               nec765_increment_sector(machine);
1490               nec765_read_data(machine);
14921491            }
14931492            }
14941493            break;
r2822r2823
15531552
15541553
15551554
1556void nec765_update_state(void)
1555void nec765_update_state(running_machine *machine)
15571556{
15581557   switch (fdc.nec765_phase) {
15591558   case NEC765_RESULT_PHASE:
r2822r2823
16411640
16421641      if (fdc.nec765_transfer_bytes_remaining==0)
16431642      {
1644         nec765_setup_command();
1643         nec765_setup_command(machine);
16451644      }
16461645      else
16471646      {
r2822r2823
16611660
16621661      if (fdc.nec765_transfer_bytes_remaining==0)
16631662      {
1664         nec765_setup_command();
1663         nec765_setup_command(machine);
16651664      }
16661665      else
16671666      {
r2822r2823
16881687}
16891688
16901689
1691 READ8_HANDLER(nec765_data_r)
1690READ8_HANDLER(nec765_data_r)
16921691{
16931692   if ((fdc.FDC_main & 0x0c0) == 0x0c0)
16941693   {
r2822r2823
17051704      nec765_clear_data_request();
17061705
17071706      /* update state */
1708      nec765_update_state();
1707      nec765_update_state(machine);
17091708   }
17101709
17111710   if (LOG_EXTRA)
r2822r2823
17371736      nec765_clear_data_request();
17381737
17391738      /* update state */
1740      nec765_update_state();
1739      nec765_update_state(machine);
17411740   }
17421741}
17431742
r2822r2823
17481747   nec765_setup_result_phase(1);
17491748}
17501749
1751static void nec765_setup_command(void)
1750static void nec765_setup_command(running_machine *machine)
17521751{
17531752   static const char *const commands[] =
17541753   {
r2822r2823
17751774      "Lock"                  /* [14] */
17761775   };
17771776
1778   const device_config *img = current_image();
1777   const device_config *img = current_image(machine);
17791778   const char *cmd = NULL;
17801779   chrn_id id;
17811780
r2822r2823
18371836         break;
18381837
18391838      case 0x07:          /* recalibrate */
1840         nec765_seek_setup(1);
1839         nec765_seek_setup(machine, 1);
18411840         break;
18421841
18431842      case 0x0f:          /* seek */
1844         nec765_seek_setup(0);
1843         nec765_seek_setup(machine, 0);
18451844         break;
18461845
18471846      case 0x0a:      /* read id */
r2822r2823
19661965         fdc.nec765_status[1] = 0;
19671966         fdc.nec765_status[2] = 0;
19681967
1969         nec765_read_data();
1968         nec765_read_data(machine);
19701969         break;
19711970
19721971      case 0x0c:
r2822r2823
19781977         fdc.nec765_status[2] = 0;
19791978
19801979         /* .. for now */
1981         nec765_read_data();
1980         nec765_read_data(machine);
19821981         break;
19831982
19841983      case 0x09:
r2822r2823
19901989         fdc.nec765_status[2] = 0;
19911990
19921991         /* ... for now */
1993         nec765_write_data();
1992         nec765_write_data(machine);
19941993         break;
19951994
19961995      case 0x02:
r2822r2823
20132012
20142013         fdc.sector_counter = 0;
20152014
2016         nec765_read_a_track();
2015         nec765_read_a_track(machine);
20172016         break;
20182017
20192018      case 0x05:  /* write data */
r2822r2823
20232022         fdc.nec765_status[1] = 0;
20242023         fdc.nec765_status[2] = 0;
20252024
2026         nec765_write_data();
2025         nec765_write_data(machine);
20272026         break;
20282027
20292028      case 0x0d:   /* format a track */
r2822r2823
20352034
20362035         fdc.sector_counter = 0;
20372036
2038         nec765_format_track();
2037         nec765_format_track(machine);
20392038         break;
20402039
20412040      default:   /* invalid */
r2822r2823
21142113}
21152114
21162115
2117void nec765_reset(int offset)
2116void nec765_reset(running_machine *machine, int offset)
21182117{
21192118   /* nec765 in idle state - ready to accept commands */
21202119   nec765_idle();
r2822r2823
21402139      are checked or only the drive selected with the drive select bits?? */
21412140
21422141      a_drive_is_ready = 0;
2143      for (i = 0; i < device_count(Machine, IO_FLOPPY); i++)
2142      for (i = 0; i < device_count(machine, IO_FLOPPY); i++)
21442143      {
21452144         if (image_exists(image_from_devtype_and_index(IO_FLOPPY, i)))
21462145         {
r2822r2823
21592158   }
21602159}
21612160
2162void nec765_set_reset_state(int state)
2161void nec765_set_reset_state(running_machine *machine, int state)
21632162{
21642163   int flags;
21652164
r2822r2823
21872186      if ((fdc.nec765_flags & NEC765_RESET)==0)
21882187      {
21892188         /* reset nec */
2190         nec765_reset(0);
2189         nec765_reset(machine, 0);
21912190      }
21922191   }
21932192}
src/mess/machine/nec765.h
r2822r2823
4444} nec765_interface;
4545
4646/* init nec765 interface */
47void nec765_init(const nec765_interface *iface, NEC765_VERSION version, NEC765_RDY_PIN rdy_pin);
47void nec765_init(running_machine *machine, const nec765_interface *iface, NEC765_VERSION version, NEC765_RDY_PIN rdy_pin);
4848/* set nec765 terminal count input state */
49void nec765_set_tc_state(int);
49void nec765_set_tc_state(running_machine *machine, int);
5050/* set nec765 ready input*/
5151void nec765_set_ready_state(int);
5252
r2822r2823
6565READ8_HANDLER(nec765_dack_r);
6666
6767/* reset nec765 */
68void nec765_reset(int);
68void nec765_reset(running_machine *machine, int);
6969
7070/* reset pin of nec765 */
71void nec765_set_reset_state(int);
71void nec765_set_reset_state(running_machine *machine, int);
7272
7373/*********************/
7474/* STATUS REGISTER 1 */
src/mess/machine/msx.c
r2822r2823
281281   cpunum_set_input_line (machine, 0, 0, (i ? HOLD_LINE : CLEAR_LINE));
282282}
283283
284static void msx_ch_reset_core (void)
284static void msx_ch_reset_core (running_machine *machine)
285285{
286   msx_memory_reset ();
286   msx_memory_reset (machine);
287287   msx_memory_map_all ();
288288}
289289
r2822r2823
313313MACHINE_RESET( msx )
314314{
315315   TMS9928A_reset ();
316   msx_ch_reset_core ();
316   msx_ch_reset_core (machine);
317317}
318318
319319MACHINE_RESET( msx2 )
320320{
321321   v9938_reset (0);
322   msx_ch_reset_core ();
322   msx_ch_reset_core (machine);
323323}
324324
325325static WRITE8_HANDLER ( msx_ppi_port_a_w );
r2822r2823
877877   }
878878}
879879
880void msx_memory_reset (void)
880void msx_memory_reset (running_machine *machine)
881881{
882882   slot_state *state, *last_state= (slot_state*)NULL;
883883   int prim, sec, page;
r2822r2823
890890         for (page=0; page<4; page++) {
891891            state = msx1.all_state[prim][sec][page];
892892            if (state && state != last_state) {
893               msx_slot_list[state->type].reset (state);
893               msx_slot_list[state->type].reset (machine, state);
894894            }
895895            last_state = state;
896896         }
src/mess/machine/pclpt.c
r2822r2823
66
77
88#include "driver.h"
9#include "deprecat.h"
109#include "memconv.h"
1110#include "includes/pclpt.h"
1211#include "machine/centroni.h"
r2822r2823
5655   This->device=device;
5756}
5857
59static void pc_LPT_w(int n, int offset, int data)
58static void pc_LPT_w(running_machine *machine, int n, int offset, int data)
6059{
6160   PC_LPT *This=LPT+n;
62   if ( !(input_port_read(Machine, "DSW1") & (0x08>>n)) ) return;
61   if ( !(input_port_read(machine, "DSW1") & (0x08>>n)) ) return;
6362//   if (!This->on) return;
6463   switch( offset )
6564   {
r2822r2823
9089    }
9190}
9291
93static int pc_LPT_r(int n, int offset)
92static int pc_LPT_r(running_machine *machine, int n, int offset)
9493{
9594   PC_LPT *This=LPT+n;
9695    int data = 0xff;
97   if ( !(input_port_read(Machine, "DSW1") & (0x08>>n)) ) return data;
96   if ( !(input_port_read(machine, "DSW1") & (0x08>>n)) ) return data;
9897//   if (!This->on) return data;
9998   switch( offset )
10099   {
r2822r2823
150149   This->status=neu;
151150}
152151
153READ8_HANDLER ( pc_parallelport0_r) { return pc_LPT_r(0, offset); }
154READ8_HANDLER ( pc_parallelport1_r) { return pc_LPT_r(1, offset); }
155READ8_HANDLER ( pc_parallelport2_r) { return pc_LPT_r(2, offset); }
156WRITE8_HANDLER ( pc_parallelport0_w ) { pc_LPT_w(0,offset,data); }
157WRITE8_HANDLER ( pc_parallelport1_w ) { pc_LPT_w(1,offset,data); }
158WRITE8_HANDLER ( pc_parallelport2_w ) { pc_LPT_w(2,offset,data); }
152READ8_HANDLER ( pc_parallelport0_r) { return pc_LPT_r(machine, 0, offset); }
153READ8_HANDLER ( pc_parallelport1_r) { return pc_LPT_r(machine, 1, offset); }
154READ8_HANDLER ( pc_parallelport2_r) { return pc_LPT_r(machine, 2, offset); }
155WRITE8_HANDLER ( pc_parallelport0_w ) { pc_LPT_w(machine,0,offset,data); }
156WRITE8_HANDLER ( pc_parallelport1_w ) { pc_LPT_w(machine,1,offset,data); }
157WRITE8_HANDLER ( pc_parallelport2_w ) { pc_LPT_w(machine,2,offset,data); }
159158
160159READ16_HANDLER ( pc16le_parallelport0_r ) { return read16le_with_read8_handler(pc_parallelport0_r, machine, offset, mem_mask); }
161160READ16_HANDLER ( pc16le_parallelport1_r ) { return read16le_with_read8_handler(pc_parallelport1_r, machine, offset, mem_mask); }
src/mess/machine/sym1.c
r2822r2823
289289   r6532_reset(0);
290290
291291   /* configure 74145 */
292   ttl74145_config(0, &ttl74145_intf);
292   ttl74145_config(machine, 0, &ttl74145_intf);
293293
294294   /* allocate a timer to refresh the led display */
295295   led_update = timer_alloc(led_refresh, NULL);
src/mess/machine/geneve.c
r2822r2823
2828static void intb_callback(running_machine *machine, int state);
2929
3030static void read_key_if_possible(void);
31static void poll_keyboard(void);
32static void poll_mouse(void);
31static void poll_keyboard(running_machine *machine);
32static void poll_mouse(running_machine *machine);
3333
3434static void tms9901_interrupt_callback(int intreq, int ic);
3535static int R9901_0(int offset);
r2822r2823
331331   if (++line_count == 262)
332332   {
333333      line_count = 0;
334      poll_keyboard();
335      poll_mouse();
334      poll_keyboard(machine);
335      poll_mouse(machine);
336336   }
337337}
338338
r2822r2823
10301030   KeyQueueLen++;
10311031}
10321032
1033static void poll_keyboard(void)
1033static void poll_keyboard(running_machine *machine)
10341034{
1035   running_machine *machine = Machine;
10361035   UINT32 keystate;
10371036   UINT32 key_transitions;
10381037   int i, j;
r2822r2823
12701269   }
12711270}
12721271
1273static void poll_mouse(void)
1272static void poll_mouse(running_machine *machine)
12741273{
12751274   static int last_mx = 0, last_my = 0;
12761275   int new_mx, new_my;
12771276   int delta_x, delta_y, buttons;
12781277
1279   buttons = input_port_read(Machine, "MOUSE0");
1280   new_mx = input_port_read(Machine, "MOUSEX");
1281   new_my = input_port_read(Machine, "MOUSEY");
1278   buttons = input_port_read(machine, "MOUSE0");
1279   new_mx = input_port_read(machine, "MOUSEX");
1280   new_my = input_port_read(machine, "MOUSEY");
12821281
12831282   /* compute x delta */
12841283   delta_x = new_mx - last_mx;
r2822r2823
14471446      KeyAutoRepeatKey = 0;
14481447   }
14491448   /*else
1450      poll_keyboard();*/
1449      poll_keyboard(Machine);*/
14511450}
14521451
14531452/*
src/mess/machine/beta.c
r2822r2823
117117        wd17xx_set_density(data & 0x20 ? DEN_MFM_HI : DEN_FM_LO );
118118        if ((data & 0x04) == 0) // reset
119119        {
120           wd17xx_reset();   
120           wd17xx_reset(machine);   
121121        }         
122122        betadisk_status = (data & 0x3f) | betadisk_status;
123123     }
src/mess/machine/pc8801.c
r2822r2823
794794    NULL
795795};
796796
797 READ8_HANDLER(pc8801fd_nec765_tc)
797READ8_HANDLER(pc8801fd_nec765_tc)
798798{
799  nec765_set_tc_state(1);
800  nec765_set_tc_state(0);
799  nec765_set_tc_state(machine, 1);
800  nec765_set_tc_state(machine, 0);
801801  return 0;
802802}
803803
r2822r2823
825825      cpunum_suspend(1, SUSPEND_REASON_DISABLE, 1);
826826   else
827827      cpunum_resume(1, SUSPEND_REASON_DISABLE);
828   nec765_init(&pc8801_fdc_interface,NEC765A,NEC765_RDY_PIN_CONNECTED);
828   nec765_init(machine, &pc8801_fdc_interface,NEC765A,NEC765_RDY_PIN_CONNECTED);
829829   cpunum_set_input_line_vector(1,0,0);
830830   floppy_drive_set_motor_state(image_from_devtype_and_index(IO_FLOPPY, 0), 1);
831831   floppy_drive_set_motor_state(image_from_devtype_and_index(IO_FLOPPY, 1), 1);
src/mess/machine/pc_fdc.c
r2822r2823
6767   pc_fdc_get_image
6868};
6969
70static void pc_fdc_reset(void)
70static void pc_fdc_reset(running_machine *machine)
7171{
7272   /* setup reset condition */
7373   fdc->data_rate_register = 2;
r2822r2823
7676   /* bit 7 is disk change */
7777   fdc->digital_input_register = 0x07f;
7878
79   nec765_reset(0);
79   nec765_reset(machine, 0);
8080
8181   /* set FDC at reset */
82   nec765_set_reset_state(1);
82   nec765_set_reset_state(machine, 1);
8383}
8484
8585
8686
87void pc_fdc_init(const struct pc_fdc_interface *iface)
87void pc_fdc_init(running_machine *machine, const struct pc_fdc_interface *iface)
8888{
8989   int i;
9090   const device_config *img;
r2822r2823
9898      memcpy(&fdc->fdc_interface, iface, sizeof(fdc->fdc_interface));
9999
100100   /* setup nec765 interface */
101   nec765_init(&pc_fdc_nec765_interface, iface->nec765_type, iface->nec765_rdy_pin);
101   nec765_init(machine, &pc_fdc_nec765_interface, iface->nec765_type, iface->nec765_rdy_pin);
102102
103103   fdc->watchdog = timer_alloc( watchdog_timeout, NULL );
104104
105   pc_fdc_reset();
105   pc_fdc_reset(machine);
106106
107   for (i = 0; i < device_count(Machine, IO_FLOPPY); i++)
107   for (i = 0; i < device_count(machine, IO_FLOPPY); i++)
108108   {
109109      img = image_from_devtype_and_index(IO_FLOPPY, i);
110110      floppy_drive_set_geometry(img, FLOPPY_DRIVE_DS_80);
r2822r2823
131131
132132
133133
134void pc_fdc_set_tc_state(int state)
134void pc_fdc_set_tc_state(running_machine *machine, int state)
135135{
136136   /* store state */
137137   fdc->tc_state = state;
r2822r2823
139139   /* if dma is not enabled, tc's are not acknowledged */
140140   if ((fdc->digital_output_register & PC_FDC_FLAGS_DOR_DMA_ENABLED)!=0)
141141   {
142      nec765_set_tc_state(state);
142      nec765_set_tc_state(machine, state);
143143   }
144144}
145145
r2822r2823
160160
161161
162162
163int   pc_fdc_dack_r(void)
163int   pc_fdc_dack_r(running_machine *machine)
164164{
165165   int data;
166166
r2822r2823
170170   /* if dma is not enabled, dacks are not acknowledged */
171171   if ((fdc->digital_output_register & PC_FDC_FLAGS_DOR_DMA_ENABLED)!=0)
172172   {
173      data = nec765_dack_r(Machine, 0);
173      data = nec765_dack_r(machine, 0);
174174   }
175175
176176   return data;
r2822r2823
178178
179179
180180
181void pc_fdc_dack_w(int data)
181void pc_fdc_dack_w(running_machine *machine, int data)
182182{
183183   /* if dma is not enabled, dacks are not issued */
184184   if ((fdc->digital_output_register & PC_FDC_FLAGS_DOR_DMA_ENABLED)!=0)
185185   {
186186      /* dma acknowledge - and send byte to fdc */
187      nec765_dack_w(Machine, 0,data);
187      nec765_dack_w(machine, 0,data);
188188   }
189189}
190190
r2822r2823
205205
206206
207207
208static void pc_fdc_data_rate_w(UINT8 data)
208static void pc_fdc_data_rate_w(running_machine *machine, UINT8 data)
209209{
210210   if ((data & 0x080)!=0)
211211   {
r2822r2823
213213      nec765_set_ready_state(1);
214214
215215      /* toggle reset state */
216      nec765_set_reset_state(1);
217       nec765_set_reset_state(0);
216      nec765_set_reset_state(Machine, 1);
217       nec765_set_reset_state(Machine, 0);
218218
219219      /* bit is self-clearing */
220220      data &= ~0x080;
r2822r2823
270270   /* changing the DMA enable bit, will affect the terminal count state
271271   from reaching the fdc - if dma is enabled this will send it through
272272   otherwise it will be ignored */
273   pc_fdc_set_tc_state(fdc->tc_state);
273   pc_fdc_set_tc_state(machine, fdc->tc_state);
274274
275275   /* changing the DMA enable bit, will affect the dma drq state
276276   from reaching us - if dma is enabled this will send it through
r2822r2823
306306         nec765_set_ready_state(1);
307307
308308      /* set FDC at reset */
309      nec765_set_reset_state(1);
309      nec765_set_reset_state(machine, 1);
310310   }
311311   else
312312   {
313      pc_fdc_set_tc_state(0);
313      pc_fdc_set_tc_state(machine, 0);
314314
315315      /* release reset on fdc */
316      nec765_set_reset_state(0);
316      nec765_set_reset_state(machine, 0);
317317   }
318318}
319319
r2822r2823
395395         nec765_set_ready_state(1);
396396
397397      /* set FDC at reset */
398      nec765_set_reset_state(1);
398      nec765_set_reset_state(machine, 1);
399399   }
400400   else
401401   {
402      pc_fdc_set_tc_state(0);
402      pc_fdc_set_tc_state(machine, 0);
403403
404404      /* release reset on fdc */
405      nec765_set_reset_state(0);
405      nec765_set_reset_state(machine, 0);
406406   }
407407
408408   logerror("pcjr_fdc_dor_w: changing dor from %02x to %02x\n", fdc->digital_output_register, data);
r2822r2823
462462         /* tape drive select? */
463463         break;
464464      case 4:
465         pc_fdc_data_rate_w(data);
465         pc_fdc_data_rate_w(machine, data);
466466         break;
467467      case 5:
468468         nec765_data_w(machine, 0, data);
src/mess/machine/pc_fdc.h
r2822r2823
3434};
3535
3636
37void pc_fdc_init(const struct pc_fdc_interface *iface);
38void pc_fdc_set_tc_state(int state);
39int   pc_fdc_dack_r(void);
40void pc_fdc_dack_w(int);
37void pc_fdc_init(running_machine *machine, const struct pc_fdc_interface *iface);
38void pc_fdc_set_tc_state(running_machine *machine, int state);
39int   pc_fdc_dack_r(running_machine *machine);
40void pc_fdc_dack_w(running_machine *machine, int);
4141
4242READ8_HANDLER(pc_fdc_r);
4343WRITE8_HANDLER(pc_fdc_w);
src/mess/machine/bebox.c
r2822r2823
728728
729729
730730static DMA8237_CHANNEL_READ( bebox_dma8237_fdc_dack_r ) {
731   return pc_fdc_dack_r();
731   return pc_fdc_dack_r(device->machine);
732732}
733733
734734
735735static DMA8237_CHANNEL_WRITE( bebox_dma8237_fdc_dack_w ) {
736   pc_fdc_dack_w( data );
736   pc_fdc_dack_w( device->machine, data );
737737}
738738
739739
740740static DMA8237_OUT_EOP( bebox_dma8237_out_eop ) {
741   pc_fdc_set_tc_state( state );
741   pc_fdc_set_tc_state( device->machine, state );
742742}
743743
744744
r2822r2823
10841084
10851085MACHINE_START( bebox )
10861086{
1087   pc_fdc_init(&bebox_fdc_interface);
1087   pc_fdc_init(machine, &bebox_fdc_interface);
10881088   /* SCSI */
10891089   lsi53c810_init(&scsi53c810_intf);
10901090   add_exit_callback(machine, bebox_exit);
src/mess/machine/mtx.c
r2822r2823
99
1010/* Core includes */
1111#include "driver.h"
12#include "deprecat.h"
1312#include "includes/mtx.h"
1413
1514/* Components */
src/mess/machine/special.c
r2822r2823
242242{
243243   specimx_set_bank(machine, 2,0x00); // Initiali load ROM disk
244244   specimx_color = 0x70;   
245   wd17xx_reset();
245   wd17xx_reset(machine);
246246   wd17xx_set_side(0);
247247   timer_set( attotime_zero, NULL, 0, setup_pit8253_gates );
248248}
r2822r2823
392392
393393MACHINE_RESET( erik )
394394{
395   wd17xx_reset();     
395   wd17xx_reset(machine);     
396396   
397397   RR_register = 0x00;   
398398   RC_register = 0x00;
src/mess/machine/c64.c
r2822r2823
699699   else if (is_c65(Machine))
700700   {
701701      // NPW 8-Feb-2004 - Don't know why I have to do this
702      //c65_bankswitch();
702      //c65_bankswitch(Machine);
703703   }
704704   else if (!ultimax)
705705      c64_bankswitch(Machine, 0);
r2822r2823
965965   c64_common_init_machine (machine);
966966
967967   c64_rom_recognition ();
968   c64_rom_load();
968   c64_rom_load(machine);
969969
970970   if (is_c128(machine))
971971      c128_bankswitch_64(machine, 1);
r2822r2823
999999    }
10001000}
10011001
1002void c64_rom_load(void)
1002void c64_rom_load(running_machine *machine)
10031003{
10041004    int i;
10051005
r2822r2823
10071007    c64_game = 1;
10081008    if (cartridge)
10091009    {
1010      if (((input_port_read(Machine, "CFG") & 0x1c ) == 0) && (cartridgetype == CartridgeAuto))   // AUTO_MODULE
1010      if (((input_port_read(machine, "CFG") & 0x1c ) == 0) && (cartridgetype == CartridgeAuto))   // AUTO_MODULE
10111011      {
1012         logerror("Cartridge type not recognized using Machine type\n");
1012         logerror("Cartridge type not recognized using machine type\n");
10131013      }
10141014   
1015      if (((input_port_read(Machine, "CFG") & 0x1c ) == 8) && (cartridgetype == CartridgeUltimax))// C64_MODULE
1015      if (((input_port_read(machine, "CFG") & 0x1c ) == 8) && (cartridgetype == CartridgeUltimax))// C64_MODULE
10161016      {
10171017         logerror("Cartridge could be ultimax type!?\n");
10181018      }
10191019   
1020      if (((input_port_read(Machine, "CFG") & 0x1c ) == 4) && (cartridgetype == CartridgeC64))   // ULTIMAX_MODULE
1020      if (((input_port_read(machine, "CFG") & 0x1c ) == 4) && (cartridgetype == CartridgeC64))   // ULTIMAX_MODULE
10211021      {
10221022         logerror("Cartridge could be c64 type!?\n");
10231023      }
10241024
1025      if ((input_port_read(Machine, "CFG") & 0x1c ) == 8)         // C64_MODULE
1025      if ((input_port_read(machine, "CFG") & 0x1c ) == 8)         // C64_MODULE
10261026         cartridgetype = CartridgeC64;
10271027
1028      else if ((input_port_read(Machine, "CFG") & 0x1c ) == 4)   // ULTIMAX_MODULE
1028      else if ((input_port_read(machine, "CFG") & 0x1c ) == 4)   // ULTIMAX_MODULE
10291029         cartridgetype = CartridgeUltimax;
10301030
10311031      if ((cbm_c64_exrom!=-1)&&(cbm_c64_game!=-1))
src/mess/machine/pc.c
r2822r2823
119119
120120static DMA8237_CHANNEL_READ( pc_dma8237_fdc_dack_r )
121121{
122   return pc_fdc_dack_r();
122   return pc_fdc_dack_r(device->machine);
123123}
124124
125125
r2822r2823
131131
132132static DMA8237_CHANNEL_WRITE( pc_dma8237_fdc_dack_w )
133133{
134   pc_fdc_dack_w( data );
134   pc_fdc_dack_w( device->machine, data );
135135}
136136
137137
r2822r2823
143143
144144static DMA8237_OUT_EOP( pc_dma8237_out_eop )
145145{
146   pc_fdc_set_tc_state( state );
146   pc_fdc_set_tc_state( device->machine, state );
147147}
148148
149149
r2822r2823
10061006
10071007MACHINE_START( pc )
10081008{
1009   pc_fdc_init( &fdc_interface_nc );
1009   pc_fdc_init( machine, &fdc_interface_nc );
10101010}
10111011
10121012
src/mess/machine/bbc.c
r2822r2823
21882188      i8271_reset();
21892189   //   break;
21902190   //case 4: case 5: case 6:
2191       wd17xx_reset();
2191       wd17xx_reset(machine);
21922192   //   break;
21932193   //}
21942194}
r2822r2823
22262226   MC6850_config(&BBC_MC6850_calls);
22272227
22282228   previous_wd177x_int_state=1;
2229    wd17xx_reset();
2229    wd17xx_reset(machine);
22302230}
22312231
22322232
r2822r2823
22632263   MC6850_config(&BBC_MC6850_calls);
22642264
22652265   previous_wd177x_int_state=1;
2266    wd17xx_reset();
2266    wd17xx_reset(machine);
22672267}
src/mess/machine/kc.c
r2822r2823
203203WRITE8_HANDLER(kc85_disc_hw_terminal_count_w)
204204{
205205   logerror("kc85 disc hw tc w: %02x\n",data);
206   nec765_set_tc_state(data & 0x01);
206   nec765_set_tc_state(machine, data & 0x01);
207207}
208208
209209
r2822r2823
239239{
240240   timer_set(attotime_zero, NULL, 0, kc85_disk_reset_timer_callback);
241241
242   nec765_init(&kc_fdc_interface,NEC765A,NEC765_RDY_PIN_CONNECTED);
242   nec765_init(machine, &kc_fdc_interface,NEC765A,NEC765_RDY_PIN_CONNECTED);
243243
244244   /* reset ctc */
245245   z80ctc_reset(1);
src/mess/drivers/nc.c
r2822r2823
13621362
13631363    nc_common_init_machine(machine);
13641364
1365    nec765_init(&nc200_nec765_interface, NEC765A,NEC765_RDY_PIN_CONNECTED);
1365    nec765_init(machine, &nc200_nec765_interface, NEC765A,NEC765_RDY_PIN_CONNECTED);
13661366    /* double sided, 80 track drive */
13671367   floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 0), FLOPPY_DRIVE_DS_80);
13681368   //floppy_drive_set_index_pulse_callback(image_from_devtype_and_index(IO_FLOPPY, 0), nc200_floppy_drive_index_callback);
r2822r2823
15181518   floppy_drive_set_motor_state(0,1);
15191519   floppy_drive_set_ready_state(0,1,1);
15201520#endif
1521   nec765_set_tc_state((data & 0x01));
1521   nec765_set_tc_state(machine, (data & 0x01));
15221522}
15231523
15241524/* bit 2: backlight: 1=off, 0=on */
src/mess/drivers/sord.c
r2822r2823
133133
134134static WRITE8_HANDLER(fd5_tc_w)
135135{
136   nec765_set_tc_state(1);
137   nec765_set_tc_state(0);
136   nec765_set_tc_state(machine, 1);
137   nec765_set_tc_state(machine, 0);
138138}
139139
140140/* 0x020 fd5 writes to this port to communicate with m5 */
r2822r2823
176176   NULL
177177};
178178
179static void sord_fd5_init(void)
179static void sord_fd5_init(running_machine *machine)
180180{
181   nec765_init(&sord_fd5_nec765_interface,NEC765A,NEC765_RDY_PIN_CONNECTED);
181   nec765_init(machine, &sord_fd5_nec765_interface,NEC765A,NEC765_RDY_PIN_CONNECTED);
182182}
183183
184184static MACHINE_RESET( sord_m5_fd5 )
185185{
186186   floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 0), FLOPPY_DRIVE_SS_40);
187187   floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 1), FLOPPY_DRIVE_SS_40);
188   sord_fd5_init();
188   sord_fd5_init(machine);
189189   MACHINE_RESET_CALL(sord_m5);
190190   ppi8255_set_portC((device_config*)device_list_find_by_tag( machine->config->devicelist, PPI8255, "ppi8255" ), 0x50);
191191}
src/mess/drivers/pentagon.c
r2822r2823
102102
103103   pentagon_update_memory(machine);   
104104     
105   wd17xx_reset();   
105   wd17xx_reset(machine);   
106106}
107107
108108static MACHINE_DRIVER_START( pentagon )
src/mess/drivers/pcw16.c
r2822r2823
11021102      /* set terminal count */
11031103      case 0x05:
11041104      {
1105         pc_fdc_set_tc_state(1);
1105         pc_fdc_set_tc_state(machine, 1);
11061106      }
11071107      break;
11081108
11091109      /* clear terminal count */
11101110      case 0x06:
11111111      {
1112         pc_fdc_set_tc_state(0);
1112         pc_fdc_set_tc_state(machine, 0);
11131113      }
11141114      break;
11151115
r2822r2823
13111311   /* initialise defaults */
13121312   pcw16_fdc_int_code = 2;
13131313   /* clear terminal count */
1314   pc_fdc_set_tc_state(0);
1314   pc_fdc_set_tc_state(machine, 0);
13151315   /* select first rom page */
13161316   pcw16_banks[0] = 0;
13171317   pcw16_update_memory(machine);
r2822r2823
13571357   timer_pulse(ATTOTIME_IN_HZ(50), NULL, 0, pcw16_keyboard_timer_callback);
13581358
13591359
1360   pc_fdc_init(&pcw16_fdc_interface);
1360   pc_fdc_init(machine, &pcw16_fdc_interface);
13611361
13621362   pc_lpt_config(0, &lpt_config);
13631363   centronics_config(0, &cent_config);
src/mess/drivers/scorpion.c
r2822r2823
309309
310310   scorpion_update_memory(machine);   
311311     
312   wd17xx_reset();   
312   wd17xx_reset(machine);   
313313   
314314   timer_pulse(ATTOTIME_IN_HZ(50), NULL, 0, nmi_check_callback);
315315}
src/mess/drivers/specpls3.c
r2822r2823
347347{
348348   memset(mess_ram,0,128*1024);
349349   
350   nec765_init(&spectrum_plus3_nec765_interface, NEC765A, NEC765_RDY_PIN_CONNECTED);
350   nec765_init(machine, &spectrum_plus3_nec765_interface, NEC765A, NEC765_RDY_PIN_CONNECTED);
351351
352352   floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 0), FLOPPY_DRIVE_SS_40);
353353   floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 1), FLOPPY_DRIVE_SS_40);
src/mess/drivers/x68k.c
r2822r2823
19431943   sys.crtc.reg[7] = 552;  // Vertical end
19441944   sys.crtc.reg[8] = 27;   // Horizontal adjust
19451945
1946   nec765_reset(0);
1946   nec765_reset(machine, 0);
19471947   mfp_init();
19481948
19491949   x68k_scanline = video_screen_get_vpos(machine->primary_screen);// = sys.crtc.reg[6];  // Vertical start
r2822r2823
19831983   timer_adjust_periodic(mouse_timer, attotime_zero, 0, ATTOTIME_IN_MSEC(1));  // a guess for now
19841984   sys.mouse.inputtype = 0;
19851985
1986   nec765_init(&fdc_interface,NEC72065,NEC765_RDY_PIN_CONNECTED);
1987   nec765_reset(0);
1986   nec765_init(machine, &fdc_interface,NEC72065,NEC765_RDY_PIN_CONNECTED);
1987   nec765_reset(machine, 0);
19881988}
19891989
19901990static DRIVER_INIT( x68000 )
src/mess/drivers/sg1000.c
r2822r2823
479479   floppy_drive_set_motor_state(image_from_devtype_and_index(IO_FLOPPY, 0), (data & 0x02) ? 0 : 1);
480480   floppy_drive_set_ready_state(image_from_devtype_and_index(IO_FLOPPY, 0), 1, 0);
481481
482   nec765_set_tc_state(data & 0x04);
482   nec765_set_tc_state(machine, data & 0x04);
483483
484484   if (data & 0x08)
485485   {
486      nec765_reset(0);
486      nec765_reset(machine, 0);
487487   }
488488
489489   memory_set_bank(1, (data & 0x40) >> 6);
r2822r2823
545545static MACHINE_START( sf7000 )
546546{
547547   TMS9928A_configure(&tms9928a_interface);
548   nec765_init(&sf7000_nec765_interface, NEC765A, NEC765_RDY_PIN_CONNECTED);
548   nec765_init(machine, &sf7000_nec765_interface, NEC765A, NEC765_RDY_PIN_CONNECTED);
549549   floppy_drive_set_index_pulse_callback(image_from_devtype_and_index(IO_FLOPPY, 0), sf7000_fdc_index_callback);
550550   msm8251_init(&sf7000_uart_interface);
551551   centronics_config(1, sf7000_centronics_config);
src/mess/drivers/pcw.c
r2822r2823
516516      /* set fdc terminal count */
517517      case 5:
518518      {
519         nec765_set_tc_state(1);
519         nec765_set_tc_state(machine, 1);
520520      }
521521      break;
522522
523523      /* clear fdc terminal count */
524524      case 6:
525525      {
526         nec765_set_tc_state(0);
526         nec765_set_tc_state(machine, 0);
527527      }
528528      break;
529529
r2822r2823
744744
745745static MACHINE_START( pcw )
746746{
747   nec765_init(&pcw_nec765_interface,NEC765A,NEC765_RDY_PIN_CONNECTED);
747   nec765_init(machine, &pcw_nec765_interface,NEC765A,NEC765_RDY_PIN_CONNECTED);
748748   fdc_interrupt_code = 0;
749749   floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 0), FLOPPY_DRIVE_DS_80);
750750}
src/mess/drivers/acrnsys1.c
r2822r2823
7878
7979static DRIVER_INIT( acrnsys1 )
8080{
81   ttl74145_config(0, &ic8_7445);
81   ttl74145_config(machine, 0, &ic8_7445);
8282}
8383
8484static MACHINE_RESET( acrnsys1 )
src/mess/drivers/newbrain.c
r2822r2823
245245   floppy_drive_set_motor_state(image_from_devtype_and_index(IO_FLOPPY, 0), BIT(data, 0));
246246   floppy_drive_set_ready_state(image_from_devtype_and_index(IO_FLOPPY, 0), 1, 0);
247247
248   nec765_set_reset_state(BIT(data, 1));
248   nec765_set_reset_state(machine, BIT(data, 1));
249249
250   nec765_set_tc_state(BIT(data, 2));
250   nec765_set_tc_state(machine, BIT(data, 2));
251251}
252252
253253static WRITE8_HANDLER( fdc_io_w )
r2822r2823
796796
797797   /* initialize devices */
798798
799   nec765_init(&newbrain_nec765_interface, NEC765A, NEC765_RDY_PIN_NOT_CONNECTED);
799   nec765_init(machine, &newbrain_nec765_interface, NEC765A, NEC765_RDY_PIN_NOT_CONNECTED);
800800   acia6850_config(0, &newbrain_acia_intf);
801801   z80ctc_init(0, &newbrain_ctc_intf);
802802
src/mess/drivers/amstrad.c
r2822r2823
20432043
20442044   if(amstrad_system_type != SYSTEM_GX4000)
20452045   {
2046      nec765_init(&amstrad_nec765_interface,NEC765A/*?*/,NEC765_RDY_PIN_CONNECTED);
2046      nec765_init(machine, &amstrad_nec765_interface,NEC765A/*?*/,NEC765_RDY_PIN_CONNECTED);
20472047      floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 0),  FLOPPY_DRIVE_SS_40);
20482048      floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 1),  FLOPPY_DRIVE_SS_40);
20492049   }
r2822r2823
22322232   amstrad_common_init(machine);
22332233   amstrad_reset_machine(machine);
22342234
2235   nec765_init(&aleste_8272_interface,NEC765A,NEC765_RDY_PIN_CONNECTED);
2235   nec765_init(machine, &aleste_8272_interface,NEC765A,NEC765_RDY_PIN_CONNECTED);
22362236   floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 0),  FLOPPY_DRIVE_DS_80);
22372237   floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 1),  FLOPPY_DRIVE_DS_80);
22382238}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team