OSDN Git Service

Enable to track git://github.com/monaka/binutils.git
[pf3gnuchains/pf3gnuchains3x.git] / sid / component / lcd / HD44780U.h
1 // HD44780U.h - description.  -*- C++ -*-
2
3 // Copyright (C) 1999, 2000 Red Hat.
4 // This file is part of SID and is licensed under the GPL.
5 // See the file COPYING.SID for conditions for redistribution.
6
7 #ifndef HD44780U_DEF_H
8 #define HD44780U_DEF_H  1
9
10 #include <sidtypes.h>
11 #include <sidcomp.h>
12 #include <sidcomputil.h>
13 #include <sidbusutil.h>
14 #include <sidpinutil.h>
15 #include <sidattrutil.h>
16 #include <sidschedutil.h>
17 #include <sidwatchutil.h>
18
19 static const int DRAM_SIZE = 80;
20 static const int CGRAM_SIZE = 64;
21 static const int ROM_SIZE = 256;
22
23 using std::vector;
24 using std::string;
25 using std::ostream;
26 using std::istream;
27 using std::ios;
28 using std::cerr;
29 using std::endl;
30
31 using sid::component;
32 using sid::host_int_1;
33 using sid::host_int_4;
34
35 using namespace sidutil;
36
37 class HD44780U: public virtual component,
38                 public no_accessor_component,
39                 public fixed_attribute_map_component,
40                 public no_relation_component,
41                 public fixed_bus_map_component,
42                 public fixed_pin_map_component
43 {
44 private:
45
46  /* The following pin replaces 58(!) pins on the real chip.
47   * Instead of 16 row and 40 column selectors, I encode the row and column
48   * on the row_col pin. The pin is only driven if the pixel is on.
49   */
50   output_pin row_col_pin;       // single pixel on/off at [row,col]
51
52  /* The frame pin is a synthetic pin added to tell the display when a
53   * refresh is starting/ending.
54   */
55   output_pin frame_pin;
56
57   // registers
58   host_int_1 ir;                // instruction register
59   host_int_1 dr;                // data register
60   host_int_1 ac;                // address counter
61
62   // state
63   char two_lines;               // two lines if non-zero
64   char big_font;                // 5X10 font if non-zero
65   char display;                 // display on/off
66   char cursor;                  // cursor on/off
67   char blink;                   // blink on/off
68   char incr;                    // incr/decr
69
70   // memory
71   host_int_1 dram[DRAM_SIZE];   // data ram
72   host_int_1 cgram[CGRAM_SIZE]; // character generator ram
73   host_int_1 rom[ROM_SIZE][8];  // stored character rom
74   host_int_1 rom10[32][11];     // 5X10 character rom
75
76   bool access_cgram;            // access DDRAM vs CGRAM
77   unsigned addr_bound;
78   bool use_europe_rom;
79
80   void incr_ac();               // inc/dec ac
81
82   int display_offset;
83   bool shift_on_write;
84
85   // bus
86   friend class callback_byte_bus<HD44780U>;
87   callback_byte_bus<HD44780U> busif;
88
89   sid::bus::status busRead( host_int_4 laddr, host_int_1& data );
90   sid::bus::status busWrite( host_int_4 laddr, host_int_1 data );
91
92   void execute( unsigned char );
93
94   // send DDRAM contents to the display
95   void refresh();
96
97   friend class scheduler_event_subscription<HD44780U>;
98   scheduler_event_subscription<HD44780U> refresh_sync;
99
100   enum {
101     NO_SCHED,
102     ONE_TIME_SCHED,
103     REGULAR_SCHED
104   };
105
106   int current_schedule;                 // one of the above
107   host_int_4 refresh_period;            // in milliseconds
108
109   bool blinking_chars_are_visible;
110
111   // Triggerpoint manager
112   friend class self_watcher<HD44780U>;
113   self_watcher<HD44780U> trigger_mgr;
114
115   // Virtual pin interfaces between self_watcher and fixed_pin_map_component
116   sid::component::status
117   pin_factory( const string& n ) { return trigger_mgr.create_virtual_pin(n); }
118
119   void
120   pin_junkyard( const string& n ) { trigger_mgr.destroy_virtual_pin( n ); }
121
122   bool verbose;
123
124 public:
125
126   HD44780U( bool use_japan_rom );
127
128   void reset();
129
130   ~HD44780U () throw() {}
131
132   // save & restore
133
134   string save_state();
135   component::status restore_state( const string& state );
136
137   friend ostream& operator << (ostream& op, const HD44780U& copy_obj);
138   friend istream& operator >> (istream& ip, HD44780U& ovwrite_obj);
139 };
140
141 #endif // HD44780U_DEF_H