1 // T6963C.h - description. -*- C++ -*-
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.
12 #include <sidcomputil.h>
13 #include <sidbusutil.h>
14 #include <sidpinutil.h>
15 #include <sidattrutil.h>
16 #include <sidschedutil.h>
17 #include <sidwatchutil.h>
20 using namespace sidutil;
22 static const int ROM_SIZE = 128 + 32;
24 class T6963C: public virtual component,
25 public fixed_accessor_map_component,
26 public fixed_attribute_map_component,
27 public fixed_bus_map_component,
28 public fixed_pin_map_component,
29 public no_relation_component
34 host_int_1 cursor_x, cursor_y;
38 host_int_2 graphic_home;
40 host_int_1 g_cols, t_cols;
44 /* Commands with arguments are sent as follows:
49 * check status (if D2 sent)
52 * dbuf1 and dbuf2 are data buffers to hold D1 and D2, respectively
55 unsigned char dbuf1, dbuf2;
60 bool cursor_on; // display mode
67 bool blinking_chars_are_visible;
69 // Set if in text attribute mode and at least one char has blink on
70 bool need_continuous_refresh;
74 /* The real chip uses a bunch of strobes to cycle through the pixels.
75 * Specifically, these are the LP, HSCP, and LSCP pins. I chose to abstract
76 * these pins into row/col so that we only have to output a pixel if it is on.
77 * Specifically, the row and col are multiplexed into a single word, and the
78 * row_col pin is only driven if that pixel is on.
80 output_pin row_col; // row/column selector
82 /* The frame pin is set on at the beginning of a refresh and turned off at
90 friend class callback_byte_bus<T6963C>;
91 callback_byte_bus<T6963C> busif;
93 /* The Toshiba specs give the following table for accessing the registers:
95 * WR! = L, C/D = H: Command Write, C/D = L: Data Write
96 * RD! = L, C/D = H: Status Read, C/D = L: Data Read
98 * So there really isn't an address range in a direct sense. To access the
99 * registers, I have assumed that C/D is tied to logical address line A0,
100 * so that the latch buffers are accessed as:
102 * Logical Address 0: Data buffer
103 * Logical Address 1: Command/Status register
105 sid::bus::status busRead( host_int_4 laddr, host_int_1& data );
106 sid::bus::status busWrite( host_int_4 laddr, host_int_1 data );
108 host_int_1 rom[ROM_SIZE][8];
110 void executeCommand( unsigned char cmd );
116 /* hw_rows and hw_cols are hardwired chip inputs derived from the MDS and
117 * MD0-3 pins. Note that the text area and graphic area commands can over-
118 * ride and refine these settings.
123 std::string getDisplayWidth() { return make_attribute( hw_cols ); }
124 component::status setDisplayWidth( const std::string& s );
126 std::string getDisplayHeight() { return make_attribute( hw_rows ); }
127 component::status setDisplayHeight( const std::string& s );
129 // The font-size attribute replaces the FS0 and FS1 pins
132 std::string getFontSize() { return make_attribute( font_width ); }
133 component::status setFontSize( const std::string& s );
135 /* Scheduler stuff. To save on simulation cycles, the screen is only refreshed
136 * if necessary. The two conditions used to determine that a refresh is
137 * required are: a) there was a write to the chip (data or control), b) either
138 * the cursor or some text is blinking. For (a) we use a one-time refresh,
139 * for (b) we use a continuous periodic refresh. The one-time refresh can
140 * turn into a periodic refresh if it turns out that we wrote something that
143 friend class sidutil::scheduler_event_subscription<T6963C>;
144 sidutil::scheduler_event_subscription<T6963C> refresh_sync;
154 int current_schedule; // one of the above
155 host_int_4 refresh_period; // in milliseconds
157 // Triggerpoint manager
158 friend class sidutil::self_watcher<T6963C>;
159 sidutil::self_watcher<T6963C> trigger_mgr;
161 // Virtual pin interfaces between self_watcher and fixed_pin_map_component
162 sid::component::status
163 pin_factory( const std::string& n ) { return trigger_mgr.create_virtual_pin(n); }
166 pin_junkyard( const std::string& n ) { trigger_mgr.destroy_virtual_pin( n ); }
168 // State save/restore.
169 std::string save_state ();
170 component::status restore_state ( const std::string& state );
171 friend std::ostream& operator << ( std::ostream& op, const T6963C& copy_obj );
172 friend std::istream& operator >> ( std::istream& ip, T6963C& ovwrite_obj );
176 T6963C( bool use_japan_rom );
183 #endif // T6963C_DEF_H