Previous 15994 Revisions Next

r15967 Sunday 19th August, 2012 at 19:53:29 UTC by Sandro Ronco
Split Psion custom LCD controller from HD44780 device. (nw)
[src/mess]mess.mak
[src/mess/drivers]alesis.c lcmate2.c mmodular.c pc2000.c psion.c
[src/mess/includes]psion.h
[src/mess/video]hd44780.c hd44780.h psion.c*

src/mess/includes/psion.h
r15966r15967
99#ifndef _PSION_H_
1010#define _PSION_H_
1111
12#include "cpu/m6800/m6800.h"
13#include "machine/psion_pack.h"
14#include "video/hd44780.h"
15#include "sound/beep.h"
16
17#define MCFG_PSION_CUSTOM_LCDC_ADD( _tag , _config) \
18   MCFG_DEVICE_ADD( _tag, PSION_CUSTOM_LCDC, 0 ) \
19   MCFG_DEVICE_CONFIG(_config)
20
21// ======================> psion_custom_lcdc
22
23class psion_custom_lcdc :   public hd44780_device
24{
25
26public:
27   // construction/destruction
28   psion_custom_lcdc(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
29
30   // hd44780_device overrides
31   virtual DECLARE_WRITE8_MEMBER(control_write);
32   virtual UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
33};
34
35
36// ======================> psion_state
37
1238class psion_state : public driver_device
1339{
1440public:
r15966r15967
6086   DECLARE_READ8_MEMBER( io_r );
6187};
6288
89// device type definition
90extern const device_type PSION_CUSTOM_LCDC;
91
6392#endif   // _PSION_H_
src/mess/video/hd44780.c
r15966r15967
3737   else
3838   {
3939      height = width = 0;
40      custom_layout = NULL;
4140   }
4241}
4342
44//-------------------------------------------------
45//  device_validity_check - perform validity checks
46//  on this device
47//-------------------------------------------------
4843
49void hd44780_device::device_validity_check(validity_checker &valid) const
50{
51   // display with more than 2 lines requires a layout
52   if ((custom_layout == NULL && height > 2) || height == 0 || width == 0)
53      mame_printf_error("Configured with invalid parameter\n");
54}
55
5644//**************************************************************************
5745//  live device
5846//**************************************************************************
r15966r15967
6654{
6755}
6856
57hd44780_device::hd44780_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) :
58   device_t(mconfig, type, name, tag, owner, clock)
59{
60}
6961
7062//-------------------------------------------------
7163//  device_start - device-specific startup
r15966r15967
170162            UINT8 line_size = (m_num_line) ? 40 : 80;
171163            INT8 char_pos = line_base + i;
172164
173            // if specified uses the custom layout
174            if (custom_layout != NULL)
175               char_pos = custom_layout[l*width + i];
176            else
177            {
178               char_pos += m_disp_shift;
165            char_pos += m_disp_shift;
179166
180               while (char_pos < 0 || (char_pos - line_base) >= line_size)
181               {
182                  if (char_pos < 0)
183                     char_pos += line_size;
184                  else if (char_pos - line_base >= line_size)
185                     char_pos -= line_size;
186               }
167            while (char_pos < 0 || (char_pos - line_base) >= line_size)
168            {
169               if (char_pos < 0)
170                  char_pos += line_size;
171               else if (char_pos - line_base >= line_size)
172                  char_pos -= line_size;
187173            }
174
188175            for (int y=0; y<8; y++)
189176               for (int x=0; x<5; x++)
190177                  if (m_ddram[char_pos] <= 0x10)
r15966r15967
224211         }
225212
226213   return 0;
227
228214}
229215
230216WRITE8_MEMBER(hd44780_device::control_write)
r15966r15967
233219   {
234220      m_ac_mode = 0;
235221      m_ac = data & 0x7f;
236      if (data != 0x81) // not in datasheet spec
237         m_cursor_pos = m_ac;
222      m_cursor_pos = m_ac;
238223      set_busy_flag(37);
239224   }
240225   else if (BIT(data, 6)) // Set CGRAM Address
src/mess/video/hd44780.h
r15966r15967
1717//**************************************************************************
1818//  TYPE DEFINITIONS
1919//**************************************************************************
20   
21#define HD44780_INTERFACE(name) \
22   const hd44780_interface (name) =
2023
2124// ======================> hd44780_interface
2225
r15966r15967
2427{
2528   UINT8 height;         // number of lines
2629   UINT8 width;         // chars for line
27   const UINT8 *custom_layout;   // custom display layout (NULL for default)
2830};
2931
3032// ======================> hd44780_device
r15966r15967
3638public:
3739   // construction/destruction
3840   hd44780_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
41   hd44780_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
3942
4043   // device interface
41   DECLARE_WRITE8_MEMBER(control_write);
42   DECLARE_READ8_MEMBER(control_read);
43   DECLARE_WRITE8_MEMBER(data_write);
44   DECLARE_READ8_MEMBER(data_read);
44   virtual DECLARE_WRITE8_MEMBER(control_write);
45   virtual DECLARE_READ8_MEMBER(control_read);
46   virtual DECLARE_WRITE8_MEMBER(data_write);
47   virtual DECLARE_READ8_MEMBER(data_read);
4548
46   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
49   virtual UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4750
4851protected:
4952   // device-level overrides
r15966r15967
5154   virtual void device_reset();
5255   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
5356   virtual void device_config_complete();
54   virtual void device_validity_check(validity_checker &valid) const;
5557
56private:
58protected:
5759   // internal helper
5860   void set_busy_flag(UINT16 usec);
5961   void update_ac(void);
src/mess/video/psion.c
r0r15967
1/***************************************************************************
2
3        Psion Organiser II LZ series custom LCD controller
4
5***************************************************************************/
6
7#include "emu.h"
8#include "includes/psion.h"
9
10// devices
11const device_type PSION_CUSTOM_LCDC = &device_creator<psion_custom_lcdc>;
12
13
14//**************************************************************************
15//  live device
16//**************************************************************************
17
18//-------------------------------------------------
19//  psion_custom_lcdc - constructor
20//-------------------------------------------------
21
22psion_custom_lcdc::psion_custom_lcdc(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
23   hd44780_device(mconfig, PSION_CUSTOM_LCDC, "Psion Custom LCD Controller", tag, owner, clock)
24{
25}
26
27
28//**************************************************************************
29//  device interface
30//**************************************************************************
31
32UINT32 psion_custom_lcdc::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
33{
34   assert(height*9 <= bitmap.height() && width*6 <= bitmap.width());
35
36   bitmap.fill(0, cliprect);
37
38   if (m_display_on)
39      for (int l=0; l<height; l++)
40         for (int i=0; i<width; i++)
41         {
42            static const UINT8 psion_display_layout[] =
43            {
44               0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
45               0x40, 0x41, 0x42, 0x43, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
46               0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
47               0x44, 0x45, 0x46, 0x47, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67
48            };
49
50            INT8 char_pos = psion_display_layout[l*width + i];
51
52            for (int y=0; y<8; y++)
53               for (int x=0; x<5; x++)
54                  if (m_ddram[char_pos] <= 0x10)
55                  {
56                     //draw CGRAM characters
57                     bitmap.pix16(l*9 + y, i*6 + x) = BIT(m_cgram[(m_ddram[char_pos]&0x07)*8+y], 4-x);
58                  }
59                  else
60                  {
61                     //draw CGROM characters
62                     if (region()->bytes() <= 0x800)
63                     {
64                        bitmap.pix16(l*9 + y, i*6 + x) = BIT(region()->u8(m_ddram[char_pos]*8+y), 4-x);
65                     }
66                     else
67                     {
68                        if(m_ddram[char_pos] < 0xe0)
69                           bitmap.pix16(l*9 + y, i*6 + x) = BIT(region()->u8(m_ddram[char_pos]*8+y), 4-x);
70                        else
71                           bitmap.pix16(l*9 + y, i*6 + x) = BIT(region()->u8(0x700+((m_ddram[char_pos]-0xe0)*11)+y), 4-x);
72                     }
73                  }
74
75            // if is the correct position draw cursor and blink
76            if (char_pos == m_cursor_pos)
77            {
78               //draw the cursor
79               if (m_cursor_on)
80                  for (int x=0; x<5; x++)
81                     bitmap.pix16(l*9 + 7, i * 6 + x) = 1;
82
83               if (!m_blink && m_blink_on)
84                  for (int y=0; y<7; y++)
85                     for (int x=0; x<5; x++)
86                        bitmap.pix16(l*9 + y, i * 6 + x) = 1;
87            }
88         }
89
90   return 0;
91}
92
93WRITE8_MEMBER(psion_custom_lcdc::control_write)
94{
95   if (BIT(data, 7)) // Set DDRAM Address
96   {
97      m_ac_mode = 0;
98      m_ac = data & 0x7f;
99      if (data != 0x81)
100         m_cursor_pos = m_ac;
101      set_busy_flag(37);
102   }
103   else
104      hd44780_device::control_write(space, offset, data);
105}
106
107
src/mess/drivers/lcmate2.c
r15966r15967
202202   membank("rombank")->configure_entries(0, 0x10, (UINT8*)machine().root_device().memregion("maincpu")->base(), 0x4000);
203203}
204204
205static const hd44780_interface lcmate2_display =
205static HD44780_INTERFACE( lcmate2_display )
206206{
207207   2,               // number of lines
208   20,               // chars for line
209   NULL            // custom display layout
208   20               // chars for line
210209};
211210
212211static const gfx_layout lcmate2_charlayout =
src/mess/drivers/pc2000.c
r15966r15967
316316   GFXDECODE_ENTRY( "hd44780", 0x0000, hd44780_charlayout, 0, 1 )
317317GFXDECODE_END
318318
319static const hd44780_interface pc2000_display =
319static HD44780_INTERFACE( pc2000_display )
320320{
321321   2,               // number of lines
322   20,               // chars for line
323   NULL            // custom display layout
322   20               // chars for line
324323};
325324
326325static MACHINE_CONFIG_START( pc2000, pc2000_state )
src/mess/drivers/mmodular.c
r15966r15967
188188   DECLARE_DRIVER_INIT(polgar);
189189};
190190
191static const hd44780_interface chess_display =
191static HD44780_INTERFACE( chess_display )
192192{
193193    2,                  // number of lines
194    16,                 // chars for line
195    NULL                // custom display layout
194    16                  // chars for line
196195};
197196
198197static UINT8 convert_imputmask(UINT8 input)
src/mess/drivers/alesis.c
r15966r15967
188188   return 0;
189189}
190190
191static const hd44780_interface hr16_display =
191static HD44780_INTERFACE( hr16_display )
192192{
193193   2,               // number of lines
194   16,               // chars for line
195   NULL            // custom display layout
194   16               // chars for line
196195};
197196
198197static const cassette_interface hr16_cassette_interface =
src/mess/drivers/psion.c
r15966r15967
1919
2020
2121#include "emu.h"
22#include "cpu/m6800/m6800.h"
23#include "sound/beep.h"
24#include "machine/psion_pack.h"
25#include "video/hd44780.h"
2622#include "includes/psion.h"
2723#include "rendlay.h"
2824
r15966r15967
464460   GFXDECODE_ENTRY( "hd44780", 0x0000, psion_charlayout, 0, 1 )
465461GFXDECODE_END
466462
467static const hd44780_interface psion_2line_display =
463static HD44780_INTERFACE( psion_2line_display )
468464{
469465   2,               // number of lines
470   16,               // chars for line
471   NULL            // custom display layout
466   16               // chars for line
472467};
473468
474469/* basic configuration for 2 lines display */
r15966r15967
507502   MCFG_SOFTWARE_LIST_ADD("pack_list", "psion")
508503MACHINE_CONFIG_END
509504
510static const UINT8 psion_4line_layout[] =
511{
512   0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
513   0x40, 0x41, 0x42, 0x43, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
514   0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
515   0x44, 0x45, 0x46, 0x47, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67
516};
517505
518static const hd44780_interface psion_4line_display =
506static HD44780_INTERFACE( psion_4line_display )
519507{
520508   4,               // number of lines
521   20,               // chars for line
522   psion_4line_layout   // custom display layout
509   20               // chars for line
523510};
524511
525512/* basic configuration for 4 lines display */
r15966r15967
539526    MCFG_PALETTE_INIT(psion)
540527   MCFG_GFXDECODE(psion)
541528
542   MCFG_HD44780_ADD("hd44780", psion_4line_display)
529   MCFG_PSION_CUSTOM_LCDC_ADD("hd44780", psion_4line_display)
543530
544531   /* sound hardware */
545532   MCFG_SPEAKER_STANDARD_MONO( "mono" )
src/mess/mess.mak
r15966r15967
14781478
14791479$(MESSOBJ)/psion.a:            \
14801480   $(MESS_DRIVERS)/psion.o      \
1481   $(MESS_VIDEO)/psion.o      \
14811482   $(MESS_MACHINE)/psion_pack.o   \
14821483
14831484$(MESSOBJ)/radio.a:            \

Previous 15994 Revisions Next


© 1998-2018 The MESS Team