X-Git-Url: http://git.subgeniuskitty.com/screensavers/.git/blobdiff_plain/37f7b288175b9d8f5ff627d6d997d8df8bb939b8..7361f6dbacf571e0f26a0eb4e9072c9c27f7cdd2:/hacks/NEDsim/NEDsim.c diff --git a/hacks/NEDsim/NEDsim.c b/hacks/NEDsim/NEDsim.c index 8331334..01733f1 100644 --- a/hacks/NEDsim/NEDsim.c +++ b/hacks/NEDsim/NEDsim.c @@ -186,6 +186,9 @@ static struct color_scheme color_list[] = { /* Helper Functions */ /* -------------------------------------------------------------------------- */ +// Fill in boilerplate when selecting colors. +#define COLOR(X) &color_list[nedsim->color_index].X + // Set foreground color for the current graphics context. static void set_color(struct NEDsim * nedsim, struct color_rgb * color) @@ -289,7 +292,7 @@ draw_rect_area(struct NEDsim * nedsim, size_t x_origin, size_t y_origin, size_t XFillRectangle(nedsim->dpy, nedsim->panel, nedsim->gc, x_origin, y_origin, x_size, y_size); // ...then give it a border, if requested. - set_color(nedsim, &color_list[nedsim->color_index].border); + set_color(nedsim, COLOR(border)); if (bord_top) { XFillRectangle(nedsim->dpy, nedsim->panel, nedsim->gc, x_origin, y_origin, x_size, nedsim->border_size); @@ -338,17 +341,36 @@ draw_circular_area(struct NEDsim * nedsim, size_t x, size_t y, double diameter) XFillArc(nedsim->dpy, nedsim->panel, nedsim->gc, x, y, diameter, diameter, 0, 360*64); } +// Draws text in a square area with upper left corner at (x_origin,y_origin). +// Requires that set_font_size() has been run at least once. All values are in +// units of 'cells'. +static void +draw_text(struct NEDsim * nedsim, const char * text, int x_origin, int y_origin, int x_size, int y_size, Bool horizontally_center) +{ + set_color(nedsim, COLOR(text)); + + int text_x_size, text_y_size; + get_text_size(nedsim, text, &text_x_size, &text_y_size); + + int local_y_offset = ((y_size * nedsim->cell_size) - text_y_size) / 2; + int local_x_offset = 0; + if (horizontally_center) local_x_offset = ((x_size * nedsim->cell_size) - text_x_size) / 2; + + XDrawString(nedsim->dpy, nedsim->panel, nedsim->gc, (x_origin * nedsim->cell_size + nedsim->origin_x_offset + local_x_offset), + ((y_origin + y_size) * nedsim->cell_size + nedsim->origin_y_offset - local_y_offset), text, strlen(text)); +} + // Draws the panel itself. Not the lights/labels/etc, but the flat sheet of // metal that is the front panel. static void draw_panel(struct NEDsim * nedsim) { // Draw background color over entire window. - set_color(nedsim, &color_list[nedsim->color_index].panel_bg); + set_color(nedsim, COLOR(panel_bg)); XFillRectangle(nedsim->dpy, nedsim->panel, nedsim->gc, 0, 0, nedsim->dpy_width, nedsim->dpy_height); // Draw NED panel in foreground color. - set_color(nedsim, &color_list[nedsim->color_index].panel_fg); + set_color(nedsim, COLOR(panel_fg)); XFillRectangle(nedsim->dpy, nedsim->panel, nedsim->gc, nedsim->origin_x_offset, nedsim->origin_y_offset, @@ -357,7 +379,7 @@ draw_panel(struct NEDsim * nedsim) ); // Give the panel rounded corners by first deleting the four right-angle corners... - set_color(nedsim, &color_list[nedsim->color_index].panel_bg); + set_color(nedsim, COLOR(panel_bg)); XFillRectangle(nedsim->dpy, nedsim->panel, nedsim->gc, nedsim->origin_x_offset, nedsim->origin_y_offset, @@ -383,7 +405,7 @@ draw_panel(struct NEDsim * nedsim) nedsim->cell_size ); // ...and then replacing them with filled arcs, forming rounded corners. - set_color(nedsim, &color_list[nedsim->color_index].panel_fg); + set_color(nedsim, COLOR(panel_fg)); XFillArc(nedsim->dpy, nedsim->panel, nedsim->gc, nedsim->origin_x_offset, nedsim->origin_y_offset, @@ -415,28 +437,18 @@ static void draw_logo(struct NEDsim * nedsim) { // First draw the two colored boxes that comprise the logo area. - set_color(nedsim, &color_list[nedsim->color_index].primary); + set_color(nedsim, COLOR(primary)); draw_rect_area(nedsim, LOGO_X_OFFSET, LOGO_Y_OFFSET, LOGO_WIDTH, LOGO_NAME_HEIGHT, True, True, False, False); - set_color(nedsim, &color_list[nedsim->color_index].tertiary); + set_color(nedsim, COLOR(tertiary)); draw_rect_area(nedsim, LOGO_X_OFFSET, LOGO_Y_OFFSET+LOGO_NAME_HEIGHT, LOGO_WIDTH, LOGO_WEBSITE_HEIGHT, False, True, False, False); // Now draw the 'NED' text in the top box. - set_color(nedsim, &color_list[nedsim->color_index].text); set_font_size(nedsim, LOGO_NAME_HEIGHT); - int text_x_size, text_y_size; - get_text_size(nedsim, "NED", &text_x_size, &text_y_size); - int local_x_offset = ((LOGO_WIDTH * nedsim->cell_size) - text_x_size) / 2; - int local_y_offset = ((LOGO_NAME_HEIGHT * nedsim->cell_size) - text_y_size) / 2; - XDrawString(nedsim->dpy, nedsim->panel, nedsim->gc, (LOGO_X_OFFSET * nedsim->cell_size + nedsim->origin_x_offset + local_x_offset), - ((LOGO_Y_OFFSET+LOGO_NAME_HEIGHT) * nedsim->cell_size + nedsim->origin_y_offset - local_y_offset), "NED", 3); + draw_text(nedsim, "NED", LOGO_X_OFFSET, LOGO_Y_OFFSET, LOGO_WIDTH, LOGO_NAME_HEIGHT, True); // And draw the 'subgeniuskitty.com' text in the bottom box. set_font_size(nedsim, LOGO_WEBSITE_HEIGHT); - get_text_size(nedsim, "subgeniuskitty.com", &text_x_size, &text_y_size); - local_x_offset = ((LOGO_WIDTH * nedsim->cell_size) - text_x_size) / 2; - local_y_offset = ((LOGO_WEBSITE_HEIGHT * nedsim->cell_size) - text_y_size) / 2; - XDrawString(nedsim->dpy, nedsim->panel, nedsim->gc, (LOGO_X_OFFSET * nedsim->cell_size + nedsim->origin_x_offset + local_x_offset), - ((LOGO_Y_OFFSET+LOGO_NAME_HEIGHT+LOGO_WEBSITE_HEIGHT) * nedsim->cell_size + nedsim->origin_y_offset - local_y_offset), "subgeniuskitty.com", 18); + draw_text(nedsim, "subgeniuskitty.com", LOGO_X_OFFSET, LOGO_Y_OFFSET+LOGO_NAME_HEIGHT, LOGO_WIDTH, LOGO_WEBSITE_HEIGHT, True); } // Draw the HALT indicator area on the front panel. @@ -444,19 +456,13 @@ static void draw_halt(struct NEDsim * nedsim) { // First draw the two colored boxes that comprise the halt area. - set_color(nedsim, &color_list[nedsim->color_index].tertiary); + set_color(nedsim, COLOR(tertiary)); draw_rect_area(nedsim, HALT_X_OFFSET, HALT_Y_OFFSET, HALT_WIDTH, HALT_LIGHT_HEIGHT, True, True, False, False); - set_color(nedsim, &color_list[nedsim->color_index].secondary); + set_color(nedsim, COLOR(secondary)); draw_rect_area(nedsim, HALT_X_OFFSET, HALT_Y_OFFSET+HALT_LIGHT_HEIGHT, HALT_WIDTH, HALT_LABEL_HEIGHT, False, True, False, False); // And finally, draw the label. - set_color(nedsim, &color_list[nedsim->color_index].text); - int text_x_size, text_y_size; - get_text_size(nedsim, "HALT", &text_x_size, &text_y_size); - int local_x_offset = ((HALT_WIDTH * nedsim->cell_size) - text_x_size) / 2; - int local_y_offset = ((HALT_LABEL_HEIGHT * nedsim->cell_size) - text_y_size) / 2; - XDrawString(nedsim->dpy, nedsim->panel, nedsim->gc, (HALT_X_OFFSET * nedsim->cell_size + nedsim->origin_x_offset + local_x_offset), - ((HALT_Y_OFFSET+HALT_LIGHT_HEIGHT+HALT_LABEL_HEIGHT) * nedsim->cell_size + nedsim->origin_y_offset - local_y_offset), "HALT", 4); + draw_text(nedsim, "HALT", HALT_X_OFFSET, HALT_Y_OFFSET+HALT_LIGHT_HEIGHT, HALT_WIDTH, HALT_LABEL_HEIGHT, True); } // Draw the 32 lights corresponding to 'word' at coordinates ('x','y'). @@ -467,9 +473,9 @@ draw_wordline_lights(struct NEDsim * nedsim, uint32_t word, int x, int y) { for (int i = 0; i < WORDLINE_WIDTH; i++) { if (word & (1<<(WORDLINE_WIDTH-1-i))) { - set_color(nedsim, &color_list[nedsim->color_index].light_on); + set_color(nedsim, COLOR(light_on)); } else { - set_color(nedsim, &color_list[nedsim->color_index].light_off); + set_color(nedsim, COLOR(light_off)); } draw_circular_area(nedsim, x+i, y, WORDLINE_HEIGHT); } @@ -483,13 +489,13 @@ static void draw_wordline(struct NEDsim * nedsim, int x, int y) { // First, draw a solid box in the primary color over the entire wordline area. - set_color(nedsim, &color_list[nedsim->color_index].primary); + set_color(nedsim, COLOR(primary)); draw_rect_area(nedsim, x, y, WORDLINE_WIDTH, WORDLINE_HEIGHT, False, True, False, False); // Now, draw stripes in the secondary color. int i; for (i = 0; i < (WORDLINE_WIDTH/(2*WORDLINE_BITS_PER_STRIPE)); i++) { - set_color(nedsim, &color_list[nedsim->color_index].secondary); + set_color(nedsim, COLOR(secondary)); draw_rect_area(nedsim, (x+(i*(WORDLINE_WIDTH/WORDLINE_BITS_PER_STRIPE))), y, WORDLINE_BITS_PER_STRIPE, WORDLINE_HEIGHT, False, True, False, False); } @@ -503,18 +509,12 @@ static void draw_pc(struct NEDsim * nedsim) { // First draw the two colored boxes that comprise the PC area. - set_color(nedsim, &color_list[nedsim->color_index].tertiary); + set_color(nedsim, COLOR(tertiary)); draw_rect_area(nedsim, PC_X_OFFSET, PC_Y_OFFSET, PC_WIDTH, PC_LABEL_HEIGHT, True, True, False, False); draw_wordline(nedsim, PC_X_OFFSET, PC_Y_OFFSET+PC_LABEL_HEIGHT); // Now draw the label text "PC". - set_color(nedsim, &color_list[nedsim->color_index].text); - int text_x_size, text_y_size; - get_text_size(nedsim, "PC", &text_x_size, &text_y_size); - int local_x_offset = ((PC_WIDTH * nedsim->cell_size) - text_x_size) / 2; - int local_y_offset = ((PC_LABEL_HEIGHT * nedsim->cell_size) - text_y_size) / 2; - XDrawString(nedsim->dpy, nedsim->panel, nedsim->gc, (PC_X_OFFSET * nedsim->cell_size + nedsim->origin_x_offset + local_x_offset), - ((PC_Y_OFFSET+PC_LABEL_HEIGHT) * nedsim->cell_size + nedsim->origin_y_offset - local_y_offset), "PC", 2); + draw_text(nedsim, "PC", PC_X_OFFSET, PC_Y_OFFSET, PC_WIDTH, PC_LABEL_HEIGHT, True); } // Draw the Stack Counter area (but don't populate it yet). @@ -522,19 +522,13 @@ static void draw_sc(struct NEDsim * nedsim) { // First draw the two colored boxes that comprise the SC area. - set_color(nedsim, &color_list[nedsim->color_index].secondary); + set_color(nedsim, COLOR(secondary)); draw_rect_area(nedsim, SC_X_OFFSET, SC_Y_OFFSET, SC_WIDTH, SC_LABEL_HEIGHT, True, True, False, False); - set_color(nedsim, &color_list[nedsim->color_index].tertiary); + set_color(nedsim, COLOR(tertiary)); draw_rect_area(nedsim, SC_X_OFFSET, SC_Y_OFFSET+SC_LABEL_HEIGHT, SC_WIDTH, SC_LIGHT_HEIGHT, False, True, False, False); // Now draw the label text "SC". - set_color(nedsim, &color_list[nedsim->color_index].text); - int text_x_size, text_y_size; - get_text_size(nedsim, "SC", &text_x_size, &text_y_size); - int local_x_offset = ((SC_WIDTH * nedsim->cell_size) - text_x_size) / 2; - int local_y_offset = ((SC_LABEL_HEIGHT * nedsim->cell_size) - text_y_size) / 2; - XDrawString(nedsim->dpy, nedsim->panel, nedsim->gc, (SC_X_OFFSET * nedsim->cell_size + nedsim->origin_x_offset + local_x_offset), - ((SC_Y_OFFSET+SC_LABEL_HEIGHT) * nedsim->cell_size + nedsim->origin_y_offset - local_y_offset), "SC", 2); + draw_text(nedsim, "SC", SC_X_OFFSET, SC_Y_OFFSET, SC_WIDTH, SC_LABEL_HEIGHT, True); } // Draw areas for the two PSW flags, 'Z'ero and 'N'egative. @@ -542,31 +536,18 @@ static void draw_psw(struct NEDsim * nedsim) { // First draw the four colored boxes that comprise the two PSW areas. - set_color(nedsim, &color_list[nedsim->color_index].secondary); + set_color(nedsim, COLOR(secondary)); draw_rect_area(nedsim, PSW_N_X_OFFSET, PSW_Y_OFFSET, PSW_LABEL_WIDTH, PSW_LABEL_HEIGHT, True, True, False, False); - set_color(nedsim, &color_list[nedsim->color_index].secondary); + set_color(nedsim, COLOR(secondary)); draw_rect_area(nedsim, PSW_Z_X_OFFSET, PSW_Y_OFFSET, PSW_LABEL_WIDTH, PSW_LABEL_HEIGHT, True, True, False, False); - set_color(nedsim, &color_list[nedsim->color_index].tertiary); + set_color(nedsim, COLOR(tertiary)); draw_rect_area(nedsim, (PSW_N_X_OFFSET + 1), PSW_Y_OFFSET+PSW_LABEL_HEIGHT, PSW_LIGHT_WIDTH, PSW_LIGHT_HEIGHT, False, True, False, False); - set_color(nedsim, &color_list[nedsim->color_index].tertiary); + set_color(nedsim, COLOR(tertiary)); draw_rect_area(nedsim, (PSW_Z_X_OFFSET + 1), PSW_Y_OFFSET+PSW_LABEL_HEIGHT, PSW_LIGHT_WIDTH, PSW_LIGHT_HEIGHT, False, True, False, False); - // Now draw the label text "N". - set_color(nedsim, &color_list[nedsim->color_index].text); - int text_x_size, text_y_size; - get_text_size(nedsim, "N", &text_x_size, &text_y_size); - int local_x_offset = ((PSW_LABEL_WIDTH * nedsim->cell_size) - text_x_size) / 2; - int local_y_offset = ((PSW_LABEL_HEIGHT * nedsim->cell_size) - text_y_size) / 2; - XDrawString(nedsim->dpy, nedsim->panel, nedsim->gc, (PSW_N_X_OFFSET * nedsim->cell_size + nedsim->origin_x_offset + local_x_offset), - ((PSW_Y_OFFSET+PSW_LABEL_HEIGHT) * nedsim->cell_size + nedsim->origin_y_offset - local_y_offset), "N", 1); - - // Now draw the label text "Z". - set_color(nedsim, &color_list[nedsim->color_index].text); - get_text_size(nedsim, "Z", &text_x_size, &text_y_size); - local_x_offset = ((PSW_LABEL_WIDTH * nedsim->cell_size) - text_x_size) / 2; - local_y_offset = ((PSW_LABEL_HEIGHT * nedsim->cell_size) - text_y_size) / 2; - XDrawString(nedsim->dpy, nedsim->panel, nedsim->gc, (PSW_Z_X_OFFSET * nedsim->cell_size + nedsim->origin_x_offset + local_x_offset), - ((PSW_Y_OFFSET+PSW_LABEL_HEIGHT) * nedsim->cell_size + nedsim->origin_y_offset - local_y_offset), "Z", 1); + // Now draw the label text. + draw_text(nedsim, "N", PSW_N_X_OFFSET, PSW_Y_OFFSET, PSW_LABEL_WIDTH, PSW_LABEL_HEIGHT, True); + draw_text(nedsim, "Z", PSW_Z_X_OFFSET, PSW_Y_OFFSET, PSW_LABEL_WIDTH, PSW_LABEL_HEIGHT, True); } // Draw the stack area (but don't populate it yet). @@ -574,19 +555,14 @@ static void draw_stack(struct NEDsim * nedsim) { // First draw the two colored boxes that comprise the stack area. - set_color(nedsim, &color_list[nedsim->color_index].tertiary); + set_color(nedsim, COLOR(tertiary)); draw_rect_area(nedsim, STACK_X_OFFSET, STACK_Y_OFFSET, STACK_WIDTH, STACK_LABEL_HEIGHT, True, True, False, False); for (int i = 0; i < nedsim->num_data_rows; i++) { draw_wordline(nedsim, STACK_X_OFFSET, STACK_Y_OFFSET+STACK_LABEL_HEIGHT+i); } // Now draw the label text "Stack Size:". - set_color(nedsim, &color_list[nedsim->color_index].text); - int text_x_size, text_y_size; - get_text_size(nedsim, "Stack Size:", &text_x_size, &text_y_size); - int local_y_offset = ((STACK_LABEL_HEIGHT * nedsim->cell_size) - text_y_size) / 2; - XDrawString(nedsim->dpy, nedsim->panel, nedsim->gc, ((STACK_X_OFFSET + 1) * nedsim->cell_size + nedsim->origin_x_offset), - ((STACK_Y_OFFSET+STACK_LABEL_HEIGHT) * nedsim->cell_size + nedsim->origin_y_offset - local_y_offset), "Stack Size:", 11); + draw_text(nedsim, "Stack Size:", STACK_X_OFFSET+1, STACK_Y_OFFSET, STACK_WIDTH, STACK_LABEL_HEIGHT, False); } // Draw the heap area (but don't populate it yet). @@ -597,28 +573,19 @@ draw_heap(struct NEDsim * nedsim) #define HEAP_START_ADDRESS 0x20000000 // First draw the two colored boxes that comprise the heap area. - set_color(nedsim, &color_list[nedsim->color_index].tertiary); + set_color(nedsim, COLOR(tertiary)); draw_rect_area(nedsim, HEAP_X_OFFSET, HEAP_Y_OFFSET, HEAP_WIDTH, HEAP_LABEL_HEIGHT, True, True, False, False); for (int i = 0; i < nedsim->num_data_rows; i++) { draw_wordline(nedsim, HEAP_X_OFFSET, HEAP_Y_OFFSET+HEAP_LABEL_HEIGHT+i); } - // Now draw the label text "RAM Base:". - set_color(nedsim, &color_list[nedsim->color_index].text); - int text_x_size, text_y_size; - get_text_size(nedsim, "RAM Base:", &text_x_size, &text_y_size); - int local_y_offset = ((HEAP_LABEL_HEIGHT * nedsim->cell_size) - text_y_size) / 2; - XDrawString(nedsim->dpy, nedsim->panel, nedsim->gc, ((HEAP_X_OFFSET + 1) * nedsim->cell_size + nedsim->origin_x_offset), - ((HEAP_Y_OFFSET+HEAP_LABEL_HEIGHT) * nedsim->cell_size + nedsim->origin_y_offset - local_y_offset), "RAM Base:", 9); + // Now draw the text label "RAM Base:". + draw_text(nedsim, "RAM Base:", HEAP_X_OFFSET+1, HEAP_Y_OFFSET, HEAP_WIDTH, HEAP_LABEL_HEIGHT, False); // Now draw the address text. - set_color(nedsim, &color_list[nedsim->color_index].text); char address[11]; snprintf(address, sizeof(address), "0x%08X", HEAP_START_ADDRESS); - get_text_size(nedsim, address, &text_x_size, &text_y_size); - local_y_offset = ((HEAP_LABEL_HEIGHT * nedsim->cell_size) - text_y_size) / 2; - XDrawString(nedsim->dpy, nedsim->panel, nedsim->gc, ((HEAP_X_OFFSET + 1 + (HEAP_WIDTH / 2)) * nedsim->cell_size + nedsim->origin_x_offset), - ((HEAP_Y_OFFSET+HEAP_LABEL_HEIGHT) * nedsim->cell_size + nedsim->origin_y_offset - local_y_offset), address, strlen(address)); + draw_text(nedsim, address, (HEAP_X_OFFSET+(HEAP_WIDTH/2)+1), HEAP_Y_OFFSET, HEAP_WIDTH, HEAP_LABEL_HEIGHT, False); } // After the static front panel has been drawn at least once, this function @@ -629,25 +596,25 @@ update_display(struct NEDsim * nedsim) { // Draw the halt indicator. if (nedsim->nedstate->halted) { - set_color(nedsim, &color_list[nedsim->color_index].error_on); + set_color(nedsim, COLOR(error_on)); } else { - set_color(nedsim, &color_list[nedsim->color_index].error_off); + set_color(nedsim, COLOR(error_off)); } draw_circular_area(nedsim, HALT_X_OFFSET, HALT_Y_OFFSET, HALT_WIDTH); // Draw the PSW "N" light. if (nedsim->nedstate->active_thread->psw->negative) { - set_color(nedsim, &color_list[nedsim->color_index].light_on); + set_color(nedsim, COLOR(light_on)); } else { - set_color(nedsim, &color_list[nedsim->color_index].light_off); + set_color(nedsim, COLOR(light_off)); } draw_circular_area(nedsim, PSW_N_X_OFFSET+1, PSW_Y_OFFSET+PSW_LABEL_HEIGHT, PSW_LIGHT_HEIGHT); // Draw the PSW "Z" light. if (nedsim->nedstate->active_thread->psw->zero) { - set_color(nedsim, &color_list[nedsim->color_index].light_on); + set_color(nedsim, COLOR(light_on)); } else { - set_color(nedsim, &color_list[nedsim->color_index].light_off); + set_color(nedsim, COLOR(light_off)); } draw_circular_area(nedsim, PSW_Z_X_OFFSET+1, PSW_Y_OFFSET+PSW_LABEL_HEIGHT, PSW_LIGHT_HEIGHT); @@ -656,9 +623,9 @@ update_display(struct NEDsim * nedsim) int i; for (i = 0; i < SC_WIDTH; i++) { if ((SC_WIDTH-1-i) == nedsim->nedstate->active_thread->sc) { - set_color(nedsim, &color_list[nedsim->color_index].light_on); + set_color(nedsim, COLOR(light_on)); } else { - set_color(nedsim, &color_list[nedsim->color_index].light_off); + set_color(nedsim, COLOR(light_off)); } draw_circular_area(nedsim, SC_X_OFFSET+i, SC_Y_OFFSET+SC_LABEL_HEIGHT, SC_LIGHT_HEIGHT); } @@ -677,16 +644,11 @@ update_display(struct NEDsim * nedsim) } // Draw the stack size in text. - set_color(nedsim, &color_list[nedsim->color_index].tertiary); + set_color(nedsim, COLOR(tertiary)); draw_rect_area(nedsim, STACK_X_OFFSET+(STACK_WIDTH/2), STACK_Y_OFFSET, STACK_WIDTH/2, STACK_LABEL_HEIGHT, True, True, False, False); - set_color(nedsim, &color_list[nedsim->color_index].text); char stack_size[11]; snprintf(stack_size, sizeof(stack_size), "0x%08X", nedsim->nedstate->active_thread->sp); - int text_x_size, text_y_size; - get_text_size(nedsim, stack_size, &text_x_size, &text_y_size); - int local_y_offset = ((STACK_LABEL_HEIGHT * nedsim->cell_size) - text_y_size) / 2; - XDrawString(nedsim->dpy, nedsim->panel, nedsim->gc, ((STACK_X_OFFSET + 1 + (STACK_WIDTH / 2)) * nedsim->cell_size + nedsim->origin_x_offset), - ((STACK_Y_OFFSET+STACK_LABEL_HEIGHT) * nedsim->cell_size + nedsim->origin_y_offset - local_y_offset), stack_size, strlen(stack_size)); + draw_text(nedsim, stack_size, (STACK_X_OFFSET+(STACK_WIDTH/2)+1), STACK_Y_OFFSET, STACK_WIDTH, STACK_LABEL_HEIGHT, False); // Draw the heap lights. for (i = 0; i < nedsim->num_data_rows; i++) { @@ -844,7 +806,7 @@ NEDsim_draw(Display * dpy, Window win, void * closure) nedsim->nedstate = run_simulator(nedsim->nedstate); update_display(nedsim); } else { - set_color(nedsim, &color_list[nedsim->color_index].error_on); + set_color(nedsim, COLOR(error_on)); XFillRectangle(nedsim->dpy, nedsim->panel, nedsim->gc, 0, 0, nedsim->dpy_width, nedsim->dpy_height); }