Previous 199869 Revisions Next

r17678 Thursday 6th September, 2012 at 14:51:39 UTC by Curt Coder
(MESS) plus4: Refactored TED to use device_memory interface. (nw)
[src/mess/audio]mos7360.c mos7360.h
[src/mess/drivers]plus4.c
[src/mess/includes]plus4.h

trunk/src/mess/audio/mos7360.c
r17677r17678
174174const device_type MOS7360 = &device_creator<mos7360_device>;
175175
176176
177// default address maps
178static ADDRESS_MAP_START( mos7360_videoram_map, AS_0, 8, mos7360_device )
179   AM_RANGE(0x0000, 0xffff) AM_RAM
180ADDRESS_MAP_END
177181
182
183//-------------------------------------------------
184//  memory_space_config - return a description of
185//  any address spaces owned by this device
186//-------------------------------------------------
187
188const address_space_config *mos7360_device::memory_space_config(address_spacenum spacenum) const
189{
190   switch (spacenum)
191   {
192      case AS_0: return &m_videoram_space_config;
193      default: return NULL;
194   }
195}
196
197
198
178199//**************************************************************************
179200//  INLINE HELPERS
180201//**************************************************************************
r17677r17678
211232   return (int) ((machine().time().as_double() - m_rastertime) * TED7360_VRETRACERATE * m_lines * 57 * 8 + 0.5);
212233}
213234
235inline UINT8 mos7360_device::read_ram(offs_t offset)
236{
237   int rom = m_rom;
238   m_rom = 0;
214239
240   m_last_data = space(AS_0)->read_byte(offset);
215241
242   m_rom = rom;
243   
244   return m_last_data;
245}
246
247inline UINT8 mos7360_device::read_rom(offs_t offset)
248{
249   int rom = m_rom;
250   m_rom = 1;
251
252   m_last_data = space(AS_0)->read_byte(offset);
253
254   m_rom = rom;
255   
256   return m_last_data;
257}
258
259
260
216261//**************************************************************************
217262//  LIVE DEVICE
218263//**************************************************************************
r17677r17678
223268
224269mos7360_device::mos7360_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
225270   : device_t(mconfig, MOS7360, "MOS7360", tag, owner, clock),
271     device_memory_interface(mconfig, *this),
226272     device_sound_interface(mconfig, *this),
273     m_videoram_space_config("videoram", ENDIANNESS_LITTLE, 8, 16, 0, NULL, *ADDRESS_MAP_NAME(mos7360_videoram_map)),
227274     m_stream(NULL)
228275{
229276}
r17677r17678
246293   else
247294   {
248295      memset(&m_out_irq_cb, 0, sizeof(m_out_irq_cb));
249      memset(&m_in_ram_cb, 0, sizeof(m_in_ram_cb));
250      memset(&m_in_rom_cb, 0, sizeof(m_in_rom_cb));
251296      memset(&m_in_k_cb, 0, sizeof(m_in_k_cb));
252297   }
253298}
r17677r17678
269314
270315   // resolve callbacks
271316   m_out_irq_func.resolve(m_out_irq_cb, *this);
272   m_in_ram_func.resolve(m_in_ram_cb, *this);
273   m_in_rom_func.resolve(m_in_rom_cb, *this);
274317   m_in_k_func.resolve(m_in_k_cb, *this);
275318
276319   // allocate timers
r17677r17678
479522   for (y = ybegin; y <= yend; y++)
480523   {
481524      if (INROM)
482         code = m_in_rom_func(m_chargenaddr + ch * 8 + y);
525         code = read_rom(m_chargenaddr + ch * 8 + y);
483526      else
484         code = m_in_ram_func(m_chargenaddr + ch * 8 + y);
527         code = read_ram(m_chargenaddr + ch * 8 + y);
485528
486      m_last_data = code;
487
488529      m_bitmap.pix16(y + yoff, 0 + xoff) = color[code >> 7];
489530      m_bitmap.pix16(y + yoff, 1 + xoff) = color[(code >> 6) & 1];
490531      m_bitmap.pix16(y + yoff, 2 + xoff) = color[(code >> 5) & 1];
r17677r17678
503544   for (y = ybegin; y <= yend; y++)
504545   {
505546      if (INROM)
506         code = m_in_rom_func(m_chargenaddr + ch * 8 + y);
547         code = read_rom(m_chargenaddr + ch * 8 + y);
507548      else
508         code = m_in_ram_func(m_chargenaddr + ch * 8 + y);
549         code = read_ram(m_chargenaddr + ch * 8 + y);
509550
510      m_last_data = code;
511
512551      m_bitmap.pix16(y + yoff, 0 + xoff) =
513552         m_bitmap.pix16(y + yoff, 1 + xoff) = m_multi[code >> 6];
514553      m_bitmap.pix16(y + yoff, 2 + xoff) =
r17677r17678
526565
527566   for (y = ybegin; y <= yend; y++)
528567   {
529      code = m_in_ram_func(m_bitmapaddr + ch * 8 + y);
568      code = read_ram(m_bitmapaddr + ch * 8 + y);
530569     
531      m_last_data = code;
532
533570      m_bitmap.pix16(y + yoff, 0 + xoff) = m_c16_bitmap[code >> 7];
534571      m_bitmap.pix16(y + yoff, 1 + xoff) = m_c16_bitmap[(code >> 6) & 1];
535572      m_bitmap.pix16(y + yoff, 2 + xoff) = m_c16_bitmap[(code >> 5) & 1];
r17677r17678
547584
548585   for (y = ybegin; y <= yend; y++)
549586   {
550      code = m_in_ram_func(m_bitmapaddr + ch * 8 + y);
587      code = read_ram(m_bitmapaddr + ch * 8 + y);
551588     
552      m_last_data = code;
553
554589      m_bitmap.pix16(y + yoff, 0 + xoff) =
555590         m_bitmap.pix16(y + yoff, 1 + xoff) = m_bitmapmulti[code >> 6];
556591      m_bitmap.pix16(y + yoff, 2 + xoff) =
r17677r17678
643678      {
644679         if (HIRESON)
645680         {
646            ch = m_in_ram_func((m_videoaddr | 0x400) + offs);
647            attr = m_in_ram_func(m_videoaddr + offs);
681            ch = read_ram((m_videoaddr | 0x400) + offs);
682            attr = read_ram(m_videoaddr + offs);
648683            c1 = ((ch >> 4) & 0xf) | (attr << 4);
649684            c2 = (ch & 0xf) | (attr & 0x70);
650685            m_bitmapmulti[1] = m_c16_bitmap[1] = c1 & 0x7f;
r17677r17678
660695         }
661696         else
662697         {
663            ch = m_in_ram_func((m_videoaddr | 0x400) + offs);
664            attr = m_in_ram_func(m_videoaddr + offs);
698            ch = read_ram((m_videoaddr | 0x400) + offs);
699            attr = read_ram(m_videoaddr + offs);
665700            // levente harsfalvi's docu says cursor off in ecm and multicolor
666701            if (ECMON)
667702            {
r17677r17678
11601195{
11611196   return m_last_data;
11621197}
1198
1199
1200//-------------------------------------------------
1201//  cs0_r - chip select 0 read
1202//-------------------------------------------------
1203
1204int mos7360_device::cs0_r(offs_t offset)
1205{
1206   if (m_rom && offset >= 0x8000 && offset < 0xc000)
1207   {
1208      return 0;
1209   }
1210
1211   return 1;
1212}
1213
1214
1215//-------------------------------------------------
1216//  cs0_r - chip select 1 read
1217//-------------------------------------------------
1218
1219int mos7360_device::cs1_r(offs_t offset)
1220{
1221   if (m_rom && ((offset >= 0xc000 && offset < 0xfd00) || (offset >= 0xff20)))
1222   {
1223      return 0;
1224   }
1225
1226   return 1;
1227}
trunk/src/mess/audio/mos7360.h
r17677r17678
4343    DEVICE CONFIGURATION MACROS
4444***************************************************************************/
4545
46#define MCFG_MOS7360_ADD(_tag, _screen_tag, _clock, _config) \
46#define MCFG_MOS7360_ADD(_tag, _screen_tag, _clock, _config, _videoram_map) \
4747   MCFG_SCREEN_ADD(_screen_tag, RASTER) \
4848   MCFG_SCREEN_REFRESH_RATE(TED7360PAL_VRETRACERATE) \
4949   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) \
r17677r17678
5252   MCFG_SCREEN_UPDATE_DEVICE(_tag, mos7360_device, screen_update) \
5353   MCFG_PALETTE_LENGTH(128) \
5454   MCFG_DEVICE_ADD(_tag, MOS7360, _clock) \
55   MCFG_DEVICE_CONFIG(_config)
55   MCFG_DEVICE_CONFIG(_config) \
56   MCFG_DEVICE_ADDRESS_MAP(AS_0, _videoram_map)
5657
5758
5859#define MOS7360_INTERFACE(_name) \
r17677r17678
9899
99100   devcb_write_line   m_out_irq_cb;
100101
101   devcb_read8         m_in_ram_cb;
102   devcb_read8         m_in_rom_cb;
103102   devcb_read8         m_in_k_cb;
104103};
105104
r17677r17678
107106// ======================> mos7360_device
108107
109108class mos7360_device :  public device_t,
109                   public device_memory_interface,
110110                   public device_sound_interface,
111111                   public mos7360_interface
112112{
r17677r17678
115115   //mos7360_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
116116   mos7360_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
117117
118   virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
119
118120   DECLARE_READ8_MEMBER( read );
119121   DECLARE_WRITE8_MEMBER( write );
120122
123   int cs0_r(offs_t offset);
124   int cs1_r(offs_t offset);
125
121126   UINT8 bus_r();
122127
123128   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
r17677r17678
153158   inline void set_interrupt(int mask);
154159   inline void clear_interrupt(int mask);
155160   inline int rastercolumn();
161   inline UINT8 read_ram(offs_t offset);
162   inline UINT8 read_rom(offs_t offset);
156163
157164   void initialize_palette();
158165   void draw_character(int ybegin, int yend, int ch, int yoff, int xoff, UINT16 *color);
r17677r17678
163170   void drawlines(int first, int last);
164171   void soundport_w(int offset, int data);
165172
173   const address_space_config      m_videoram_space_config;
174
166175   devcb_resolved_write_line   m_out_irq_func;
167   devcb_resolved_read8      m_in_ram_func;
168   devcb_resolved_read8      m_in_rom_func;
169176   devcb_resolved_read8      m_in_k_func;
170177
171178   screen_device *m_screen;         // screen which sets bitmap properties
trunk/src/mess/includes/plus4.h
r17677r17678
4747        m_function(NULL),
4848        m_c2(NULL),
4949        m_addr(0),
50        m_rom_en(1),
5150        m_ted_irq(CLEAR_LINE),
5251        m_acia_irq(CLEAR_LINE),
5352        m_exp_irq(CLEAR_LINE)
r17677r17678
7675
7776   DECLARE_READ8_MEMBER( read );
7877   DECLARE_WRITE8_MEMBER( write );
78   DECLARE_READ8_MEMBER( ted_videoram_r );
7979
8080   DECLARE_READ8_MEMBER( cpu_r );
8181   DECLARE_READ8_MEMBER( c16_cpu_r );
r17677r17678
9898   const UINT8 *m_function;
9999   const UINT8 *m_c2;
100100   UINT8 m_addr;
101   int m_rom_en;
102101
103102   // interrupt state
104103   int m_ted_irq;
trunk/src/mess/drivers/plus4.c
r17677r17678
139139   *keyport = F5;
140140   *kernal = F6;
141141
142   // the following logic is actually inside the TED
143
144   *cs0 = 1;
145   *cs1 = 1;
146
147   if (m_rom_en)
148   {
149      if (offset >= 0x8000 && offset < 0xc000)
150      {
151         *cs0 = 0;
152         *cs1 = 1;
153      }
154      else if ((offset >= 0xc000 && offset < 0xfd00) || (offset >= 0xff20))
155      {
156         *cs0 = 1;
157         *cs1 = 0;
158      }
159   }
142   *cs0 = m_ted->cs0_r(offset);
143   *cs1 = m_ted->cs1_r(offset);
160144}
161145
162146
r17677r17678
169153   UINT8 data = m_ted->bus_r();
170154   int c1l = 1, c1h = 1, c2l = 1, c2h = 1;
171155
172   //logerror("offset %04x user %u 6551 %u addr_clk %u keyport %u kernal %u cs0 %u cs1 %u m_rom_en %u\n", offset,user,_6551,addr_clk,keyport,kernal,cs0,cs1,m_rom_en);
156   //logerror("offset %04x user %u 6551 %u addr_clk %u keyport %u kernal %u cs0 %u cs1 %u\n", offset,user,_6551,addr_clk,keyport,kernal,cs0,cs1);
173157
174158   if (!scs && m_t6721)
175159   {
r17677r17678
298282
299283   bankswitch(offset, phi0, mux, ras, &scs, &phi2, &user, &_6551, &addr_clk, &keyport, &kernal, &cs0, &cs1);
300284
301   //logerror("write offset %04x data %02x user %u 6551 %u addr_clk %u keyport %u kernal %u cs0 %u cs1 %u m_rom_en %u\n", offset,data,user,_6551,addr_clk,keyport,kernal,cs0,cs1,m_rom_en);
285   //logerror("write offset %04x data %02x user %u 6551 %u addr_clk %u keyport %u kernal %u cs0 %u cs1 %u\n", offset,data,user,_6551,addr_clk,keyport,kernal,cs0,cs1);
302286
303287   if (!scs && m_t6721)
304288   {
r17677r17678
326310   }
327311   else if (offset == 0xff3e)
328312   {
329      m_rom_en = 1;
330
331      m_ted->rom_switch_w(m_rom_en);
313      m_ted->rom_switch_w(1);
332314   }
333315   else if (offset == 0xff3f)
334316   {
335      m_rom_en = 0;
336
337      m_ted->rom_switch_w(m_rom_en);
317      m_ted->rom_switch_w(0);
338318   }
339319   else if (offset < 0xfd00 || offset >= 0xff20)
340320   {
r17677r17678
345325}
346326
347327
328//-------------------------------------------------
329//  ted_videoram_r -
330//-------------------------------------------------
348331
332READ8_MEMBER( plus4_state::ted_videoram_r )
333{
334   int phi0 = 1, mux = 0, ras = 1, ba = 0;
335   int scs, phi2, user, _6551, addr_clk, keyport, kernal, cs0, cs1;
336
337   bankswitch(offset, phi0, mux, ras, &scs, &phi2, &user, &_6551, &addr_clk, &keyport, &kernal, &cs0, &cs1);
338
339   return read_memory(space, offset, ba, scs, phi2, user, _6551, addr_clk, keyport, kernal, cs0, cs1);
340}
341
342
343
349344//**************************************************************************
350345//  ADDRESS MAPS
351346//**************************************************************************
r17677r17678
359354ADDRESS_MAP_END
360355
361356
357//-------------------------------------------------
358//  ADDRESS_MAP( ted_videoram_map )
359//-------------------------------------------------
362360
361static ADDRESS_MAP_START( ted_videoram_map, AS_0, 8, plus4_state )
362   AM_RANGE(0x0000, 0xffff) AM_READ(ted_videoram_r)
363ADDRESS_MAP_END
364
365
366
363367//**************************************************************************
364368//  INPUT PORTS
365369//**************************************************************************
r17677r17678
637641   check_interrupts();
638642}
639643
640READ8_MEMBER( plus4_state::ted_ram_r )
641{
642   int phi0 = 1, mux = 0, ras = 1, ba = 0;
643   int scs, phi2, user, _6551, addr_clk, keyport, kernal, cs0, cs1;
644
645   bankswitch(offset, phi0, mux, ras, &scs, &phi2, &user, &_6551, &addr_clk, &keyport, &kernal, &cs0, &cs1);
646
647   return read_memory(space, offset, ba, scs, phi2, user, _6551, addr_clk, keyport, kernal, 1, 1);
648}
649
650READ8_MEMBER( plus4_state::ted_rom_r )
651{
652   int phi0 = 1, mux = 0, ras = 1, ba = 0;
653   int scs, phi2, user, _6551, addr_clk, keyport, kernal, cs0, cs1;
654
655   bankswitch(offset, phi0, mux, ras, &scs, &phi2, &user, &_6551, &addr_clk, &keyport, &kernal, &cs0, &cs1);
656
657   return read_memory(space, offset, ba, scs, phi2, user, _6551, addr_clk, keyport, kernal, cs0, cs1);
658}
659
660644READ8_MEMBER( plus4_state::ted_k_r )
661645{
662646   UINT8 value = 0xff;
r17677r17678
685669   SCREEN_TAG,
686670   MOS7501_TAG,
687671   DEVCB_DRIVER_LINE_MEMBER(plus4_state, ted_irq_w),
688   DEVCB_DRIVER_MEMBER(plus4_state, ted_ram_r),
689   DEVCB_DRIVER_MEMBER(plus4_state, ted_rom_r),
690672   DEVCB_DRIVER_MEMBER(plus4_state, ted_k_r)
691673};
692674
r17677r17678
872854
873855   // state saving
874856   save_item(NAME(m_addr));
875   save_item(NAME(m_rom_en));
876857   save_item(NAME(m_ted_irq));
877858   save_item(NAME(m_acia_irq));
878859   save_item(NAME(m_exp_irq));
r17677r17678
902883   }
903884
904885   m_addr = 0;
905   m_rom_en = 1;
906886
907887   for (int i = 0; i < 10; i++)
908888   {
r17677r17678
931911
932912   // video and sound hardware
933913   MCFG_SPEAKER_STANDARD_MONO("mono")
934   MCFG_MOS7360_ADD(MOS7360_TAG, SCREEN_TAG, XTAL_14_31818MHz/4, ted_intf)
914   MCFG_MOS7360_ADD(MOS7360_TAG, SCREEN_TAG, XTAL_14_31818MHz/4, ted_intf, ted_videoram_map)
935915   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
936916
937917   // devices
r17677r17678
970950
971951   // video and sound hardware
972952   MCFG_SPEAKER_STANDARD_MONO("mono")
973   MCFG_MOS7360_ADD(MOS7360_TAG, SCREEN_TAG, XTAL_17_73447MHz/5, ted_intf)
953   MCFG_MOS7360_ADD(MOS7360_TAG, SCREEN_TAG, XTAL_17_73447MHz/5, ted_intf, ted_videoram_map)
974954   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
975955
976956   // devices

Previous 199869 Revisions Next


© 1997-2024 The MAME Team