Previous 15994 Revisions Next

r3581 Wednesday 26th November, 2008 at 12:43:14 UTC by Miodrag Milanović
[SPECTRUM] Enabling Sinclair drivers, pentagon/scorpion/zx8x crashing
[src/mess]mess.mak messdriv.c
[src/mess/drivers]pentagon.c scorpion.c spec128.c specpls3.c spectrum.c timex.c
[src/mess/machine]beta.c spectrum.c zx.c
[src/mess/video]zx.c

src/mess/video/zx.c
r3580r3581
111111
112112   r.min_y = r.max_y = ula_scanline_count;
113113   fillbitmap(bitmap, 1, &r);
114//   logerror("ULA %3d[%d] NMI, R:$%02X, $%04x\n", video_screen_get_vpos(machine->primary_screen), ula_scancode_count, (unsigned) cpunum_get_reg(0, Z80_R), (unsigned) cpunum_get_reg(0, Z80_PC));
114//   logerror("ULA %3d[%d] NMI, R:$%02X, $%04x\n", video_screen_get_vpos(machine->primary_screen), ula_scancode_count, (unsigned) cpu_get_reg(machine->cpu[0], Z80_R), (unsigned) cpu_get_reg(machine->cpu[0], Z80_PC));
115115   cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, PULSE_LINE);
116116   if (++ula_scanline_count == height)
117117      ula_scanline_count = 0;
r3580r3581
127127    */
128128   if (ula_irq_active)
129129   {
130//      logerror("ULA %3d[%d] IRQ, R:$%02X, $%04x\n", video_screen_get_vpos(machine->primary_screen), ula_scancode_count, (unsigned) cpunum_get_reg(0, Z80_R), (unsigned) cpunum_get_reg(0, Z80_PC));
130//      logerror("ULA %3d[%d] IRQ, R:$%02X, $%04x\n", video_screen_get_vpos(machine->primary_screen), ula_scancode_count, (unsigned) cpu_get_reg(machine->cpu[0], Z80_R), (unsigned) cpu_get_reg(machine->cpu[0], Z80_PC));
131131
132132      ula_irq_active = 0;
133133      cpu_set_input_line(machine->cpu[0], 0, HOLD_LINE);
r3580r3581
145145   {
146146      bitmap_t *bitmap = tmpbitmap;
147147      UINT16 y, *scanline;
148      UINT16 ireg = cpunum_get_reg(0, Z80_I) << 8;
149      UINT8 creg = cpunum_get_reg(0, Z80_C);
148      UINT16 ireg = cpu_get_reg(machine->cpu[0], Z80_I) << 8;
149      UINT8 creg = cpu_get_reg(machine->cpu[0], Z80_C);
150150      UINT8 data, *chrgen;
151151      chrgen = memory_region(machine, region);
152152
src/mess/messdriv.c
r3580r3581
456456//128u4   DRIVER( osborne1 )   /* 1981 Osborne-1                           */
457457
458458   /* SINCLAIR RESEARCH */
459//128u4   DRIVER( zx80 )      /* 1980 Sinclair ZX-80                        */
460//128u4   DRIVER( zx81 )      /* 1981 Sinclair ZX-81                        */
461//128u4   DRIVER( ts1000 )   /* 1982 Timex Sinclair 1000                     */
462//128u4   DRIVER( pc8300 )   /* Your Computer - PC8300                     */
463//128u4   DRIVER( pow3000 )   /* Creon Enterprises - Power 3000               */
464//128u4   DRIVER( lambda )   /* Lambda 8300                              */
459   DRIVER( zx80 )      /* 1980 Sinclair ZX-80                        */
460   DRIVER( zx81 )      /* 1981 Sinclair ZX-81                        */
461   DRIVER( ts1000 )   /* 1982 Timex Sinclair 1000                     */
462   DRIVER( pc8300 )   /* Your Computer - PC8300                     */
463   DRIVER( pow3000 )   /* Creon Enterprises - Power 3000               */
464   DRIVER( lambda )   /* Lambda 8300                              */
465465
466//128u4   DRIVER( spectrum )/* 1982 ZX Spectrum                           */
467//128u4   DRIVER( spec80k ) /* 1987 ZX Spectrum 80k                     */
468//128u4   DRIVER( specide ) /* 1995 ZX Spectrum IDE                     */
469//128u4   DRIVER( inves )      /* 1986 Inves Spectrum 48K+                     */
470//128u4   DRIVER( tk90x )      /* 1985 TK90x Color Computer                  */
471//128u4   DRIVER( tk95 )      /* 1986 TK95 Color Computer                     */
472//128u4   DRIVER( tc2048 )   /* 198? TC2048                              */
473//128u4   DRIVER( ts2068 )   /* 1983 TS2068                              */
474//128u4   DRIVER( uk2086 )   /* 1986 UK2086                              */ 
466   DRIVER( spectrum )/* 1982 ZX Spectrum                           */
467   DRIVER( spec80k ) /* 1987 ZX Spectrum 80k                     */
468   DRIVER( specide ) /* 1995 ZX Spectrum IDE                     */
469   DRIVER( inves )      /* 1986 Inves Spectrum 48K+                     */
470   DRIVER( tk90x )      /* 1985 TK90x Color Computer                  */
471   DRIVER( tk95 )      /* 1986 TK95 Color Computer                     */
472   DRIVER( tc2048 )   /* 198? TC2048                              */
473   DRIVER( ts2068 )   /* 1983 TS2068                              */
474   DRIVER( uk2086 )   /* 1986 UK2086                              */ 
475   
476   DRIVER( spec128 )     /* 1986 ZX Spectrum 128                        */
477   DRIVER( specpls2 )   /* 1986 ZX Spectrum +2                        */
478   DRIVER( specpl2a )   /* 1987 ZX Spectrum +2a                        */   
479   DRIVER( specpls3 )   /* 1987 ZX Spectrum +3                        */
480   DRIVER( specpl3e )   /* 2000 ZX Spectrum +3e                        */
481   DRIVER( sp3e8bit )   /* 2002 ZX Spectrum +3e   8bit IDE         */
482   DRIVER( sp3ezcf )     /* 2002 ZX Spectrum +3e   ZXCF               */
483   DRIVER( sp3eata )     /* 2002 ZX Spectrum +3e   ZXATASP           */   
484   DRIVER( scorpion )
485   DRIVER( pentagon )
475486
476//128u4   DRIVER( spec128 )     /* 1986 ZX Spectrum 128                        */
477//128u4   DRIVER( specpls2 )   /* 1986 ZX Spectrum +2                        */
478//128u4   DRIVER( specpl2a )   /* 1987 ZX Spectrum +2a                        */   
479//128u4   DRIVER( specpls3 )   /* 1987 ZX Spectrum +3                        */
480//128u4   DRIVER( specpl3e )   /* 2000 ZX Spectrum +3e                        */
481//128u4   DRIVER( sp3e8bit )   /* 2002 ZX Spectrum +3e   8bit IDE         */
482//128u4   DRIVER( sp3ezcf )     /* 2002 ZX Spectrum +3e   ZXCF               */
483//128u4   DRIVER( sp3eata )     /* 2002 ZX Spectrum +3e   ZXATASP           */   
484//128u4   DRIVER( scorpion )
485//128u4   DRIVER( pentagon )
486
487487//128u4   DRIVER( ql )      /* 1984 Sinclair QL   (UK)                     */
488488//128u4   DRIVER( ql_us )      /* 1984 Sinclair QL   (USA)                     */
489489//128u4   DRIVER( ql_es )      /* 1984 Sinclair QL   (Spain)                     */
r3580r3581
10301030  /* Spectrum clones */
10311031     
10321032  /* ICE-Felix */
1033//128u4   DRIVER( hc85 )    /* 1985 HC-85                                */
1034//128u4   DRIVER( hc90 )    /* 1990 HC-90                                */
1035//128u4   DRIVER( hc91 )    /* 1991 HC-91                                */
1036//128u4   DRIVER( hc128 )   /* 1991 HC-128                             */
1037//128u4   DRIVER( hc2000 )  /* 1992 HC-2000                             */
1033   DRIVER( hc85 )    /* 1985 HC-85                                */
1034   DRIVER( hc90 )    /* 1990 HC-90                                */
1035   DRIVER( hc91 )    /* 1991 HC-91                                */
1036   DRIVER( hc128 )   /* 1991 HC-128                             */
1037   DRIVER( hc2000 )  /* 1992 HC-2000                             */
1038
1039   DRIVER( cip03 )   /* 1988 CIP-03                                */
1040   DRIVER( jet )     /* 1990 JET                                */
10381041 
1039//128u4   DRIVER( cip03 )   /* 1988 CIP-03                                */
1040//128u4   DRIVER( jet )     /* 1990 JET                                */
1041 
10421042  /* Didaktik Skalica */
1043//128u4   DRIVER( dgama87)  /* 1987 Didaktik Gama 87          */
1044//128u4   DRIVER( dgama88)  /* 1988 Didaktik Gama 88          */
1045//128u4   DRIVER( dgama89)  /* 1989 Didaktik Gama 89          */
1046//128u4   DRIVER( didakt90) /* 1990 Didaktik Skalica 90       */
1047//128u4   DRIVER( didakm91) /* 1991 Didaktik M 91             */
1048//128u4   DRIVER( didaktk)  /* 1992 Didaktik Kompakt          */
1049//128u4   DRIVER( didakm93) /* 1993 Didaktik M 93             */
1050
1051//128u4   DRIVER( mistrum ) /* 1988 Mistrum                              */
1043   DRIVER( dgama87)  /* 1987 Didaktik Gama 87          */
1044   DRIVER( dgama88)  /* 1988 Didaktik Gama 88          */
1045   DRIVER( dgama89)  /* 1989 Didaktik Gama 89          */
1046   DRIVER( didakt90) /* 1990 Didaktik Skalica 90       */
1047   DRIVER( didakm91) /* 1991 Didaktik M 91             */
1048   DRIVER( didaktk)  /* 1992 Didaktik Kompakt          */
1049   DRIVER( didakm93) /* 1993 Didaktik M 93             */
10521050   
1051   DRIVER( mistrum ) /* 1988 Mistrum                              */
1052   
10531053  /* Russian clones */
10541054
1055//128u4   DRIVER( blitz )     /* 1990 Blic                     */
1056//128u4   DRIVER( byte )      /* 1990 Byte                     */
1057//128u4   DRIVER( orizon )    /* 199? Orizon-Micro             */
1058//128u4   DRIVER( quorum48 )  /* 1993 Kvorum 48K               */
1059//128u4   DRIVER( magic6 )    /* 1993 Magic 6                  */
1060//128u4   DRIVER( compani1 )  /* 1990 Kompanion 1              */
1055   DRIVER( blitz )     /* 1990 Blic                     */
1056   DRIVER( byte )      /* 1990 Byte                     */
1057   DRIVER( orizon )    /* 199? Orizon-Micro             */
1058   DRIVER( quorum48 )  /* 1993 Kvorum 48K               */
1059   DRIVER( magic6 )    /* 1993 Magic 6                  */
1060   DRIVER( compani1 )  /* 1990 Kompanion 1              */
10611061
10621062   /* Kramer */
10631063//128u4   DRIVER(kramermc) /* 1987 Kramer MC            */
src/mess/machine/spectrum.c
r3580r3581
5353}
5454SPECTRUM_SNAPSHOT_TYPE;
5555
56static OPBASE_HANDLER(spectrum_opbaseoverride)
56static DIRECT_UPDATE_HANDLER(spectrum_direct)
5757{
5858   /* Hack for correct handling 0xffff interrupt vector */
5959   if (address == 0x0001)
60      if (cpunum_get_reg(0, REG_PREVIOUSPC)==0xffff)
60      if (cpu_get_reg(space->machine->cpu[0], REG_PREVIOUSPC)==0xffff)
6161      {
62         cpunum_set_reg(0, Z80_PC, 0xfff4);
62         cpu_set_reg(space->machine->cpu[0], Z80_PC, 0xfff4);
6363         return 0xfff4;
6464      }
6565   return address;
r3580r3581
6767
6868MACHINE_RESET( spectrum )
6969{
70   memory_set_opbase_handler(0, spectrum_opbaseoverride);
70   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
71   memory_set_direct_update_handler(space, spectrum_direct);
7172}
7273
7374SNAPSHOT_LOAD(spectrum)
r3580r3581
103104      spectrum_setup_z80(image->machine, snapshot_data, snapshot_size);
104105   }
105106   free(snapshot_data);
106   logerror("Snapshot loaded - new PC = %04x\n", (unsigned) cpunum_get_reg(0, Z80_PC) & 0x0ffff);
107   //logerror("Snapshot loaded - new PC = %04x\n", (unsigned) cpu_get_reg(machine->cpu[0], Z80_PC) & 0x0ffff);
107108   return INIT_PASS;
108109
109110error:
r3580r3581
192193   UINT8 lo, hi, data;
193194   UINT16 offset, size;
194195   UINT16 status;
196   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
195197
196198   lo = pSnapshot[2] & 0x0ff;
197199   hi = pSnapshot[3] & 0x0ff;
r3580r3581
204206
205207   lo = pSnapshot[6] & 0x0ff;
206208   hi = pSnapshot[7] & 0x0ff;
207   cpunum_set_reg(0, Z80_BC, (hi << 8) | lo);
209   cpu_set_reg(machine->cpu[0], Z80_BC, (hi << 8) | lo);
208210   lo = pSnapshot[8] & 0x0ff;
209211   hi = pSnapshot[9] & 0x0ff;
210   cpunum_set_reg(0, Z80_DE, (hi << 8) | lo);
212   cpu_set_reg(machine->cpu[0], Z80_DE, (hi << 8) | lo);
211213   lo = pSnapshot[10] & 0x0ff;
212214   hi = pSnapshot[11] & 0x0ff;
213   cpunum_set_reg(0, Z80_HL, (hi << 8) | lo);
215   cpu_set_reg(machine->cpu[0], Z80_HL, (hi << 8) | lo);
214216   lo = pSnapshot[12] & 0x0ff;
215217   hi = pSnapshot[13] & 0x0ff;
216   cpunum_set_reg(0, Z80_AF, (hi << 8) | lo);
218   cpu_set_reg(machine->cpu[0], Z80_AF, (hi << 8) | lo);
217219
218220   lo = pSnapshot[14] & 0x0ff;
219221   hi = pSnapshot[15] & 0x0ff;
220   cpunum_set_reg(0, Z80_IX, (hi << 8) | lo);
222   cpu_set_reg(machine->cpu[0], Z80_IX, (hi << 8) | lo);
221223   lo = pSnapshot[16] & 0x0ff;
222224   hi = pSnapshot[17] & 0x0ff;
223   cpunum_set_reg(0, Z80_IY, (hi << 8) | lo);
225   cpu_set_reg(machine->cpu[0], Z80_IY, (hi << 8) | lo);
224226
225227   lo = pSnapshot[18] & 0x0ff;
226228   hi = pSnapshot[19] & 0x0ff;
227   cpunum_set_reg(0, Z80_BC2, (hi << 8) | lo);
229   cpu_set_reg(machine->cpu[0], Z80_BC2, (hi << 8) | lo);
228230   lo = pSnapshot[20] & 0x0ff;
229231   hi = pSnapshot[21] & 0x0ff;
230   cpunum_set_reg(0, Z80_DE2, (hi << 8) | lo);
232   cpu_set_reg(machine->cpu[0], Z80_DE2, (hi << 8) | lo);
231233   lo = pSnapshot[22] & 0x0ff;
232234   hi = pSnapshot[23] & 0x0ff;
233   cpunum_set_reg(0, Z80_HL2, (hi << 8) | lo);
235   cpu_set_reg(machine->cpu[0], Z80_HL2, (hi << 8) | lo);
234236   lo = pSnapshot[24] & 0x0ff;
235237   hi = pSnapshot[25] & 0x0ff;
236   cpunum_set_reg(0, Z80_AF2, (hi << 8) | lo);
238   cpu_set_reg(machine->cpu[0], Z80_AF2, (hi << 8) | lo);
237239
238   cpunum_set_reg(0, Z80_R, (pSnapshot[26] & 0x0ff));
239   cpunum_set_reg(0, Z80_I, (pSnapshot[27] & 0x0ff));
240   cpu_set_reg(machine->cpu[0], Z80_R, (pSnapshot[26] & 0x0ff));
241   cpu_set_reg(machine->cpu[0], Z80_I, (pSnapshot[27] & 0x0ff));
240242
241243   lo = pSnapshot[28] & 0x0ff;
242244   hi = pSnapshot[29] & 0x0ff;
243   cpunum_set_reg(0, Z80_SP, (hi << 8) | lo);
245   cpu_set_reg(machine->cpu[0], Z80_SP, (hi << 8) | lo);
244246   lo = pSnapshot[30] & 0x0ff;
245247   hi = pSnapshot[31] & 0x0ff;
246   cpunum_set_reg(0, Z80_PC, (hi << 8) | lo);
248   cpu_set_reg(machine->cpu[0], Z80_PC, (hi << 8) | lo);
247249
248250   lo = pSnapshot[32] & 0x0ff;
249251   hi = pSnapshot[33] & 0x0ff;
r3580r3581
264266   status = (hi << 8) | lo;
265267
266268   data = (status & 0x01);
267   cpunum_set_reg(0, Z80_IFF1, data);
269   cpu_set_reg(machine->cpu[0], Z80_IFF1, data);
268270   data = (status & 0x04)>>2;
269   cpunum_set_reg(0, Z80_IFF2, data);
271   cpu_set_reg(machine->cpu[0], Z80_IFF2, data);
270272
271273   data = (status & 0x08)>>3;
272274   if (data)
273      cpunum_set_reg(0, Z80_IM, 0);
275      cpu_set_reg(machine->cpu[0], Z80_IM, 0);
274276   else
275277   {
276278      data = (status & 0x02)>>1;
277279      if (data)
278         cpunum_set_reg(0, Z80_IM, 2);
280         cpu_set_reg(machine->cpu[0], Z80_IM, 2);
279281      else
280         cpunum_set_reg(0, Z80_IM, 1);
282         cpu_set_reg(machine->cpu[0], Z80_IM, 1);
281283   }
282284
283285   data = (status & 0x10)>>4;
r3580r3581
289291
290292   /* memory dump */
291293   for (i = 0; i < size; i++)
292      program_write_byte(i + offset, pSnapshot[38 + i]);
294      memory_write_byte(space, i + offset, pSnapshot[38 + i]);
293295}
294296
295297/*******************************************************************
r3580r3581
329331   long bank_offset;
330332   unsigned char lo, hi, data;
331333   unsigned short addr;
334   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
332335
333336   if ((SnapshotSize != 49179) && (spectrum_128_port_7ffd_data == -1))
334337   {
r3580r3581
336339      return;
337340   }
338341
339   cpunum_set_reg(0, Z80_I, (pSnapshot[0] & 0x0ff));
342   cpu_set_reg(machine->cpu[0], Z80_I, (pSnapshot[0] & 0x0ff));
340343   lo = pSnapshot[1] & 0x0ff;
341344   hi = pSnapshot[2] & 0x0ff;
342   cpunum_set_reg(0, Z80_HL2, (hi << 8) | lo);
345   cpu_set_reg(machine->cpu[0], Z80_HL2, (hi << 8) | lo);
343346   lo = pSnapshot[3] & 0x0ff;
344347   hi = pSnapshot[4] & 0x0ff;
345   cpunum_set_reg(0, Z80_DE2, (hi << 8) | lo);
348   cpu_set_reg(machine->cpu[0], Z80_DE2, (hi << 8) | lo);
346349   lo = pSnapshot[5] & 0x0ff;
347350   hi = pSnapshot[6] & 0x0ff;
348   cpunum_set_reg(0, Z80_BC2, (hi << 8) | lo);
351   cpu_set_reg(machine->cpu[0], Z80_BC2, (hi << 8) | lo);
349352   lo = pSnapshot[7] & 0x0ff;
350353   hi = pSnapshot[8] & 0x0ff;
351   cpunum_set_reg(0, Z80_AF2, (hi << 8) | lo);
354   cpu_set_reg(machine->cpu[0], Z80_AF2, (hi << 8) | lo);
352355   lo = pSnapshot[9] & 0x0ff;
353356   hi = pSnapshot[10] & 0x0ff;
354   cpunum_set_reg(0, Z80_HL, (hi << 8) | lo);
357   cpu_set_reg(machine->cpu[0], Z80_HL, (hi << 8) | lo);
355358   lo = pSnapshot[11] & 0x0ff;
356359   hi = pSnapshot[12] & 0x0ff;
357   cpunum_set_reg(0, Z80_DE, (hi << 8) | lo);
360   cpu_set_reg(machine->cpu[0], Z80_DE, (hi << 8) | lo);
358361   lo = pSnapshot[13] & 0x0ff;
359362   hi = pSnapshot[14] & 0x0ff;
360   cpunum_set_reg(0, Z80_BC, (hi << 8) | lo);
363   cpu_set_reg(machine->cpu[0], Z80_BC, (hi << 8) | lo);
361364   lo = pSnapshot[15] & 0x0ff;
362365   hi = pSnapshot[16] & 0x0ff;
363   cpunum_set_reg(0, Z80_IY, (hi << 8) | lo);
366   cpu_set_reg(machine->cpu[0], Z80_IY, (hi << 8) | lo);
364367   lo = pSnapshot[17] & 0x0ff;
365368   hi = pSnapshot[18] & 0x0ff;
366   cpunum_set_reg(0, Z80_IX, (hi << 8) | lo);
369   cpu_set_reg(machine->cpu[0], Z80_IX, (hi << 8) | lo);
367370   data = (pSnapshot[19] & 0x04) >> 2;
368   cpunum_set_reg(0, Z80_IFF2, data);
369   cpunum_set_reg(0, Z80_IFF1, data);
371   cpu_set_reg(machine->cpu[0], Z80_IFF2, data);
372   cpu_set_reg(machine->cpu[0], Z80_IFF1, data);
370373   data = (pSnapshot[20] & 0x0ff);
371   cpunum_set_reg(0, Z80_R, data);
374   cpu_set_reg(machine->cpu[0], Z80_R, data);
372375   lo = pSnapshot[21] & 0x0ff;
373376   hi = pSnapshot[22] & 0x0ff;
374   cpunum_set_reg(0, Z80_AF, (hi << 8) | lo);
377   cpu_set_reg(machine->cpu[0], Z80_AF, (hi << 8) | lo);
375378   lo = pSnapshot[23] & 0x0ff;
376379   hi = pSnapshot[24] & 0x0ff;
377   cpunum_set_reg(0, Z80_SP, (hi << 8) | lo);
380   cpu_set_reg(machine->cpu[0], Z80_SP, (hi << 8) | lo);
378381   data = (pSnapshot[25] & 0x0ff);
379   cpunum_set_reg(0, Z80_IM, data);
382   cpu_set_reg(machine->cpu[0], Z80_IM, data);
380383
381384   /* Set border colour */
382385   PreviousFE = (PreviousFE & 0xf8) | (pSnapshot[26] & 0x07);
r3580r3581
401404   /* memory dump */
402405   for (i = 0; i < 49152; i++)
403406   {
404      program_write_byte(i + 16384, pSnapshot[27 + i]);
407      memory_write_byte(space,i + 16384, pSnapshot[27 + i]);
405408   }
406409
407410   if (SnapshotSize == 49179)
408411   {
409412      /* get pc from stack */
410      addr = cpunum_get_reg(0, Z80_SP) & 0xFFFF;
413      addr = cpu_get_reg(machine->cpu[0], Z80_SP) & 0xFFFF;
411414
412      cpunum_set_reg(0, Z80_PC,
413         ((UINT16) program_read_byte(addr + 0) ) >> 8 |
414         ((UINT16) program_read_byte(addr + 1) ) >> 0);
415      cpu_set_reg(machine->cpu[0], Z80_PC,
416         ((UINT16) memory_read_byte(space,addr + 0) ) >> 8 |
417         ((UINT16) memory_read_byte(space,addr + 1) ) >> 0);
415418
416419      addr += 2;
417      cpunum_set_reg(0, Z80_SP, (addr & 0x0ffff));
420      cpu_set_reg(machine->cpu[0], Z80_SP, (addr & 0x0ffff));
418421
419422
420423   }
r3580r3581
438441            spectrum_128_port_7ffd_data += i;
439442            spectrum_update_paging(machine);
440443            for (j = 0; j < 16384; j++)
441               program_write_byte(j + 49152, pSnapshot[bank_offset + j]);
444               memory_write_byte(space,j + 49152, pSnapshot[bank_offset + j]);
442445            bank_offset += 16384;
443446         }
444447      }
r3580r3581
450453      /* program counter */
451454      lo = pSnapshot[49179] & 0x0ff;
452455      hi = pSnapshot[49180] & 0x0ff;
453      cpunum_set_reg(0, Z80_PC, (hi << 8) | lo);
456      cpu_set_reg(machine->cpu[0], Z80_PC, (hi << 8) | lo);
454457   }
455458}
456459
457460
458static void spectrum_z80_decompress_block(unsigned char *pSource, int Dest, int size)
461static void spectrum_z80_decompress_block(running_machine *machine,unsigned char *pSource, int Dest, int size)
459462{
460463   unsigned char ch;
461464   int i;
462
465   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
466   
463467   do
464468   {
465469      /* get byte */
r3580r3581
494498
495499            for (i = 0; i < count; i++)
496500            {
497               program_write_byte(Dest, data);
501               memory_write_byte(space,Dest, data);
498502               Dest++;
499503            }
500504         }
501505         else
502506         {
503507            /* single 0x0ed */
504            program_write_byte(Dest, ch);
508            memory_write_byte(space,Dest, ch);
505509            Dest++;
506510            pSource++;
507511            size--;
r3580r3581
511515      else
512516      {
513517         /* not 0x0ed */
514         program_write_byte(Dest, ch);
518         memory_write_byte(space,Dest, ch);
515519         Dest++;
516520         pSource++;
517521         size--;
r3580r3581
584588   int i;
585589   unsigned char lo, hi, data;
586590   SPECTRUM_Z80_SNAPSHOT_TYPE z80_type;
591   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
587592
588593   z80_type = spectrum_identify_z80(pSnapshot, SnapshotSize);
589594
r3580r3581
624629   /* AF */
625630   hi = pSnapshot[0] & 0x0ff;
626631   lo = pSnapshot[1] & 0x0ff;
627   cpunum_set_reg(0, Z80_AF, (hi << 8) | lo);
632   cpu_set_reg(machine->cpu[0], Z80_AF, (hi << 8) | lo);
628633   /* BC */
629634   lo = pSnapshot[2] & 0x0ff;
630635   hi = pSnapshot[3] & 0x0ff;
631   cpunum_set_reg(0, Z80_BC, (hi << 8) | lo);
636   cpu_set_reg(machine->cpu[0], Z80_BC, (hi << 8) | lo);
632637   /* HL */
633638   lo = pSnapshot[4] & 0x0ff;
634639   hi = pSnapshot[5] & 0x0ff;
635   cpunum_set_reg(0, Z80_HL, (hi << 8) | lo);
640   cpu_set_reg(machine->cpu[0], Z80_HL, (hi << 8) | lo);
636641
637642   /* SP */
638643   lo = pSnapshot[8] & 0x0ff;
639644   hi = pSnapshot[9] & 0x0ff;
640   cpunum_set_reg(0, Z80_SP, (hi << 8) | lo);
645   cpu_set_reg(machine->cpu[0], Z80_SP, (hi << 8) | lo);
641646
642647   /* I */
643   cpunum_set_reg(0, Z80_I, (pSnapshot[10] & 0x0ff));
648   cpu_set_reg(machine->cpu[0], Z80_I, (pSnapshot[10] & 0x0ff));
644649
645650   /* R */
646651   data = (pSnapshot[11] & 0x07f) | ((pSnapshot[12] & 0x01) << 7);
647   cpunum_set_reg(0, Z80_R, data);
652   cpu_set_reg(machine->cpu[0], Z80_R, data);
648653
649654   /* Set border colour */
650655   PreviousFE = (PreviousFE & 0xf8) | ((pSnapshot[12] & 0x0e) >> 1);
r3580r3581
654659
655660   lo = pSnapshot[13] & 0x0ff;
656661   hi = pSnapshot[14] & 0x0ff;
657   cpunum_set_reg(0, Z80_DE, (hi << 8) | lo);
662   cpu_set_reg(machine->cpu[0], Z80_DE, (hi << 8) | lo);
658663
659664   lo = pSnapshot[15] & 0x0ff;
660665   hi = pSnapshot[16] & 0x0ff;
661   cpunum_set_reg(0, Z80_BC2, (hi << 8) | lo);
666   cpu_set_reg(machine->cpu[0], Z80_BC2, (hi << 8) | lo);
662667
663668   lo = pSnapshot[17] & 0x0ff;
664669   hi = pSnapshot[18] & 0x0ff;
665   cpunum_set_reg(0, Z80_DE2, (hi << 8) | lo);
670   cpu_set_reg(machine->cpu[0], Z80_DE2, (hi << 8) | lo);
666671
667672   lo = pSnapshot[19] & 0x0ff;
668673   hi = pSnapshot[20] & 0x0ff;
669   cpunum_set_reg(0, Z80_HL2, (hi << 8) | lo);
674   cpu_set_reg(machine->cpu[0], Z80_HL2, (hi << 8) | lo);
670675
671676   hi = pSnapshot[21] & 0x0ff;
672677   lo = pSnapshot[22] & 0x0ff;
673   cpunum_set_reg(0, Z80_AF2, (hi << 8) | lo);
678   cpu_set_reg(machine->cpu[0], Z80_AF2, (hi << 8) | lo);
674679
675680   lo = pSnapshot[23] & 0x0ff;
676681   hi = pSnapshot[24] & 0x0ff;
677   cpunum_set_reg(0, Z80_IY, (hi << 8) | lo);
682   cpu_set_reg(machine->cpu[0], Z80_IY, (hi << 8) | lo);
678683
679684   lo = pSnapshot[25] & 0x0ff;
680685   hi = pSnapshot[26] & 0x0ff;
681   cpunum_set_reg(0, Z80_IX, (hi << 8) | lo);
686   cpu_set_reg(machine->cpu[0], Z80_IX, (hi << 8) | lo);
682687
683688   /* Interrupt Flip/Flop */
684689   if (pSnapshot[27] == 0)
685690   {
686      cpunum_set_reg(0, Z80_IFF1, 0);
687      /* cpunum_set_reg(0, Z80_IRQ_STATE, 0); */
691      cpu_set_reg(machine->cpu[0], Z80_IFF1, 0);
692      /* cpu_set_reg(machine->cpu[0], Z80_IRQ_STATE, 0); */
688693   }
689694   else
690695   {
691      cpunum_set_reg(0, Z80_IFF1, 1);
692      /* cpunum_set_reg(0, Z80_IRQ_STATE, 1); */
696      cpu_set_reg(machine->cpu[0], Z80_IFF1, 1);
697      /* cpu_set_reg(machine->cpu[0], Z80_IRQ_STATE, 1); */
693698   }
694699
695700   cpu_set_input_line(machine->cpu[0], 0, data);
r3580r3581
705710   {
706711      data = 0;
707712   }
708   cpunum_set_reg(0, Z80_IFF2, data);
713   cpu_set_reg(machine->cpu[0], Z80_IFF2, data);
709714
710715   /* Interrupt Mode */
711   cpunum_set_reg(0, Z80_IM, (pSnapshot[29] & 0x03));
716   cpu_set_reg(machine->cpu[0], Z80_IM, (pSnapshot[29] & 0x03));
712717
713718   if (z80_type == SPECTRUM_Z80_SNAPSHOT_48K_OLD)
714719   {
715720      lo = pSnapshot[6] & 0x0ff;
716721      hi = pSnapshot[7] & 0x0ff;
717      cpunum_set_reg(0, Z80_PC, (hi << 8) | lo);
722      cpu_set_reg(machine->cpu[0], Z80_PC, (hi << 8) | lo);
718723
719724      spectrum_page_basicrom(machine);
720725
r3580r3581
722727      {
723728         logerror("Not compressed\n");   /* not compressed */
724729         for (i = 0; i < 49152; i++)
725            program_write_byte(i + 16384, pSnapshot[30 + i]);
730            memory_write_byte(space,i + 16384, pSnapshot[30 + i]);
726731      }
727732      else
728733      {
729734         logerror("Compressed\n");   /* compressed */
730         spectrum_z80_decompress_block(pSnapshot + 30, 16384, 49152);
735         spectrum_z80_decompress_block(machine, pSnapshot + 30, 16384, 49152);
731736      }
732737   }
733738   else
r3580r3581
739744
740745      lo = pSnapshot[32] & 0x0ff;
741746      hi = pSnapshot[33] & 0x0ff;
742      cpunum_set_reg(0, Z80_PC, (hi << 8) | lo);
747      cpu_set_reg(machine->cpu[0], Z80_PC, (hi << 8) | lo);
743748
744749      if ((z80_type == SPECTRUM_Z80_SNAPSHOT_128K) || ((z80_type == SPECTRUM_Z80_SNAPSHOT_TS2068) && !strcmp(machine->gamedrv->name,"ts2068")))
745750      {
746751         /* Only set up sound registers for 128K machine or TS2068! */
747752         for (i = 0; i < 16; i++)
748753         {
749            ay8910_control_port_0_w(machine, 0, i);
750            ay8910_write_port_0_w(machine, 0, pSnapshot[39 + i]);
754            ay8910_control_port_0_w(space, 0, i);
755            ay8910_write_port_0_w(space, 0, pSnapshot[39 + i]);
751756         }
752         ay8910_control_port_0_w(machine, 0, pSnapshot[38]);
757         ay8910_control_port_0_w(space, 0, pSnapshot[38]);
753758      }
754759
755760      pSource = pSnapshot + header_size;
r3580r3581
801806
802807               /* not compressed */
803808               for (i = 0; i < 16384; i++)
804                  program_write_byte(i + Dest, pSource[i]);
809                  memory_write_byte(space,i + Dest, pSource[i]);
805810            }
806811            else
807812            {
808813               logerror("Compressed\n");
809814
810815               /* block is compressed */
811               spectrum_z80_decompress_block(&pSource[3], Dest, 16384);
816               spectrum_z80_decompress_block(machine,&pSource[3], Dest, 16384);
812817            }
813818         }
814819
r3580r3581
850855
851856QUICKLOAD_LOAD(spectrum)
852857{
858   const address_space *space = cpu_get_address_space(image->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
853859   int i;
854860   int quick_addr = 0x4000;
855861   int quick_length;
r3580r3581
866872      return INIT_FAIL;
867873
868874   for (i = 0; i < quick_length; i++)
869      program_write_byte(i + quick_addr, quick_data[i]);
875      memory_write_byte(space,i + quick_addr, quick_data[i]);
870876
871877   logerror("quick loading at %.4x size:%.4x\n", quick_addr, quick_length);
872878   return INIT_PASS;
src/mess/machine/zx.c
r3580r3581
1616#define   DEBUG_ZX81_PORTS   1
1717#define DEBUG_ZX81_VSYNC   1
1818
19#define LOG_ZX81_IOR(_comment) { if (DEBUG_ZX81_PORTS) logerror("ZX81 IOR: %04x, Data: %02x, Scanline: %d (%s)\n", offset, data, video_screen_get_vpos(machine->primary_screen), _comment); }
20#define LOG_ZX81_IOW(_comment) { if (DEBUG_ZX81_PORTS) logerror("ZX81 IOW: %04x, Data: %02x, Scanline: %d (%s)\n", offset, data, video_screen_get_vpos(machine->primary_screen), _comment); }
19#define LOG_ZX81_IOR(_comment) { if (DEBUG_ZX81_PORTS) logerror("ZX81 IOR: %04x, Data: %02x, Scanline: %d (%s)\n", offset, data, video_screen_get_vpos(space->machine->primary_screen), _comment); }
20#define LOG_ZX81_IOW(_comment) { if (DEBUG_ZX81_PORTS) logerror("ZX81 IOW: %04x, Data: %02x, Scanline: %d (%s)\n", offset, data, video_screen_get_vpos(space->machine->primary_screen), _comment); }
2121#define LOG_ZX81_VSYNC { if (DEBUG_ZX81_VSYNC) logerror("VSYNC starts in scanline: %d\n", video_screen_get_vpos(machine->primary_screen)); }
2222
2323static UINT8 zx_tape_bit = 0x80;
2424
2525static WRITE8_HANDLER( zx_ram_w )
2626{
27   UINT8 *rom = memory_region(machine, "main");
28
27   UINT8 *rom = memory_region(space->machine, "main");   
2928   rom[offset | 0x4000] = data;
3029
3130   if ((offset > 0x29) && (offset < 0x300))
3231   {
3332      if (data & 0x40)
34         program_write_byte (offset | 0xc000, data);
33         memory_write_byte (space, offset | 0xc000, data);
3534      else
36         program_write_byte (offset | 0xc000, 0);
35         memory_write_byte (space, offset | 0xc000, 0);
3736   }
3837}
3938
4039DRIVER_INIT ( zx )
4140{
42   memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x4000 + mess_ram_size - 1, 0, 0, SMH_BANK1);
43   memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x4000 + mess_ram_size - 1, 0, 0, zx_ram_w);
44   memory_set_bankptr(1, memory_region(machine, "main") + 0x4000);
41   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
42
43   memory_install_read8_handler(space, 0x4000, 0x4000 + mess_ram_size - 1, 0, 0, SMH_BANK1);
44   memory_install_write8_handler(space, 0x4000, 0x4000 + mess_ram_size - 1, 0, 0, zx_ram_w);
45   memory_set_bankptr(machine, 1, memory_region(machine, "main") + 0x4000);
4546}
4647
4748#if 0
48static OPBASE_HANDLER ( zx_setopbase )
49static OPBASE_HANDLER ( zx_setdirect )
4950{
5051   if ((address > 0xc029) && (address < 0xc300))
5152   {
r3580r3581
6263}
6364#endif
6465
65static OPBASE_HANDLER ( zx_setopbase )
66static DIRECT_UPDATE_HANDLER ( zx_setdirect )
6667{
6768   if (address & 0x8000)
68      zx_ula_r(machine, address, "main");
69      zx_ula_r(space->machine, address, "main");
6970   return address;
7071}
7172
72static OPBASE_HANDLER ( pc8300_setopbase )
73static DIRECT_UPDATE_HANDLER ( pc8300_setdirect )
7374{
7475   if (address & 0x8000)
75      zx_ula_r(machine, address, "gfx1");
76      zx_ula_r(space->machine, address, "gfx1");
7677   return address;
7778}
7879
79static void common_init_machine(opbase_handler_func setopbase)
80{
81   memory_set_opbase_handler(0, setopbase);
82   zx_tape_bit = 0x80;
83}
8480
8581MACHINE_RESET ( zx80 )
8682{
87   common_init_machine(zx_setopbase);
83   memory_set_direct_update_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), zx_setdirect);
84   zx_tape_bit = 0x80;
8885}
8986
9087MACHINE_RESET ( zx81 )
9188{
92   common_init_machine(zx_setopbase);
89   memory_set_direct_update_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), zx_setdirect);
90   zx_tape_bit = 0x80;
9391}
9492
9593MACHINE_RESET ( pc8300 )
9694{
97   common_init_machine(pc8300_setopbase);
95   memory_set_direct_update_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), pc8300_setdirect);
96   zx_tape_bit = 0x80;
9897}
9998
10099static TIMER_CALLBACK(zx_tape_pulse)
r3580r3581
104103
105104WRITE8_HANDLER ( zx_io_w )
106105{
107   const device_config *screen = video_screen_first(machine->config);
106   const device_config *screen = video_screen_first(space->machine->config);
108107   int height = video_screen_get_height(screen);
109108
110109   if ((offset & 2) == 0)
r3580r3581
124123   }
125124   else
126125   {
127      zx_ula_bkgnd(machine, 1);
126      zx_ula_bkgnd(space->machine, 1);
128127      if (ula_frame_vsync == 2)
129128      {
130         cpu_spinuntil_time(video_screen_get_time_until_pos(machine->primary_screen, height - 1, 0));
129         cpu_spinuntil_time(space->cpu,video_screen_get_time_until_pos(space->machine->primary_screen, height - 1, 0));
131130         ula_scanline_count = height - 1;
132         logerror ("S: %d B: %d\n", video_screen_get_vpos(machine->primary_screen), video_screen_get_hpos(machine->primary_screen));
131         logerror ("S: %d B: %d\n", video_screen_get_vpos(space->machine->primary_screen), video_screen_get_hpos(space->machine->primary_screen));
133132      }
134133
135134      LOG_ZX81_IOW("ULA IRQs on");
r3580r3581
138137
139138READ8_HANDLER ( zx_io_r )
140139{
141   const device_config *screen = video_screen_first(machine->config);
140   const device_config *screen = video_screen_first(space->machine->config);
142141   int data = 0xff;
143142
144143   if ((offset & 1) == 0)
145144   {
146      int extra1 = input_port_read(machine, "SPC0");
147      int extra2 = input_port_read(machine, "SPC1");
145      int extra1 = input_port_read(space->machine, "SPC0");
146      int extra2 = input_port_read(space->machine, "SPC1");
148147
149148//      ula_scancode_count = 0;
150149      if ((offset & 0x0100) == 0)
151150      {
152         data &= input_port_read(machine, "ROW0");
151         data &= input_port_read(space->machine, "ROW0");
153152         /* SHIFT for extra keys */
154153         if (extra1 != 0xff || extra2 != 0xff)
155154            data &= ~0x01;
156155      }
157156      if ((offset & 0x0200) == 0)
158         data &= input_port_read(machine, "ROW1");
157         data &= input_port_read(space->machine, "ROW1");
159158      if ((offset & 0x0400) == 0)
160         data &= input_port_read(machine, "ROW2");
159         data &= input_port_read(space->machine, "ROW2");
161160      if ((offset & 0x0800) == 0)
162         data &= input_port_read(machine, "ROW3") & extra1;
161         data &= input_port_read(space->machine, "ROW3") & extra1;
163162      if ((offset & 0x1000) == 0)
164         data &= input_port_read(machine, "ROW4") & extra2;
163         data &= input_port_read(space->machine, "ROW4") & extra2;
165164      if ((offset & 0x2000) == 0)
166         data &= input_port_read(machine, "ROW5");
165         data &= input_port_read(space->machine, "ROW5");
167166      if ((offset & 0x4000) == 0)
168         data &= input_port_read(machine, "ROW6");
167         data &= input_port_read(space->machine, "ROW6");
169168      if ((offset & 0x8000) == 0)
170         data &= input_port_read(machine, "ROW7");
169         data &= input_port_read(space->machine, "ROW7");
171170      if (video_screen_get_refresh(screen) > 55)
172171         data &= ~0x40;
173172
174173      if (ula_irq_active)
175174      {
176         zx_ula_bkgnd(machine, 0);
175         zx_ula_bkgnd(space->machine, 0);
177176         ula_irq_active = 0;
178177
179178         LOG_ZX81_IOR("ULA IRQs off");
180179      }
181180      else
182181      {
183         if ((cassette_input(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" )) < -0.75) && zx_tape_bit)
182         if ((cassette_input(device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette" )) < -0.75) && zx_tape_bit)
184183         {
185184            zx_tape_bit = 0x00;
186185            timer_set(ATTOTIME_IN_USEC(362), NULL, 0, zx_tape_pulse);
r3580r3581
193192      if (ula_frame_vsync == 3)
194193      {
195194         ula_frame_vsync = 2;
196         LOG_ZX81_VSYNC;
195//         LOG_ZX81_VSYNC;
197196      }
198197   }
199198   else
r3580r3581
204203
205204READ8_HANDLER ( pow3000_io_r )
206205{
207   const device_config *screen = video_screen_first(machine->config);
206   const device_config *screen = video_screen_first(space->machine->config);
208207   int data = 0xff;
209208
210209   if ((offset & 1) == 0)
211210   {
212      int extra1 = input_port_read(machine, "SPC0");
213      int extra2 = input_port_read(machine, "SPC1");
211      int extra1 = input_port_read(space->machine, "SPC0");
212      int extra2 = input_port_read(space->machine, "SPC1");
214213
215214//      ula_scancode_count = 0;
216215      if ((offset & 0x0100) == 0)
217216      {
218         data &= input_port_read(machine, "ROW0") & extra1;
217         data &= input_port_read(space->machine, "ROW0") & extra1;
219218         /* SHIFT for extra keys */
220219         if (extra1 != 0xff || extra2 != 0xff)
221220            data &= ~0x01;
222221      }
223222      if ((offset & 0x0200) == 0)
224         data &= input_port_read(machine, "ROW1") & extra2;
223         data &= input_port_read(space->machine, "ROW1") & extra2;
225224      if ((offset & 0x0400) == 0)
226         data &= input_port_read(machine, "ROW2");
225         data &= input_port_read(space->machine, "ROW2");
227226      if ((offset & 0x0800) == 0)
228         data &= input_port_read(machine, "ROW3");
227         data &= input_port_read(space->machine, "ROW3");
229228      if ((offset & 0x1000) == 0)
230         data &= input_port_read(machine, "ROW4");
229         data &= input_port_read(space->machine, "ROW4");
231230      if ((offset & 0x2000) == 0)
232         data &= input_port_read(machine, "ROW5");
231         data &= input_port_read(space->machine, "ROW5");
233232      if ((offset & 0x4000) == 0)
234         data &= input_port_read(machine, "ROW6");
233         data &= input_port_read(space->machine, "ROW6");
235234      if ((offset & 0x8000) == 0)
236         data &= input_port_read(machine, "ROW7");
235         data &= input_port_read(space->machine, "ROW7");
237236      if (video_screen_get_refresh(screen) > 55)
238237         data &= ~0x40;
239238
240239      if (ula_irq_active)
241240      {
242         zx_ula_bkgnd(machine, 0);
241         zx_ula_bkgnd(space->machine, 0);
243242         ula_irq_active = 0;
244243         LOG_ZX81_IOR("ULA IRQs off");
245244      }
246245      else
247246      {
248         if ((cassette_input(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" )) < -0.75) && zx_tape_bit)
247         if ((cassette_input(device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette" )) < -0.75) && zx_tape_bit)
249248         {
250249            zx_tape_bit = 0x00;
251250            timer_set(ATTOTIME_IN_USEC(362), NULL, 0, zx_tape_pulse);
r3580r3581
258257      if (ula_frame_vsync == 3)
259258      {
260259         ula_frame_vsync = 2;
261         LOG_ZX81_VSYNC;
260//         LOG_ZX81_VSYNC;
262261      }
263262   }
264263   else
src/mess/machine/beta.c
r3580r3581
6868READ8_HANDLER(betadisk_status_r)
6969{
7070   if (betadisk_active==1) {
71      return wd17xx_status_r(machine, offset);
71      return wd17xx_status_r(space, offset);
7272   } else {
7373      return 0xff;
7474   }
r3580r3581
7777READ8_HANDLER(betadisk_track_r)
7878{
7979   if (betadisk_active==1) {
80      return wd17xx_track_r(machine, offset);
80      return wd17xx_track_r(space, offset);
8181   } else {
8282      return 0xff;
8383   }
r3580r3581
8686READ8_HANDLER(betadisk_sector_r)
8787{
8888   if (betadisk_active==1) {
89      return wd17xx_sector_r(machine, offset);
89      return wd17xx_sector_r(space, offset);
9090   } else {
9191      return 0xff;
9292   }
r3580r3581
9595READ8_HANDLER(betadisk_data_r)
9696{
9797   if (betadisk_active==1) {
98      return wd17xx_data_r(machine, offset);
98      return wd17xx_data_r(space, offset);
9999   } else {
100100      return 0xff;
101101   }
r3580r3581
118118        wd17xx_set_density(data & 0x20 ? DEN_MFM_HI : DEN_FM_LO );
119119        if ((data & 0x04) == 0) // reset
120120        {
121           wd17xx_reset(machine);   
121           wd17xx_reset(space->machine);   
122122        }         
123123        betadisk_status = (data & 0x3f) | betadisk_status;
124124     }
r3580r3581
127127WRITE8_HANDLER(betadisk_command_w)
128128{
129129   if (betadisk_active==1) {
130      wd17xx_command_w(machine, offset, data);
130      wd17xx_command_w(space, offset, data);
131131   }   
132132}
133133
134134WRITE8_HANDLER(betadisk_track_w)
135135{
136136   if (betadisk_active==1) {
137      wd17xx_track_w(machine, offset, data);
137      wd17xx_track_w(space, offset, data);
138138   }   
139139}
140140
141141WRITE8_HANDLER(betadisk_sector_w)
142142{
143143   if (betadisk_active==1) {
144      wd17xx_sector_w(machine, offset, data);
144      wd17xx_sector_w(space, offset, data);
145145   }   
146146}
147147
148148WRITE8_HANDLER(betadisk_data_w)
149149{
150150   if (betadisk_active==1) {
151      wd17xx_data_w(machine, offset, data);
151      wd17xx_data_w(space, offset, data);
152152   }   
153153}
154154
src/mess/mess.mak
r3580r3581
380380   $(MESSOBJ)/pp01.a \
381381   $(MESSOBJ)/rt1715.a \
382382   $(MESSOBJ)/sapi1.a \
383   $(MESSOBJ)/sinclair.a \
383384   $(MESSOBJ)/vector06.a \
384385   $(MESSOBJ)/votrax.a \
385386   $(MESSOBJ)/shared.a \
r3580r3581
462463#   $(MESSOBJ)/sega.a \
463464#   $(MESSOBJ)/sgi.a \
464465#   $(MESSOBJ)/sharp.a \
465#   $(MESSOBJ)/sinclair.a \
466466#   $(MESSOBJ)/sony.a \
467467#   $(MESSOBJ)/sord.a \
468468#   $(MESSOBJ)/special.a \
r3580r3581
742742   $(MESS_MACHINE)/spectrum.o      \
743743   $(MESS_MACHINE)/beta.o      \
744744   $(MESS_FORMATS)/zx81_p.o      \
745   $(MESS_DRIVERS)/ql.o      \
746   $(MESS_VIDEO)/zx8301.o      \
747   $(MESS_MACHINE)/zx8302.o      \
748745   $(MESS_FORMATS)/tzx_cas.o      \
746#   $(MESS_DRIVERS)/ql.o      \
747#   $(MESS_VIDEO)/zx8301.o      \
748#   $(MESS_MACHINE)/zx8302.o      \
749749
750750$(MESSOBJ)/apple.a:   \
751751   $(MESS_VIDEO)/apple2.o      \
src/mess/drivers/pentagon.c
r3580r3581
1818
1919static int ROMSelection;
2020
21static OPBASE_HANDLER( pentagon_opbase )
21static DIRECT_UPDATE_HANDLER( pentagon_direct )
2222{   
2323   if (betadisk_is_active()) {
24      if (activecpu_get_pc() >= 0x4000) {
24      if (cpu_get_pc(space->machine->cpu[0]) >= 0x4000) {
2525         ROMSelection = ((spectrum_128_port_7ffd_data>>4) & 0x01) ? 1 : 0;
2626         betadisk_disable();
27         memory_set_bankptr(1, memory_region(machine, "main") + 0x010000 + 0x4000*ROMSelection); // Set BASIC ROM
27         memory_set_bankptr(space->machine, 1, memory_region(space->machine, "main") + 0x010000 + 0x4000*ROMSelection); // Set BASIC ROM
2828      }   
29   } else if (((activecpu_get_pc() & 0xff00) == 0x3d00) && (ROMSelection==1))
29   } else if (((cpu_get_pc(space->machine->cpu[0]) & 0xff00) == 0x3d00) && (ROMSelection==1))
3030   {
3131      ROMSelection = 3;
3232      betadisk_enable();
33      memory_set_bankptr(1, memory_region(machine, "main") + 0x01c000); // Set TRDOS ROM         
33      memory_set_bankptr(space->machine,1, memory_region(space->machine, "main") + 0x01c000); // Set TRDOS ROM         
3434   }
3535   return address;
3636}
r3580r3581
3939{
4040   spectrum_128_screen_location = mess_ram + ((spectrum_128_port_7ffd_data & 8) ? (7<<14) : (5<<14));
4141
42   memory_set_bankptr(4, mess_ram + ((spectrum_128_port_7ffd_data & 0x07) * 0x4000));
42   memory_set_bankptr(machine, 4, mess_ram + ((spectrum_128_port_7ffd_data & 0x07) * 0x4000));
4343
4444   if( betadisk_is_active() && !( spectrum_128_port_7ffd_data & 0x10 ) ) {   
4545      /* GLUK */
r3580r3581
5151      ROMSelection = ((spectrum_128_port_7ffd_data>>4) & 0x01) ;
5252   }
5353   /* rom 0 is 128K rom, rom 1 is 48 BASIC */
54   memory_set_bankptr(1, memory_region(machine, "main") + 0x010000 + (ROMSelection<<14));
54   memory_set_bankptr(machine, 1, memory_region(machine, "main") + 0x010000 + (ROMSelection<<14));
5555}
5656
5757static WRITE8_HANDLER(pentagon_port_7ffd_w)
r3580r3581
6464   spectrum_128_port_7ffd_data = data;
6565
6666   /* update memory */
67   pentagon_update_memory(machine);
67   pentagon_update_memory(space->machine);
6868}
6969
7070static ADDRESS_MAP_START (pentagon_io, ADDRESS_SPACE_IO, 8)   
r3580r3581
8282
8383static MACHINE_RESET( pentagon )
8484{
85   memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, SMH_BANK1);
86   memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, SMH_UNMAP);
85   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
8786
87   memory_install_read8_handler(space, 0x0000, 0x3fff, 0, 0, SMH_BANK1);
88   memory_install_write8_handler(space, 0x0000, 0x3fff, 0, 0, SMH_UNMAP);
89
8890   betadisk_enable();
8991   betadisk_clear_status();
9092
91   memory_set_opbase_handler( 0, pentagon_opbase );
93   memory_set_direct_update_handler( space, pentagon_direct );
9294   
9395   memset(mess_ram,0,128*1024);
9496   
9597   /* Bank 5 is always in 0x4000 - 0x7fff */
96   memory_set_bankptr(2, mess_ram + (5<<14));
98   memory_set_bankptr(machine, 2, mess_ram + (5<<14));
9799
98100   /* Bank 2 is always in 0x8000 - 0xbfff */
99   memory_set_bankptr(3, mess_ram + (2<<14));
101   memory_set_bankptr(machine, 3, mess_ram + (2<<14));
100102
101103   spectrum_128_port_7ffd_data = 0;
102104
src/mess/drivers/scorpion.c
r3580r3581
196196
197197static void scorpion_update_memory(running_machine *machine)
198198{
199   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
199200   spectrum_128_screen_location = mess_ram + ((spectrum_128_port_7ffd_data & 8) ? (7<<14) : (5<<14));
200201
201   memory_set_bankptr(4, mess_ram + (((spectrum_128_port_7ffd_data & 0x07) | ((scorpion_256_port_1ffd_data & 0x10)>>1)) * 0x4000));
202   memory_set_bankptr(machine, 4, mess_ram + (((spectrum_128_port_7ffd_data & 0x07) | ((scorpion_256_port_1ffd_data & 0x10)>>1)) * 0x4000));
202203
203204   if ((scorpion_256_port_1ffd_data & 0x01)==0x01)
204205   {
205      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, SMH_BANK1);
206      memory_set_bankptr(1, mess_ram+(8<<14));     
206      memory_install_write8_handler(space, 0x0000, 0x3fff, 0, 0, SMH_BANK1);
207      memory_set_bankptr(machine, 1, mess_ram+(8<<14));     
207208   }
208209   else
209210   {
r3580r3581
214215         /* ROM switching */
215216         ROMSelection = ((spectrum_128_port_7ffd_data>>4) & 0x01) ? 1 : 0;
216217      }         
217      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, SMH_UNMAP);
218      memory_set_bankptr(1, memory_region(machine, "main") + 0x010000 + (ROMSelection<<14));     
218      memory_install_write8_handler(space, 0x0000, 0x3fff, 0, 0, SMH_UNMAP);
219      memory_set_bankptr(machine, 1, memory_region(machine, "main") + 0x010000 + (ROMSelection<<14));     
219220   }
220221   
221222   
222223}
223224
224static OPBASE_HANDLER( scorpion_opbase )
225static DIRECT_UPDATE_HANDLER( scorpion_direct )
225226{   
226227   if (betadisk_is_active()) {
227      if (activecpu_get_pc() >= 0x4000) {
228      if (cpu_get_pc(space->machine->cpu[0]) >= 0x4000) {
228229         ROMSelection = ((spectrum_128_port_7ffd_data>>4) & 0x01) ? 1 : 0;
229230         betadisk_disable();
230         memory_set_bankptr(1, memory_region(machine, "main") + 0x010000 + 0x4000*ROMSelection); // Set BASIC ROM
231         memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, SMH_UNMAP);
231         memory_set_bankptr(space->machine, 1, memory_region(space->machine, "main") + 0x010000 + 0x4000*ROMSelection); // Set BASIC ROM
232         memory_install_write8_handler(space, 0x0000, 0x3fff, 0, 0, SMH_UNMAP);
232233      }   
233   } else if (((activecpu_get_pc() & 0xff00) == 0x3d00) && (ROMSelection==1))
234   } else if (((cpu_get_pc(space->machine->cpu[0]) & 0xff00) == 0x3d00) && (ROMSelection==1))
234235   {
235236      ROMSelection = 3;
236237      betadisk_enable();
237      memory_set_bankptr(1, memory_region(machine, "main") + 0x01c000); // Set TRDOS ROM         
238      memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, SMH_UNMAP);
238      memory_set_bankptr(space->machine, 1, memory_region(space->machine, "main") + 0x01c000); // Set TRDOS ROM         
239      memory_install_write8_handler(space, 0x0000, 0x3fff, 0, 0, SMH_UNMAP);
239240   }
240241   return address;
241242}
r3580r3581
259260   spectrum_128_port_7ffd_data = data;
260261
261262   /* update memory */
262   scorpion_update_memory(machine);
263   scorpion_update_memory(space->machine);
263264}
264265
265266static WRITE8_HANDLER(scorpion_port_1ffd_w)
r3580r3581
268269   if ((spectrum_128_port_7ffd_data & 0x20)==0)
269270   {
270271      scorpion_256_port_1ffd_data = data;
271      scorpion_update_memory(machine);
272      scorpion_update_memory(space->machine);
272273   }
273274}
274275 
r3580r3581
289290
290291static MACHINE_RESET( scorpion )
291292{   
292   memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, SMH_BANK1);
293   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
293294   
295   memory_install_read8_handler(space, 0x0000, 0x3fff, 0, 0, SMH_BANK1);
296   
294297   betadisk_disable();
295298   betadisk_clear_status();
296299
297   memory_set_opbase_handler( 0, scorpion_opbase );
300   memory_set_direct_update_handler(space, scorpion_direct );
298301   
299302   memset(mess_ram,0,256*1024);
300303   
301304   /* Bank 5 is always in 0x4000 - 0x7fff */
302   memory_set_bankptr(2, mess_ram + (5<<14));
305   memory_set_bankptr(machine, 2, mess_ram + (5<<14));
303306
304307   /* Bank 2 is always in 0x8000 - 0xbfff */
305   memory_set_bankptr(3, mess_ram + (2<<14));
308   memory_set_bankptr(machine, 3, mess_ram + (2<<14));
306309
307310   spectrum_128_port_7ffd_data = 0;
308311   scorpion_256_port_1ffd_data = 0;
src/mess/drivers/specpls3.c
r3580r3581
184184
185185static WRITE8_HANDLER(spectrum_plus3_port_3ffd_w)
186186{
187      if (~input_port_read(machine, "CONFIG") & 0x20)
188            nec765_data_w(machine, 0,data);
187      if (~input_port_read(space->machine, "CONFIG") & 0x20)
188            nec765_data_w(space, 0,data);
189189}
190190
191191static  READ8_HANDLER(spectrum_plus3_port_3ffd_r)
192192{
193      if (input_port_read(machine, "CONFIG") & 0x20)
193      if (input_port_read(space->machine, "CONFIG") & 0x20)
194194            return 0xff;
195195      else
196            return nec765_data_r(machine, 0);
196            return nec765_data_r(space, 0);
197197}
198198
199199
200200static  READ8_HANDLER(spectrum_plus3_port_2ffd_r)
201201{
202      if (input_port_read(machine, "CONFIG") & 0x20)
202      if (input_port_read(space->machine, "CONFIG") & 0x20)
203203            return 0xff;
204204      else
205            return nec765_status_r(machine, 0);
205            return nec765_status_r(space, 0);
206206}
207207
208208
209209void spectrum_plus3_update_memory(running_machine *machine)
210210{
211   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
212   
211213   if (spectrum_128_port_7ffd_data & 8)
212214   {
213215         logerror("+3 SCREEN 1: BLOCK 7\n");
r3580r3581
232234         ram_page = spectrum_128_port_7ffd_data & 0x07;
233235         ram_data = mess_ram + (ram_page<<14);
234236
235         memory_set_bankptr(4, ram_data);
237         memory_set_bankptr(machine, 4, ram_data);
236238
237239         logerror("RAM at 0xc000: %02x\n",ram_page);
238240
239241         /* Reset memory between 0x4000 - 0xbfff in case extended paging was being used */
240242         /* Bank 5 in 0x4000 - 0x7fff */
241         memory_set_bankptr(2, mess_ram + (5<<14));
243         memory_set_bankptr(machine, 2, mess_ram + (5<<14));
242244
243245         /* Bank 2 in 0x8000 - 0xbfff */
244         memory_set_bankptr(3, mess_ram + (2<<14));
246         memory_set_bankptr(machine, 3, mess_ram + (2<<14));
245247
246248
247249         ROMSelection = ((spectrum_128_port_7ffd_data>>4) & 0x01) |
r3580r3581
251253
252254         ChosenROM = memory_region(machine, "main") + 0x010000 + (ROMSelection<<14);
253255
254         memory_set_bankptr(1, ChosenROM);
255         memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, SMH_UNMAP);
256         memory_set_bankptr(machine, 1, ChosenROM);
257         memory_install_write8_handler(space, 0x0000, 0x3fff, 0, 0, SMH_UNMAP);
256258
257259         logerror("rom switch: %02x\n", ROMSelection);
258260   }
r3580r3581
269271         memory_selection = &spectrum_plus3_memory_selections[(MemorySelection<<2)];
270272
271273         ram_data = mess_ram + (memory_selection[0]<<14);
272         memory_set_bankptr(1, ram_data);
274         memory_set_bankptr(machine, 1, ram_data);
273275         /* allow writes to 0x0000-0x03fff */
274         memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, SMH_BANK1);
276         memory_install_write8_handler(space, 0x0000, 0x3fff, 0, 0, SMH_BANK1);
275277
276278         ram_data = mess_ram + (memory_selection[1]<<14);
277         memory_set_bankptr(2, ram_data);
279         memory_set_bankptr(machine, 2, ram_data);
278280
279281         ram_data = mess_ram + (memory_selection[2]<<14);
280         memory_set_bankptr(3, ram_data);
282         memory_set_bankptr(machine, 3, ram_data);
281283
282284         ram_data = mess_ram + (memory_selection[3]<<14);
283         memory_set_bankptr(4, ram_data);
285         memory_set_bankptr(machine, 4, ram_data);
284286
285287         logerror("extended memory paging: %02x\n",MemorySelection);
286288      }
r3580r3581
303305      spectrum_128_port_7ffd_data = data;
304306
305307      /* update memory */
306      spectrum_plus3_update_memory(machine);
308      spectrum_plus3_update_memory(space->machine);
307309}
308310
309311static WRITE8_HANDLER(spectrum_plus3_port_1ffd_w)
r3580r3581
325327      if ((spectrum_128_port_7ffd_data & 0x20)==0)
326328      {
327329            /* no */
328            spectrum_plus3_update_memory(machine);
330            spectrum_plus3_update_memory(space->machine);
329331      }
330332}
331333
src/mess/drivers/spectrum.c
r3580r3581
177177   if ((Changed & 0x07)!=0)
178178   {
179179      /* yes - send event */
180      EventList_AddItemOffset(machine, 0x0fe, data & 0x07, ATTOTIME_TO_CYCLES(0,attotime_mul(video_screen_get_scan_period(machine->primary_screen), video_screen_get_vpos(machine->primary_screen))));
180      EventList_AddItemOffset(space->machine, 0x0fe, data & 0x07, ATTOTIME_TO_CYCLES(0,attotime_mul(video_screen_get_scan_period(space->machine->primary_screen), video_screen_get_vpos(space->machine->primary_screen))));
181181   }
182182
183183   if ((Changed & (1<<4))!=0)
r3580r3581
189189   if ((Changed & (1<<3))!=0)
190190   {
191191      /* write cassette data */
192      cassette_output(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" ), (data & (1<<3)) ? -1.0 : +1.0);
192      cassette_output(device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette" ), (data & (1<<3)) ? -1.0 : +1.0);
193193   }
194194
195195   PreviousFE = data;
r3580r3581
209209   int lines = offset>>8;
210210   int data = 0xff;
211211
212   int cs_extra1 = input_port_read(machine, "PLUS0")  & 0x1f;
213   int cs_extra2 = input_port_read(machine, "PLUS1")  & 0x1f;
214   int cs_extra3 = input_port_read(machine, "PLUS2") & 0x1f;
215   int ss_extra1 = input_port_read(machine, "PLUS3") & 0x1f;
216   int ss_extra2 = input_port_read(machine, "PLUS4") & 0x1f;
212   int cs_extra1 = input_port_read(space->machine, "PLUS0")  & 0x1f;
213   int cs_extra2 = input_port_read(space->machine, "PLUS1")  & 0x1f;
214   int cs_extra3 = input_port_read(space->machine, "PLUS2") & 0x1f;
215   int ss_extra1 = input_port_read(space->machine, "PLUS3") & 0x1f;
216   int ss_extra2 = input_port_read(space->machine, "PLUS4") & 0x1f;
217217
218218   /* Caps - V */
219219   if ((lines & 1)==0)
220220   {
221      data &= input_port_read(machine, "LINE0");
221      data &= input_port_read(space->machine, "LINE0");
222222      /* CAPS for extra keys */
223223      if (cs_extra1 != 0x1f || cs_extra2 != 0x1f || cs_extra3 != 0x1f)
224224         data &= ~0x01;
r3580r3581
226226
227227   /* A - G */
228228   if ((lines & 2)==0)
229      data &= input_port_read(machine, "LINE1");
229      data &= input_port_read(space->machine, "LINE1");
230230
231231   /* Q - T */
232232   if ((lines & 4)==0)
233      data &= input_port_read(machine, "LINE2");
233      data &= input_port_read(space->machine, "LINE2");
234234
235235   /* 1 - 5 */
236236   if ((lines & 8)==0)
237      data &= input_port_read(machine, "LINE3") & cs_extra1;
237      data &= input_port_read(space->machine, "LINE3") & cs_extra1;
238238
239239   /* 6 - 0 */
240240   if ((lines & 16)==0)
241      data &= input_port_read(machine, "LINE4") & cs_extra2;
241      data &= input_port_read(space->machine, "LINE4") & cs_extra2;
242242
243243   /* Y - P */
244244   if ((lines & 32)==0)
245      data &= input_port_read(machine, "LINE5") & ss_extra1;
245      data &= input_port_read(space->machine, "LINE5") & ss_extra1;
246246
247247   /* H - Enter */
248248   if ((lines & 64)==0)
249      data &= input_port_read(machine, "LINE6");
249      data &= input_port_read(space->machine, "LINE6");
250250
251251   /* B - Space */
252252   if ((lines & 128)==0)
253253   {
254      data &= input_port_read(machine, "LINE7") & cs_extra3 & ss_extra2;
254      data &= input_port_read(space->machine, "LINE7") & cs_extra3 & ss_extra2;
255255      /* SYMBOL SHIFT for extra keys */
256256      if (ss_extra1 != 0x1f || ss_extra2 != 0x1f)
257257         data &= ~0x02;
r3580r3581
260260   data |= (0xe0); /* Set bits 5-7 - as reset above */
261261
262262   /* cassette input from wav */
263   if (cassette_input(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" )) > 0.0038 )
263   if (cassette_input(device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette" )) > 0.0038 )
264264   {
265265      data &= ~0x40;
266266   }
267267
268268   /* Issue 2 Spectrums default to having bits 5, 6 & 7 set.
269269    Issue 3 Spectrums default to having bits 5 & 7 set and bit 6 reset. */
270   if (input_port_read(machine, "CONFIG") & 0x80)
270   if (input_port_read(space->machine, "CONFIG") & 0x80)
271271      data ^= (0x40);
272272   return data;
273273}
r3580r3581
275275/* kempston joystick interface */
276276READ8_HANDLER(spectrum_port_1f_r)
277277{
278   return input_port_read(machine, "KEMPSTON") & 0x1f;
278   return input_port_read(space->machine, "KEMPSTON") & 0x1f;
279279}
280280
281281/* fuller joystick interface */
282282READ8_HANDLER(spectrum_port_7f_r)
283283{
284   return input_port_read(machine, "FULLER") | (0xff^0x8f);
284   return input_port_read(space->machine, "FULLER") | (0xff^0x8f);
285285}
286286
287287/* mikrogen joystick interface */
288288READ8_HANDLER(spectrum_port_df_r)
289289{
290   return input_port_read(machine, "MIKROGEN") | (0xff^0x1f);
290   return input_port_read(space->machine, "MIKROGEN") | (0xff^0x1f);
291291}
292292
293293static  READ8_HANDLER ( spectrum_port_ula_r )
294294{
295   return video_screen_get_vpos(machine->primary_screen)<193 ? spectrum_colorram[(video_screen_get_vpos(machine->primary_screen)&0xf8)<<2]:0xff;
295   return video_screen_get_vpos(space->machine->primary_screen)<193 ? spectrum_colorram[(video_screen_get_vpos(space->machine->primary_screen)&0xf8)<<2]:0xff;
296296}
297297
298298/* ports are not decoded full.
r3580r3581
443443
444444static INTERRUPT_GEN( spec_interrupt )
445445{
446   cpu_set_input_line(machine->cpu[0], 0, HOLD_LINE);
446   cpu_set_input_line(device, 0, HOLD_LINE);
447447}
448448
449449static const cassette_config spectrum_cassette_config =
src/mess/drivers/spec128.c
r3580r3581
182182   spectrum_128_port_7ffd_data = data;
183183
184184   /* update memory */
185   spectrum_128_update_memory(machine);
185   spectrum_128_update_memory(space->machine);
186186}
187187
188188void spectrum_128_update_memory(running_machine *machine)
r3580r3581
209209         ram_page = spectrum_128_port_7ffd_data & 0x07;
210210         ram_data = mess_ram + (ram_page<<14);
211211
212         memory_set_bankptr(4, ram_data);
212         memory_set_bankptr(machine, 4, ram_data);
213213
214214         logerror("RAM at 0xc000: %02x\n",ram_page);
215215   }
r3580r3581
221221
222222   ChosenROM = memory_region(machine, "main") + 0x010000 + (ROMSelection<<14);
223223
224   memory_set_bankptr(1, ChosenROM);
224   memory_set_bankptr(machine, 1, ChosenROM);
225225
226226   logerror("rom switch: %02x\n", ROMSelection);
227227}
228228
229229static  READ8_HANDLER ( spectrum_128_ula_r )
230230{
231   return video_screen_get_vpos(machine->primary_screen)<193 ? spectrum_128_screen_location[0x1800|(video_screen_get_vpos(machine->primary_screen)&0xf8)<<2]:0xff;
231   return video_screen_get_vpos(space->machine->primary_screen)<193 ? spectrum_128_screen_location[0x1800|(video_screen_get_vpos(space->machine->primary_screen)&0xf8)<<2]:0xff;
232232}
233233
234234static ADDRESS_MAP_START (spectrum_128_io, ADDRESS_SPACE_IO, 8)
r3580r3581
255255   /* 0x0000-0x3fff always holds ROM */
256256
257257   /* Bank 5 is always in 0x4000 - 0x7fff */
258   memory_set_bankptr(2, mess_ram + (5<<14));
258   memory_set_bankptr(machine, 2, mess_ram + (5<<14));
259259
260260   /* Bank 2 is always in 0x8000 - 0xbfff */
261   memory_set_bankptr(3, mess_ram + (2<<14));
261   memory_set_bankptr(machine, 3, mess_ram + (2<<14));
262262
263263   /* set initial ram config */
264264   spectrum_128_port_7ffd_data = 0;
src/mess/drivers/timex.c
r3580r3581
169169static WRITE8_HANDLER(ts2068_port_f4_w)
170170{
171171      ts2068_port_f4_data = data;
172      ts2068_update_memory(machine);
172      ts2068_update_memory(space->machine);
173173}
174174
175175static  READ8_HANDLER(ts2068_port_ff_r)
r3580r3581
186186           Bit  7   Cartridge (0) / EXROM (1) select
187187        */
188188      ts2068_port_ff_data = data;
189      ts2068_update_memory(machine);
189      ts2068_update_memory(space->machine);
190190      logerror("Port %04x write %02x\n", offset, data);
191191}
192192
r3580r3581
210210 *******************************************************************/
211211void ts2068_update_memory(running_machine *machine)
212212{
213   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
213214   unsigned char *ChosenROM, *ExROM, *DOCK;
214   read8_machine_func rh;
215   write8_machine_func wh;
215   read8_space_func rh;
216   write8_space_func wh;
216217
217218   DOCK = timex_cart_data;
218219
r3580r3581
224225      {
225226            rh = SMH_BANK1;
226227            wh = SMH_UNMAP;
227            memory_set_bankptr(1, ExROM);
228            memory_set_bankptr(machine, 1, ExROM);
228229            logerror("0000-1fff EXROM\n");
229230      }
230231      else
231232      {
232233         if (timex_cart_type == TIMEX_CART_DOCK)
233234         {
234            memory_set_bankptr(1, DOCK);
235            memory_set_bankptr(machine, 1, DOCK);
235236            rh = SMH_BANK1;
236237            if (timex_cart_chunks&0x01)
237238               wh = SMH_BANK9;
r3580r3581
249250   else
250251   {
251252      ChosenROM = memory_region(machine, "main") + 0x010000;
252      memory_set_bankptr(1, ChosenROM);
253      memory_set_bankptr(machine, 1, ChosenROM);
253254      rh = SMH_BANK1;
254255      wh = SMH_UNMAP;
255256      logerror("0000-1fff HOME\n");
256257   }
257   memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x1fff, 0, 0, rh);
258   memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x1fff, 0, 0, wh);
258   memory_install_read8_handler(space, 0x0000, 0x1fff, 0, 0, rh);
259   memory_install_write8_handler(space, 0x0000, 0x1fff, 0, 0, wh);
259260
260261   if (ts2068_port_f4_data & 0x02)
261262   {
262263      if (ts2068_port_ff_data & 0x80)
263264      {
264         memory_set_bankptr(2, ExROM);
265         memory_set_bankptr(machine, 2, ExROM);
265266         rh = SMH_BANK2;
266267         wh = SMH_UNMAP;
267268         logerror("2000-3fff EXROM\n");
r3580r3581
270271      {
271272         if (timex_cart_type == TIMEX_CART_DOCK)
272273         {
273            memory_set_bankptr(2, DOCK+0x2000);
274            memory_set_bankptr(machine, 2, DOCK+0x2000);
274275            rh = SMH_BANK2;
275276            if (timex_cart_chunks&0x02)
276277               wh = SMH_BANK10;
r3580r3581
288289   else
289290   {
290291      ChosenROM = memory_region(machine, "main") + 0x012000;
291      memory_set_bankptr(2, ChosenROM);
292      memory_set_bankptr(machine, 2, ChosenROM);
292293      rh = SMH_BANK2;
293294      wh = SMH_UNMAP;
294295      logerror("2000-3fff HOME\n");
295296   }
296   memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x2000, 0x3fff, 0, 0, rh);
297   memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x2000, 0x3fff, 0, 0, wh);
297   memory_install_read8_handler(space, 0x2000, 0x3fff, 0, 0, rh);
298   memory_install_write8_handler(space, 0x2000, 0x3fff, 0, 0, wh);
298299
299300   if (ts2068_port_f4_data & 0x04)
300301   {
301302      if (ts2068_port_ff_data & 0x80)
302303      {
303         memory_set_bankptr(3, ExROM);
304         memory_set_bankptr(machine, 3, ExROM);
304305         rh = SMH_BANK3;
305306         wh = SMH_UNMAP;
306307         logerror("4000-5fff EXROM\n");
r3580r3581
309310      {
310311         if (timex_cart_type == TIMEX_CART_DOCK)
311312         {
312            memory_set_bankptr(3, DOCK+0x4000);
313            memory_set_bankptr(machine, 3, DOCK+0x4000);
313314            rh = SMH_BANK3;
314315            if (timex_cart_chunks&0x04)
315316               wh = SMH_BANK11;
r3580r3581
326327   }
327328   else
328329   {
329      memory_set_bankptr(3, mess_ram);
330      memory_set_bankptr(11, mess_ram);
330      memory_set_bankptr(machine, 3, mess_ram);
331      memory_set_bankptr(machine, 11, mess_ram);
331332      rh = SMH_BANK3;
332333      wh = SMH_BANK11;
333334      logerror("4000-5fff RAM\n");
334335   }
335   memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x5fff, 0, 0, rh);
336   memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x5fff, 0, 0, wh);
336   memory_install_read8_handler(space, 0x4000, 0x5fff, 0, 0, rh);
337   memory_install_write8_handler(space, 0x4000, 0x5fff, 0, 0, wh);
337338
338339   if (ts2068_port_f4_data & 0x08)
339340   {
340341      if (ts2068_port_ff_data & 0x80)
341342      {
342         memory_set_bankptr(4, ExROM);
343         memory_set_bankptr(machine, 4, ExROM);
343344         rh = SMH_BANK4;
344345         wh = SMH_UNMAP;
345346         logerror("6000-7fff EXROM\n");
r3580r3581
348349      {
349350            if (timex_cart_type == TIMEX_CART_DOCK)
350351            {
351               memory_set_bankptr(4, DOCK+0x6000);
352               memory_set_bankptr(machine, 4, DOCK+0x6000);
352353               rh = SMH_BANK4;
353354               if (timex_cart_chunks&0x08)
354355                  wh = SMH_BANK12;
r3580r3581
365366   }
366367   else
367368   {
368      memory_set_bankptr(4, mess_ram + 0x2000);
369      memory_set_bankptr(12, mess_ram + 0x2000);
369      memory_set_bankptr(machine, 4, mess_ram + 0x2000);
370      memory_set_bankptr(machine, 12, mess_ram + 0x2000);
370371      rh = SMH_BANK4;
371372      wh = SMH_BANK12;
372373      logerror("6000-7fff RAM\n");
373374   }
374   memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, rh);
375   memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, wh);
375   memory_install_read8_handler(space, 0x6000, 0x7fff, 0, 0, rh);
376   memory_install_write8_handler(space, 0x6000, 0x7fff, 0, 0, wh);
376377
377378   if (ts2068_port_f4_data & 0x10)
378379   {
379380      if (ts2068_port_ff_data & 0x80)
380381      {
381         memory_set_bankptr(5, ExROM);
382         memory_set_bankptr(machine, 5, ExROM);
382383         rh = SMH_BANK5;
383384         wh = SMH_UNMAP;
384385         logerror("8000-9fff EXROM\n");
r3580r3581
387388      {
388389         if (timex_cart_type == TIMEX_CART_DOCK)
389390         {
390            memory_set_bankptr(5, DOCK+0x8000);
391            memory_set_bankptr(machine, 5, DOCK+0x8000);
391392            rh = SMH_BANK5;
392393            if (timex_cart_chunks&0x10)
393394               wh = SMH_BANK13;
r3580r3581
404405   }
405406   else
406407   {
407      memory_set_bankptr(5, mess_ram + 0x4000);
408      memory_set_bankptr(13, mess_ram + 0x4000);
408      memory_set_bankptr(machine, 5, mess_ram + 0x4000);
409      memory_set_bankptr(machine, 13, mess_ram + 0x4000);
409410      rh = SMH_BANK5;
410411      wh = SMH_BANK13;
411412      logerror("8000-9fff RAM\n");
412413   }
413   memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x8000, 0x9fff, 0, 0,rh);
414   memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x8000, 0x9fff, 0, 0,wh);
414   memory_install_read8_handler(space, 0x8000, 0x9fff, 0, 0,rh);
415   memory_install_write8_handler(space, 0x8000, 0x9fff, 0, 0,wh);
415416
416417   if (ts2068_port_f4_data & 0x20)
417418   {
418419      if (ts2068_port_ff_data & 0x80)
419420      {
420         memory_set_bankptr(6, ExROM);
421         memory_set_bankptr(machine, 6, ExROM);
421422         rh = SMH_BANK6;
422423         wh = SMH_UNMAP;
423424         logerror("a000-bfff EXROM\n");
r3580r3581
426427      {
427428         if (timex_cart_type == TIMEX_CART_DOCK)
428429         {
429            memory_set_bankptr(6, DOCK+0xa000);
430            memory_set_bankptr(machine, 6, DOCK+0xa000);
430431            rh = SMH_BANK6;
431432            if (timex_cart_chunks&0x20)
432433               wh = SMH_BANK14;
r3580r3581
443444   }
444445   else
445446   {
446      memory_set_bankptr(6, mess_ram + 0x6000);
447      memory_set_bankptr(14, mess_ram + 0x6000);
447      memory_set_bankptr(machine, 6, mess_ram + 0x6000);
448      memory_set_bankptr(machine, 14, mess_ram + 0x6000);
448449      rh = SMH_BANK6;
449450      wh = SMH_BANK14;
450451      logerror("a000-bfff RAM\n");
451452   }
452   memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xbfff, 0, 0, rh);
453   memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xbfff, 0, 0, wh);
453   memory_install_read8_handler(space, 0xa000, 0xbfff, 0, 0, rh);
454   memory_install_write8_handler(space, 0xa000, 0xbfff, 0, 0, wh);
454455
455456   if (ts2068_port_f4_data & 0x40)
456457   {
457458      if (ts2068_port_ff_data & 0x80)
458459      {
459         memory_set_bankptr(7, ExROM);
460         memory_set_bankptr(machine, 7, ExROM);
460461         rh = SMH_BANK7;
461462         wh = SMH_UNMAP;
462463         logerror("c000-dfff EXROM\n");
r3580r3581
465466      {
466467         if (timex_cart_type == TIMEX_CART_DOCK)
467468         {
468            memory_set_bankptr(7, DOCK+0xc000);
469            memory_set_bankptr(machine, 7, DOCK+0xc000);
469470            rh = SMH_BANK7;
470471            if (timex_cart_chunks&0x40)
471472               wh = SMH_BANK15;
r3580r3581
482483   }
483484   else
484485   {
485      memory_set_bankptr(7, mess_ram + 0x8000);
486      memory_set_bankptr(15, mess_ram + 0x8000);
486      memory_set_bankptr(machine, 7, mess_ram + 0x8000);
487      memory_set_bankptr(machine, 15, mess_ram + 0x8000);
487488      rh = SMH_BANK7;
488489      wh = SMH_BANK15;
489490      logerror("c000-dfff RAM\n");
490491   }
491   memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc000, 0xdfff, 0, 0, rh);
492   memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc000, 0xdfff, 0, 0, wh);
492   memory_install_read8_handler(space, 0xc000, 0xdfff, 0, 0, rh);
493   memory_install_write8_handler(space, 0xc000, 0xdfff, 0, 0, wh);
493494
494495   if (ts2068_port_f4_data & 0x80)
495496   {
496497      if (ts2068_port_ff_data & 0x80)
497498      {
498         memory_set_bankptr(8, ExROM);
499         memory_set_bankptr(machine, 8, ExROM);
499500         rh = SMH_BANK8;
500501         wh = SMH_UNMAP;
501502         logerror("e000-ffff EXROM\n");
r3580r3581
504505      {
505506         if (timex_cart_type == TIMEX_CART_DOCK)
506507         {
507            memory_set_bankptr(8, DOCK+0xe000);
508            memory_set_bankptr(machine, 8, DOCK+0xe000);
508509            rh = SMH_BANK8;
509510            if (timex_cart_chunks&0x80)
510511               wh = SMH_BANK16;
r3580r3581
521522   }
522523   else
523524   {
524      memory_set_bankptr(8, mess_ram + 0xa000);
525      memory_set_bankptr(16, mess_ram + 0xa000);
525      memory_set_bankptr(machine, 8, mess_ram + 0xa000);
526      memory_set_bankptr(machine, 16, mess_ram + 0xa000);
526527      rh = SMH_BANK8;
527528      wh = SMH_BANK16;
528529      logerror("e000-ffff RAM\n");
529530   }
530   memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe000, 0xffff, 0, 0, rh);
531   memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe000, 0xffff, 0, 0, wh);
531   memory_install_read8_handler(space, 0xe000, 0xffff, 0, 0, rh);
532   memory_install_write8_handler(space, 0xe000, 0xffff, 0, 0, wh);
532533}
533534
534535static ADDRESS_MAP_START (ts2068_io, ADDRESS_SPACE_IO, 8)   
r3580r3581
589590
590591static MACHINE_RESET( tc2048 )
591592{
592   memory_set_bankptr(1, mess_ram);
593   memory_set_bankptr(2, mess_ram);
593   memory_set_bankptr(machine, 1, mess_ram);
594   memory_set_bankptr(machine, 2, mess_ram);
594595   ts2068_port_ff_data = 0;
595596
596597   MACHINE_RESET_CALL(spectrum);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team