1 // t6963c-japan.cxx - 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.
7 #include "t6963c-japan.h"
36 STA0 = 0x1, // set if ready to take next command
37 STA1 = 0x2, // set if memory ready
38 STA2 = 0x4, // set if auto read
39 STA3 = 0x8, // set if auto write
40 STA6 = 0x40, // set if peek/poke error
41 STA7 = 0x80, // set if display on
50 T6963C_tester :: T6963C_tester() : run_ipin( this, &T6963C_tester::run ) {
51 add_pin( "run", &run_ipin, &run_opin );
52 add_accessor( "bus", &bus );
55 add_uni_relation( "lcd", &lcd );
58 add_uni_relation( "ddram", &dram );
65 T6963C_tester :: check_status( uchar what ) {
69 if( bus->read( STATUS_REG, val ) != sid::bus::ok ) {
71 printf( "check_status: read failed\n" );
76 if( (byte & what) != what ) {
78 printf( "check_status: bad status - got %02x != %02x\n", byte, what );
86 T6963C_tester :: send_cmd( uchar cmd ) {
89 if( !check_status( STA1 | STA0 ) )
92 if( bus->write( CMD_REG, val ) != sid::bus::ok ) {
94 printf( "send_cmd: bad write\n" );
102 T6963C_tester :: reset_auto( uchar mode ) {
103 big_int_1 val = CLR_AUTO_RW;
105 if( !check_status( mode ) )
108 if( bus->write( CMD_REG, val ) != sid::bus::ok ) {
110 printf( "reset_auto: bad write\n" );
118 T6963C_tester :: send_data( uchar data ) {
119 big_int_1 val = data;
121 if( !check_status( STA1 | STA0 ) )
124 if( bus->write( DATA_REG, val ) != sid::bus::ok ) {
126 printf( "send_data: bad write\n" );
134 T6963C_tester :: get_data( uchar& data ) {
137 if( !check_status( STA1 | STA0 ) )
140 if( bus->read( DATA_REG, val ) != sid::bus::ok ) {
142 printf( "get_data: read failed\n" );
151 T6963C_tester :: write_mem( uchar cmd, uchar val ) {
152 if( !send_data( val ) )
155 if( !send_cmd( cmd ) )
162 T6963C_tester :: read_mem( uchar cmd, uchar& val ) {
163 if( !send_cmd( cmd ) )
166 return get_data( val );
170 T6963C_tester :: auto_write( uchar data ) {
171 big_int_1 val = data;
173 if( !check_status( STA3 ) )
176 if( bus->write( DATA_REG, val ) != sid::bus::ok ) {
178 printf( "auto_write failed\n" );
186 T6963C_tester :: auto_read( uchar& data ) {
189 if( !check_status( STA2 ) )
192 if( bus->read( DATA_REG, val ) != sid::bus::ok ) {
194 printf( "auto_read failed\n" );
203 T6963C_tester :: set_word_reg( uchar cmd, uchar lo, uchar hi ) {
204 if( !send_data( lo ) )
207 if( !send_data( hi ) )
210 if( !send_cmd( cmd ) )
217 T6963C_tester :: mem_set( uchar val, unsigned addr, int len ) {
218 set_word_reg( SET_ADP, addr & 0xff, addr >> 8 );
219 send_cmd( SET_AWRITE );
221 for( int i=0; i<len; i++ )
228 T6963C_tester :: init() {
232 cout << "starting T6963C LCD tests" << endl;
234 //intialize the display
235 set_word_reg( SET_TXT_HOME, 0x00, 0x00 );
236 set_word_reg( SET_TXT_AREA, NCOLS, 0 );
237 set_word_reg( SET_GRX_HOME, 0x00, 0x02 );
238 set_word_reg( SET_GRX_AREA, NCOLS, 0 );
240 // mode set: OR mode, internal cgen
243 mem_set( 0, 0, NCOLS*NROWS ); // clear display
245 // write a text string
246 set_word_reg( SET_ADP, 2*NCOLS+1, 0x00 ); // row 2, col 1
247 send_cmd( SET_AWRITE );
249 char *test_str = "CYGNUS";
250 int len = strlen( test_str );
252 for( i=0; i<len; i++ )
253 auto_write( test_str[i] - ' ' );
256 set_word_reg( SET_ADP, 4*NCOLS+1, 0x00 ); // row 4, col 1
257 send_cmd( SET_AWRITE );
260 len = strlen( test_str );
262 for( i=0; i<len; i++ )
263 auto_write( test_str[i] - ' ' );
266 set_word_reg( SET_ADP, 3*NCOLS+4, 0x00 ); // row 3, col 4
267 write_mem( DWRITE, '+' - ' ' );
268 set_word_reg( SET_ADP, 5*NCOLS+4, 0x00 ); // row 5, col 4
269 write_mem( DWRITE, '=' - ' ' );
270 set_word_reg( SET_ADP, 6*NCOLS+3, 0x00 ); // row 6, col 3
271 write_mem( DWRITE_INC, '$' - ' ' );
272 write_mem( DWRITE_INC, 0 );
273 write_mem( DWRITE_INC, '?' - ' ' );
275 set_word_reg( SET_CURSOR, 3, 6 ); // cursor at [x,y] = 5,6
276 send_cmd( 0xa8 ); // 8-line cursor
278 // display: text on, graphics off, blinking cursor
281 cout << "should see 'CYGNUS + REDHAT = $?'" << endl;
285 T6963C_tester :: dump_rom() {
288 mem_set( 0, 0, NROWS*NCOLS ); // clear text mem
290 set_word_reg( SET_ADP, 0, 0 );
291 send_cmd( SET_AWRITE );
292 for( i=0x40; i<0x80; i++ )
296 set_word_reg( SET_CURSOR, NCOLS/2, NROWS/2 );
297 send_cmd( 0xa0 ); // 1-line cursor
299 send_cmd( 0x94 ); // text only, no cursor
301 cout << "should Japanese character set" << endl;
305 T6963C_tester :: yield( int to_state, unsigned long count ) {
306 if( state == WAITING ) {
307 if( curr_count < wait_count ) {
311 if( (curr_count % 1000) == 0 )
320 next_state = to_state;
328 T6963C_tester :: run( host_int_4 ) {
332 yield( DISABLE_DISPLAY, 1000000 );
335 case DISABLE_DISPLAY:
336 if( !lcd || !dram ) {
337 cout << "missing relation to lcd and/or dram" << endl;
341 snap_shot = lcd->attribute_value( "state-snapshot" );
342 dram_state = dram->attribute_value( "state-snapshot" );
343 cout << "Took a state snapshot" << endl;
346 send_cmd( 0x90 ); // disable display
347 cout << "Display should now be disabled" << endl;
348 yield( ENABLE_DISPLAY, 100000 );
353 cout << "Re-enabled display" << endl;
354 yield( DUMP_ROM, 0 );
359 yield( RESTORE, 1000000 );
364 component::status rc;
366 rc = lcd->set_attribute_value( "state-snapshot", snap_shot );
367 if( rc != component::ok ) {
368 cout << "lcd restore state failed" << endl;
371 rc = dram->set_attribute_value( "state-snapshot", dram_state );
372 if( rc != component::ok ) {
373 cout << "dram restore state failed" << endl;
377 cout << "state should be restored to snap-shot" << endl;
378 yield( DONE, 200000 );
383 yield( next_state, 0 );
390 cout << "all tests complete: fail count " << fail_count << endl;
395 static vector<string>
396 T6963CTesterListTypes() {
397 vector<string> types;
398 types.push_back(string("t6963c-tester"));
403 T6963CTesterCreate( const string& typeName ) {
404 if(typeName == "t6963c-tester")
405 return new T6963C_tester();
411 T6963CTesterDelete( component* c ) {
412 delete dynamic_cast<T6963C_tester*>(c);
417 extern const component_library t6963c_tester_component_library;
419 const component_library t6963c_tester_component_library DLLEXPORT =
421 COMPONENT_LIBRARY_MAGIC,
422 & T6963CTesterListTypes,
423 & T6963CTesterCreate,