diff --git a/libs/video/renderer/crosshair.c b/libs/video/renderer/crosshair.c index 555a7d567..7870c7aad 100644 --- a/libs/video/renderer/crosshair.c +++ b/libs/video/renderer/crosshair.c @@ -65,6 +65,15 @@ byte crosshair_data[CROSSHAIR_WIDTH * CROSSHAIR_HEIGHT * CROSSHAIR_COUNT] = { 255,255,255, 7, 8, 2,255,255, 255,255,255,255, 2, 2,255,255, 255,255,255,255,255,255,255,255, + + 0xff,0xff,0xfe,0xfe,0xfe,0xff,0xff,0xff, + 0xff,0xfe,0xff,0xff,0xff,0xfe,0xff,0xff, + 0xfe,0xff,0xff,0xff,0xff,0xff,0xfe,0xff, + 0xfe,0xff,0xff,0xfe,0xff,0xff,0xfe,0xff, + 0xfe,0xff,0xff,0xff,0xff,0xff,0xfe,0xff, + 0xff,0xfe,0xff,0xff,0xff,0xfe,0xff,0xff, + 0xff,0xff,0xfe,0xfe,0xfe,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, }; qpic_t * diff --git a/libs/video/renderer/glsl/glsl_draw.c b/libs/video/renderer/glsl/glsl_draw.c index 675e3007a..8561d7bff 100644 --- a/libs/video/renderer/glsl/glsl_draw.c +++ b/libs/video/renderer/glsl/glsl_draw.c @@ -519,67 +519,35 @@ glsl_Draw_AltString (int x, int y, const char *str) } static void -crosshair_1 (int x, int y) +draw_crosshair_plus (int ch, int x, int y) { glsl_Draw_Character (x - 4, y - 4, '+'); } -//FIXME these should use an index to select the region. static void -crosshair_2 (int x, int y) +draw_crosshair_pic (int ch, int x, int y) { - draw_pic (x, y, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_pic, - 0, 0, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_color); + static const int pos[CROSSHAIR_COUNT][4] = { + {0, 0, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT}, + {CROSSHAIR_WIDTH, 0, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT}, + {0, CROSSHAIR_HEIGHT, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT}, + {CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT}, + }; + const int *p = pos[ch - 1]; + + draw_pic (x - CROSSHAIR_WIDTH / 2, y - CROSSHAIR_HEIGHT / 2, + CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_pic, + p[0], p[1], p[2], p[3], crosshair_color); } -static void -crosshair_3 (int x, int y) -{ - draw_pic (x, y, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_pic, - CROSSHAIR_WIDTH, 0, - CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_color); -} - -static void -crosshair_4 (int x, int y) -{ - draw_pic (x, y, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_pic, - 0, CROSSHAIR_HEIGHT, - CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_color); -} - -static void -crosshair_5 (int x, int y) -{ - draw_pic (x, y, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_pic, - CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, - CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_color); -} - -static void (*crosshair_func[]) (int x, int y) = { - crosshair_1, - crosshair_2, - crosshair_3, - crosshair_4, - crosshair_5, +static void (*crosshair_func[]) (int ch, int x, int y) = { + draw_crosshair_plus, + draw_crosshair_pic, + draw_crosshair_pic, + draw_crosshair_pic, + draw_crosshair_pic, }; -void -glsl_Draw_Crosshair (void) -{ - int x, y; - size_t ch; - - ch = crosshair->int_val - 1; - if (ch >= sizeof (crosshair_func) / sizeof (crosshair_func[0])) - return; - - x = vid.conwidth / 2 + cl_crossx->int_val; - y = vid.conheight / 2 + cl_crossy->int_val; - - crosshair_func[ch] (x, y); -} - void glsl_Draw_CrosshairAt (int ch, int x, int y) { @@ -588,7 +556,18 @@ glsl_Draw_CrosshairAt (int ch, int x, int y) if (c >= sizeof (crosshair_func) / sizeof (crosshair_func[0])) return; - crosshair_func[c] (x, y); + crosshair_func[c] (c, x, y); +} + +void +glsl_Draw_Crosshair (void) +{ + int x, y; + + x = vid.conwidth / 2 + cl_crossx->int_val; + y = vid.conheight / 2 + cl_crossy->int_val; + + glsl_Draw_CrosshairAt (crosshair->int_val, x, y); } void diff --git a/libs/video/renderer/sw/draw.c b/libs/video/renderer/sw/draw.c index d0b8ea7f0..58e261f27 100644 --- a/libs/video/renderer/sw/draw.c +++ b/libs/video/renderer/sw/draw.c @@ -379,10 +379,76 @@ crosshair_3 (int x, int y) Draw_Pixel (x + 3, y + 3, c); } +static void +crosshair_4 (int x, int y) +{ + //byte c = crosshaircolor->int_val; + + Draw_Pixel (x, y - 2, 8); + Draw_Pixel (x + 1, y - 2, 9); + + Draw_Pixel (x, y - 1, 6); + Draw_Pixel (x + 1, y - 1, 8); + Draw_Pixel (x + 2, y - 1, 2); + + Draw_Pixel (x - 2, y, 6); + Draw_Pixel (x - 1, y, 8); + Draw_Pixel (x, y, 8); + Draw_Pixel (x + 1, y, 6); + Draw_Pixel (x + 2, y, 8); + Draw_Pixel (x + 3, y, 8); + + Draw_Pixel (x - 1, y + 1, 2); + Draw_Pixel (x, y + 1, 8); + Draw_Pixel (x + 1, y + 1, 8); + Draw_Pixel (x + 2, y + 1, 2); + Draw_Pixel (x + 3, y + 1, 2); + Draw_Pixel (x + 4, y + 1, 2); + + Draw_Pixel (x, y + 2, 7); + Draw_Pixel (x + 1, y + 2, 8); + Draw_Pixel (x + 2, y + 2, 2); + + Draw_Pixel (x + 1, y + 3, 2); + Draw_Pixel (x + 2, y + 3, 2); +} + +static void +crosshair_5 (int x, int y) +{ + byte c = crosshaircolor->int_val; + + Draw_Pixel (x - 1, y - 3, c); + Draw_Pixel (x + 0, y - 3, c); + Draw_Pixel (x + 1, y - 3, c); + + Draw_Pixel (x - 2, y - 2, c); + Draw_Pixel (x + 2, y - 2, c); + + Draw_Pixel (x - 3, y - 1, c); + Draw_Pixel (x + 3, y - 1, c); + + Draw_Pixel (x - 3, y, c); + Draw_Pixel (x, y, c); + Draw_Pixel (x + 3, y, c); + + Draw_Pixel (x - 3, y + 1, c); + Draw_Pixel (x + 3, y + 1, c); + + Draw_Pixel (x - 2, y + 2, c); + Draw_Pixel (x + 2, y + 2, c); + + Draw_Pixel (x - 1, y + 3, c); + Draw_Pixel (x + 0, y + 3, c); + Draw_Pixel (x + 1, y + 3, c); +} + static void (*crosshair_func[]) (int x, int y) = { crosshair_1, crosshair_2, crosshair_3, + crosshair_4, + crosshair_5, }; void diff --git a/libs/video/renderer/sw32/draw.c b/libs/video/renderer/sw32/draw.c index 74c40fc17..fe8496d7b 100644 --- a/libs/video/renderer/sw32/draw.c +++ b/libs/video/renderer/sw32/draw.c @@ -456,10 +456,76 @@ crosshair_3 (int x, int y) Draw_Pixel (x + 3, y + 3, c); } +static void +crosshair_4 (int x, int y) +{ + //byte c = crosshaircolor->int_val; + + Draw_Pixel (x, y - 2, 8); + Draw_Pixel (x + 1, y - 2, 9); + + Draw_Pixel (x, y - 1, 6); + Draw_Pixel (x + 1, y - 1, 8); + Draw_Pixel (x + 2, y - 1, 2); + + Draw_Pixel (x - 2, y, 6); + Draw_Pixel (x - 1, y, 8); + Draw_Pixel (x, y, 8); + Draw_Pixel (x + 1, y, 6); + Draw_Pixel (x + 2, y, 8); + Draw_Pixel (x + 3, y, 8); + + Draw_Pixel (x - 1, y + 1, 2); + Draw_Pixel (x, y + 1, 8); + Draw_Pixel (x + 1, y + 1, 8); + Draw_Pixel (x + 2, y + 1, 2); + Draw_Pixel (x + 3, y + 1, 2); + Draw_Pixel (x + 4, y + 1, 2); + + Draw_Pixel (x, y + 2, 7); + Draw_Pixel (x + 1, y + 2, 8); + Draw_Pixel (x + 2, y + 2, 2); + + Draw_Pixel (x + 1, y + 3, 2); + Draw_Pixel (x + 2, y + 3, 2); +} + +static void +crosshair_5 (int x, int y) +{ + byte c = crosshaircolor->int_val; + + Draw_Pixel (x - 1, y - 3, c); + Draw_Pixel (x + 0, y - 3, c); + Draw_Pixel (x + 1, y - 3, c); + + Draw_Pixel (x - 2, y - 2, c); + Draw_Pixel (x + 2, y - 2, c); + + Draw_Pixel (x - 3, y - 1, c); + Draw_Pixel (x + 3, y - 1, c); + + Draw_Pixel (x - 3, y, c); + Draw_Pixel (x, y, c); + Draw_Pixel (x + 3, y, c); + + Draw_Pixel (x - 3, y + 1, c); + Draw_Pixel (x + 3, y + 1, c); + + Draw_Pixel (x - 2, y + 2, c); + Draw_Pixel (x + 2, y + 2, c); + + Draw_Pixel (x - 1, y + 3, c); + Draw_Pixel (x + 0, y + 3, c); + Draw_Pixel (x + 1, y + 3, c); +} + static void (*crosshair_func[]) (int x, int y) = { crosshair_1, crosshair_2, crosshair_3, + crosshair_4, + crosshair_5, }; void diff --git a/ruamoko/cl_menu/CrosshairCvar.r b/ruamoko/cl_menu/CrosshairCvar.r index c0a919dff..89e71eedd 100644 --- a/ruamoko/cl_menu/CrosshairCvar.r +++ b/ruamoko/cl_menu/CrosshairCvar.r @@ -6,7 +6,7 @@ -(void) next { local int val = Cvar_GetInteger (name); - Cvar_SetInteger (name, (val + 1) % 4); + Cvar_SetInteger (name, (val + 1) % 6); } -(int) crosshair