[patch] - new bbsplash applet
Bernhard Fischer
rep.dot.nop at gmail.com
Fri Feb 8 13:28:19 UTC 2008
On Fri, Feb 08, 2008 at 11:41:08AM +0100, Michele Sanges wrote:
>Hello everybody,
>
>here is a patch for busybox-1.9.0 tarball, that adds my implementation
>of an utility that shows a splash image and a progress bar on
>framebuffer device; it can be used during the boot phase of an embedded
>device. I named it 'bbsplash'.
>
>It consists of four files, 'bbsplash' and 'framebuffer' (.c and .h),
>that I added in miscutils directory. If this is not the appropriate
>place, fell free to move them (I wanted to put them into a subdirectory
>of miscutil, but I was unable to compile).
>
>
>Usage of bbsplash:
>* reboot the system, passing to the kernel the options 'vga=xxx' in
>order to enable the framebuffer at the appropriate resolution, and
>'bbsplash=on'. This one is useful when you start the applet in the
>initramdisk and, for some reasons, you want disable it.
>
>* make the directory '/etc/bbsplash' and put in it the file
>'bbsplash.ini' and your splash image in .ppm format. Configure the
>applet by editing the .ini file.
>
>* when started, the applet daemonize it, make a fifo
>('/dev/bbsplash_fifo') and a log file ('/dev/bbsplash_log').
>- it is possible communicate with the daemon sending the following
>messages to the fifo:
>- the percentage of the boot process
>- the 'exit' command in order to kill the daemon
>
>* you can test this applet by means the script 'test.sh'.
How big is this applet?
Further comments below..
>
>Regards.
>Michele Sanges
>
>
># debug messages: ON or OFF
>DEBUG_MESSAGES=ON
># splash theme
>SPLASH_THEME=splash.ppm
># progress bar width
>BAR_WIDTH=300
># progress bar height
>BAR_HEIGHT=20
># progress bar orizzontal position
>BAR_POS_X=170
># progress bar vertical position
>BAR_POS_Y=300
># progress bar colour red component
>BAR_R_COL=80
># progress bar colour green component
>BAR_G_COL=80
># progress bar colour blue component
>BAR_B_COL=130
>diff -urP busybox-1.9.0_originale/include/applets.h busybox-1.9.0_bbsplash/include/applets.h
>--- busybox-1.9.0_originale/include/applets.h 2007-12-21 23:00:31.000000000 +0100
>+++ busybox-1.9.0_bbsplash/include/applets.h 2008-02-07 18:24:58.000000000 +0100
>@@ -85,6 +85,7 @@
> USE_AWK(APPLET_NOEXEC(awk, awk, _BB_DIR_USR_BIN, _BB_SUID_NEVER, awk))
> USE_BASENAME(APPLET_NOFORK(basename, basename, _BB_DIR_USR_BIN, _BB_SUID_NEVER, basename))
> USE_BBCONFIG(APPLET(bbconfig, _BB_DIR_BIN, _BB_SUID_NEVER))
>+USE_BBSPLASH(APPLET(bbsplash, _BB_DIR_BIN, _BB_SUID_NEVER))
> //USE_BBSH(APPLET(bbsh, _BB_DIR_BIN, _BB_SUID_NEVER))
You have to maintain alphabetical order here, see comment above this block.
> USE_BUNZIP2(APPLET(bunzip2, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
> USE_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, _BB_DIR_USR_BIN, _BB_SUID_NEVER, bzcat))
>diff -urP busybox-1.9.0_originale/include/usage.h busybox-1.9.0_bbsplash/include/usage.h
>--- busybox-1.9.0_originale/include/usage.h 2007-12-21 23:00:31.000000000 +0100
>+++ busybox-1.9.0_bbsplash/include/usage.h 2008-02-07 18:24:07.000000000 +0100
>@@ -119,6 +119,17 @@
> "$ basename /foo/bar.txt .txt\n" \
> "bar"
>
>+#define bbsplash_trivial_usage \
>+ "-[vh]"
>+#define bbsplash_full_usage \
>+ "Options:\n" \
>+ " -v Show program version informations\n" \
>+ " -h Show help informations\n"
I think that both are not needed, i'd drop them.
>+#define bbsplash_example_usage \
>+ "$ bbsplash (start the daemon)" \
>+ "$ echo val > /dev/bbsplash (where val=0..100 - show a progress bar of value val)\n" \
>+ "$ echo exit > /dev/bbsplash (kill the daemon)\n"
>+
> #define bunzip2_trivial_usage \
> "[OPTION]... [FILE]"
> #define bunzip2_full_usage \
>diff -urP busybox-1.9.0_originale/miscutils/bbsplash.c busybox-1.9.0_bbsplash/miscutils/bbsplash.c
>--- busybox-1.9.0_originale/miscutils/bbsplash.c 1970-01-01 01:00:00.000000000 +0100
>+++ busybox-1.9.0_bbsplash/miscutils/bbsplash.c 2008-02-08 10:49:25.000000000 +0100
>@@ -0,0 +1,313 @@
>+/* vi: set sw=4 ts=4: */
>+/*
>+ * boot splash implementation for busybox
>+ *
>+ * Copyright (C)[2008 by Michele Sanges <michele.sanges at otomelara.it> <pigrecoq at libero.it>
>+ *
>+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
>+ */
>+
>+#include "bbsplash.h"
>+
>+StructSystemConfiguration SystemConfiguration; ///< hold the system configuration data
>+
>+
>+/**
>+ * initializes the application with the data taken from the configuration file.
>+ * \return nothing
>+ */
Can you reuse the configfile-parsing of e.g. mdev?
Also this looks like it should be static.
>+void Init(void)
>+{
>+ char strIniFile[40];
>+ FILE *pIniFile;
>+ char strIniRecord[150];
>+
>+ sprintf(strIniFile, "/etc/%s/%s.ini", PROGRAM, PROGRAM);
>+ pIniFile = fopen(strIniFile, "r");
>+
>+ if (pIniFile == NULL)
>+ {
>+ printf("configuration file /etc/bbsplash/bbsplash.ini not found... exit\n");
>+ exit(EXIT_FAILURE);
>+ }
>+
>+ while(!feof(pIniFile))
>+ {
>+ char *pValue;
>+ int nPos;
>+ char strParam[100];
>+
>+ if (fgets(strIniRecord, 150, pIniFile) == NULL) // Reading record
>+ continue;
>+
>+ if (strIniRecord[0] == '#') // it's a comment
>+ continue;
>+
>+ pValue = strstr(strIniRecord, "="); // pointer to character '='
>+ nPos = pValue - strIniRecord; // position of the character '='
>+
>+ // parameter
>+ memcpy(strParam, strIniRecord, nPos);
>+ strParam[nPos] = '\0';
>+ // value
>+ pValue[strlen(pValue)-1] = '\0';
>+
>+ if (strcmp(strParam, "DEBUG_MESSAGES") == 0)
erm, no. Use index_in_str_array() or try to reuse mdev's config parser
for this..
>+ {
>+ // flag for enable/disable writing messages on the standard output
>+ SystemConfiguration.bDebugMessages = (strcmp(pValue + 1, "ON") == 0);
>+ if (SystemConfiguration.bDebugMessages)
>+ {
>+ char strLogFile[40];
>+ sprintf(strLogFile, "/dev/%s_log", PROGRAM);
>+ SystemConfiguration.logFile_fd = fopen(strLogFile, "w");
>+ }
>+ }
>+ if (strcmp(strParam, "SPLASH_THEME") == 0)
>+ {
>+ // name of the splash theme
>+ sprintf(SystemConfiguration.strSplashTheme, "/etc/%s/%s", PROGRAM, (pValue + 1));
>+ }
>+ else if (strcmp(strParam, "BAR_WIDTH") == 0)
>+ {
>+ // progress bar width
>+ SystemConfiguration.nBar_Width = atoi(pValue + 1);
>+ }
>+ else if (strcmp(strParam, "BAR_HEIGHT") == 0)
>+ {
>+ // progress bar height
>+ SystemConfiguration.nBar_Height = atoi(pValue + 1);
>+ }
>+ else if (strcmp(strParam, "BAR_POS_X") == 0)
>+ {
>+ // progress bar orizzontal position
>+ SystemConfiguration.nBar_PosX = atoi(pValue + 1);
>+ }
>+ else if (strcmp(strParam, "BAR_POS_Y") == 0)
>+ {
>+ // progress bar vertical position
>+ SystemConfiguration.nBar_PosY = atoi(pValue + 1);
>+ }
>+ else if (strcmp(strParam, "BAR_R_COL") == 0)
>+ {
>+ // progress bar colour red component
>+ SystemConfiguration.nBarRCol = atoi(pValue + 1);
>+ }
>+ else if (strcmp(strParam, "BAR_G_COL") == 0)
>+ {
>+ // progress bar colour green component
>+ SystemConfiguration.nBarGCol = atoi(pValue + 1);
>+ }
>+ else if (strcmp(strParam, "BAR_B_COL") == 0)
>+ {
>+ // progress bar colour blue component
>+ SystemConfiguration.nBarBCol = atoi(pValue + 1);
>+ }
>+ }
.. whole block.
>+
>+ fclose(pIniFile);
>+}
>+
>+
>+/**
>+ * enable/disable the cursor apparance.
>+ * \param bEnable flag for enabling/disabling
>+ * \return nothing
>+ */
static?
>+bool enableCursor(bool bEnable)
>+{
>+ int fd, ret;
>+ char * cursoff = "\E[?25l\000";
>+ char * curson = "\E[?25h\000";
>+
>+ fd = open ("/dev/tty0", O_RDWR);
>+ if (fd < 0)
>+ fd = open ("/dev/vc/0", O_RDWR);
>+
>+ if (fd < 0)
>+ {
>+ return false;
>+ }
>+ else
>+ {
>+ if (bEnable)
>+ {
>+ if ((ret = write (fd, curson, strlen (curson))) == -1)
>+ {
>+ DEBUG_MESSAGE("failed to write on console");
>+ }
>+ }
>+ else
>+ {
>+ if ((ret = write (fd, cursoff, strlen (cursoff))) == -1)
>+ {
>+ DEBUG_MESSAGE("failed to write on console");
>+ }
>+ }
>+
>+ close (fd);
>+ return true;
>+ }
>+}
>+
>+int bbsplash_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
>+int bbsplash_main(int argc, char **argv)
>+{
>+ int i, fd, len;
>+ char cmdline[1024];
That's a bit gross, isn't it?
>+ char *param;
>+ char strFifo[100];
>+ char buf[255];
>+ // process and session ID
>+ pid_t pid, sid;
>+ fd_set rfds;
>+
>+ // command line options
>+ opterr = 0; // disables writing on stderr
>+ while ((i = getopt (argc , argv , "vh")) != -1)
getopt32() if you really think you want to support those (just wastes
space).
>+ {
>+ switch (i)
>+ {
>+ case 'v': // 'information' option
>+ printf("\t%s - ver. %s\n", PROGRAM, VERSION);
>+ printf("\tcompiled: %s - %s\n", __DATE__, __TIME__);
>+ exit(EXIT_SUCCESS);
>+ case 'h': // 'help' option
>+ printf("\trun the daemon for the management of the splash screen during the boot process\n");
>+ printf("\twritten by Michele Sanges - report bugs to michele.sanges at otomelara.it\n");
>+ exit(EXIT_SUCCESS);
>+ case '?': // option not recognized
>+ printf("\t%s: option '-%c' not recognized\n", PROGRAM, optopt);
>+ printf("\tuse '%s -v' for information about the version\n", PROGRAM);
>+ printf("\tuse '%s -h' for help\n", PROGRAM);
>+ exit(EXIT_SUCCESS);
>+ }
>+ }
>+
>+ // initializes the application with the data taken from the configuration file
>+ Init();
yea, just inline it here.
>+
>+ // parse /proc/cmdline in order to start or not the daemon
>+ if ((fd = open("/proc/cmdline", O_RDONLY)) < 0)
>+ {
>+ DEBUG_MESSAGE("failed to open /proc/cmdline... exit");
>+ exit(EXIT_FAILURE);
xopen()
>+ }
>+ len = read(fd, cmdline, sizeof(cmdline) - 1);
broken indentation and xread() instead.
>+ close(fd);
>+ if (len <= 0)
>+ exit(EXIT_SUCCESS);
>+
>+ cmdline[len] = '\0';
>+ param = strstr(cmdline, "bbsplash=on");
>+ if (param == NULL)
>+ {
>+ DEBUG_MESSAGE("non enabled by /proc/cmdline... exit");
>+ exit(EXIT_SUCCESS);
>+ }
>+
>+//enableCursor(false);
>+//printf("\033[?25l");
>+
>+
>+ // fork the parent process
>+ pid = fork();
i don't think that this will work. Use spawn() el al.
>+ if (pid < 0)
>+ {
>+ DEBUG_MESSAGE("failed to fork process... exit");
>+ exit(EXIT_FAILURE);
>+ }
>+
>+ // if we got a good PID, then we can exit the parent process.
>+ if (pid > 0)
>+ {
>+ exit(EXIT_SUCCESS);
>+ }
>+
>+ // this is the child process
>+ // change the file mode mask
>+ umask(0);
>+
>+ // create a new SID for the child process
>+ sid = setsid();
>+ if (sid < 0)
>+ {
>+ DEBUG_MESSAGE("failed to create new sid... exit");
>+ exit(EXIT_FAILURE);
>+ }
>+
>+ // close out the standard file descriptors
>+// close(STDIN_FILENO);
>+// close(STDOUT_FILENO);
>+// close(STDERR_FILENO);
>+
>+ // open the fifo used for receiving commands
>+ sprintf(strFifo, "/dev/%s_fifo", PROGRAM);
>+ mkfifo(strFifo, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
>+
>+ // open the device to be non blocking (read will return immediatly)
>+ if ((fd = open(strFifo, O_RDWR | O_NOCTTY | O_NONBLOCK)) == -1)
>+ {
>+ DEBUG_MESSAGE("failed to open the fifo... exit");
>+ exit(EXIT_FAILURE);
>+ }
xopen() or xopen3() like above.
>+
>+ FD_ZERO(&rfds);
>+ FD_SET(fd,&rfds);
>+
>+ fbOpen();
>+ fbDrawImage();
>+ fbDrawProgressBar(0);
Would be better if you inlined those here. Less files and easier to read
and follow.
>+
>+ while(1)
>+ {
>+ int retval = select(fd+1, &rfds, NULL, NULL, NULL);
>+
>+ if (retval == -1)
>+ continue;
>+
>+ if (FD_ISSET(fd, &rfds))
>+ {
>+ len = read(fd, buf, 255);
>+ buf[len] = '\0';
>+
>+ // comando di uscita
>+ if(strcmp(buf, "exit\n") == 0)
>+ {
>+ DEBUG_MESSAGE("exit");
>+ break;
>+ }
>+ else
>+ {
>+ int nVal = atoi(buf);
>+ if ((nVal >= 0) && (nVal <= 100))
>+ {
>+ char strVal[10];
>+ sprintf(strVal, "%d", nVal);
>+ DEBUG_MESSAGE(strVal);
>+ fbDrawProgressBar(nVal);
>+ }
>+ }
>+ }
>+ }
>+
>+// if (SystemConfiguration.bDebugMessages)
>+// {
>+// fclose(SystemConfiguration.logFile_fd);
>+// }
>+
>+ //enableCursor(true);
>+ //printf("\033[?25h");
>+ close(fd);
>+/*
>+ // rimozione della fifo
>+ char strCmd[100];
>+ sprintf(strCmd, "rm -f /dev/%s", PROGRAM);
>+ system(strCmd);
>+*/
>+ fbClose();
>+ DEBUG_MESSAGE("bye");
>+
>+ exit(EXIT_SUCCESS);
>+}
>+
>diff -urP busybox-1.9.0_originale/miscutils/bbsplash.h busybox-1.9.0_bbsplash/miscutils/bbsplash.h
>--- busybox-1.9.0_originale/miscutils/bbsplash.h 1970-01-01 01:00:00.000000000 +0100
>+++ busybox-1.9.0_bbsplash/miscutils/bbsplash.h 2008-02-07 18:28:14.000000000 +0100
>@@ -0,0 +1,71 @@
>+/**
>+ * main module of the project 'bbsplash'
>+ * \file: bbsplash.h
>+ * \author Michele Sanges <michele.sanges at otomelara.it> <pigrecoq at libero.it>
>+ * \version 1.0.0
>+ * \date 07/02/2008
>+ */
>+
>+
>+#ifndef __BBSPLASH__
>+#define __BBSPLASH__
>+
>+#include "libbb.h"
>+
>+//@{
>+/// system include files
>+
>+/*#include <stdio.h>
>+#include <string.h>
>+#include <stdlib.h>
>+#include <unistd.h>
>+#include <sys/types.h>
>+#include <sys/stat.h>
>+#include <sys/mman.h>*/
>+#include <linux/fb.h>
>+// #include <fcntl.h>
>+// #include <sys/ioctl.h>
>+
>+//@}
>+
>+//@{
>+/// project include files
>+#include "framebuffer.h"
>+//@}
>+
>+/// function used for debug purpose
>+#define DEBUG_MESSAGE(strMessage, args...) \
>+ if (SystemConfiguration.bDebugMessages) \
>+ { \
>+ fprintf(SystemConfiguration.logFile_fd, "[%s][%s] - %s\n", __FILE__, __FUNCTION__, strMessage); \
>+ }
>+
>+#define PROGRAM "bbsplash"
>+#define VERSION "1.0.0"
>+// typedef char bool;
>+// #define true 1
>+// #define false 0
>+
>+/// data struct with the application parameters
>+typedef struct
>+{
>+ bool bDebugMessages; ///< flag for enable/disable writing messages in logfile
>+ FILE * logFile_fd; ///< descriptor of log file
>+ char strSplashTheme[40];///< name of the splash theme
>+ ushort nBar_Width; ///< progress bar width
>+ ushort nBar_Height; ///< progress bar height
>+ ushort nBar_PosX; ///< progress bar orizzontal position
>+ ushort nBar_PosY; ///< progress bar vertical position
>+ unsigned char nBarRCol; ///< progress bar colour red component
>+ unsigned char nBarGCol; ///< progress bar colour green component
>+ unsigned char nBarBCol; ///< progress bar colour blue component
>+} StructSystemConfiguration;
>+
>+
>+//############################ FUNCTION PROTOTYPES ############################
>+void Init(void);
>+bool enableCursor(bool bEnable);
>+
>+#endif
>+
>+
>diff -urP busybox-1.9.0_originale/miscutils/Config.in busybox-1.9.0_bbsplash/miscutils/Config.in
>--- busybox-1.9.0_originale/miscutils/Config.in 2007-12-21 23:00:31.000000000 +0100
>+++ busybox-1.9.0_bbsplash/miscutils/Config.in 2008-02-07 18:09:39.000000000 +0100
>@@ -19,6 +19,13 @@
> The bbconfig applet will print the config file with which
> busybox was built.
>
>+config BBSPLASH
>+ bool "bbsplash"
>+ default n
>+ help
>+ The bbsplash shows a splash image and a progress bar on framebuffer device.
>+ Can be used during the boot phase of embedded device.
mention how much it adds to the size, too.
>+
> config CHRT
> bool "chrt"
> default n
>diff -urP busybox-1.9.0_originale/miscutils/framebuffer.c busybox-1.9.0_bbsplash/miscutils/framebuffer.c
>--- busybox-1.9.0_originale/miscutils/framebuffer.c 1970-01-01 01:00:00.000000000 +0100
>+++ busybox-1.9.0_bbsplash/miscutils/framebuffer.c 2008-02-08 10:48:29.000000000 +0100
>@@ -0,0 +1,224 @@
>+#include "bbsplash.h"
>+
>+
>+extern StructSystemConfiguration SystemConfiguration; ///< hold the system configuration data
>+
>+int m_fbfd; ///< descriptor of framebuffer device
>+FILE *m_ThemeFile; ///< splash file
>+unsigned char *m_addr; ///< pointer to framebuffer memory
>+struct fb_var_screeninfo m_ScreenInfoVar;
>+struct fb_fix_screeninfo m_ScreenInfoFix;
>+
>+
>+/**
>+ * open and initialize the framebuffer device.
>+ * \return nothing
>+ */
>+void fbOpen(void)
>+{
>+ // apertura del frame buffer
>+ m_fbfd = open("/dev/fb0", O_RDWR);
xopen3()
>+ if (m_fbfd < 0)
>+ {
>+ DEBUG_MESSAGE("failed to open the frame buffer device... exit");
>+ exit(EXIT_FAILURE);
>+ }
>+
>+ m_ThemeFile = fopen(SystemConfiguration.strSplashTheme, "r");
>+ if (m_ThemeFile == NULL)
>+ {
>+ DEBUG_MESSAGE("failed to open the splash image... exit");
>+ exit(EXIT_FAILURE);
>+ }
xfopen()
>+
>+ // Richiesta proprietà del framenbuffer
>+ if (ioctl(m_fbfd, FBIOGET_VSCREENINFO, &m_ScreenInfoVar))
>+ {
>+ DEBUG_MESSAGE("Errore richiesta proprietà variabili del frame buffer.. exit");
>+ exit(EXIT_FAILURE);
>+ }
xioctl()
>+
>+ if (ioctl(m_fbfd, FBIOGET_FSCREENINFO, &m_ScreenInfoFix))
>+ {
>+ DEBUG_MESSAGE("Errore richiesta proprietà fisse del frame buffer.. exit");
>+ exit(EXIT_FAILURE);
>+ }
ditto
>+
>+ // Mappa il device in memoria
wrong language ;)
>+ m_addr = (unsigned char *)mmap(0, m_ScreenInfoVar.xres * m_ScreenInfoVar.yres * (m_ScreenInfoVar.bits_per_pixel / 8), /*PROT_READ | */PROT_WRITE, MAP_SHARED, m_fbfd, 0);
>+
>+ if (m_addr == (unsigned char *)-1)
>+ {
>+ DEBUG_MESSAGE("Errore nel mappaggio del device in memoria.. exit");
ditto.
>+ exit(EXIT_FAILURE);
>+ }
>+}
>+
>+
>+/**
>+ * unmapp and close the device.
>+ * \return nothing
>+ */
>+void fbClose(void)
>+{
>+ // Unmappa il device dalla memoria
>+ if (munmap(m_addr, m_ScreenInfoVar.xres * m_ScreenInfoVar.yres * (m_ScreenInfoVar.bits_per_pixel / 8)))
>+ {
>+ DEBUG_MESSAGE("Errore nel unmappaggio del device dalla memoria.. exit");
>+ }
>+
>+ // Chiusura del frame buffer
>+ close(m_fbfd);
>+
>+ // chiusura del file tema
>+ fclose(m_ThemeFile);
Missing english translation.
>+}
>+
>+
>+/**
>+ * draw a rectangle in the position and of color passed as a parameters
>+ * \return nothing
\r is a bit odd (everywhere).
>+ */
>+void fbDrawRectangle(short nX1Pos, short nY1Pos, short nX2Pos, short nY2Pos, unsigned char nRed24, unsigned char nGreen24, unsigned char nBlue24)
>+{
>+ int x, y, idx;
>+ unsigned char nRed16 = (nRed24) >> 3; // 5-bit red
>+ unsigned char nGreen16 = (nGreen24) >> 2; // 6-bit green
>+ unsigned char nBlue16 = (nBlue24) >> 3; // 5-bit blue
>+
>+ unsigned short nRGB2Bytes = nBlue16 + (nGreen16<<5) + (nRed16<<(5+6));
>+ DATA thispix = nRGB2Bytes;
>+
>+
>+ // Linea orizzontale superiore
translation
>+ for (x = nX1Pos; x <= nX2Pos; x++)
>+ {
>+ idx = (nY1Pos * m_ScreenInfoVar.xres + x) * (m_ScreenInfoVar.bits_per_pixel / 8);
>+ *(DATA *)(m_addr + idx) = thispix;
>+ }
>+
>+ // Linea orizzontale inferiore
>+ for (x = nX1Pos; x <= nX2Pos; x++)
>+ {
>+ idx = (nY2Pos * m_ScreenInfoVar.xres + x) * (m_ScreenInfoVar.bits_per_pixel / 8);
>+ *(DATA *)(m_addr + idx) = thispix;
>+ }
>+
>+ // Linea verticale sinistra
>+ for (y = nY1Pos; y <= nY2Pos; y++)
>+ {
>+ idx = (y * m_ScreenInfoVar.xres + nX1Pos) * (m_ScreenInfoVar.bits_per_pixel / 8);
>+ *(DATA *)(m_addr + idx) = thispix;
>+ }
>+
>+ // Linea verticale destra
>+ for (y = nY1Pos; y <= nY2Pos; y++)
>+ {
>+ idx = (y * m_ScreenInfoVar.xres + nX2Pos) * (m_ScreenInfoVar.bits_per_pixel / 8);
>+ *(DATA *)(m_addr + idx) = thispix;
>+ }
>+}
>+
>+
>+/**
>+ * draw a full rectangle in the position and of color passed as a parameters
>+ * \return nothing
>+ */
>+void fbDrawFullRectangle(short nX1Pos, short nY1Pos, short nX2Pos, short nY2Pos, unsigned char nRed24, unsigned char nGreen24, unsigned char nBlue24)
>+{
>+ int x, y, idx;
>+ unsigned char nRed16 = (nRed24) >> 3; // 5-bit red
>+ unsigned char nGreen16 = (nGreen24) >> 2; // 6-bit green
>+ unsigned char nBlue16 = (nBlue24) >> 3; // 5-bit blue
>+
>+ unsigned short nRGB2Bytes = nBlue16 + (nGreen16<<5) + (nRed16<<(5+6));
>+ DATA thispix = nRGB2Bytes;
>+
>+ // linea orizzontale superiore
>+ for (y = nY1Pos; y <= nY2Pos; y++)
>+ {
>+ for (x = nX1Pos; x <= nX2Pos; x++)
>+ {
>+ idx = (y * m_ScreenInfoVar.xres + x) * (m_ScreenInfoVar.bits_per_pixel / 8);
>+ *(DATA *)(m_addr + idx) = thispix;
>+ }
>+ }
>+}
>+
>+
>+/**
>+ * draw a progress bar
>+ * \param nPercent percentage of loading
>+ * \return nothing
>+ */
>+void fbDrawProgressBar(unsigned char nPercent)
>+{
>+ int i;
>+
>+ fbDrawRectangle(SystemConfiguration.nBar_PosX, SystemConfiguration.nBar_PosY, SystemConfiguration.nBar_PosX + SystemConfiguration.nBar_Width, SystemConfiguration.nBar_PosY + SystemConfiguration.nBar_Height, SystemConfiguration.nBarRCol/2, SystemConfiguration.nBarGCol/2, SystemConfiguration.nBarBCol/2);
heh. Please fit them into at most 80 chars per line.
[snip]
More information about the busybox
mailing list