OSDN Git Service

* public snapshot of sid simulator
[pf3gnuchains/pf3gnuchains3x.git] / sid / component / lcd / testsuite / hd-one-line.cxx
1 // hd-one-line.cxx - 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 #include "hd-one-line.h"
8 #include <sidso.h>
9
10 void
11 hd_one_line :: init() {
12   put( LCD_IR, 0x30 );          // 1-lines, 5x8 font
13   put( LCD_IR, 1 );             // clear display
14   put( LCD_IR, 0x3 );           // return home
15   put( LCD_IR, 0xc );           // enable display
16
17   put( LCD_IR, 0x80 );          // select DDRAM address 0
18
19   for( int i=0; i<8; i++ )
20     put( LCD_DR, 0xa1 + i );
21
22   put( LCD_IR, 0x7 );           // shift left on input
23   curr_char = 0xaa;
24
25   refresh.drive( 1 );
26   cout << "should see Japanese chars 0xa1-0xa9" << endl;
27 }
28
29 void
30 hd_one_line :: draw_char( uchar val ) {
31   put( LCD_DR, val );
32 }
33
34 void
35 hd_one_line :: run( host_int_4 ) {
36   switch( curr_state() ) {
37   case INIT:
38     init();
39     yield( SCROLL, 50000 );
40     return;
41
42   case SCROLL:
43     if( (curr_char & 0x0f) == 0 )
44       cout << "drawing japanese char " << hex << (int)curr_char << dec << endl;
45
46     draw_char( curr_char );
47     ++curr_char;
48     if( curr_char >= 0xe0 )
49       yield( DONE, 80000 );
50     else {
51       refresh.drive( 1 );
52       yield( SCROLL, 80000 );
53     }
54     return;
55
56   case WAITING:
57     yield();
58     return;
59
60   default:
61     break;
62   }
63
64   cout << "all tests complete: fail count " << fail_count << endl;
65
66   run_opin.drive( 0 );
67 }
68
69 static vector<string>
70 HD44780UTesterListTypes() {
71   vector<string> types;
72   types.push_back(string("hd44780u-tester"));
73   return types;
74 }
75
76 static component*
77 HD44780UTesterCreate( const string& typeName ) {
78   if(typeName == "hd44780u-tester")
79     return new hd_one_line();
80   else
81     return 0;
82 }
83
84 static void
85 HD44780UTesterDelete( component* c ) {
86   delete dynamic_cast<hd_one_line*>(c);
87 }
88
89
90 // static object
91 extern const component_library hd1l_tester_component_library;
92
93 const component_library hd1l_tester_component_library DLLEXPORT = 
94 {
95   COMPONENT_LIBRARY_MAGIC,
96   & HD44780UTesterListTypes, 
97   & HD44780UTesterCreate,
98   & HD44780UTesterDelete
99 };
100