Previous 15994 Revisions Next

r13271 Wednesday 16th November, 2011 at 08:02:11 UTC by Fabio Priuli
exelv: refactored to define ADDRESS_MAP_MODERN [Fabio Priuli]
tms3556: converted to be a C++ device [Fabio Priuli]
[src/mess/drivers]exelv.c
[src/mess/video]tms3556.c tms3556.h

src/mess/video/tms3556.c
r13270r13271
1414#include "emu.h"
1515#include "tms3556.h"
1616
17typedef struct
18{
19   /* registers */
20   UINT8 controlRegs[8];
21   UINT16 addressRegs[8];
22   UINT16 writePtr;
23   /* register interface */
24   int reg_ptr;
25   int reg_access_phase;
26   int magical_mystery_flag;
27   /* memory */
28   UINT8 *vram;
29   int vram_size;
30   /* scanline counter */
31   int scanline;
32   /* blinking */
33   int blink, blink_count;
34   /* background color for current line */
35   int bg_color;
36   /* current offset in name table */
37   int name_offset;
38   /* c/g flag (mixed mode only) */
39   int cg_flag;
40   /* character line counter (decrements from 10, 0 when we have reached last
41    line of character row) */
42   int char_line_counter;
43   /* double height phase flags (one per horizontal character position) */
44   int dbl_h_phase[40];
45} vdp_t;
46static vdp_t vdp;
17//**************************************************************************
18//  MACROS / CONSTANTS
19//**************************************************************************
4720
48#define TOP_BORDER 1
49#define BOTTOM_BORDER 1
50#define LEFT_BORDER 8
51#define RIGHT_BORDER 8
52#define TOTAL_WIDTH (320 + LEFT_BORDER + RIGHT_BORDER)
53#define TOTAL_HEIGHT (250 + TOP_BORDER + BOTTOM_BORDER)
21#define LOG 0
5422
55/* if DOUBLE_WIDTH set, the horizontal resolution is doubled */
56#define DOUBLE_WIDTH 1
23//**************************************************************************
24//  GLOBAL VARIABLES
25//**************************************************************************
5726
58#define TMS3556_MODE_OFF   0
59#define TMS3556_MODE_TEXT   1
60#define TMS3556_MODE_BITMAP   2
61#define TMS3556_MODE_MIXED   3
27// devices
28const device_type TMS3556 = &device_creator<tms3556_device>;
6229
63/*static const char *const tms3556_mode_names[] = { "DISPLAY OFF", "TEXT", "GRAPHIC", "MIXED" };*/
6430
65static PALETTE_INIT(tms3556);
31// default address map
32static ADDRESS_MAP_START( tms3556, AS_0, 8 )
33   AM_RANGE(0x0000, 0xffff) AM_RAM
34ADDRESS_MAP_END
6635
36//-------------------------------------------------
37//  memory_space_config - return a description of
38//  any address spaces owned by this device
39//-------------------------------------------------
6740
68#if 0
69#pragma mark BUS INTERFACE
70#endif
71/*
72    bus interface
73*/
41const address_space_config *tms3556_device::memory_space_config(address_spacenum spacenum) const
42{
43   return (spacenum == AS_0) ? &m_space_config : NULL;
44}
7445
75/*
76    tms3556_vram_r
7746
78    read a byte from tms3556 VRAM port
79*/
80READ8_HANDLER(tms3556_vram_r)
47//**************************************************************************
48//  INLINE HELPERS
49//**************************************************************************
50
51//-------------------------------------------------
52//  readbyte - read a byte at the given address
53//-------------------------------------------------
54
55inline UINT8 tms3556_device::readbyte(offs_t address)
8156{
82   int reply;
57   return space()->read_byte(address);
58}
8359
84   if (vdp.magical_mystery_flag)
60
61//-------------------------------------------------
62//  writebyte - write a byte at the given address
63//-------------------------------------------------
64
65inline void tms3556_device::writebyte(offs_t address, UINT8 data)
66{
67   space()->write_byte(address, data);
68}
69
70
71//**************************************************************************
72//  LIVE DEVICE
73//**************************************************************************
74
75//-------------------------------------------------
76//  tms3556_device - constructor
77//-------------------------------------------------
78
79tms3556_device::tms3556_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
80   : device_t(mconfig, TMS3556, "Texas Instruments VDP TMS3556", tag, owner, clock),
81     device_memory_interface(mconfig, *this),
82     m_space_config("videoram", ENDIANNESS_LITTLE, 8, 17, 0, NULL, *ADDRESS_MAP_NAME(tms3556)),
83     m_write_ptr(0),
84     m_reg_ptr(0),
85     m_reg_access_phase(0),
86     m_magical_mystery_flag(0),
87     m_scanline(0)
88{
89   for (int i = 0; i < 8; i++)
8590   {
86      vdp.writePtr = ((vdp.controlRegs[2] << 8) | vdp.controlRegs[1]) + 1;
87      vdp.magical_mystery_flag = 0;
91      m_control_regs[i] = 0;
92      m_address_regs[i] = 0;
8893   }
94}
8995
90   reply = vdp.vram[vdp.addressRegs[1]];
91   vdp.addressRegs[1] ++;
9296
93   return reply;
97//-------------------------------------------------
98//  device_start - device-specific startup
99//-------------------------------------------------
100
101void tms3556_device::device_start()
102{   
103   // register for state saving
104   save_item(NAME(m_control_regs));
105   save_item(NAME(m_address_regs));
106   save_item(NAME(m_write_ptr));
107   save_item(NAME(m_reg_ptr));
108   save_item(NAME(m_reg_access_phase));
109   save_item(NAME(m_magical_mystery_flag));
110   save_item(NAME(m_scanline));
111   save_item(NAME(m_blink));
112   save_item(NAME(m_blink_count));
113   save_item(NAME(m_bg_color));
114   save_item(NAME(m_name_offset));
115   save_item(NAME(m_cg_flag));
116   save_item(NAME(m_char_line_counter));
117   save_item(NAME(m_dbl_h_phase));
94118}
95119
96/*
97    tms3556_vram_w
98120
99    write a byte to tms3556 VRAM port
100*/
101WRITE8_HANDLER(tms3556_vram_w)
121/*static const char *const tms3556_mode_names[] = { "DISPLAY OFF", "TEXT", "GRAPHIC", "MIXED" };*/
122
123
124//-------------------------------------------------
125//  vram_r - VRAM read
126//-------------------------------------------------
127
128READ8_MEMBER( tms3556_device::vram_r )
102129{
103   if (vdp.magical_mystery_flag)
130   if (LOG) logerror("TMS3556 VRAM Read: %06x\n", offset);
131
132   if (m_magical_mystery_flag)
104133   {
105      vdp.writePtr = (vdp.controlRegs[2] << 8) | vdp.controlRegs[1];
106      vdp.magical_mystery_flag = 0;
134      m_write_ptr = ((m_control_regs[2] << 8) | m_control_regs[1]) + 1;
135      m_magical_mystery_flag = 0;
107136   }
108137
109   vdp.vram[vdp.writePtr] = data;
110   vdp.writePtr++;
138   return readbyte(m_address_regs[1]++);
111139}
112140
113/*
114    tms3556_reg_r
141//-------------------------------------------------
142//  vram_w - VRAM write
143//-------------------------------------------------
115144
116    read a byte from tms3556 register port
117*/
118READ8_HANDLER(tms3556_reg_r)
145WRITE8_MEMBER( tms3556_device::vram_w )
119146{
147   if (LOG) logerror("TMS3556 VRAM Write: %06x = %02x\n", offset, data);
148
149   if (m_magical_mystery_flag)
150   {
151      m_write_ptr = (m_control_regs[2] << 8) | m_control_regs[1];
152      m_magical_mystery_flag = 0;
153   }
154
155   writebyte(m_write_ptr++, data);
156}
157
158
159//-------------------------------------------------
160//  reg_r - read from register port
161//-------------------------------------------------
162
163READ8_MEMBER( tms3556_device::reg_r )
164{
165   if (LOG) logerror("TMS3556 Reg Read: %06x\n", offset);
166   
120167   int reply = 0;
121168
122   if (vdp.reg_ptr < 8)
169   if (m_reg_ptr < 8)
123170   {
124      reply = vdp.controlRegs[vdp.reg_ptr];
125      vdp.reg_access_phase = 0;
171      reply = m_control_regs[m_reg_ptr];
172      m_reg_access_phase = 0;
126173   }
127   /*else
128    {   // ???
129    }*/
174   else
175    {
176      // ???
177    }
130178
131179   return reply;
132180}
133181
134/*
135    tms3556_reg_w
182//-------------------------------------------------
183//  reg_w - write to register port
184//-------------------------------------------------
136185
137    write a byte to tms3556 register port
138*/
139WRITE8_HANDLER(tms3556_reg_w)
186WRITE8_MEMBER( tms3556_device::reg_w )
140187{
141   if ((vdp.reg_access_phase == 3) && (data))
142      vdp.reg_access_phase = 0;   /* ???????????? */
143   switch (vdp.reg_access_phase)
188   if (LOG) logerror("TMS3556 Reg Write: %06x = %02x\n", offset, data);
189
190   if ((m_reg_access_phase == 3) && (data))
191      m_reg_access_phase = 0;   /* ???????????? */
192
193   switch (m_reg_access_phase)
144194   {
145195   case 0:
146      vdp.reg_ptr = data & 0x0f;
147      vdp.reg_access_phase = 1;
196      m_reg_ptr = data & 0x0f;
197      m_reg_access_phase = 1;
148198      break;
199
149200   case 1:
150      if (vdp.reg_ptr < 8)
201      if (m_reg_ptr < 8)
151202      {
152         vdp.controlRegs[vdp.reg_ptr] = data;
153         vdp.reg_access_phase = 0;
154         if (vdp.reg_ptr == 2)
155            vdp.magical_mystery_flag = 1;
203         m_control_regs[m_reg_ptr] = data;
204         m_reg_access_phase = 0;
205         if (m_reg_ptr == 2)
206            m_magical_mystery_flag = 1;
156207      }
157      else if (vdp.reg_ptr == 9)
208      else if (m_reg_ptr == 9)
158209      {   /* I don't understand what is going on, but it is the only way to
159210            get this to work */
160         vdp.addressRegs[vdp.reg_ptr-8] = ((vdp.controlRegs[2] << 8) | vdp.controlRegs[1]) + 1;
161         vdp.reg_access_phase = 0;
162         vdp.magical_mystery_flag = 0;
211         m_address_regs[m_reg_ptr - 8] = ((m_control_regs[2] << 8) | m_control_regs[1]) + 1;
212         m_reg_access_phase = 0;
213         m_magical_mystery_flag = 0;
163214      }
164215      else
165216      {
166         vdp.addressRegs[vdp.reg_ptr-8] = (vdp.addressRegs[vdp.reg_ptr-8] & 0xff00) | vdp.controlRegs[1];
167         vdp.reg_access_phase = 2;
168         vdp.magical_mystery_flag = 0;
217         m_address_regs[m_reg_ptr - 8] = (m_control_regs[m_reg_ptr - 8] & 0xff00) | m_control_regs[1];
218         m_reg_access_phase = 2;
219         m_magical_mystery_flag = 0;
169220      }
170221      break;
222
171223   case 2:
172      vdp.addressRegs[vdp.reg_ptr-8] = (vdp.addressRegs[vdp.reg_ptr-8] & 0x00ff) | (vdp.controlRegs[2] << 8);
173      if ((vdp.reg_ptr <= 10) || (vdp.reg_ptr == 15))
174         vdp.addressRegs[vdp.reg_ptr-8] ++;
224      m_address_regs[m_reg_ptr - 8] = (m_control_regs[m_reg_ptr - 8] & 0x00ff) | (m_control_regs[2] << 8);
225      if ((m_reg_ptr <= 10) || (m_reg_ptr == 15))
226         m_address_regs[m_reg_ptr - 8]++;
175227      else
176         vdp.addressRegs[vdp.reg_ptr-8] += 2;
177      vdp.reg_access_phase = 3;
228         m_address_regs[m_reg_ptr - 8] += 2;
229      m_reg_access_phase = 3;
178230      break;
231
179232   case 3:
180      vdp.reg_access_phase = 0;
233      m_reg_access_phase = 0;
181234      break;
182235   }
183236}
184237
185238
186#if 0
187#pragma mark -
188#pragma mark INITIALIZATION CODE
189#endif
190/*
191    initialization code
192*/
239//-------------------------------------------------
240//  redraw code
241//-------------------------------------------------
193242
194/*
195    MCFG_tms3556
196243
197    machine struct initialization helper
198*/
199MACHINE_CONFIG_FRAGMENT( tms3556 )
200   /* video hardware */
201   MCFG_SCREEN_ADD("screen", RASTER)
202   MCFG_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
203   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
204#if DOUBLE_WIDTH
205   MCFG_SCREEN_SIZE(TOTAL_WIDTH*2, TOTAL_HEIGHT*2)
206   MCFG_SCREEN_VISIBLE_AREA(0, TOTAL_WIDTH*2-1, 0, TOTAL_HEIGHT*2-1)
207#else
208   MCFG_SCREEN_SIZE(TOTAL_WIDTH, TOTAL_HEIGHT*2)
209   MCFG_SCREEN_VISIBLE_AREA(0, TOTAL_WIDTH-1, 0, TOTAL_HEIGHT*2-1)
210#endif
211   MCFG_SCREEN_UPDATE(generic_bitmapped)
212   MCFG_PALETTE_LENGTH(8)
213   MCFG_PALETTE_INIT(tms3556)
244//-------------------------------------------------
245//  draw_line_empty - draw an empty line (used for
246//  top and bottom borders, and screen off mode)
247//-------------------------------------------------
214248
215   MCFG_VIDEO_START(generic_bitmapped)
216MACHINE_CONFIG_END
217
218
219/*
220    PALETTE_INIT( tms3556 )
221
222    Create our 8-color RGB palette
223*/
224static PALETTE_INIT( tms3556 )
249void tms3556_device::draw_line_empty(UINT16 *ln)
225250{
226   int   i, red, green, blue;
227
228   /* create the 8 color palette */
229   for (i=0;i<8;i++)
230   {
231      red = (i & 1) ? 255 : 0;   /* red */
232      green = (i & 2) ? 255 : 0;   /* green */
233      blue = (i & 4) ? 255 : 0;   /* blue */
234      palette_set_color_rgb(machine, i, red, green, blue);
235   }
236}
237
238/*
239    tms3556_init
240
241    tms3556 core init (called at video init time)
242*/
243void tms3556_init(running_machine &machine, int vram_size)
244{
245   memset(&vdp, 0, sizeof (vdp));
246
247   vdp.vram_size = vram_size;
248
249   /* allocate VRAM */
250   vdp.vram = auto_alloc_array(machine, UINT8, 0x10000);
251   memset (vdp.vram, 0, 0x10000);
252   if (vdp.vram_size < 0x10000)
253   {
254      /* set unavailable RAM to 0xff */
255      memset(vdp.vram + vdp.vram_size, 0xff, (0x10000 - vdp.vram_size) );
256   }
257}
258
259/*
260    tms3556_reset
261
262    tms3556 reset (should be called at machine init time)
263*/
264void tms3556_reset(void)
265{
266   int i;
267
268   /* register reset */
269   for (i=0;i<8;i++)
270   {
271      vdp.controlRegs[i] = 0;
272      vdp.addressRegs[i] = 0;
273   }
274   vdp.writePtr = 0;
275   vdp.reg_ptr = 0;
276   vdp.reg_access_phase = 0;
277   vdp.magical_mystery_flag = 0;
278   vdp.scanline = 0;
279}
280
281
282#if 0
283#pragma mark -
284#pragma mark REDRAW CODE
285#endif
286/*
287    redraw code
288*/
289
290/*
291    tms3556_draw_line_empty
292
293    draw an empty line (used for top and bottom borders, and screen off mode)
294*/
295static void tms3556_draw_line_empty(UINT16 *ln)
296{
297251   int   i;
298252
299   for (i=0; i<TOTAL_WIDTH; i++)
300#if DOUBLE_WIDTH
301      *ln++ = vdp.bg_color;
253   for (i = 0; i < TMS3556_TOTAL_WIDTH; i++)
254#if TMS3556_DOUBLE_WIDTH
255      *ln++ = m_bg_color;
302256#endif
303         *ln++ = vdp.bg_color;
257      *ln++ = m_bg_color;
304258}
305259
306/*
307    tms3556_draw_line_text_common
308260
309    draw a line of text (called by tms3556_draw_line_text and
310    tms3556_draw_line_mixed)
311*/
312static void tms3556_draw_line_text_common(UINT16 *ln)
261//-------------------------------------------------
262//  draw_line_text_common - draw a line of text
263//  (called by draw_line_text and draw_line_mixed)
264//-------------------------------------------------
265
266void tms3556_device::draw_line_text_common(UINT16 *ln)
313267{
314268   int pattern, x, xx, i, name_offset;
315269   UINT16 fg, bg;
316   UINT8 *nametbl, *patterntbl[4];
270   offs_t nametbl_base;
271   offs_t patterntbl_base[4];
317272   int name_hi, name_lo;
318273   int pattern_ix;
319274   int alphanumeric_mode, dbl_w, dbl_h, dbl_w_phase = 0;
320275
276   nametbl_base = m_address_regs[2];
277   for (i = 0; i < 4; i++)
278      patterntbl_base[i] = m_address_regs[i + 3];
321279
322   nametbl = vdp.vram + vdp.addressRegs[2];
323   for (i=0; i<4; i++)
324      patterntbl[i] = vdp.vram + vdp.addressRegs[i+3];
325
326   for (xx=0; xx<LEFT_BORDER; xx++)
327#if DOUBLE_WIDTH
328      *ln++ = vdp.bg_color;
280   for (xx = 0; xx < TMS3556_LEFT_BORDER; xx++)
281#if TMS3556_DOUBLE_WIDTH
282      *ln++ = m_bg_color;
329283#endif
330         *ln++ = vdp.bg_color;
284      *ln++ = m_bg_color;
331285
332   name_offset = vdp.name_offset;
286   name_offset = m_name_offset;
333287
334   for (x=0;x<40;x++)
288   for (x = 0; x < 40; x++)
335289   {
336      name_hi = nametbl[name_offset];
337      name_lo = nametbl[name_offset+1];
290      name_hi = readbyte(nametbl_base + name_offset);
291      name_lo = readbyte(nametbl_base + name_offset + 1);
338292      pattern_ix = ((name_hi >> 2) & 2) | ((name_hi >> 4) & 1);
339      alphanumeric_mode = (pattern_ix < 2) || ((pattern_ix == 3) && !(vdp.controlRegs[7] & 0x08));
293      alphanumeric_mode = (pattern_ix < 2) || ((pattern_ix == 3) && !(m_control_regs[7] & 0x08));
340294      fg = (name_hi >> 5) & 0x7;
341295      if (alphanumeric_mode)
342296      {
343297         if (name_hi & 4)
344298         {   /* inverted color */
345299            bg = fg;
346            fg = vdp.bg_color;
300            fg = m_bg_color;
347301         }
348302         else
349            bg = vdp.bg_color;
303            bg = m_bg_color;
350304         dbl_w = name_hi & 0x2;
351305         dbl_h = name_hi & 0x1;
352306      }
r13270r13271
356310         dbl_w = 0;
357311         dbl_h = 0;
358312      }
359      if ((name_lo & 0x80) && vdp.blink)
313      if ((name_lo & 0x80) && m_blink)
360314         fg = bg;   /* blink off time */
361315      if (! dbl_h)
362316      {   /* single height */
363         pattern = patterntbl[pattern_ix][(name_lo & 0x7f) + 128*vdp.char_line_counter];
364         if (vdp.char_line_counter == 0)
365            vdp.dbl_h_phase[x] = 0;
317         pattern = readbyte(patterntbl_base[pattern_ix] + (name_lo & 0x7f) + 128 * m_char_line_counter);
318         if (m_char_line_counter == 0)
319            m_dbl_h_phase[x] = 0;
366320      }
367321      else
368322      {   /* double height */
369         if (! vdp.dbl_h_phase[x])
323         if (! m_dbl_h_phase[x])
370324            /* first phase: pattern from upper half */
371            pattern = patterntbl[pattern_ix][(name_lo & 0x7f) + 128*(5+(vdp.char_line_counter>>1))];
325            pattern = readbyte(patterntbl_base[pattern_ix] + (name_lo & 0x7f) + 128 * (5 + (m_char_line_counter >> 1)));
372326         else
373327            /* second phase: pattern from lower half */
374            pattern = patterntbl[pattern_ix][(name_lo & 0x7f) + 128*(vdp.char_line_counter>>1)];
375         if (vdp.char_line_counter == 0)
376            vdp.dbl_h_phase[x] = ! vdp.dbl_h_phase[x];
328            pattern = readbyte(patterntbl_base[pattern_ix] + (name_lo & 0x7f) + 128 * (m_char_line_counter >> 1));
329         if (m_char_line_counter == 0)
330            m_dbl_h_phase[x] = !m_dbl_h_phase[x];
377331      }
378      if (! dbl_w)
332      if (!dbl_w)
379333      {   /* single width */
380         for (xx=0;xx<8;xx++)
334         for (xx = 0; xx < 8; xx++)
381335         {
382336            UINT16 color = (pattern & 0x80) ? fg : bg;
383#if DOUBLE_WIDTH
337#if TMS3556_DOUBLE_WIDTH
384338            *ln++ = color;
385339#endif
386               *ln++ = color;
340            *ln++ = color;
387341            pattern <<= 1;
388342         }
389343         dbl_w_phase = 0;
r13270r13271
393347         if (dbl_w_phase)
394348            /* second phase: display right half */
395349            pattern <<= 4;
396         for (xx=0;xx<4;xx++)
350         for (xx = 0; xx < 4; xx++)
397351         {
398352            UINT16 color = (pattern & 0x80) ? fg : bg;
399#if DOUBLE_WIDTH
353#if TMS3556_DOUBLE_WIDTH
400354            *ln++ = color; *ln++ = color;
401355#endif
402               *ln++ = color; *ln++ = color;
356            *ln++ = color; *ln++ = color;
403357            pattern <<= 1;
404358         }
405359         dbl_w_phase = !dbl_w_phase;
r13270r13271
407361      name_offset += 2;
408362   }
409363
410   for (xx=0; xx<RIGHT_BORDER; xx++)
411#if DOUBLE_WIDTH
412      *ln++ = vdp.bg_color;
364   for (xx = 0; xx < TMS3556_RIGHT_BORDER; xx++)
365#if TMS3556_DOUBLE_WIDTH
366      *ln++ = m_bg_color;
413367#endif
414         *ln++ = vdp.bg_color;
368      *ln++ = m_bg_color;
415369
416   if (vdp.char_line_counter == 0)
417      vdp.name_offset = name_offset;
370   if (m_char_line_counter == 0)
371      m_name_offset = name_offset;
418372}
419373
420/*
421    tms3556_draw_line_bitmap_common
422374
423    draw a line of bitmap (called by tms3556_draw_line_bitmap and
424    tms3556_draw_line_mixed)
425*/
426static void tms3556_draw_line_bitmap_common(UINT16 *ln)
375//-------------------------------------------------
376//  draw_line_bitmap_common - draw a line of bitmap
377//  (called by draw_line_bitmap and draw_line_mixed)
378//-------------------------------------------------
379
380void tms3556_device::draw_line_bitmap_common(UINT16 *ln)
427381{
428382   int x, xx;
429   UINT8 *nametbl;
383   offs_t nametbl_base;
430384   int name_b, name_g, name_r;
431385
386   nametbl_base = m_address_regs[2];
432387
433   nametbl = vdp.vram + vdp.addressRegs[2];
434
435   for (xx=0; xx<LEFT_BORDER; xx++)
436#if DOUBLE_WIDTH
437      *ln++ = vdp.bg_color;
388   for (xx = 0; xx < TMS3556_LEFT_BORDER; xx++)
389#if TMS3556_DOUBLE_WIDTH
390      *ln++ = m_bg_color;
438391#endif
439         *ln++ = vdp.bg_color;
392      *ln++ = m_bg_color;
440393
441   for (x=0;x<40;x++)
394   for (x = 0; x < 40; x++)
442395   {
443      name_b = nametbl[vdp.name_offset];
444      name_g = nametbl[vdp.name_offset+1];
445      name_r = nametbl[vdp.name_offset+2];
446      for (xx=0;xx<8;xx++)
396      name_b = readbyte(nametbl_base + m_name_offset);
397      name_g = readbyte(nametbl_base + m_name_offset + 1);
398      name_r = readbyte(nametbl_base + m_name_offset + 2);
399      for (xx = 0; xx < 8; xx++)
447400      {
448401         UINT16 color = ((name_b >> 5) & 0x4) | ((name_g >> 6) & 0x2) | ((name_r >> 7) & 0x1);
449#if DOUBLE_WIDTH
402#if TMS3556_DOUBLE_WIDTH
450403         *ln++ = color;
451404#endif
452            *ln++ = color;
405         *ln++ = color;
453406         name_b <<= 1;
454407         name_g <<= 1;
455408         name_r <<= 1;
456409      }
457      vdp.name_offset += 3;
410      m_name_offset += 3;
458411   }
459412
460   for (xx=0; xx<RIGHT_BORDER; xx++)
461#if DOUBLE_WIDTH
462      *ln++ = vdp.bg_color;
413   for (xx = 0; xx < TMS3556_RIGHT_BORDER; xx++)
414#if TMS3556_DOUBLE_WIDTH
415      *ln++ = m_bg_color;
463416#endif
464         *ln++ = vdp.bg_color;
417      *ln++ = m_bg_color;
465418}
466419
467/*
468    tms3556_draw_line_text
469420
470    draw a line in text mode
471*/
472static void tms3556_draw_line_text(UINT16 *ln)
421//-------------------------------------------------
422//  draw_line_text - draw a line in text mode
423//-------------------------------------------------
424
425void tms3556_device::draw_line_text(UINT16 *ln)
473426{
474   if (vdp.char_line_counter == 0)
475      vdp.char_line_counter = 10;
476   vdp.char_line_counter--;
477   tms3556_draw_line_text_common(ln);
427   if (m_char_line_counter == 0)
428      m_char_line_counter = 10;
429   m_char_line_counter--;
430   draw_line_text_common(ln);
478431}
479432
480/*
481    tms3556_draw_line_bitmap
482433
483    draw a line in bitmap mode
484*/
485static void tms3556_draw_line_bitmap(UINT16 *ln)
486{
487   UINT8 *nametbl;
434//-------------------------------------------------
435//  draw_line_bitmap - draw a line in bitmap mode
436//-------------------------------------------------
488437
489
490   tms3556_draw_line_bitmap_common(ln);
491   nametbl = vdp.vram + vdp.addressRegs[2];
492   vdp.bg_color = (nametbl[vdp.name_offset] >> 5) & 0x7;
493   vdp.name_offset += 2;
438void tms3556_device::draw_line_bitmap(UINT16 *ln)
439{
440   draw_line_bitmap_common(ln);
441   m_bg_color = (readbyte(m_address_regs[2] + m_name_offset) >> 5) & 0x7;
442   m_name_offset += 2;
494443}
495444
496/*
497    tms3556_draw_line_mixed
498445
499    draw a line in mixed mode
500*/
501static void tms3556_draw_line_mixed(UINT16 *ln)
502{
503   UINT8 *nametbl;
446//-------------------------------------------------
447//  draw_line_mixed - draw a line in mixed mode
448//-------------------------------------------------
504449
505
506   if (vdp.cg_flag)
450void tms3556_device::draw_line_mixed(UINT16 *ln)
451{
452   if (m_cg_flag)
507453   {   /* bitmap line */
508      tms3556_draw_line_bitmap_common(ln);
509      nametbl = vdp.vram + vdp.addressRegs[2];
510      vdp.bg_color = (nametbl[vdp.name_offset] >> 5) & 0x7;
511      vdp.cg_flag = (nametbl[vdp.name_offset] >> 4) & 0x1;
512      vdp.name_offset += 2;
454      draw_line_bitmap_common(ln);
455      m_bg_color = (readbyte(m_address_regs[2] + m_name_offset) >> 5) & 0x7;
456      m_cg_flag = (readbyte(m_address_regs[2] + m_name_offset) >> 4) & 0x1;
457      m_name_offset += 2;
513458   }
514459   else
515460   {   /* text line */
516      if (vdp.char_line_counter == 0)
517         vdp.char_line_counter = 10;
518      vdp.char_line_counter--;
519      tms3556_draw_line_text_common(ln);
520      if (vdp.char_line_counter == 0)
461      if (m_char_line_counter == 0)
462         m_char_line_counter = 10;
463      m_char_line_counter--;
464      draw_line_text_common(ln);
465      if (m_char_line_counter == 0)
521466      {
522         nametbl = vdp.vram + vdp.addressRegs[2];
523         vdp.bg_color = (nametbl[vdp.name_offset] >> 5) & 0x7;
524         vdp.cg_flag = (nametbl[vdp.name_offset] >> 4) & 0x1;
525         vdp.name_offset += 2;
467         m_bg_color = (readbyte(m_address_regs[2] + m_name_offset) >> 5) & 0x7;
468         m_cg_flag = (readbyte(m_address_regs[2] + m_name_offset) >> 4) & 0x1;
469         m_name_offset += 2;
526470      }
527471   }
528472}
529473
530/*
531    tms3556_draw_line
532474
533    draw a line.  If non-interlaced mode, duplicate the line.
534*/
535static void tms3556_draw_line(bitmap_t *bmp, int line)
475//-------------------------------------------------
476//  draw_line - draw a line. If non-interlaced mode,
477//  duplicate the line.
478//-------------------------------------------------
479
480void tms3556_device::draw_line(bitmap_t *bmp, int line)
536481{
537   int double_lines;
482   int double_lines = 0;
538483   UINT16 *ln, *ln2 = NULL;
539484
540   double_lines = 0;
541
542#if 0
543   if ( vdp.controlRegs[4] & 0x?? )
544   {   // interlaced mode
545      ln = BITMAP_ADDR16(bmp, line, vdp.field);
546   }
547   else
548#endif
485//   if (m_control_regs[4] & 0x??)
486//   {   // interlaced mode
487//      ln = BITMAP_ADDR16(bmp, line, m_field);
488//   }
489//   else
549490   {   /* non-interlaced mode */
550491      ln = BITMAP_ADDR16(bmp, line, 0);
551492      ln2 = BITMAP_ADDR16(bmp, line, 1);
552493      double_lines = 1;
553494   }
554495
555   if ((line < TOP_BORDER) || (line >= (TOP_BORDER + 250)))
556   {   /* draw top and bottom borders */
557      tms3556_draw_line_empty(ln);
496   if ((line < TMS3556_TOP_BORDER) || (line >= (TMS3556_TOP_BORDER + 250)))
497   {
498      /* draw top and bottom borders */
499      draw_line_empty(ln);
558500   }
559501   else
560   {   /* draw useful area */
561      switch (vdp.controlRegs[6] >> 6)
502   {
503      /* draw useful area */
504      switch (m_control_regs[6] >> 6)
562505      {
563506      case TMS3556_MODE_OFF:
564         tms3556_draw_line_empty(ln);
507         draw_line_empty(ln);
565508         break;
566509      case TMS3556_MODE_TEXT:
567         tms3556_draw_line_text(ln);
510         draw_line_text(ln);
568511         break;
569512      case TMS3556_MODE_BITMAP:
570         tms3556_draw_line_bitmap(ln);
513         draw_line_bitmap(ln);
571514         break;
572515      case TMS3556_MODE_MIXED:
573         tms3556_draw_line_mixed(ln);
516         draw_line_mixed(ln);
574517         break;
575518      }
576519   }
577520
578521   if (double_lines)
579      memcpy (ln2, ln, TOTAL_WIDTH*(DOUBLE_WIDTH ? 2 : 1) * 2);
522      memcpy (ln2, ln, TMS3556_TOTAL_WIDTH * (TMS3556_DOUBLE_WIDTH ? 2 : 1) * 2);
580523}
581524
582525
583/*
584    tms3556_interrupt_start_vblank
526//-------------------------------------------------
527//  interrupt_start_vblank - Do vblank-time tasks
528//-------------------------------------------------
585529
586    Do vblank-time tasks
587*/
588static void tms3556_interrupt_start_vblank(void)
530void tms3556_device::interrupt_start_vblank(void)
589531{
590   int i;
591
592
593532   /* at every frame, vdp switches fields */
594   //vdp.field = !vdp.field;
533   //m_field = !m_field;
595534
596535   /* color blinking */
597   if (vdp.blink_count)
598      vdp.blink_count--;
599   if (!vdp.blink_count)
536   if (m_blink_count)
537      m_blink_count--;
538   if (!m_blink_count)
600539   {
601      vdp.blink = !vdp.blink;
602      vdp.blink_count = 60;   /*no idea what the real value is*/
540      m_blink = !m_blink;
541      m_blink_count = 60;   /*no idea what the real value is*/
603542   }
604543   /* reset background color */
605   vdp.bg_color = (vdp.controlRegs[7] >> 5) & 0x7;
544   m_bg_color = (m_control_regs[7] >> 5) & 0x7;
606545   /* reset name offset */
607   vdp.name_offset = 0;
546   m_name_offset = 0;
608547   /* reset character line counter */
609   vdp.char_line_counter = 0;
548   m_char_line_counter = 0;
610549   /* reset c/g flag */
611   vdp.cg_flag = 0;
550   m_cg_flag = 0;
612551   /* reset double height phase flags */
613   for (i=0; i<40; i++)
614      vdp.dbl_h_phase[i] = 0;
552   memset(m_dbl_h_phase, 0, sizeof(m_dbl_h_phase));
615553}
616554
617/*
618    tms3556_interrupt
619555
620    scanline handler
621*/
622void tms3556_interrupt(running_machine &machine)
556//-------------------------------------------------
557//  interrupt - scanline handler
558//-------------------------------------------------
559
560void tms3556_device::interrupt(running_machine &machine)
623561{
624562   /* check for start of vblank */
625   if (vdp.scanline == 310)   /*no idea what the real value is*/
626      tms3556_interrupt_start_vblank();
563   if (m_scanline == 310)   /*no idea what the real value is*/
564      interrupt_start_vblank();
627565
628566   /* render the current line */
629   if ((vdp.scanline >= 0) && (vdp.scanline < TOTAL_HEIGHT))
567   if ((m_scanline >= 0) && (m_scanline < TMS3556_TOTAL_HEIGHT))
630568   {
631569      //if (!video_skip_this_frame())
632         tms3556_draw_line(machine.generic.tmpbitmap, vdp.scanline);
570         draw_line(machine.generic.tmpbitmap, m_scanline);
633571   }
634572
635   if (++vdp.scanline == 313)
636      vdp.scanline = 0;
573   if (++m_scanline == 313)
574      m_scanline = 0;
637575}
638
src/mess/video/tms3556.h
r13270r13271
22    tms3556.h: header file for tms3556.c
33*/
44
5READ8_HANDLER(tms3556_vram_r);
6WRITE8_HANDLER(tms3556_vram_w);
7READ8_HANDLER(tms3556_reg_r);
8WRITE8_HANDLER(tms3556_reg_w);
5#ifndef __TMS3556_H__
6#define __TMS3556_H__
97
10extern void tms3556_init(running_machine &machine, int vram_size);
11extern void tms3556_reset(void);
12extern void tms3556_interrupt(running_machine &machine);
8#include "emu.h"
139
14MACHINE_CONFIG_EXTERN( tms3556 );
10
11///*************************************************************************
12//  MACROS / CONSTANTS
13///*************************************************************************
14
15#define TMS3556_TOP_BORDER 1
16#define TMS3556_BOTTOM_BORDER 1
17#define TMS3556_LEFT_BORDER 8
18#define TMS3556_RIGHT_BORDER 8
19#define TMS3556_TOTAL_WIDTH (320 + TMS3556_LEFT_BORDER + TMS3556_RIGHT_BORDER)
20#define TMS3556_TOTAL_HEIGHT (250 + TMS3556_TOP_BORDER + TMS3556_BOTTOM_BORDER)
21
22/* if DOUBLE_WIDTH set, the horizontal resolution is doubled */
23#define TMS3556_DOUBLE_WIDTH 1
24
25#define TMS3556_MODE_OFF   0
26#define TMS3556_MODE_TEXT   1
27#define TMS3556_MODE_BITMAP   2
28#define TMS3556_MODE_MIXED   3
29
30
31///*************************************************************************
32//  INTERFACE CONFIGURATION MACROS
33///*************************************************************************
34
35#define MCFG_TMS3556_ADD(_tag) \
36MCFG_DEVICE_ADD(_tag, TMS3556, 0) \
37
38
39///*************************************************************************
40//  TYPE DEFINITIONS
41///*************************************************************************
42
43// ======================> tms3556_device
44
45class tms3556_device :   public device_t,
46                  public device_memory_interface
47{
48public:
49    // construction/destruction
50    tms3556_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
51   
52   DECLARE_READ8_MEMBER( vram_r );
53   DECLARE_WRITE8_MEMBER( vram_w );
54   DECLARE_READ8_MEMBER( reg_r );
55   DECLARE_WRITE8_MEMBER( reg_w );
56
57   void interrupt(running_machine &machine);
58   
59protected:
60    // device-level overrides
61    virtual void device_start();
62   
63   // device_config_memory_interface overrides
64   virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
65   
66    // address space configurations
67   const address_space_config      m_space_config;
68   
69   inline UINT8 readbyte(offs_t address);
70   inline void writebyte(offs_t address, UINT8 data);
71   
72   void draw_line_empty(UINT16 *ln);
73   void draw_line_text_common(UINT16 *ln);
74   void draw_line_bitmap_common(UINT16 *ln);
75   void draw_line_text(UINT16 *ln);
76   void draw_line_bitmap(UINT16 *ln);
77   void draw_line_mixed(UINT16 *ln);
78   void draw_line(bitmap_t *bmp, int line);
79   void interrupt_start_vblank(void);
80
81private:
82   // registers
83   UINT8 m_control_regs[8];
84   UINT16 m_address_regs[8];
85   UINT16 m_write_ptr;
86
87   // register interface
88   int m_reg_ptr;
89   int m_reg_access_phase;
90   int m_magical_mystery_flag;
91
92   int m_scanline;            // scanline counter
93   int m_blink, m_blink_count;   // blinking
94   int m_bg_color;            // background color for current line
95   int m_name_offset;         // current offset in name table
96   int m_cg_flag;            // c/g flag (mixed mode only)
97   int m_char_line_counter;   // character line counter (decrements from 10, 0 when we have reached
98                        // last line of character row)
99   int m_dbl_h_phase[40];      // double height phase flags (one per horizontal character position)
100};
101
102
103// device type definition
104extern const device_type TMS3556;
105
106
107#endif
src/mess/drivers/exelv.c
r13270r13271
4949    * everything
5050*/
5151
52#define ADDRESS_MAP_MODERN
53
5254#include "emu.h"
5355#include "deprecat.h"
5456#include "cpu/tms7000/tms7000.h"
5557#include "video/tms3556.h"
5658#include "sound/tms5220.h"
5759#include "audio/spchroms.h"
58/*#include "imagedev/cartslot.h"
59#include "imagedev/cassette.h"*/
60//#include "imagedev/cartslot.h"
61//#include "imagedev/cassette.h"
6062
6163
6264class exelv_state : public driver_device
6365{
6466public:
6567   exelv_state(const machine_config &mconfig, device_type type, const char *tag)
66      : driver_device(mconfig, type, tag) { }
68      : driver_device(mconfig, type, tag),
69        m_maincpu(*this, "maincpu"),
70        m_tms3556(*this, "tms3556"),
71        m_tms5220c(*this, "tms5220c")
72   { }
6773
74   required_device<cpu_device> m_maincpu;
75   required_device<tms3556_device> m_tms3556;
76   required_device<tms5220c_device> m_tms5220c;
77
78   virtual void machine_start();
79   virtual void machine_reset();
80
81   virtual void video_start();
82
83   DECLARE_READ8_MEMBER( mailbox_wx319_r );
84   DECLARE_WRITE8_MEMBER( mailbox_wx318_w );
85   DECLARE_READ8_MEMBER( tms7020_porta_r );
86   DECLARE_WRITE8_MEMBER( tms7020_porta_w );
87   DECLARE_READ8_MEMBER( tms7020_portb_r );
88   DECLARE_WRITE8_MEMBER( tms7020_portb_w );
89   DECLARE_READ8_MEMBER( tms7041_porta_r );
90   DECLARE_WRITE8_MEMBER( tms7041_porta_w );
91   DECLARE_READ8_MEMBER( tms7041_portb_r );
92   DECLARE_WRITE8_MEMBER( tms7041_portb_w );
93   DECLARE_READ8_MEMBER( tms7041_portc_r );
94   DECLARE_WRITE8_MEMBER( tms7041_portc_w );
95   DECLARE_READ8_MEMBER( tms7041_portd_r );
96   DECLARE_WRITE8_MEMBER( tms7041_portd_w );
97
6898   /* tms7020 i/o ports */
6999   UINT8   m_tms7020_porta;
70100   UINT8   m_tms7020_portb;
r13270r13271
81111};
82112
83113
84/*
85    video initialization
86*/
87static VIDEO_START( exelv )
88{
89   VIDEO_START_CALL( generic_bitmapped );
90   tms3556_init(machine, /*0x8000*/0x10000);   /* tms3556 with 32 kb of video RAM */
91}
92
93
94static MACHINE_RESET( exelv )
95{
96   static const spchroms_interface exelv_speech_intf = { "tms5220c" };
97
98   tms3556_reset();
99   spchroms_config( machine, &exelv_speech_intf );
100   memory_set_bankptr( machine, "bank1", machine.region("user1")->base() + 0x0200 );
101}
102
103114static INTERRUPT_GEN( exelv_hblank_interrupt )
104115{
105   tms3556_interrupt(device->machine());
116   exelv_state *exelv = device->machine().driver_data<exelv_state>();
117   exelv->m_tms3556->interrupt(device->machine());
106118}
107119
108120#ifdef UNUSED_FUNCTION
r13270r13271
191203*/
192204
193205
194static READ8_HANDLER(mailbox_wx319_r)
206READ8_MEMBER(exelv_state::mailbox_wx319_r)
195207{
196   exelv_state *state = space->machine().driver_data<exelv_state>();
197   return state->m_wx319;
208   return m_wx319;
198209}
199210
200211
201static WRITE8_HANDLER(mailbox_wx318_w)
212WRITE8_MEMBER(exelv_state::mailbox_wx318_w)
202213{
203   exelv_state *state = space->machine().driver_data<exelv_state>();
204214   logerror("wx318 write 0x%02x\n", data);
205
206   state->m_wx318 = data;
215   m_wx318 = data;
207216}
208217
209218
r13270r13271
218227    A6 -
219228    A7 -
220229*/
221static READ8_HANDLER(tms7020_porta_r)
230READ8_MEMBER(exelv_state::tms7020_porta_r)
222231{
223   exelv_state *state = space->machine().driver_data<exelv_state>();
224232   logerror("tms7020_porta_r\n");
225
226   return ( state->m_tms7041_portb & 0x80 ) ? 0x01 : 0x00;
233   return ( m_tms7041_portb & 0x80 ) ? 0x01 : 0x00;
227234}
228235
229236
230static WRITE8_HANDLER(tms7020_porta_w)
237WRITE8_MEMBER(exelv_state::tms7020_porta_w)
231238{
232   exelv_state *state = space->machine().driver_data<exelv_state>();
233239   logerror("tms7020_porta_w: data = 0x%02x\n", data);
234
235   state->m_tms7020_porta = data;
240   m_tms7020_porta = data;
236241}
237242
238243
r13270r13271
247252    B6 -
248253    B7 -
249254*/
250static READ8_HANDLER(tms7020_portb_r)
255READ8_MEMBER(exelv_state::tms7020_portb_r)
251256{
252257   logerror("tms7020_portb_r\n");
253
254258   return 0x00;
255259}
256260
257261
258static WRITE8_HANDLER(tms7020_portb_w)
262WRITE8_MEMBER(exelv_state::tms7020_portb_w)
259263{
260   exelv_state *state = space->machine().driver_data<exelv_state>();
261264   logerror("tms7020_portb_w: data = 0x%02x\n", data);
262
263   state->m_tms7020_portb = data;
265   m_tms7020_portb = data;
264266}
265267
266268
r13270r13271
275277    A6 - X1 SCLK A9
276278    A7 - TMS5220 RDY
277279*/
278static READ8_HANDLER(tms7041_porta_r)
280READ8_MEMBER(exelv_state::tms7041_porta_r)
279281{
280   exelv_state *state = space->machine().driver_data<exelv_state>();
281   device_t *tms5220c = space->machine().device( "tms5220c" );
282282   UINT8 data = 0x00;
283283
284284   logerror("tms7041_porta_r\n");
285285
286   data |= ( state->m_tms7020_portb & 0x01 ) ? 0x04 : 0x00;
287   data |= tms5220_intq_r( tms5220c ) ? 0x08 : 0x00;
288   data |= ( state->m_tms7020_portb & 0x02 ) ? 0x10 : 0x00;
289   data |= tms5220_readyq_r( tms5220c ) ? 0x80 : 0x00;
286   data |= (m_tms7020_portb & 0x01 ) ? 0x04 : 0x00;
287   data |= tms5220_intq_r(m_tms5220c) ? 0x08 : 0x00;
288   data |= (m_tms7020_portb & 0x02) ? 0x10 : 0x00;
289   data |= tms5220_readyq_r(m_tms5220c) ? 0x80 : 0x00;
290290
291291   return data;
292292}
293293
294294
295static WRITE8_HANDLER(tms7041_porta_w)
295WRITE8_MEMBER(exelv_state::tms7041_porta_w)
296296{
297   exelv_state *state = space->machine().driver_data<exelv_state>();
298297   logerror("tms7041_porta_w: data = 0x%02x\n", data);
299
300   state->m_tms7041_porta = data;
298   m_tms7041_porta = data;
301299}
302300
303301
r13270r13271
312310    B6 - W - REV6 WX319-11
313311    B7 - W - TMS7020 port A bit 0 (REV3)
314312*/
315static READ8_HANDLER(tms7041_portb_r)
313READ8_MEMBER(exelv_state::tms7041_portb_r)
316314{
317   UINT8 data = 0xFF;
318
315   UINT8 data = 0xff;
319316   logerror("tms7041_portb_r\n");
320
321317   return data;
322318}
323319
324320
325static WRITE8_HANDLER(tms7041_portb_w)
321WRITE8_MEMBER(exelv_state::tms7041_portb_w)
326322{
327   exelv_state *state = space->machine().driver_data<exelv_state>();
328   device_t *tms5220c = space->machine().device( "tms5220c" );
329
330323   logerror("tms7041_portb_w: data = 0x%02x\n", data);
331324
332   tms5220_wsq_w( tms5220c, ( data & 0x01 ) ? 1 : 0 );
333   tms5220_rsq_w( tms5220c, ( data & 0x02 ) ? 1 : 0 );
325   tms5220_wsq_w(m_tms5220c, (data & 0x01) ? 1 : 0);
326   tms5220_rsq_w(m_tms5220c, (data & 0x02) ? 1 : 0);
334327
335   cputag_set_input_line(space->machine(), "maincpu", TMS7000_IRQ1_LINE, ( data & 0x04 ) ? CLEAR_LINE : ASSERT_LINE);
328   device_set_input_line(m_maincpu, TMS7000_IRQ1_LINE, (data & 0x04) ? CLEAR_LINE : ASSERT_LINE);
336329
337330   /* Check for low->high transition on B6 */
338   if ( ! ( state->m_tms7041_portb & 0x40 ) && ( data & 0x40 ) )
331   if (!(m_tms7041_portb & 0x40) && (data & 0x40))
339332   {
340      logerror("wx319 write 0x%02x\n", state->m_tms7041_portc);
341      state->m_wx319 = state->m_tms7041_portc;
333      logerror("wx319 write 0x%02x\n", m_tms7041_portc);
334      m_wx319 = m_tms7041_portc;
342335   }
343336
344   state->m_tms7041_portb = data;
337   m_tms7041_portb = data;
345338}
346339
347340
348341/*
349342    TMS7041 PORT C - connected to mailbox WX318 and WX319 data bits
350343*/
351static READ8_HANDLER(tms7041_portc_r)
344READ8_MEMBER(exelv_state::tms7041_portc_r)
352345{
353   exelv_state *state = space->machine().driver_data<exelv_state>();
354   UINT8 data = 0xFF;
355
346   UINT8 data = 0xff;
356347   logerror("tms7041_portc_r\n");
357348
358349   /* Check if wx318 output is enabled */
359   if ( ! ( state->m_tms7041_portb & 0x20 ) )
360   {
361      data = state->m_wx318;
362   }
350   if (!(m_tms7041_portb & 0x20))
351      data = m_wx318;
363352
364353   return data;
365354}
366355
367356
368static WRITE8_HANDLER(tms7041_portc_w)
357WRITE8_MEMBER(exelv_state::tms7041_portc_w)
369358{
370   exelv_state *state = space->machine().driver_data<exelv_state>();
371359   logerror("tms7041_portc_w: data = 0x%02x\n", data);
372
373   state->m_tms7041_portc = data;
360   m_tms7041_portc = data;
374361}
375362
376363
r13270r13271
385372    D6 - TMS5220 D1
386373    D7 - TMS5220 D0
387374*/
388static READ8_HANDLER(tms7041_portd_r)
375READ8_MEMBER(exelv_state::tms7041_portd_r)
389376{
390   UINT8 data = 0xFF;
391
377   UINT8 data = 0xff;
392378   logerror("tms7041_portd_r\n");
393
394379   return data;
395380}
396381
397382
398static WRITE8_HANDLER(tms7041_portd_w)
383WRITE8_MEMBER(exelv_state::tms7041_portd_w)
399384{
400   exelv_state *state = space->machine().driver_data<exelv_state>();
401   device_t *tms5220c = space->machine().device( "tms5220c" );
402
403385   logerror("tms7041_portd_w: data = 0x%02x\n", data);
404386
405   tms5220_data_w( tms5220c, 0, BITSWAP8(data,0,1,2,3,4,5,6,7) );
406
407   state->m_tms7041_portd = data;
387   tms5220_data_w(m_tms5220c, 0, BITSWAP8(data,0,1,2,3,4,5,6,7));
388   m_tms7041_portd = data;
408389}
409390
410391/*
r13270r13271
432413    @>f800-@>ffff: tms7020/tms7040 internal ROM
433414*/
434415
435static ADDRESS_MAP_START(tms7020_mem, AS_PROGRAM, 8)
416static ADDRESS_MAP_START(tms7020_mem, AS_PROGRAM, 8, exelv_state)
436417   //AM_RANGE(0x0000, 0x007f) AM_READWRITE(tms7000_internal_r, tms7000_internal_w)/* tms7020 internal RAM */
437418   AM_RANGE(0x0080, 0x00ff) AM_NOP
438419   //AM_RANGE(0x0100, 0x010b) AM_READWRITE(tms70x0_pf_r, tms70x0_pf_w)/* tms7020 internal I/O ports */
439420   //AM_RANGE(0x010c, 0x01ff) AM_READWRITE(SMH_NOP, SMH_NOP)     /* external I/O ports */
440   AM_RANGE(0x012d, 0x0012d) AM_READWRITE(tms3556_reg_r/*right???*/, tms3556_reg_w)
441   AM_RANGE(0x012e, 0x0012e) AM_READWRITE(tms3556_vram_r/*right???*/, tms3556_vram_w)
421   AM_RANGE(0x012d, 0x0012d) AM_DEVREADWRITE("tms3556", tms3556_device, reg_r/*right???*/, reg_w)
422   AM_RANGE(0x012e, 0x0012e) AM_DEVREADWRITE("tms3556", tms3556_device, vram_r/*right???*/, vram_w)
442423   AM_RANGE(0x0130, 0x00130) AM_READWRITE(mailbox_wx319_r, mailbox_wx318_w)
443424   AM_RANGE(0x0200, 0x7fff) AM_ROMBANK("bank1")                        /* system ROM */
444425   AM_RANGE(0x8000, 0xbfff) AM_NOP
r13270r13271
448429ADDRESS_MAP_END
449430
450431
451static ADDRESS_MAP_START(tms7020_port, AS_IO, 8)
432static ADDRESS_MAP_START(tms7020_port, AS_IO, 8, exelv_state)
452433   AM_RANGE(TMS7000_PORTA, TMS7000_PORTA) AM_READWRITE(tms7020_porta_r, tms7020_porta_w)
453434   AM_RANGE(TMS7000_PORTB, TMS7000_PORTB) AM_READWRITE(tms7020_portb_r, tms7020_portb_w)
454435ADDRESS_MAP_END
455436
456437
457static ADDRESS_MAP_START(tms7041_map, AS_PROGRAM, 8)
438static ADDRESS_MAP_START(tms7041_map, AS_PROGRAM, 8, exelv_state)
458439   AM_RANGE(0xf000, 0xffff) AM_ROM AM_REGION("tms7041",0x0000)
459440ADDRESS_MAP_END
460441
461442
462static ADDRESS_MAP_START(tms7041_port, AS_IO, 8)
443static ADDRESS_MAP_START(tms7041_port, AS_IO, 8, exelv_state)
463444   AM_RANGE(TMS7000_PORTA, TMS7000_PORTA)   AM_READWRITE(tms7041_porta_r, tms7041_porta_w)
464445   AM_RANGE(TMS7000_PORTB, TMS7000_PORTB)   AM_READWRITE(tms7041_portb_r, tms7041_portb_w)
465446   AM_RANGE(TMS7000_PORTC, TMS7000_PORTC)   AM_READWRITE(tms7041_portc_r, tms7041_portc_w)
r13270r13271
467448ADDRESS_MAP_END
468449
469450
470static ADDRESS_MAP_START(tms7040_mem, AS_PROGRAM, 8)
451static ADDRESS_MAP_START(tms7040_mem, AS_PROGRAM, 8, exelv_state)
471452   //AM_RANGE(0x0000, 0x007f) AM_READWRITE(tms7000_internal_r, tms7000_internal_w)/* tms7040 internal RAM */
472453   AM_RANGE(0x0080, 0x00ff) AM_NOP
473454   //AM_RANGE(0x0100, 0x010b) AM_READWRITE(tms70x0_pf_r, tms70x0_pf_w)/* tms7020 internal I/O ports */
474455   //AM_RANGE(0x010c, 0x01ff) AM_READWRITE(SMH_NOP, SMH_NOP)     /* external I/O ports */
475   AM_RANGE(0x012d, 0x0012d) AM_READWRITE(tms3556_reg_r/*right???*/, tms3556_reg_w)
476   AM_RANGE(0x012e, 0x0012e) AM_READWRITE(tms3556_vram_r/*right???*/, tms3556_vram_w)
456   AM_RANGE(0x012d, 0x0012d) AM_DEVREADWRITE("tms3556", tms3556_device, reg_r/*right???*/, reg_w)
457   AM_RANGE(0x012e, 0x0012e) AM_DEVREADWRITE("tms3556", tms3556_device, vram_r/*right???*/, vram_w)
477458   AM_RANGE(0x0130, 0x00130) AM_READWRITE(mailbox_wx319_r, mailbox_wx318_w)
478459   AM_RANGE(0x0200, 0x7fff) AM_ROMBANK("bank1")                        /* system ROM */
479460   AM_RANGE(0x8000, 0xbfff) AM_NOP
r13270r13271
483464ADDRESS_MAP_END
484465
485466
486static ADDRESS_MAP_START(tms7042_map, AS_PROGRAM, 8)
467static ADDRESS_MAP_START(tms7042_map, AS_PROGRAM, 8, exelv_state)
487468   AM_RANGE(0xe000, 0xefff) AM_ROM AM_REGION("tms7042",0x0000)
488469    AM_RANGE(0xf000, 0xffff) AM_ROM AM_REGION("tms7042",0x0000)      /* Duplicated until a proper dump surfaces */
489470ADDRESS_MAP_END
r13270r13271
507488};
508489
509490
491static PALETTE_INIT( exelv )
492{
493   int   i, red, green, blue;
494   
495   /* create the 8 color palette */
496   for (i = 0; i < 8; i++)
497   {
498      red = (i & 1) ? 255 : 0;   /* red */
499      green = (i & 2) ? 255 : 0;   /* green */
500      blue = (i & 4) ? 255 : 0;   /* blue */
501      palette_set_color_rgb(machine, i, red, green, blue);
502   }
503}
504
505
506/* Video Initialization  */
507
508void exelv_state::video_start()
509{
510   video_start_generic_bitmapped(machine());
511}
512
513
514/* Machine Initialization */
515
516void exelv_state::machine_start()
517{
518   UINT8 *rom = machine().region("user1")->base();
519   memory_configure_bank(machine(), "bank1", 0, 1, rom, 0x8000 - 0x200);
520   memory_set_bank(machine(), "bank1", 0);
521   
522   /* register for state saving */
523   state_save_register_global(machine(), m_tms7020_porta);
524   state_save_register_global(machine(), m_tms7020_portb);
525   state_save_register_global(machine(), m_tms7041_porta);
526   state_save_register_global(machine(), m_tms7041_portb);
527   state_save_register_global(machine(), m_tms7041_portc);
528   state_save_register_global(machine(), m_tms7041_portd);
529   state_save_register_global(machine(), m_wx318);
530   state_save_register_global(machine(), m_wx319);
531}
532
533void exelv_state::machine_reset()
534{
535   static const spchroms_interface exelv_speech_intf = {"tms5220c"};
536   spchroms_config(machine(), &exelv_speech_intf);
537}
538
510539static MACHINE_CONFIG_START( exl100, exelv_state )
511540   /* basic machine hardware */
512541   MCFG_CPU_ADD("maincpu", TMS7000_EXL, XTAL_4_9152MHz)   /* TMS7020 */
r13270r13271
521550   MCFG_QUANTUM_PERFECT_CPU("maincpu")
522551   MCFG_QUANTUM_PERFECT_CPU("tms7041")
523552
524   MCFG_MACHINE_RESET( exelv )
553   MCFG_TMS3556_ADD("tms3556")
525554
526555   /* video hardware */
527   MCFG_FRAGMENT_ADD(tms3556)
556   MCFG_SCREEN_ADD("screen", RASTER)
557   MCFG_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
558   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
559#if TMS3556_DOUBLE_WIDTH
560   MCFG_SCREEN_SIZE(TMS3556_TOTAL_WIDTH*2, TMS3556_TOTAL_HEIGHT*2)
561   MCFG_SCREEN_VISIBLE_AREA(0, TMS3556_TOTAL_WIDTH*2-1, 0, TMS3556_TOTAL_HEIGHT*2-1)
562#else
563   MCFG_SCREEN_SIZE(TMS3556_TOTAL_WIDTH, TMS3556_TOTAL_HEIGHT*2)
564   MCFG_SCREEN_VISIBLE_AREA(0, TMS3556_TOTAL_WIDTH-1, 0, TMS3556_TOTAL_HEIGHT*2-1)
565#endif
566   MCFG_SCREEN_UPDATE(generic_bitmapped)
567   MCFG_PALETTE_LENGTH(8)
568   MCFG_PALETTE_INIT(exelv)
528569
529   MCFG_SCREEN_MODIFY("screen")
530570   MCFG_SCREEN_REFRESH_RATE(50)
531571   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
532572
533   MCFG_VIDEO_START(exelv)
534
535573   /* sound */
536574   MCFG_SPEAKER_STANDARD_MONO("mono")
537575   MCFG_SOUND_ADD("tms5220c", TMS5220C, 640000)
r13270r13271
554592   MCFG_QUANTUM_PERFECT_CPU("maincpu")
555593   MCFG_QUANTUM_PERFECT_CPU("tms7042")
556594
557   MCFG_MACHINE_RESET( exelv )
595   MCFG_TMS3556_ADD("tms3556")
558596
559597   /* video hardware */
560   MCFG_FRAGMENT_ADD(tms3556)
598   MCFG_SCREEN_ADD("screen", RASTER)
599   MCFG_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
600   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
601#if TMS3556_DOUBLE_WIDTH
602   MCFG_SCREEN_SIZE(TMS3556_TOTAL_WIDTH*2, TMS3556_TOTAL_HEIGHT*2)
603   MCFG_SCREEN_VISIBLE_AREA(0, TMS3556_TOTAL_WIDTH*2-1, 0, TMS3556_TOTAL_HEIGHT*2-1)
604#else
605   MCFG_SCREEN_SIZE(TMS3556_TOTAL_WIDTH, TMS3556_TOTAL_HEIGHT*2)
606   MCFG_SCREEN_VISIBLE_AREA(0, TMS3556_TOTAL_WIDTH-1, 0, TMS3556_TOTAL_HEIGHT*2-1)
607#endif
608   MCFG_SCREEN_UPDATE(generic_bitmapped)
609   MCFG_PALETTE_LENGTH(8)
610   MCFG_PALETTE_INIT(exelv)
561611
562   MCFG_SCREEN_MODIFY("screen")
563612   MCFG_SCREEN_REFRESH_RATE(50)
564613   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
565614
566   MCFG_VIDEO_START(exelv)
567
568615   /* sound */
569616   MCFG_SPEAKER_STANDARD_MONO("mono")
570617   MCFG_SOUND_ADD("tms5220c", TMS5220C, 640000)
r13270r13271
610657ROM_END
611658
612659
613/*      YEAR    NAME    PARENT      COMPAT  MACHINE     INPUT   INIT    COMPANY         FULLNAME */
614COMP(   1984,   exl100, 0,          0,      exl100,     exelv,  0,      "Exelvision",   "EXL 100" , GAME_NOT_WORKING)
615COMP(   1986,   exeltel,exl100,     0,      exeltel,   exelv,   0,      "Exelvision",   "Exeltel" , GAME_NOT_WORKING)
660/*   YEAR   NAME     PARENT      COMPAT  MACHINE     INPUT   INIT    COMPANY         FULLNAME */
661COMP(1984,   exl100,  0,          0,      exl100,     exelv,  0,        "Exelvision",   "EXL 100",  GAME_NOT_WORKING)
662COMP(1986,   exeltel, exl100,     0,      exeltel,    exelv,  0,        "Exelvision",   "Exeltel",  GAME_NOT_WORKING)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team