Previous 15994 Revisions Next

r9153 Friday 17th September, 2010 at 07:02:04 UTC by Miodrag Milanović
Sync with MAME, some drivers commented (pcw16, avigo and gba)
[src/emu]devintrf.c devintrf.h timer.c timer.h
[src/emu/machine]6522via.c 6522via.h 8257dma.c 8257dma.h intelfsh.c intelfsh.h mc146818.c mc146818.h
[src/mess]mess.mak messdriv.c
[src/mess/drivers]bebox.c pcw16.c
[src/mess/includes]bebox.h
[src/mess/machine]bebox.c

src/emu/devintrf.c
r9152r9153
873873//  fires
874874//-------------------------------------------------
875875
876void device_t::device_timer(emu_timer &timer, int param, void *ptr)
876void device_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
877877{
878878   // do nothing by default
879879}
src/emu/devintrf.h
r9152r9153
137137typedef device_config *(*device_type)(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
138138
139139
140// timer IDs for devices
141typedef UINT32 device_timer_id;
142
143
140144// read/write types for I/O lines (similar to read/write handlers but no offset)
141145typedef int (*read_line_device_func)(device_t *device);
142146typedef void (*write_line_device_func)(device_t *device, int state);
r9152r9153
425429   void set_clock_scale(double clockscale);
426430   attotime clocks_to_attotime(UINT64 clocks) const;
427431   UINT64 attotime_to_clocks(attotime duration) const;
428   void timer_fired(emu_timer &timer, int param, void *ptr) { device_timer(timer, param, ptr); }
432   void timer_fired(emu_timer &timer, device_timer_id id, int param, void *ptr) { device_timer(timer, id, param, ptr); }
429433
430434   // debugging
431435   device_debug *debug() const { return m_debug; }
r9152r9153
460464   virtual void device_post_load();
461465   virtual void device_clock_changed();
462466   virtual void device_debug_setup();
463   virtual void device_timer(emu_timer &timer, int param, void *ptr);
467   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
464468
465469   //------------------- end derived class overrides
466470
src/emu/machine/mc146818.h
r9152r9153
8282protected:
8383   // device-level overrides
8484   virtual void device_start();
85   virtual void device_timer(emu_timer &timer, int param, void *ptr);
85   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
8686
8787   // device_mc146818_interface overrides
8888   virtual void nvram_default();
src/emu/machine/6522via.c
r9152r9153
218218    m_t2ll = 0xff; /* taken from vice */
219219    m_t2lh = 0xff;
220220    m_time2 = m_time1 = timer_get_time(&m_machine);
221    m_t1 = device_timer_alloc(*this);
222    m_t2 = device_timer_alloc(*this);
223    m_shift_timer = device_timer_alloc(*this);
221    m_t1 = device_timer_alloc(*this, TIMER_T1);
222    m_t2 = device_timer_alloc(*this, TIMER_T2);
223    m_shift_timer = device_timer_alloc(*this, TIMER_SHIFT);
224224
225225   /* Default clock is from CPU1 */
226226   if (clock() == 0)
r9152r9153
415415}
416416
417417
418void via6522_device::device_timer(emu_timer &timer, int param, void *ptr)
418void via6522_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
419419{
420   // shift timer
421   if (&timer == m_shift_timer)
422      shift();
423   
424   // t1 timeout
425   else if (&timer == m_t1)
420   switch (id)
426421   {
427       if (T1_CONTINUOUS (m_acr))
428       {
429           if (T1_SET_PB7(m_acr))
430           {
431               m_out_b ^= 0x80;
432           }
433           timer_adjust_oneshot(m_t1, cycles_to_time(TIMER1_VALUE + IFR_DELAY), 0);
434       }
435      else
436       {
437           if (T1_SET_PB7(m_acr))
438           {
439               m_out_b |= 0x80;
440           }
441           m_t1_active = 0;
442           m_time1 = timer_get_time(&m_machine);
443       }
444       if (m_ddr_b)
445      {
446           UINT8 write_data = (m_out_b & m_ddr_b) | (m_ddr_b ^ 0xff);
447           devcb_call_write8(&m_out_b_func, 0, write_data);
448      }
422      // shift timer
423      case TIMER_SHIFT:
424         shift();
425         break;
426         
427      // t1 timeout
428      case TIMER_T1:
429          if (T1_CONTINUOUS (m_acr))
430          {
431              if (T1_SET_PB7(m_acr))
432              {
433                  m_out_b ^= 0x80;
434              }
435              timer_adjust_oneshot(m_t1, cycles_to_time(TIMER1_VALUE + IFR_DELAY), 0);
436          }
437         else
438          {
439              if (T1_SET_PB7(m_acr))
440              {
441                  m_out_b |= 0x80;
442              }
443              m_t1_active = 0;
444              m_time1 = timer_get_time(&m_machine);
445          }
446          if (m_ddr_b)
447         {
448              UINT8 write_data = (m_out_b & m_ddr_b) | (m_ddr_b ^ 0xff);
449              devcb_call_write8(&m_out_b_func, 0, write_data);
450         }
449451
450       if (!(m_ifr & INT_T1))
451       {
452         set_int(INT_T1);
453       }
454   }
455   
456   // t2 timeout
457   else if (&timer == m_t2)
458   {
459       m_t2_active = 0;
460       m_time2 = timer_get_time(&m_machine);
452          if (!(m_ifr & INT_T1))
453          {
454            set_int(INT_T1);
455          }
456          break;
457         
458      // t2 timeout
459      case TIMER_T2:
460          m_t2_active = 0;
461          m_time2 = timer_get_time(&m_machine);
461462
462       if (!(m_ifr & INT_T2))
463       {
464         set_int(INT_T2);
465       }
463          if (!(m_ifr & INT_T2))
464          {
465            set_int(INT_T2);
466          }
467          break;
466468   }
467469}
468470
src/emu/machine/6522via.h
r9152r9153
133133    // device-level overrides
134134    virtual void device_start();
135135    virtual void device_reset();
136   virtual void device_timer(emu_timer &timer, int param, void *ptr);
136   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
137137
138138private:
139   static const device_timer_id TIMER_SHIFT = 0;
140   static const device_timer_id TIMER_T1 = 1;
141   static const device_timer_id TIMER_T2 = 2;
142
139143    attotime cycles_to_time(int c);
140144    UINT32 time_to_cycles(attotime t);
141145    UINT16 get_counter1_value();
src/emu/machine/8257dma.c
r9152r9153
101101
102102i8257_device::i8257_device(running_machine &_machine, const i8257_device_config &config)
103103    : device_t(_machine, config),
104      m_mode(0),
105      m_rr(0),
106      m_msb(0),
107      m_drq(0),
108      m_status(0x0f),
104109      m_config(config)
105110{
106
111   memset(m_registers, 0, sizeof(m_registers));
112   memset(m_address, 0, sizeof(m_address));
113   memset(m_count, 0, sizeof(m_count));
114   memset(m_rwmode, 0, sizeof(m_rwmode));
107115}
108116
109117//-------------------------------------------------
r9152r9153
129137   }
130138
131139   /* set initial values */
132   m_status = 0x0f;
133   m_timer = timer_alloc(&m_machine, i8257_timerproc_callback, (void *) this);
134   m_msbflip_timer = timer_alloc(&m_machine, i8257_msbflip_timerproc_callback, (void *) this);
140   m_timer = device_timer_alloc(*this, TIMER_OPERATION);
141   m_msbflip_timer = device_timer_alloc(*this, TIMER_MSBFLIP);
135142
136143   /* register for state saving */
137144   state_save_register_device_item_array(this, 0, m_address);
r9152r9153
243250}
244251
245252
246TIMER_CALLBACK( i8257_device::i8257_timerproc_callback )
253void i8257_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
247254{
248   reinterpret_cast<i8257_device*>(ptr)->i8257_timerproc();
249}
250
251void i8257_device::i8257_timerproc()
252{
253   int i, channel = 0, rr;
254   int done;
255
256   rr = DMA_MODE_ROTPRIO(m_mode) ? m_rr : 0;
257   for (i = 0; i < I8257_NUM_CHANNELS; i++)
255   switch (id)
258256   {
259      channel = (i + rr) % I8257_NUM_CHANNELS;
260      if ((m_status & (1 << channel)) == 0)
257      case TIMER_OPERATION:
261258      {
262         if (m_mode & m_drq & (1 << channel))
259         int i, channel = 0, rr;
260         int done;
261
262         rr = DMA_MODE_ROTPRIO(m_mode) ? m_rr : 0;
263         for (i = 0; i < I8257_NUM_CHANNELS; i++)
263264         {
264            break;
265            channel = (i + rr) % I8257_NUM_CHANNELS;
266            if ((m_status & (1 << channel)) == 0)
267            {
268               if (m_mode & m_drq & (1 << channel))
269               {
270                  break;
271               }
272            }
265273         }
266      }
267   }
268   done = i8257_do_operation(channel);
274         done = i8257_do_operation(channel);
269275
270   m_rr = (channel + 1) & 0x03;
276         m_rr = (channel + 1) & 0x03;
271277
272   if (done)
273   {
274      m_drq &= ~(0x01 << channel);
275      i8257_update_status();
276      if (!(DMA_MODE_AUTOLOAD(m_mode) && channel==2))
278         if (done)
279         {
280            m_drq &= ~(0x01 << channel);
281            i8257_update_status();
282            if (!(DMA_MODE_AUTOLOAD(m_mode) && channel==2))
283            {
284               if (DMA_MODE_TCSTOP(m_mode))
285               {
286                  m_mode &= ~(0x01 << channel);
287               }
288            }
289         }
290         break;
291      }
292   
293      case TIMER_MSBFLIP:
294         m_msb ^= 1;
295         break;
296     
297      case TIMER_DRQ_SYNC:
277298      {
278         if (DMA_MODE_TCSTOP(m_mode))
299         int channel = param >> 1;
300         int state = param & 0x01;
301
302         /* normalize state */
303         if (state)
279304         {
280            m_mode &= ~(0x01 << channel);
305            m_drq |= 0x01 << channel;
306            m_address[channel] =  m_registers[channel * 2];
307            m_count[channel] =  m_registers[channel * 2 + 1] & 0x3FFF;
308            m_rwmode[channel] =  m_registers[channel * 2 + 1] >> 14;
309            /* clear channel TC */
310            m_status &= ~(0x01 << channel);
281311         }
312         else
313            m_drq &= ~(0x01 << channel);
314
315         i8257_update_status();
316         break;
282317      }
283318   }
284319}
285320
286321
287TIMER_CALLBACK( i8257_device::i8257_msbflip_timerproc_callback )
288{
289   reinterpret_cast<i8257_device*>(ptr)->i8257_msbflip_timerproc();
290}
291
292void i8257_device::i8257_msbflip_timerproc()
293{
294   m_msb ^= 1;
295}
296
297
298322void i8257_device::i8257_update_status()
299323{
300324   UINT16 pending_transfer;
r9152r9153
421445}
422446
423447
424TIMER_CALLBACK( i8257_device::i8257_drq_write_callback )
425{
426   reinterpret_cast<i8257_device*>(ptr)->i8257_drq_write_timerproc(param);
427}
428
429void i8257_device::i8257_drq_write_timerproc(INT32 param)
430{
431   int channel = param >> 1;
432   int state = param & 0x01;
433
434   /* normalize state */
435   if (state)
436   {
437      m_drq |= 0x01 << channel;
438      m_address[channel] =  m_registers[channel * 2];
439      m_count[channel] =  m_registers[channel * 2 + 1] & 0x3FFF;
440      m_rwmode[channel] =  m_registers[channel * 2 + 1] >> 14;
441      /* clear channel TC */
442      m_status &= ~(0x01 << channel);
443   }
444   else
445      m_drq &= ~(0x01 << channel);
446
447   i8257_update_status();
448}
449
450448void i8257_device::i8257_drq_w(int channel, int state)
451449{
452450   int param = (channel << 1) | (state ? 1 : 0);
453451
454   timer_call_after_resynch(&m_machine, (void *)this, param, i8257_drq_write_callback);
452   device_timer_call_after_resynch(*this, TIMER_DRQ_SYNC, param);
455453}
456454
457455WRITE_LINE_DEVICE_HANDLER( i8257_hlda_w ) { }
src/emu/machine/8257dma.h
r9152r9153
117117   /* data request */
118118   void i8257_drq_w(int channel, int state);
119119
120   void i8257_timerproc();
121   void i8257_msbflip_timerproc();
122   void i8257_drq_write_timerproc(INT32 param);
123
124120protected:
125121    // device-level overrides
126122    virtual void device_start();
127123    virtual void device_reset();
128    virtual void device_post_load() { }
129    virtual void device_clock_changed() { }
124   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
130125
131   static TIMER_CALLBACK( i8257_timerproc_callback );
132   static TIMER_CALLBACK( i8257_msbflip_timerproc_callback );
133   static TIMER_CALLBACK( i8257_drq_write_callback );
134
135126private:
127   static const device_timer_id TIMER_OPERATION = 0;
128   static const device_timer_id TIMER_MSBFLIP = 1;
129   static const device_timer_id TIMER_DRQ_SYNC = 2;
136130
137131   int i8257_do_operation(int channel);
138132   void i8257_update_status();
src/emu/machine/intelfsh.c
r9152r9153
1414#include "emu.h"
1515#include "intelfsh.h"
1616
17
18//**************************************************************************
19//  CONSTANTS
20//**************************************************************************
21
1722enum
1823{
1924   FM_NORMAL,   // normal read/write
r9152r9153
3237   FM_BYTEPROGRAM,
3338};
3439
35struct flash_chip
36{
37   int type;
38   int size;
39   int bits;
40   int status;
41   int erase_sector;
42   int sector_is_4k;
43   INT32 flash_mode;
44   INT32 flash_master_lock;
45   int device_id;
46   int maker_id;
47   emu_timer *timer;
48   void *flash_memory;
49};
5040
51static struct flash_chip chips[FLASH_CHIPS_MAX];
5241
53static TIMER_CALLBACK( erase_finished )
54{
55   struct flash_chip *c = (struct flash_chip *)ptr;
42//**************************************************************************
43//  DEVICE DEFINITIONS
44//**************************************************************************
5645
57   switch( c->flash_mode )
58   {
59   case FM_READSTATUS:
60      c->status = 0x80;
61      break;
46// 8-bit variants
47DEFINE_TRIVIAL_DERIVED_DEVICE(intel_28f016s5_device_config, intelfsh8_device_config, intel_28f016s5_device, intelfsh8_device, "Sharp LH28F400 Flash", intelfsh_device_config::FLASH_SHARP_LH28F400)
48DEFINE_TRIVIAL_DERIVED_DEVICE(fujitsu_29f016a_device_config, intelfsh8_device_config, fujitsu_29f016a_device, intelfsh8_device, "Fujitsu 29F016A Flash", intelfsh_device_config::FLASH_FUJITSU_29F016A)
49DEFINE_TRIVIAL_DERIVED_DEVICE(sharp_lh28f016s_device_config, intelfsh8_device_config, sharp_lh28f016s_device, intelfsh8_device, "Sharp LH28F016S Flash", intelfsh_device_config::FLASH_SHARP_LH28F016S)
50DEFINE_TRIVIAL_DERIVED_DEVICE(intel_e28f008sa_device_config, intelfsh8_device_config, intel_e28f008sa_device, intelfsh8_device, "Intel E28F008SA Flash", intelfsh_device_config::FLASH_INTEL_E28F008SA)
51DEFINE_TRIVIAL_DERIVED_DEVICE(macronix_29l001mc_device_config, intelfsh8_device_config, macronix_29l001mc_device, intelfsh8_device, "Macronix 29L001MC Flash", intelfsh_device_config::FLASH_MACRONIX_29L001MC)
52DEFINE_TRIVIAL_DERIVED_DEVICE(panasonic_mn63f805mnp_device_config, intelfsh8_device_config, panasonic_mn63f805mnp_device, intelfsh8_device, "Panasonic MN63F805MNP Flash", intelfsh_device_config::FLASH_PANASONIC_MN63F805MNP)
53DEFINE_TRIVIAL_DERIVED_DEVICE(sanyo_le26fv10n1ts_device_config, intelfsh8_device_config, sanyo_le26fv10n1ts_device, intelfsh8_device, "Sanyo LE26FV10N1TS Flash", intelfsh_device_config::FLASH_SANYO_LE26FV10N1TS)
6254
63   case FM_ERASEAMD4:
64      c->flash_mode = FM_NORMAL;
65      break;
66   }
67}
55const device_type INTEL_28F016S5 = intel_28f016s5_device_config::static_alloc_device_config;
56const device_type SHARP_LH28F016S = sharp_lh28f016s_device_config::static_alloc_device_config;
57const device_type FUJITSU_29F016A = fujitsu_29f016a_device_config::static_alloc_device_config;
58const device_type INTEL_E28F008SA = intel_e28f008sa_device_config::static_alloc_device_config;
59const device_type MACRONIX_29L001MC = macronix_29l001mc_device_config::static_alloc_device_config;
60const device_type PANASONIC_MN63F805MNP = panasonic_mn63f805mnp_device_config::static_alloc_device_config;
61const device_type SANYO_LE26FV10N1TS = sanyo_le26fv10n1ts_device_config::static_alloc_device_config;
6862
69void* intelflash_getmemptr(int chip)
70{
71   struct flash_chip *c;
72   if( chip >= FLASH_CHIPS_MAX )
73   {
74      logerror( "intelflash_init: invalid chip %d\n", chip );
75      return 0;
76   }
77   c = &chips[ chip ];
7863
79   return c->flash_memory;
80}
64// 16-bit variants
65DEFINE_TRIVIAL_DERIVED_DEVICE(sharp_lh28f400_device_config, intelfsh16_device_config, sharp_lh28f400_device, intelfsh16_device, "Sharp LH28F400 Flash", intelfsh_device_config::FLASH_SHARP_LH28F400)
66DEFINE_TRIVIAL_DERIVED_DEVICE(intel_te28f160_device_config, intelfsh16_device_config, intel_te28f160_device, intelfsh16_device, "Intel TE28F160 Flash", intelfsh_device_config::FLASH_INTEL_TE28F160)
67DEFINE_TRIVIAL_DERIVED_DEVICE(intel_e28f400_device_config, intelfsh16_device_config, intel_e28f400_device, intelfsh16_device, "Intel E28F400 Flash", intelfsh_device_config::FLASH_INTEL_E28F400)
68DEFINE_TRIVIAL_DERIVED_DEVICE(sharp_unk128mbit_device_config, intelfsh16_device_config, sharp_unk128mbit_device, intelfsh16_device, "Sharp Unknown 128Mb Flash", intelfsh_device_config::FLASH_SHARP_UNK128MBIT)
8169
82void intelflash_init(running_machine *machine, int chip, int type, void *data)
70const device_type SHARP_LH28F400 = sharp_lh28f400_device_config::static_alloc_device_config;
71const device_type INTEL_TE28F160 = intel_te28f160_device_config::static_alloc_device_config;
72const device_type INTEL_E28F400 = intel_e28f400_device_config::static_alloc_device_config;
73const device_type SHARP_UNK128MBIT = sharp_unk128mbit_device_config::static_alloc_device_config;
74
75
76
77//**************************************************************************
78//  GLOBAL VARIABLES
79//**************************************************************************
80
81static ADDRESS_MAP_START( memory_map8_512Kb, ADDRESS_SPACE_PROGRAM, 8 )
82   AM_RANGE(0x00000, 0x00ffff) AM_RAM
83ADDRESS_MAP_END
84
85static ADDRESS_MAP_START( memory_map8_1Mb, ADDRESS_SPACE_PROGRAM, 8 )
86   AM_RANGE(0x00000, 0x01ffff) AM_RAM
87ADDRESS_MAP_END
88
89static ADDRESS_MAP_START( memory_map8_8Mb, ADDRESS_SPACE_PROGRAM, 8 )
90   AM_RANGE(0x00000, 0x0fffff) AM_RAM
91ADDRESS_MAP_END
92
93static ADDRESS_MAP_START( memory_map8_16Mb, ADDRESS_SPACE_PROGRAM, 8 )
94   AM_RANGE(0x00000, 0x1fffff) AM_RAM
95ADDRESS_MAP_END
96
97
98static ADDRESS_MAP_START( memory_map16_4Mb, ADDRESS_SPACE_PROGRAM, 16 )
99   AM_RANGE(0x00000, 0x07ffff) AM_RAM
100ADDRESS_MAP_END
101
102static ADDRESS_MAP_START( memory_map16_16Mb, ADDRESS_SPACE_PROGRAM, 16 )
103   AM_RANGE(0x00000, 0x1fffff) AM_RAM
104ADDRESS_MAP_END
105
106static ADDRESS_MAP_START( memory_map16_64Mb, ADDRESS_SPACE_PROGRAM, 16 )
107   AM_RANGE(0x00000, 0x7fffff) AM_RAM
108ADDRESS_MAP_END
109
110
111
112//**************************************************************************
113//  DEVICE CONFIGURATION
114//**************************************************************************
115
116//-------------------------------------------------
117//  intelfsh_device_config - constructor
118//-------------------------------------------------
119
120intelfsh_device_config::intelfsh_device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock, UINT32 variant)
121   : device_config(mconfig, type, name, tag, owner, clock),
122     device_config_memory_interface(mconfig, *this),
123     device_config_nvram_interface(mconfig, *this),
124     m_type(variant),
125     m_size(0),
126     m_bits(8),
127     m_device_id(0),
128     m_maker_id(0),
129     m_sector_is_4k(false)
83130{
84   struct flash_chip *c;
85   if( chip >= FLASH_CHIPS_MAX )
86   {
87      logerror( "intelflash_init: invalid chip %d\n", chip );
88      return;
89   }
90   c = &chips[ chip ];
131   address_map_constructor map = NULL;
91132
92   c->type = type;
93   c->sector_is_4k = 0;
94   switch( c->type )
133   switch( variant )
95134   {
96135   case FLASH_INTEL_28F016S5:
97136   case FLASH_SHARP_LH28F016S:
98      c->bits = 8;
99      c->size = 0x200000;
100      c->maker_id = 0x89;
101      c->device_id = 0xaa;
137      m_bits = 8;
138      m_size = 0x200000;
139      m_maker_id = 0x89;
140      m_device_id = 0xaa;
141      map = ADDRESS_MAP_NAME( memory_map8_16Mb );
102142      break;
103143   case FLASH_SHARP_LH28F400:
104144   case FLASH_INTEL_E28F400:
105      c->bits = 16;
106      c->size = 0x80000;
107      c->maker_id = 0xb0;
108      c->device_id = 0xed;
145      m_bits = 16;
146      m_size = 0x80000;
147      m_maker_id = 0xb0;
148      m_device_id = 0xed;
149      map = ADDRESS_MAP_NAME( memory_map16_4Mb );
109150      break;
110151   case FLASH_FUJITSU_29F016A:
111      c->bits = 8;
112      c->size = 0x200000;
113      c->maker_id = 0x04;
114      c->device_id = 0xad;
152      m_bits = 8;
153      m_size = 0x200000;
154      m_maker_id = 0x04;
155      m_device_id = 0xad;
156      map = ADDRESS_MAP_NAME( memory_map8_16Mb );
115157      break;
116158   case FLASH_INTEL_E28F008SA:
117      c->bits = 8;
118      c->size = 0x100000;
119      c->maker_id = 0x89;
120      c->device_id = 0xa2;
159      m_bits = 8;
160      m_size = 0x100000;
161      m_maker_id = 0x89;
162      m_device_id = 0xa2;
163      map = ADDRESS_MAP_NAME( memory_map8_8Mb );
121164      break;
122165   case FLASH_INTEL_TE28F160:
123      c->bits = 16;
124      c->size = 0x200000;
125      c->maker_id = 0xb0;
126      c->device_id = 0xd0;
166      m_bits = 16;
167      m_size = 0x200000;
168      m_maker_id = 0xb0;
169      m_device_id = 0xd0;
170      map = ADDRESS_MAP_NAME( memory_map16_16Mb );
127171      break;
128172   case FLASH_SHARP_UNK128MBIT:
129      c->bits = 16;
130      c->size = 0x800000;
131      c->maker_id = 0xb0;
132      c->device_id = 0xb0;
173      m_bits = 16;
174      m_size = 0x800000;
175      m_maker_id = 0xb0;
176      m_device_id = 0xb0;
177      map = ADDRESS_MAP_NAME( memory_map16_64Mb );
133178      break;
134179   case FLASH_MACRONIX_29L001MC:
135      c->bits = 8;
136      c->size = 0x20000;
137      c->maker_id = 0xc2;
138      c->device_id = 0x51;
180      m_bits = 8;
181      m_size = 0x20000;
182      m_maker_id = 0xc2;
183      m_device_id = 0x51;
184      map = ADDRESS_MAP_NAME( memory_map8_1Mb );
139185      break;
140
141186   case FLASH_PANASONIC_MN63F805MNP:
142      c->bits = 8;
143      c->size = 0x10000;
144      c->maker_id = 0x32;
145      c->device_id = 0x1b;
146      c->sector_is_4k = 1;
187      m_bits = 8;
188      m_size = 0x10000;
189      m_maker_id = 0x32;
190      m_device_id = 0x1b;
191      m_sector_is_4k = true;
192      map = ADDRESS_MAP_NAME( memory_map8_512Kb );
147193      break;
148
149194   case FLASH_SANYO_LE26FV10N1TS:
150      c->bits = 8;
151      c->size = 0x20000;
152      c->maker_id = 0x62;
153      c->device_id = 0x13;
154      c->sector_is_4k = 1;
195      m_bits = 8;
196      m_size = 0x20000;
197      m_maker_id = 0x62;
198      m_device_id = 0x13;
199      m_sector_is_4k = true;
200      map = ADDRESS_MAP_NAME( memory_map8_1Mb );
155201      break;
156202   }
157   if( data == NULL )
203   
204   int addrbits;
205   for (addrbits = 24; addrbits > 0; addrbits--)
206      if ((m_size & (1 << addrbits)) != 0)
207         break;
208
209   m_space_config = address_space_config("flash", ENDIANNESS_BIG, m_bits, addrbits, 0, map);
210}
211
212intelfsh8_device_config::intelfsh8_device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock, UINT32 variant)
213   : intelfsh_device_config(mconfig, type, name, tag, owner, clock, variant)
214{
215}
216
217intelfsh16_device_config::intelfsh16_device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock, UINT32 variant)
218   : intelfsh_device_config(mconfig, type, name, tag, owner, clock, variant)
219{
220}
221
222
223//-------------------------------------------------
224//  memory_space_config - return a description of
225//  any address spaces owned by this device
226//-------------------------------------------------
227
228const address_space_config *intelfsh_device_config::memory_space_config(int spacenum) const
229{
230   return (spacenum == 0) ? &m_space_config : NULL;
231}
232
233
234
235//**************************************************************************
236//  LIVE DEVICE
237//**************************************************************************
238
239//-------------------------------------------------
240//  intelfsh_device - constructor
241//-------------------------------------------------
242
243intelfsh_device::intelfsh_device(running_machine &_machine, const intelfsh_device_config &config)
244   : device_t(_machine, config),
245     device_memory_interface(_machine, config, *this),
246     device_nvram_interface(_machine, config, *this),
247     m_config(config),
248     m_status(0x80),
249     m_erase_sector(0),
250     m_flash_mode(FM_NORMAL),
251     m_flash_master_lock(false),
252     m_timer(NULL)
253{
254}
255
256intelfsh8_device::intelfsh8_device(running_machine &_machine, const intelfsh_device_config &config)
257   : intelfsh_device(_machine, config) { }
258
259intelfsh16_device::intelfsh16_device(running_machine &_machine, const intelfsh_device_config &config)
260   : intelfsh_device(_machine, config) { }
261
262
263//-------------------------------------------------
264//  device_start - device-specific startup
265//-------------------------------------------------
266
267void intelfsh_device::device_start()
268{
269   m_timer = device_timer_alloc(*this);
270
271   state_save_register_device_item( this, 0, m_status );
272   state_save_register_device_item( this, 0, m_flash_mode );
273   state_save_register_device_item( this, 0, m_flash_master_lock );
274}
275
276
277//-------------------------------------------------
278//  device_timer - handler timer events
279//-------------------------------------------------
280
281void intelfsh_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
282{
283   switch( m_flash_mode )
158284   {
159      data = auto_alloc_array( machine, UINT8, c->size );
160      memset( data, 0xff, c->size );
285   case FM_READSTATUS:
286      m_status = 0x80;
287      break;
288
289   case FM_ERASEAMD4:
290      m_flash_mode = FM_NORMAL;
291      break;
161292   }
293}
162294
163   c->status = 0x80;
164   c->flash_mode = FM_NORMAL;
165   c->flash_master_lock = 0;
166   c->timer = timer_alloc(machine, erase_finished, c);
167   c->flash_memory = data;
168295
169   state_save_register_item( machine, "intelfsh", NULL, chip, c->status );
170   state_save_register_item( machine, "intelfsh", NULL, chip, c->flash_mode );
171   state_save_register_item( machine, "intelfsh", NULL, chip, c->flash_master_lock );
172   state_save_register_memory( machine, "intelfsh", NULL, chip, "flash_memory", c->flash_memory, c->bits/8, c->size / (c->bits/8), __FILE__, __LINE__ );
173}
296//-------------------------------------------------
297//  nvram_default - called to initialize NVRAM to
298//  its default state
299//-------------------------------------------------
174300
175UINT32 intelflash_read(int chip, UINT32 address)
301void intelfsh_device::nvram_default()
176302{
177   UINT32 data = 0;
178   struct flash_chip *c;
179   if( chip >= FLASH_CHIPS_MAX )
303   // region always wins
304   if (m_region != NULL)
180305   {
181      logerror( "intelflash_read: invalid chip %d\n", chip );
182      return 0;
306      UINT32 bytes = m_region->bytes();
307      if (bytes > m_config.m_size)
308         bytes = m_config.m_size;
309
310      if (m_config.m_bits == 8)
311      {
312         for (offs_t offs = 0; offs < bytes; offs++)
313            m_addrspace[0]->write_byte(offs, m_region->u8(offs));
314      }
315      else
316      {
317         for (offs_t offs = 0; offs < bytes; offs += 2)
318            m_addrspace[0]->write_word(offs, m_region->u16(offs / 2));
319      }
320      return;
183321   }
184   c = &chips[ chip ];
185322
186   switch( c->flash_mode )
323   // otherwise, default to 0xff
324   for (offs_t offs = 0; offs < m_config.m_size; offs++)
325      m_addrspace[0]->write_byte(offs, 0xff);
326}
327
328
329//-------------------------------------------------
330//  nvram_read - called to read NVRAM from the
331//  .nv file
332//-------------------------------------------------
333
334void intelfsh_device::nvram_read(mame_file &file)
335{
336   UINT8 *buffer = global_alloc_array(UINT8, m_config.m_size);
337   mame_fread(&file, buffer, m_config.m_size);
338   for (int byte = 0; byte < m_config.m_size; byte++)
339      m_addrspace[0]->write_byte(byte, buffer[byte]);
340   global_free(buffer);
341}
342
343
344//-------------------------------------------------
345//  nvram_write - called to write NVRAM to the
346//  .nv file
347//-------------------------------------------------
348
349void intelfsh_device::nvram_write(mame_file &file)
350{
351   UINT8 *buffer = global_alloc_array(UINT8, m_config.m_size);
352   for (int byte = 0; byte < m_config.m_size; byte++)
353      buffer[byte] = m_addrspace[0]->read_byte(byte);
354   mame_fwrite(&file, buffer, m_config.m_size);
355   global_free(buffer);
356}
357
358
359//-------------------------------------------------
360//  read_full - generic read, called by the
361//  bit-width-specific readers
362//-------------------------------------------------
363
364UINT32 intelfsh_device::read_full(UINT32 address)
365{
366   UINT32 data = 0;
367   switch( m_flash_mode )
187368   {
188369   default:
189370   case FM_NORMAL:
190      switch( c->bits )
371      switch( m_config.m_bits )
191372      {
192373      case 8:
193374         {
194            UINT8 *flash_memory = (UINT8 *)c->flash_memory;
195            data = flash_memory[ address ];
375            data = m_addrspace[0]->read_byte(address);
196376         }
197377         break;
198378      case 16:
199379         {
200            UINT16 *flash_memory = (UINT16 *)c->flash_memory;
201            data = flash_memory[ address ];
380            data = m_addrspace[0]->read_word(address * 2);
202381         }
203382         break;
204383      }
205384      break;
206385   case FM_READSTATUS:
207      data = c->status;
386      data = m_status;
208387      break;
209388   case FM_READAMDID3:
210389      switch (address)
211390      {
212         case 0:   data = c->maker_id; break;
213         case 1: data = c->device_id; break;
391         case 0:   data = m_config.m_maker_id; break;
392         case 1: data = m_config.m_device_id; break;
214393         case 2: data = 0; break;
215394      }
216395      break;
r9152r9153
218397      switch (address)
219398      {
220399      case 0:   // maker ID
221         data = c->maker_id;
400         data = m_config.m_maker_id;
222401         break;
223402      case 1:   // chip ID
224         data = c->device_id;
403         data = m_config.m_device_id;
225404         break;
226405      case 2:   // block lock config
227406         data = 0; // we don't support this yet
228407         break;
229408      case 3: // master lock config
230         if (c->flash_master_lock)
409         if (m_flash_master_lock)
231410         {
232411            data = 1;
233412         }
r9152r9153
240419      break;
241420   case FM_ERASEAMD4:
242421      // reads outside of the erasing sector return normal data
243      if ((address < c->erase_sector) || (address >= c->erase_sector+(64*1024)))
422      if ((address < m_erase_sector) || (address >= m_erase_sector+(64*1024)))
244423      {
245         switch( c->bits )
424         switch( m_config.m_bits )
246425         {
247426         case 8:
248427            {
249               UINT8 *flash_memory = (UINT8 *)c->flash_memory;
250               data = flash_memory[ address ];
428               data = m_addrspace[0]->read_byte(address);
251429            }
252430            break;
253431         case 16:
254432            {
255               UINT16 *flash_memory = (UINT16 *)c->flash_memory;
256               data = flash_memory[ address ];
433               data = m_addrspace[0]->read_word(address * 2);
257434            }
258435            break;
259436         }
260437      }
261438      else
262439      {
263         c->status ^= ( 1 << 6 ) | ( 1 << 2 );
264         data = c->status;
440         m_status ^= ( 1 << 6 ) | ( 1 << 2 );
441         data = m_status;
265442      }
266443      break;
267444   }
r9152r9153
271448   return data;
272449}
273450
274void intelflash_write(int chip, UINT32 address, UINT32 data)
451
452//-------------------------------------------------
453//  write_full - generic write, called by the
454//  bit-width-specific writers
455//-------------------------------------------------
456
457void intelfsh_device::write_full(UINT32 address, UINT32 data)
275458{
276   struct flash_chip *c;
277   if( chip >= FLASH_CHIPS_MAX )
278   {
279      logerror( "intelflash_write: invalid chip %d\n", chip );
280      return;
281   }
282   c = &chips[ chip ];
283
284459//  logerror( "intelflash_write( %d, %08x, %08x )\n", chip, address, data );
285460
286   switch( c->flash_mode )
461   switch( m_flash_mode )
287462   {
288463   case FM_NORMAL:
289464   case FM_READSTATUS:
r9152r9153
293468      {
294469      case 0xf0:
295470      case 0xff:   // reset chip mode
296         c->flash_mode = FM_NORMAL;
471         m_flash_mode = FM_NORMAL;
297472         break;
298473      case 0x90:   // read ID
299         c->flash_mode = FM_READID;
474         m_flash_mode = FM_READID;
300475         break;
301476      case 0x40:
302477      case 0x10:   // program
303         c->flash_mode = FM_WRITEPART1;
478         m_flash_mode = FM_WRITEPART1;
304479         break;
305480      case 0x50:   // clear status reg
306         c->status = 0x80;
307         c->flash_mode = FM_READSTATUS;
481         m_status = 0x80;
482         m_flash_mode = FM_READSTATUS;
308483         break;
309484      case 0x20:   // block erase
310         c->flash_mode = FM_CLEARPART1;
485         m_flash_mode = FM_CLEARPART1;
311486         break;
312487      case 0x60:   // set master lock
313         c->flash_mode = FM_SETMASTER;
488         m_flash_mode = FM_SETMASTER;
314489         break;
315490      case 0x70:   // read status
316         c->flash_mode = FM_READSTATUS;
491         m_flash_mode = FM_READSTATUS;
317492         break;
318493      case 0xaa:   // AMD ID select part 1
319494         if( ( address & 0xfff ) == 0x555 )
320495         {
321            c->flash_mode = FM_READAMDID1;
496            m_flash_mode = FM_READAMDID1;
322497         }
323498         break;
324499      default:
r9152r9153
329504   case FM_READAMDID1:
330505      if( ( address & 0xffff ) == 0x2aa && ( data & 0xff ) == 0x55 )
331506      {
332         c->flash_mode = FM_READAMDID2;
507         m_flash_mode = FM_READAMDID2;
333508      }
334509      else if( ( address & 0xffff ) == 0x2aaa && ( data & 0xff ) == 0x55 )
335510      {
336         c->flash_mode = FM_READAMDID2;
511         m_flash_mode = FM_READAMDID2;
337512      }
338513      else
339514      {
340515         logerror( "unexpected %08x=%02x in FM_READAMDID1\n", address, data & 0xff );
341         c->flash_mode = FM_NORMAL;
516         m_flash_mode = FM_NORMAL;
342517      }
343518      break;
344519   case FM_READAMDID2:
345520      if( ( address & 0xffff ) == 0x555 && ( data & 0xff ) == 0x90 )
346521      {
347         c->flash_mode = FM_READAMDID3;
522         m_flash_mode = FM_READAMDID3;
348523      }
349524      else if( ( address & 0xffff ) == 0x5555 && ( data & 0xff ) == 0x90 )
350525      {
351         c->flash_mode = FM_READAMDID3;
526         m_flash_mode = FM_READAMDID3;
352527      }
353528      else if( ( address & 0xffff ) == 0x555 && ( data & 0xff ) == 0x80 )
354529      {
355         c->flash_mode = FM_ERASEAMD1;
530         m_flash_mode = FM_ERASEAMD1;
356531      }
357532      else if( ( address & 0xffff ) == 0x5555 && ( data & 0xff ) == 0x80 )
358533      {
359         c->flash_mode = FM_ERASEAMD1;
534         m_flash_mode = FM_ERASEAMD1;
360535      }
361536      else if( ( address & 0xffff ) == 0x555 && ( data & 0xff ) == 0xa0 )
362537      {
363         c->flash_mode = FM_BYTEPROGRAM;
538         m_flash_mode = FM_BYTEPROGRAM;
364539      }
365540      else if( ( address & 0xffff ) == 0x5555 && ( data & 0xff ) == 0xa0 )
366541      {
367         c->flash_mode = FM_BYTEPROGRAM;
542         m_flash_mode = FM_BYTEPROGRAM;
368543      }
369544      else if( ( address & 0xffff ) == 0x555 && ( data & 0xff ) == 0xf0 )
370545      {
371         c->flash_mode = FM_NORMAL;
546         m_flash_mode = FM_NORMAL;
372547      }
373548      else if( ( address & 0xffff ) == 0x5555 && ( data & 0xff ) == 0xf0 )
374549      {
375         c->flash_mode = FM_NORMAL;
550         m_flash_mode = FM_NORMAL;
376551      }
377552      else
378553      {
379554         logerror( "unexpected %08x=%02x in FM_READAMDID2\n", address, data & 0xff );
380         c->flash_mode = FM_NORMAL;
555         m_flash_mode = FM_NORMAL;
381556      }
382557      break;
383558   case FM_ERASEAMD1:
384559      if( ( address & 0xfff ) == 0x555 && ( data & 0xff ) == 0xaa )
385560      {
386         c->flash_mode = FM_ERASEAMD2;
561         m_flash_mode = FM_ERASEAMD2;
387562      }
388563      else
389564      {
r9152r9153
393568   case FM_ERASEAMD2:
394569      if( ( address & 0xffff ) == 0x2aa && ( data & 0xff ) == 0x55 )
395570      {
396         c->flash_mode = FM_ERASEAMD3;
571         m_flash_mode = FM_ERASEAMD3;
397572      }
398573      else if( ( address & 0xffff ) == 0x2aaa && ( data & 0xff ) == 0x55 )
399574      {
400         c->flash_mode = FM_ERASEAMD3;
575         m_flash_mode = FM_ERASEAMD3;
401576      }
402577      else
403578      {
r9152r9153
408583      if( ( address & 0xfff ) == 0x555 && ( data & 0xff ) == 0x10 )
409584      {
410585         // chip erase
411         memset( c->flash_memory, 0xff, c->size);
586         for (offs_t offs = 0; offs < m_config.m_size; offs++)
587            m_addrspace[0]->write_byte(offs, 0xff);
412588
413         c->status = 1 << 3;
414         c->flash_mode = FM_ERASEAMD4;
589         m_status = 1 << 3;
590         m_flash_mode = FM_ERASEAMD4;
415591
416         timer_adjust_oneshot( c->timer, ATTOTIME_IN_SEC( 17 ), 0 );
592         timer_adjust_oneshot( m_timer, ATTOTIME_IN_SEC( 17 ), 0 );
417593      }
418594      else if( ( data & 0xff ) == 0x30 )
419595      {
420596         // sector erase
421597         // clear the 4k/64k block containing the current address to all 0xffs
422         switch( c->bits )
598         if (m_config.m_sector_is_4k)
423599         {
424         case 8:
425            {
426               UINT8 *flash_memory = (UINT8 *)c->flash_memory;
427               if (c->sector_is_4k)
428               {
429                  memset( &flash_memory[ address & ~0xfff ], 0xff, 4 * 1024 );
430                  c->erase_sector = address & ~0xfff;
431                  timer_adjust_oneshot( c->timer, ATTOTIME_IN_MSEC( 125 ), 0 );
432               }
433               else
434               {
435                  memset( &flash_memory[ address & ~0xffff ], 0xff, 64 * 1024 );
436                  c->erase_sector = address & ~0xffff;
437                  timer_adjust_oneshot( c->timer, ATTOTIME_IN_SEC( 1 ), 0 );
438               }
439            }
440            break;
441         case 16:
442            {
443               UINT16 *flash_memory = (UINT16 *)c->flash_memory;
444               if (c->sector_is_4k)
445               {
446                  memset( &flash_memory[ address & ~0x7ff ], 0xff, 4 * 1024 );
447                  c->erase_sector = address & ~0x7ff;
448                  timer_adjust_oneshot( c->timer, ATTOTIME_IN_MSEC( 125 ), 0 );
449               }
450               else
451               {
452                  memset( &flash_memory[ address & ~0x7fff ], 0xff, 64 * 1024 );
453                  c->erase_sector = address & ~0x7fff;
454                  timer_adjust_oneshot( c->timer, ATTOTIME_IN_SEC( 1 ), 0 );
455               }
456            }
457            break;
600            for (offs_t offs = 0; offs < 4 * 1024; offs++)
601               m_addrspace[0]->write_byte((address & ~0xfff) + offs, 0xff);
602            m_erase_sector = address & ~0xfff;
603            timer_adjust_oneshot( m_timer, ATTOTIME_IN_MSEC( 125 ), 0 );
458604         }
605         else
606         {
607            for (offs_t offs = 0; offs < 64 * 1024; offs++)
608               m_addrspace[0]->write_byte((address & ~0xffff) + offs, 0xff);
609            m_erase_sector = address & ~0xffff;
610            timer_adjust_oneshot( m_timer, ATTOTIME_IN_SEC( 1 ), 0 );
611         }
459612
460         c->status = 1 << 3;
461         c->flash_mode = FM_ERASEAMD4;
613         m_status = 1 << 3;
614         m_flash_mode = FM_ERASEAMD4;
462615      }
463616      else
464617      {
r9152r9153
466619      }
467620      break;
468621   case FM_BYTEPROGRAM:
469      switch( c->bits )
622      switch( m_config.m_bits )
470623      {
471624      case 8:
472625         {
473            UINT8 *flash_memory = (UINT8 *)c->flash_memory;
474            flash_memory[ address ] = data;
626            m_addrspace[0]->write_byte(address, data);
475627         }
476628         break;
477629      default:
478         logerror( "FM_BYTEPROGRAM not supported when c->bits == %d\n", c->bits );
630         logerror( "FM_BYTEPROGRAM not supported when m_bits == %d\n", m_config.m_bits );
479631         break;
480632      }
481      c->flash_mode = FM_NORMAL;
633      m_flash_mode = FM_NORMAL;
482634      break;
483635   case FM_WRITEPART1:
484      switch( c->bits )
636      switch( m_config.m_bits )
485637      {
486638      case 8:
487639         {
488            UINT8 *flash_memory = (UINT8 *)c->flash_memory;
489            flash_memory[ address ] = data;
640            m_addrspace[0]->write_byte(address, data);
490641         }
491642         break;
492643      case 16:
493644         {
494            UINT16 *flash_memory = (UINT16 *)c->flash_memory;
495            flash_memory[ address ] = data;
645            m_addrspace[0]->write_word(address * 2, data);
496646         }
497647         break;
498648      default:
499         logerror( "FM_WRITEPART1 not supported when c->bits == %d\n", c->bits );
649         logerror( "FM_WRITEPART1 not supported when m_bits == %d\n", m_config.m_bits );
500650         break;
501651      }
502      c->status = 0x80;
503      c->flash_mode = FM_READSTATUS;
652      m_status = 0x80;
653      m_flash_mode = FM_READSTATUS;
504654      break;
505655   case FM_CLEARPART1:
506656      if( ( data & 0xff ) == 0xd0 )
507657      {
508658         // clear the 64k block containing the current address to all 0xffs
509         switch( c->bits )
510         {
511         case 8:
512            {
513               UINT8 *flash_memory = (UINT8 *)c->flash_memory;
514               memset( &flash_memory[ address & ~0xffff ], 0xff, 64 * 1024 );
515            }
516            break;
517         case 16:
518            {
519               UINT16 *flash_memory = (UINT16 *)c->flash_memory;
520               memset( &flash_memory[ address & ~0x7fff ], 0xff, 64 * 1024 );
521            }
522            break;
523         default:
524            logerror( "FM_CLEARPART1 not supported when c->bits == %d\n", c->bits );
525            break;
526         }
527         c->status = 0x00;
528         c->flash_mode = FM_READSTATUS;
659         for (offs_t offs = 0; offs < 64 * 1024; offs++)
660            m_addrspace[0]->write_byte((address & ~0xffff) + offs, 0xff);
529661
530         timer_adjust_oneshot( c->timer, ATTOTIME_IN_SEC( 1 ), 0 );
662         m_status = 0x00;
663         m_flash_mode = FM_READSTATUS;
664
665         timer_adjust_oneshot( m_timer, ATTOTIME_IN_SEC( 1 ), 0 );
531666         break;
532667      }
533668      else
r9152r9153
539674      switch( data & 0xff )
540675      {
541676      case 0xf1:
542         c->flash_master_lock = 1;
677         m_flash_master_lock = true;
543678         break;
544679      case 0xd0:
545         c->flash_master_lock = 0;
680         m_flash_master_lock = false;
546681         break;
547682      default:
548683         logerror( "unexpected %08x=%02x in FM_SETMASTER:\n", address, data & 0xff );
549684         break;
550685      }
551      c->flash_mode = FM_NORMAL;
686      m_flash_mode = FM_NORMAL;
552687      break;
553688   }
554689}
555
556void nvram_handler_intelflash(running_machine *machine, int chip,mame_file *file,int read_or_write)
557{
558   struct flash_chip *c;
559   if( chip >= FLASH_CHIPS_MAX )
560   {
561      logerror( "intelflash_nvram: invalid chip %d\n", chip );
562      return;
563   }
564   c = &chips[ chip ];
565
566   switch( c->bits )
567   {
568   case 8:
569      if (read_or_write)
570      {
571         mame_fwrite( file, c->flash_memory, c->size );
572      }
573      else if (file)
574      {
575         mame_fread( file, c->flash_memory, c->size );
576      }
577      break;
578   case 16:
579      if (read_or_write)
580      {
581         /// TODO: endian conversion
582         mame_fwrite( file, c->flash_memory, c->size );
583      }
584      else if (file)
585      {
586         mame_fread( file, c->flash_memory, c->size );
587         /// TODO: endian conversion
588      }
589      break;
590   }
591}
src/emu/machine/intelfsh.h
r9152r9153
55#ifndef _INTELFLASH_H_
66#define _INTELFLASH_H_
77
8#define FLASH_CHIPS_MAX   ( 56 )
98
10#define FLASH_INTEL_28F016S5 ( 0 )
11#define FLASH_SHARP_LH28F400 ( 1 )
12#define FLASH_FUJITSU_29F016A ( 2 )
13#define FLASH_INTEL_E28F008SA ( 3 )
14#define FLASH_INTEL_TE28F160 ( 4 )
15#define FLASH_SHARP_LH28F016S ( 5 )
16#define FLASH_INTEL_E28F400 ( 6 )
17#define FLASH_SHARP_UNK128MBIT ( 7 )
18#define FLASH_MACRONIX_29L001MC ( 8 )
19#define FLASH_PANASONIC_MN63F805MNP ( 9 )
20#define FLASH_SANYO_LE26FV10N1TS ( 10 )
9//**************************************************************************
10//  INTERFACE CONFIGURATION MACROS
11//**************************************************************************
2112
22extern void intelflash_init( running_machine *machine, int chip, int type, void *data );
23extern UINT32 intelflash_read( int chip, UINT32 address );
24extern void intelflash_write( int chip, UINT32 address, UINT32 value );
25extern void nvram_handler_intelflash( running_machine *machine, int chip, mame_file *file, int read_or_write );
26extern void* intelflash_getmemptr(int chip);
13#define MDRV_INTEL_28F016S5_ADD(_tag) \
14   MDRV_DEVICE_ADD(_tag, INTEL_28F016S5, 0)
2715
16#define MDRV_SHARP_LH28F016S_ADD(_tag) \
17   MDRV_DEVICE_ADD(_tag, SHARP_LH28F016S, 0)
18
19#define MDRV_FUJITSU_29F016A_ADD(_tag) \
20   MDRV_DEVICE_ADD(_tag, FUJITSU_29F016A, 0)
21
22#define MDRV_INTEL_E28F400_ADD(_tag) \
23   MDRV_DEVICE_ADD(_tag, INTEL_E28F400, 0)
24
25#define MDRV_MACRONIX_29L001MC_ADD(_tag) \
26   MDRV_DEVICE_ADD(_tag, MACRONIX_29L001MC, 0)
27
28#define MDRV_PANASONIC_MN63F805MNP_ADD(_tag) \
29   MDRV_DEVICE_ADD(_tag, PANASONIC_MN63F805MNP, 0)
30
31#define MDRV_SANYO_LE26FV10N1TS_ADD(_tag) \
32   MDRV_DEVICE_ADD(_tag, SANYO_LE26FV10N1TS, 0)
33
34#define MDRV_SHARP_LH28F400_ADD(_tag) \
35   MDRV_DEVICE_ADD(_tag, SHARP_LH28F400, 0)
36
37#define MDRV_INTEL_E28F008SA_ADD(_tag) \
38   MDRV_DEVICE_ADD(_tag, INTEL_E28F008SA, 0)
39
40#define MDRV_INTEL_TE28F160_ADD(_tag) \
41   MDRV_DEVICE_ADD(_tag, INTEL_TE28F160, 0)
42
43#define MDRV_SHARP_UNK128MBIT_ADD(_tag) \
44   MDRV_DEVICE_ADD(_tag, SHARP_UNK128MBIT, 0)
45
46
47
48//**************************************************************************
49//  TYPE DEFINITIONS
50//**************************************************************************
51
52class intelfsh_device;
53
54
55// ======================> intelfsh_device_config
56
57class intelfsh_device_config :   public device_config,
58                        public device_config_memory_interface,
59                        public device_config_nvram_interface
60{
61   friend class intelfsh_device;
62
63protected:
64   // constants
65   enum
66   {
67      // 8-bit variants
68      FLASH_INTEL_28F016S5 = 0x0800,
69      FLASH_FUJITSU_29F016A,
70      FLASH_SHARP_LH28F016S,
71      FLASH_INTEL_E28F400,
72      FLASH_MACRONIX_29L001MC,
73      FLASH_PANASONIC_MN63F805MNP,
74      FLASH_SANYO_LE26FV10N1TS,
75
76      // 16-bit variants
77      FLASH_SHARP_LH28F400 = 0x1000,
78      FLASH_INTEL_E28F008SA,
79      FLASH_INTEL_TE28F160,
80      FLASH_SHARP_UNK128MBIT
81   };
82
83   // construction/destruction
84   intelfsh_device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock, UINT32 variant);
85
86   // device_config_memory_interface overrides
87   virtual const address_space_config *memory_space_config(int spacenum = 0) const;
88
89   // internal state
90   address_space_config   m_space_config;
91   UINT32                m_type;
92   INT32                m_size;
93   UINT8                m_bits;
94   UINT8                m_device_id;
95   UINT8                m_maker_id;
96   bool                m_sector_is_4k;
97};
98
99
100// ======================> intelfsh_device
101
102class intelfsh_device :   public device_t,
103                  public device_memory_interface,
104                  public device_nvram_interface
105{
106   friend class intelfsh_device_config;
107
108protected:
109   // construction/destruction
110   intelfsh_device(running_machine &_machine, const intelfsh_device_config &config);
111
112protected:
113   // device-level overrides
114   virtual void device_start();
115   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
116
117   // device_config_nvram_interface overrides
118   virtual void nvram_default();
119   virtual void nvram_read(mame_file &file);
120   virtual void nvram_write(mame_file &file);
121   
122   // derived helpers
123   UINT32 read_full(UINT32 offset);
124   void write_full(UINT32 offset, UINT32 data);
125
126   // internal state
127   const intelfsh_device_config &   m_config;
128
129   UINT8                   m_status;
130   INT32                   m_erase_sector;
131   INT32                   m_flash_mode;
132   bool                   m_flash_master_lock;
133   emu_timer *               m_timer;
134};
135
136
137// ======================> intelfsh8_device_config
138
139class intelfsh8_device_config : public intelfsh_device_config
140{
141   friend class intelfsh8_device;
142
143protected:
144   // construction/destruction
145   intelfsh8_device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock, UINT32 variant);
146};
147
148
149// ======================> intelfsh8_device
150
151class intelfsh8_device : public intelfsh_device
152{
153   friend class intelfsh8_device_config;
154   friend class intel_28f016s5_device_config;
155   friend class fujitsu_29f016a_device_config;
156   friend class sharp_lh28f016s_device_config;
157   friend class intel_e28f008sa_device_config;
158   friend class macronix_29l001mc_device_config;
159   friend class panasonic_mn63f805mnp_device_config;
160   friend class sanyo_le26fv10n1ts_device_config;
161
162protected:
163   // construction/destruction
164   intelfsh8_device(running_machine &_machine, const intelfsh_device_config &config);
165
166public:
167   // public interface
168   UINT8 read(offs_t offset) { return read_full(offset); }
169   void write(offs_t offset, UINT8 data) { write_full(offset, data); }
170   
171   UINT8 read_raw(offs_t offset) { return m_addrspace[0]->read_byte(offset); }
172   void write_raw(offs_t offset, UINT8 data) { m_addrspace[0]->write_byte(offset, data); }
173};
174
175
176// ======================> intelfsh16_device_config
177
178class intelfsh16_device_config : public intelfsh_device_config
179{
180   friend class intelfsh16_device;
181
182protected:
183   // construction/destruction
184   intelfsh16_device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock, UINT32 variant);
185};
186
187
188// ======================> intelfsh16_device
189
190class intelfsh16_device : public intelfsh_device
191{
192   friend class intelfsh16_device_config;
193   friend class sharp_lh28f400_device_config;
194   friend class intel_te28f160_device_config;
195   friend class intel_e28f400_device_config;
196   friend class sharp_unk128mbit_device_config;
197
198protected:
199   // construction/destruction
200   intelfsh16_device(running_machine &_machine, const intelfsh_device_config &config);
201
202public:
203   // public interface
204   UINT16 read(offs_t offset) { return read_full(offset); }
205   void write(offs_t offset, UINT16 data) { write_full(offset, data); }
206   
207   UINT16 read_raw(offs_t offset) { return m_addrspace[0]->read_word(offset * 2); }
208   void write_raw(offs_t offset, UINT16 data) { m_addrspace[0]->write_word(offset * 2, data); }
209};
210
211
212// ======================> trivial variants
213
214// 8-bit variants
215DECLARE_TRIVIAL_DERIVED_DEVICE(intel_28f016s5_device_config, intelfsh8_device_config, intel_28f016s5_device, intelfsh8_device)
216DECLARE_TRIVIAL_DERIVED_DEVICE(fujitsu_29f016a_device_config, intelfsh8_device_config, fujitsu_29f016a_device, intelfsh8_device)
217DECLARE_TRIVIAL_DERIVED_DEVICE(sharp_lh28f016s_device_config, intelfsh8_device_config, sharp_lh28f016s_device, intelfsh8_device)
218DECLARE_TRIVIAL_DERIVED_DEVICE(intel_e28f008sa_device_config, intelfsh8_device_config, intel_e28f008sa_device, intelfsh8_device)
219DECLARE_TRIVIAL_DERIVED_DEVICE(macronix_29l001mc_device_config, intelfsh8_device_config, macronix_29l001mc_device, intelfsh8_device)
220DECLARE_TRIVIAL_DERIVED_DEVICE(panasonic_mn63f805mnp_device_config, intelfsh8_device_config, panasonic_mn63f805mnp_device, intelfsh8_device)
221DECLARE_TRIVIAL_DERIVED_DEVICE(sanyo_le26fv10n1ts_device_config, intelfsh8_device_config, sanyo_le26fv10n1ts_device, intelfsh8_device)
222
223
224// 16-bit variants
225DECLARE_TRIVIAL_DERIVED_DEVICE(sharp_lh28f400_device_config, intelfsh16_device_config, sharp_lh28f400_device, intelfsh16_device)
226DECLARE_TRIVIAL_DERIVED_DEVICE(intel_te28f160_device_config, intelfsh16_device_config, intel_te28f160_device, intelfsh16_device)
227DECLARE_TRIVIAL_DERIVED_DEVICE(intel_e28f400_device_config, intelfsh16_device_config, intel_e28f400_device, intelfsh16_device)
228DECLARE_TRIVIAL_DERIVED_DEVICE(sharp_unk128mbit_device_config, intelfsh16_device_config, sharp_unk128mbit_device, intelfsh16_device)
229     
230
231
232// device type definition
233extern const device_type INTEL_28F016S5;
234extern const device_type SHARP_LH28F016S;
235extern const device_type FUJITSU_29F016A;
236extern const device_type INTEL_E28F400;
237extern const device_type MACRONIX_29L001MC;
238extern const device_type PANASONIC_MN63F805MNP;
239extern const device_type SANYO_LE26FV10N1TS;
240
241extern const device_type SHARP_LH28F400;
242extern const device_type INTEL_E28F008SA;
243extern const device_type INTEL_TE28F160;
244extern const device_type SHARP_UNK128MBIT;
245
246
28247#endif
src/emu/machine/mc146818.c
r9152r9153
192192//  device_timer - handler timer events
193193//-------------------------------------------------
194194
195void mc146818_device::device_timer(emu_timer &timer, int param, void *ptr)
195void mc146818_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
196196{
197197   int year/*, month*/;
198198
src/emu/timer.c
r9152r9153
5757   attotime            start;         /* time when the timer was started */
5858   attotime            expire;         /* time when the timer will expire */
5959   device_t *            device;         /* for device timers, a pointer to the device */
60   device_timer_id            id;            /* for device timers, the ID of the timer */
6061};
6162
6263
r9152r9153
372373      if (was_enabled)
373374      {
374375         if (timer->device != NULL)
375            timer->device->timer_fired(*timer, timer->param, timer->ptr);
376            timer->device->timer_fired(*timer, timer->id, timer->param, timer->ptr);
376377         else if (timer->callback != NULL)
377378         {
378379            LOG(("Timer %s:%d[%s] fired (expire=%s)\n", timer->file, timer->line, timer->func, attotime_string(timer->expire, 9)));
r9152r9153
519520   state_save_register_item(timer->machine, "timer", timer->func, count, timer->start.attoseconds);
520521   state_save_register_item(timer->machine, "timer", timer->func, count, timer->expire.seconds);
521522   state_save_register_item(timer->machine, "timer", timer->func, count, timer->expire.attoseconds);
523   if (timer->device != NULL)
524      state_save_register_item(timer->machine, "timer", timer->func, count, timer->id);
522525}
523526
524527
r9152r9153
594597    isn't primed yet
595598-------------------------------------------------*/
596599
597INLINE emu_timer *_timer_alloc_common(running_machine *machine, timer_fired_func callback, void *ptr, const char *file, int line, const char *func, int temp)
600INLINE emu_timer *_timer_alloc_common(running_machine *machine, device_t *device, device_timer_id id, timer_fired_func callback, void *ptr, const char *file, int line, const char *func, int temp)
598601{
599602   attotime time = get_current_time(machine);
600603   emu_timer *timer = timer_new(machine);
r9152r9153
609612   timer->file = file;
610613   timer->line = line;
611614   timer->func = func;
612   timer->device = NULL;
615   timer->device = device;
616   timer->id = id;
613617
614618   /* compute the time of the next firing and insert into the list */
615619   timer->start = time;
r9152r9153
630634
631635emu_timer *_timer_alloc_internal(running_machine *machine, timer_fired_func callback, void *ptr, const char *file, int line, const char *func)
632636{
633   return _timer_alloc_common(machine, callback, ptr, file, line, func, FALSE);
637   return _timer_alloc_common(machine, NULL, 0, callback, ptr, file, line, func, FALSE);
634638}
635639
636emu_timer *device_timer_alloc(device_t &device, void *ptr, int param)
640emu_timer *device_timer_alloc(device_t &device, UINT32 id, void *ptr)
637641{
638   emu_timer *timer = _timer_alloc_common(device.machine, NULL, ptr, __FILE__, __LINE__, device.tag(), FALSE);
639   timer->param = param;
640   timer->device = &device;
641   return timer;
642   return _timer_alloc_common(device.machine, &device, id, NULL, ptr, __FILE__, __LINE__, device.tag(), FALSE);
642643}
643644
644645
r9152r9153
728729    SIMPLIFIED ANONYMOUS TIMER MANAGEMENT
729730***************************************************************************/
730731
732void device_timer_call_after_resynch(device_t &device, device_timer_id id, INT32 param, void *ptr)
733{
734   emu_timer *timer = _timer_alloc_common(device.machine, &device, id, NULL, ptr, __FILE__, __LINE__, device.tag(), TRUE);
735   timer_adjust_oneshot(timer, attotime_zero, param);
736}
737
738
731739/*-------------------------------------------------
732740    timer_pulse - allocate a pulse timer, which
733741    repeatedly calls the callback using the given
r9152r9153
736744
737745void _timer_pulse_internal(running_machine *machine, attotime period, void *ptr, INT32 param, timer_fired_func callback, const char *file, int line, const char *func)
738746{
739   emu_timer *timer = _timer_alloc_common(machine, callback, ptr, file, line, func, FALSE);
747   emu_timer *timer = _timer_alloc_common(machine, NULL, 0, callback, ptr, file, line, func, FALSE);
740748   timer_adjust_periodic(timer, period, param, period);
741749}
742750
r9152r9153
748756
749757void _timer_set_internal(running_machine *machine, attotime duration, void *ptr, INT32 param, timer_fired_func callback, const char *file, int line, const char *func)
750758{
751   emu_timer *timer = _timer_alloc_common(machine, callback, ptr, file, line, func, TRUE);
759   emu_timer *timer = _timer_alloc_common(machine, NULL, 0, callback, ptr, file, line, func, TRUE);
752760   timer_adjust_oneshot(timer, duration, param);
753761}
754762
src/emu/timer.h
r9152r9153
149149emu_timer *_timer_alloc_internal(running_machine *machine, timer_fired_func callback, void *param, const char *file, int line, const char *func);
150150
151151/* allocate a permament device timer that isn't primed yet */
152emu_timer *device_timer_alloc(device_t &device, void *ptr = NULL, int param = 0);
152emu_timer *device_timer_alloc(device_t &device, device_timer_id id = 0, void *ptr = NULL);
153153
154154/* adjust the time when this timer will fire and disable any periodic firings */
155155void timer_adjust_oneshot(emu_timer *which, attotime duration, INT32 param);
r9152r9153
161161
162162/* ----- anonymous timer management ----- */
163163
164/* request a one-shot temporary timer for a device */
165void device_timer_call_after_resynch(device_t &device, device_timer_id id = 0, INT32 param = 0, void *ptr = NULL);
166
164167/* allocate a one-shot timer, which calls the callback after the given duration */
165168void _timer_set_internal(running_machine *machine, attotime duration, void *ptr, INT32 param, timer_fired_func callback, const char *file, int line, const char *func);
166169
src/mess/machine/bebox.c
r9152r9153
815815
816816static READ8_HANDLER( bebox_flash8_r )
817817{
818   fujitsu_29f016a_device *flash = space->machine->device<fujitsu_29f016a_device>("flash");
818819   offset = (offset & ~7) | (7 - (offset & 7));
819   return intelflash_read(0, offset);
820   return flash->read(offset);
820821}
821822
822823
823824static WRITE8_HANDLER( bebox_flash8_w )
824825{
826   fujitsu_29f016a_device *flash = space->machine->device<fujitsu_29f016a_device>("flash");
825827   offset = (offset & ~7) | (7 - (offset & 7));
826   intelflash_write(0, offset, data);
828   flash->write(offset, data);
827829}
828830
829831
r9152r9153
10561058 *
10571059 *************************************/
10581060
1059NVRAM_HANDLER( bebox )
1060{
1061   nvram_handler_intelflash(machine, 0, file, read_or_write);
1062}
1063
10641061MACHINE_RESET( bebox )
10651062{
10661063   bebox_devices.pic8259_master = NULL;
r9152r9153
10981095
10991096   /* set up boot and flash ROM */
11001097   memory_set_bankptr(machine, "bank2", memory_region(machine, "user2"));
1101   intelflash_init(machine, 0, FLASH_FUJITSU_29F016A, memory_region(machine, "user1"));
11021098
11031099   /* install MESS managed RAM */
11041100   memory_install_readwrite_bank(space_0, 0, messram_get_size(machine->device("messram")) - 1, 0, 0x02000000, "bank3");
src/mess/includes/bebox.h
r9152r9153
2727MACHINE_START( bebox );
2828MACHINE_RESET( bebox );
2929DRIVER_INIT( bebox );
30NVRAM_HANDLER( bebox );
3130
3231READ64_HANDLER( bebox_cpu0_imask_r );
3332READ64_HANDLER( bebox_cpu1_imask_r );
src/mess/messdriv.c
r9152r9153
6565   DRIVER( gbpocket )  /* Nintendo Game Boy Pocket Handheld */
6666   DRIVER( gblight )   /* Nintendo Game Boy Light Handheld */
6767   DRIVER( gbcolor )   /* Nintendo Game Boy Color Handheld */
68   DRIVER( gba )       /* Nintendo Game Boy Advance Handheld */
68//   DRIVER( gba )       /* Nintendo Game Boy Advance Handheld */
6969   DRIVER( snes )      /* Nintendo Super Nintendo NTSC */
7070   DRIVER( snespal )   /* Nintendo Super Nintendo PAL */
7171   DRIVER( snessfx )   /* Nintendo Super Nintendo NTSC w/SuperFX CPU*/
r9152r9153
346346   DRIVER( pcw9256 )   /* 198? PCW9256  */
347347   DRIVER( pcw9512 )   /* 198? PCW9512 (+)  */
348348   DRIVER( pcw10 )    /* 198? PCW10     */
349   DRIVER( pcw16 )    /* 1995 PCW16     */
349//   DRIVER( pcw16 )    /* 1995 PCW16     */
350350   DRIVER( nc100 )    /* 1992 NC100     */
351351   DRIVER( nc150 )    /* 1992 NC150     */
352352   DRIVER( nc200 )    /* 1993 NC200     */
r9152r9153
768768   DRIVER( genmod )   /* 199?? Myarc Geneve 9640    */
769769   DRIVER( ti99_4p )   /* 1996 SNUG 99/4P (a.k.a. SGCPU)      */
770770
771   DRIVER( avigo )    /*   */
771//   DRIVER( avigo )    /*   */
772772
773773   /* Texas Instruments Calculators */
774774   DRIVER( ti73 )     /* 1990 TI-73    */
src/mess/mess.mak
r9152r9153
584584   $(MESS_MACHINE)/nc.o      \
585585   $(MESS_VIDEO)/pcw.o         \
586586   $(MESS_DRIVERS)/pcw.o      \
587   $(MESS_DRIVERS)/pcw16.o      \
588587   $(MESS_VIDEO)/pcw16.o      \
589588   $(MESS_DRIVERS)/pda600.o   \
589   #$(MESS_DRIVERS)/pcw16.o      \
590590
591591$(MESSOBJ)/apf.a:            \
592592   $(MESS_DRIVERS)/apf.o      \
r9152r9153
11721172   $(MESS_MACHINE)/pokemini.o   \
11731173   $(MESS_DRIVERS)/pokemini.o   \
11741174   $(MESS_DRIVERS)/vboy.o      \
1175   $(MESS_DRIVERS)/gba.o      \
1176   $(MESS_VIDEO)/gba.o      \
1175#   $(MESS_DRIVERS)/gba.o      \
1176#   $(MESS_VIDEO)/gba.o      \
11771177
11781178$(MESSOBJ)/nokia.a:            \
11791179   $(MESS_DRIVERS)/mikromik.o   \
r9152r9153
15161516   $(MESS_FORMATS)/thom_cas.o   \
15171517
15181518$(MESSOBJ)/ti.a:            \
1519   $(MESS_VIDEO)/avigo.o      \
1520   $(MESS_DRIVERS)/avigo.o      \
15211519   $(MESS_DRIVERS)/ti85.o      \
15221520   $(MESS_FORMATS)/ti85_ser.o   \
15231521   $(MESS_VIDEO)/ti85.o      \
r9152r9153
15511549   $(MESS_VIDEO)/733_asr.o      \
15521550   $(MESS_DRIVERS)/ti990_10.o   \
15531551   $(MESS_DRIVERS)/ti99_2.o   \
1552#   $(MESS_VIDEO)/avigo.o      \
1553#   $(MESS_DRIVERS)/avigo.o      \
15541554
15551555$(MESSOBJ)/tiger.a:            \
15561556   $(MESS_DRIVERS)/gamecom.o   \
src/mess/drivers/pcw16.c
r9152r9153
192192/* PCW16 Flash interface */
193193/* PCW16 can have two 1mb flash chips */
194194
195static NVRAM_HANDLER( pcw16 )
196{
197   nvram_handler_intelflash( machine, 0, file, read_or_write );
198   nvram_handler_intelflash( machine, 1, file, read_or_write );
199}
200
201195/* read flash0 */
202static int pcw16_flash0_bank_handler_r(int bank, int offset)
196static int pcw16_flash0_bank_handler_r(running_machine *machine, int bank, int offset)
203197{
204   int flash_offset = (pcw16_banks[bank]<<14) | offset;
205
206   return intelflash_read(0, flash_offset);
198   intel_e28f008sa_device *flash = machine->device<intel_e28f008sa_device>("flash0");
199   int flash_offset = (pcw16_banks[bank]<<14) | offset;   
200   return flash->read(flash_offset);
207201}
208202
209203/* read flash1 */
210static int pcw16_flash1_bank_handler_r(int bank, int offset)
204static int pcw16_flash1_bank_handler_r(running_machine *machine, int bank, int offset)
211205{
206   intel_e28f008sa_device *flash = machine->device<intel_e28f008sa_device>("flash1");
212207   int flash_offset = ((pcw16_banks[bank]&0x03f)<<14) | offset;
213208
214   return intelflash_read(1, flash_offset);
209   return flash->read(flash_offset);
215210}
216211
217212/* flash 0 */
218213static  READ8_HANDLER(pcw16_flash0_bank_handler0_r)
219214{
220   return pcw16_flash0_bank_handler_r(0, offset);
215   return pcw16_flash0_bank_handler_r(space->machine,0, offset);
221216}
222217
223218static  READ8_HANDLER(pcw16_flash0_bank_handler1_r)
224219{
225   return pcw16_flash0_bank_handler_r(1, offset);
220   return pcw16_flash0_bank_handler_r(space->machine,1, offset);
226221}
227222
228223static  READ8_HANDLER(pcw16_flash0_bank_handler2_r)
229224{
230   return pcw16_flash0_bank_handler_r(2, offset);
225   return pcw16_flash0_bank_handler_r(space->machine,2, offset);
231226}
232227
233228static  READ8_HANDLER(pcw16_flash0_bank_handler3_r)
234229{
235   return pcw16_flash0_bank_handler_r(3, offset);
230   return pcw16_flash0_bank_handler_r(space->machine,3, offset);
236231}
237232
238233/* flash 1 */
239234static  READ8_HANDLER(pcw16_flash1_bank_handler0_r)
240235{
241   return pcw16_flash1_bank_handler_r(0, offset);
236   return pcw16_flash1_bank_handler_r(space->machine,0, offset);
242237}
243238
244239static  READ8_HANDLER(pcw16_flash1_bank_handler1_r)
245240{
246   return pcw16_flash1_bank_handler_r(1, offset);
241   return pcw16_flash1_bank_handler_r(space->machine,1, offset);
247242}
248243
249244static  READ8_HANDLER(pcw16_flash1_bank_handler2_r)
250245{
251   return pcw16_flash1_bank_handler_r(2, offset);
246   return pcw16_flash1_bank_handler_r(space->machine,2, offset);
252247}
253248
254249static  READ8_HANDLER(pcw16_flash1_bank_handler3_r)
255250{
256   return pcw16_flash1_bank_handler_r(3, offset);
251   return pcw16_flash1_bank_handler_r(space->machine,3, offset);
257252}
258253
259254static const read8_space_func pcw16_flash0_bank_handlers_r[4] =
r9152r9153
273268};
274269
275270/* write flash0 */
276static void pcw16_flash0_bank_handler_w(int bank, int offset, int data)
271static void pcw16_flash0_bank_handler_w(running_machine *machine, int bank, int offset, int data)
277272{
273   intel_e28f008sa_device *flash = machine->device<intel_e28f008sa_device>("flash0");
274
278275   int flash_offset = (pcw16_banks[bank]<<14) | offset;
279276
280   intelflash_write(0, flash_offset, data);
277   flash->write(flash_offset, data);
281278}
282279
283280/* read flash1 */
284static void pcw16_flash1_bank_handler_w(int bank, int offset, int data)
281static void pcw16_flash1_bank_handler_w(running_machine *machine, int bank, int offset, int data)
285282{
283   intel_e28f008sa_device *flash = machine->device<intel_e28f008sa_device>("flash1");
284
286285   int flash_offset = ((pcw16_banks[bank]&0x03f)<<14) | offset;
287286
288   intelflash_write(1, flash_offset,data);
287   flash->write(flash_offset,data);
289288}
290289
291290/* flash 0 */
292291static WRITE8_HANDLER(pcw16_flash0_bank_handler0_w)
293292{
294   pcw16_flash0_bank_handler_w(0, offset, data);
293   pcw16_flash0_bank_handler_w(space->machine,0, offset, data);
295294}
296295
297296
298297static WRITE8_HANDLER(pcw16_flash0_bank_handler1_w)
299298{
300   pcw16_flash0_bank_handler_w(1, offset, data);
299   pcw16_flash0_bank_handler_w(space->machine,1, offset, data);
301300}
302301
303302static WRITE8_HANDLER(pcw16_flash0_bank_handler2_w)
304303{
305   pcw16_flash0_bank_handler_w(2, offset, data);
304   pcw16_flash0_bank_handler_w(space->machine,2, offset, data);
306305}
307306
308307static WRITE8_HANDLER(pcw16_flash0_bank_handler3_w)
309308{
310   pcw16_flash0_bank_handler_w(3, offset, data);
309   pcw16_flash0_bank_handler_w(space->machine,3, offset, data);
311310}
312311
313312
314313/* flash 1 */
315314static WRITE8_HANDLER(pcw16_flash1_bank_handler0_w)
316315{
317   pcw16_flash1_bank_handler_w(0, offset, data);
316   pcw16_flash1_bank_handler_w(space->machine,0, offset, data);
318317}
319318
320319
321320static WRITE8_HANDLER(pcw16_flash1_bank_handler1_w)
322321{
323   pcw16_flash1_bank_handler_w(1, offset, data);
322   pcw16_flash1_bank_handler_w(space->machine,1, offset, data);
324323}
325324
326325static WRITE8_HANDLER(pcw16_flash1_bank_handler2_w)
327326{
328   pcw16_flash1_bank_handler_w(2, offset, data);
327   pcw16_flash1_bank_handler_w(space->machine,2, offset, data);
329328}
330329
331330static WRITE8_HANDLER(pcw16_flash1_bank_handler3_w)
332331{
333   pcw16_flash1_bank_handler_w(3, offset, data);
332   pcw16_flash1_bank_handler_w(space->machine,3, offset, data);
334333}
335334
336335static const write8_space_func pcw16_flash0_bank_handlers_w[4] =
r9152r9153
431430      {
432431         /* nvram */
433432         if ((bank_id & 0x040)==0)
434         {
433         {         
435434            mem_ptr = (unsigned char *)intelflash_getmemptr(0);
436435         }
437436         else
r9152r9153
13991398   MDRV_QUANTUM_TIME(HZ(60))
14001399
14011400   MDRV_MACHINE_START( pcw16 )
1402   MDRV_NVRAM_HANDLER( pcw16 )
14031401
14041402   MDRV_NS16550_ADD( "ns16550_1", pcw16_com_interface[0] )            /* TODO: Verify uart model */
14051403
r9152r9153
14311429   /* internal ram */
14321430   MDRV_RAM_ADD("messram")
14331431   MDRV_RAM_DEFAULT_SIZE("2M")
1432   MDRV_INTEL_E28F008SA_ADD("flash0")
1433   MDRV_INTEL_E28F008SA_ADD("flash1")
14341434MACHINE_CONFIG_END
14351435
1436
1437static DRIVER_INIT( pcw16 )
1438{
1439   /* init flashes */
1440   intelflash_init(machine, 0, FLASH_INTEL_E28F008SA, NULL);
1441   intelflash_init(machine, 1, FLASH_INTEL_E28F008SA, NULL);
1442}
1443
14441436/***************************************************************************
14451437
14461438  Game driver(s)
r9152r9153
14561448
14571449
14581450/*     YEAR  NAME     PARENT    COMPAT  MACHINE    INPUT     INIT    COMPANY          FULLNAME */
1459COMP( 1995, pcw16,     0,      0,      pcw16,      pcw16,    pcw16,    "Amstrad plc",   "PCW16", GAME_NOT_WORKING )
1451COMP( 1995, pcw16,     0,      0,      pcw16,      pcw16,    0,       "Amstrad plc",   "PCW16", GAME_NOT_WORKING )
src/mess/drivers/bebox.c
r9152r9153
2828#include "machine/pit8253.h"
2929#include "machine/idectrl.h"
3030#include "machine/mpc105.h"
31#include "machine/intelfsh.h"
3132
3233/* Devices */
3334#include "devices/flopdrv.h"
r9152r9153
155156   MDRV_SOUND_ADD("ym3812", YM3812, 3579545)
156157   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
157158
158   MDRV_NVRAM_HANDLER( bebox )
159   MDRV_FUJITSU_29F016A_ADD("flash")
159160
160161   MDRV_CDROM_ADD( "cdrom" )
161162   MDRV_HARDDISK_ADD( "harddisk1" )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team