diff options
author | Daniel Borca <dborca@users.sourceforge.net> | 2004-11-12 14:58:26 +0000 |
---|---|---|
committer | Daniel Borca <dborca@users.sourceforge.net> | 2004-11-12 14:58:26 +0000 |
commit | 0676fc357a12879531e6509354ecc7447c99d148 (patch) | |
tree | d4885d993c066614546beab3aad6168b92d97119 /src/mesa/drivers/dos/null.c | |
parent | 885f10706a096037eea815803dbf4b4d28c3bd27 (diff) |
added a few sanity checks
made coding style a bit more consistent
Diffstat (limited to 'src/mesa/drivers/dos/null.c')
-rw-r--r-- | src/mesa/drivers/dos/null.c | 170 |
1 files changed, 86 insertions, 84 deletions
diff --git a/src/mesa/drivers/dos/null.c b/src/mesa/drivers/dos/null.c index 62e2c942ef..369255a422 100644 --- a/src/mesa/drivers/dos/null.c +++ b/src/mesa/drivers/dos/null.c @@ -23,7 +23,7 @@ */ /* - * DOS/DJGPP device driver v1.6 for Mesa + * DOS/DJGPP device driver v1.7 for Mesa * * Copyright (C) 2002 - Borca Daniel * Email : dborca@users.sourceforge.net @@ -38,58 +38,57 @@ #include "null.h" - static vl_mode *modes; #define null_color_precision 8 - - -static void null_blit_nop (void) +static void +null_blit_nop (void) { } - -/* Desc: Attempts to detect VGA, check video modes and create selectors. +/* Desc: Attempts to detect NUL, check video modes and create selectors. * * In : - * Out : mode array * * Note: - */ -static vl_mode *null_init (void) +static vl_mode * +null_init (void) { - static int m[][2] = { - {320, 200}, - {320, 240}, - {400, 300}, - {512, 384}, - {640, 400}, - {640, 480}, - {800, 600}, - {1024, 768}, - {1280, 1024}, - {1600, 1200} - }; - static int b[] = { - 8, - 15, - 16, - 24, - 32 - }; - - unsigned int i, j, k; - - if (modes == NULL) { - modes = malloc(sizeof(vl_mode) * - (1 + (sizeof(m) / sizeof(m[0]) * sizeof(b) / sizeof(b[0])))); - - if (modes != NULL) { - for (k = 0, i = 0; i < sizeof(m) / sizeof(m[0]); i++) { - for (j = 0; j < sizeof(b) / sizeof(b[0]); j++, k++) { + static int m[][2] = { + { 320, 200 }, + { 320, 240 }, + { 400, 300 }, + { 512, 384 }, + { 640, 400 }, + { 640, 480 }, + { 800, 600 }, + { 1024, 768 }, + { 1280, 1024 }, + { 1600, 1200 } + }; + static int b[] = { + 8, + 15, + 16, + 24, + 32 + }; + const unsigned int m_count = sizeof(m) / sizeof(m[0]); + const unsigned int b_count = sizeof(b) / sizeof(b[0]); + + unsigned int i, j, k; + + if (modes == NULL) { + modes = malloc(sizeof(vl_mode) * (1 + m_count * b_count)); + + if (modes != NULL) { + for (k = 0, i = 0; i < m_count; i++) { + for (j = 0; j < b_count; j++, k++) { modes[k].xres = m[i][0]; modes[k].yres = m[i][1]; modes[k].bpp = b[j]; @@ -97,36 +96,39 @@ static vl_mode *null_init (void) modes[k].scanlen = m[i][0] * ((b[j] + 7) / 8); modes[k].sel = -1; modes[k].gran = -1; - } - } - modes[k].xres = -1; - modes[k].yres = -1; - modes[k].bpp = -1; - modes[k].mode = 0xffff; - modes[k].scanlen = -1; - modes[k].sel = -1; - modes[k].gran = -1; - } - } - - return modes; + } + } + modes[k].xres = -1; + modes[k].yres = -1; + modes[k].bpp = -1; + modes[k].mode = 0xffff; + modes[k].scanlen = -1; + modes[k].sel = -1; + modes[k].gran = -1; + } + } + + return modes; } - -/* Desc: Frees all resources allocated by VGA init code. +/* Desc: Frees all resources allocated by NUL init code. * * In : - * Out : - * * Note: - */ -static void null_fini (void) +static void +null_fini (void) { + if (modes != NULL) { + free(modes); + modes = NULL; + } } - /* Desc: Attempts to enter specified video mode. * * In : ptr to mode structure, refresh rate @@ -134,17 +136,17 @@ static void null_fini (void) * * Note: - */ -static int null_entermode (vl_mode *p, int refresh) +static int +null_entermode (vl_mode *p, int refresh) { - NUL.blit = null_blit_nop; + NUL.blit = null_blit_nop; - return 0; + return 0; - (void)(p && refresh); /* silence compiler warning */ + (void)(p && refresh); /* silence compiler warning */ } - /* Desc: Restores to the mode prior to first call to null_entermode. * * In : - @@ -152,12 +154,12 @@ static int null_entermode (vl_mode *p, int refresh) * * Note: - */ -static void null_restore (void) +static void +null_restore (void) { } - /* Desc: set one palette entry * * In : color index, R, G, B @@ -165,13 +167,13 @@ static void null_restore (void) * * Note: uses integer values */ -static void null_setCI_i (int index, int red, int green, int blue) +static void +null_setCI_i (int index, int red, int green, int blue) { - (void)(index && red && green && blue); /* silence compiler warning */ + (void)(index && red && green && blue); /* silence compiler warning */ } - /* Desc: set one palette entry * * In : color index, R, G, B @@ -179,15 +181,15 @@ static void null_setCI_i (int index, int red, int green, int blue) * * Note: uses normalized values */ -static void null_setCI_f (int index, float red, float green, float blue) +static void +null_setCI_f (int index, float red, float green, float blue) { - float max = (1 << null_color_precision) - 1; + float max = (1 << null_color_precision) - 1; - null_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max)); + null_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max)); } - /* Desc: state retrieval * * In : parameter name, ptr to storage @@ -195,28 +197,28 @@ static void null_setCI_f (int index, float red, float green, float blue) * * Note: - */ -static int null_get (int pname, int *params) +static int +null_get (int pname, int *params) { - switch (pname) { - default: - params[0] = params[0]; /* silence compiler warning */ - return -1; - } - return 0; + switch (pname) { + default: + params[0] = params[0]; /* silence compiler warning */ + return -1; + } + return 0; } - /* * the driver */ vl_driver NUL = { - null_init, - null_entermode, - NULL, - null_setCI_f, - null_setCI_i, - null_get, - null_restore, - null_fini + null_init, + null_entermode, + NULL, + null_setCI_f, + null_setCI_i, + null_get, + null_restore, + null_fini }; |