Previous 15994 Revisions Next

r9539 Monday 8th November, 2010 at 17:55:09 UTC by Cowering
update to use font from datasheet (A00 and A02) (needs redump someday) CGRAM works for Mephisto chess machines
[src/mess/video]hd44780.c

src/mess/video/hd44780.c
r9538r9539
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
13
1014***************************************************************************/
1115
1216#include "emu.h"
1317#include "video/hd44780.h"
1418
15
1619//**************************************************************************
1720//  device configuration
1821//**************************************************************************
r9538r9539
2629{
2730}
2831
29
3032//-------------------------------------------------
3133//  static_alloc_device_config - allocate a new
3234//  configuration object
r9538r9539
130132   state_save_register_device_item( this, 0, blink);
131133   state_save_register_device_item_array( this, 0, ddram);
132134   state_save_register_device_item_array( this, 0, cgram);
135
133136}
134137
135138
r9538r9539
141144{
142145   busy_flag = 0;
143146
144   memset(ddram, 0, ARRAY_LENGTH(ddram));
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
145148   memset(cgram, 0, ARRAY_LENGTH(cgram));
146149   ac = 0;
147150   ac_mode = 0;
r9538r9539
152155   shift_on = 0;
153156   blink_on = 0;
154157   direction = 1;
155   data_len = 1;
158   data_len = -1; // must not be 0 or 1 on intial start to pick up first 4/8 bit mode change
156159   n_line = 0;
157160   char_size = 0;
158161   disp_shift = 0;
r9538r9539
237240                     char_pos -= line_size;
238241               }
239242            }
240
241243            for (int y=0; y<8; y++)
242244               for (int x=0; x<5; x++)
243245                  if (ddram[char_pos] <= 0x10)
r9538r9539
248250                  else
249251                  {
250252                     //draw CGROM characters
251                     *BITMAP_ADDR16(bitmap, l*9 + y, i*6 + x) = BIT(region()->u8(ddram[char_pos]*8+y), 4-x);
253                     if (region()->bytes() <= 0x800) {
254                        *BITMAP_ADDR16(bitmap, l*9 + y, i*6 + x) = BIT(region()->u8(ddram[char_pos]*8+y), 4-x);
255                     } else {
256                        if(ddram[char_pos] < 0xe0) {
257                           *BITMAP_ADDR16(bitmap, l*9 + y, i*6 + x) = BIT(region()->u8(ddram[char_pos]*8+y), 4-x);
258                        } else {
259                           *BITMAP_ADDR16(bitmap, l*9 + y, i*6 + x) = BIT(region()->u8(0x700+((ddram[char_pos]-0xe0)*11)+y), 4-x);
260                        }
261                     }
252262                  }
253263
254264            // if is the correct position draw cursor and blink
r9538r9539
272282
273283void hd44780_device::control_write(offs_t offset, UINT8 data)
274284{
275   if (BIT(data, 7))
285   if (BIT(data, 7)) // Set DDRAM Address
276286   {
277287      ac_mode = 0;
278288      ac = data & 0x7f;
279      if (data != 0x81)
289      if (data != 0x81) // not in datasheet spec
280290         cursor_pos = ac;
281291      set_busy_flag(37);
282292   }
283   else if (BIT(data, 6))
293   else if (BIT(data, 6)) // Set CGRAM Address
284294   {
285295      ac_mode = 1;
286296      ac = data & 0x3f;
287297      set_busy_flag(37);
288298   }
289   else if (BIT(data, 5))
299   else if (BIT(data, 5)) // Function Set
290300   {
301      // datasheet says you can't change char size after first function set without altering 4/8 bit mode
302      if (BIT(data, 4) != data_len) {
303         char_size = BIT(data, 2);
304      }
291305      data_len = BIT(data, 4);
292306      n_line = BIT(data, 3);
293      char_size = BIT(data, 2);
294307      set_busy_flag(37);
295308   }
296   else if (BIT(data, 4))
309   else if (BIT(data, 4)) // Cursor or display shift
297310   {
298311      UINT8 direct = (BIT(data, 2)) ? +1 : -1;
299312
r9538r9539
307320
308321      set_busy_flag(37);
309322   }
310   else if (BIT(data, 3))
323   else if (BIT(data, 3)) // Display on/off Control
311324   {
312325      display_on = BIT(data, 2);
313326      cursor_on = BIT(data, 1);
r9538r9539
315328
316329      set_busy_flag(37);
317330   }
318   else if (BIT(data, 2))
331   else if (BIT(data, 2)) // Entry Mode set
319332   {
320333      direction = (BIT(data, 1)) ? +1 : -1;
321334
r9538r9539
323336
324337      set_busy_flag(37);
325338   }
326   else if (BIT(data, 1))
339   else if (BIT(data, 1)) // return home
327340   {
328341      ac = 0;
329342      cursor_pos = 0;
330      ac_mode = 0;
343      ac_mode = 0; // datasheet does not specifically say this but mephisto won't run without it
331344      direction = 1;
332345      disp_shift = 0;
333346      set_busy_flag(1520);
334347   }
335   else if (BIT(data, 0))
348   else if (BIT(data, 0)) // clear display
336349   {
337350      ac = 0;
338351      cursor_pos = 0;
r9538r9539
340353      direction = 1;
341354      disp_shift = 0;
342355      memset(ddram, 0x20, ARRAY_LENGTH(ddram));
343      memset(cgram, 0x20, ARRAY_LENGTH(cgram));
356      // nothing in datasheet says to clear CGRAM
357      // memset(cgram, 0x20, ARRAY_LENGTH(cgram));
344358      set_busy_flag(1520);
345359   }
346360}
r9538r9539
352366
353367void hd44780_device::data_write(offs_t offset, UINT8 data)
354368{
369   static int lastac = 0;
370   if (lastac != ac_mode) {
371      lastac = ac_mode;
372   }
373
355374   if (ac_mode == 0)
356375      ddram[ac] = data;
357   else
376   else {
358377      cgram[ac] = data;
359
378      }
360379   data_bus_flag = 1;
361380
362381   set_busy_flag(41);
r9538r9539
368387
369388   if (ac_mode == 0)
370389      data = ddram[ac];
371   else
390   else {
372391      data = cgram[ac];
392   }
373393
374394   data_bus_flag = 2;
375395

Previous 15994 Revisions Next


© 1998-2018 The MESS Team