From ab9fd1840b8025336081bd72fb9dbaea7b9909dd Mon Sep 17 00:00:00 2001 From: Rafaël Carré Date: Sat, 28 Aug 2010 21:46:45 +0000 Subject: plugins: use lcd_putsf/lcd_putsxyf git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27926 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/bench_mem_jpeg.c | 4 +-- apps/plugins/bench_scaler.c | 4 +-- apps/plugins/blackjack.c | 12 +++------ apps/plugins/bounce.c | 4 +-- apps/plugins/brickmania.c | 6 ++--- apps/plugins/calendar.c | 13 ++++----- apps/plugins/clix.c | 10 +++---- apps/plugins/codebuster.c | 2 +- apps/plugins/credits.c | 6 ++--- apps/plugins/cube.c | 3 +-- apps/plugins/disktidy.c | 5 +--- apps/plugins/firmware_flash.c | 15 +++-------- apps/plugins/flipit.c | 5 +--- apps/plugins/greyscale.c | 5 +--- apps/plugins/imageviewer/bmp/bmp.c | 12 +++------ apps/plugins/imageviewer/imageviewer.c | 5 +--- apps/plugins/imageviewer/jpeg/jpeg.c | 13 +++------ apps/plugins/imageviewer/png/png.c | 15 +++-------- apps/plugins/iriver_flash.c | 45 +++++++++---------------------- apps/plugins/jewels.c | 7 +++-- apps/plugins/lib/highscore.c | 10 +++---- apps/plugins/mp3_encoder.c | 14 +++------- apps/plugins/nim.c | 13 +++------ apps/plugins/pacbox/pacbox.c | 5 +--- apps/plugins/pegbox.c | 13 +++------ apps/plugins/reversi/reversi-gui.c | 9 ++----- apps/plugins/robotfindskitten.c | 6 ++--- apps/plugins/rockblox.c | 25 +++++------------ apps/plugins/rockblox1d.c | 4 +-- apps/plugins/rockbox_flash.c | 10 +++---- apps/plugins/rockboy/debug.c | 49 +++++----------------------------- apps/plugins/rockboy/lcd.c | 8 ++---- apps/plugins/rockboy/menu.c | 5 ++-- apps/plugins/rocklife.c | 4 +-- apps/plugins/rockpaint.c | 22 ++++++--------- apps/plugins/sliding_puzzle.c | 6 ++--- apps/plugins/snake.c | 8 ++---- apps/plugins/sokoban.c | 18 +++++-------- apps/plugins/spacerocks.c | 16 +++++------ apps/plugins/star.c | 8 +++--- apps/plugins/starfield.c | 8 ++---- apps/plugins/superdom.c | 22 +++++---------- apps/plugins/test_scanrate.c | 4 +-- apps/plugins/vbrfix.c | 5 +--- apps/plugins/vu_meter.c | 4 +-- apps/plugins/wav2wv.c | 16 +++-------- apps/plugins/wavplay.c | 7 ++--- apps/plugins/wavrecord.c | 18 +++++++------ apps/plugins/wavview.c | 23 ++++++---------- apps/plugins/xobox.c | 23 +++++++--------- apps/plugins/zxbox/zxvid_16bpp.c | 6 +---- apps/plugins/zxbox/zxvid_2bpp.c | 5 +--- 52 files changed, 173 insertions(+), 412 deletions(-) (limited to 'apps') diff --git a/apps/plugins/bench_mem_jpeg.c b/apps/plugins/bench_mem_jpeg.c index 4e24f2a405..184eb0f1c8 100644 --- a/apps/plugins/bench_mem_jpeg.c +++ b/apps/plugins/bench_mem_jpeg.c @@ -54,14 +54,12 @@ const struct custom_format format_null = { .get_size = get_size_null }; -static char output_buf[256]; static int output_y = 0; static int font_h; #define lcd_printf(...) \ do { \ - rb->snprintf(output_buf, sizeof(output_buf), __VA_ARGS__); \ - rb->lcd_putsxy(0, output_y, output_buf); \ + rb->lcd_putsxyf(0, output_y, __VA_ARGS__); \ rb->lcd_update_rect(0, output_y, LCD_WIDTH, font_h); \ output_y += font_h; \ } while (0) diff --git a/apps/plugins/bench_scaler.c b/apps/plugins/bench_scaler.c index 5db2987ec7..dc794e67f2 100644 --- a/apps/plugins/bench_scaler.c +++ b/apps/plugins/bench_scaler.c @@ -29,7 +29,6 @@ static unsigned char output; static int output_y = 0; static int font_h; static unsigned char *plugin_buf; -char output_buf[256]; struct img_part part; /* a null output plugin to save memory and better isolate scale cost */ @@ -77,8 +76,7 @@ const struct custom_format format_null = { #define lcd_printf(...) \ do { \ - rb->snprintf(output_buf, sizeof(output_buf), __VA_ARGS__); \ - rb->lcd_putsxy(0, output_y, output_buf); \ + rb->lcd_putsxyf(0, output_y, __VA_ARGS__); \ rb->lcd_update_rect(0, output_y, LCD_WIDTH, font_h); \ output_y += font_h; \ } while (0) diff --git a/apps/plugins/blackjack.c b/apps/plugins/blackjack.c index 8b28b815b8..42f73ff47c 100644 --- a/apps/plugins/blackjack.c +++ b/apps/plugins/blackjack.c @@ -946,7 +946,6 @@ static signed int blackjack_get_amount(char message[20], signed int lower_limit, signed int upper_limit, signed int start) { int button; - char str[9]; bool breakout = false, changed = false; unsigned int w, h; signed int amount; @@ -968,8 +967,7 @@ static signed int blackjack_get_amount(char message[20], signed int lower_limit, #if LCD_HEIGHT <= 64 rb->lcd_clear_display(); rb->lcd_puts(0, 1, message); - rb->snprintf(str, 9, "$%d", amount); - rb->lcd_puts(0, 2, str); + rb->lcd_putsf(0, 2, "$%d", amount); rb->lcd_puts(0, 3, "RIGHT: +1"); rb->lcd_puts(0, 4, "LEFT: -1"); rb->lcd_puts(0, 5, "UP: +10"); @@ -983,8 +981,7 @@ static signed int blackjack_get_amount(char message[20], signed int lower_limit, rb->lcd_drawrect(LCD_WIDTH/2 - 9*w - 1, LCD_HEIGHT/2 - 4*h - 3, 37*w / 2, 8*h -3); rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 4*h - 1, message); - rb->snprintf(str, 9, "$%d", amount); - rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 3*h, str); + rb->lcd_putsxyf(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 3*h, "$%d", amount); #if (CONFIG_KEYPAD == IPOD_4G_PAD) || \ (CONFIG_KEYPAD == IPOD_3G_PAD) || \ (CONFIG_KEYPAD == IPOD_1G2G_PAD) || \ @@ -1063,15 +1060,14 @@ static signed int blackjack_get_amount(char message[20], signed int lower_limit, } if(changed) { - rb->snprintf(str, 9, "$%d", amount); #if LCD_HEIGHT <= 64 - rb->lcd_puts(0, 2, str); + rb->lcd_putsf(0, 2, "$%d", amount); rb->lcd_update(); #else rb->lcd_set_drawmode(DRMODE_BG+DRMODE_INVERSEVID); rb->lcd_fillrect(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 3*h, 5*w, h); rb->lcd_set_drawmode(DRMODE_SOLID); - rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 3*h, str); + rb->lcd_putsxyf(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 3*h, "$%d", amount); rb->lcd_update_rect(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 3*h, 5*w, h); #endif changed = false; diff --git a/apps/plugins/bounce.c b/apps/plugins/bounce.c index 1ee5b1eaeb..abc551ff0a 100644 --- a/apps/plugins/bounce.c +++ b/apps/plugins/bounce.c @@ -582,7 +582,6 @@ static int loopit(void) int show=0; int timeout=0; - char buffer[30]; rb->lcd_clear_display(); while(1) @@ -628,9 +627,8 @@ static int loopit(void) show=NUM_LAST-1; break; } - rb->snprintf(buffer, 30, "%s: %d", + rb->lcd_putsxyf(0, LCD_HEIGHT - 8, "%s: %d", values[show].what, values[show].num); - rb->lcd_putsxy(0, LCD_HEIGHT - 8, (unsigned char *)buffer); timeout--; } for(i=0, yy=y, xx=x; diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c index 50ceaa7557..2a025d750b 100644 --- a/apps/plugins/brickmania.c +++ b/apps/plugins/brickmania.c @@ -1573,11 +1573,11 @@ static int brickmania_game_loop(void) /* write life num */ #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64) - rb->snprintf(s, sizeof(s), "L:%d", life); + #define LIFE_STR "L:%d" #else - rb->snprintf(s, sizeof(s), "Life: %d", life); + #define LIFE_STR "Life: %d" #endif - rb->lcd_putsxy(0, 0, s); + rb->lcd_putsxyf(0, 0, LIFE_STR, life); #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64) rb->snprintf(s, sizeof(s), "L%d", level+1); diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c index 32d4501920..8f25a7adc7 100644 --- a/apps/plugins/calendar.c +++ b/apps/plugins/calendar.c @@ -451,7 +451,6 @@ static void draw_calendar(struct shown *shown) int w, h; int x, y, pos, days_per_month, j; int wday; - char buffer[12]; const char *monthname[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" @@ -472,10 +471,6 @@ static void draw_calendar(struct shown *shown) y = Y_OFFSET + h; for (j = 1; j <= days_per_month; j++) { - if ( (day_has_memo[j]) || (wday_has_memo[wday]) ) - rb->snprintf(buffer, 4, "%02d.", j); - else - rb->snprintf(buffer, 4, "%02d", j); if (shown->mday == j) { rb->lcd_set_drawmode(DRMODE_SOLID); @@ -487,7 +482,10 @@ static void draw_calendar(struct shown *shown) { rb->lcd_set_drawmode(DRMODE_SOLID); } - rb->lcd_putsxy(x, y, buffer); + if ( (day_has_memo[j]) || (wday_has_memo[wday]) ) + rb->lcd_putsxyf(x, y, "%02d.", j); + else + rb->lcd_putsxyf(x, y, "%02d", j); x += CELL_WIDTH; wday++; if (wday >= 7) @@ -504,9 +502,8 @@ static void draw_calendar(struct shown *shown) rb->lcd_set_drawmode(DRMODE_SOLID); rb->lcd_vline(LCD_WIDTH-w*8-10, LCD_HEIGHT-h-3, LCD_HEIGHT-1); rb->lcd_hline(LCD_WIDTH-w*8-10, LCD_WIDTH-1, LCD_HEIGHT-h-3); - rb->snprintf(buffer, sizeof(buffer), "%s %04d", + rb->lcd_putsxyf(LCD_WIDTH-w*8-8, LCD_HEIGHT-h-1, "%s %04d", monthname[shown->mon-1], shown->year); - rb->lcd_putsxy(LCD_WIDTH-w*8-8, LCD_HEIGHT-h-1, buffer); rb->lcd_update(); } diff --git a/apps/plugins/clix.c b/apps/plugins/clix.c index 0bdf693f54..9eda97a1d9 100644 --- a/apps/plugins/clix.c +++ b/apps/plugins/clix.c @@ -408,23 +408,19 @@ static void clix_draw_cell(struct clix_game_state_t* state, const int x, const i static void clix_draw(struct clix_game_state_t* state) { int i,j; - char str[30]; /* Clear screen */ rb->lcd_clear_display(); rb->lcd_set_foreground( LCD_WHITE); rb->lcd_putsxy( MARGIN, MARGIN, "Score:"); - rb->snprintf( str, sizeof(str), "%d", state->score); - rb->lcd_putsxy( 43, MARGIN, str); + rb->lcd_putsxyf( 43, MARGIN, "%d", state->score); #if LCD_WIDTH <= 100 rb->lcd_putsxy( 75, MARGIN, "L:"); - rb->snprintf( str, sizeof(str), "%d", state->level); - rb->lcd_putsxy( 90, MARGIN, str); + rb->lcd_putsxyf( 90, MARGIN, "%d", state->level); #else rb->lcd_putsxy( 75, MARGIN, "Level:"); - rb->snprintf( str, sizeof(str), "%d", state->level); - rb->lcd_putsxy( 113, MARGIN, str); + rb->lcd_putsxyf( 113, MARGIN, "%d", state->level); #endif for( i = 0; i < BOARD_WIDTH; ++i) { diff --git a/apps/plugins/codebuster.c b/apps/plugins/codebuster.c index 1169f265c3..ca36d5d01b 100644 --- a/apps/plugins/codebuster.c +++ b/apps/plugins/codebuster.c @@ -174,7 +174,7 @@ static void draw_piece(int x, int y, int w, int h, int color_id, bool emph) { if (settings.labeling && color_id >= 0) { char text[2]; - rb->snprintf(text, 2, "%d", color_id); + rb->snprintf(text, sizeof(text), "%d", color_id); int fw, fh; rb->font_getstringsize(text, &fw, &fh, FONT_SYSFIXED); rb->lcd_putsxy(x + get_margin(fw, w), y + get_margin(fh, h), text); diff --git a/apps/plugins/credits.c b/apps/plugins/credits.c index a05b44c20d..8f86c7626b 100644 --- a/apps/plugins/credits.c +++ b/apps/plugins/credits.c @@ -331,10 +331,8 @@ static void roll_credits(void) rb->lcd_putsxy(CREDITS_TARGETPOS, 0, elapsednames); for(i=0; isnprintf(name, sizeof(name), "%s", credits[j+i]); - rb->lcd_putsxy(0, font_h*(i+1), name); - } + rb->lcd_putsxyf(0, font_h*(i+1), "%s", credits[j+i]); + rb->lcd_update(); rb->yield(); diff --git a/apps/plugins/cube.c b/apps/plugins/cube.c index 7dec822d56..88036ed661 100644 --- a/apps/plugins/cube.c +++ b/apps/plugins/cube.c @@ -701,10 +701,9 @@ enum plugin_status plugin_start(const void* parameter) if (t_disp == DISP_TIME) { rb->lcd_puts(5, 0, axes[curr].label); - rb->snprintf(buffer, sizeof(buffer), "%d %c", + rb->lcd_putsf(5, 1, "%d %c", paused ? axes[curr].angle : axes[curr].speed, highspeed ? 'H' : ' '); - rb->lcd_puts(5, 1, buffer); } t_disp--; if (t_disp == 0) diff --git a/apps/plugins/disktidy.c b/apps/plugins/disktidy.c index d83ecf4312..cc883fea9c 100644 --- a/apps/plugins/disktidy.c +++ b/apps/plugins/disktidy.c @@ -160,15 +160,12 @@ bool tidy_remove_item(char *item, int attr) void tidy_lcd_status(const char *name, int *removed) { - char text[24]; /* "Cleaned up nnnnn items" */ - /* display status text */ rb->lcd_clear_display(); rb->lcd_puts(0, 0, "Working ..."); rb->lcd_puts(0, 1, name); - rb->snprintf(text, 24, "Cleaned up %d items", *removed); #ifdef HAVE_LCD_BITMAP - rb->lcd_puts(0, 2, text); + rb->lcd_putsf(0, 2, "Cleaned up %d items", *removed); #endif rb->lcd_update(); } diff --git a/apps/plugins/firmware_flash.c b/apps/plugins/firmware_flash.c index 02c4098ec1..5c310e028d 100644 --- a/apps/plugins/firmware_flash.c +++ b/apps/plugins/firmware_flash.c @@ -556,8 +556,6 @@ int WaitForButton(void) /* helper for DoUserDialog() */ void ShowFlashInfo(tFlashInfo* pInfo) { - char buf[32]; - if (!pInfo->manufacturer) { rb->lcd_puts(0, 0, "Flash: M=?? D=??"); @@ -565,16 +563,14 @@ void ShowFlashInfo(tFlashInfo* pInfo) } else { - rb->snprintf(buf, sizeof(buf), "Flash: M=%02x D=%02x", + rb->lcd_putsf(0, 0, "Flash: M=%02x D=%02x", pInfo->manufacturer, pInfo->id); - rb->lcd_puts(0, 0, buf); if (pInfo->size) { rb->lcd_puts(0, 1, pInfo->name); - rb->snprintf(buf, sizeof(buf), "Size: %d KB", pInfo->size / 1024); - rb->lcd_puts(0, 2, buf); + rb->lcd_puts(0, 2, "Size: %d KB", pInfo->size / 1024); } else { @@ -591,7 +587,6 @@ void ShowFlashInfo(tFlashInfo* pInfo) void DoUserDialog(char* filename) { tFlashInfo FlashInfo; - char buf[32]; char default_filename[32]; int button; int rc; /* generic return code */ @@ -761,8 +756,7 @@ void DoUserDialog(char* filename) rb->lcd_clear_display(); rb->lcd_puts(0, 0, "Panic:"); rb->lcd_puts(0, 1, "Programming fail!"); - rb->snprintf(buf, sizeof(buf), "%d errors", rc); - rb->lcd_puts(0, 2, buf); + rb->lcd_putsf(0, 2, "%d errors", rc); rb->lcd_update(); button = WaitForButton(); } @@ -782,8 +776,7 @@ void DoUserDialog(char* filename) { rb->lcd_puts(0, 0, "Panic:"); rb->lcd_puts(0, 1, "Verify fail!"); - rb->snprintf(buf, sizeof(buf), "%d errors", rc); - rb->lcd_puts(0, 2, buf); + rb->lcd_putsf(0, 2, "%d errors", rc); } rb->lcd_puts(0, 7, "Any key to exit"); rb->lcd_update(); diff --git a/apps/plugins/flipit.c b/apps/plugins/flipit.c index 44ad011a64..2bc4a1ff97 100644 --- a/apps/plugins/flipit.c +++ b/apps/plugins/flipit.c @@ -496,11 +496,8 @@ static void draw_cursor(void) /* draw the info panel ... duh */ static void draw_info_panel(void) { - char s[16]; - rb->lcd_puts( 6, 0, "Flips" ); - rb->snprintf( s, sizeof(s), "%d", moves ); - rb->lcd_puts( 6, 1, s ); + rb->lcd_putsf( 6, 1, "%d", moves ); } #endif /* LCD */ diff --git a/apps/plugins/greyscale.c b/apps/plugins/greyscale.c index 33254439b6..00699715f7 100644 --- a/apps/plugins/greyscale.c +++ b/apps/plugins/greyscale.c @@ -120,7 +120,6 @@ /******************************* Globals ***********************************/ GREY_INFO_STRUCT -static char pbuf[32]; /* global printf buffer */ static unsigned char *gbuf; static size_t gbuf_size = 0; @@ -298,9 +297,7 @@ int main(void) time = *rb->current_tick - time; /* end time measurement */ - rb->snprintf(pbuf, sizeof(pbuf), "Shades: 129, %d.%02ds", - time / 100, time % 100); - rb->lcd_puts(0, 0, pbuf); + rb->lcd_putsf(0, 0, "Shades: 129, %d.%02ds", time / 100, time % 100); grey_deferred_lcd_update(); /* schedule an lcd_update() */ #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost(false); diff --git a/apps/plugins/imageviewer/bmp/bmp.c b/apps/plugins/imageviewer/bmp/bmp.c index 6b5c4b1759..b96577dbed 100644 --- a/apps/plugins/imageviewer/bmp/bmp.c +++ b/apps/plugins/imageviewer/bmp/bmp.c @@ -209,11 +209,8 @@ int load_image(char *filename, struct image_info *info, if (!running_slideshow) { rb->lcd_puts(0, 0, rb->strrchr(filename,'/')+1); - rb->lcd_update(); - - rb->snprintf(print, sizeof(print), "loading %dx%d%s", + rb->lcd_putsf(0, 1, "loading %dx%d%s", bmp.width, bmp.height, ds == 1?"":"(resize on load)"); - rb->lcd_puts(0, 1, print); rb->lcd_update(); } @@ -260,8 +257,7 @@ int load_image(char *filename, struct image_info *info, if (!running_slideshow) { - rb->snprintf(print, sizeof(print), "image %dx%d", bmp.width, bmp.height); - rb->lcd_puts(0, 2, print); + rb->lcd_putsf(0, 2, "image %dx%d", bmp.width, bmp.height); rb->lcd_update(); } @@ -308,9 +304,7 @@ int get_image(struct image_info *info, int ds) if (!running_slideshow) { - rb->snprintf(print, sizeof(print), "resizing %d*%d", - info->width, info->height); - rb->lcd_puts(0, 3, print); + rb->lcd_putsf(0, 3, "resizing %d*%d", info->width, info->height); rb->lcd_update(); } diff --git a/apps/plugins/imageviewer/imageviewer.c b/apps/plugins/imageviewer/imageviewer.c index e581407290..eb1ce498a1 100644 --- a/apps/plugins/imageviewer/imageviewer.c +++ b/apps/plugins/imageviewer/imageviewer.c @@ -97,7 +97,6 @@ static fb_data rgb_linebuf[LCD_WIDTH]; /* Line buffer for scrolling when #endif /* my memory pool (from the mp3 buffer) */ -static char print[32]; /* use a common snprintf() buffer */ /* the remaining free part of the buffer for loaded+resized images */ static unsigned char* buf; static size_t buf_size; @@ -777,9 +776,7 @@ static int load_and_show(char* filename, struct image_info *info) if(!running_slideshow) { - rb->snprintf(print, sizeof(print), "showing %dx%d", - info->width, info->height); - rb->lcd_puts(0, 3, print); + rb->lcd_putsf(0, 3, "showing %dx%d", info->width, info->height); rb->lcd_update(); } diff --git a/apps/plugins/imageviewer/jpeg/jpeg.c b/apps/plugins/imageviewer/jpeg/jpeg.c index 95e493e7ee..5f69cc7f51 100644 --- a/apps/plugins/imageviewer/jpeg/jpeg.c +++ b/apps/plugins/imageviewer/jpeg/jpeg.c @@ -157,10 +157,7 @@ int load_image(char *filename, struct image_info *info, if(!running_slideshow) { rb->lcd_puts(0, 0, rb->strrchr(filename,'/')+1); - rb->lcd_update(); - - rb->snprintf(print, sizeof(print), "loading %d bytes", filesize); - rb->lcd_puts(0, 1, print); + rb->lcd_putsf(0, 1, "loading %d bytes", filesize); rb->lcd_update(); } @@ -195,9 +192,7 @@ int load_image(char *filename, struct image_info *info, if(!running_slideshow) { - rb->snprintf(print, sizeof(print), "image %dx%d", - p_jpg->x_size, p_jpg->y_size); - rb->lcd_puts(0, 2, print); + rb->lcd_putsf(0, 2, "image %dx%d", p_jpg->x_size, p_jpg->y_size); rb->lcd_update(); } @@ -269,9 +264,7 @@ int get_image(struct image_info *info, int ds) if(!running_slideshow) { - rb->snprintf(print, sizeof(print), "decoding %d*%d", - info->width, info->height); - rb->lcd_puts(0, 3, print); + rb->lcd_putsf(0, 3, "decoding %d*%d", info->width, info->height); rb->lcd_update(); } diff --git a/apps/plugins/imageviewer/png/png.c b/apps/plugins/imageviewer/png/png.c index 8bd1b241f3..46430607ea 100644 --- a/apps/plugins/imageviewer/png/png.c +++ b/apps/plugins/imageviewer/png/png.c @@ -1359,8 +1359,7 @@ int load_image(char *filename, struct image_info *info, } else { if (!running_slideshow) { - rb->snprintf(print, sizeof(print), "loading %lu bytes", (unsigned long)image_size); - rb->lcd_puts(0, 1, print); + rb->lcd_putsf(0, 1, "loading %zu bytes", image_size); rb->lcd_update(); } @@ -1388,14 +1387,10 @@ int load_image(char *filename, struct image_info *info, if (!decoder->error) { if (!running_slideshow) { - rb->snprintf(print, sizeof(print), "image %dx%d", + rb->lcd_putsf(0, 2, "image %dx%d", decoder->infoPng.width, decoder->infoPng.height); - rb->lcd_puts(0, 2, print); - rb->lcd_update(); - - rb->snprintf(print, sizeof(print), "decoding %d*%d", + rb->lcd_putsf(0, 3, "decoding %d*%d", decoder->infoPng.width, decoder->infoPng.height); - rb->lcd_puts(0, 3, print); rb->lcd_update(); } @@ -1481,9 +1476,7 @@ int get_image(struct image_info *info, int ds) if (ds > 1) { if (!running_slideshow) { - rb->snprintf(print, sizeof(print), "resizing %d*%d", - info->width, info->height); - rb->lcd_puts(0, 3, print); + rb->lcd_putsf(0, 3, "resizing %d*%d", info->width, info->height); rb->lcd_update(); } struct bitmap bmp_src, bmp_dst; diff --git a/apps/plugins/iriver_flash.c b/apps/plugins/iriver_flash.c index b744eac70f..67ea090cf2 100644 --- a/apps/plugins/iriver_flash.c +++ b/apps/plugins/iriver_flash.c @@ -187,8 +187,6 @@ int wait_for_button(void) /* helper for DoUserDialog() */ void ShowFlashInfo(struct flash_info* pInfo) { - char buf[32]; - if (!pInfo->manufacturer) { rb->lcd_puts(0, 0, "Flash: M=?? D=??"); @@ -196,16 +194,14 @@ void ShowFlashInfo(struct flash_info* pInfo) } else { - rb->snprintf(buf, sizeof(buf), "Flash: M=%02x D=%02x", + rb->lcd_putsf(0, 0, "Flash: M=%02x D=%02x", pInfo->manufacturer, pInfo->id); - rb->lcd_puts(0, 0, buf); if (pInfo->size) { rb->lcd_puts(0, 1, pInfo->name); - rb->snprintf(buf, sizeof(buf), "Size: %d KB", pInfo->size / 1024); - rb->lcd_puts(0, 2, buf); + rb->lcd_putsf(0, 2, "Size: %d KB", pInfo->size / 1024); } else { @@ -235,11 +231,9 @@ bool show_info(void) bool confirm(const char *msg) { - char buf[128]; bool ret; - rb->snprintf(buf, sizeof buf, "%s ([PLAY] to CONFIRM)", msg); - rb->splash(0, buf); + rb->splashf(0, "%s ([PLAY] to CONFIRM)", msg); ret = (wait_for_button() == BUTTON_ON); show_info(); @@ -338,7 +332,6 @@ static int get_section_address(int section) int flash_rockbox(const char *filename, int section) { struct flash_header hdr; - char buf[64]; int pos, i, len, rc; unsigned long checksum, sum; unsigned char *p8; @@ -378,9 +371,8 @@ int flash_rockbox(const char *filename, int section) if (pos+sizeof(struct flash_header) != *p32) { - rb->snprintf(buf, sizeof(buf), "Incorrect relocation: 0x%08lx/0x%08lx", + rb->splashf(HZ*10, "Incorrect relocation: 0x%08lx/0x%08lx", *p32, pos+sizeof(struct flash_header)); - rb->splash(HZ*10, buf); return -1; } @@ -393,9 +385,7 @@ int flash_rockbox(const char *filename, int section) if (i + pos < SEC_SIZE) return -1; - rb->snprintf(buf, sizeof(buf), "Erasing... %d%%", - (i+SEC_SIZE)*100/len); - rb->lcd_puts(0, 3, buf); + rb->lcd_putsf(0, 3, "Erasing... %d%%", (i+SEC_SIZE)*100/len); rb->lcd_update(); rc = cfi_erase_sector(FB + (i + pos)/2); @@ -408,8 +398,7 @@ int flash_rockbox(const char *filename, int section) // rb->strncpy(hdr.version, rb->rbversion , sizeof(hdr.version)-1); p16 = (uint16_t *)&hdr; - rb->snprintf(buf, sizeof(buf), "Programming..."); - rb->lcd_puts(0, 4, buf); + rb->lcd_puts(0, 4, "Programming..."); rb->lcd_update(); pos = get_section_address(section)/2; @@ -424,9 +413,7 @@ int flash_rockbox(const char *filename, int section) { if (i % SEC_SIZE == 0) { - rb->snprintf(buf, sizeof(buf), "Programming... %d%%", - (i+1)*100/(len/2)); - rb->lcd_puts(0, 4, buf); + rb->lcd_putsf(0, 4, "Programming... %d%%", (i+1)*100/(len/2)); rb->lcd_update(); } @@ -434,8 +421,7 @@ int flash_rockbox(const char *filename, int section) } /* Verify */ - rb->snprintf(buf, sizeof(buf), "Verifying"); - rb->lcd_puts(0, 5, buf); + rb->lcd_puts(0, 5, "Verifying"); rb->lcd_update(); p8 = (char *)get_section_address(section); @@ -560,13 +546,10 @@ int flash_bootloader(const char *filename) int flash_original_fw(int len) { unsigned char reset_vector[8]; - char buf[32]; int pos, i, rc; unsigned char *p8; uint16_t *p16; - (void)buf; - rb->lcd_puts(0, 3, "Critical section..."); rb->lcd_update(); @@ -586,13 +569,11 @@ int flash_original_fw(int len) for (i = 1; i < BOOTLOADER_ERASEGUARD && (i-1)*4096 < len; i++) { rc = cfi_erase_sector(FB + (SEC_SIZE/2) * i); - rb->snprintf(buf, sizeof(buf), "Erase: 0x%03x (%d)", i, rc); - rb->lcd_puts(0, 5, buf); + rb->lcd_putsf(0, 5, "Erase: 0x%03x (%d)", i, rc); rb->lcd_update(); } - rb->snprintf(buf, sizeof(buf), "Programming"); - rb->lcd_puts(0, 6, buf); + rb->lcd_puts(0, 6, "Programming"); rb->lcd_update(); pos = 0x00000008/2; @@ -600,8 +581,7 @@ int flash_original_fw(int len) for (i = 0; i < len/2 && pos + i < (BOOTLOADER_ENTRYPOINT/2); i++) cfi_program_word(FB + pos + i, p16[i]); - rb->snprintf(buf, sizeof(buf), "Verifying"); - rb->lcd_puts(0, 7, buf); + rb->lcd_puts(0, 7, "Verifying"); rb->lcd_update(); /* Verify reset vectors. */ @@ -623,8 +603,7 @@ int flash_original_fw(int len) if (p8[i] != audiobuf[i]) { rb->splash(HZ*3, "Verify failed!"); - rb->snprintf(buf, sizeof buf, "at: 0x%08x", i); - rb->splash(HZ*10, buf); + rb->splashf(HZ*10, "at: 0x%08x", i); return -5; } } diff --git a/apps/plugins/jewels.c b/apps/plugins/jewels.c index c636619b43..fc20c674aa 100644 --- a/apps/plugins/jewels.c +++ b/apps/plugins/jewels.c @@ -629,8 +629,7 @@ static void jewels_drawboard(struct game_context* bj) { #endif /* print text */ - rb->snprintf(str, 10, "%s %d", title, bj->level); - rb->lcd_putsxy(1, LCD_HEIGHT-10, str); + rb->lcd_putsxyf(1, LCD_HEIGHT-10, "%s %d", title, bj->level); if (bj->type == GAME_TYPE_NORMAL) { rb->snprintf(str, 6, "%d", (bj->level-1)*LEVEL_PTS+bj->score); @@ -671,8 +670,8 @@ static void jewels_drawboard(struct game_context* bj) { #endif /* print text */ - rb->snprintf(str, 10, "%s %d", title, bj->level); - rb->lcd_putsxy(1, LCD_HEIGHT-(LCD_HEIGHT-(8*TILE_HEIGHT+YOFS))/2-3, str); + rb->lcd_putsxyf(1, LCD_HEIGHT-(LCD_HEIGHT-(8*TILE_HEIGHT+YOFS))/2-3,"%s %d", + title, bj->level); if (bj->type == GAME_TYPE_NORMAL) { rb->snprintf(str, 6, "%d", (bj->level-1)*LEVEL_PTS+bj->score); diff --git a/apps/plugins/lib/highscore.c b/apps/plugins/lib/highscore.c index 185930202a..ff7a166222 100644 --- a/apps/plugins/lib/highscore.c +++ b/apps/plugins/lib/highscore.c @@ -125,7 +125,6 @@ void highscore_show(int position, struct highscore *scores, int num_scores, bool show_level) { int i, w, h; - char str[30]; #ifdef HAVE_LCD_COLOR unsigned bgcolor = rb->lcd_get_background(); unsigned fgcolor = rb->lcd_get_foreground(); @@ -155,14 +154,11 @@ void highscore_show(int position, struct highscore *scores, int num_scores, rb->lcd_set_foreground(LCD_RGBPACK(245,0,0)); } #endif - rb->snprintf (str, sizeof (str), "%d)", i+1); - rb->lcd_putsxy (MARGIN,3*h + h*i, str); - rb->snprintf (str, sizeof (str), "%d", scores[i].score); - rb->lcd_putsxy (LCD_WIDTH/4-w/4,3*h + h*i, str); + rb->lcd_putsxyf (MARGIN,3*h + h*i, "%d)", i+1); + rb->lcd_putsxyf (LCD_WIDTH/4-w/4,3*h + h*i, "%d", scores[i].score); if(show_level) { - rb->snprintf (str, sizeof (str), "%d", scores[i].level); - rb->lcd_putsxy (LCD_WIDTH*3/4-w/4,3*h + h*i, str); + rb->lcd_putsxyf (LCD_WIDTH*3/4-w/4,3*h + h*i, "%d", scores[i].level); } if(i == position) { diff --git a/apps/plugins/mp3_encoder.c b/apps/plugins/mp3_encoder.c index 06d28a344a..d26500819b 100644 --- a/apps/plugins/mp3_encoder.c +++ b/apps/plugins/mp3_encoder.c @@ -2137,15 +2137,13 @@ void set_scale_facs(int *mdct_freq) void compress(void) { int i, gr, gr_cnt; - char stg[20]; uint32_t max; while(1) { if((frames & 7) == 0) { rb->lcd_clear_display(); - rb->snprintf(stg, 20, "Frame %d / %d", frames, wav_size/SAMPL2/8); - rb->lcd_putsxy(4, 20, stg); + rb->lcd_putsxyf(4, 20, "Frame %d / %d", frames, wav_size/SAMPL2/8); rb->lcd_update(); } /* encode one mp3 frame in this loop */ @@ -2496,7 +2494,6 @@ enum plugin_status plugin_start(const void* parameter) int rat, srat, nrat; /* for rate selection */ int cont = 1, butt; long tim = 0; - char stg[40]; static const char* bstrg[] = { "64", "80", "96", "112", "128", "160", "192", "224", "256", "320" }; @@ -2568,18 +2565,15 @@ enum plugin_status plugin_start(const void* parameter) else { rb->close(wavfile); - rb->snprintf(stg, 20, "WaveOpen failed %d", wave_open()); - rb->lcd_putsxy(0, 20, stg); + rb->lcd_putsxyf(0, 20, "WaveOpen failed %d", wave_open()); rb->lcd_update(); rb->sleep(5*HZ); } rb->lcd_clear_display(); - rb->snprintf(stg, 30, " Conversion: %ld.%02lds ", tim/100, tim%100); - rb->lcd_putsxy(0, 30, stg); + rb->lcd_putsxyf(0, 30, " Conversion: %ld.%02lds ", tim/100, tim%100); tim = frames * SAMP_PER_FRAME * 100 / 44100; /* unit=.01s */ - rb->snprintf(stg, 30, " WAV-Length: %ld.%02lds ", tim/100, tim%100); - rb->lcd_putsxy(0, 20, stg); + rb->lcd_putsxyf(0, 20, " WAV-Length: %ld.%02lds ", tim/100, tim%100); rb->lcd_update(); rb->sleep(5*HZ); } diff --git a/apps/plugins/nim.c b/apps/plugins/nim.c index 3a3a870dad..70cf8dcec4 100644 --- a/apps/plugins/nim.c +++ b/apps/plugins/nim.c @@ -56,7 +56,6 @@ static unsigned char pattern3[]={0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15}; /*3 static unsigned char pattern2[]={0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14}; /*2 parts*/ static unsigned char pattern1[]={0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10}; /*1 part*/ -static unsigned char str[12]; /*String use to display the first line*/ static unsigned long hsmile,hcry,h1,h2; /*Handle for the new pattern*/ static bool end; /*If true game is finished*/ @@ -101,8 +100,7 @@ static void display_first_line(int x) { int i; - rb->snprintf(str,sizeof(str)," =%d",x); - rb->lcd_puts(0,0,str); + rb->lcd_putsf(0,0," =%d",x); rb->lcd_define_pattern(h1,pattern3); for (i=0;isnprintf(str,sizeof(str),"[%d..%d]?=%d",min,v,y); - rb->lcd_puts(0,1,str); + rb->lcd_putsf(0,1,"[%d..%d]?=%d",min,v,y); rb->lcd_update(); go=false; @@ -215,8 +212,7 @@ enum plugin_status plugin_start(const void* parameter) break; } display_first_line(x); - rb->snprintf(str,sizeof(str),"[%d..%d]?=%d",min,v,y); - rb->lcd_puts(0,1,str); + rb->lcd_putsf(0,1,"[%d..%d]?=%d",min,v,y); rb->lcd_update(); } @@ -276,8 +272,7 @@ enum plugin_status plugin_start(const void* parameter) } v=y*2; x-=y; - rb->snprintf(str,sizeof(str),"I take=%d",y); - rb->lcd_puts(0,1,str); + rb->lcd_putsf(0,1,"I take=%d",y); rb->lcd_update(); rb->sleep(HZ); } diff --git a/apps/plugins/pacbox/pacbox.c b/apps/plugins/pacbox/pacbox.c index db25b1c0f1..e942841a19 100644 --- a/apps/plugins/pacbox/pacbox.c +++ b/apps/plugins/pacbox/pacbox.c @@ -367,7 +367,6 @@ static void stop_sound(void) static int gameProc( void ) { int fps; - char str[80]; int status; long end_time; int frame_counter = 0; @@ -469,9 +468,7 @@ static int gameProc( void ) if (settings.showfps) { fps = (video_frames*HZ*100) / (*rb->current_tick-start_time); - rb->snprintf(str,sizeof(str),"%d.%02d / %d fps ", - fps/100,fps%100,FPS); - rb->lcd_putsxy(0,0,str); + rb->lcd_putsxyf(0,0,"%d.%02d / %d fps ",fps/100,fps%100,FPS); } #if !defined(HAVE_LCD_MODES) || \ diff --git a/apps/plugins/pegbox.c b/apps/plugins/pegbox.c index a953c6804b..1c4b2fcb6e 100644 --- a/apps/plugins/pegbox.c +++ b/apps/plugins/pegbox.c @@ -773,7 +773,6 @@ static void pegbox_draw_board(struct game_context* pb) { unsigned int r, c, type; pb->num_left = 0; - char str[5]; rb->lcd_clear_display(); #ifdef WIDE_LAYOUT @@ -819,15 +818,11 @@ static void pegbox_draw_board(struct game_context* pb) } #ifdef WIDE_LAYOUT - rb->snprintf(str, 3, "%d", pb->level); - rb->lcd_putsxy(TEXT_X, LEVEL_TEXT_Y, str); - rb->snprintf(str, 3, "%d", pb->num_left); - rb->lcd_putsxy(TEXT_X, PEGS_TEXT_Y, str); + rb->lcd_putsxyf(TEXT_X, LEVEL_TEXT_Y, "%d", pb->level); + rb->lcd_putsxyf(TEXT_X, PEGS_TEXT_Y, "%d", pb->num_left); #else - rb->snprintf(str, 3, "%d", pb->level); - rb->lcd_putsxy(LEVEL_TEXT_X, TEXT_Y, str); - rb->snprintf(str, 3, "%d", pb->num_left); - rb->lcd_putsxy(PEGS_TEXT_X, TEXT_Y, str); + rb->lcd_putsxyf(LEVEL_TEXT_X, TEXT_Y, "%d", pb->level); + rb->lcd_putsxyf(PEGS_TEXT_X, TEXT_Y, "%d", pb->num_left); #endif /*WIDE_LAYOUT*/ #ifdef HAVE_LCD_COLOR diff --git a/apps/plugins/reversi/reversi-gui.c b/apps/plugins/reversi/reversi-gui.c index 5188986e84..6f5d53da58 100644 --- a/apps/plugins/reversi/reversi-gui.c +++ b/apps/plugins/reversi/reversi-gui.c @@ -613,7 +613,6 @@ enum plugin_status plugin_start(const void *parameter) { int lastbutton = BUTTON_NONE; int row, col; int w_cnt, b_cnt; - char msg_buf[30]; /* Initialize Font Width and height */ rb->lcd_getstringsize("0", &font_width, &font_height); @@ -671,10 +670,8 @@ enum plugin_status plugin_start(const void *parameter) { /* TODO: Don't duplicate end of game check */ if (reversi_game_is_finished(&game, cur_player)) { reversi_count_occupied_cells(&game, &w_cnt, &b_cnt); - rb->snprintf(msg_buf, sizeof(msg_buf), - "Game over. %s won.", + rb->splashf(HZ*2, "Game over. %s won.", (w_cnt>b_cnt?"WHITE":"BLACK")); - rb->splash(HZ*2, msg_buf); draw_screen = true; /* Must update screen after splash */ game_finished = true; } @@ -743,10 +740,8 @@ enum plugin_status plugin_start(const void *parameter) { cur_player = reversi_flipped_color(cur_player); if (reversi_game_is_finished(&game, cur_player)) { reversi_count_occupied_cells(&game, &w_cnt, &b_cnt); - rb->snprintf(msg_buf, sizeof(msg_buf), - "Game over. %s won.", + rb->splashf(HZ*2, "Game over. %s won.", (w_cnt>b_cnt?"WHITE":"BLACK")); - rb->splash(HZ*2, msg_buf); draw_screen = true; /* Must update screen after splash */ game_finished = true; } diff --git a/apps/plugins/robotfindskitten.c b/apps/plugins/robotfindskitten.c index 003087b5c3..8426f35850 100644 --- a/apps/plugins/robotfindskitten.c +++ b/apps/plugins/robotfindskitten.c @@ -598,11 +598,9 @@ int screen[X_MAX + 1][Y_MAX + 1]; * *****************************************************************************/ -static void drawchar(int x, int y, char c) +static inline void drawchar(int x, int y, char c) { - char str[2]; - rb->snprintf(str, sizeof(str), "%c", c); - rb->lcd_putsxy(x*SYSFONT_WIDTH, y*SYSFONT_HEIGHT, str); + rb->lcd_putsxyf(x*SYSFONT_WIDTH, y*SYSFONT_HEIGHT, "%c", c); } static void draw(struct screen_object o) diff --git a/apps/plugins/rockblox.c b/apps/plugins/rockblox.c index 90df401ef9..44d637d8fa 100644 --- a/apps/plugins/rockblox.c +++ b/apps/plugins/rockblox.c @@ -810,25 +810,18 @@ static void init_board (void) /* show the score, level and lines */ static void show_details (void) { - char str[25]; /* for strings */ - #ifdef HAVE_LCD_BITMAP #if LCD_DEPTH >= 2 rb->lcd_set_foreground (LCD_BLACK); rb->lcd_set_background (LCD_WHITE); #endif - rb->snprintf (str, sizeof (str), "%d", rockblox_status.score); - rb->lcd_putsxy (LABEL_X, SCORE_Y, str); - rb->snprintf (str, sizeof (str), "%d", rockblox_status.level); - rb->lcd_putsxy (LEVEL_X, LEVEL_Y, str); - rb->snprintf (str, sizeof (str), "%d", rockblox_status.lines); - rb->lcd_putsxy (LINES_X, LINES_Y, str); + rb->lcd_putsxyf (LABEL_X, SCORE_Y, "%d", rockblox_status.score); + rb->lcd_putsxyf (LEVEL_X, LEVEL_Y, "%d", rockblox_status.level); + rb->lcd_putsxyf (LINES_X, LINES_Y, "%d", rockblox_status.lines); #else /* HAVE_LCD_CHARCELLS */ - rb->snprintf (str, sizeof (str), "L%d/%d", rockblox_status.level, + rb->lcd_putsf (5, 0, "L%d/%d", rockblox_status.level, rockblox_status.lines); - rb->lcd_puts (5, 0, str); - rb->snprintf (str, sizeof (str), "S%d", rockblox_status.score); - rb->lcd_puts (5, 1, str); + rb->lcd_putsf (5, 1, "S%d", rockblox_status.score); #endif } @@ -836,14 +829,10 @@ static void show_details (void) static void show_highscores (void) { int i; - char str[25]; /* for strings */ for (i = 0; isnprintf (str, sizeof (str), "%06d" _SPACE "L%1d", - highscores[i].score, highscores[i].level); - rb->lcd_putsxy (HIGH_LABEL_X, HIGH_SCORE_Y + (10 * i), str); - } + rb->lcd_putsxyf (HIGH_LABEL_X, HIGH_SCORE_Y + (10 * i), + "%06d" _SPACE "L%1d", highscores[i].score, highscores[i].level); } #endif diff --git a/apps/plugins/rockblox1d.c b/apps/plugins/rockblox1d.c index 6a175e5bb5..96937bbae9 100644 --- a/apps/plugins/rockblox1d.c +++ b/apps/plugins/rockblox1d.c @@ -206,7 +206,6 @@ enum plugin_status plugin_start(const void* parameter) int type_next_brick = 0; unsigned long int score = 34126; - char score_buf[10]; (void)parameter; @@ -278,8 +277,7 @@ enum plugin_status plugin_start(const void* parameter) } /* Score box */ - rb->snprintf(score_buf, sizeof(score_buf), "%8ld0", score); - rb->lcd_putsxy(score_x, SCORE_Y, score_buf); + rb->lcd_putsxyf(score_x, SCORE_Y, "%8ld0", score); rb->lcd_update(); diff --git a/apps/plugins/rockbox_flash.c b/apps/plugins/rockbox_flash.c index 9da3f63c8b..09ee96997c 100644 --- a/apps/plugins/rockbox_flash.c +++ b/apps/plugins/rockbox_flash.c @@ -559,7 +559,6 @@ static void DoUserDialog(char* filename) { tImageHeader ImageHeader; tFlashInfo FlashInfo; - static char buf[MAX_PATH]; int button; int rc; /* generic return code */ UINT32 space, aligned_size, true_size; @@ -612,8 +611,7 @@ static void DoUserDialog(char* filename) bl_version = BootloaderVersion(); if (bl_version < LATEST_BOOTLOADER_VERSION) { - rb->snprintf(buf, sizeof(buf), "Bootloader V%d", bl_version); - rb->lcd_puts(0, 0, buf); + rb->lcd_putsf(0, 0, "Bootloader V%d", bl_version); rb->lcd_puts(0, 1, "Hint: You're not "); rb->lcd_puts(0, 2, "using the latest "); rb->lcd_puts(0, 3, "bootloader. "); @@ -722,10 +720,9 @@ static void DoUserDialog(char* filename) if (rc) { /* errors */ rb->lcd_clear_display(); - rb->snprintf(buf, sizeof(buf), "%d errors", rc); rb->lcd_puts(0, 0, "Error:"); rb->lcd_puts(0, 1, "Programming fail!"); - rb->lcd_puts(0, 2, buf); + rb->lcd_putsf(0, 2, "%d errors", rc); rb->lcd_update(); button = WaitForButton(); } @@ -743,10 +740,9 @@ static void DoUserDialog(char* filename) } else { - rb->snprintf(buf, sizeof(buf), "%d errors", rc); rb->lcd_puts(0, 0, "Error:"); rb->lcd_puts(0, 1, "Verify fail!"); - rb->lcd_puts(0, 2, buf); + rb->lcd_putsf(0, 2, "%d errors", rc); rb->lcd_puts(0, 3, "Use safe image"); rb->lcd_puts(0, 4, "if booting hangs:"); rb->lcd_puts(0, 5, "F1 during power-on"); diff --git a/apps/plugins/rockboy/debug.c b/apps/plugins/rockboy/debug.c index a829b98799..8dc7320035 100644 --- a/apps/plugins/rockboy/debug.c +++ b/apps/plugins/rockboy/debug.c @@ -571,7 +571,7 @@ void debug_disassemble(addr a, int c) static int opaddr; static char mnemonic[256]; static char *pattern; - char meow[500],buf[300]; + char ops_str[300]; if(!debug_trace) return; while (c > 0) @@ -600,8 +600,7 @@ void debug_disassemble(addr a, int c) case 'B': case 'b': ops[k] = readb(a); a++; - j += snprintf(mnemonic + j,255-j, - "%02Xh", ops[k++]); + j += snprintf(mnemonic + j,255-j, "%02Xh", ops[k++]); break; case 'W': case 'w': @@ -614,8 +613,7 @@ void debug_disassemble(addr a, int c) case 'O': case 'o': ops[k] = readb(a); a++; - j += snprintf(mnemonic + j, 255-j,"%+d", - (n8)(ops[k++])); + j += snprintf(mnemonic + j, 255-j,"%+d", (n8)(ops[k++])); break; } i++; @@ -626,52 +624,19 @@ void debug_disassemble(addr a, int c) } } mnemonic[j] = 0; - snprintf(buf,299,"%04X ", opaddr); - strcpy(meow,buf); switch (operand_count[ops[0]]) { case 1: - snprintf(buf,299,"%02X ", ops[0]); - strcat(meow,buf); + snprintf(ops_str,sizeof(ops_str),"%02X ", ops[0]); break; case 2: - snprintf(buf,299,"%02X %02X ", ops[0], ops[1]); - strcat(meow,buf); + snprintf(ops_str,sizeof(ops_str),"%02X %02X ", ops[0], ops[1]); break; case 3: - snprintf(buf,299,"%02X %02X %02X ", ops[0], ops[1], ops[2]); - strcat(meow,buf); + snprintf(ops_str,sizeof(ops_str),"%02X %02X %02X", ops[0], ops[1], ops[2]); break; } - snprintf(buf,"%-16.16s", mnemonic); - strcat(meow,buf); - rb->lcd_putsxy(0,0,meow); + rb->lcd_putsxyf(0,0,"%04X %s %-16.16s", opaddr, ops_str, mnemonic); rb->lcd_update(); c--; } } - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/plugins/rockboy/lcd.c b/apps/plugins/rockboy/lcd.c index 0da9fc7e9d..22f8864889 100644 --- a/apps/plugins/rockboy/lcd.c +++ b/apps/plugins/rockboy/lcd.c @@ -1009,10 +1009,6 @@ void setvidmode(void) void lcd_refreshline(void) { -#ifdef HAVE_LCD_COLOR - char frameout[30]; -#endif - if (!(R_LCDC & 0x80)) return; /* should not happen... */ @@ -1112,8 +1108,8 @@ void lcd_refreshline(void) { if(options.showstats) { - snprintf(frameout,sizeof(frameout),"FPS: %d Frameskip: %d ",options.fps, options.frameskip); - rb->lcd_putsxy(0,LCD_HEIGHT-10,frameout); + rb->lcd_putsxyf(0,LCD_HEIGHT-10,"FPS: %d Frameskip: %d ", + options.fps, options.frameskip); rb->lcd_update_rect(0,LCD_HEIGHT-10, LCD_WIDTH, 10); } diff --git a/apps/plugins/rockboy/menu.c b/apps/plugins/rockboy/menu.c index 6e8df5c0ea..242518c01e 100644 --- a/apps/plugins/rockboy/menu.c +++ b/apps/plugins/rockboy/menu.c @@ -171,7 +171,7 @@ static void build_slot_path(char *buf, size_t bufsiz, int slot_id) { * */ static bool do_file(char *path, char *desc, bool is_load) { - char buf[200], desc_buf[20]; + char desc_buf[20]; int fd, file_mode; /* set file mode */ @@ -191,8 +191,7 @@ static bool do_file(char *path, char *desc, bool is_load) { loadstate(fd); /* print out a status message so the user knows the state loaded */ - snprintf(buf, 200, "Loaded state from \"%s\"", path); - rb->splash(HZ * 1, buf); + rb->splashf(HZ * 1, "Loaded state from \"%s\"", path); } else { diff --git a/apps/plugins/rocklife.c b/apps/plugins/rocklife.c index afe442f989..8ae5cdb120 100644 --- a/apps/plugins/rocklife.c +++ b/apps/plugins/rocklife.c @@ -90,7 +90,6 @@ unsigned char grid_b[GRID_W][GRID_H]; int generation = 0; int population = 0; int status_line = 0; -char buf[30]; static inline bool is_valid_cell(int x, int y) { @@ -308,11 +307,10 @@ static void show_grid(char *pgrid){ } } if(status_line){ - rb->snprintf(buf, sizeof(buf), "g:%d p:%d", generation, population); #if LCD_DEPTH > 1 rb->lcd_set_foreground( LCD_BLACK ); #endif - rb->lcd_puts(0, 0, buf); + rb->lcd_putsf(0, 0, "g:%d p:%d", generation, population); } rb->lcd_update(); } diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c index 7032a8e793..557c84d8ea 100644 --- a/apps/plugins/rockpaint.c +++ b/apps/plugins/rockpaint.c @@ -977,8 +977,6 @@ static unsigned int color_chooser( unsigned int color ) enum BaseColor current = Red; bool has_changed; - char str[6] = ""; - restore_screen(); rgb2hsv( red, green, blue, &hue, &saturation, &value ); @@ -1028,18 +1026,14 @@ static unsigned int color_chooser( unsigned int color ) #undef POSITION rb->lcd_set_background(COLOR_LIGHTGRAY); rb->lcd_setfont( FONT_SYSFIXED ); - rb->snprintf( str, 6, "%d", hue/10 ); - rb->lcd_putsxy( left + 117, top + 20, str ); - rb->snprintf( str, 6, "%d.%d", saturation/255, ((saturation*100)/255)%100 ); - rb->lcd_putsxy( left + 117, top + 30, str ); - rb->snprintf( str, 6, "%d.%d", value/255, ((value*100)/255)%100 ); - rb->lcd_putsxy( left + 117, top + 40, str ); - rb->snprintf( str, 6, "%d", red ); - rb->lcd_putsxy( left + 117, top + 50, str ); - rb->snprintf( str, 6, "%d", green ); - rb->lcd_putsxy( left + 117, top + 60, str ); - rb->snprintf( str, 6, "%d", blue ); - rb->lcd_putsxy( left + 117, top + 70, str ); + rb->lcd_putsxyf( left + 117, top + 20, "%d", hue/10 ); + rb->lcd_putsxyf( left + 117, top + 30, "%d.%d", + saturation/255, ((saturation*100)/255)%100 ); + rb->lcd_putsxyf( left + 117, top + 40, "%d.%d", + value/255, ((value*100)/255)%100 ); + rb->lcd_putsxyf( left + 117, top + 50, "%d", red ); + rb->lcd_putsxyf( left + 117, top + 60, "%d", green ); + rb->lcd_putsxyf( left + 117, top + 70, "%d", blue ); rb->lcd_setfont( FONT_UI ); #define CURSOR( l ) \ diff --git a/apps/plugins/sliding_puzzle.c b/apps/plugins/sliding_puzzle.c index 6ea04d5057..517a3a1690 100644 --- a/apps/plugins/sliding_puzzle.c +++ b/apps/plugins/sliding_puzzle.c @@ -489,8 +489,7 @@ static void move_spot(int x, int y) moves_y, s); #else (void)w; - rb->snprintf(s, sizeof(s), "Moves: %d", moves); - rb->lcd_putsxy(3, moves_y, s); + rb->lcd_putsxyf(3, moves_y, "Moves: %d", moves); #endif for(i=1;i<=4;i++) { @@ -532,8 +531,7 @@ static void draw_playfield(void) #else (void)w; rb->lcd_hline(0, LCD_WIDTH-1, IMAGE_HEIGHT); - rb->snprintf(s, sizeof(s), "Moves: %d", moves); - rb->lcd_putsxy(3, moves_y, s); + rb->lcd_putsxyf(3, moves_y, "Moves: %d", moves); #endif /* draw spots to the lcd */ diff --git a/apps/plugins/snake.c b/apps/plugins/snake.c index 5ae941a655..eb2b311fc9 100644 --- a/apps/plugins/snake.c +++ b/apps/plugins/snake.c @@ -260,18 +260,14 @@ static struct configdata config[] = { static void snake_die (void) { - char pscore[17]; rb->lcd_clear_display(); - rb->snprintf(pscore,sizeof(pscore),"Your score: %d",score); rb->lcd_puts(0,0,"Oops..."); - rb->lcd_puts(0,1, pscore); + rb->lcd_putsf(0,1,"Your score: %d",score); if (highscore_update(score, level, "", highscores, NUM_SCORES) == 0) { rb->lcd_puts(0,2,"New High Score!"); } else { - rb->snprintf(pscore, sizeof(pscore), - "High Score: %d", highscores[0].score); - rb->lcd_puts(0,2,pscore); + rb->lcd_putsf(0,2,"High Score: %d", highscores[0].score); } rb->lcd_update(); rb->sleep(3*HZ); diff --git a/apps/plugins/sokoban.c b/apps/plugins/sokoban.c index 6e94519803..1159402bac 100644 --- a/apps/plugins/sokoban.c +++ b/apps/plugins/sokoban.c @@ -982,14 +982,11 @@ static void update_screen(void) #define BOARD_WIDTH LCD_WIDTH #define BOARD_HEIGHT (LCD_HEIGHT - STAT_HEIGHT) rb->lcd_putsxy(STAT_X + 4, STAT_Y + 4, "Level"); - rb->snprintf(buf, sizeof(buf), "%d", current_info.level.index + 1); - rb->lcd_putsxy(STAT_X + 7, STAT_Y + 14, buf); + rb->lcd_putsxyf(STAT_X + 7, STAT_Y + 14, "%d", current_info.level.index + 1); rb->lcd_putsxy(STAT_X + 41, STAT_Y + 4, "Moves"); - rb->snprintf(buf, sizeof(buf), "%d", current_info.level.moves); - rb->lcd_putsxy(STAT_X + 44, STAT_Y + 14, buf); + rb->lcd_putsxyf(STAT_X + 44, STAT_Y + 14, "%d", current_info.level.moves); rb->lcd_putsxy(STAT_X + 79, STAT_Y + 4, "Pushes"); - rb->snprintf(buf, sizeof(buf), "%d", current_info.level.pushes); - rb->lcd_putsxy(STAT_X + 82, STAT_Y + 14, buf); + rb->lcd_putsxyf(STAT_X + 82, STAT_Y + 14, "%d", current_info.level.pushes); rb->lcd_drawrect(STAT_X, STAT_Y, 38, STAT_HEIGHT); rb->lcd_drawrect(STAT_X + 37, STAT_Y, 39, STAT_HEIGHT); @@ -1005,18 +1002,15 @@ static void update_screen(void) #define BOARD_WIDTH (LCD_WIDTH - STAT_WIDTH) #define BOARD_HEIGHT LCD_HEIGHT rb->lcd_putsxy(STAT_X + 1, STAT_Y + 2, "Level"); - rb->snprintf(buf, sizeof(buf), "%d", current_info.level.index + 1); - rb->lcd_putsxy(STAT_X + 4, STAT_Y + 12, buf); + rb->lcd_putsxyf(STAT_X + 4, STAT_Y + 12, "%d", current_info.level.index + 1); rb->lcd_putsxy(STAT_X + 1, STAT_Y + 23, "Moves"); - rb->snprintf(buf, sizeof(buf), "%d", current_info.level.moves); - rb->lcd_putsxy(STAT_X + 4, STAT_Y + 33, buf); + rb->lcd_putsxyf(STAT_X + 4, STAT_Y + 33, "%d", current_info.level.moves); #if STAT_WIDTH < 38 rb->lcd_putsxy(STAT_X + 1, STAT_Y + 44, "Push"); #else rb->lcd_putsxy(STAT_X + 1, STAT_Y + 44, "Pushes"); #endif - rb->snprintf(buf, sizeof(buf), "%d", current_info.level.pushes); - rb->lcd_putsxy(STAT_X + 4, STAT_Y + 54, buf); + rb->lcd_putsxyf(STAT_X + 4, STAT_Y + 54, "%d", current_info.level.pushes); rb->lcd_drawrect(STAT_X, STAT_Y + 0, STAT_WIDTH, 64); rb->lcd_hline(STAT_X, LCD_WIDTH - 1, STAT_Y + 21); diff --git a/apps/plugins/spacerocks.c b/apps/plugins/spacerocks.c index 2e7ccc0743..206d52aed8 100644 --- a/apps/plugins/spacerocks.c +++ b/apps/plugins/spacerocks.c @@ -1826,7 +1826,6 @@ static int spacerocks_menu(void) static int spacerocks_game_loop(void) { - char str[20]; int button; int end; int position; @@ -1861,8 +1860,7 @@ static int spacerocks_game_loop(void) break; case PAUSE_MODE: - rb->snprintf(str, sizeof(str), "score %d ", current_score); - rb->lcd_putsxy(1,LCD_HEIGHT-8, str); + rb->lcd_putsxyf(1,LCD_HEIGHT-8, "score %d ", current_score); rb->lcd_putsxy(CENTER_LCD_X - 15, CENTER_LCD_Y + CENTER_LCD_Y/2 - 4, "pause"); draw_and_move_missiles(); @@ -1871,8 +1869,7 @@ static int spacerocks_game_loop(void) break; case PLAY_MODE: - rb->snprintf(str, sizeof(str), "score %d ", current_score); - rb->lcd_putsxy(1, LCD_HEIGHT-8, str); + rb->lcd_putsxyf(1, LCD_HEIGHT-8, "score %d ", current_score); draw_and_move_missiles(); draw_lives(); check_collisions(); @@ -1880,11 +1877,10 @@ static int spacerocks_game_loop(void) break; case SHOW_LEVEL: - rb->snprintf(str, sizeof(str), "score %d ", current_score); - rb->lcd_putsxy(1, LCD_HEIGHT-8, str); - rb->snprintf(str, sizeof(str), "stage %d ", current_level); - rb->lcd_putsxy(CENTER_LCD_X - 20, - CENTER_LCD_Y + CENTER_LCD_Y/2 - 4, str); + rb->lcd_putsxyf(1, LCD_HEIGHT-8, "score %d ", current_score); + rb->lcd_putsxyf(CENTER_LCD_X - 20, + CENTER_LCD_Y + CENTER_LCD_Y/2 - 4, + "stage %d ", current_level); draw_lives(); draw_and_move_ship(); show_level_timeout--; diff --git a/apps/plugins/star.c b/apps/plugins/star.c index e5d8259d88..a653bdb4a9 100644 --- a/apps/plugins/star.c +++ b/apps/plugins/star.c @@ -759,7 +759,6 @@ static void star_transition_update(void) static void star_display_board_info(int current_level) { int label_pos_y, tile_pos_y; - char str_info[32]; if (TILE_HEIGHT > char_height) { @@ -772,10 +771,9 @@ static void star_display_board_info(int current_level) tile_pos_y = label_pos_y + (char_height - TILE_HEIGHT) / 2; } - rb->snprintf(str_info, sizeof(str_info), "L:%02d", current_level + 1); - rb->lcd_putsxy(STAR_OFFSET_X, label_pos_y, str_info); - rb->snprintf(str_info, sizeof(str_info), "S:%02d", star_count); - rb->lcd_putsxy(LCD_WIDTH/2 - 2 * char_width, label_pos_y, str_info); + rb->lcd_putsxyf(STAR_OFFSET_X, label_pos_y, "L:%02d", current_level + 1); + rb->lcd_putsxyf(LCD_WIDTH/2 - 2 * char_width, label_pos_y, "S:%02d", + star_count); rb->lcd_putsxy(STAR_OFFSET_X + (STAR_WIDTH-1) * TILE_WIDTH - 2 * char_width, label_pos_y, "C:"); diff --git a/apps/plugins/starfield.c b/apps/plugins/starfield.c index 7f17970a84..6ddc268285 100644 --- a/apps/plugins/starfield.c +++ b/apps/plugins/starfield.c @@ -377,7 +377,6 @@ static struct starfield starfield; int plugin_main(void) { - char str_buffer[40]; int button, avg_peak, t_disp=0; int font_h, font_w; bool pulse=true; @@ -449,14 +448,11 @@ int plugin_main(void) if (t_disp > 0) { --t_disp; - rb->snprintf(str_buffer, sizeof(str_buffer), - "star:%d speed:%d", - starfield.nb_stars, - starfield.z_move); #ifdef HAVE_LCD_COLOR rb->lcd_set_foreground(LCD_WHITE); #endif - rb->lcd_putsxy(0, LCD_HEIGHT-font_h, str_buffer); + rb->lcd_putsxyf(0, LCD_HEIGHT-font_h, "star:%d speed:%d", + starfield.nb_stars, starfield.z_move); } rb->lcd_update(); diff --git a/apps/plugins/superdom.c b/apps/plugins/superdom.c index 5ded7f9f12..ad54c565b2 100644 --- a/apps/plugins/superdom.c +++ b/apps/plugins/superdom.c @@ -500,13 +500,9 @@ void update_score(void) { rb->lcd_fillrect(5,LCD_HEIGHT-20,105,20); rb->lcd_set_drawmode(DRMODE_SOLID); strength = calc_strength(COLOUR_LIGHT, cursor.x, cursor.y); - rb->snprintf(buf, sizeof(buf), "Your power: %d.%d", - strength/10, strength%10); - rb->lcd_putsxy(5,LCD_HEIGHT-20, buf); + rb->lcd_putsxyf(5,LCD_HEIGHT-20,"Your power: %d.%d",strength/10,strength%10); strength = calc_strength(COLOUR_DARK, cursor.x, cursor.y); - rb->snprintf(buf, sizeof(buf), "Comp power: %d.%d", - strength/10, strength%10); - rb->lcd_putsxy(5,LCD_HEIGHT-10, buf); + rb->lcd_putsxyf(5,LCD_HEIGHT-10,"Comp power: %d.%d",strength/10,strength%10); rb->lcd_setfont(FONT_UI); } @@ -733,8 +729,7 @@ int get_number(char* param, int* value, int max) { button_labels[i][j]); } } - rb->snprintf(buf,sizeof(buf), "%d", *value); - rb->lcd_putsxy(NUM_MARGIN_X+10, NUM_MARGIN_Y+4*NUM_BOX_HEIGHT+10, buf); + rb->lcd_putsxyf(NUM_MARGIN_X+10, NUM_MARGIN_Y+4*NUM_BOX_HEIGHT+10,"%d",*value); rb->lcd_getstringsize(param, &width, &height); if(width < LCD_WIDTH) rb->lcd_putsxy((LCD_WIDTH-width)/2, (NUM_MARGIN_Y-height)/2, param); @@ -772,9 +767,8 @@ int get_number(char* param, int* value, int max) { rb->lcd_fillrect(0, NUM_MARGIN_Y+4*NUM_BOX_HEIGHT+10, LCD_WIDTH, 30); rb->lcd_set_drawmode(DRMODE_SOLID); - rb->snprintf(buf,sizeof(buf), "%d", *value); - rb->lcd_putsxy(NUM_MARGIN_X+10, - NUM_MARGIN_Y+4*NUM_BOX_HEIGHT+10, buf); + rb->lcd_putsxyf(NUM_MARGIN_X+10,NUM_MARGIN_Y+4*NUM_BOX_HEIGHT+10, + "%d", *value); break; case SUPERDOM_CANCEL: *value = 0; @@ -1404,10 +1398,8 @@ int select_square(void) { update_score(); #if LCD_WIDTH >= 220 rb->lcd_setfont(FONT_SYSFIXED); - rb->snprintf(buf, sizeof(buf), "Cash: %d", humanres.cash); - rb->lcd_putsxy(125, LCD_HEIGHT-20, buf); - rb->snprintf(buf, sizeof(buf), "Food: %d", humanres.food); - rb->lcd_putsxy(125, LCD_HEIGHT-10, buf); + rb->lcd_putsxyf(125, LCD_HEIGHT-20,"Cash: %d", humanres.cash); + rb->lcd_putsxyf(125, LCD_HEIGHT-10,"Food: %d", humanres.food); rb->lcd_setfont(FONT_UI); #endif rb->lcd_update(); diff --git a/apps/plugins/test_scanrate.c b/apps/plugins/test_scanrate.c index d29544fb33..f22beb87ff 100644 --- a/apps/plugins/test_scanrate.c +++ b/apps/plugins/test_scanrate.c @@ -152,7 +152,6 @@ static void timer_isr(void) int plugin_main(void) { - unsigned char buf[32]; int button; bool done = false; bool change = true; @@ -186,9 +185,8 @@ int plugin_main(void) { /* The actual frequency is twice the displayed value */ rb->timer_set_period(TIMER_FREQ * 5 / scan_rate); - rb->snprintf(buf, sizeof(buf), "f: %d.%d Hz", scan_rate / 10, + rb->lcd_putsxyf(TEXT_X, TEXT_Y, "f: %d.%d Hz", scan_rate / 10, scan_rate % 10); - rb->lcd_putsxy(TEXT_X, TEXT_Y, buf); need_refresh = true; change = false; } diff --git a/apps/plugins/vbrfix.c b/apps/plugins/vbrfix.c index 71c502bc67..98ca15b6a8 100644 --- a/apps/plugins/vbrfix.c +++ b/apps/plugins/vbrfix.c @@ -29,10 +29,7 @@ char tmpname[MAX_PATH]; static void xingupdate(int percent) { - char buf[32]; - - rb->snprintf(buf, 32, "%d%%", percent); - rb->lcd_puts(0, 1, buf); + rb->lcd_putsf(0, 1, "%d%%", percent); rb->lcd_update(); } diff --git a/apps/plugins/vu_meter.c b/apps/plugins/vu_meter.c index 6dc69d1d4e..f9ecf8ef33 100644 --- a/apps/plugins/vu_meter.c +++ b/apps/plugins/vu_meter.c @@ -465,7 +465,6 @@ void save_settings(void) { } void change_volume(int delta) { - char curr_vol[5]; int minvol = rb->sound_min(SOUND_VOLUME); int maxvol = rb->sound_max(SOUND_VOLUME); int vol = rb->global_settings->volume + delta; @@ -475,8 +474,7 @@ void change_volume(int delta) { if (vol != rb->global_settings->volume) { rb->sound_set(SOUND_VOLUME, vol); rb->global_settings->volume = vol; - rb->snprintf(curr_vol, sizeof(curr_vol), "%d", vol); - rb->lcd_putsxy(0,0, curr_vol); + rb->lcd_putsxyf(0,0, "%d", vol); rb->lcd_update(); rb->sleep(HZ/12); } diff --git a/apps/plugins/wav2wv.c b/apps/plugins/wav2wv.c index 98b4c0fe4f..e2db398ef7 100644 --- a/apps/plugins/wav2wv.c +++ b/apps/plugins/wav2wv.c @@ -58,7 +58,6 @@ static void wvupdate (int32_t start_tick, { int32_t elapsed_ticks = *rb->current_tick - start_tick; int compression = 0, progress = 0, realtime = 0; - char buf[32]; if (total_samples) progress = (int)(((int64_t) samples_converted * 100 + @@ -72,18 +71,11 @@ static void wvupdate (int32_t start_tick, compression = (int)(((int64_t)(bytes_read - bytes_written) * 100 + (bytes_read/2)) / bytes_read); - rb->snprintf(buf, 32, "elapsed time: %ld secs", + rb->lcd_putsf(0, 2, "elapsed time: %ld secs", (long)(elapsed_ticks + (HZ/2)) / HZ); - rb->lcd_puts(0, 2, (unsigned char *)buf); - - rb->snprintf(buf, 32, "progress: %d%%", progress); - rb->lcd_puts(0, 4, (unsigned char *)buf); - - rb->snprintf(buf, 32, "realtime: %d%% ", realtime); - rb->lcd_puts(0, 6, (unsigned char *)buf); - - rb->snprintf(buf, 32, "compression: %d%% ", compression); - rb->lcd_puts(0, 8, (unsigned char *)buf); + rb->lcd_putsf(0, 4, "progress: %d%%", progress); + rb->lcd_putsf(0, 6, "realtime: %d%% ", realtime); + rb->lcd_putsf(0, 8, "compression: %d%% ", compression); #ifdef HAVE_LCD_BITMAP rb->lcd_update(); diff --git a/apps/plugins/wavplay.c b/apps/plugins/wavplay.c index cbd4dfbeda..887c5cdd55 100644 --- a/apps/plugins/wavplay.c +++ b/apps/plugins/wavplay.c @@ -3454,7 +3454,6 @@ void cleanup(void *fd) int play_file(char* filename) { - char buf[32]; int button; int fd; int wanted, got; @@ -3540,11 +3539,9 @@ int play_file(char* filename) time = bytes / (samplerate * 2 * channels); rb->lcd_puts(0, 0, "Playing WAV file"); - rb->snprintf(buf, sizeof(buf), "%dHz %s", samplerate, + rb->lcd_putsf(0, 1, "%dHz %s", samplerate, (channels == 1) ? "mono" : "stereo"); - rb->lcd_puts(0, 1, buf); - rb->snprintf(buf, sizeof(buf), "Length: %d:%02d", time / 60, time % 60); - rb->lcd_puts(0, 2, buf); + rb->lcd_putsf(0, 2, "Length: %d:%02d", time / 60, time % 60); rb->lcd_update(); rb->sound_set_pitch(PITCH_SPEED_100); /* reset pitch */ diff --git a/apps/plugins/wavrecord.c b/apps/plugins/wavrecord.c index 375642ec4b..91ce9c92f6 100644 --- a/apps/plugins/wavrecord.c +++ b/apps/plugins/wavrecord.c @@ -3480,7 +3480,6 @@ static bool update_wav_header(char *filename, int sample_rate, static int record_file(char *filename) { bool recording, saving; - char buf[32]; int fd, low_water, i; int bytes_written; int button; @@ -3514,8 +3513,6 @@ static int record_file(char *filename) rb->lcd_clear_display(); rb->lcd_puts(0, 0, filename); - rb->snprintf(buf, sizeof(buf), "%sHz 16bit %s", - samplerate_str[reccfg.samplerate], channel_str[reccfg.channels]); switch (reccfg.source) { @@ -3535,12 +3532,18 @@ static int record_file(char *filename) #ifdef HAVE_SPDIF_REC case WAV_SRC_SPDIF: rb->mas_codec_writereg(0, 0x01); - rb->snprintf(buf, sizeof(buf), "16bit %s", - channel_str[reccfg.channels]); break; #endif } - rb->lcd_puts(0, 1, buf); + +#ifdef HAVE_SPDIF_REC + if (reccfg.source == WAV_SRC_SPDIF) + rb->lcd_putsf(0, 1, "16bit %s", channel_str[reccfg.channels]); + else +#endif + rb->lcd_putsf(0, 1, "%sHz 16bit %s", + samplerate_str[reccfg.samplerate], channel_str[reccfg.channels]); + rb->lcd_update(); mas = 0x0060 /* no framing, little endian */ @@ -3649,8 +3652,7 @@ static int record_file(char *filename) recording = false; saving = true; } - rb->snprintf(buf, sizeof(buf), "Bytes: %d", num_rec_bytes); - rb->lcd_puts(0, 2, buf); + rb->lcd_puts(0, 2, "Bytes: %d", num_rec_bytes); rb->lcd_update(); } /* read sample rate from MAS */ diff --git a/apps/plugins/wavview.c b/apps/plugins/wavview.c index ddf72e10af..25afa40901 100644 --- a/apps/plugins/wavview.c +++ b/apps/plugins/wavview.c @@ -109,7 +109,6 @@ static int readwavpeaks(const char *filename) int file; uint32_t total_bytes_read = 0; - char tstr[128]; int hours; int minutes; int seconds; @@ -156,25 +155,20 @@ static int readwavpeaks(const char *filename) rb->lcd_puts_scroll(0, 1, (unsigned char *)filename); rb->lcd_update(); - rb->snprintf(tstr,127, "Channels: %s", + rb->lcd_putsf(0, 2, "Channels: %s", header.numchannels == 1 ? "mono" : "stereo"); - rb->lcd_puts(0, 2, tstr); - - rb->snprintf(tstr,127, "Bits/sample: %d", header.bitspersample); - rb->lcd_puts(0, 3, tstr); - - rb->snprintf(tstr,127, "Samplerate: %d Hz", (int)(header.samplerate)); - rb->lcd_puts(0, 4, tstr); + rb->lcd_putsf(0, 3, "Bits/sample: %d", header.bitspersample); + rb->lcd_putsf(0, 4, "Samplerate: %"PRIu32" Hz", header.samplerate); seconds = header.datachunksize / header.byterate; hours = seconds / 3600; seconds -= hours * 3600; minutes = seconds / 60; seconds -= minutes * 60; - rb->snprintf(tstr,127, "Length (hh:mm:ss): %02d:%02d:%02d", hours, - minutes, - seconds); - rb->lcd_puts(0, 5, tstr); + + rb->lcd_putsf(0, 5, "Length (hh:mm:ss): %02d:%02d:%02d", hours, + minutes, + seconds); rb->lcd_puts(0, 6, "Searching for peaks... "); rb->lcd_update(); @@ -246,10 +240,9 @@ static int readwavpeaks(const char *filename) } /* update progress */ - rb->snprintf(tstr,127, "Searching for peaks... %d%%",(int) + rb->lcd_putsf(0, 6, "Searching for peaks... %"PRIu32"%%", (total_bytes_read / ((header.datachunksize + sizeof(struct wav_header)) / 100))); - rb->lcd_puts(0, 6, tstr); rb->lcd_update(); /* allow user to abort */ diff --git a/apps/plugins/xobox.c b/apps/plugins/xobox.c index 871cb2bdf5..e93a820b71 100644 --- a/apps/plugins/xobox.c +++ b/apps/plugins/xobox.c @@ -549,7 +549,7 @@ static int percentage (void) static void refresh_board (void) { int i, j; - char str[25]; + int x; #if LCD_DEPTH>=2 rb->lcd_set_background (LCD_BLACK); @@ -590,21 +590,18 @@ static void refresh_board (void) #else rb->lcd_set_drawmode (DRMODE_COMPLEMENT); #endif - rb->snprintf (str, sizeof (str), "Level %d", player.level + 1); - rb->lcd_putsxy (BOARD_X, BOARD_Y, str); - rb->snprintf (str, sizeof (str), "%d%%", percentage_cache); - rb->lcd_putsxy (BOARD_X + CUBE_SIZE * BOARD_W - 24, BOARD_Y, str); - rb->snprintf (str, sizeof (str), "Score: %d", player.score); - rb->lcd_putsxy (BOARD_X, BOARD_Y + CUBE_SIZE * BOARD_H - 8, str); - rb->snprintf (str, sizeof (str), - (player.lives != 1) ? "%d Lives" : "%d Life", player.lives); + rb->lcd_putsxyf (BOARD_X, BOARD_Y, "Level %d", player.level + 1); + rb->lcd_putsxyf (BOARD_X + CUBE_SIZE * BOARD_W - 24, BOARD_Y, "%d%%", + percentage_cache); + rb->lcd_putsxyf (BOARD_X, BOARD_Y + CUBE_SIZE * BOARD_H - 8, "Score: %d", + player.score); #if LCD_DEPTH>=2 - rb->lcd_putsxy (BOARD_X + CUBE_SIZE * BOARD_W - 60, - BOARD_Y + CUBE_SIZE * BOARD_H - 8, str); + x = BOARD_X + CUBE_SIZE * BOARD_W - 60; #else - rb->lcd_putsxy (BOARD_X + CUBE_SIZE * BOARD_W - 40, - BOARD_Y + CUBE_SIZE * BOARD_H - 8, str); + x = BOARD_X + CUBE_SIZE * BOARD_W - 40; #endif + rb->lcd_putsxyf (x, BOARD_Y + CUBE_SIZE * BOARD_H - 8, + (player.lives != 1) ? "%d Lives" : "%d Life", player.lives); #if LCD_DEPTH>=2 rb->lcd_set_foreground (PLR_COL); diff --git a/apps/plugins/zxbox/zxvid_16bpp.c b/apps/plugins/zxbox/zxvid_16bpp.c index 4a05c69f97..f213afe307 100644 --- a/apps/plugins/zxbox/zxvid_16bpp.c +++ b/apps/plugins/zxbox/zxvid_16bpp.c @@ -49,7 +49,6 @@ void init_spect_scr(void) void update_screen(void) { - char str[80]; fb_data *frameb; int y=0; @@ -88,10 +87,7 @@ void update_screen(void) int TPF = HZ/50;/* ticks per frame */ if ((*rb->current_tick-start_time) > TPF ) percent = 100*video_frames/((*rb->current_tick-start_time)/TPF); - rb->snprintf(str,sizeof(str),"%d %%",percent); - rb->lcd_putsxy(0,0,str); + rb->lcd_putsxyf(0,0,"%d %%",percent); } rb -> lcd_update(); } - - diff --git a/apps/plugins/zxbox/zxvid_2bpp.c b/apps/plugins/zxbox/zxvid_2bpp.c index 0a4519e0ac..9f98ab4cfb 100644 --- a/apps/plugins/zxbox/zxvid_2bpp.c +++ b/apps/plugins/zxbox/zxvid_2bpp.c @@ -41,8 +41,6 @@ void init_spect_scr(void) } void update_screen(void) { - char str[80]; - fb_data *frameb; int y=0; int x=0; @@ -106,8 +104,7 @@ void update_screen(void) int TPF = HZ/50;/* ticks per frame */ if ((*rb->current_tick-start_time) > TPF ) percent = 100*video_frames/((*rb->current_tick-start_time)/TPF); - rb->snprintf(str,sizeof(str),"%d %%",percent); - rb->lcd_putsxy(0,0,str); + rb->lcd_putsxyf(0,0,"%d %%",percent); } -- cgit v1.2.3