/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-05-17 22:49:36 UTC
  • Revision ID: tim@ed.am-20120517224936-0wgyem932dlq5bs4
various tweaks, a (failed) attempt to fix text reset bug and added TODO

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
 
42
45
// time last frame
43
46
static unsigned long _last_millis;
44
47
 
90
93
                        _message_params[ message_num ] = NUM_SEGMENTS; break;
91
94
                }
92
95
                _message_params[ message_num ] = -( _message_params[ message_num ] -
93
 
                        TextRenderer::get_width( _message_lens[ message_num ] ) ) / 2;
 
96
                        TextRenderer::get_width( _message_lens[ message_num ],
 
97
                                        _message_scale[ message_num ] ) ) / 2;
94
98
        }
95
99
}
96
100
 
102
106
}
103
107
 
104
108
 
105
 
void Text::reset_message( int message_num, char mode )
 
109
void Text::reset_message( int message_num, char mode, int scale )
106
110
{
107
111
        _message_modes[ message_num ] = mode;
108
112
        _message_recalc_flags |= 1 << message_num;
 
113
        _message_scale[ message_num ] = scale;
109
114
}
110
115
 
111
116
 
134
139
}
135
140
 
136
141
 
 
142
void Text::post_draw()
 
143
{
 
144
        _do_draw_reset = false;
 
145
}
 
146
 
 
147
 
137
148
void Text::draw( int message_num, int segment )
138
149
{
139
150
        TextRenderer::buffer_in_use();
140
151
 
141
152
        // perform a mid-frame reset, as necessary
142
 
        if( _do_draw_reset && segment > NUM_SEGMENTS / 2 ) {
143
 
                _do_draw_reset = false;
144
 
 
 
153
        if( _do_draw_reset ) // && segment > NUM_SEGMENTS / 2 )
 
154
        {
145
155
                // reset message param?
146
156
                if( _message_recalc_flags & ( 1 << message_num ) ) {
147
157
                        _message_recalc_flags &= ~( 1 << message_num );
153
163
                        _message_params[ message_num ] +=
154
164
                                _duration * TEXT_SCROLL_SPEED / 1000;
155
165
                        long excess = _message_params[ message_num ] -
156
 
                                TextRenderer::get_width( _message_lens[ message_num ] );
 
166
                                TextRenderer::get_width( _message_lens[ message_num ],
 
167
                                                _message_scale[ message_num ] );
157
168
                        if( excess >= 0 ) {
158
169
                                reset_message_param( message_num );
159
170
                                _message_params[ message_num ] += excess;
211
222
        TextRenderer::render(
212
223
                _messages[ message_num ], _message_lens[ message_num ],
213
224
                (long)segment + _message_params[ message_num ],
214
 
                ( _message_modes[ message_num ] & 1 ) == 0, 0 );
 
225
                ( _message_modes[ message_num ] & 1 ) == 0, 0,
 
226
                _message_scale[ message_num ] );
215
227
}