#include #include #include "gst_display.h" #include "gst_cond.h" static GdkDrawable *drawable; static GdkGC *gc; static GdkColor black_color, red_color, bg_color, yellow_color, second_title_color; static GdkFont *font_titre; static GdkFont *font_mop; static GdkFont *font_small; static mtr_infos *infos; void dis_init (GdkDrawable *_drawable, mtr_infos *_infos) { GdkColormap *colormap; infos = _infos; drawable = _drawable; colormap = gdk_window_get_colormap (drawable); gc = gdk_gc_new (drawable); bg_color.red = 64000; bg_color.green = 63000; bg_color.blue = 61000; gdk_color_alloc (colormap, &bg_color); gdk_window_set_background (drawable, &bg_color); black_color.red = 0; black_color.green = 0; black_color.blue = 0; gdk_color_alloc (colormap, &black_color); gdk_gc_set_foreground (gc, &black_color); red_color.red = 61000; red_color.green = 1000; red_color.blue = 1000; gdk_color_alloc (colormap, &red_color); yellow_color.red = 100; yellow_color.green = 5100; yellow_color.blue = 65000; gdk_color_alloc (colormap, &yellow_color); second_title_color.red = 5000; second_title_color.green = 25000; second_title_color.blue = 10000; gdk_color_alloc (colormap, &second_title_color); font_titre = gdk_font_load ("-adobe-times-medium-i-normal--20-140-100-100-p-94-iso8859-1"); if (font_titre == NULL) font_titre = gdk_font_load ("9x15"); font_mop = gdk_font_load ("-misc-fixed-bold-r-semicondensed--13-120-75-75-c-60-iso8859-15"); if (font_mop == NULL) font_titre = gdk_font_load ("9x15"); font_small = gdk_font_load ("7x13"); } char *hex[256] = { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6a", "6b", "6c", "6d", "6e", "6f", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7a", "7b", "7c", "7d", "7e", "7f", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8a", "8b", "8c", "8d", "8e", "8f", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9a", "9b", "9c", "9d", "9e", "9f", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af", "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf", "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "da", "db", "dc", "dd", "de", "df", "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff", }; void rectangle(int x, int y, int width, int height) { gdk_draw_rectangle (drawable, gc, FALSE, x, y, width, height); } void string(int x, int y, GdkFont *font, char *contents) { int len = strlen (contents); int w = gdk_text_width (font, contents, len); gdk_gc_set_foreground (gc, &second_title_color); gdk_draw_text (drawable, font, gc, x - w / 2 + 1, y + 8, contents, len); gdk_gc_set_foreground (gc, &black_color); gdk_draw_text (drawable, font, gc, x - w / 2, y + 8, contents, len); } void smallstring_color(int x, int y, GdkColor *color, char *contents) { int len = strlen(contents); int w = gdk_text_width (font_small, contents, len); int h = gdk_text_height (font_small, contents, len); gdk_gc_set_foreground (gc, &bg_color); gdk_draw_rectangle (drawable, gc, TRUE, x, y - h, w, h); gdk_gc_set_foreground (gc, color); gdk_draw_text (drawable, font_small, gc, x, y, contents, len); gdk_gc_set_foreground (gc, &black_color); } void smallstring(int x, int y, char *contents) { smallstring_color (x, y, &black_color, contents); } void mop(int x, int y, int actif, char *label) { if (actif) gdk_gc_set_foreground (gc, &red_color); else gdk_gc_set_foreground (gc, &bg_color); gdk_draw_arc (drawable, gc, TRUE, x - 15, y - 15, 30, 30, 0, 360 * 64); gdk_gc_set_foreground (gc, &black_color); gdk_draw_arc (drawable, gc, FALSE, x - 15, y - 15, 30, 30, 0, 360 * 64); string (x, y, font_mop, label); } void registr(int x, int y, int w, int h, char *label) { rectangle(x, y, w, h); string(x + w / 2, y + h / 2, font_titre, label); } void line(int x1, int y1, int x2, int y2) { gdk_draw_line (drawable, gc, x1, y1, x2, y2); } void vline(int x, int y, int y1) { line(x, y, x, y1); } void hline(int x, int y, int x1) { line(x, y, x1, y); } void uparrow(int x, int y) { int delta = 2 * HT; line(x, y, x - delta, y + delta); line(x, y, x + delta, y + delta); } void downarrow(int x, int y) { int delta = 2 * HT; line(x, y, x - delta, y - delta); line(x, y, x + delta, y - delta); } void leftarrow(int x, int y) { int delta = 2 * HT; line(x, y, x + delta, y - delta); line(x, y, x + delta, y + delta); } void rightarrow(int x, int y) { int delta = 2 * HT; line(x, y, x - delta, y - delta); line(x, y, x - delta, y + delta); } void thick_hwire(int x, int y, int x1) { if(x1 < x) { hline(x - HT, y - HT, x1 + HT); hline(x - HT, y + HT, x1 + HT); } else { hline(x + HT, y - HT, x1 - HT); hline(x + HT, y + HT, x1 - HT); } } void thick_vwire(int x, int y, int y1) { if(y1 < y) { vline(x - HT, y - HT, y1 + HT); vline(x + HT, y - HT, y1 + HT); } else { vline(x - HT, y + HT, y1 - HT); vline(x + HT, y + HT, y1 - HT); } } void ulcorner(int x, int y) { vline(x - HT, y - HT, y + HT); hline(x - HT, y - HT, x + HT); } void urcorner(int x, int y) { vline(x + HT, y - HT, y + HT); hline(x + HT, y - HT, x - HT); } void llcorner(int x, int y) { vline(x - HT, y + HT, y - HT); hline(x - HT, y + HT, x + HT); } void lrcorner(int x, int y) { vline(x + HT, y + HT, y - HT); hline(x + HT, y + HT, x - HT); } void upline(int x, int y1, int y2) { GdkPoint points[3]; gdk_draw_line (drawable, gc, x, y1, x, y2); points[0].x = x + 0; points[0].y = y2; points[1].x = x - 3; points[1].y = y2 + 7; points[2].x = x + 3; points[2].y = y2 + 7; gdk_draw_polygon (drawable, gc, TRUE, points, 3); } void downline(int x, int y1, int y2) { GdkPoint points[3]; gdk_draw_line (drawable, gc, x, y1, x, y2); points[0].x = x + 0; points[0].y = y2; points[1].x = x - 3; points[1].y = y2 - 7; points[2].x = x + 3; points[2].y = y2 - 7; gdk_draw_polygon (drawable, gc, TRUE, points, 3); } void leftline(int x1, int y, int x2) { GdkPoint points[3]; gdk_draw_line (drawable, gc, x1, y, x2, y); points[0].x = x2 + 0; points[0].y = y; points[1].x = x2 + 7; points[1].y = y - 3; points[2].x = x2 + 7; points[2].y = y + 3; gdk_draw_polygon (drawable, gc, TRUE, points, 3); } void rightline(int x1, int y, int x2) { GdkPoint points[3]; gdk_draw_line (drawable, gc, x1, y, x2, y); points[0].x = x2 + 0; points[0].y = y; points[1].x = x2 - 7; points[1].y = y - 3; points[2].x = x2 - 7; points[2].y = y + 3; gdk_draw_polygon (drawable, gc, TRUE, points, 3); } void buses(void) { /* data bus */ thick_vwire(DBX, DBY1, DBY2 + 65); uparrow(DBX, DBY1); downarrow(DBX, DBY2 + 65); string(DBX, DBY1 - 11, font_titre, "Data Bus"); /* address bus */ thick_vwire(ABX, ABY1, ABY2 + 100); uparrow(ABX, ABY1); downarrow(ABX, ABY2 + 100); string(ABX, ABY1 - 11, font_titre, "Address Bus"); } void micro_pc(void) { registr(20, 100, 120, 30, "Micro PC"); thick_vwire(80, 130 - HT, 160); smallstring(80 + 15, 130 + 20, hex[*infos->valeur_bus_mcp_mm]); mop(110, 60, infos->mop[2], "2"); downline(110, 75, 100); smallstring(98, 98, infos->mop[2] ? "1" : "0"); mop(50, 60, infos->mop[1], "1"); downline(50, 75, 100); smallstring(57, 98, infos->mop[1] ? "1" : "0"); smallstring(120, 98, "ld"); smallstring(25, 98, "clr"); } void alu(int x, int y, int w, int h) { int h1 = h / 4; line(x, y, x + h, y + h); hline(x + h, y + h, x + w - h); line(x + w - h, y + h, x + w, y); hline(x + w, y, x + w / 2 + h1); line(x + w / 2 + h1, y, x + w / 2, y + h1); line(x + w / 2, y + h1, x + w / 2 - h1, y); hline(x + w / 2 - h1, y, x); string(x + w / 2, y + h / 2, font_titre, "ALU"); if (infos->mop[13] || infos->mop[14] || infos->mop[15]) gdk_gc_set_foreground (gc, &red_color); else gdk_gc_set_foreground (gc, &bg_color); gdk_draw_arc (drawable, gc, TRUE, x - 55, y + h / 2 - 15, 30, 30, 90 * 64, 180 * 64); gdk_draw_arc (drawable, gc, TRUE, x - 35, y + h / 2 - 15, 30, 30, -90 * 64, 180 * 64); gdk_draw_rectangle (drawable, gc, TRUE, x - 40, y + h / 2 - 15, 20, 30); gdk_gc_set_foreground (gc, &black_color); gdk_draw_arc (drawable, gc, FALSE, x - 55, y + h / 2 - 15, 30, 30, 90 * 64, 180 * 64); gdk_draw_arc (drawable, gc, FALSE, x - 35, y + h / 2 - 15, 30, 30, -90 * 64, 180 * 64); hline(x - 40, y + h / 2 - 15, x - 20); hline(x - 40, y + h / 2 + 15, x - 20); string(x - 30, y + h / 2, font_mop, "13-15"); rightline(x - 5, y + h / 2, x + h / 2); smallstring(x - 2, y + h / 2 + 14, infos->mop[13] ? "1" : "0"); smallstring(x + 5, y + h / 2 + 14, infos->mop[14] ? "1" : "0"); smallstring(x + 12, y + h / 2 + 14, infos->mop[15] ? "1" : "0"); } void alu_and_registrs(int x, int y, int w, int h) { int reg_width = w / 2 - h / 8; int reg_height = h / 3; int deltay_r1_bd = 60; alu(x, y + 2 * h / 3, w, h / 3); registr(x, y, reg_width, reg_height, "R0"); mop(x - 40, y + reg_height / 2, infos->mop[11], "11"); rightline(x - 25, y + reg_height / 2, x); smallstring(x - 10, y + reg_height / 2 + 14, infos->mop[11] ? "1" : "0"); registr(x + w - reg_width, y, reg_width, reg_height, "R1"); mop(x + w + 40, y + reg_height / 2, infos->mop[12], "12"); leftline(x + w + 25, y + reg_height / 2, x + w); smallstring(x + w + 4, y + reg_height / 2 + 14, infos->mop[12] ? "1" : "0"); /* draw the connections from registers to ALU */ thick_vwire(x + reg_width / 2, y + reg_height - HT, y + 2 * h / 3); downarrow(x + reg_width / 2, y + 2 * h / 3); smallstring(x + reg_width / 2 + 10, y + reg_height + 15, hex[*infos->valeur_bus_reg0_ual]); thick_vwire(x + w - reg_width / 2, y + reg_height - HT, y + 2 * h / 3); downarrow(x + w - reg_width / 2, y + 2 * h / 3); smallstring(x + w - reg_width / 2 + 10, y + reg_height + 15, hex[*infos->valeur_bus_reg1_ual]); /* draw connection from ALU to R1 */ thick_vwire(x + w / 2, y + h - HT, y + h + h / 3); smallstring(x + w / 2 + 15, y + h + 20, hex[*infos->valeur_bus_ual_reg1]); llcorner(x + w / 2, y + h + h / 3); thick_hwire(x + w / 2, y + h + h / 3, x + w + 65); lrcorner(x + w + 65, y + h + h / 3); thick_vwire(x + w + 65, y + h + h / 3, y - h / 3); urcorner(x + w + 65, y - h / 3); thick_hwire(x + w + 65, y - h / 3, x + w - reg_width / 2); ulcorner(x + w - reg_width / 2, y - h / 3); thick_vwire(x + w - reg_width / 2, y - h / 3, y); downarrow(x + w - reg_width / 2, y); smallstring(x + w - reg_width / 2 + 15, y - 10, hex[*infos->valeur_bus_ual_reg1]); /* draw connection from data bus to R0 */ thick_hwire(DBX, DBY2 + 40, x + reg_width / 2); smallstring(DBX + 15, DBY2 + 40 + 20, hex[*infos->valeur_bus_donnees]); urcorner(x + reg_width / 2, DBY2 + 40); thick_vwire(x + reg_width / 2, DBY2 + 40, y); downarrow(x + reg_width / 2, y); /* draw connection from R1 to bus driver */ thick_hwire(x + w - reg_width / 2, y + h / 2, x + w / 2); llcorner(x + w / 2, y + h / 2); thick_vwire(x + w / 2, y + h / 2, DBY2 - 50 + deltay_r1_bd); urcorner(x + w / 2, DBY2 - 50 + deltay_r1_bd); thick_hwire(x + w / 2, DBY2 - 50 + deltay_r1_bd, DBX + 60); leftarrow(DBX + 60, DBY2 - 50 + deltay_r1_bd); smallstring(DBX + 60 + 15, DBY2 - 50 - 10 + deltay_r1_bd, hex[*infos->valeur_bus_reg1_ual]); registr(DBX + 30, DBY2 - 65 + deltay_r1_bd, 30, 30, "BD"); mop(DBX + 45, DBY2 - 100 + deltay_r1_bd, infos->mop[8], "8"); downline(DBX + 45, DBY2 - 85 + deltay_r1_bd, DBY2 - 65 + deltay_r1_bd); smallstring(DBX + 52, DBY2 - 67 + deltay_r1_bd, infos->mop[8] ? "1" : "0"); thick_hwire(DBX + 30 + HT, DBY2 - 50 + deltay_r1_bd, DBX + HT); leftarrow(DBX + HT, DBY2 - 50 + deltay_r1_bd); smallstring(DBX + 15, DBY2 - 50 - 10 + deltay_r1_bd, hex[*infos->valeur_bus_donnees]); } void pc(void) { int ypos = (ABY1 + ABY2) / 2 - 25; thick_hwire(ABX, ypos, ABX + 50); rightarrow(ABX + 50, ypos); smallstring(ABX + 50 - 20, ypos + 20, hex[*infos->valeur_bus_adresses]); registr(ABX + 50, ypos - 15, 80, 30, "PC"); thick_vwire(ABX + 50 + 40, ypos - 15 + HT, ypos - 50); smallstring(ABX + 50 + 40 + 15, ypos - 15 - 10, hex[*infos->valeur_bus_cp_cb]); urcorner(ABX + 50 + 40, ypos - 50); thick_hwire(ABX + 50 + 40, ypos - 50, ABX + 50 + 10); leftarrow(ABX + 50 + 10, ypos - 50); registr(ABX + 50 - 20, ypos - 50 - 15, 30, 30, "BD"); thick_hwire(ABX + 50 - 20 + HT, ypos - 50, ABX + HT); leftarrow(ABX + HT, ypos - 50); smallstring(ABX + 15, ypos - 50 - 10, hex[*infos->valeur_bus_adresses]); mop(ABX + 45, ypos - 110, infos->mop[5], "5"); downline(ABX + 45, ypos - 95, ypos - 65); smallstring(ABX + 52, ypos - 67, infos->mop[5] ? "1" : "0"); upline(ABX + 70, ypos + 40, ypos + 15); smallstring(ABX + 75, ypos + 27, *infos->valeur_fil_cond_cp ? "1" : "0"); smallstring(ABX + 50, ypos + 28, "ld"); mop(ABX + 110, ypos + 55, infos->mop[7], "7"); upline(ABX + 110, ypos + 40, ypos + 15); smallstring(ABX + 98, ypos + 27, infos->mop[7] ? "1" : "0"); smallstring(ABX + 115, ypos + 28, "incr"); } void data_reg(void) { int xpos = ABX - 190; int ypos = ABY1 + 325; int w_datareg = 130; registr(xpos, ypos, w_datareg, 30, "Data Reg"); mop(xpos + 35, ypos + 60, infos->mop[21], "21"); upline(xpos + 35, ypos + 45, ypos + 30); thick_hwire(xpos + w_datareg, ypos + 15, ABX); leftarrow(xpos + w_datareg, ypos + 15); smallstring(ABX - 45, ypos + 33, hex[*infos->valeur_bus_adresses]); thick_hwire(xpos + 2, ypos + 15, xpos - 55); leftarrow(xpos - 55, ypos + 15); smallstring(xpos - 25, ypos + 33, hex[*infos->valeur_bus_regdonnees_cb]); registr(xpos - 90, ypos, 35, 30, "DB"); mop(xpos - 72, ypos + 60, infos->mop[22], "22"); upline(xpos - 72, ypos + 45, ypos + 30); thick_hwire(xpos - 88, ypos + 15, DBX + 5); leftarrow(DBX + 5, ypos + 15); smallstring(xpos - 110, ypos + 33, hex[*infos->valeur_bus_donnees]); } void address_reg(void) { int dx = (ABX - DBX - 30) / 6; int ypos = ABY2 + 60; thick_hwire(DBX, ypos, DBX + dx); rightarrow(DBX + dx, ypos); smallstring(DBX + dx - 20, ypos + 20, hex[*infos->valeur_bus_donnees]); registr(DBX + dx, ypos - 15, 3 * dx, 30, "Address Reg"); mop(DBX + 3 * dx, ypos + 50, infos->mop[9], "9"); upline(DBX + 3 * dx, ypos + 35, ypos + 15); smallstring(DBX + 3 * dx + 7, ypos + 27, infos->mop[9] ? "1" : "0"); thick_hwire(DBX + 4 * dx - HT, ypos, DBX + 5 * dx); rightarrow(DBX + 5 * dx, ypos); smallstring(DBX + 5 * dx - 20, ypos + 20, hex[*infos->valeur_bus_regad_cb]); registr(DBX + 5 * dx, ypos - 15, 30, 30, "BD"); mop(DBX + 5 * dx + 15, ypos + 50, infos->mop[10], "10"); upline(DBX + 5 * dx + 15, ypos + 35, ypos + 15); smallstring(DBX + 5 * dx + 3, ypos + 27, infos->mop[10] ? "1" : "0"); thick_hwire(DBX + 5 * dx + 30, ypos, ABX - HT); rightarrow(ABX - HT, ypos); smallstring(ABX - HT - 20, ypos + 20, hex[*infos->valeur_bus_adresses]); } void stack_pointer (void) { int xpos = ABX + 90; int ypos = ABY1 + 320; registr(xpos, ypos, 125, 30, "Stack Pointer"); mop(xpos + 30, ypos + 65, infos->mop[23], "23"); upline(xpos + 30, ypos + 50, ypos + 30); smallstring(xpos + 5, ypos + 43, "inc"); smallstring(xpos + 35, ypos + 43, infos->mop[23] ? "1" : "0"); mop(xpos + 95, ypos + 65, infos->mop[24], "24"); upline(xpos + 95, ypos + 50, ypos + 30); smallstring(xpos + 70, ypos + 43, "dec"); smallstring(xpos + 100, ypos + 43, infos->mop[24] ? "1" : "0"); thick_vwire(xpos + 115 / 2, ypos + 3, ypos - 33); uparrow(xpos + 115 / 2, ypos - 34); smallstring(xpos + 35, ypos - 15, hex[*infos->valeur_bus_pptr_cb]); registr(xpos + 38 , ypos - 65, 35, 30, "DB"); mop(xpos + 113, ypos - 50, infos->mop[25], "25"); leftline(xpos + 98, ypos - 50, xpos + 73); thick_hwire(xpos + 41, ypos - 50, ABX + 5); leftarrow(ABX + 5, ypos - 50); smallstring(xpos - 48, ypos - 30, hex[*infos->valeur_bus_adresses]); } void conditional_reg(int deltax, int deltay) { int xpos = ABX + 20 + deltax; int ypos = ABY2 - 95 + deltay; int ypcpos = (ABY1 + ABY2) / 2; rectangle(xpos, ypos, 80, 150); //hline(xpos + 20, ypcpos + 15, xpos + 40); //vline(xpos + 40, ypcpos + 15, ypcpos + 90 + deltay); vline(xpos + 20, ypcpos + 15, ypcpos + 90 + deltay); mop(xpos + 110, ypos + 10, infos->mop[6], "6"); leftline(xpos + 95, ypos + 10, xpos + 80); smallstring(xpos + 85, ypos + 5, infos->mop[6] ? "1" : "0"); mop(xpos + 110, ypos + 43, infos->mop[20], "20"); leftline(xpos + 95, ypos + 43, xpos + 80); smallstring(xpos + 85, ypos + 38, infos->mop[20] ? "1" : "0"); mop(xpos + 110, ypos + 76, infos->mop[19], "19"); leftline(xpos + 95, ypos + 76, xpos + 80); smallstring(xpos + 85, ypos + 71, infos->mop[19] ? "1" : "0"); mop(xpos + 110, ypos + 109, infos->mop[18], "18"); leftline(xpos + 95, ypos + 109, xpos + 80); smallstring(xpos + 85, ypos + 104, infos->mop[18] ? "1" : "0"); mop(xpos + 110, ypos + 142, infos->mop[17], "17"); leftline(xpos + 95, ypos + 142, xpos + 80); smallstring(xpos + 85, ypos + 137, infos->mop[17] ? "1" : "0"); mop(xpos + 110, ypos + 187, infos->mop[16], "16"); leftline(xpos + 95, ypos + 187, xpos + 80); smallstring(xpos + 85, ypos + 180, infos->mop[16] ? "1" : "0"); registr(xpos, ypos + 170, 20, 30, "N"); vline(xpos + 10, ypos + 150, ypos + 170); smallstring(xpos, ypos + 165, infos->valeur_fil_regcond_cond[N] ? "1" : "0"); smallstring(xpos, ypos + 215, infos->valeur_fil_ual_regcond[N] ? "1" : "0"); registr(xpos + 20, ypos + 170, 20, 30, "Z"); vline(xpos + 30, ypos + 150, ypos + 170); smallstring(xpos + 20, ypos + 165, infos->valeur_fil_regcond_cond[Z] ? "1" : "0"); smallstring(xpos + 20, ypos + 215, infos->valeur_fil_ual_regcond[Z] ? "1" : "0"); registr(xpos + 40, ypos + 170, 20, 30, "C"); vline(xpos + 50, ypos + 150, ypos + 170); smallstring(xpos + 40, ypos + 165, infos->valeur_fil_regcond_cond[C] ? "1" : "0"); smallstring(xpos + 40, ypos + 215, infos->valeur_fil_ual_regcond[C] ? "1" : "0"); registr(xpos + 60, ypos + 170, 20, 30, "V"); vline(xpos + 70, ypos + 150, ypos + 170); smallstring(xpos + 60, ypos + 165, infos->valeur_fil_regcond_cond[V] ? "1" : "0"); smallstring(xpos + 60, ypos + 215, infos->valeur_fil_ual_regcond[V] ? "1" : "0"); /* draw the connections from ALU to conditional */ hline(xpos - 79 - deltax, ypos + 395 - deltay, xpos + 10); vline(xpos + 10, ypos + 395 - deltay, ypos + 200); hline(xpos - 84 - deltax, ypos + 400 - deltay, xpos + 30); vline(xpos + 30, ypos + 400 - deltay, ypos + 200); hline(xpos - 89 - deltax, ypos + 405 - deltay, xpos + 50); vline(xpos + 50, ypos + 405 - deltay, ypos + 200); hline(xpos - 94 - deltax, ypos + 410 - deltay, xpos + 70); vline(xpos + 70, ypos + 410 - deltay, ypos + 200); } void micro_mem(void) { int deltay = 7 * TAILLE_MM; rectangle(7, 160, 161, deltay + 30); string(95, 160 + 9, font_titre, "Micro Memory"); downarrow(80, 160); mop(40, 235 + deltay, 0, "1"); mop(130, 235 + deltay, 0, "25"); gdk_draw_arc (drawable, gc, FALSE, 66, 235 + deltay, 4, 4, 0, 360 * 64); gdk_draw_arc (drawable, gc, FALSE, 80, 235 + deltay, 4, 4, 0, 360 * 64); gdk_draw_arc (drawable, gc, FALSE, 95, 235 + deltay, 4, 4, 0, 360 * 64); downline(40, 190 + deltay, 190 + deltay + 30); downline(130, 190 + deltay, 190 + deltay + 30); /* display contents */ { int row; for(row = 0; row < TAILLE_MM; row++) { int y = 160 + 7 * row + 25; int col; if (row == *infos->valeur_bus_mcp_mm) gdk_gc_set_foreground (gc, &yellow_color); for(col = 1; col < NBRE_MOP; col++) { int x = 6 * col + 8; if (*(*(infos->mm + row) + col)) vline(x + 2, y, y + 4); else gdk_draw_rectangle (drawable, gc, FALSE, x, y, 3, 4); } if (row == *infos->valeur_bus_mcp_mm) gdk_gc_set_foreground (gc, &black_color); } } } void instruction_decoder(void) { rectangle(180, 100, 80, 400); string(220, 100 - 27, font_titre, "Instruction"); string(220, 100 - 11, font_titre, "Decoder"); thick_hwire(DBX, 115, 260); smallstring(DBX - 20, 115 + 20, hex[*infos->valeur_bus_donnees & 0x1f]); leftarrow(260, 115); thick_hwire(180 + HT, 115, 140); smallstring(180 - 20, 115 + 20, hex[*infos->valeur_bus_deci_mcp]); leftarrow(140, 115); /* draw contents */ { int x = 180 + 10; int row; for(row = 0; row < 32; row++) { int y = 100 + 12 * row + 20; if (row == (*infos->valeur_bus_donnees & 0x1f)) { smallstring_color(x, y, &yellow_color, hex[row]); smallstring_color(x + 20, y, &yellow_color, ":"); smallstring_color(x + 30, y, &yellow_color, hex[infos->deci[row]]); } else { smallstring(x, y, hex[row]); smallstring(x + 20, y, ":"); smallstring(x + 30, y, hex[infos->deci[row]]); } } } } void main_mem(void) { int xpos = DBX + 30; int ypos = DBY1; int w = ABX - 30 - xpos; int h = ABY2 - ABY1 - 100; registr(xpos, ypos, w, h, ""); thick_hwire(DBX + HT, ypos + h / 2, xpos); leftarrow(DBX + HT, ypos + h / 2); smallstring(DBX + HT + 5, ypos + h / 2 + 20, hex[*infos->valeur_bus_donnees]); rightarrow(xpos, ypos + h / 2); thick_hwire(xpos + w, ypos + h / 2, ABX); leftarrow(xpos + w, ypos + h / 2); smallstring(xpos + w + 5, ypos + h / 2 + 20, hex[*infos->valeur_bus_adresses]); string(xpos + w / 2, ypos - 11, font_titre, "Main Memory"); mop(xpos + 50, ypos + h + 30, infos->mop[3], "3"); upline(xpos + 50, ypos + h + 15, ypos + h); smallstring(xpos + 57, ypos + h + 12, infos->mop[3] ? "1" : "0"); smallstring(xpos + 30, ypos + h + 15, "en"); mop(xpos + w - 50, ypos + h + 30, infos->mop[4], "4"); upline(xpos + w - 50, ypos + h + 15, ypos + h); smallstring(xpos + w - 62, ypos + h + 12, infos->mop[4] ? "1" : "0"); smallstring(xpos + w - 40, ypos + h + 15, "r/w"); /* display contents */ { int col; for(col = 0; col < 16; col++) { int row; for(row = 0; row < 16; row++) { int x = xpos + 4 + w / 16 * col; int y = ypos + 20 + row * 16; int pos = col * 16 + row; if (*infos->valeur_bus_adresses == pos) smallstring_color(x, y, &yellow_color, hex[infos->mp[pos]]); else smallstring(x, y, hex[infos->mp[pos]]); } } } } void dis_expose_handler(void) { micro_pc(); micro_mem(); instruction_decoder(); buses(); alu_and_registrs(DBX, DBY2 + 75, 300, 100); pc(); address_reg(); main_mem(); conditional_reg(30, 150); data_reg (); stack_pointer(); }