/elec/propeller-clock

To get this branch, use:
bzr branch http://bzr.ed.am/elec/propeller-clock

« back to all changes in this revision

Viewing changes to src/text.cc

  • Committer: Tim Marston
  • Date: 2012-03-10 01:01:54 UTC
  • Revision ID: tim@ed.am-20120310010154-lv041mt4275k5jxo
removed most OOP/inheritance crap, saved loads of space!

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
// mode-specific message parameters
40
40
static signed long _message_params[ NUM_MESSAGE_BUFFERS ];
41
41
 
42
 
// text scaling factors
43
 
static int _message_scale[ NUM_MESSAGE_BUFFERS ];
44
 
 
45
42
// time last frame
46
43
static unsigned long _last_millis;
47
44
 
51
48
// recalculate message params, based on _duration
52
49
static bool _do_draw_reset;
53
50
 
54
 
// recalculate messages parameters (after message reset)
55
 
static unsigned char _message_recalc_flags;
56
 
 
57
51
 
58
52
void reset_message_param( int message_num )
59
53
{
93
87
                        _message_params[ message_num ] = NUM_SEGMENTS; break;
94
88
                }
95
89
                _message_params[ message_num ] = -( _message_params[ message_num ] -
96
 
                        TextRenderer::get_width( _message_lens[ message_num ],
97
 
                                        _message_scale[ message_num ] ) ) / 2;
 
90
                        TextRenderer::get_width( _message_lens[ message_num ] ) ) / 2;
98
91
        }
99
92
}
100
93
 
106
99
}
107
100
 
108
101
 
109
 
void Text::reset_message( int message_num, char mode, int scale )
 
102
void Text::reset_message( int message_num, char mode )
110
103
{
111
104
        _message_modes[ message_num ] = mode;
112
 
        _message_recalc_flags |= 1 << message_num;
113
 
        _message_scale[ message_num ] = scale;
 
105
        reset_message_param( message_num );
114
106
}
115
107
 
116
108
 
120
112
        _duration = 0;
121
113
        _last_millis = ::millis();
122
114
        _do_draw_reset = false;
123
 
        _message_recalc_flags = 0;
124
115
 
125
116
        // reset the text renderer's output buffer
126
117
        TextRenderer::reset_buffer();
141
132
 
142
133
void Text::draw( int message_num, int segment )
143
134
{
144
 
        TextRenderer::buffer_in_use();
145
 
 
146
135
        // perform a mid-frame reset, as necessary
147
136
        if( _do_draw_reset && segment > NUM_SEGMENTS / 2 ) {
148
137
                _do_draw_reset = false;
149
138
 
150
 
                // reset message param?
151
 
                if( _message_recalc_flags & ( 1 << message_num ) ) {
152
 
                        _message_recalc_flags &= ~( 1 << message_num );
153
 
                        reset_message_param( message_num );
154
 
                }
155
 
 
156
 
                // add to horizontal scroll position
157
 
                if( _message_modes[ message_num ] & MODE_HSCROLL ) {
 
139
                if( _message_modes[ message_num ] & MODE_HSCROLL )
 
140
                {
 
141
                        // add to horizontal scroll position
158
142
                        _message_params[ message_num ] +=
159
143
                                _duration * TEXT_SCROLL_SPEED / 1000;
160
144
                        long excess = _message_params[ message_num ] -
161
 
                                TextRenderer::get_width( _message_lens[ message_num ],
162
 
                                                _message_scale[ message_num ] );
 
145
                                TextRenderer::get_width( _message_lens[ message_num ] );
163
146
                        if( excess >= 0 ) {
164
147
                                reset_message_param( message_num );
165
148
                                _message_params[ message_num ] += excess;
217
200
        TextRenderer::render(
218
201
                _messages[ message_num ], _message_lens[ message_num ],
219
202
                (long)segment + _message_params[ message_num ],
220
 
                ( _message_modes[ message_num ] & 1 ) == 0, 0,
221
 
                _message_scale[ message_num ] );
 
203
                ( _message_modes[ message_num ] & 1 ) == 0, 0 );
222
204
}