/** * Write a big number to the screen. * \param drvthis Pointer to driver structure. * \param x Horizontal character position (column). * \param num Character to write (0 - 10 with 10 representing ':') */ MODULE_EXPORT void lcterm_num (Driver *drvthis, int x, int num) { PrivateData *p = (PrivateData *) drvthis->private_data; int do_init = 0; if ((num < 0) || (num > 10)) return; if (p->height >= 4) { /* Use standard bignum library */ if (p->last_ccmode != bignum) { if (p->ccmode != standard) { report(RPT_WARNING, "%s: num: cannot combine two modes using user-defined characters", drvthis->name); return; } p->ccmode = p->last_ccmode = bignum; do_init = 1; } lib_adv_bignum(drvthis, x, num, 0, do_init); } else { /* Roll our own 'mini big numbers' */ lcterm_chr(drvthis, x, 1 + (p->height - 1) / 2, (num == 10) ? ':' : (num + '0')); } }
/** * Place an icon on the screen. * \param drvthis Pointer to driver structure. * \param x Horizontal character position (column). * \param y Vertical character position (row). * \param icon synbolic value representing the icon. * \retval 0 Icon has been successfully defined/written. * \retval <0 Server core shall define/write the icon. */ MODULE_EXPORT int lcterm_icon (Driver *drvthis, int x, int y, int icon) { static unsigned char heart_open[] = { b__XXXXX, b__X_X_X, b_______, b_______, b_______, b__X___X, b__XX_XX, b__XXXXX }; static unsigned char heart_filled[] = { b__XXXXX, b__X_X_X, b___X_X_, b___XXX_, b___XXX_, b__X_X_X, b__XX_XX, b__XXXXX }; switch (icon) { case ICON_BLOCK_FILLED: lcterm_chr(drvthis, x, y, 255); break; case ICON_HEART_FILLED: lcterm_set_char(drvthis, 0, heart_filled); lcterm_chr(drvthis, x, y, 0); break; case ICON_HEART_OPEN: lcterm_set_char(drvthis, 0, heart_open); lcterm_chr(drvthis, x, y, 0); break; default: return -1; } return 0; }
///////////////////////////////////////////////////////////////// // Writes a big number. // MODULE_EXPORT void lcterm_num (Driver *drvthis, int x, int num) { PrivateData *p = (PrivateData *) drvthis->private_data; static char bignum_map[11][4][3] = { { /* 0: */ {1,2,3}, {6,32,6}, {6,32,6}, {7,2,32} }, { /* 1: */ {7,6,32}, {32,6,32}, {32,6,32}, {7,2,32}, }, { /* 2: */ {1,2,3}, {32,5,0}, {1,32,32}, {2,2,0}, }, { /* 3: */ {1,2,3}, {32,5,0}, {3,32,6}, {7,2,32} }, { /* 4: */ {32,3,6}, {1,32,6}, {2,2,6}, {32,32,0} }, { /* 5: */ {1,2,0}, {2,2,3}, {3,32,6}, {7,2,32} }, { /* 6: */ {1,2,32}, {6,5,32}, {6,32,6}, {7,2,32} }, { /* 7: */ {2,2,6}, {32,1,32}, {32,6,32}, {32,0,32} }, { /* 8: */ {1,2,3}, {4,5,0}, {6,32,6}, {7,2,32} }, { /* 9: */ {1,2,3}, {4,3,6}, {32,1,32}, {7,32,32} }, { /* colon: */ {32}, {7}, {7}, {32} }}; if ((num < 0) || (num > 10)) return; if (p->height >= 4) { int y = (p->height - 2) / 2; int x2, y2; lcterm_init_num(drvthis); for (x2 = 0; x2 <= 2; x2++) { for (y2 = 0; y2 <= 3; y2++) { lcterm_chr(drvthis, x+x2, y+y2, bignum_map[num][y2][x2]); } if (num == 10) x2 = 2; /* =break, for colon only */ } } else lcterm_chr(drvthis, x, 1 + (p->height - 1) / 2, (num == 10) ? ':' : (num + '0')); }