Previous 15994 Revisions Next

r2541 Sunday 4th May, 2008 at 19:44:09 UTC by Miodrag Milanović
[SPECTRUM] IO maps now done right way, BETA disk support in separate file
[src/mess]mess.mak
[src/mess/drivers]pentagon.c scorpion.c spec128.c specpls3.c spectrum.c timex.c
[src/mess/machine]b2m.c beta.c* beta.h*

src/mess/machine/b2m.c
r2540r2541
155155
156156static PIT8253_OUTPUT_CHANGED(bm2_pit_irq)
157157{
158   if (state==1) logerror("Timer IRQ\n");
159158   pic8259_set_irq_line((device_config*)device_list_find_by_tag( Machine->config->devicelist, PIC8259, "pic8259"),1,state);   
160159}
161160
162UINT8 vblank_state = 0;
163INTERRUPT_GEN (b2m_vblank_interrupt)
164{
165   vblank_state++;
166   if (vblank_state>1) vblank_state=0;
167   pic8259_set_irq_line((device_config*)device_list_find_by_tag( Machine->config->devicelist, PIC8259, "pic8259"),0,vblank_state);     
168}
161
169162const struct pit8253_config b2m_pit8253_intf =
170163{
171164   {
r2540r2541
329322{     
330323   cpunum_set_input_line(Machine, 0, 0,interrupt ?  HOLD_LINE : CLEAR_LINE); 
331324}
325UINT8 vblank_state = 0;
332326
333327
334328/* Driver initialization */
r2540r2541
393387   b2m_pic_set_int_line
394388};
395389
390INTERRUPT_GEN (b2m_vblank_interrupt)
391{   
392   //vblank_state++;
393   //if (vblank_state>1) vblank_state=0;
394   //pic8259_set_irq_line((device_config*)device_list_find_by_tag( Machine->config->devicelist, PIC8259, "pic8259"),0,vblank_state);     
395}
396static TIMER_CALLBACK (b2m_callback)
397{   
398   vblank_state++;
399   if (vblank_state>1) vblank_state=0;
400   pic8259_set_irq_line((device_config*)device_list_find_by_tag( Machine->config->devicelist, PIC8259, "pic8259"),0,vblank_state);     
401}
396402
397403MACHINE_RESET(b2m)
398404{
r2540r2541
406412
407413   cpunum_set_irq_callback(0, b2m_irq_callback);
408414   b2m_set_bank(machine,7);
415     
416   timer_pulse(ATTOTIME_IN_HZ(1), NULL, 0, b2m_callback);
409417}
410418
411419DEVICE_IMAGE_LOAD( b2m_floppy )
src/mess/machine/beta.c
r0r2541
1/*********************************************************************
2
3   beta.h
4
5   Implementation of Beta disk drive support for Spectrum and clones
6   
7   04/05/2008 Created by Miodrag Milanovic
8
9*********************************************************************/
10#include "driver.h"
11#include "devices/basicdsk.h"
12#include "machine/wd17xx.h"
13
14static int betadisk_status;
15static int betadisk_active;
16
17int betadisk_is_active(void)
18{
19   return betadisk_active;
20}
21
22void betadisk_enable(void)
23{
24   betadisk_active = 1;
25}
26
27void betadisk_disable(void)
28{
29   betadisk_active = 0;
30}
31
32void betadisk_clear_status(void)
33{
34   betadisk_status = 0;
35}
36
37void betadisk_wd179x_callback(running_machine *machine, wd17xx_state_t state, void *param)
38{
39   switch (state)
40   {
41      case WD17XX_DRQ_SET:
42      {
43         betadisk_status |= (1<<6);
44      }
45      break;
46
47      case WD17XX_DRQ_CLR:
48      {
49         betadisk_status &=~(1<<6);
50      }
51      break;
52
53      case WD17XX_IRQ_SET:
54      {
55         betadisk_status |= (1<<7);
56      }
57      break;
58
59      case WD17XX_IRQ_CLR:
60      {
61         betadisk_status &=~(1<<7);
62      }
63      break;
64   }
65}
66
67READ8_HANDLER(betadisk_status_r)
68{
69   if (betadisk_active==1) {
70      return wd17xx_status_r(machine, offset);
71   } else {
72      return 0xff;
73   }
74}
75
76READ8_HANDLER(betadisk_track_r)
77{
78   if (betadisk_active==1) {
79      return wd17xx_track_r(machine, offset);
80   } else {
81      return 0xff;
82   }
83}
84
85READ8_HANDLER(betadisk_sector_r)
86{
87   if (betadisk_active==1) {
88      return wd17xx_sector_r(machine, offset);
89   } else {
90      return 0xff;
91   }
92}
93
94READ8_HANDLER(betadisk_data_r)
95{
96   if (betadisk_active==1) {
97      return wd17xx_data_r(machine, offset);
98   } else {
99      return 0xff;
100   }
101}
102
103READ8_HANDLER(betadisk_state_r)
104{
105   if (betadisk_active==1) {
106      return betadisk_status | 0x3f;
107   } else {
108      return 0xff;
109   }
110}
111
112WRITE8_HANDLER(betadisk_param_w)
113{
114   if (betadisk_active==1) {
115        wd17xx_set_drive ( data & 3); 
116        wd17xx_set_side ((data & 0x10) ? 0 : 1 );
117        wd17xx_set_density(data & 0x20 ? DEN_MFM_LO : DEN_FM_LO );
118        if ((data & 0x04) == 0) // reset
119        {
120           wd17xx_reset();   
121        }             
122     }
123}   
124
125WRITE8_HANDLER(betadisk_command_w)
126{
127   if (betadisk_active==1) {
128      wd17xx_command_w(machine, offset, data);
129   }   
130}
131
132WRITE8_HANDLER(betadisk_track_w)
133{
134   if (betadisk_active==1) {
135      wd17xx_track_w(machine, offset, data);
136   }   
137}
138
139WRITE8_HANDLER(betadisk_sector_w)
140{
141   if (betadisk_active==1) {
142      wd17xx_sector_w(machine, offset, data);
143   }   
144}
145
146WRITE8_HANDLER(betadisk_data_w)
147{
148   if (betadisk_active==1) {
149      wd17xx_data_w(machine, offset, data);
150   }   
151}
152
153DEVICE_IMAGE_LOAD( beta_floppy )
154{
155   if (device_load_basicdsk_floppy (image) != INIT_PASS)
156      return INIT_FAIL;
157
158   basicdsk_set_geometry (image, 80, 2, 16, 256, 1, 0, FALSE);
159   return INIT_PASS;
160}
161
162void beta_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
163{
164   /* floppy */
165   switch(state)
166   {
167      /* --- the following bits of info are returned as 64-bit signed integers --- */
168      case MESS_DEVINFO_INT_COUNT:                     info->i = 4; break;
169
170      /* --- the following bits of info are returned as pointers to data or functions --- */
171      case MESS_DEVINFO_PTR_LOAD:                     info->load = DEVICE_IMAGE_LOAD_NAME(beta_floppy); break;
172
173      /* --- the following bits of info are returned as NULL-terminated strings --- */
174      case MESS_DEVINFO_STR_FILE_EXTENSIONS:            strcpy(info->s = device_temp_str(), "trd"); break;
175
176      default:                              legacybasicdsk_device_getinfo(devclass, state, info); break;
177   }   
178}
src/mess/machine/beta.h
r0r2541
1/*********************************************************************
2
3   beta.h
4
5   Implementation of Beta disk drive support for Spectrum and clones
6   
7   04/05/2008 Created by Miodrag Milanovic
8
9*********************************************************************/
10#ifndef BETA_H
11#define BETA_H
12
13#include "machine/wd17xx.h"
14
15int betadisk_is_active(void);
16void betadisk_enable(void);
17void betadisk_disable(void);
18void betadisk_clear_status(void);
19void betadisk_wd179x_callback(running_machine *machine, wd17xx_state_t state, void *param);
20
21READ8_HANDLER(betadisk_status_r);
22READ8_HANDLER(betadisk_track_r);
23READ8_HANDLER(betadisk_sector_r);
24READ8_HANDLER(betadisk_data_r);
25READ8_HANDLER(betadisk_state_r);
26
27WRITE8_HANDLER(betadisk_param_w);
28WRITE8_HANDLER(betadisk_command_w);
29WRITE8_HANDLER(betadisk_track_w);
30WRITE8_HANDLER(betadisk_sector_w);
31WRITE8_HANDLER(betadisk_data_w);
32
33void beta_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info);
34
35#endif /* BETA_H */
src/mess/mess.mak
r2540r2541
686686   $(MESS_DRIVERS)/scorpion.o      \
687687   $(MESS_DRIVERS)/pentagon.o      \
688688   $(MESS_MACHINE)/spectrum.o      \
689   $(MESS_MACHINE)/beta.o      \
689690   $(MESS_FORMATS)/zx81_p.o      \
690691   $(MESS_DRIVERS)/ql.o      \
691692   $(MESS_VIDEO)/zx8301.o      \
src/mess/drivers/pentagon.c
r2540r2541
11#include "driver.h"
22#include "includes/spectrum.h"
3#include "eventlst.h"
34#include "devices/snapquik.h"
45#include "devices/cartslot.h"
56#include "devices/cassette.h"
7#include "sound/ay8910.h"
8#include "sound/speaker.h"
69#include "formats/tzx_cas.h"
10#include "devices/basicdsk.h"
11#include "machine/wd17xx.h"
12#include "machine/beta.h"
713
8extern MACHINE_START( scorpion );
14MACHINE_START( pentagon )
15{
16   wd17xx_init(machine, WD_TYPE_179X, betadisk_wd179x_callback, NULL);
17}
918
10/****************************************************************************************************/
11/* pentagon */
1219
13static  READ8_HANDLER(pentagon_port_r)
14{
15   return 0x0ff;
20static int ROMSelection;
21
22static OPBASE_HANDLER( pentagon_opbase )
23{   
24   if ( address >= 0x4000 ) {
25      if (ROMSelection == 3) {         
26         ROMSelection = 1;
27         betadisk_disable();
28         memory_set_bankptr(1, memory_region(REGION_CPU1) + 0x014000); // Set BASIC ROM
29      }
30   }
31   else if ((address & 0xff00) == 0x3d00)
32   {
33      if (ROMSelection == 1)
34      {
35         ROMSelection = 3;
36         betadisk_enable();
37         memory_set_bankptr(1, memory_region(REGION_CPU1) + 0x01c000); // Set TRDOS ROM         
38      }
39   }
40   return address;
1641}
1742
43static void pentagon_update_memory(running_machine *machine)
44{
45   unsigned char *ChosenROM;
46   
47   read8_machine_func rh;
48   write8_machine_func wh;
1849
19static WRITE8_HANDLER(pentagon_port_w)
20{
50   if (spectrum_128_port_7ffd_data & 8)
51   {
52      //logerror("SCREEN 1: BLOCK 7\n");
53      spectrum_128_screen_location = mess_ram + (7<<14);
54   }
55   else
56   {
57      //logerror("SCREEN 0: BLOCK 5\n");
58      spectrum_128_screen_location = mess_ram + (5<<14);
59   }
60
61   /* select ram at 0x0c000-0x0ffff */
62   {
63      int ram_page;
64      unsigned char *ram_data;
65
66      ram_page = (spectrum_128_port_7ffd_data & 0x07);
67      ram_data = mess_ram + (ram_page<<14);
68
69      memory_set_bankptr(4, ram_data);
70
71      //logerror("RAM at 0xc000: %02x\n",ram_page);
72   }
73
74      /* rom at 0x0000 */
75      //logerror("ROM at 0x0000\n");
76
77      /* connect page 0 of rom to 0x0000 */
78      rh = SMH_BANK1;
79      wh = SMH_NOP;
80
81       if( betadisk_is_active() && !( spectrum_128_port_7ffd_data & 0x10 ) ) {   
82         ROMSelection = 2;
83      }
84      else
85      {
86         /* ROM switching */
87         ROMSelection = ((spectrum_128_port_7ffd_data>>4) & 0x01) ;
88      }
89      /* rom 0 is 128K rom, rom 1 is 48 BASIC */
90      ChosenROM = memory_region(REGION_CPU1) + 0x010000 + (ROMSelection<<14);
91
92      memory_set_bankptr(1, ChosenROM);
93
94      //logerror("rom switch: %02x\n", ROMSelection);
95   memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, rh);
96   memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, wh);
2197}
2298
99static WRITE8_HANDLER(pentagon_port_7ffd_w)
100{
101   //logerror("pentagon 7ffd w: %02x\n", data);
23102
103   /* disable paging? */
104   if (spectrum_128_port_7ffd_data & 0x20)
105      return;
24106
25/* ports are not decoded full.
26The function decodes the ports appropriately */
27static ADDRESS_MAP_START (pentagon_io, ADDRESS_SPACE_IO, 8)
28   AM_RANGE(0x0000, 0xffff) AM_READWRITE( pentagon_port_r, pentagon_port_w )
107   /* store new state */
108   spectrum_128_port_7ffd_data = data;
109
110   /* update memory */
111   pentagon_update_memory(machine);
112}
113
114static ADDRESS_MAP_START (pentagon_io, ADDRESS_SPACE_IO, 8)   
115   ADDRESS_MAP_UNMAP_HIGH
116   AM_RANGE(0x001f, 0x001f) AM_READWRITE(betadisk_status_r,betadisk_command_w) AM_MIRROR(0xff00)
117   AM_RANGE(0x003f, 0x003f) AM_READWRITE(betadisk_track_r,betadisk_track_w) AM_MIRROR(0xff00)
118   AM_RANGE(0x005f, 0x005f) AM_READWRITE(betadisk_sector_r,betadisk_sector_w) AM_MIRROR(0xff00)
119   AM_RANGE(0x007f, 0x007f) AM_READWRITE(betadisk_data_r,betadisk_data_w) AM_MIRROR(0xff00)
120   AM_RANGE(0x00fe, 0x00fe) AM_READWRITE(spectrum_port_fe_r,spectrum_port_fe_w) AM_MIRROR(0xff00) AM_MASK(0xffff)
121   AM_RANGE(0x00ff, 0x00ff) AM_READWRITE(betadisk_state_r, betadisk_param_w) AM_MIRROR(0xff00)
122   AM_RANGE(0x4000, 0x4000) AM_WRITE(pentagon_port_7ffd_w)  AM_MIRROR(0x3ffd)
123   AM_RANGE(0x8000, 0x8000) AM_WRITE(AY8910_write_port_0_w) AM_MIRROR(0x3ffd)
124   AM_RANGE(0xc000, 0xc000) AM_READWRITE(AY8910_read_port_0_r,AY8910_control_port_0_w) AM_MIRROR(0x3ffd)
29125ADDRESS_MAP_END
30126
31127static MACHINE_RESET( pentagon )
32128{
129   betadisk_enable();
130   betadisk_clear_status();
131
132   memory_set_opbase_handler( 0, pentagon_opbase );
133   
134   memset(mess_ram,0,128*1024);
135   
33136   /* Bank 5 is always in 0x4000 - 0x7fff */
34137   memory_set_bankptr(2, mess_ram + (5<<14));
35138
36139   /* Bank 2 is always in 0x8000 - 0xbfff */
37140   memory_set_bankptr(3, mess_ram + (2<<14));
141
142   spectrum_128_port_7ffd_data = 0;
143
144   pentagon_update_memory(machine);   
145   
146   MACHINE_RESET_CALL(spectrum);
147   
148   wd17xx_reset();   
38149}
39150
40151static MACHINE_DRIVER_START( pentagon )
41152   MDRV_IMPORT_FROM( spectrum_128 )
42153   MDRV_CPU_MODIFY("main")
43154   MDRV_CPU_IO_MAP(pentagon_io, 0)
44   MDRV_MACHINE_START( scorpion )
155   MDRV_MACHINE_START( pentagon )
45156   MDRV_MACHINE_RESET( pentagon )
46157MACHINE_DRIVER_END
47158
48159
160
49161/***************************************************************************
50162
51163  Game driver(s)
52164
53165***************************************************************************/
54166
55
56167ROM_START(pentagon)
57168   ROM_REGION(0x020000, REGION_CPU1, 0)
169   ROM_LOAD("128p-0.rom",0x010000, 0x4000, CRC(124AD9E0))
170   ROM_LOAD("128p-1.rom",0x014000, 0x4000, CRC(B96A36BE))
171   ROM_LOAD("gluck.rom",0x018000, 0x4000, CRC(CA321D79))
172   ROM_LOAD("trdos.rom",0x01c000, 0x4000, CRC(10751ABA))   
58173   ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL)
59174ROM_END
60175
61SYSTEM_CONFIG_EXTERN(specpls3)
176SYSTEM_CONFIG_EXTERN(spectrum)
62177
178SYSTEM_CONFIG_START(pentagon)
179   CONFIG_IMPORT_FROM(spectrum)
180   CONFIG_RAM_DEFAULT(128 * 1024)
181   CONFIG_DEVICE(beta_floppy_getinfo)
182SYSTEM_CONFIG_END
183
63184/*    YEAR  NAME      PARENT    COMPAT  MACHINE     INPUT       INIT    CONFIG      COMPANY     FULLNAME */
64COMP( ????, pentagon, spectrum, 0,      pentagon,      spectrum,   0,      specpls3,   "???",      "Pentagon", GAME_NOT_WORKING)
185COMP( ????, pentagon, 0,       0,      pentagon,   spectrum,   0,      pentagon,   "???",      "Pentagon", 0)
src/mess/drivers/specpls3.c
r2540r2541
329329      }
330330}
331331
332/* decoding as per spectrum FAQ on www.worldofspectrum.org */
333static  READ8_HANDLER ( spectrum_plus3_port_r )
334{
335    if ((offset & 1)==0)
336    {
337       return spectrum_port_fe_r(machine, offset);
338    }
339
340    if ((offset & 2)==0)
341    {
342       switch ((offset>>14) & 0x03)
343       {
344         /* +3 fdc,memory,centronics */
345         case 0:
346         {
347            switch ((offset>>12) & 0x03)
348            {
349               /* +3 centronics */
350               case 0:
351                  break;
352
353               /* +3 fdc status */
354               case 2:
355                  return spectrum_plus3_port_2ffd_r(machine, offset);
356               /* +3 fdc data */
357               case 3:
358                  return spectrum_plus3_port_3ffd_r(machine, offset);
359
360               default:
361                  break;
362            }
363         }
364         break;
365
366         /* 128k AY data */
367         case 3:
368            return spectrum_128_port_fffd_r(machine, offset);
369
370         default:
371            break;
372       }
373    }
374
375    return video_screen_get_vpos(machine->primary_screen)<193 ? spectrum_128_screen_location[0x1800|(video_screen_get_vpos(machine->primary_screen)&0xf8)<<2]:0xff;
376}
377
378static WRITE8_HANDLER ( spectrum_plus3_port_w )
379{
380      if ((offset & 1)==0)
381            spectrum_port_fe_w(machine, offset, data);
382
383      /* the following is not decoded exactly, need to check
384        what is correct! */
385
386      if ((offset & 2)==0)
387      {
388         switch ((offset>>14) & 0x03)
389         {
390            /* +3 fdc,memory,centronics */
391            case 0:
392            {
393               switch ((offset>>12) & 0x03)
394               {
395                  /* +3 centronics */
396                  case 0:
397                  {
398
399
400                  }
401                  break;
402
403                  /* +3 memory */
404                  case 1:
405                     spectrum_plus3_port_1ffd_w(machine, offset, data);
406                     break;
407
408                  /* +3 fdc data */
409                  case 3:
410                     spectrum_plus3_port_3ffd_w(machine, offset, data);
411                     break;
412
413                  default:
414                     break;
415               }
416            }
417            break;
418
419            /* 128k memory */
420            case 1:
421               spectrum_plus3_port_7ffd_w(machine, offset, data);
422               break;
423
424            /* 128k AY data */
425            case 2:
426               spectrum_128_port_bffd_w(machine, offset, data);
427               break;
428
429            /* 128K AY register */
430            case 3:
431               spectrum_128_port_fffd_w(machine, offset, data);
432
433            default:
434               break;
435         }
436      }
437
438/*logerror("Write %02x to +3 port: %04x\n", data, offset); */
439}
440
441332/* ports are not decoded full.
442333The function decodes the ports appropriately */
443334static ADDRESS_MAP_START (spectrum_plus3_io, ADDRESS_SPACE_IO, 8)
444      AM_RANGE(0x0000, 0xffff) AM_READWRITE( spectrum_plus3_port_r, spectrum_plus3_port_w )
335   ADDRESS_MAP_UNMAP_HIGH
336   AM_RANGE(0x0000, 0x0000) AM_READWRITE(spectrum_port_fe_r,spectrum_port_fe_w) AM_MIRROR(0xfffe) AM_MASK(0xffff)
337   AM_RANGE(0x001f, 0x001f) AM_READ(spectrum_port_1f_r) AM_MIRROR(0xff00)
338   AM_RANGE(0x4000, 0x4000) AM_WRITE(spectrum_plus3_port_7ffd_w) AM_MIRROR(0x3ffd)
339   AM_RANGE(0x8000, 0x8000) AM_WRITE(AY8910_write_port_0_w) AM_MIRROR(0x3ffd)
340   AM_RANGE(0xc000, 0xc000) AM_READWRITE(AY8910_read_port_0_r,AY8910_control_port_0_w) AM_MIRROR(0x3ffd)
341   AM_RANGE(0x1000, 0x1000) AM_WRITE(spectrum_plus3_port_1ffd_w) AM_MIRROR(0x0ffd)
342   AM_RANGE(0x2000, 0x2000) AM_READ(spectrum_plus3_port_2ffd_r) AM_MIRROR(0x0ffd)
343   AM_RANGE(0x3000, 0x3000) AM_READWRITE(spectrum_plus3_port_3ffd_r,spectrum_plus3_port_3ffd_w) AM_MIRROR(0x0ffd)
445344ADDRESS_MAP_END
446345
447346static MACHINE_RESET( spectrum_plus3 )
src/mess/drivers/scorpion.c
r2540r2541
154154#include "sound/speaker.h"
155155#include "formats/tzx_cas.h"
156156
157/* +3 hardware */
158#include "machine/nec765.h"
159#include "devices/dsk.h"
160
161/****************************************************************************************************/
162/* BETADISK/TR-DOS disc controller emulation */
163/* microcontroller KR1818VG93 is a russian wd179x clone */
164157#include "machine/wd17xx.h"
158#include "machine/beta.h"
165159
166/*
167DRQ (D6) and INTRQ (D7).
168DRQ - signal showing request of data by microcontroller
169INTRQ - signal of completion of execution of command.
170*/
171
172static int betadisk_status;
173static int betadisk_active;
174
175static void betadisk_wd179x_callback(running_machine *machine, wd17xx_state_t state, void *param)
176{
177   switch (state)
178   {
179      case WD17XX_DRQ_SET:
180      {
181         betadisk_status |= (1<<6);
182      }
183      break;
184
185      case WD17XX_DRQ_CLR:
186      {
187         betadisk_status &=~(1<<6);
188      }
189      break;
190
191      case WD17XX_IRQ_SET:
192      {
193         betadisk_status |= (1<<7);
194      }
195      break;
196
197      case WD17XX_IRQ_CLR:
198      {
199         betadisk_status &=~(1<<7);
200      }
201      break;
202   }
203}
204
205160MACHINE_START( scorpion )
206161{
207   betadisk_active = 0;
208   betadisk_status = 0x03f;
209162   wd17xx_init(machine, WD_TYPE_179X, betadisk_wd179x_callback, NULL);
210163}
211164
r2540r2541
239192
240193static int scorpion_256_port_1ffd_data = 0;
241194
195static int ROMSelection;
196
197static OPBASE_HANDLER( scorpion_opbase )
198{   
199   if ( address >= 0x4000 ) {
200      if (ROMSelection == 3) {         
201         ROMSelection = 1;
202         betadisk_disable();
203         memory_set_bankptr(1, memory_region(REGION_CPU1) + 0x014000); // Set BASIC ROM
204      }
205   }
206   else if ((address & 0xff00) == 0x3d00)
207   {
208      if (ROMSelection == 1)
209      {
210         ROMSelection = 3;
211         betadisk_enable();
212         memory_set_bankptr(1, memory_region(REGION_CPU1) + 0x01c000); // Set TRDOS ROM         
213      }
214   }
215   return address;
216}
217
242218static void scorpion_update_memory(running_machine *machine)
243219{
244220   unsigned char *ChosenROM;
245   int ROMSelection;
221   
246222   read8_machine_func rh;
247223   write8_machine_func wh;
248224
249225   if (spectrum_128_port_7ffd_data & 8)
250226   {
251      logerror("SCREEN 1: BLOCK 7\n");
227      //logerror("SCREEN 1: BLOCK 7\n");
252228      spectrum_128_screen_location = mess_ram + (7<<14);
253229   }
254230   else
255231   {
256      logerror("SCREEN 0: BLOCK 5\n");
232      //logerror("SCREEN 0: BLOCK 5\n");
257233      spectrum_128_screen_location = mess_ram + (5<<14);
258234   }
259235
r2540r2541
267243
268244      memory_set_bankptr(4, ram_data);
269245
270      logerror("RAM at 0xc000: %02x\n",ram_page);
246      //logerror("RAM at 0xc000: %02x\n",ram_page);
271247   }
272248
273249   if (scorpion_256_port_1ffd_data & 0x01)
274250   {
275251      /* ram at 0x0000 */
276      logerror("RAM at 0x0000\n");
252      //logerror("RAM at 0x0000\n");
277253
278254      /* connect page 0 of ram to 0x0000 */
279255      rh = SMH_BANK1;
r2540r2541
283259   else
284260   {
285261      /* rom at 0x0000 */
286      logerror("ROM at 0x0000\n");
262      //logerror("ROM at 0x0000\n");
287263
288264      /* connect page 0 of rom to 0x0000 */
289265      rh = SMH_BANK1;
r2540r2541
303279
304280      memory_set_bankptr(1, ChosenROM);
305281
306      logerror("rom switch: %02x\n", ROMSelection);
282      //logerror("rom switch: %02x\n", ROMSelection);
307283   }
308284   memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, rh);
309285   memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, wh);
310286}
311287
312288
289
290static TIMER_CALLBACK(nmi_check_callback)
291{
292   if ((input_port_read(machine, "NMI") & 1)==1) {
293      scorpion_256_port_1ffd_data |= 0x02;
294      scorpion_update_memory(machine);
295      cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
296   }
297}
298
313299static WRITE8_HANDLER(scorpion_port_7ffd_w)
314300{
315   logerror("scorpion 7ffd w: %02x\n", data);
301   //logerror("scorpion 7ffd w: %02x\n", data);
316302
317303   /* disable paging? */
318304   if (spectrum_128_port_7ffd_data & 0x20)
r2540r2541
327313
328314static WRITE8_HANDLER(scorpion_port_1ffd_w)
329315{
330   logerror("scorpion 1ffd w: %02x\n", data);
316   //logerror("scorpion 1ffd w: %02x\n", data);
331317
332318   scorpion_256_port_1ffd_data = data;
333319
r2540r2541
337323      scorpion_update_memory(machine);
338324   }
339325}
340
341
342/* not sure if decoding is full or partial on scorpion */
343/* TO BE CHECKED! */
344static  READ8_HANDLER(scorpion_port_r)
345{
346
347    /* KT: the following is not decoded exactly, need to check what
348     is correct */
349    if ((offset & 2)==0)
350    {
351       switch ((offset>>8) & 0xff)
352       {
353            case 0xff: return spectrum_128_port_fffd_r(machine, offset);
354            case 0x1f: return spectrum_port_1f_r(machine, offset);
355            case 0x7f: return spectrum_port_7f_r(machine, offset);
356            case 0xdf: return spectrum_port_df_r(machine, offset);
357       }
358    }
359    switch (offset & 0x0ff)
360    {
361       case 0x0fe:
362          return spectrum_port_fe_r(machine, offset);
363/*      case 0x01f:
364         return wd17xx_status_r(machine, offset);
365      case 0x03f:
366         return wd17xx_track_r(machine, offset);
367      case 0x05f:
368         return wd17xx_sector_r(machine, offset);
369      case 0x07f:
370         return wd17xx_data_r(machine, offset);
371      case 0x0ff:
372         return betadisk_status;*/
373    }
374    return 0xff;
375}
376
377
378/* not sure if decoding is full or partial on scorpion */
379/* TO BE CHECKED! */
380static WRITE8_HANDLER(scorpion_port_w)
381{
382    switch (offset & 0x0ff)
383    {
384      case 0xfe : spectrum_port_fe_w(machine, offset, data);
385               break;
386      default:
387          if ((offset & 2)==0)
388         {
389               switch ((offset>>8) & 0xf0)
390               {
391                  case 0x70:
392                        scorpion_port_7ffd_w(machine, offset, data);
393                        break;
394                  case 0xb0:
395                        spectrum_128_port_bffd_w(machine, offset, data);
396                        break;
397                  case 0xf0:
398                        spectrum_128_port_fffd_w(machine, offset, data);
399                        break;
400                  case 0x10:
401                        scorpion_port_1ffd_w(machine, offset, data);
402                        break;
403                  default:
404                        logerror("Write %02x to scorpion port: %04x\n", data, offset);
405               }
406         }
407         else
408         {
409            logerror("Write %02x to scorpion port: %04x\n", data, offset);
410         }
411   }
412}
413
414
415
326 
416327/* ports are not decoded full.
417328The function decodes the ports appropriately */
418static ADDRESS_MAP_START (scorpion_io, ADDRESS_SPACE_IO, 8)
419   AM_RANGE(0x0000, 0xffff) AM_READWRITE(scorpion_port_r, scorpion_port_w)
329static ADDRESS_MAP_START (scorpion_io, ADDRESS_SPACE_IO, 8)   
330   ADDRESS_MAP_UNMAP_HIGH
331   AM_RANGE(0x001f, 0x001f) AM_READWRITE(betadisk_status_r,betadisk_command_w) AM_MIRROR(0xff00)
332   AM_RANGE(0x003f, 0x003f) AM_READWRITE(betadisk_track_r,betadisk_track_w) AM_MIRROR(0xff00)
333   AM_RANGE(0x005f, 0x005f) AM_READWRITE(betadisk_sector_r,betadisk_sector_w) AM_MIRROR(0xff00)
334   AM_RANGE(0x007f, 0x007f) AM_READWRITE(betadisk_data_r,betadisk_data_w) AM_MIRROR(0xff00)
335   AM_RANGE(0x00fe, 0x00fe) AM_READWRITE(spectrum_port_fe_r,spectrum_port_fe_w) AM_MIRROR(0xff00) AM_MASK(0xffff)
336   AM_RANGE(0x00ff, 0x00ff) AM_READWRITE(betadisk_state_r, betadisk_param_w) AM_MIRROR(0xff00)
337   AM_RANGE(0x4000, 0x4000) AM_WRITE(scorpion_port_7ffd_w)  AM_MIRROR(0x3ffd)
338   AM_RANGE(0x8000, 0x8000) AM_WRITE(AY8910_write_port_0_w) AM_MIRROR(0x3ffd)
339   AM_RANGE(0xc000, 0xc000) AM_READWRITE(AY8910_read_port_0_r,AY8910_control_port_0_w) AM_MIRROR(0x3ffd)
340   AM_RANGE(0x1000, 0x1000) AM_WRITE(scorpion_port_1ffd_w) AM_MIRROR(0x0ffd)
420341ADDRESS_MAP_END
421342
422343
423344static MACHINE_RESET( scorpion )
424345{
346   betadisk_disable();
347   betadisk_clear_status();
348
349   memory_set_opbase_handler( 0, scorpion_opbase );
350   
425351   memset(mess_ram,0,256*1024);
426352   
427353   /* Bank 5 is always in 0x4000 - 0x7fff */
r2540r2541
434360   scorpion_256_port_1ffd_data = 0;
435361
436362   scorpion_update_memory(machine);   
363   
364   MACHINE_RESET_CALL(spectrum);
365   
366   wd17xx_reset();   
367   
368   timer_pulse(ATTOTIME_IN_HZ(50), NULL, 0, nmi_check_callback);
437369}
438370
439371static MACHINE_DRIVER_START( scorpion )
r2540r2541
461393   ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL)
462394ROM_END
463395
464
465396SYSTEM_CONFIG_EXTERN(spectrum)
466397
467398SYSTEM_CONFIG_START(scorpion)
468399   CONFIG_IMPORT_FROM(spectrum)
469400   CONFIG_RAM_DEFAULT(256 * 1024)
401   CONFIG_DEVICE(beta_floppy_getinfo)
470402SYSTEM_CONFIG_END
471403
472404/*    YEAR  NAME      PARENT    COMPAT  MACHINE     INPUT       INIT    CONFIG      COMPANY     FULLNAME */
src/mess/drivers/spectrum.c
r2540r2541
275275/* kempston joystick interface */
276276READ8_HANDLER(spectrum_port_1f_r)
277277{
278  return input_port_read(machine, "KEMPSTON") & 0x1f;
278   return input_port_read(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(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(machine, "MIKROGEN") | (0xff^0x1f);
291291}
292292
293static  READ8_HANDLER ( spectrum_port_r )
293static  READ8_HANDLER ( spectrum_port_ula_r )
294294{
295   if ((offset & 1)==0)
296      return spectrum_port_fe_r(machine, offset);
297
298   if ((offset & 0xff)==0x1f)
299      return spectrum_port_1f_r(machine, offset);
300
301   if ((offset & 0xff)==0x7f)
302      return spectrum_port_7f_r(machine, offset);
303
304   if ((offset & 0xff)==0xdf)
305      return spectrum_port_df_r(machine, offset);
306
307295   return video_screen_get_vpos(machine->primary_screen)<193 ? spectrum_colorram[(video_screen_get_vpos(machine->primary_screen)&0xf8)<<2]:0xff;
308296}
309297
310static WRITE8_HANDLER ( spectrum_port_w )
311{
312   if ((offset & 1)==0)
313      spectrum_port_fe_w(machine, offset,data);
314   else
315   {
316      logerror("Write %02x to Port: %04x\n", data, offset);
317   }
318}
319
320298/* ports are not decoded full.
321299The function decodes the ports appropriately */
322300static ADDRESS_MAP_START (spectrum_io, ADDRESS_SPACE_IO, 8)
323   AM_RANGE(0x0000, 0xffff) AM_READWRITE( spectrum_port_r, spectrum_port_w )
301   AM_RANGE(0x00, 0x00) AM_READWRITE(spectrum_port_fe_r,spectrum_port_fe_w) AM_MIRROR(0xfffe) AM_MASK(0xffff)
302   AM_RANGE(0x1f, 0x1f) AM_READ(spectrum_port_1f_r) AM_MIRROR(0xff00)
303   AM_RANGE(0x7f, 0x7f) AM_READ(spectrum_port_7f_r) AM_MIRROR(0xff00)
304   AM_RANGE(0xdf, 0xdf) AM_READ(spectrum_port_df_r) AM_MIRROR(0xff00)
305   AM_RANGE(0x01, 0x01) AM_READ(spectrum_port_ula_r) AM_MIRROR(0xfffe)
324306ADDRESS_MAP_END
325307
326308/****************************************************************************************************/
r2540r2541
442424   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("MIKROGEN JOYSTICK LEFT") PORT_CODE(JOYCODE_X_LEFT_SWITCH)
443425   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("MIKROGEN JOYSTICK FIRE") PORT_CODE(JOYCODE_BUTTON1)
444426
427   PORT_START_TAG("NMI")
428   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("NMI") PORT_CODE(KEYCODE_F12)
445429
446430   PORT_START_TAG("CONFIG") /* [16] */
447431   PORT_DIPNAME(0x80, 0x00, "Hardware Version")
r2540r2541
499483   MDRV_QUICKLOAD_ADD(spectrum, "scr", 0)
500484MACHINE_DRIVER_END
501485
502
503486/***************************************************************************
504487
505488  Game driver(s)
r2540r2541
567550   ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL)
568551ROM_END
569552
553/* Romanian clones - added by Miodrag Milanovic */
554ROM_START(jet)
555   ROM_REGION(0x10000,REGION_CPU1,0)
556   ROM_LOAD("jet.rom", 0x0000, 0x4000, CRC(E56A7D11) )
557   ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL)   
558ROM_END
570559
560ROM_START(cip03)
561   ROM_REGION(0x10000,REGION_CPU1,0)
562   ROM_LOAD("cip03.rom", 0x0000, 0x4000, CRC(C7D0CD3C) )
563   ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL)   
564ROM_END
565
566ROM_START(hc85)
567   ROM_REGION(0x10000,REGION_CPU1,0)
568   ROM_LOAD("hc85.rom", 0x0000, 0x4000, CRC(3AB60FB5) )
569   ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL)   
570ROM_END
571
572ROM_START(hc90)
573   ROM_REGION(0x10000,REGION_CPU1,0)
574   ROM_LOAD("hc90.rom", 0x0000, 0x4000, CRC(78C14D9A) )
575   ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL)   
576ROM_END
577
578ROM_START(hc91)
579   ROM_REGION(0x10000,REGION_CPU1,0)
580   ROM_LOAD("hc91.rom", 0x0000, 0x4000, CRC(8BF53761) )
581   ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL)   
582ROM_END
583
571584static void spectrum_common_cassette_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
572585{
573586   /* cassette */
r2540r2541
601614COMP( 1986, inves,    spectrum, 0,      spectrum,      spectrum,   0,      spectrum,   "Investronica",   "Inves Spectrum 48K+" , 0)
602615COMP( 1985, tk90x,    spectrum, 0,      spectrum,      spectrum,   0,      spectrum,   "Micro Digital",   "TK-90x Color Computer" , 0)
603616COMP( 1986, tk95,     spectrum, 0,      spectrum,      spectrum,   0,      spectrum,   "Micro Digital",   "TK-95 Color Computer" , 0)
617
618
619COMP( 1990, jet,      spectrum,  0,      spectrum,      spectrum,   0,      spectrum,   "Electromagnetica",   "JET" , 0)
620COMP( 1982, cip03,    spectrum,  0,      spectrum,      spectrum,   0,      spectrum,   "Electronica",   "CIP-03" , 0)
621COMP( 1985, hc85,    spectrum,  0,      spectrum,      spectrum,   0,      spectrum,   "Ice Felix",   "HC85" , 0)
622COMP( 1990, hc90,    spectrum,  0,      spectrum,      spectrum,   0,      spectrum,   "Ice Felix",   "HC90" , 0)
623COMP( 1991, hc91,    spectrum,  0,      spectrum,      spectrum,   0,      spectrum,   "Ice Felix",   "HC91" , 0)
src/mess/drivers/spec128.c
r2540r2541
226226   logerror("rom switch: %02x\n", ROMSelection);
227227}
228228
229
230
231WRITE8_HANDLER(spectrum_128_port_bffd_w)
229static  READ8_HANDLER ( spectrum_128_ula_r )
232230{
233   AY8910_write_port_0_w(machine, 0, data);
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;
234232}
235233
236WRITE8_HANDLER(spectrum_128_port_fffd_w)
237{
238   AY8910_control_port_0_w(machine, 0, data);
239}
240
241READ8_HANDLER(spectrum_128_port_fffd_r)
242{
243   return AY8910_read_port_0_r(machine, 0);
244}
245
246static  READ8_HANDLER ( spectrum_128_port_r )
247{
248    if ((offset & 1)==0)
249    {
250       return spectrum_port_fe_r(machine, offset);
251    }
252
253    if ((offset & 2)==0)
254    {
255      switch ((offset>>14) & 0x03)
256      {
257         default:
258            break;
259
260         case 3:
261            return spectrum_128_port_fffd_r(machine, offset);
262      }
263    }
264
265    /* don't think these are correct! */
266    if ((offset & 0xff)==0x1f)
267       return spectrum_port_1f_r(machine, offset);
268
269    if ((offset & 0xff)==0x7f)
270       return spectrum_port_7f_r(machine, offset);
271
272    if ((offset & 0xff)==0xdf)
273       return spectrum_port_df_r(machine, offset);
274
275    return video_screen_get_vpos(machine->primary_screen)<193 ? spectrum_128_screen_location[0x1800|(video_screen_get_vpos(machine->primary_screen)&0xf8)<<2]:0xff;
276}
277
278static WRITE8_HANDLER ( spectrum_128_port_w )
279{
280      if ((offset & 1)==0)
281            spectrum_port_fe_w(machine, offset,data);
282
283      /* Only decodes on A15, A14 & A1 */
284      else if ((offset & 2)==0)
285      {
286            switch ((offset>>8) & 0xc0)
287            {
288                  case 0x40:
289                        spectrum_128_port_7ffd_w(machine, offset, data);
290                        break;
291                  case 0x80:
292                        spectrum_128_port_bffd_w(machine, offset, data);
293                        break;
294                  case 0xc0:
295                        spectrum_128_port_fffd_w(machine, offset, data);
296                        break;
297                  default:
298                        logerror("Write %02x to 128 port: %04x\n", data, offset);
299            }
300      }
301      else
302      {
303         logerror("Write %02x to 128 port: %04x\n", data, offset);
304      }
305}
306
307/* ports are not decoded full.
308The function decodes the ports appropriately */
309234static ADDRESS_MAP_START (spectrum_128_io, ADDRESS_SPACE_IO, 8)
310   AM_RANGE(0x0000, 0xffff) AM_READWRITE( spectrum_128_port_r, spectrum_128_port_w )
235   AM_RANGE(0x0000, 0x0000) AM_READWRITE(spectrum_port_fe_r,spectrum_port_fe_w) AM_MIRROR(0xfffe) AM_MASK(0xffff)
236   AM_RANGE(0x001f, 0x001f) AM_READ(spectrum_port_1f_r) AM_MIRROR(0xff00)
237   AM_RANGE(0x007f, 0x007f) AM_READ(spectrum_port_7f_r) AM_MIRROR(0xff00)
238   AM_RANGE(0x00df, 0x00df) AM_READ(spectrum_port_df_r) AM_MIRROR(0xff00)
239   AM_RANGE(0x4000, 0x4000) AM_WRITE(spectrum_128_port_7ffd_w) AM_MIRROR(0x3ffd)
240   AM_RANGE(0x8000, 0x8000) AM_WRITE(AY8910_write_port_0_w) AM_MIRROR(0x3ffd)
241   AM_RANGE(0xc000, 0xc000) AM_READWRITE(AY8910_read_port_0_r,AY8910_control_port_0_w) AM_MIRROR(0x3ffd)
242   AM_RANGE(0x0001, 0x0001) AM_READ(spectrum_128_ula_r) AM_MIRROR(0xfffe)   
311243ADDRESS_MAP_END
312244
313245static ADDRESS_MAP_START (spectrum_128_mem, ADDRESS_SPACE_PROGRAM, 8)
r2540r2541
413345   ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL)
414346ROM_END
415347
348ROM_START(hc128)
349   ROM_REGION(0x18000,REGION_CPU1,0)
350   ROM_LOAD("zx128_0.rom",0x10000,0x4000, CRC(e76799d2) SHA1(4f4b11ec22326280bdb96e3baf9db4b4cb1d02c5))
351   ROM_LOAD("hc128.rom",  0x14000, 0x4000, CRC(0241E960) )
352   ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL)   
353ROM_END
416354SYSTEM_CONFIG_START(spec128)
417355   CONFIG_IMPORT_FROM(spectrum)
418356   CONFIG_RAM_DEFAULT(128 * 1024)
r2540r2541
425363COMP( 1986, specpls2, spec128,  0,      spectrum_128,   spectrum,   0,      spec128,   "Amstrad plc",          "ZX Spectrum +2" , 0 )
426364COMP( 1986, specp2fr, spec128,  0,      spectrum_128,   spectrum,   0,      spec128,   "Amstrad plc",          "ZX Spectrum +2 (France)" , 0 )
427365COMP( 1986, specp2sp, spec128,  0,      spectrum_128,   spectrum,   0,      spec128,   "Amstrad plc",          "ZX Spectrum +2 (Spain)" , 0 )
366COMP( 1992, hc128,     spec128,  0,      spectrum_128,   spectrum,   0,      spec128,   "Ice Felix",         "HC128" , 0)
src/mess/drivers/timex.c
r2540r2541
172172      ts2068_update_memory(machine);
173173}
174174
175static WRITE8_HANDLER(ts2068_port_f5_w)
176{
177      AY8910_control_port_0_w(machine, 0, data);
178}
179
180static  READ8_HANDLER(ts2068_port_f6_r)
181{
182      /* TODO - Reading from register 14 reads the joystick ports
183           set bit 8 of address to read joystick #1
184           set bit 9 of address to read joystick #2
185           if both bits are set then OR values
186           Bit 0 up, 1 down, 2 left, 3 right, 7 fire active low. Other bits 1
187        */
188      return AY8910_read_port_0_r(machine, 0);
189}
190
191static WRITE8_HANDLER(ts2068_port_f6_w)
192{
193      AY8910_write_port_0_w(machine, 0, data);
194}
195
196175static  READ8_HANDLER(ts2068_port_ff_r)
197176{
198177      return ts2068_port_ff_data;
r2540r2541
211190      logerror("Port %04x write %02x\n", offset, data);
212191}
213192
214
215static READ8_HANDLER ( ts2068_port_r )
216{
217   switch (offset & 0xff)
218   {
219      /* Note: keys only decoded on port #fe not all even ports so
220           ports #f4 & #f6 correctly read */
221      case 0xf4: return ts2068_port_f4_r(machine, offset);
222      case 0xf6: return ts2068_port_f6_r(machine, offset);
223      case 0xff: return ts2068_port_ff_r(machine, offset);
224
225      case 0xfe: return spectrum_port_fe_r(machine, offset);
226      case 0x1f: return spectrum_port_1f_r(machine, offset);
227      case 0x7f: return spectrum_port_7f_r(machine, offset);
228      case 0xdf: return spectrum_port_df_r(machine, offset);
229   }
230   logerror("Read from port: %04x\n", offset);
231
232   return 0xff;
233}
234
235static WRITE8_HANDLER ( ts2068_port_w )
236{
237/* Ports #fd & #fc were reserved by Timex for bankswitching and are not used
238   by either the hardware or system software.
239   Port #fb is the Thermal printer port and works exactly as the Sinclair
240   Printer - ie not yet emulated.
241*/
242   switch (offset & 0xff)
243   {
244      case 0xfe: spectrum_port_fe_w(machine, offset,data); break;
245      case 0xf4: ts2068_port_f4_w(machine, offset,data); break;
246      case 0xf5: ts2068_port_f5_w(machine, offset,data); break;
247      case 0xf6: ts2068_port_f6_w(machine, offset,data); break;
248      case 0xff: ts2068_port_ff_w(machine, offset,data); break;
249      default:
250            logerror("Write %02x to Port: %04x\n", data, offset);
251   }
252}
253
254
255
256193/*******************************************************************
257194 *
258195 *      Bank switch between the 3 internal memory banks HOME, EXROM
r2540r2541
594531   memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe000, 0xffff, 0, 0, wh);
595532}
596533
597
598static ADDRESS_MAP_START (ts2068_io, ADDRESS_SPACE_IO, 8)
599   AM_RANGE(0x0000, 0xffff) AM_READWRITE( ts2068_port_r, ts2068_port_w )
534static ADDRESS_MAP_START (ts2068_io, ADDRESS_SPACE_IO, 8)   
535   AM_RANGE(0x1f, 0x1f ) AM_READ( spectrum_port_1f_r ) AM_MIRROR(0xff00)
536   AM_RANGE(0x7f, 0x7f ) AM_READ( spectrum_port_7f_r ) AM_MIRROR(0xff00)
537   AM_RANGE(0xdf, 0xdf ) AM_READ( spectrum_port_df_r ) AM_MIRROR(0xff00)
538   AM_RANGE(0xf4, 0xf4 ) AM_READWRITE( ts2068_port_f4_r,ts2068_port_f4_w ) AM_MIRROR(0xff00)
539   AM_RANGE(0xf5, 0xf5 ) AM_WRITE( AY8910_control_port_0_w ) AM_MIRROR(0xff00)
540   AM_RANGE(0xf6, 0xf6 ) AM_READWRITE( AY8910_read_port_0_r,AY8910_write_port_0_w ) AM_MIRROR(0xff00)
541   AM_RANGE(0xfe, 0xfe ) AM_READWRITE( spectrum_port_fe_r,spectrum_port_fe_w )  AM_MIRROR(0xff00)  AM_MASK(0xffff)
542   AM_RANGE(0xff, 0xff ) AM_READWRITE( ts2068_port_ff_r,ts2068_port_ff_w ) AM_MIRROR(0xff00)
600543ADDRESS_MAP_END
601544
602545static ADDRESS_MAP_START (ts2068_mem, ADDRESS_SPACE_PROGRAM, 8)
r2540r2541
625568/* TC2048 specific functions */
626569
627570
628static void tc2048_port_ff_w(int offset, int data)
571static WRITE8_HANDLER (tc2048_port_ff_w)
629572{
630573      ts2068_port_ff_data = data;
631574      logerror("Port %04x write %02x\n", offset, data);
632575}
633576
634static  READ8_HANDLER ( tc2048_port_r )
635{
636      if ((offset & 1)==0)
637            return spectrum_port_fe_r(machine, offset);
638      switch (offset & 0xff)
639      {
640            case 0xff: return ts2068_port_ff_r(machine, offset);
641            case 0x1f: return spectrum_port_1f_r(machine, offset);
642            case 0x7f: return spectrum_port_7f_r(machine, offset);
643            case 0xdf: return spectrum_port_df_r(machine, offset);
644      }
645
646      logerror("Read from port: %04x\n", offset);
647      return 0xff;
648}
649
650static WRITE8_HANDLER ( tc2048_port_w )
651{
652      if ((offset & 1)==0)
653            spectrum_port_fe_w(machine, offset,data);
654      else if ((offset & 0xff)==0xff)
655            tc2048_port_ff_w(offset, data);
656      else
657      {
658            logerror("Write %02x to Port: %04x\n", data, offset);
659      }
660}
661
662/* ports are not decoded full.
663The function decodes the ports appropriately */
664577static ADDRESS_MAP_START (tc2048_io, ADDRESS_SPACE_IO, 8)
665   AM_RANGE(0x0000, 0xffff) AM_READWRITE( tc2048_port_r, tc2048_port_w )
578   AM_RANGE(0x00, 0x00) AM_READWRITE(spectrum_port_fe_r,spectrum_port_fe_w) AM_MIRROR(0xfffe) AM_MASK(0xffff)
579   AM_RANGE(0x1f, 0x1f) AM_READ(spectrum_port_1f_r) AM_MIRROR(0xff00)
580   AM_RANGE(0x7f, 0x7f) AM_READ(spectrum_port_7f_r) AM_MIRROR(0xff00)
581   AM_RANGE(0xdf, 0xdf) AM_READ(spectrum_port_df_r) AM_MIRROR(0xff00)
582   AM_RANGE(0xff, 0xff) AM_READWRITE(ts2068_port_ff_r,tc2048_port_ff_w)  AM_MIRROR(0xff00)   
666583ADDRESS_MAP_END
667584
668585static ADDRESS_MAP_START (tc2048_mem, ADDRESS_SPACE_PROGRAM, 8)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team