clean up ugly bignum code a bit, do range checks, support colon display
This commit is contained in:
+61
-54
@@ -382,57 +382,62 @@ driver_alt_num( Driver * drv, int x, int num )
|
||||
{
|
||||
/* Ugly code extracted by David GLAUDE from lcdm001.c ;)*/
|
||||
/* Moved to driver.c by Joris Robijn */
|
||||
static char num_map [10][4][3] = {
|
||||
{
|
||||
{' ','_',' '}, /*0*/
|
||||
{'|',' ','|'},
|
||||
{'|','_','|'},
|
||||
{' ',' ',' '}},
|
||||
{
|
||||
{' ',' ',' '},/*1*/
|
||||
{' ',' ','|'},
|
||||
{' ',' ','|'},
|
||||
{' ',' ',' '}},
|
||||
{
|
||||
{' ','_',' '},/*2*/
|
||||
{' ','_','|'},
|
||||
{'|','_',' '},
|
||||
{' ',' ',' '}},
|
||||
{
|
||||
{' ','_',' '},/*3*/
|
||||
{' ','_','|'},
|
||||
{' ','_','|'},
|
||||
{' ',' ',' '}},
|
||||
{
|
||||
{' ',' ',' '},/*4*/
|
||||
{'|','_','|'},
|
||||
{' ',' ','|'},
|
||||
{' ',' ',' '}},
|
||||
{
|
||||
{' ','_',' '},/*5*/
|
||||
{'|','_',' '},
|
||||
{' ','_','|'},
|
||||
{' ',' ',' '}},
|
||||
{
|
||||
{' ','_',' '},/*6*/
|
||||
{'|','_',' '},
|
||||
{'|','_','|'},
|
||||
{' ',' ',' '}},
|
||||
{
|
||||
{' ','_',' '},/*7*/
|
||||
{' ',' ','|'},
|
||||
{' ',' ','|'},
|
||||
{' ',' ',' '}},
|
||||
{
|
||||
{' ','_',' '},/*8*/
|
||||
{'|','_','|'},
|
||||
{'|','_','|'},
|
||||
{' ',' ',' '}},
|
||||
{
|
||||
{' ','_',' '},/*9*/
|
||||
{'|','_','|'},
|
||||
{' ','_','|'},
|
||||
{' ',' ',' '}}
|
||||
static char num_map[][4][4] = {
|
||||
{ /* 0 */
|
||||
" _ ",
|
||||
"| |",
|
||||
"|_|",
|
||||
" " },
|
||||
{ /* 1 */
|
||||
" ",
|
||||
" |",
|
||||
" |",
|
||||
" " },
|
||||
{ /* 2 */
|
||||
" _ ",
|
||||
" _|",
|
||||
"|_ ",
|
||||
" " },
|
||||
{ /* 3 */
|
||||
" _ ",
|
||||
" _|",
|
||||
" _|",
|
||||
" " },
|
||||
{ /* 4 */
|
||||
" ",
|
||||
"|_|",
|
||||
" |",
|
||||
" " },
|
||||
{ /* 5 */
|
||||
" _ ",
|
||||
"|_ ",
|
||||
" _|",
|
||||
" " },
|
||||
{ /* 6 */
|
||||
" _ ",
|
||||
"|_ ",
|
||||
"|_|",
|
||||
" " },
|
||||
{ /* 7 */
|
||||
" _ ",
|
||||
" |",
|
||||
" |",
|
||||
" " },
|
||||
{ /* 8 */
|
||||
" _ ",
|
||||
"|_|",
|
||||
"|_|",
|
||||
" " },
|
||||
{ /* 9 */
|
||||
" _ ",
|
||||
"|_|",
|
||||
" _|",
|
||||
" " },
|
||||
{ /* colon */
|
||||
" ",
|
||||
".",
|
||||
".",
|
||||
" " }
|
||||
};
|
||||
/* End of ugly code ;) by Rene Wagner */
|
||||
/* I like this code ! Joris */
|
||||
@@ -441,12 +446,14 @@ driver_alt_num( Driver * drv, int x, int num )
|
||||
|
||||
debug (RPT_DEBUG, "%s( drv=[%.40s], x=%d, num=%d )", __FUNCTION__, drv->name, x, num);
|
||||
|
||||
if ((num < 0) || (num > 10))
|
||||
return;
|
||||
if (!drv->chr)
|
||||
return;
|
||||
|
||||
for (y = 1; y < 5; y++)
|
||||
for (dx = 0; dx < 3; dx++)
|
||||
drv->chr (drv, x + dx, y, num_map[num][y-1][dx]);
|
||||
for (y = 0; y < 4; y++)
|
||||
for (dx = 0; num_map[num][y][dx] != '\0'; dx++)
|
||||
drv->chr (drv, x + dx, y+1, num_map[num][y][dx]);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user