Previous 15994 Revisions Next

r10257 Tuesday 1st February, 2011 at 11:41:44 UTC by Sandro Ronco
Class declaration cleanup, for respect the coding conventions
[src/mess/drivers]pro80.c psion.c
[src/mess/includes]psion.h ti89.h
[src/mess/video]ef9345.c ef9345.h hd44352.c hd44352.h hd44780.c hd44780.h

src/mess/video/hd44352.h
r10256r10257
8181   static const device_timer_id ON_TIMER = 1;
8282   emu_timer *m_on_timer;
8383
84   UINT8 video_ram[2][0x180];
85   UINT8 control_lines;
86   UINT8 data_bus;
87   UINT8 par[3];
88   UINT8 state;
89   UINT16 bank;
90   UINT16 offset;
91   UINT8 char_width;
92   UINT8 lcd_on;
93   UINT8 scroll;
94   UINT32 contrast;
84   UINT8 m_video_ram[2][0x180];
85   UINT8 m_control_lines;
86   UINT8 m_data_bus;
87   UINT8 m_par[3];
88   UINT8 m_state;
89   UINT16 m_bank;
90   UINT16 m_offset;
91   UINT8 m_char_width;
92   UINT8 m_lcd_on;
93   UINT8 m_scroll;
94   UINT32 m_contrast;
9595
96   UINT8 custom_char[4][8];      // 4 chars * 8 bytes
97   UINT8 byte_count;
98   UINT8 cursor_status;
99   UINT8 cursor[8];
100   UINT8 cursor_x;
101   UINT8 cursor_y;
102   UINT8 cursor_lcd;
96   UINT8 m_custom_char[4][8];      // 4 chars * 8 bytes
97   UINT8 m_byte_count;
98   UINT8 m_cursor_status;
99   UINT8 m_cursor[8];
100   UINT8 m_cursor_x;
101   UINT8 m_cursor_y;
102   UINT8 m_cursor_lcd;
103103
104104   devcb_resolved_write_line m_on;         // ON line callback
105105   const hd44352_device_config &m_config;
src/mess/video/hd44780.c
r10256r10257
77        - 5x10 chars
88        - dump internal CGROM
99
10      HACKS:
11      - A00 10 bit chars are tacked onto recreated chrrom at $700 (until internal rom is dumped)
12      - A00/A02 drawing selected by sizeof romfile, A02 is $800, A00 is $860
10        HACKS:
11        - A00 10 bit chars are tacked onto recreated chrrom at $700 (until internal rom is dumped)
12        - A00/A02 drawing selected by sizeof romfile, A02 is $800, A00 is $860
1313
1414***************************************************************************/
1515
r10256r10257
116116
117117   timer_adjust_periodic(m_blink_timer, ATTOTIME_IN_MSEC(409), 0, ATTOTIME_IN_MSEC(409));
118118
119   state_save_register_device_item( this, 0, ac);
120   state_save_register_device_item( this, 0, ac_mode);
121   state_save_register_device_item( this, 0, data_bus_flag);
122   state_save_register_device_item( this, 0, cursor_pos);
123   state_save_register_device_item( this, 0, display_on);
124   state_save_register_device_item( this, 0, cursor_on);
125   state_save_register_device_item( this, 0, shift_on);
126   state_save_register_device_item( this, 0, blink_on);
127   state_save_register_device_item( this, 0, direction);
128   state_save_register_device_item( this, 0, data_len);
129   state_save_register_device_item( this, 0, n_line);
130   state_save_register_device_item( this, 0, char_size);
119   state_save_register_device_item( this, 0, m_ac);
120   state_save_register_device_item( this, 0, m_ac_mode);
121   state_save_register_device_item( this, 0, m_data_bus_flag);
122   state_save_register_device_item( this, 0, m_cursor_pos);
123   state_save_register_device_item( this, 0, m_display_on);
124   state_save_register_device_item( this, 0, m_cursor_on);
125   state_save_register_device_item( this, 0, m_shift_on);
126   state_save_register_device_item( this, 0, m_blink_on);
127   state_save_register_device_item( this, 0, m_direction);
128   state_save_register_device_item( this, 0, m_data_len);
129   state_save_register_device_item( this, 0, m_num_line);
130   state_save_register_device_item( this, 0, m_char_size);
131131   state_save_register_device_item( this, 0, disp_shift);
132   state_save_register_device_item( this, 0, blink);
133   state_save_register_device_item_array( this, 0, ddram);
134   state_save_register_device_item_array( this, 0, cgram);
132   state_save_register_device_item( this, 0, m_blink);
133   state_save_register_device_item_array( this, 0, m_ddram);
134   state_save_register_device_item_array( this, 0, m_cgram);
135135
136136}
137137
r10256r10257
142142
143143void hd44780_device::device_reset()
144144{
145   busy_flag = 0;
145   m_busy_flag = 0;
146146
147   memset(ddram, 0x20, ARRAY_LENGTH(ddram)); // can't use 0 here as it would show CGRAM instead of blank space on a soft reset
148   memset(cgram, 0, ARRAY_LENGTH(cgram));
149   ac = 0;
150   ac_mode = 0;
151   data_bus_flag = 0;
152   cursor_pos = 0;
153   display_on = 0;
154   cursor_on = 0;
155   shift_on = 0;
156   blink_on = 0;
157   direction = 1;
158   data_len = -1; // must not be 0 or 1 on intial start to pick up first 4/8 bit mode change
159   n_line = 0;
160   char_size = 0;
147   memset(m_ddram, 0x20, sizeof(m_ddram)); // can't use 0 here as it would show CGRAM instead of blank space on a soft reset
148   memset(m_cgram, 0, sizeof(m_cgram));
149   m_ac = 0;
150   m_ac_mode = 0;
151   m_data_bus_flag = 0;
152   m_cursor_pos = 0;
153   m_display_on = 0;
154   m_cursor_on = 0;
155   m_shift_on = 0;
156   m_blink_on = 0;
157   m_direction = 1;
158   m_data_len = -1; // must not be 0 or 1 on intial start to pick up first 4/8 bit mode change
159   m_num_line = 0;
160   m_char_size = 0;
161161   disp_shift = 0;
162   blink = 0;
162   m_blink = 0;
163163
164164   set_busy_flag(1520);
165165}
r10256r10257
173173   switch(id)
174174   {
175175      case BUSY_TIMER:
176         busy_flag = 0;
176         m_busy_flag = 0;
177177         break;
178178
179179      case BLINKING_TIMER:
180         blink = !blink;
180         m_blink = !m_blink;
181181         break;
182182   }
183183}
184184
185185void hd44780_device::set_busy_flag(UINT16 usec)
186186{
187   busy_flag = 1;
187   m_busy_flag = 1;
188188
189189   timer_adjust_oneshot( m_busy_timer, ATTOTIME_IN_USEC( usec ), 0 );
190190
r10256r10257
200200
201201   bitmap_fill(bitmap, cliprect, 0);
202202
203   if (display_on)
203   if (m_display_on)
204204      for (int l=0; l<m_config.height; l++)
205205         for (int i=0; i<m_config.width; i++)
206206         {
207207            UINT8 line_base = l * 0x40;
208            UINT8 line_size = (n_line) ? 40 : 80;
208            UINT8 line_size = (m_num_line) ? 40 : 80;
209209            INT8 char_pos = line_base + i;
210210
211211            // if specified uses the custom layout
r10256r10257
225225            }
226226            for (int y=0; y<8; y++)
227227               for (int x=0; x<5; x++)
228                  if (ddram[char_pos] <= 0x10)
228                  if (m_ddram[char_pos] <= 0x10)
229229                  {
230230                     //draw CGRAM characters
231                     *BITMAP_ADDR16(bitmap, l*9 + y, i*6 + x) = BIT(cgram[(ddram[char_pos]&0x07)*8+y], 4-x);
231                     *BITMAP_ADDR16(bitmap, l*9 + y, i*6 + x) = BIT(m_cgram[(m_ddram[char_pos]&0x07)*8+y], 4-x);
232232                  }
233233                  else
234234                  {
235235                     //draw CGROM characters
236                     if (region()->bytes() <= 0x800) {
237                        *BITMAP_ADDR16(bitmap, l*9 + y, i*6 + x) = BIT(region()->u8(ddram[char_pos]*8+y), 4-x);
238                     } else {
239                        if(ddram[char_pos] < 0xe0) {
240                           *BITMAP_ADDR16(bitmap, l*9 + y, i*6 + x) = BIT(region()->u8(ddram[char_pos]*8+y), 4-x);
241                        } else {
242                           *BITMAP_ADDR16(bitmap, l*9 + y, i*6 + x) = BIT(region()->u8(0x700+((ddram[char_pos]-0xe0)*11)+y), 4-x);
243                        }
236                     if (region()->bytes() <= 0x800)
237                     {
238                        *BITMAP_ADDR16(bitmap, l*9 + y, i*6 + x) = BIT(region()->u8(m_ddram[char_pos]*8+y), 4-x);
244239                     }
240                     else
241                     {
242                        if(m_ddram[char_pos] < 0xe0)
243                           *BITMAP_ADDR16(bitmap, l*9 + y, i*6 + x) = BIT(region()->u8(m_ddram[char_pos]*8+y), 4-x);
244                        else
245                           *BITMAP_ADDR16(bitmap, l*9 + y, i*6 + x) = BIT(region()->u8(0x700+((m_ddram[char_pos]-0xe0)*11)+y), 4-x);
246                     }
245247                  }
246248
247249            // if is the correct position draw cursor and blink
248            if (char_pos == cursor_pos)
250            if (char_pos == m_cursor_pos)
249251            {
250252               //draw the cursor
251               if (cursor_on)
253               if (m_cursor_on)
252254                  for (int x=0; x<5; x++)
253255                     *BITMAP_ADDR16(bitmap, l*9 + 7, i * 6 + x) = 1;
254256
255               if (!blink && blink_on)
257               if (!m_blink && m_blink_on)
256258                  for (int y=0; y<7; y++)
257259                     for (int x=0; x<5; x++)
258260                        *BITMAP_ADDR16(bitmap, l*9 + y, i * 6 + x) = 1;
r10256r10257
265267
266268void hd44780_device::control_write(offs_t offset, UINT8 data)
267269{
268   if (busy_flag)
269   {
270      logerror("HD44780 '%s' Instruction %02x refused due of busy flag\n", tag(), data);
271      return;
272   }
273
274270   if (BIT(data, 7)) // Set DDRAM Address
275271   {
276      ac_mode = 0;
277      ac = data & 0x7f;
272      m_ac_mode = 0;
273      m_ac = data & 0x7f;
278274      if (data != 0x81) // not in datasheet spec
279         cursor_pos = ac;
275         m_cursor_pos = m_ac;
280276      set_busy_flag(37);
281277   }
282278   else if (BIT(data, 6)) // Set CGRAM Address
283279   {
284      ac_mode = 1;
285      ac = data & 0x3f;
280      m_ac_mode = 1;
281      m_ac = data & 0x3f;
286282      set_busy_flag(37);
287283   }
288284   else if (BIT(data, 5)) // Function Set
289285   {
290286      // datasheet says you can't change char size after first function set without altering 4/8 bit mode
291      if (BIT(data, 4) != data_len) {
292         char_size = BIT(data, 2);
293      }
294      data_len = BIT(data, 4);
295      n_line = BIT(data, 3);
287      if (BIT(data, 4) != m_data_len)
288         m_char_size = BIT(data, 2);
289
290      m_data_len = BIT(data, 4);
291      m_num_line = BIT(data, 3);
296292      set_busy_flag(37);
297293   }
298294   else if (BIT(data, 4)) // Cursor or display shift
r10256r10257
303299         disp_shift += direct;
304300      else
305301      {
306         ac += direct;
307         cursor_pos += direct;
302         m_ac += direct;
303         m_cursor_pos += direct;
308304      }
309305
310306      set_busy_flag(37);
311307   }
312308   else if (BIT(data, 3)) // Display on/off Control
313309   {
314      display_on = BIT(data, 2);
315      cursor_on = BIT(data, 1);
316      blink_on = BIT(data, 0);
310      m_display_on = BIT(data, 2);
311      m_cursor_on = BIT(data, 1);
312      m_blink_on = BIT(data, 0);
317313
318314      set_busy_flag(37);
319315   }
320316   else if (BIT(data, 2)) // Entry Mode set
321317   {
322      direction = (BIT(data, 1)) ? +1 : -1;
318      m_direction = (BIT(data, 1)) ? +1 : -1;
323319
324      shift_on = BIT(data, 0);
320      m_shift_on = BIT(data, 0);
325321
326322      set_busy_flag(37);
327323   }
328324   else if (BIT(data, 1)) // return home
329325   {
330      ac = 0;
331      cursor_pos = 0;
332      ac_mode = 0; // datasheet does not specifically say this but mephisto won't run without it
333      direction = 1;
326      m_ac = 0;
327      m_cursor_pos = 0;
328      m_ac_mode = 0; // datasheet does not specifically say this but mephisto won't run without it
329      m_direction = 1;
334330      disp_shift = 0;
335331      set_busy_flag(1520);
336332   }
337333   else if (BIT(data, 0)) // clear display
338334   {
339      ac = 0;
340      cursor_pos = 0;
341      ac_mode = 0;
342      direction = 1;
335      m_ac = 0;
336      m_cursor_pos = 0;
337      m_ac_mode = 0;
338      m_direction = 1;
343339      disp_shift = 0;
344      memset(ddram, 0x20, ARRAY_LENGTH(ddram));
345      // nothing in datasheet says to clear CGRAM
346      // memset(cgram, 0x20, ARRAY_LENGTH(cgram));
340      memset(m_ddram, 0x20, sizeof(m_ddram));
347341      set_busy_flag(1520);
348342   }
349343}
350344
351345UINT8 hd44780_device::control_read(offs_t offset)
352346{
353   return busy_flag<<7 || ac&0x7f;
347   return m_busy_flag<<7 || m_ac&0x7f;
354348}
355349
356void hd44780_device::update_ac(void) // data_bus_flag was left as global so old savestates will work
350void hd44780_device::update_ac(void) // m_data_bus_flag was left as global so old savestates will work
357351{
358int new_ac = ac + direction;
359ac = (new_ac < 0) ? 0 : ((new_ac > 0x7f) ? 0x7f : new_ac);
360if (ac_mode == 0) {
361   cursor_pos = ac;
362   // display is shifted only after a write
363   if (shift_on && data_bus_flag == 1)   disp_shift += direction;
352   int new_ac = m_ac + m_direction;
353   m_ac = (new_ac < 0) ? 0 : ((new_ac > 0x7f) ? 0x7f : new_ac);
354   if (m_ac_mode == 0)
355   {
356      m_cursor_pos = m_ac;
357      // display is shifted only after a write
358      if (m_shift_on && m_data_bus_flag == 1)   disp_shift += m_direction;
359   }
360   m_data_bus_flag = 0;
364361}
365   data_bus_flag = 0;
366}
367362
368363
369364void hd44780_device::data_write(offs_t offset, UINT8 data)
370365{
371   if (busy_flag)
366   if (m_busy_flag)
372367   {
373368      logerror("HD44780 '%s' Ignoring data write %02x due of busy flag\n", tag(), data);
374369      return;
375370   }
376371
377   if (ac_mode == 0) ddram[ac] = data;
378   else cgram[ac] = data;
379   data_bus_flag = 1;
372   if (m_ac_mode == 0) m_ddram[m_ac] = data;
373   else m_cgram[m_ac] = data;
374   m_data_bus_flag = 1;
380375   update_ac();
381376   set_busy_flag(41);
382377}
r10256r10257
385380{
386381   UINT8 data;
387382
388   if (ac_mode == 0)
389      data = ddram[ac];
390   else {
391      data = cgram[ac];
392   }
383   if (m_ac_mode == 0)
384      data = m_ddram[m_ac];
385   else
386      data = m_cgram[m_ac];
393387
394   data_bus_flag = 2;
388   m_data_bus_flag = 2;
395389   update_ac();
396390
397391   set_busy_flag(41);
src/mess/video/hd44780.h
r10256r10257
8888   emu_timer *m_blink_timer;
8989   emu_timer *m_busy_timer;
9090
91   UINT8 busy_flag;
91   UINT8 m_busy_flag;
9292
93   UINT8 ddram[0x80];   //internal display data RAM
94   UINT8 cgram[0x40];   //internal chargen RAM
93   UINT8 m_ddram[0x80];   //internal display data RAM
94   UINT8 m_cgram[0x40];   //internal chargen RAM
9595
96   INT8 ac;         //address counter
97   UINT8 ac_mode;      //0=DDRAM 1=CGRAM
98   UINT8 data_bus_flag;//0=none 1=write 2=read
96   INT8 m_ac;            //address counter
97   UINT8 m_ac_mode;      //0=DDRAM 1=CGRAM
98   UINT8 m_data_bus_flag;   //0=none 1=write 2=read
9999
100   INT8 cursor_pos;   //cursor position
101   UINT8 display_on;   //display on/off
102   UINT8 cursor_on;   //cursor on/off
103   UINT8 blink_on;      //blink on/off
104   UINT8 shift_on;      //shift  on/off
105   INT8 disp_shift;   //display shift
100   INT8 m_cursor_pos;      //cursor position
101   UINT8 m_display_on;      //display on/off
102   UINT8 m_cursor_on;      //cursor on/off
103   UINT8 m_blink_on;      //blink on/off
104   UINT8 m_shift_on;      //shift  on/off
105   INT8 disp_shift;      //display shift
106106
107   INT8 direction;      //auto increment/decrement
108   UINT8 data_len;      //interface data length 4 or 8 bit
109   UINT8 n_line;      //number of lines
110   UINT8 char_size;   //char size 5x8 or 5x10
107   INT8 m_direction;      //auto increment/decrement
108   UINT8 m_data_len;      //interface data length 4 or 8 bit
109   UINT8 m_num_line;      //number of lines
110   UINT8 m_char_size;      //char size 5x8 or 5x10
111111
112   UINT8 blink;
112   UINT8 m_blink;
113113};
114114
115115// device type definition
src/mess/video/ef9345.c
r10256r10257
109109// calculate the internal RAM offset
110110inline UINT16 ef9345_device::indexram(UINT8 r)
111111{
112   UINT8 x = registers[r];
113   UINT8 y = registers[r - 1];
112   UINT8 x = m_registers[r];
113   UINT8 y = m_registers[r - 1];
114114   if (y < 8)
115115      y &= 1;
116116   return ((x&0x3f) | ((x & 0x40) << 6) | ((x & 0x80) << 4) | ((y & 0x1f) << 6) | ((y & 0x20) << 8));
r10256r10257
119119// calculate the internal ROM offset
120120inline UINT16 ef9345_device::indexrom(UINT8 r)
121121{
122   UINT8 x = registers[r];
123   UINT8 y = registers[r - 1];
122   UINT8 x = m_registers[r];
123   UINT8 y = m_registers[r - 1];
124124   if (y < 8)
125125      y &= 1;
126126   return((x&0x3f)|((x&0x40)<<6)|((x&0x80)<<4)|((y&0x1f)<<6));
r10256r10257
129129// increment x
130130inline void ef9345_device::inc_x(UINT8 r)
131131{
132   UINT8 i = (registers[r] & 0x3f) + 1;
132   UINT8 i = (m_registers[r] & 0x3f) + 1;
133133   if (i > 39)
134134   {
135135      i -= 40;
136      state |= 0x40;
136      m_state |= 0x40;
137137   }
138   registers[r] = (registers[r] & 0xc0) | i;
138   m_registers[r] = (m_registers[r] & 0xc0) | i;
139139}
140140
141141// increment y
142142inline void ef9345_device::inc_y(UINT8 r)
143143{
144   UINT8 i = (registers[r] & 0x1f) + 1;
144   UINT8 i = (m_registers[r] & 0x1f) + 1;
145145   if (i > 31)
146146      i -= 24;
147   registers[r] = (registers[r] & 0xe0) | i;
147   m_registers[r] = (m_registers[r] & 0xe0) | i;
148148}
149149
150150
r10256r10257
169169
170170void ef9345_device::device_start()
171171{
172   screen = machine->device<screen_device>(m_config.screen_tag);
172   m_screen = machine->device<screen_device>(m_config.screen_tag);
173173
174   assert(screen != NULL);
174   assert(m_screen != NULL);
175175
176176   m_busy_timer = device_timer_alloc(*this, BUSY_TIMER);
177177   m_blink_timer = device_timer_alloc(*this, BLINKING_TIMER);
178178
179   videoram = space(0);
180   charset = region();
179   m_videoram = space(0);
180   m_charset = region();
181181
182   screen_out = auto_bitmap_alloc(machine, 496, screen->height() , BITMAP_FORMAT_INDEXED16);
182   m_screen_out = auto_bitmap_alloc(machine, 496, m_screen->height() , BITMAP_FORMAT_INDEXED16);
183183
184184   timer_adjust_periodic(m_blink_timer, ATTOTIME_IN_MSEC(500), 0, ATTOTIME_IN_MSEC(500));
185185
186186   init_accented_chars();
187187
188   state_save_register_device_item_array(this, 0, border);
189   state_save_register_device_item_array(this, 0, registers);
190   state_save_register_device_item_array(this, 0, last_dial);
191   state_save_register_device_item_array(this, 0, ram_base);
192   state_save_register_device_item(this, 0, bf);
193   state_save_register_device_item(this, 0, char_mode);
194   state_save_register_device_item(this, 0, state);
195   state_save_register_device_item(this, 0, TGS);
196   state_save_register_device_item(this, 0, MAT);
197   state_save_register_device_item(this, 0, PAT);
198   state_save_register_device_item(this, 0, DOR);
199   state_save_register_device_item(this, 0, ROR);
200   state_save_register_device_item(this, 0, block);
201   state_save_register_device_item(this, 0, blink);
202   state_save_register_device_item(this, 0, latchc0);
203   state_save_register_device_item(this, 0, latchm);
204   state_save_register_device_item(this, 0, latchi);
205   state_save_register_device_item(this, 0, latchu);
188   state_save_register_device_item_array(this, 0, m_border);
189   state_save_register_device_item_array(this, 0, m_registers);
190   state_save_register_device_item_array(this, 0, m_last_dial);
191   state_save_register_device_item_array(this, 0, m_ram_base);
192   state_save_register_device_item(this, 0, m_bf);
193   state_save_register_device_item(this, 0, m_char_mode);
194   state_save_register_device_item(this, 0, m_state);
195   state_save_register_device_item(this, 0, m_tgs);
196   state_save_register_device_item(this, 0, m_mat);
197   state_save_register_device_item(this, 0, m_pat);
198   state_save_register_device_item(this, 0, m_dor);
199   state_save_register_device_item(this, 0, m_ror);
200   state_save_register_device_item(this, 0, m_block);
201   state_save_register_device_item(this, 0, m_blink);
202   state_save_register_device_item(this, 0, m_latchc0);
203   state_save_register_device_item(this, 0, m_latchm);
204   state_save_register_device_item(this, 0, m_latchi);
205   state_save_register_device_item(this, 0, m_latchu);
206206
207   state_save_register_device_item_bitmap(this, 0, screen_out);
207   state_save_register_device_item_bitmap(this, 0, m_screen_out);
208208}
209209
210210//-------------------------------------------------
r10256r10257
212212//-------------------------------------------------
213213void ef9345_device::device_reset()
214214{
215   TGS = MAT = PAT = DOR = ROR = 0;
216   state = 0;
217   bf = 0;
218   block = 0;
219   blink = 0;
220   latchc0 = 0;
221   latchm = 0;
222   latchi = 0;
223   latchu = 0;
224   char_mode = 0;
215   m_tgs = m_mat = m_pat = m_dor = m_ror = 0;
216   m_state = 0;
217   m_bf = 0;
218   m_block = 0;
219   m_blink = 0;
220   m_latchc0 = 0;
221   m_latchm = 0;
222   m_latchi = 0;
223   m_latchu = 0;
224   m_char_mode = 0;
225225
226   memset(last_dial, 0, ARRAY_LENGTH(last_dial) * sizeof(UINT8));
227   memset(registers, 0, ARRAY_LENGTH(registers) * sizeof(UINT8));
228   memset(border, 0, ARRAY_LENGTH(border) * sizeof(UINT8));
229   memset(border, 0, ARRAY_LENGTH(ram_base) * sizeof(UINT16));
226   memset(m_last_dial, 0, sizeof(m_last_dial));
227   memset(m_registers, 0, sizeof(m_registers));
228   memset(m_border, 0, sizeof(m_border));
229   memset(m_border, 0, sizeof(m_ram_base));
230230
231   bitmap_fill(screen_out, NULL, 0);
231   bitmap_fill(m_screen_out, NULL, 0);
232232
233233   set_video_mode();
234234}
r10256r10257
241241   switch(id)
242242   {
243243      case BUSY_TIMER:
244         bf = 0;
244         m_bf = 0;
245245         break;
246246
247247      case BLINKING_TIMER:
248         blink = !blink;
248         m_blink = !m_blink;
249249         break;
250250   }
251251}
r10256r10257
254254// set busy flag and timer to clear it
255255void ef9345_device::set_busy_flag(int period)
256256{
257   bf = 1;
257   m_bf = 1;
258258   timer_adjust_oneshot(m_busy_timer, ATTOTIME_IN_USEC(period), 0);
259259}
260260
r10256r10257
262262void ef9345_device::draw_char_40(UINT8 *c, UINT16 x, UINT16 y)
263263{
264264   //verify size limit
265   if (y * 10 >= screen->height() || x * 8 >= screen->width())
265   if (y * 10 >= m_screen->height() || x * 8 >= m_screen->width())
266266      return;
267267
268268   for(int i = 0; i < 10; i++)
269269      for(int j = 0; j < 8; j++)
270            *BITMAP_ADDR16(screen_out, y * 10 + i, x * 8 + j)  = c[8 * i + j] & 0x07;
270            *BITMAP_ADDR16(m_screen_out, y * 10 + i, x * 8 + j)  = c[8 * i + j] & 0x07;
271271}
272272
273273// draw a char in 80 char line mode
274274void ef9345_device::draw_char_80(UINT8 *c, UINT16 x, UINT16 y)
275275{
276276   // verify size limit
277   if (y * 10 >= screen->height() || x * 6 >= screen->width())
277   if (y * 10 >= m_screen->height() || x * 6 >= m_screen->width())
278278      return;
279279
280280   for(int i = 0; i < 10; i++)
281281      for(int j = 0; j < 6; j++)
282            *BITMAP_ADDR16(screen_out, y * 10 + i, x * 6 + j)  = c[6 * i + j] & 0x07;
282            *BITMAP_ADDR16(m_screen_out, y * 10 + i, x * 6 + j)  = c[6 * i + j] & 0x07;
283283}
284284
285285
286286// set then ef9345 mode
287287void ef9345_device::set_video_mode(void)
288288{
289   char_mode = ((PAT & 0x80) >> 5) | ((TGS & 0xc0) >> 6);
290   UINT16 new_width = (char_mode == MODE12x80 || char_mode == MODE8x80) ? 492 : 336;
289   m_char_mode = ((m_pat & 0x80) >> 5) | ((m_tgs & 0xc0) >> 6);
290   UINT16 new_width = (m_char_mode == MODE12x80 || m_char_mode == MODE8x80) ? 492 : 336;
291291
292   if (screen->width() != new_width)
292   if (m_screen->width() != new_width)
293293   {
294      rectangle visarea = screen->visible_area();
294      rectangle visarea = m_screen->visible_area();
295295      visarea.max_x = new_width - 1;
296296
297      screen->configure(new_width, screen->height(), visarea, screen->frame_period().attoseconds);
297      m_screen->configure(new_width, m_screen->height(), visarea, m_screen->frame_period().attoseconds);
298298   }
299299
300300   //border color
301   memset(border, MAT & 0x07, ARRAY_LENGTH(border));
301   memset(m_border, m_mat & 0x07, sizeof(m_border));
302302
303   //set the base for the videoram charset
304   ram_base[0] = ((DOR & 0x07) << 11);
305   ram_base[1] = ram_base[0];
306   ram_base[2] = ((DOR & 0x30) << 8);
307   ram_base[3] = ram_base[2] + 0x0800;
303   //set the base for the m_videoram charset
304   m_ram_base[0] = ((m_dor & 0x07) << 11);
305   m_ram_base[1] = m_ram_base[0];
306   m_ram_base[2] = ((m_dor & 0x30) << 8);
307   m_ram_base[3] = m_ram_base[2] + 0x0800;
308308
309309   //address of the current memory block
310   block = 0x0800 * ((((ROR & 0xf0) >> 4) | ((ROR & 0x40) >> 5) | ((ROR & 0x20) >> 3)) & 0x0c);
310   m_block = 0x0800 * ((((m_ror & 0xf0) >> 4) | ((m_ror & 0x40) >> 5) | ((m_ror & 0x20) >> 3)) & 0x0c);
311311}
312312
313313// initialize the ef9345 accented chars
r10256r10257
316316   UINT16 i, j;
317317   for(j = 0; j < 0x10; j++)
318318      for(i = 0; i < 0x200; i++)
319         acc_char[(j << 9) + i] = charset->u8(0x0600 + i);
319         m_acc_char[(j << 9) + i] = m_charset->u8(0x0600 + i);
320320
321321   for(j = 0; j < 0x200; j += 0x40)
322322      for(i = 0; i < 4; i++)
323323      {
324         acc_char[0x0200 + j + i +  4] |= 0x1c; //tilde
325         acc_char[0x0400 + j + i +  4] |= 0x10; //acute
326         acc_char[0x0400 + j + i +  8] |= 0x08; //acute
327         acc_char[0x0600 + j + i +  4] |= 0x04; //grave
328         acc_char[0x0600 + j + i +  8] |= 0x08; //grave
324         m_acc_char[0x0200 + j + i +  4] |= 0x1c; //tilde
325         m_acc_char[0x0400 + j + i +  4] |= 0x10; //acute
326         m_acc_char[0x0400 + j + i +  8] |= 0x08; //acute
327         m_acc_char[0x0600 + j + i +  4] |= 0x04; //grave
328         m_acc_char[0x0600 + j + i +  8] |= 0x08; //grave
329329
330         acc_char[0x0a00 + j + i +  4] |= 0x1c; //tilde
331         acc_char[0x0c00 + j + i +  4] |= 0x10; //acute
332         acc_char[0x0c00 + j + i +  8] |= 0x08; //acute
333         acc_char[0x0e00 + j + i +  4] |= 0x04; //grave
334         acc_char[0x0e00 + j + i +  8] |= 0x08; //grave
330         m_acc_char[0x0a00 + j + i +  4] |= 0x1c; //tilde
331         m_acc_char[0x0c00 + j + i +  4] |= 0x10; //acute
332         m_acc_char[0x0c00 + j + i +  8] |= 0x08; //acute
333         m_acc_char[0x0e00 + j + i +  4] |= 0x04; //grave
334         m_acc_char[0x0e00 + j + i +  8] |= 0x08; //grave
335335
336         acc_char[0x1200 + j + i +  4] |= 0x08; //point
337         acc_char[0x1400 + j + i +  4] |= 0x14; //trema
338         acc_char[0x1600 + j + i + 32] |= 0x08; //cedilla
339         acc_char[0x1600 + j + i + 36] |= 0x04; //cedilla
336         m_acc_char[0x1200 + j + i +  4] |= 0x08; //point
337         m_acc_char[0x1400 + j + i +  4] |= 0x14; //trema
338         m_acc_char[0x1600 + j + i + 32] |= 0x08; //cedilla
339         m_acc_char[0x1600 + j + i + 36] |= 0x04; //cedilla
340340
341         acc_char[0x1a00 + j + i +  4] |= 0x08; //point
342         acc_char[0x1c00 + j + i +  4] |= 0x14; //trema
343         acc_char[0x1e00 + j + i + 32] |= 0x08; //cedilla
344         acc_char[0x1e00 + j + i + 36] |= 0x04; //cedilla
341         m_acc_char[0x1a00 + j + i +  4] |= 0x08; //point
342         m_acc_char[0x1c00 + j + i +  4] |= 0x14; //trema
343         m_acc_char[0x1e00 + j + i + 32] |= 0x08; //cedilla
344         m_acc_char[0x1e00 + j + i + 36] |= 0x04; //cedilla
345345      }
346346}
347347
348// read a char in charset or in videoram
348// read a char in charset or in m_videoram
349349UINT8 ef9345_device::read_char(UINT8 index, UINT16 addr)
350350{
351351   if (index < 0x04)
352      return charset->u8(0x0800*index + addr);
352      return m_charset->u8(0x0800*index + addr);
353353   else if (index < 0x08)
354      return acc_char[0x0800*(index&3) + addr];
354      return m_acc_char[0x0800*(index&3) + addr];
355355   else if (index < 0x0c)
356      return videoram->read_byte(ram_base[index-8] + addr);
356      return m_videoram->read_byte(m_ram_base[index-8] + addr);
357357   else
358      return videoram->read_byte(addr);
358      return m_videoram->read_byte(addr);
359359}
360360
361361// calculate the dial position of the char
362362UINT8 ef9345_device::get_dial(UINT8 x, UINT8 attrib)
363363{
364   if (x > 0 && last_dial[x-1] == 1)       //top right
365      last_dial[x] = 2;
366   else if (x > 0 && last_dial[x-1] == 5)   //half right
367      last_dial[x] = 10;
368   else if (last_dial[x] == 1)            //bottom left
369      last_dial[x] = 4;
370   else if (last_dial[x] == 2)            //bottom right
371      last_dial[x] = 8;
372   else if (last_dial[x] == 3)            //lower half
373      last_dial[x] = 12;
374   else if (attrib == 1)               //Left half
375      last_dial[x] = 5;
376   else if (attrib == 2)               //half high
377      last_dial[x] = 3;
378   else if (attrib == 3)               //top left
379      last_dial[x] = 1;
380   else                            //none
381      last_dial[x] = 0;
364   if (x > 0 && m_last_dial[x-1] == 1)       //top right
365      m_last_dial[x] = 2;
366   else if (x > 0 && m_last_dial[x-1] == 5)   //half right
367      m_last_dial[x] = 10;
368   else if (m_last_dial[x] == 1)            //bottom left
369      m_last_dial[x] = 4;
370   else if (m_last_dial[x] == 2)            //bottom right
371      m_last_dial[x] = 8;
372   else if (m_last_dial[x] == 3)            //lower half
373      m_last_dial[x] = 12;
374   else if (attrib == 1)                  //Left half
375      m_last_dial[x] = 5;
376   else if (attrib == 2)                  //half high
377      m_last_dial[x] = 3;
378   else if (attrib == 3)                  //top left
379      m_last_dial[x] = 1;
380   else                              //none
381      m_last_dial[x] = 0;
382382
383   return last_dial[x];
383   return m_last_dial[x];
384384}
385385
386386// zoom the char
r10256r10257
413413UINT16 ef9345_device::indexblock(UINT16 x, UINT16 y)
414414{
415415   UINT16 i = x, j;
416   j = (y == 0) ? ((TGS & 0x20) >> 5) : ((ROR & 0x1f) + y - 1);
416   j = (y == 0) ? ((m_tgs & 0x20) >> 5) : ((m_ror & 0x1f) + y - 1);
417417
418418   //right side of a double width character
419   if ((TGS & 0x80) == 0 && x > 0)
419   if ((m_tgs & 0x80) == 0 && x > 0)
420420   {
421      if (last_dial[x - 1] == 1) i--;
422      if (last_dial[x - 1] == 4) i--;
423      if (last_dial[x - 1] == 5) i--;
421      if (m_last_dial[x - 1] == 1) i--;
422      if (m_last_dial[x - 1] == 4) i--;
423      if (m_last_dial[x - 1] == 5) i--;
424424   }
425425
426426   return 0x40 * j + i;
r10256r10257
432432   UINT16 i;
433433   UINT8 pix[80];
434434
435   if (flash && PAT & 0x40 && blink)
435   if (flash && m_pat & 0x40 && m_blink)
436436      c1 = c0;               //flash
437   if (hided && PAT & 0x08)
437   if (hided && m_pat & 0x08)
438438      c1 = c0;                 //hided
439439   if (negative)               //negative
440440   {
r10256r10257
443443      c0 = i;
444444   }
445445
446   if ((PAT & 0x30) == 0x30)
446   if ((m_pat & 0x30) == 0x30)
447447      insert = 0;               //active area mark
448448   if (insert == 0)
449      c1 += 8;                      //foreground color
450   if ((PAT & 0x30) == 0x00)
449      c1 += 8;                   //foreground color
450   if ((m_pat & 0x30) == 0x00)
451451      insert = 1;               //insert mode
452452   if (insert == 0)
453      c0 += 8;                      //background color
453      c0 += 8;                   //background color
454454
455455   //draw the cursor
456   i = (registers[6] & 0x1f);
456   i = (m_registers[6] & 0x1f);
457457   if (i < 8)
458458      i &= 1;
459459
460   if (iblock == 0x40 * i + (registers[7] & 0x3f))   //cursor position
460   if (iblock == 0x40 * i + (m_registers[7] & 0x3f))   //cursor position
461461   {
462      switch(MAT & 0x70)
462      switch(m_mat & 0x70)
463463      {
464464      case 0x40:               //00 = fixed complemented
465465         c0 = (23 - c0) & 15;
r10256r10257
469469         underline = 1;
470470         break;
471471      case 0x60:               //10 = flash complemented
472         if (blink)
472         if (m_blink)
473473         {
474474            c0 = (23 - c0) & 15;
475475            c1 = (23 - c1) & 15;
476476         }
477477         break;
478478      case 0x70:               //11 = flash underlined
479         if (blink)
479         if (m_blink)
480480            underline = 1;
481481            break;
482482      }
r10256r10257
499499      zoom(pix, dial);
500500
501501   //doubles the height of the char
502   if (MAT & 0x80)
502   if (m_mat & 0x80)
503503      zoom(pix, (y & 0x01) ? 0x0c : 0x03);
504504
505505   draw_char_40(pix, x + 1 , y + 1);
r10256r10257
520520   UINT16 ramindex;
521521
522522   //quadrichrome don't suppor double size
523   last_dial[x] = 0;
523   m_last_dial[x] = 0;
524524
525525   //initialize the color table
526526   for(j = 1, n = 0, i = 0; i < 8; i++)
r10256r10257
559559{
560560   UINT8 c0, c1, pix[60];
561561   UINT16 i, j, d;
562   
563   c1 = (a & 1) ? (DOR >> 4) & 7 : DOR & 7; //foreground color = DOR
564   c0 =  MAT & 7;                           //background color = MAT
565562
563   c1 = (a & 1) ? (m_dor >> 4) & 7 : m_dor & 7;   //foreground color = DOR
564   c0 =  m_mat & 7;                              //background color = MAT
565
566566   switch(c & 0x80)
567567   {
568568   case 0: //alphanumeric G0 set
r10256r10257
572572      //A3: N = negative
573573      //C0-6: character code
574574
575      if ((a & 4) && (PAT & 0x40) && (blink))
576         c1 = c0;    //flash
575      if ((a & 4) && (m_pat & 0x40) && (m_blink))
576         c1 = c0;   //flash
577577      if (a & 8)      //negative
578578      {
579579         i = c1;
r10256r10257
631631   UINT8 a, b, c0, c1, i, f, m, n, u, type, dial;
632632   UINT16 address, iblock;
633633
634   iblock = (MAT & 0x80 && y > 1) ? indexblock(x, y / 2) : indexblock(x, y);
635   a = videoram->read_byte(block + iblock);
636   b = videoram->read_byte(block + iblock + 0x0800);
634   iblock = (m_mat & 0x80 && y > 1) ? indexblock(x, y / 2) : indexblock(x, y);
635   a = m_videoram->read_byte(m_block + iblock);
636   b = m_videoram->read_byte(m_block + iblock + 0x0800);
637637
638638   dial = get_dial(x, (a & 0x80) ? 0 : (((a & 0x20) >> 5) | ((a & 0x10) >> 3)));
639639
r10256r10257
650650
651651   //reset attributes latch
652652   if (x == 0)
653      latchm = latchi = latchu = latchc0 = 0;
653      m_latchm = m_latchi = m_latchu = m_latchc0 = 0;
654654
655655   if (type == 4)
656656   {
657      latchm = b & 1;
658      latchi = (b & 2) >> 1;
659      latchu = (b & 4) >> 2;
657      m_latchm = b & 1;
658      m_latchi = (b & 2) >> 1;
659      m_latchu = (b & 4) >> 2;
660660   }
661661
662662   if (a & 0x80)
663      latchc0 = (a & 0x70) >> 4;
663      m_latchc0 = (a & 0x70) >> 4;
664664
665665   //char attributes
666   c0 = latchc0;                     //background
666   c0 = m_latchc0;                     //background
667667   c1 = a & 0x07;                     //foreground
668   i = latchi;                        //insert mode
668   i = m_latchi;                        //insert mode
669669   f  = (a & 0x08) >> 3;               //flash
670   m = latchm;                        //hided
670   m = m_latchm;                        //hided
671671   n  = (a & 0x80) ? 0: ((a & 0x40) >> 6);   //negative
672   u = latchu;                        //underline
672   u = m_latchu;                        //underline
673673
674674   bichrome40(type, address, dial, iblock, x, y, c0, c1, i, f, m, n, u);
675675}
r10256r10257
680680   UINT8 a, b, c, c0, c1, i, f, m, n, u, type, dial;
681681   UINT16 address, iblock;
682682
683   iblock = (MAT & 0x80 && y > 1) ? indexblock(x, y / 2) : indexblock(x, y);
684   c = videoram->read_byte(block + iblock);
685   b = videoram->read_byte(block + iblock + 0x0800);
686   a = videoram->read_byte(block + iblock + 0x1000);
683   iblock = (m_mat & 0x80 && y > 1) ? indexblock(x, y / 2) : indexblock(x, y);
684   c = m_videoram->read_byte(m_block + iblock);
685   b = m_videoram->read_byte(m_block + iblock + 0x0800);
686   a = m_videoram->read_byte(m_block + iblock + 0x1000);
687687
688688   if ((b & 0xc0) == 0xc0)
689689   {
r10256r10257
713713void ef9345_device::makechar_12x80(UINT16 x, UINT16 y)
714714{
715715   UINT16 iblock = indexblock(x, y);
716   bichrome80(videoram->read_byte(block + iblock), (videoram->read_byte(block + iblock + 0x1000) >> 4) & 0x0f, 2 * x + 1, y + 1);
717   bichrome80(videoram->read_byte(block + iblock + 0x0800), videoram->read_byte(block + iblock + 0x1000) & 0x0f, 2 * x + 2, y + 1);
716   bichrome80(m_videoram->read_byte(m_block + iblock), (m_videoram->read_byte(m_block + iblock + 0x1000) >> 4) & 0x0f, 2 * x + 1, y + 1);
717   bichrome80(m_videoram->read_byte(m_block + iblock + 0x0800), m_videoram->read_byte(m_block + iblock + 0x1000) & 0x0f, 2 * x + 2, y + 1);
718718}
719719
720720void ef9345_device::draw_border(UINT16 line)
721721{
722   if (char_mode == MODE12x80 || char_mode == MODE8x80)
722   if (m_char_mode == MODE12x80 || m_char_mode == MODE8x80)
723723      for(int i = 0; i < 82; i++)
724         draw_char_80(border, i, line);
724         draw_char_80(m_border, i, line);
725725   else
726726      for(int i = 0; i < 42; i++)
727         draw_char_40(border, i, line);
727         draw_char_40(m_border, i, line);
728728}
729729
730730void ef9345_device::makechar(UINT16 x, UINT16 y)
731731{
732   switch (char_mode)
732   switch (m_char_mode)
733733   {
734734      case MODE24x40:
735735         makechar_24x40(x, y);
736736         break;
737737      case MODEVAR40:
738738      case MODE8x80:
739         logerror("Unemulated EF9345 mode: %02x\n", char_mode);
739         logerror("Unemulated EF9345 mode: %02x\n", m_char_mode);
740740         break;
741741      case MODE12x80:
742742         makechar_12x80(x, y);
r10256r10257
745745         makechar_16x40(x, y);
746746         break;
747747      default:
748         logerror("Unknown EF9345 mode: %02x\n", char_mode);
748         logerror("Unknown EF9345 mode: %02x\n", m_char_mode);
749749         break;
750750   }
751751}
r10256r10257
753753// Execute EF9345 command
754754void ef9345_device::ef9345_exec(UINT8 cmd)
755755{
756   state = 0;
757   if ((registers[5] & 0x3f) == 39) state |= 0x10; //S4(LXa) set
758   if ((registers[7] & 0x3f) == 39) state |= 0x20; //S5(LXm) set
756   m_state = 0;
757   if ((m_registers[5] & 0x3f) == 39) m_state |= 0x10; //S4(LXa) set
758   if ((m_registers[7] & 0x3f) == 39) m_state |= 0x20; //S5(LXm) set
759759
760760   UINT16 a = indexram(7);
761761
r10256r10257
764764      case 0x00:   //KRF: R1,R2,R3->ram
765765      case 0x01:   //KRF: R1,R2,R3->ram + increment
766766         set_busy_flag(4);
767         videoram->write_byte(a, registers[1]);
768         videoram->write_byte(a + 0x0800, registers[2]);
769         videoram->write_byte(a + 0x1000, registers[3]);
767         m_videoram->write_byte(a, m_registers[1]);
768         m_videoram->write_byte(a + 0x0800, m_registers[2]);
769         m_videoram->write_byte(a + 0x1000, m_registers[3]);
770770         if (cmd&1) inc_x(7);
771771         break;
772772      case 0x02:   //KRG: R1,R2->ram
773773      case 0x03:   //KRG: R1,R2->ram + increment
774774         set_busy_flag(5.5);
775         videoram->write_byte(a, registers[1]);
776         videoram->write_byte(a + 0x0800, registers[2]);
775         m_videoram->write_byte(a, m_registers[1]);
776         m_videoram->write_byte(a + 0x0800, m_registers[2]);
777777         if (cmd&1) inc_x(7);
778778         break;
779779      case 0x08:   //KRF: ram->R1,R2,R3
780780      case 0x09:   //KRF: ram->R1,R2,R3 + increment
781781         set_busy_flag(7.5);
782         registers[1] = videoram->read_byte(a);
783         registers[2] = videoram->read_byte(a + 0x0800);
784         registers[3] = videoram->read_byte(a + 0x1000);
782         m_registers[1] = m_videoram->read_byte(a);
783         m_registers[2] = m_videoram->read_byte(a + 0x0800);
784         m_registers[3] = m_videoram->read_byte(a + 0x1000);
785785         if (cmd&1) inc_x(7);
786786         break;
787787      case 0x0a:   //KRG: ram->R1,R2
788788      case 0x0b:   //KRG: ram->R1,R2 + increment
789789         set_busy_flag(7.5);
790         registers[1] = videoram->read_byte(a);
791         registers[2] = videoram->read_byte(a + 0x0800);
790         m_registers[1] = m_videoram->read_byte(a);
791         m_registers[2] = m_videoram->read_byte(a + 0x0800);
792792         if (cmd&1) inc_x(7);
793793         break;
794794      case 0x30:   //OCT: R1->RAM, main pointer
795795      case 0x31:   //OCT: R1->RAM, main pointer + inc
796796         set_busy_flag(4);
797         videoram->write_byte(indexram(7), registers[1]);
797         m_videoram->write_byte(indexram(7), m_registers[1]);
798798
799799         if (cmd&1)
800800         {
801801            inc_x(7);
802            if ((registers[7] & 0x3f) == 0)
802            if ((m_registers[7] & 0x3f) == 0)
803803               inc_y(6);
804804         }
805805         break;
806806      case 0x34:   //OCT: R1->RAM, aux pointer
807807      case 0x35:   //OCT: R1->RAM, aux pointer + inc
808808         set_busy_flag(4);
809         videoram->write_byte(indexram(5), registers[1]);
809         m_videoram->write_byte(indexram(5), m_registers[1]);
810810
811811         if (cmd&1)
812812            inc_x(5);
r10256r10257
814814      case 0x38:   //OCT: RAM->R1, main pointer
815815      case 0x39:   //OCT: RAM->R1, main pointer + inc
816816         set_busy_flag(4.5);
817         registers[1] = videoram->read_byte(indexram(7));
817         m_registers[1] = m_videoram->read_byte(indexram(7));
818818
819819         if (cmd&1)
820820         {
821821            inc_x(7);
822822
823            if ((registers[7] & 0x3f) == 0)
823            if ((m_registers[7] & 0x3f) == 0)
824824               inc_y(6);
825825         }
826826         break;
827827      case 0x3c:   //OCT: RAM->R1, aux pointer
828828      case 0x3d:   //OCT: RAM->R1, aux pointer + inc
829829         set_busy_flag(4.5);
830         registers[1] = videoram->read_byte(indexram(5));
830         m_registers[1] = m_videoram->read_byte(indexram(5));
831831
832832         if (cmd&1)
833833            inc_x(5);
r10256r10257
835835      case 0x50:   //KRL: 80 UINT8 - 12 bits write
836836      case 0x51:   //KRL: 80 UINT8 - 12 bits write + inc
837837         set_busy_flag(12.5);
838         videoram->write_byte(a, registers[1]);
838         m_videoram->write_byte(a, m_registers[1]);
839839         switch((a / 0x0800) & 1)
840840         {
841841            case 0:
842842            {
843               UINT8 tmp_data = videoram->read_byte(a + 0x1000);
844               videoram->write_byte(a + 0x1000, (tmp_data & 0x0f) | (registers[3] & 0xf0));
843               UINT8 tmp_data = m_videoram->read_byte(a + 0x1000);
844               m_videoram->write_byte(a + 0x1000, (tmp_data & 0x0f) | (m_registers[3] & 0xf0));
845845               break;
846846            }
847847            case 1:
848848            {
849               UINT8 tmp_data = videoram->read_byte(a + 0x0800);
850               videoram->write_byte(a + 0x0800, (tmp_data & 0xf0) | (registers[3] & 0x0f));
849               UINT8 tmp_data = m_videoram->read_byte(a + 0x0800);
850               m_videoram->write_byte(a + 0x0800, (tmp_data & 0xf0) | (m_registers[3] & 0x0f));
851851               break;
852852            }
853853         }
854854         if (cmd&1)
855855         {
856            if ((registers[7] & 0x80) == 0x00) { registers[7] |= 0x80; return; }
857            registers[7] &= 0x80;
856            if ((m_registers[7] & 0x80) == 0x00) { m_registers[7] |= 0x80; return; }
857            m_registers[7] &= 0x80;
858858            inc_x(7);
859859         }
860860         break;
861861      case 0x58:   //KRL: 80 UINT8 - 12 bits read
862862      case 0x59:   //KRL: 80 UINT8 - 12 bits read + inc
863863         set_busy_flag(11.5);
864         registers[1] = videoram->read_byte(a);
864         m_registers[1] = m_videoram->read_byte(a);
865865         switch((a / 0x0800) & 1)
866866         {
867867            case 0:
868               registers[3] = videoram->read_byte(a + 0x1000);
868               m_registers[3] = m_videoram->read_byte(a + 0x1000);
869869               break;
870870            case 1:
871               registers[3] = videoram->read_byte(a + 0x0800);
871               m_registers[3] = m_videoram->read_byte(a + 0x0800);
872872               break;
873873         }
874874         if (cmd&1)
875875         {
876            if ((registers[7] & 0x80) == 0x00)
876            if ((m_registers[7] & 0x80) == 0x00)
877877            {
878               registers[7] |= 0x80;
878               m_registers[7] |= 0x80;
879879               break;;
880880            }
881            registers[7] &= 0x80;
881            m_registers[7] &= 0x80;
882882            inc_x(7);
883883         }
884884         break;
r10256r10257
892892         set_busy_flag(2);
893893         switch(cmd&7)
894894         {
895            case 1:    TGS = registers[1]; break;
896            case 2:    MAT = registers[1]; break;
897            case 3:    PAT = registers[1]; break;
898            case 4:    DOR = registers[1]; break;
899            case 7:    ROR = registers[1]; break;
895            case 1:    m_tgs = m_registers[1]; break;
896            case 2:    m_mat = m_registers[1]; break;
897            case 3:    m_pat = m_registers[1]; break;
898            case 4:    m_dor = m_registers[1]; break;
899            case 7:    m_ror = m_registers[1]; break;
900900         }
901901         set_video_mode();
902         state &= 0x8f;  //reset S4(LXa), S5(LXm), S6(Al)
902         m_state &= 0x8f;  //reset S4(LXa), S5(LXm), S6(Al)
903903         break;
904904      case 0x88:   //IND: ROM->R1
905905      case 0x89:   //IND: TGS->R1
r10256r10257
910910         set_busy_flag(3.5);
911911         switch(cmd&7)
912912         {
913            case 0:    registers[1] = charset->u8(indexrom(7) & 0x1fff);
914            case 1:    registers[1] = TGS; break;
915            case 2:    registers[1] = MAT; break;
916            case 3:    registers[1] = PAT; break;
917            case 4:    registers[1] = DOR; break;
918            case 7:    registers[1] = ROR; break;
913            case 0:    m_registers[1] = m_charset->u8(indexrom(7) & 0x1fff);
914            case 1:    m_registers[1] = m_tgs; break;
915            case 2:    m_registers[1] = m_mat; break;
916            case 3:    m_registers[1] = m_pat; break;
917            case 4:    m_registers[1] = m_dor; break;
918            case 7:    m_registers[1] = m_ror; break;
919919         }
920         state &= 0x8f;  //reset S4(LXa), S5(LXm), S6(Al)
920         m_state &= 0x8f;  //reset S4(LXa), S5(LXm), S6(Al)
921921         break;
922922      case 0x90:   //NOP: no operation
923923      case 0x91:   //NOP: no operation
r10256r10257
927927      case 0xb0:   //INY: increment Y
928928         set_busy_flag(2);
929929         inc_y(6);
930         state &= 0x8f;  //reset S4(LXa), S5(LXm), S6(Al)
930         m_state &= 0x8f;  //reset S4(LXa), S5(LXm), S6(Al)
931931         break;
932932      case 0xd5:   //MVB: move buffer MP->AP stop
933933      case 0xd6:   //MVB: move buffer MP->AP nostop
r10256r10257
951951         for(i = 0; i < 1280; i++)
952952         {
953953            a1 = indexram(r1); a2 = indexram(r2);
954            videoram->write_byte(a2, videoram->read_byte(a1));
954            m_videoram->write_byte(a2, m_videoram->read_byte(a1));
955955
956            if (n > 1) videoram->write_byte(a2 + 0x0800, videoram->read_byte(a1 + 0x0800));
957            if (n > 2) videoram->write_byte(a2 + 0x1000, videoram->read_byte(a1 + 0x1000));
956            if (n > 1) m_videoram->write_byte(a2 + 0x0800, m_videoram->read_byte(a1 + 0x0800));
957            if (n > 2) m_videoram->write_byte(a2 + 0x1000, m_videoram->read_byte(a1 + 0x1000));
958958
959959            inc_x(r1);
960960            inc_x(r2);
961            if ((registers[5] & 0x3f) == 0 && (cmd&1))
961            if ((m_registers[5] & 0x3f) == 0 && (cmd&1))
962962               break;
963963
964            if ((registers[7] & 0x3f) == 0)
964            if ((m_registers[7] & 0x3f) == 0)
965965            {
966966               if (cmd&1)
967967                  break;
r10256r10257
971971
972972            busy += 4 * n;
973973         }
974         state &= 0x8f;  //reset S4(LXa), S5(LXm), S6(Al)
974         m_state &= 0x8f;  //reset S4(LXa), S5(LXm), S6(Al)
975975         set_busy_flag(busy);
976976      }
977977      break;
r10256r10257
993993
994994void ef9345_device::video_update(bitmap_t *bitmap, const rectangle *cliprect)
995995{
996   copybitmap(bitmap, screen_out, 0, 0, 0, 0, cliprect);
996   copybitmap(bitmap, m_screen_out, 0, 0, 0, 0, cliprect);
997997}
998998
999999void ef9345_device::update_scanline(UINT16 scanline)
r10256r10257
10011001   UINT16 i;
10021002
10031003   if (scanline == 250)
1004      state &= 0xfb;
1004      m_state &= 0xfb;
10051005
10061006   set_busy_flag(104);
10071007
1008   if (char_mode == MODE12x80 || char_mode == MODE8x80)
1008   if (m_char_mode == MODE12x80 || m_char_mode == MODE8x80)
10091009   {
1010      draw_char_80(border, 0, (scanline / 10) + 1);
1011      draw_char_80(border, 81, (scanline / 10) + 1);
1010      draw_char_80(m_border, 0, (scanline / 10) + 1);
1011      draw_char_80(m_border, 81, (scanline / 10) + 1);
10121012   }
10131013   else
10141014   {
1015      draw_char_40(border, 0, (scanline / 10) + 1);
1016      draw_char_40(border, 41, (scanline / 10) + 1);
1015      draw_char_40(m_border, 0, (scanline / 10) + 1);
1016      draw_char_40(m_border, 41, (scanline / 10) + 1);
10171017   }
10181018
10191019   if (scanline == 0)
10201020   {
1021      state |= 0x04;
1021      m_state |= 0x04;
10221022      draw_border(0);
1023      if (PAT & 1)
1023      if (m_pat & 1)
10241024         for(i = 0; i < 40; i++)
10251025            makechar(i, (scanline / 10));
10261026      else
10271027         for(i = 0; i < 42; i++)
1028            draw_char_40(border, i, 1);
1028            draw_char_40(m_border, i, 1);
10291029   }
10301030   else if (scanline < 120)
10311031   {
1032      if (PAT & 2)
1032      if (m_pat & 2)
10331033         for(i = 0; i < 40; i++)
10341034            makechar(i, (scanline / 10));
10351035      else
r10256r10257
10371037   }
10381038   else if (scanline < 250)
10391039   {
1040      if (PAT & 4)
1040      if (m_pat & 4)
10411041         for(i = 0; i < 40; i++)
10421042            makechar(i, (scanline / 10));
10431043      else
r10256r10257
10511051READ8_MEMBER( ef9345_device::data_r )
10521052{
10531053   if (offset & 7)
1054      return registers[offset & 7];
1054      return m_registers[offset & 7];
10551055
1056   if (bf)
1057      state |= 0x80;
1056   if (m_bf)
1057      m_state |= 0x80;
10581058   else
1059      state &= 0x7f;
1059      m_state &= 0x7f;
10601060
1061   return state;
1061   return m_state;
10621062}
10631063
10641064WRITE8_MEMBER( ef9345_device::data_w )
10651065{
1066   registers[offset & 7] = data;
1066   m_registers[offset & 7] = data;
10671067
10681068   if (offset & 8)
1069      ef9345_exec(registers[0] & 0xff);
1069      ef9345_exec(m_registers[0] & 0xff);
10701070}
src/mess/video/ef9345.h
r10256r10257
8080    virtual void device_start();
8181    virtual void device_reset();
8282   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
83   
83
8484   // inline helper
8585   inline UINT16 indexram(UINT8 r);
8686   inline UINT16 indexrom(UINT8 r);
r10256r10257
113113   static const device_timer_id BUSY_TIMER = 0;
114114   static const device_timer_id BLINKING_TIMER = 1;
115115
116   const memory_region *charset;
117   address_space *videoram;
116   const memory_region *m_charset;
117   address_space *m_videoram;
118118
119   screen_device *screen;         //screen we are acting on
119   screen_device *m_screen;            //screen we are acting on
120120
121   UINT8 bf;                  //busy flag
122   UINT8 char_mode;            //40 or 80 chars for line
123   UINT8 acc_char[0x2000];         //accented chars
124   UINT8 registers[8];            //registers R0-R7
125   UINT8 state;               //status register
126   UINT8 TGS,MAT,PAT,DOR,ROR;      //indirect registers
127   UINT8 border[80];            //border color
128   UINT16 block;               //current memory block
129   UINT16 ram_base[4];            //index of ram charset
130   UINT8 blink;               //cursor status
131   UINT8 last_dial[40];         //last chars dial (for determinate the zoom position)
132   UINT8 latchc0;               //background color latch
133   UINT8 latchm;               //hided atribute latch
134   UINT8 latchi;               //insert atribute latch
135   UINT8 latchu;               //underline atribute latch
121   UINT8 m_bf;                        //busy flag
122   UINT8 m_char_mode;                  //40 or 80 chars for line
123   UINT8 m_acc_char[0x2000];            //accented chars
124   UINT8 m_registers[8];               //registers R0-R7
125   UINT8 m_state;                     //status register
126   UINT8 m_tgs,m_mat,m_pat,m_dor,m_ror;   //indirect registers
127   UINT8 m_border[80];                  //border color
128   UINT16 m_block;                     //current memory block
129   UINT16 m_ram_base[4];               //index of ram charset
130   UINT8 m_blink;                     //cursor status
131   UINT8 m_last_dial[40];               //last chars dial (for determinate the zoom position)
132   UINT8 m_latchc0;                  //background color latch
133   UINT8 m_latchm;                     //hided atribute latch
134   UINT8 m_latchi;                     //insert atribute latch
135   UINT8 m_latchu;                     //underline atribute latch
136136
137   bitmap_t *screen_out;
137   bitmap_t *m_screen_out;
138138
139139   // timers
140140   emu_timer *m_busy_timer;
src/mess/video/hd44352.c
r10256r10257
112112   m_on_timer = device_timer_alloc(*this, ON_TIMER);
113113   timer_adjust_periodic(m_on_timer, ATTOTIME_IN_HZ(m_clock/16384), 0, ATTOTIME_IN_HZ(m_clock/16384));
114114
115   state_save_register_device_item( this, 0, control_lines);
116   state_save_register_device_item( this, 0, data_bus);
117   state_save_register_device_item( this, 0, state);
118   state_save_register_device_item( this, 0, offset);
119   state_save_register_device_item( this, 0, char_width);
120   state_save_register_device_item( this, 0, bank);
121   state_save_register_device_item( this, 0, lcd_on);
122   state_save_register_device_item( this, 0, scroll);
123   state_save_register_device_item( this, 0, contrast);
124   state_save_register_device_item( this, 0, byte_count);
125   state_save_register_device_item( this, 0, cursor_status);
126   state_save_register_device_item( this, 0, cursor_x);
127   state_save_register_device_item( this, 0, cursor_y);
128   state_save_register_device_item( this, 0, cursor_lcd);
129   state_save_register_device_item_array( this, 0, video_ram[0]);
130   state_save_register_device_item_array( this, 0, video_ram[1]);
131   state_save_register_device_item_array( this, 0, par);
132   state_save_register_device_item_array( this, 0, cursor);
133   state_save_register_device_item_array( this, 0, custom_char[0]);
134   state_save_register_device_item_array( this, 0, custom_char[1]);
135   state_save_register_device_item_array( this, 0, custom_char[2]);
136   state_save_register_device_item_array( this, 0, custom_char[3]);
115   state_save_register_device_item( this, 0, m_control_lines);
116   state_save_register_device_item( this, 0, m_data_bus);
117   state_save_register_device_item( this, 0, m_state);
118   state_save_register_device_item( this, 0, m_offset);
119   state_save_register_device_item( this, 0, m_char_width);
120   state_save_register_device_item( this, 0, m_bank);
121   state_save_register_device_item( this, 0, m_lcd_on);
122   state_save_register_device_item( this, 0, m_scroll);
123   state_save_register_device_item( this, 0, m_contrast);
124   state_save_register_device_item( this, 0, m_byte_count);
125   state_save_register_device_item( this, 0, m_cursor_status);
126   state_save_register_device_item( this, 0, m_cursor_x);
127   state_save_register_device_item( this, 0, m_cursor_y);
128   state_save_register_device_item( this, 0, m_cursor_lcd);
129   state_save_register_device_item_array( this, 0, m_video_ram[0]);
130   state_save_register_device_item_array( this, 0, m_video_ram[1]);
131   state_save_register_device_item_array( this, 0, m_par);
132   state_save_register_device_item_array( this, 0, m_cursor);
133   state_save_register_device_item_array( this, 0, m_custom_char[0]);
134   state_save_register_device_item_array( this, 0, m_custom_char[1]);
135   state_save_register_device_item_array( this, 0, m_custom_char[2]);
136   state_save_register_device_item_array( this, 0, m_custom_char[3]);
137137}
138138
139139
r10256r10257
143143
144144void hd44352_device::device_reset()
145145{
146   memset(video_ram, 0x00, 0x300);
147   memset(par, 0x00, 3);
148   memset(custom_char, 0x00, 4*8);
149   memset(cursor, 0x00, 8);
150   control_lines = 0;
151   data_bus = 0xff;
152   state = 0;
153   bank = 0;
154   offset = 0;
155   char_width = 6;
156   lcd_on = 0;
157   scroll = 0;
158   byte_count = 0;
159   cursor_status = 0;
160   cursor_x = 0;
161   cursor_y = 0;
162   cursor_lcd = 0;
163   contrast = 0;
146   memset(m_video_ram, 0x00, sizeof(m_video_ram));
147   memset(m_par, 0x00, sizeof(m_par));
148   memset(m_custom_char, 0x00, sizeof(m_custom_char));
149   memset(m_cursor, 0x00, sizeof(m_cursor));
150   m_control_lines = 0;
151   m_data_bus = 0xff;
152   m_state = 0;
153   m_bank = 0;
154   m_offset = 0;
155   m_char_width = 6;
156   m_lcd_on = 0;
157   m_scroll = 0;
158   m_byte_count = 0;
159   m_cursor_status = 0;
160   m_cursor_x = 0;
161   m_cursor_y = 0;
162   m_cursor_lcd = 0;
163   m_contrast = 0;
164164}
165165
166166
r10256r10257
172172   switch(id)
173173   {
174174      case ON_TIMER:
175         if (control_lines & 0x40)
175         if (m_control_lines & 0x40)
176176         {
177177            devcb_call_write_line(&m_on, ASSERT_LINE);
178178            devcb_call_write_line(&m_on, CLEAR_LINE);
r10256r10257
187187
188188int hd44352_device::video_update(bitmap_t &bitmap, const rectangle &cliprect)
189189{
190   UINT8 cw = char_width;
190   UINT8 cw = m_char_width;
191191
192192   bitmap_fill(&bitmap, &cliprect, 0);
193193
194   if (control_lines&0x80 && lcd_on)
194   if (m_control_lines&0x80 && m_lcd_on)
195195   {
196196      for (int a=0; a<2; a++)
197197         for (int py=0; py<4; py++)
198198            for (int px=0; px<16; px++)
199               if (BIT(cursor_status, 4) && px == cursor_x && py == cursor_y && a == cursor_lcd)
199               if (BIT(m_cursor_status, 4) && px == m_cursor_x && py == m_cursor_y && a == m_cursor_lcd)
200200               {
201201                  //draw the cursor
202202                  for (int c=0; c<cw; c++)
203203                  {
204                     UINT8 d = compute_newval((cursor_status>>5) & 0x07, video_ram[a][py*16*cw + px*cw + c + scroll * 48], cursor[c]);
204                     UINT8 d = compute_newval((m_cursor_status>>5) & 0x07, m_video_ram[a][py*16*cw + px*cw + c + m_scroll * 48], m_cursor[c]);
205205                     for (int b=0; b<8; b++)
206206                     {
207207                        *BITMAP_ADDR16(&bitmap, py*8 + b, a*cw*16 + px*cw + c) = BIT(d, 7-b);
r10256r10257
212212               {
213213                  for (int c=0; c<cw; c++)
214214                  {
215                     UINT8 d = video_ram[a][py*16*cw + px*cw + c + scroll * 48];
215                     UINT8 d = m_video_ram[a][py*16*cw + px*cw + c + m_scroll * 48];
216216                     for (int b=0; b<8; b++)
217217                     {
218218                        *BITMAP_ADDR16(&bitmap, py*8 + b, a*cw*16 + px*cw + c) = BIT(d, 7-b);
r10256r10257
227227
228228void hd44352_device::control_write(UINT8 data)
229229{
230   if(control_lines == data)
231      state = 0;
230   if(m_control_lines == data)
231      m_state = 0;
232232
233   control_lines = data;
233   m_control_lines = data;
234234}
235235
236236UINT8 hd44352_device::compute_newval(UINT8 type, UINT8 oldval, UINT8 newval)
r10256r10257
261261   switch ((UINT8)pos/8)
262262   {
263263      case 0xcf:
264         return custom_char[0][pos%8];
264         return m_custom_char[0][pos%8];
265265      case 0xdf:
266         return custom_char[1][pos%8];
266         return m_custom_char[1][pos%8];
267267      case 0xef:
268         return custom_char[2][pos%8];
268         return m_custom_char[2][pos%8];
269269      case 0xff:
270         return custom_char[3][pos%8];
270         return m_custom_char[3][pos%8];
271271      default:
272272         return region()->u8(pos);
273273   }
r10256r10257
276276void hd44352_device::data_write(UINT8 data)
277277{
278278   // verify that controller is active
279   if (!(control_lines&0x80))
279   if (!(m_control_lines&0x80))
280280      return;
281281
282   if (control_lines & 0x01)
282   if (m_control_lines & 0x01)
283283   {
284      if (!(control_lines&0x02) && !(control_lines&0x04))
284      if (!(m_control_lines&0x02) && !(m_control_lines&0x04))
285285         return;
286286
287      switch (state)
287      switch (m_state)
288288      {
289289         case 0:      //parameter 0
290            par[state++] = data;
290            m_par[m_state++] = data;
291291            break;
292292         case 1:      //parameter 1
293            par[state++] = data;
293            m_par[m_state++] = data;
294294            break;
295295         case 2:      //parameter 2
296            par[state++] = data;
296            m_par[m_state++] = data;
297297            break;
298298      }
299299
300      switch (par[0] & 0x0f)
300      switch (m_par[0] & 0x0f)
301301      {
302302         case LCD_BYTE_INPUT:
303303         case LCD_CHAR_OUTPUT:
304304            {
305               if (state == 1)
306                  bank = BIT(data, 4);
307               else if (state == 2)
308                  offset = ((data>>1)&0x3f) % 48 + (BIT(data,7) * 48);
309               else if (state == 3)
310                  offset += ((data & 0x03) * 96);
305               if (m_state == 1)
306                  m_bank = BIT(data, 4);
307               else if (m_state == 2)
308                  m_offset = ((data>>1)&0x3f) % 48 + (BIT(data,7) * 48);
309               else if (m_state == 3)
310                  m_offset += ((data & 0x03) * 96);
311311            }
312312            break;
313313         case LCD_BYTE_OUTPUT:
314314            {
315               if (state == 1)
316                  bank = BIT(data, 4);
317               else if (state == 2)
318                  offset = ((data>>1)&0x3f) % 48 + (BIT(data,7) * 48);
319               else if (state == 3)
320                  offset += ((data & 0x03) * 96);
315               if (m_state == 1)
316                  m_bank = BIT(data, 4);
317               else if (m_state == 2)
318                  m_offset = ((data>>1)&0x3f) % 48 + (BIT(data,7) * 48);
319               else if (m_state == 3)
320                  m_offset += ((data & 0x03) * 96);
321321            }
322322            break;
323323         case LCD_ON_OFF:
324324            {
325               if (state == 1)
326                  lcd_on = BIT(data, 4);
327               data_bus = 0xff;
328               state = 0;
325               if (m_state == 1)
326                  m_lcd_on = BIT(data, 4);
327               m_data_bus = 0xff;
328               m_state = 0;
329329            }
330330            break;
331331         case LCD_SCROLL_CHAR_WIDTH:
332332            {
333               if (state == 1)
333               if (m_state == 1)
334334               {
335                  char_width = 8-((data>>4)&3);
336                  scroll = ((data>>6)&3);
335                  m_char_width = 8-((data>>4)&3);
336                  m_scroll = ((data>>6)&3);
337337               }
338338
339               data_bus = 0xff;
340               state = 0;
339               m_data_bus = 0xff;
340               m_state = 0;
341341            }
342342            break;
343343         case LCD_CURSOR_STATUS:
344344            {
345               if (state == 1)
346                  cursor_status = data;
347               data_bus = 0xff;
348               state = 0;
345               if (m_state == 1)
346                  m_cursor_status = data;
347               m_data_bus = 0xff;
348               m_state = 0;
349349            }
350350            break;
351351         case LCD_CONTRAST:
352352            {
353               if (state == 1)
354                  contrast = (contrast & 0x00ffff) | (data<<16);
355               else if (state == 2)
356                  contrast = (contrast & 0xff00ff) | (data<<8);
357               else if (state == 3)
353               if (m_state == 1)
354                  m_contrast = (m_contrast & 0x00ffff) | (data<<16);
355               else if (m_state == 2)
356                  m_contrast = (m_contrast & 0xff00ff) | (data<<8);
357               else if (m_state == 3)
358358               {
359                  contrast = (contrast & 0xffff00) | (data<<0);
360                  state = 0;
359                  m_contrast = (m_contrast & 0xffff00) | (data<<0);
360                  m_state = 0;
361361               }
362362
363               data_bus = 0xff;
363               m_data_bus = 0xff;
364364            }
365365            break;
366366         case LCD_IRQ_FREQUENCY:
367367            {
368               if (state == 1)
368               if (m_state == 1)
369369               {
370370                  UINT32 on_timer_rate;
371371
r10256r10257
388388
389389                  timer_adjust_periodic(m_on_timer, ATTOTIME_IN_HZ(m_clock/on_timer_rate), 0, ATTOTIME_IN_HZ(m_clock/on_timer_rate));
390390               }
391               data_bus = 0xff;
392               state = 0;
391               m_data_bus = 0xff;
392               m_state = 0;
393393            }
394394            break;
395395         case LCD_CURSOR_POSITION:
396396            {
397               if (state == 1)
398                  cursor_lcd = BIT(data, 4);   //0:left lcd 1:right lcd;
399               else if (state == 2)
400                  cursor_x = ((data>>1)&0x3f) % 48 + (BIT(data,7) * 48);
401               else if (state == 3)
397               if (m_state == 1)
398                  m_cursor_lcd = BIT(data, 4);   //0:left lcd 1:right lcd;
399               else if (m_state == 2)
400                  m_cursor_x = ((data>>1)&0x3f) % 48 + (BIT(data,7) * 48);
401               else if (m_state == 3)
402402               {
403                  cursor_y = data & 0x03;
404                  state = 0;
403                  m_cursor_y = data & 0x03;
404                  m_state = 0;
405405               }
406406
407               data_bus = 0xff;
407               m_data_bus = 0xff;
408408            }
409409            break;
410410      }
411411
412      byte_count = 0;
413      data_bus = 0xff;
412      m_byte_count = 0;
413      m_data_bus = 0xff;
414414   }
415415   else
416416   {
417      switch (par[0] & 0x0f)
417      switch (m_par[0] & 0x0f)
418418      {
419419         case LCD_BYTE_INPUT:
420420            {
421               if (((par[0]>>5) & 0x07) != 0x03)
421               if (((m_par[0]>>5) & 0x07) != 0x03)
422422                  break;
423423
424               offset %= 0x180;
425               data_bus = ((video_ram[bank][offset]<<4)&0xf0) | ((video_ram[bank][offset]>>4)&0x0f);
426               offset++; byte_count++;
424               m_offset %= 0x180;
425               m_data_bus = ((m_video_ram[m_bank][m_offset]<<4)&0xf0) | ((m_video_ram[m_bank][m_offset]>>4)&0x0f);
426               m_offset++; m_byte_count++;
427427            }
428428            break;
429429         case LCD_BYTE_OUTPUT:
430430            {
431               offset %= 0x180;
432               video_ram[bank][offset] = compute_newval((par[0]>>5) & 0x07, video_ram[bank][offset], data);
433               offset++; byte_count++;
431               m_offset %= 0x180;
432               m_video_ram[m_bank][m_offset] = compute_newval((m_par[0]>>5) & 0x07, m_video_ram[m_bank][m_offset], data);
433               m_offset++; m_byte_count++;
434434
435               data_bus = 0xff;
435               m_data_bus = 0xff;
436436            }
437437            break;
438438         case LCD_CHAR_OUTPUT:
439439            {
440440               int char_pos = data*8;
441441
442               for (int i=0; i<char_width; i++)
442               for (int i=0; i<m_char_width; i++)
443443               {
444                  offset %= 0x180;
445                  video_ram[bank][offset] = compute_newval((par[0]>>5) & 0x07, video_ram[bank][offset], get_char(char_pos));
446                  offset++; char_pos++;
444                  m_offset %= 0x180;
445                  m_video_ram[m_bank][m_offset] = compute_newval((m_par[0]>>5) & 0x07, m_video_ram[m_bank][m_offset], get_char(char_pos));
446                  m_offset++; char_pos++;
447447               }
448448
449               byte_count++;
450               data_bus = 0xff;
449               m_byte_count++;
450               m_data_bus = 0xff;
451451            }
452452            break;
453453         case LCD_CURSOR_GRAPHIC:
454            if (byte_count<8)
454            if (m_byte_count<8)
455455            {
456               cursor[byte_count] = data;
457               byte_count++;
458               data_bus = 0xff;
456               m_cursor[m_byte_count] = data;
457               m_byte_count++;
458               m_data_bus = 0xff;
459459            }
460460            break;
461461         case LCD_CURSOR_CHAR:
462            if (byte_count<1)
462            if (m_byte_count<1)
463463            {
464464               UINT8 char_code = ((data<<4)&0xf0) | ((data>>4)&0x0f);
465465
466466               for (int i=0; i<8; i++)
467                  cursor[i] = get_char(char_code*8 + i);
467                  m_cursor[i] = get_char(char_code*8 + i);
468468
469               byte_count++;
470               data_bus = 0xff;
469               m_byte_count++;
470               m_data_bus = 0xff;
471471            }
472472            break;
473473         case LCD_USER_CHARACTER:
474            if (byte_count<8)
474            if (m_byte_count<8)
475475            {
476               custom_char[(par[0]&0x03)][byte_count] = data;
477               byte_count++;
478               data_bus = 0xff;
476               m_custom_char[(m_par[1]&0x03)][m_byte_count] = data;
477               m_byte_count++;
478               m_data_bus = 0xff;
479479            }
480480            break;
481481         default:
482            data_bus = 0xff;
482            m_data_bus = 0xff;
483483      }
484484
485      state=0;
485      m_state=0;
486486   }
487487}
488488
489489UINT8 hd44352_device::data_read()
490490{
491   return data_bus;
491   return m_data_bus;
492492}
493493
494494// devices
495495const device_type HD44352 = hd44352_device_config::static_alloc_device_config;
496
src/mess/includes/ti89.h
r10256r10257
5454   bool video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect);
5555
5656   UINT8 keypad_r (running_machine *machine);
57   WRITE16_MEMBER ( ti68k_io_w );
58   READ16_MEMBER ( ti68k_io_r );
59   WRITE16_MEMBER ( ti68k_io2_w );
60   READ16_MEMBER ( ti68k_io2_r );
61   WRITE16_MEMBER ( flash_w );
62   READ16_MEMBER ( flash_r );
57   DECLARE_WRITE16_MEMBER ( ti68k_io_w );
58   DECLARE_READ16_MEMBER ( ti68k_io_r );
59   DECLARE_WRITE16_MEMBER ( ti68k_io2_w );
60   DECLARE_READ16_MEMBER ( ti68k_io2_r );
61   DECLARE_WRITE16_MEMBER ( flash_w );
62   DECLARE_READ16_MEMBER ( flash_r );
6363   UINT64 timer;
6464};
6565
src/mess/includes/psion.h
r10256r10257
7676   UINT8 kb_read(running_machine *machine);
7777   void update_banks(running_machine *machine);
7878   datapack *get_active_slot(UINT8 data);
79   WRITE8_MEMBER( hd63701_int_reg_w );
80   READ8_MEMBER( hd63701_int_reg_r );
79   DECLARE_WRITE8_MEMBER( hd63701_int_reg_w );
80   DECLARE_READ8_MEMBER( hd63701_int_reg_r );
8181   void io_rw(address_space &space, UINT16 offset);
82   WRITE8_MEMBER( io_w );
83   READ8_MEMBER( io_r );
82   DECLARE_WRITE8_MEMBER( io_w );
83   DECLARE_READ8_MEMBER( io_r );
8484};
8585
8686#endif   // _PSION_H_
src/mess/drivers/pro80.c
r10256r10257
2626
2727   void machine_reset();
2828
29   WRITE8_MEMBER( digit_w );
30   WRITE8_MEMBER( segment_w );
31   READ8_MEMBER( kp_r );
29   DECLARE_WRITE8_MEMBER( digit_w );
30   DECLARE_WRITE8_MEMBER( segment_w );
31   DECLARE_READ8_MEMBER( kp_r );
3232
3333   UINT8 digit_sel;
3434};
src/mess/drivers/psion.c
r10256r10257
757757   MCFG_CARTSLOT_LOAD(psion_pack2)
758758   MCFG_CARTSLOT_UNLOAD(psion_pack2)
759759   MCFG_CARTSLOT_INTERFACE("psion_pack")
760   
760
761761   /* Software lists */
762762   MCFG_SOFTWARE_LIST_ADD("pack_list", "psion")
763763MACHINE_CONFIG_END

Previous 15994 Revisions Next


© 1998-2018 The MESS Team