static int output_file(file_type type, int srcrootlen, int dstrootlen, const astring *srcfile, const astring *dstfile, int link_to_file) { const char *comment_start, *comment_end, *comment_inline, *token_chars; const char *comment_start_esc, *comment_end_esc, *comment_inline_esc; const token_entry *token_table; const astring *srcfile_subpath; char srcline[4096], *srcptr; int in_comment = FALSE; UINT8 is_token[256]; int color_quotes; core_file *src; core_file *dst; int toknum; int linenum = 1; /* extract a normalized subpath */ srcfile_subpath = normalized_subpath(srcfile, srcrootlen + 1); if (srcfile_subpath == NULL) return 1; fprintf(stderr, "Processing %s\n", astring_c(srcfile_subpath)); /* set some defaults */ color_quotes = FALSE; comment_start = comment_start_esc = ""; comment_end = comment_end_esc = ""; comment_inline = comment_inline_esc = ""; token_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_#"; token_table = dummy_token_table; /* based on the file type, set the comment info */ switch (type) { case FILE_TYPE_C: color_quotes = TRUE; comment_start = comment_start_esc = "/*"; comment_end = comment_end_esc = "*/"; comment_inline = comment_inline_esc = "//"; token_table = c_token_table; break; case FILE_TYPE_MAKE: color_quotes = TRUE; comment_inline = comment_inline_esc = "#"; break; case FILE_TYPE_XML: color_quotes = TRUE; comment_start = "<!--"; comment_start_esc = "<!--"; comment_end = "-->"; comment_end_esc = "-->"; break; default: case FILE_TYPE_TEXT: break; } /* make the token lookup table */ memset(is_token, 0, sizeof(is_token)); for (toknum = 0; token_chars[toknum] != 0; toknum++) is_token[(UINT8)token_chars[toknum]] = TRUE; /* open the source file */ if (core_fopen(astring_c(srcfile), OPEN_FLAG_READ, &src) != FILERR_NONE) { fprintf(stderr, "Unable to read file '%s'\n", astring_c(srcfile)); return 1; } /* open the output file */ dst = create_file_and_output_header(dstfile, "MAME Source Code", astring_c(srcfile_subpath)); if (dst == NULL) { fprintf(stderr, "Unable to write file '%s'\n", astring_c(dstfile)); core_fclose(src); return 1; } /* output the directory navigation */ core_fprintf(dst, "<h3>Viewing File: "); output_path_as_links(dst, srcfile_subpath, FALSE, link_to_file); core_fprintf(dst, "</h3>"); astring_free((astring *)srcfile_subpath); /* start with some tags */ core_fprintf(dst, "\t<pre style=\"font-family:'Courier New','Courier',monospace; font-size:12px;\">\n"); /* iterate over lines in the source file */ while (core_fgets(srcline, ARRAY_LENGTH(srcline), src) != NULL) { char dstline[4096], *dstptr = dstline; int in_inline_comment = FALSE; int last_token_was_include = FALSE; int last_was_token = FALSE; int quotes_are_linked = FALSE; char in_quotes = 0; int curcol = 0; /* start with the line number */ dstptr += sprintf(dstptr, "<span style=\"" LINENUM_STYLE "\">%5d</span> ", linenum++); /* iterate over characters in the source line */ for (srcptr = srcline; *srcptr != 0; ) { UINT8 ch = *srcptr++; /* track whether or not we are within an extended (C-style) comment */ if (!in_quotes && !in_inline_comment) { if (!in_comment && ch == comment_start[0] && strncmp(srcptr - 1, comment_start, strlen(comment_start)) == 0) { dstptr += sprintf(dstptr, "<span style=\"" COMMENT_STYLE "\">%s", comment_start_esc); curcol += strlen(comment_start); srcptr += strlen(comment_start) - 1; ch = 0; in_comment = TRUE; } else if (in_comment && ch == comment_end[0] && strncmp(srcptr - 1, comment_end, strlen(comment_end)) == 0) { dstptr += sprintf(dstptr, "%s</span>", comment_end_esc); curcol += strlen(comment_end); srcptr += strlen(comment_end) - 1; ch = 0; in_comment = FALSE; } } /* track whether or not we are within an inline (C++-style) comment */ if (!in_quotes && !in_comment && !in_inline_comment && ch == comment_inline[0] && strncmp(srcptr - 1, comment_inline, strlen(comment_inline)) == 0) { dstptr += sprintf(dstptr, "<span style=\"" COMMENT_STYLE "\">%s", comment_inline_esc); curcol += strlen(comment_inline); srcptr += strlen(comment_inline) - 1; ch = 0; in_inline_comment = TRUE; } /* if this is the start of a new token, see if we want to color it */ if (!in_quotes && !in_comment && !in_inline_comment && !last_was_token && is_token[ch]) { const token_entry *curtoken; char *temp = srcptr; int toklength; /* find the end of the token */ while (*temp != 0 && is_token[(UINT8)*temp]) temp++; toklength = temp - (srcptr - 1); /* scan the token table */ last_token_was_include = FALSE; for (curtoken = token_table; curtoken->token != NULL; curtoken++) if (strncmp(srcptr - 1, curtoken->token, toklength) == 0 && strlen(curtoken->token) == toklength) { dstptr += sprintf(dstptr, "<span style=\"%s\">%s</span>", curtoken->color, curtoken->token); curcol += strlen(curtoken->token); srcptr += strlen(curtoken->token) - 1; ch = 0; /* look for include tokens specially */ if (type == FILE_TYPE_C && strcmp(curtoken->token, "#include") == 0) last_token_was_include = TRUE; break; } } last_was_token = is_token[ch]; /* if we hit a tab, expand it */ if (ch == 0x09) { /* compute how many spaces */ int spaces = 4 - curcol % 4; while (spaces--) { *dstptr++ = ' '; curcol++; } } /* otherwise, copy the source character */ else if (ch != 0x0a && ch != 0x0d && ch != 0) { /* track opening quotes */ if (!in_comment && !in_inline_comment && !in_quotes && (ch == '"' || ch == '\'')) { if (color_quotes) dstptr += sprintf(dstptr, "<span style=\"" STRING_STYLE "\">%c", ch); else *dstptr++ = ch; in_quotes = ch; /* handle includes */ if (last_token_was_include) { char *endquote = strchr(srcptr, ch); if (endquote != NULL) { astring *filename = astring_dupch(srcptr, endquote - srcptr); astring *target = find_include_file(srcrootlen, dstrootlen, srcfile, dstfile, filename); if (target != NULL) { dstptr += sprintf(dstptr, "<a href=\"%s\">", astring_c(target)); quotes_are_linked = TRUE; astring_free(target); } astring_free(filename); } } } /* track closing quotes */ else if (!in_comment && !in_inline_comment && in_quotes && ch == in_quotes && (type != FILE_TYPE_C || srcptr[-2] != '\\' || srcptr[-3] == '\\')) { if (quotes_are_linked) dstptr += sprintf(dstptr, "</a>"); if (color_quotes) dstptr += sprintf(dstptr, "%c</span>", ch); else *dstptr++ = ch; in_quotes = 0; quotes_are_linked = FALSE; } /* else just output the current character */ else if (ch == '&') dstptr += sprintf(dstptr, "&"); else if (ch == '<') dstptr += sprintf(dstptr, "<"); else if (ch == '>') dstptr += sprintf(dstptr, ">"); else *dstptr++ = ch; curcol++; } } /* finish inline comments */ if (in_inline_comment) { dstptr += sprintf(dstptr, "</span>"); in_inline_comment = FALSE; } /* append a break and move on */ dstptr += sprintf(dstptr, "\n"); core_fputs(dst, dstline); } /* close tags */ core_fprintf(dst, "\t</pre>\n"); /* close the file */ output_footer_and_close_file(dst); core_fclose(src); return 0; }
int main (int argc, char *argv[]) { int screensaver = 0, c, brightness_prev = -1, backlight_prev = -1; int light = 0, brightness = 255, backlight = 100; int foreground = 0, verbose = 0, debug = 0; int brightness_restore, backlight_restore, brightness_restoreflag = 0, backlight_restoreflag = 0; int res, dbus_backend = -1, tmp = -1; float idletime = 0; pid_t pid; conf_data conf; Display *display = NULL; DBusGConnection *connection; DBusGProxy *proxy_manager; DBusGProxy *proxy_session; uid_t uid, euid; int light_aux = -1, light_avg = -1; int lightvalues[15] = { 0 }; int countarray[256] = { 0 }; unsigned int i, index = 0; // make sure we are run as a regular user uid = getuid (); euid = geteuid (); if (uid == 0 || euid == 0) { fprintf (stderr, "lightum must NOT be run as root.\n"); exit (1); } // overwrite defaults with config file conf = config_parse (); // overwrite config file with command line arguments while ((c = getopt (argc, argv, "hxuUlsvfm:n:M:N:p:I:i:d:w:?")) != EOF) { switch (c) { case 'h': usage (""); break; case 'x': conf.manualmode = 1; break; case 'u': conf.ignoreuser = 0; break; case 'U': conf.ignoresession = 1; break; case 'l': conf.fulldim = 1; break; case 's': conf.queryscreensaver = 1; break; case 'f': foreground = 1; break; case 'v': verbose = 1; break; case 'd': debug = atoi (optarg); break; case 'm': conf.maxbrightness = atoi (optarg); break; case 'n': conf.minbrightness = atoi (optarg); break; case 'M': conf.maxbacklight = atoi (optarg); break; case 'N': conf.minbacklight = atoi (optarg); break; case 'p': conf.polltime = atoi (optarg); break; case 'i': conf.idleoff = atoi (optarg); break; case 'I': conf.screenidle = atoi (optarg); break; case 'w': conf.workmode = atoi (optarg); break; default: usage ("ERROR: Unknown OPTION\n"); break; } } if (verbose) printf ("CONFIG:\n\tmanualmode: %d\n", conf.manualmode); if (verbose) printf ("\tignoreuser: %d\n", conf.ignoreuser); if (verbose) printf ("\tignoresession: %d\n", conf.ignoresession); if (verbose) printf ("\tworkmode: %d\n", conf.workmode); if (verbose) printf ("\tqueryscreensaver: %d\n", conf.queryscreensaver); if (verbose) printf ("\tmaxbrightness: %d\n", conf.maxbrightness); if (verbose) printf ("\tminbrightness: %d\n", conf.minbrightness); if (verbose) printf ("\tmaxbacklight: %d\n", conf.maxbacklight); if (verbose) printf ("\tminbacklight: %d\n", conf.minbacklight); if (verbose) printf ("\tpolltime: %d\n", conf.polltime); if (verbose) printf ("\tidleoff: %d\n", conf.idleoff); if (verbose) printf ("\tscreenidle: %d\n", conf.screenidle); if (verbose) printf ("\tfulldim: %d\n\n", conf.fulldim); // make sure all config values are correct check_config_values (conf); if (debug < 0 || debug > 3) usage ("ERROR: Wrong value in config variable 'debug'\n"); // if debug enabled, force verbose mode too if (debug > 0) verbose = 1; // if verbose enabled, force foreground mode too if (verbose) foreground = 1; if (conf.manualmode) printf ("lightum v%s running in manual mode ", VERSION); else printf ("lightum v%s running in auto mode ", VERSION); fflush (stdout); if (!foreground) { if ((pid = fork ()) < 0) exit (1); else if (pid != 0) exit (0); /* daemon running here */ setsid (); res = chdir ("/"); if (res != 0) { perror ("Could not chdir"); exit (1); } umask (0); printf ("forked into background\n"); } else printf ("\n"); /* create pid file */ if (!create_pid_file ()) exit (1); /* start with current brightness values */ if (conf.workmode == 1 || conf.workmode == 3) { brightness_restore = get_keyboard_brightness_value (); } /* start with current backlight values */ if (conf.workmode == 2 || conf.workmode == 3) { backlight_restore = get_screen_backlight_value (); // detect dbus backend: 0: gnome, 1: kde tmp = dbus_set_screen_backlight_value_gnome (acpi_to_dbus_backlight (backlight_restore)); if (tmp == -1) { tmp = dbus_set_screen_backlight_value_kde (acpi_to_dbus_backlight (backlight_restore)); if (tmp == -1) { tmp = set_screen_xbacklight_value (acpi_to_dbus_backlight (backlight_restore)); if (tmp == -1) { fprintf (stderr, "Can't manage screen backlight on this system.\nPlease disable backlight with config option 'workmode='1' or command line switch '-w 1'.\nIf you believe this is an error, open a bug report: https://github.com/poliva/lightum/issues\n"); exit (1); } else { dbus_backend = 2; } } else { dbus_backend = 1; } } else { dbus_backend = 0; } } if (conf.idleoff != 0 || conf.screenidle != 0) { display = XOpenDisplay (NULL); if (display == NULL) { fprintf (stderr, "Failed to open display\n"); exit (1); } } signal_installer (); if (!conf.ignoresession) { connection = get_dbus_connection (); proxy_manager = get_dbus_proxy_manager (connection); proxy_session = get_dbus_proxy_session (connection, proxy_manager); } // initialize the light values array if (!conf.manualmode) { light = get_light_sensor_value (); for (i = 0; i < ARRAY_LENGTH (lightvalues); i++) lightvalues[i] = light; countarray[light] = ARRAY_LENGTH (lightvalues); } else { for (i = 0; i < ARRAY_LENGTH (lightvalues); i++) lightvalues[i] = 0; } while (1) { if (reloadconfig) { conf = config_parse (); if (verbose) printf ("lightum: SIGUSR1 received, configuration reloaded\n"); check_config_values (conf); reloadconfig = 0; } if (!conf.ignoresession) { if (!get_session_active (proxy_session)) { if (verbose) printf ("lightum: user session not active, sleeping %d milliseconds.\nIf you believe this is an error, try running lightum with 'ignoresession=1' or '-U' command line switch.\n", conf.polltime); usleep (conf.polltime * 1000); continue; } } if (!conf.manualmode) { light = get_light_sensor_value (); if (verbose) printf ("light_sensor: %d ", light); // to avoid backlight flickering when the light sensor flaps too frequently // between two values, we collect lighting values and use the most common // value of the collected values if (index == ARRAY_LENGTH (lightvalues)) index = 0; lightvalues[index] = light; // get the most repetitive value of lightvalues array for (i = 0; i < ARRAY_LENGTH (lightvalues); ++i) { countarray[lightvalues[i]]++; } light_avg = -1; light_aux = -1; for (i = 0; i < ARRAY_LENGTH (countarray); ++i) { if (countarray[i] > light_aux) { light_aux = countarray[i]; light_avg = i; } countarray[i] = 0; } light = light_avg; if (verbose) printf ("light_avg: %d ", light); index++; } if (conf.idleoff != 0 || conf.screenidle != 0) { idletime = get_session_idle_time (display); if (verbose) printf ("idle_time: %f ", idletime); } if (!conf.manualmode) { if (conf.workmode == 1 || conf.workmode == 3) brightness = calculate_keyboard_brightness_value (light, conf.maxbrightness, conf.minbrightness); if (conf.workmode == 2 || conf.workmode == 3) backlight = calculate_screen_backlight_value (light, conf.maxbacklight, conf.minbacklight); if (verbose) printf ("auto mode "); } else { if (verbose) printf ("manual mode "); if (conf.workmode == 1 || conf.workmode == 3) { if (!screensaver) { if (idletime > conf.idleoff) { if (brightness_restoreflag == 0) { brightness_restore = get_keyboard_brightness_value (); brightness_restoreflag = 1; if (debug == 1 || debug == 3) printf ("brightness_restoreflag(%d) ", brightness_restore); } brightness = conf.minbrightness; } else { brightness = brightness_restore; brightness_restoreflag = 0; if (debug == 1 || debug == 3) printf ("brightness_restored(%d) ", brightness_restore); } } } if (conf.workmode == 2 || conf.workmode == 3) { if (!screensaver) { if (idletime > conf.screenidle) { if (backlight_restoreflag == 0) { backlight_restore = get_screen_backlight_value (); backlight_restoreflag = 1; if (debug == 2 || debug == 3) printf ("backlight_restoreflag(%d) ", backlight_restore); } if (conf.fulldim) backlight = 1; else backlight = conf.minbacklight; } else { backlight = backlight_restore; backlight_restoreflag = 0; if (debug == 2 || debug == 3) printf ("backlight_restored(%d) ", backlight_restore); } } } } if (conf.workmode == 1 || conf.workmode == 3) { if ((conf.idleoff != 0) && (idletime > conf.idleoff)) { brightness = conf.minbrightness; } } if (conf.workmode == 2 || conf.workmode == 3) { if ((conf.screenidle != 0) && (idletime > conf.screenidle)) { if (conf.fulldim) backlight = 1; else backlight = conf.minbacklight; } } if (conf.queryscreensaver) { screensaver = get_screensaver_active (); if (verbose) printf ("screensaver: %d ", screensaver); if (screensaver) { brightness = 0; backlight = conf.minbacklight; } } if (conf.workmode == 1 || conf.workmode == 3) if (verbose) printf ("brightness: %d/%d ", brightness, conf.maxbrightness); if (conf.workmode == 2 || conf.workmode == 3) if (verbose) printf ("backlight: %d/%d ", backlight, conf.maxbacklight); // keyboard brightness if (conf.workmode == 1 || conf.workmode == 3) { if (brightness != brightness_prev) { if (!conf.manualmode) { brightness_restore = get_keyboard_brightness_value (); if (brightness_restore < conf.minbrightness) brightness_restore = conf.minbrightness; if (debug == 1 || debug == 3) printf ("\ncurrent brightness: %d\n", brightness_restore); if ((brightness_restore != brightness_prev) && (brightness_restoreflag)) { if (!conf.ignoreuser) { /* make sure maxbrightness is never <4 */ if (brightness_restore < 4) conf.maxbrightness = 4; else conf.maxbrightness = brightness_restore; if (verbose) printf ("-> Detected user brightness change, setting maxbrightness to %d\n", conf.maxbrightness); brightness_prev = brightness_restore; } else { if (verbose) printf ("-> Ignoring user brightness change, wants to set maxbrightness to %d\n", brightness_restore); } brightness = calculate_keyboard_brightness_value (light, conf. maxbrightness, conf. minbrightness); } brightness_restoreflag = 1; } if (debug == 1 || debug == 3) printf ("-> set keyboard brightness: %d -> %d\n", brightness_prev, brightness); fading (brightness_prev, brightness); usleep (1500); brightness = get_keyboard_brightness_value (); brightness_prev = brightness; } if (!conf.manualmode) { tmp = get_keyboard_brightness_value (); if (tmp != brightness) { if (verbose) printf ("-> Detected user brightness change, current brightness is set to %d\n", tmp); if (conf.ignoreuser) { if (debug == 1 || debug == 3) printf ("\n*** forcing brightness from %d to %d\n", tmp, brightness); fading (tmp, brightness); } } } } // screen backlight if (conf.workmode == 2 || conf.workmode == 3) { if (backlight != backlight_prev) { if (!conf.manualmode) { backlight_restore = get_screen_backlight_value (); if (debug == 2 || debug == 3) printf ("\ncurrent backlight: %d\n", backlight_restore); if ((backlight_restore != backlight_prev) && (backlight_restoreflag)) { if (!conf.ignoreuser) { if (verbose) printf ("-> Detected user backlight change, switching to manualmode\n"); conf.manualmode = 1; backlight_prev = backlight_restore; backlight = backlight_restore; } else { if (verbose) printf ("-> Ignoring user backlight change, wants to set maxbacklight to %d\n", backlight_restore); backlight = calculate_screen_backlight_value (light, conf. maxbacklight, conf. minbacklight); } } backlight_restoreflag = 1; } if (debug == 2 || debug == 3) printf ("-> set screen backlight: %d -> %d\n", backlight_prev, backlight); backlight_fading (backlight_prev, backlight, dbus_backend); usleep (1500); backlight = get_screen_backlight_value (); backlight_prev = backlight; } if (!conf.manualmode) { tmp = get_screen_backlight_value (); if (tmp != backlight) { if (verbose) printf ("-> Detected user backlight change, current backlight is set to %d\n", tmp); if (conf.ignoreuser) { if (debug == 2 || debug == 3) printf ("\n*** forcing backlight from %d to %d\n", tmp, backlight); backlight_fading (tmp, backlight, dbus_backend); } } } } if (verbose) printf ("\n"); usleep (conf.polltime * 1000); } // we should never reach here. //if (conf.idleoff != 0) XCloseDisplay(display); //dbus_g_connection_unref(connection); exit (1); }
void laserdisc_device::init_video() { // register for VBLANK callbacks m_screen->register_vblank_callback(vblank_state_delegate(FUNC(laserdisc_device::vblank_state_changed), this)); // allocate palette for applying brightness/contrast/gamma m_videopalette = palette_alloc(256, 1); if (m_videopalette == NULL) throw emu_fatalerror("Out of memory allocating video palette"); for (int index = 0; index < 256; index++) palette_entry_set_color(m_videopalette, index, MAKE_RGB(index, index, index)); // allocate video frames for (int index = 0; index < ARRAY_LENGTH(m_frame); index++) { // first allocate a YUY16 bitmap at 2x the height frame_data &frame = m_frame[index]; frame.m_bitmap.allocate(m_width, m_height * 2); frame.m_bitmap.set_palette(m_videopalette); fillbitmap_yuy16(frame.m_bitmap, 40, 109, 240); // make a copy of the bitmap that clips out the VBI and horizontal blanking areas frame.m_visbitmap.wrap(&frame.m_bitmap.pix16(44, frame.m_bitmap.width() * 8 / 720), frame.m_bitmap.width() - 2 * frame.m_bitmap.width() * 8 / 720, frame.m_bitmap.height() - 44, frame.m_bitmap.rowpixels()); frame.m_visbitmap.set_palette(m_videopalette); } // allocate an empty frame of the same size m_emptyframe.allocate(m_width, m_height * 2); m_emptyframe.set_palette(m_videopalette); fillbitmap_yuy16(m_emptyframe, 0, 128, 128); // allocate texture for rendering m_videoenable = true; m_videotex = machine().render().texture_alloc(); if (m_videotex == NULL) fatalerror("Out of memory allocating video texture\n"); // allocate overlay m_overenable = overlay_configured(); if (m_overenable) { // bind our handlers m_overupdate_ind16.bind_relative_to(*owner()); m_overupdate_rgb32.bind_relative_to(*owner()); // configure bitmap formats bitmap_format format = !m_overupdate_ind16.isnull() ? BITMAP_FORMAT_IND16 : BITMAP_FORMAT_RGB32; texture_format texformat = !m_overupdate_ind16.isnull() ? TEXFORMAT_PALETTEA16 : TEXFORMAT_ARGB32; // allocate overlay bitmaps for (int index = 0; index < ARRAY_LENGTH(m_overbitmap); index++) { m_overbitmap[index].set_format(format, texformat); m_overbitmap[index].set_palette(machine().palette); m_overbitmap[index].resize(m_overwidth, m_overheight); } // allocate overlay texture m_overtex = machine().render().texture_alloc(); if (m_overtex == NULL) fatalerror("Out of memory allocating overlay texture\n"); } }
); if (!p) moves.nMoves++; else if (p->whatColor() != color) moves.nMoves++; } } return; } const POSITIONOFFSET kingOffset[] = { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1}, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } }; const int nKingOffsets = ARRAY_LENGTH(kingOffset); const POSITIONOFFSET knightOffset[] = { { 1, 2 }, { 2, 1}, { -1, 2 }, { 2, -1 }, { 1, -2}, { -2, 1 }, { -1, -2 }, { -2, -1 } }; const int nKnightOffsets = ARRAY_LENGTH(knightOffset); void PAWN::promote(PIECETYPE promoteType) { switch (promoteType) { case TYPEQUEEN: promotePiece = new QUEEN(whatColor()); break; case TYPEROOK:
//---------------------------------------------------------------------------// D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsPipelineState::GetNativePSOdesc() { D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc; memset(&psoDesc, 0u, sizeof(D3D12_GRAPHICS_PIPELINE_STATE_DESC)); // SHADER BYTECODES D3D12_SHADER_BYTECODE* shaderDescs[]{ &psoDesc.VS, &psoDesc.PS, &psoDesc.DS, &psoDesc.HS, &psoDesc.GS }; ASSERT(ARRAY_LENGTH(shaderDescs) == (uint)ShaderStage::NUM_NO_COMPUTE); if (myGpuProgramPipeline != nullptr) { for (uint i = 0u; i < (uint)ShaderStage::NUM_NO_COMPUTE; ++i) { if (nullptr == myGpuProgramPipeline->myGpuPrograms[i]) continue; (*shaderDescs[i]) = myGpuProgramPipeline->myGpuPrograms[i]->getNativeByteCode(); } } // ROOT SIGNATURE psoDesc.pRootSignature = myGpuProgramPipeline->GetRootSignature(); // BLEND DESC D3D12_BLEND_DESC& blendDesc = psoDesc.BlendState; memset(&blendDesc, 0u, sizeof(D3D12_BLEND_DESC)); blendDesc.AlphaToCoverageEnable = myBlendState.getAlphaToCoverageEnabled(); blendDesc.IndependentBlendEnable = myBlendState.getBlendStatePerRT(); uint rtCount = blendDesc.IndependentBlendEnable ? Constants::kMaxNumRenderTargets : 1u; for (uint rt = 0u; rt < rtCount; ++rt) { D3D12_RENDER_TARGET_BLEND_DESC& rtBlendDesc = blendDesc.RenderTarget[rt]; memset(&rtBlendDesc, 0u, sizeof(D3D12_RENDER_TARGET_BLEND_DESC)); rtBlendDesc.BlendEnable = myBlendState.myBlendEnabled[rt]; rtBlendDesc.BlendOp = Adapter::toNativeType(myBlendState.myBlendOp[rt]); rtBlendDesc.BlendOpAlpha = Adapter::toNativeType(myBlendState.myBlendOpAlpha[rt]); rtBlendDesc.DestBlend = Adapter::toNativeType(myBlendState.myDestBlend[rt]); rtBlendDesc.DestBlendAlpha = Adapter::toNativeType(myBlendState.myDestBlendAlpha[rt]); // FEATURE: Add support for LogicOps? rtBlendDesc.LogicOp = D3D12_LOGIC_OP_NOOP; rtBlendDesc.LogicOpEnable = false; if (myBlendState.myRTwriteMask[rt] & 0xFFFFFF > 0u) { rtBlendDesc.RenderTargetWriteMask = D3D12_COLOR_WRITE_ENABLE_ALL; } else { const bool red = (myBlendState.myRTwriteMask[rt] & 0xFF000000) > 0u; const bool green = (myBlendState.myRTwriteMask[rt] & 0x00FF0000) > 0u; const bool blue = (myBlendState.myRTwriteMask[rt] & 0x0000FF00) > 0u; const bool alpha = (myBlendState.myRTwriteMask[rt] & 0x000000FF) > 0u; rtBlendDesc.RenderTargetWriteMask |= red ? D3D12_COLOR_WRITE_ENABLE_RED : 0u; rtBlendDesc.RenderTargetWriteMask |= green ? D3D12_COLOR_WRITE_ENABLE_GREEN : 0u; rtBlendDesc.RenderTargetWriteMask |= blue ? D3D12_COLOR_WRITE_ENABLE_BLUE : 0u; rtBlendDesc.RenderTargetWriteMask |= alpha ? D3D12_COLOR_WRITE_ENABLE_ALPHA : 0u; } } // STREAM OUTPUT // FEATURE: Add support for StreamOutput D3D12_STREAM_OUTPUT_DESC& streamOutDesc = psoDesc.StreamOutput; memset(&streamOutDesc, 0u, sizeof(D3D12_STREAM_OUTPUT_DESC)); // SAMPLE MASK / DESC psoDesc.SampleMask = ~0u; psoDesc.SampleDesc.Count = 1u; // RASTERIZER STATE D3D12_RASTERIZER_DESC& rasterizerDesc = psoDesc.RasterizerState; memset(&rasterizerDesc, 0u, sizeof(D3D12_RASTERIZER_DESC)); rasterizerDesc.AntialiasedLineEnable = false; rasterizerDesc.ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF; rasterizerDesc.FillMode = Adapter::toNativeType(myFillMode); rasterizerDesc.CullMode = Adapter::toNativeType(myCullMode); rasterizerDesc.MultisampleEnable = false; rasterizerDesc.FrontCounterClockwise = myWindingOrder == WindingOrder::CCW; rasterizerDesc.DepthBias = 0; rasterizerDesc.DepthBiasClamp = 0; rasterizerDesc.SlopeScaledDepthBias = 0; rasterizerDesc.DepthClipEnable = false; // DEPTH STENCIL STATE D3D12_DEPTH_STENCIL_DESC& dsState = psoDesc.DepthStencilState; dsState.DepthEnable = myDepthStencilState.myDepthTestEnabled; dsState.DepthWriteMask = myDepthStencilState.myDepthWriteEnabled ? D3D12_DEPTH_WRITE_MASK_ALL : D3D12_DEPTH_WRITE_MASK_ZERO; dsState.DepthFunc = Adapter::toNativeType(myDepthStencilState.myDepthCompFunc); dsState.StencilEnable = myDepthStencilState.myStencilEnabled; dsState.StencilReadMask = static_cast<uint8>(myDepthStencilState.myStencilReadMask); dsState.StencilWriteMask = static_cast<uint8>(myDepthStencilState.myStencilWriteMask[0u]); // FrontFace { D3D12_DEPTH_STENCILOP_DESC& faceDesc = dsState.FrontFace; uint faceIdx = static_cast<uint>(FaceType::FRONT); faceDesc.StencilFunc = Adapter::toNativeType(myDepthStencilState.myStencilCompFunc[faceIdx]); faceDesc.StencilDepthFailOp = Adapter::toNativeType(myDepthStencilState.myStencilDepthFailOp[faceIdx]); faceDesc.StencilFailOp = Adapter::toNativeType(myDepthStencilState.myStencilFailOp[faceIdx]); faceDesc.StencilPassOp = Adapter::toNativeType(myDepthStencilState.myStencilPassOp[faceIdx]); } // BackFace { D3D12_DEPTH_STENCILOP_DESC& faceDesc = dsState.BackFace; uint faceIdx = static_cast<uint>(FaceType::BACK); faceDesc.StencilFunc = Adapter::toNativeType(myDepthStencilState.myStencilCompFunc[faceIdx]); faceDesc.StencilDepthFailOp = Adapter::toNativeType(myDepthStencilState.myStencilDepthFailOp[faceIdx]); faceDesc.StencilFailOp = Adapter::toNativeType(myDepthStencilState.myStencilFailOp[faceIdx]); faceDesc.StencilPassOp = Adapter::toNativeType(myDepthStencilState.myStencilPassOp[faceIdx]); } // INPUT LAYOUT if (myGpuProgramPipeline != nullptr && myGpuProgramPipeline->myGpuPrograms[(uint32)ShaderStage::VERTEX] != nullptr) { const GpuProgram* vertexShader = myGpuProgramPipeline->myGpuPrograms[(uint32)ShaderStage::VERTEX].get(); D3D12_INPUT_LAYOUT_DESC& inputLayout = psoDesc.InputLayout; inputLayout.NumElements = vertexShader->GetNumNativeInputElements(); inputLayout.pInputElementDescs = vertexShader->GetNativeInputElements(); } // IB STRIP CUT VALUE psoDesc.IBStripCutValue = D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_DISABLED; // TOPOLOGY TYPE psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; // NUM RENDER TARGETS psoDesc.NumRenderTargets = myNumRenderTargets; // RTV-FORMATS for (uint i = 0u; i < myNumRenderTargets; ++i) { psoDesc.RTVFormats[i] = RenderCore::GetFormat(myRTVformats[i]); } // DSV FORMAT psoDesc.DSVFormat = RenderCore::GetFormat(myDSVformat); // NODE MASK psoDesc.NodeMask = 0u; return psoDesc; }
void jangou_blitter_device::device_reset() { memset(m_pen_data, 0, ARRAY_LENGTH(m_pen_data)); m_bltflip = false; }
static int recurse_dir(int srcrootlen, const astring *srcdir) { static const osd_dir_entry_type typelist[] = { ENTTYPE_DIR, ENTTYPE_FILE }; int result = 0; int entindex; /* iterate first over directories, then over files */ for (entindex = 0; entindex < ARRAY_LENGTH(typelist) && result == 0; entindex++) { osd_dir_entry_type entry_type = typelist[entindex]; const osd_directory_entry *entry; list_entry **listarray = NULL; list_entry *list = NULL; list_entry *curlist; osd_directory *dir; int found = 0; /* open the directory and iterate through it */ dir = osd_opendir(astring_c(srcdir)); if (dir == NULL) { result = 1; goto error; } /* build up the list of files */ while ((entry = osd_readdir(dir)) != NULL) if (entry->type == entry_type && entry->name[0] != '.') { list_entry *lentry = (list_entry *)malloc(sizeof(*lentry)); lentry->name = astring_dupc(entry->name); lentry->next = list; list = lentry; found++; } /* close the directory */ osd_closedir(dir); /* skip if nothing found */ if (found == 0) continue; /* allocate memory for sorting */ listarray = (list_entry **)malloc(sizeof(list_entry *) * found); found = 0; for (curlist = list; curlist != NULL; curlist = curlist->next) listarray[found++] = curlist; /* sort the list */ qsort(listarray, found, sizeof(listarray[0]), compare_list_entries); /* rebuild the list */ list = NULL; while (--found >= 0) { listarray[found]->next = list; list = listarray[found]; } free(listarray); /* iterate through each file */ for (curlist = list; curlist != NULL && result == 0; curlist = curlist->next) { astring *srcfile; /* build the source filename */ srcfile = astring_alloc(); astring_printf(srcfile, "%s%c%s", astring_c(srcdir), PATH_SEPARATOR[0], astring_c(curlist->name)); /* if we have a file, output it */ if (entry_type == ENTTYPE_FILE) { /* make sure we care, first */ if (core_filename_ends_with(astring_c(curlist->name), ".c")) { tagmap *depend_map = tagmap_alloc(); tagmap_entry *map_entry; file_entry *file; astring *target; int taghash; /* find dependencies */ file = compute_dependencies(srcrootlen, srcfile); recurse_dependencies(file, depend_map); /* convert the target from source to object (makes assumptions about rules) */ target = astring_dup(file->name); astring_replacec(target, 0, "src/", "$(OBJ)/"); astring_replacec(target, 0, ".c", ".o"); printf("\n%s : \\\n", astring_c(target)); /* iterate over the hashed dependencies and output them as well */ for (taghash = 0; taghash < TAGMAP_HASH_SIZE; taghash++) for (map_entry = depend_map->table[taghash]; map_entry != NULL; map_entry = map_entry->next) printf("\t%s \\\n", astring_c((astring *)map_entry->object)); astring_free(target); tagmap_free(depend_map); } } /* if we have a directory, recurse */ else result = recurse_dir(srcrootlen, srcfile); /* free memory for the names */ astring_free(srcfile); } /* free all the allocated entries */ while (list != NULL) { list_entry *next = list->next; astring_free((astring *)list->name); free(list); list = next; } } error: return result; }
static void pr8210_execute(const device_config *laserdisc, int command) { static const UINT8 digits[10] = { 0x01, 0x11, 0x09, 0x19, 0x05, 0x15, 0x0d, 0x1d, 0x03, 0x13 }; switch (command) { case CMD_SCAN_REVERSE: if (pr8210_command_buffer_in == pr8210_command_buffer_out || pr8210_command_buffer_in == (pr8210_command_buffer_out + 1) % ARRAY_LENGTH(pr8210_command_buffer)) { pr8210_add_command(0x1c); playing = TRUE; } break; case CMD_STEP_REVERSE: pr8210_add_command(0x12); playing = FALSE; break; case CMD_SLOW_REVERSE: pr8210_add_command(0x02); playing = TRUE; break; case CMD_FAST_REVERSE: if (pr8210_command_buffer_in == pr8210_command_buffer_out || pr8210_command_buffer_in == (pr8210_command_buffer_out + 1) % ARRAY_LENGTH(pr8210_command_buffer)) { pr8210_add_command(0x0c); playing = TRUE; } break; case CMD_SCAN_FORWARD: if (pr8210_command_buffer_in == pr8210_command_buffer_out || pr8210_command_buffer_in == (pr8210_command_buffer_out + 1) % ARRAY_LENGTH(pr8210_command_buffer)) { pr8210_add_command(0x08); playing = TRUE; } break; case CMD_STEP_FORWARD: pr8210_add_command(0x04); playing = FALSE; break; case CMD_SLOW_FORWARD: pr8210_add_command(0x18); playing = TRUE; break; case CMD_FAST_FORWARD: if (pr8210_command_buffer_in == pr8210_command_buffer_out || pr8210_command_buffer_in == (pr8210_command_buffer_out + 1) % ARRAY_LENGTH(pr8210_command_buffer)) { pr8210_add_command(0x10); playing = TRUE; } break; case CMD_PLAY: pr8210_add_command(0x14); playing = TRUE; break; case CMD_PAUSE: pr8210_add_command(0x0a); playing = FALSE; break; case CMD_FRAME_TOGGLE: pr8210_add_command(0x0b); break; case CMD_CHAPTER_TOGGLE: pr8210_add_command(0x06); break; case CMD_CH1_TOGGLE: pr8210_add_command(0x0e); break; case CMD_CH2_TOGGLE: pr8210_add_command(0x16); break; case CMD_0: case CMD_1: case CMD_2: case CMD_3: case CMD_4: case CMD_5: case CMD_6: case CMD_7: case CMD_8: case CMD_9: pr8210_add_command(digits[command - CMD_0]); break; case CMD_SEARCH: pr8210_add_command(0x1a); playing = FALSE; break; } }
//================================================================================================== // PIXGetCounterInfo //================================================================================================== BOOL WINAPI PIXGetCounterInfo( DWORD* pdwReturnCounters, PIXCOUNTERINFO** ppCounterInfoList ) { *pdwReturnCounters = ARRAY_LENGTH(pixCounterSet); *ppCounterInfoList = &pixCounterSet[0]; return TRUE; }
static int parse_options(int argc, char *argv[], options *opts) { int pending_base = FALSE; int pending_arch = FALSE; int pending_mode = FALSE; int curarch; int numrows; int arg; memset(opts, 0, sizeof(*opts)); // loop through arguments for (arg = 1; arg < argc; arg++) { char *curarg = argv[arg]; // is it a switch? if (curarg[0] == '-') { if (pending_base || pending_arch || pending_mode) goto usage; if (tolower((UINT8)curarg[1]) == 'a') pending_arch = TRUE; else if (tolower((UINT8)curarg[1]) == 'b') pending_base = TRUE; else if (tolower((UINT8)curarg[1]) == 'f') opts->flipped = TRUE; else if (tolower((UINT8)curarg[1]) == 'l') opts->lower = TRUE; else if (tolower((UINT8)curarg[1]) == 'm') pending_mode = TRUE; else if (tolower((UINT8)curarg[1]) == 'n') opts->norawbytes = TRUE; else if (tolower((UINT8)curarg[1]) == 'u') opts->upper = TRUE; else goto usage; } // base PC else if (pending_base) { int result; if (curarg[0] == '0' && curarg[1] == 'x') result = sscanf(&curarg[2], "%x", &opts->basepc); else if (curarg[0] == '$') result = sscanf(&curarg[1], "%x", &opts->basepc); else result = sscanf(&curarg[0], "%x", &opts->basepc); if (result != 1) goto usage; pending_base = FALSE; } // mode else if (pending_mode) { if (sscanf(curarg, "%d", &opts->mode) != 1) goto usage; pending_mode = FALSE; } // architecture else if (pending_arch) { for (curarch = 0; curarch < ARRAY_LENGTH(dasm_table); curarch++) if (core_stricmp(curarg, dasm_table[curarch].name) == 0) break; if (curarch == ARRAY_LENGTH(dasm_table)) goto usage; opts->dasm = &dasm_table[curarch]; pending_arch = FALSE; } // filename else if (opts->filename == NULL) opts->filename = curarg; // fail else goto usage; } // if we have a dangling option, error if (pending_base || pending_arch || pending_mode) goto usage; // if no file or no architecture, fail if (opts->filename == NULL || opts->dasm == NULL) goto usage; return 0; usage: printf("Usage: %s <filename> -arch <architecture> [-basepc <pc>] \n", argv[0]); printf(" [-mode <n>] [-norawbytes] [-flipped] [-upper] [-lower]\n"); printf("\n"); printf("Supported architectures:"); numrows = (ARRAY_LENGTH(dasm_table) + 6) / 7; for (curarch = 0; curarch < numrows * 7; curarch++) { int row = curarch / 7; int col = curarch % 7; int index = col * numrows + row; if (col == 0) printf("\n "); printf("%-11s", (index < ARRAY_LENGTH(dasm_table)) ? dasm_table[index].name : ""); } printf("\n"); return 1; };
INLINE void pr8210_add_command(UINT8 command) { pr8210_command_buffer[pr8210_command_buffer_in++ % ARRAY_LENGTH(pr8210_command_buffer)] = (command & 0x1f) | 0x20; pr8210_command_buffer[pr8210_command_buffer_in++ % ARRAY_LENGTH(pr8210_command_buffer)] = 0x00 | 0x20; }
#define OP_NOP 0 #define OP_VIBRATE 1 #define OP_SHOW_NOTCONNECTED 2 #define OP_FIND_ME 3 #define OP_UNREAD_MESSAGE_COUNT 4 #define OP_CURRENT_HR 5 static char unread_sms_buffer[4]; static char current_hr_buffer[4]; static char bt_notification_delay = 0; static const uint32_t const disconnect_segments[] = { 300, 300, 300, 300, 300 }; VibePattern disconnecte_pat = { .durations = disconnect_segments, .num_segments = ARRAY_LENGTH(disconnect_segments), }; static void inbox_received_handler(DictionaryIterator *iterator, void *context) { // Get the first pair Tuple *t = dict_read_first(iterator); // Process all pairs present while(t != NULL) { // Process this pair's key APP_LOG(APP_LOG_LEVEL_INFO, "Got opcode: %d, value: %d", (int)t->key, (int)t->value->int32); switch(t->key) { case OP_VIBRATE: // Trigger vibration vibes_short_pulse();
void TestDx::testDxCmdLineArgs() { string progName("TestDxCmdLineArgs"); int defaultMainPort(9999); int defaultRemotePort(5555); string defaultHost("thisHost"); string defaultSciDataDir("fooDir"); string defaultSciDataPrefix("nss.p10"); bool defaultBroadcast(false); bool defaultNoUi(false); bool defaultVaryOutputData(false); string defaultDxName("dxsim33"); bool defaultRemoteMode(false); DxCmdLineArgs cmdArgs(progName, defaultMainPort, defaultRemotePort, defaultHost, defaultSciDataDir, defaultSciDataPrefix, defaultBroadcast, defaultNoUi, defaultVaryOutputData, defaultDxName, defaultRemoteMode); // test usage message output cmdArgs.usage(); cerr << endl; // check the defaults cu_assert (cmdArgs.getMainPort() == 9999); cu_assert (cmdArgs.getRemotePort() == 5555); cu_assert (cmdArgs.getHostName() == "thisHost"); cu_assert (cmdArgs.getSciDataDir() == "fooDir"); cu_assert (cmdArgs.getSciDataPrefix() == "nss.p10"); cu_assert (! cmdArgs.getBroadcast()); cu_assert (! cmdArgs.getNoUi()); cu_assert (! cmdArgs.getVaryOutputData()); cu_assert (cmdArgs.getDxName() == "dxsim33"); cu_assert (! cmdArgs.getRemoteMode()); // try setting good parameters const char *argv[] = { "ProgName", "-host", "matrix", "-mainport", "8888", "-remport", "9999", "-sddir", "../scienceData", "-sdprefix", "nss.p6", "-broadcast", "-name", "dxsim127", "-remote", "-noui", "-vary" }; const int argc = ARRAY_LENGTH(argv); // verify that everything parses cu_assert(cmdArgs.parseArgs(argc, const_cast<char **>(argv))); // check the values cu_assert (cmdArgs.getHostName() == "matrix"); cu_assert (cmdArgs.getMainPort() == 8888); cu_assert (cmdArgs.getRemotePort() == 9999); cu_assert (cmdArgs.getSciDataDir() == "../scienceData"); cu_assert (cmdArgs.getSciDataPrefix() == "nss.p6"); cu_assert (cmdArgs.getBroadcast()); cu_assert (cmdArgs.getDxName() == "dxsim127"); cu_assert (cmdArgs.getRemoteMode()); cu_assert (cmdArgs.getNoUi()); cu_assert (cmdArgs.getVaryOutputData()); cout << "Test a bad port number:" << endl; const char *argvBadPort[] = { "ProgName", "-host", "matrix", "-mainport", "badportnumber", }; const int argcBadPort = ARRAY_LENGTH(argvBadPort); cu_assert(cmdArgs.parseArgs(argcBadPort, const_cast<char **>(argvBadPort)) == false); }
int parse_file(const char *srcfile) { // read source file void *buffer; UINT32 length; file_error filerr = core_fload(srcfile, &buffer, &length); if (filerr != FILERR_NONE) { fprintf(stderr, "Unable to read source file '%s'\n", srcfile); return 1; } // rip through it to find all drivers char *srcptr = (char *)buffer; char *endptr = srcptr + length; int linenum = 1; bool in_comment = false; while (srcptr < endptr) { char c = *srcptr++; // count newlines if (c == 13 || c == 10) { if (c == 13 && *srcptr == 10) srcptr++; linenum++; continue; } // skip any spaces if (isspace(c)) continue; // look for end of C comment if (in_comment && c == '*' && *srcptr == '/') { srcptr++; in_comment = false; continue; } // skip anything else inside a C comment if (in_comment) continue; // look for start of C comment if (c == '/' && *srcptr == '*') { srcptr++; in_comment = true; continue; } // if we hit a C++ comment, scan to the end of line if (c == '/' && *srcptr == '/') { while (srcptr < endptr && *srcptr != 13 && *srcptr != 10) srcptr++; continue; } // look for an import directive if (c == '#') { char filename[256]; filename[0] = 0; for (int pos = 0; srcptr < endptr && pos < ARRAY_LENGTH(filename) - 1 && !isspace(*srcptr); pos++) { filename[pos] = *srcptr++; filename[pos+1] = 0; } fprintf(stderr, "Importing drivers from '%s'\n", filename); parse_file(filename); continue; } if (c == '!') { char drivname[256]; drivname[0] = 0; for (int pos = 0; srcptr < endptr && pos < ARRAY_LENGTH(drivname) - 1 && !isspace(*srcptr); pos++) { drivname[pos] = *srcptr++; drivname[pos+1] = 0; } fprintf(stderr, "Place driver '%s' to ignore list\n", drivname); char *name = (char *)malloc(strlen(drivname) + 1); strcpy(name, drivname); ignorelst[ignorecount++] = name; continue; } // otherwise treat as a driver name char drivname[32]; drivname[0] = 0; srcptr--; for (int pos = 0; srcptr < endptr && pos < ARRAY_LENGTH(drivname) - 1 && !isspace(*srcptr); pos++) { drivname[pos] = *srcptr++; drivname[pos+1] = 0; } // verify the name as valid for (char *drivch = drivname; *drivch != 0; drivch++) { if ((*drivch >= 'a' && *drivch <= 'z') || (*drivch >= '0' && *drivch <= '9') || *drivch == '_') continue; fprintf(stderr, "%s:%d - Invalid character '%c' in driver \"%s\"\n", srcfile, linenum, *drivch, drivname); return 1; } // add it to the list if(!isignored(drivname)) { char *name = (char *)malloc(strlen(drivname) + 1); strcpy(name, drivname); drivlist[drivcount++] = name; } } osd_free(buffer); return 0; }
int core_fgetc(core_file *file) { int result; /* refresh buffer, if necessary */ if (file->back_char_head == file->back_char_tail) { utf16_char utf16_buffer[UTF16_CHAR_MAX]; char utf8_buffer[UTF8_CHAR_MAX]; char default_buffer[16]; unicode_char uchar = (unicode_char) ~0; int readlen, charlen; /* do we need to check the byte order marks? */ if (file->offset == 0) { UINT8 bom[4]; int pos = 0; if (core_fread(file, bom, 4) == 4) { if (bom[0] == 0xef && bom[1] == 0xbb && bom[2] == 0xbf) { file->text_type = TFT_UTF8; pos = 3; } else if (bom[0] == 0x00 && bom[1] == 0x00 && bom[2] == 0xfe && bom[3] == 0xff) { file->text_type = TFT_UTF32BE; pos = 4; } else if (bom[0] == 0xff && bom[1] == 0xfe && bom[2] == 0x00 && bom[3] == 0x00) { file->text_type = TFT_UTF32LE; pos = 4; } else if (bom[0] == 0xfe && bom[1] == 0xff) { file->text_type = TFT_UTF16BE; pos = 2; } else if (bom[0] == 0xff && bom[1] == 0xfe) { file->text_type = TFT_UTF16LE; pos = 2; } else { file->text_type = TFT_OSD; pos = 0; } } core_fseek(file, pos, SEEK_SET); } /* fetch the next character */ switch (file->text_type) { default: case TFT_OSD: readlen = core_fread(file, default_buffer, sizeof(default_buffer)); if (readlen > 0) { charlen = osd_uchar_from_osdchar(&uchar, default_buffer, readlen / sizeof(default_buffer[0])); core_fseek(file, (INT64) (charlen * sizeof(default_buffer[0])) - readlen, SEEK_CUR); } break; case TFT_UTF8: readlen = core_fread(file, utf8_buffer, sizeof(utf8_buffer)); if (readlen > 0) { charlen = uchar_from_utf8(&uchar, utf8_buffer, readlen / sizeof(utf8_buffer[0])); core_fseek(file, (INT64) (charlen * sizeof(utf8_buffer[0])) - readlen, SEEK_CUR); } break; case TFT_UTF16BE: readlen = core_fread(file, utf16_buffer, sizeof(utf16_buffer)); if (readlen > 0) { charlen = uchar_from_utf16be(&uchar, utf16_buffer, readlen / sizeof(utf16_buffer[0])); core_fseek(file, (INT64) (charlen * sizeof(utf16_buffer[0])) - readlen, SEEK_CUR); } break; case TFT_UTF16LE: readlen = core_fread(file, utf16_buffer, sizeof(utf16_buffer)); if (readlen > 0) { charlen = uchar_from_utf16le(&uchar, utf16_buffer, readlen / sizeof(utf16_buffer[0])); core_fseek(file, (INT64) (charlen * sizeof(utf16_buffer[0])) - readlen, SEEK_CUR); } break; case TFT_UTF32BE: if (core_fread(file, &uchar, sizeof(uchar)) == sizeof(uchar)) uchar = BIG_ENDIANIZE_INT32(uchar); break; case TFT_UTF32LE: if (core_fread(file, &uchar, sizeof(uchar)) == sizeof(uchar)) uchar = LITTLE_ENDIANIZE_INT32(uchar); break; } if (uchar != ~0) { /* place the new character in the ring buffer */ file->back_char_head = 0; file->back_char_tail = utf8_from_uchar(file->back_chars, ARRAY_LENGTH(file->back_chars), uchar); /* assert(file->back_char_tail != -1);*/ } } /* now read from the ring buffer */ if (file->back_char_head != file->back_char_tail) { result = file->back_chars[file->back_char_head++]; file->back_char_head %= ARRAY_LENGTH(file->back_chars); } else result = EOF; return result; }
static void output_report(astring &dirname, astring &tempheader, astring &tempfooter, summary_file *filelist) { summary_file *buckethead[BUCKET_COUNT], **buckettailptr[BUCKET_COUNT]; summary_file *curfile; astring title("MAME Regressions"); astring tempname; int listnum, bucknum; core_file *indexfile; int count = 0, total; /* initialize the lists */ for (bucknum = 0; bucknum < BUCKET_COUNT; bucknum++) { buckethead[bucknum] = NULL; buckettailptr[bucknum] = &buckethead[bucknum]; } /* compute the total number of files */ total = 0; for (curfile = filelist; curfile != NULL; curfile = curfile->next) total++; /* first bucketize the games */ for (curfile = filelist; curfile != NULL; curfile = curfile->next) { int statcount[STATUS_COUNT] = { 0 }; int bucket = BUCKET_UNKNOWN; int unique_codes = 0; int first_valid; /* print status */ if (++count % 100 == 0) fprintf(stderr, "Processing file %d/%d\n", count, total); /* find the first valid entry */ for (first_valid = 0; curfile->status[first_valid] == STATUS_NOT_PRESENT; first_valid++) ; /* do we need to output anything? */ for (listnum = first_valid; listnum < list_count; listnum++) if (statcount[curfile->status[listnum]]++ == 0) unique_codes++; /* were we consistent? */ if (unique_codes == 1) { /* were we consistently ok? */ if (curfile->status[first_valid] == STATUS_SUCCESS) bucket = compare_screenshots(curfile); /* must have been consistently erroring */ else bucket = BUCKET_CONSISTENT_ERROR; } /* ok, we're not consistent; could be a number of things */ else { /* were we ok at the start and end but not in the middle? */ if (curfile->status[first_valid] == STATUS_SUCCESS && curfile->status[list_count - 1] == STATUS_SUCCESS) bucket = BUCKET_GOOD_BUT_CHANGED; /* did we go from good to bad? */ else if (curfile->status[first_valid] == STATUS_SUCCESS) bucket = BUCKET_REGRESSED; /* did we go from bad to good? */ else if (curfile->status[list_count - 1] == STATUS_SUCCESS) bucket = BUCKET_IMPROVED; /* must have had multiple errors */ else bucket = BUCKET_MULTI_ERROR; } /* add us to the appropriate list */ *buckettailptr[bucket] = curfile; buckettailptr[bucket] = &curfile->next; } /* terminate all the lists */ for (bucknum = 0; bucknum < BUCKET_COUNT; bucknum++) *buckettailptr[bucknum] = NULL; /* output header */ tempname.printf("%s" PATH_SEPARATOR "%s", dirname.cstr(), "index.html"); indexfile = create_file_and_output_header(tempname, tempheader, title); if (indexfile == NULL) { fprintf(stderr, "Error creating file '%s'\n", tempname.cstr()); return; } /* iterate over buckets and output them */ for (bucknum = 0; bucknum < ARRAY_LENGTH(bucket_output_order); bucknum++) { int curbucket = bucket_output_order[bucknum]; if (buckethead[curbucket] != NULL) { fprintf(stderr, "Outputting bucket: %s\n", bucket_name[curbucket]); append_driver_list_table(bucket_name[curbucket], dirname, indexfile, buckethead[curbucket], tempheader, tempfooter); } } /* output footer */ output_footer_and_close_file(indexfile, tempfooter, title); }
int core_ungetc(int c, core_file *file) { file->back_chars[file->back_char_tail++] = (char) c; file->back_char_tail %= ARRAY_LENGTH(file->back_chars); return c; }
MCFG_QUANTUM_TIME(attotime::from_hz(60)) MCFG_MACHINE_START( c64 ) MCFG_MACHINE_RESET( c64 ) /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) MCFG_SCREEN_REFRESH_RATE(VIC6567_VRETRACERATE) MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) /* not accurate */ MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) MCFG_SCREEN_SIZE(VIC6567_COLUMNS, VIC6567_LINES) MCFG_SCREEN_VISIBLE_AREA(0, VIC6567_VISIBLECOLUMNS - 1, 0, VIC6567_VISIBLELINES - 1) MCFG_SCREEN_UPDATE( c64 ) MCFG_PALETTE_INIT( c64 ) MCFG_PALETTE_LENGTH(ARRAY_LENGTH(c64_palette) / 3) MCFG_VIC2_ADD("vic2", c64_vic2_ntsc_intf) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") MCFG_SOUND_ADD("sid6581", SID6581, VIC6567_CLOCK) MCFG_SOUND_CONFIG(c64_sound_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) MCFG_SOUND_ADD("dac", DAC, 0) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) /* quickload */ MCFG_QUICKLOAD_ADD("quickload", cbm_c64, "p00,prg,t64", CBM_QUICKLOAD_DELAY_SECONDS) /* cassette */
void handle_init(void) { window = window_create(); window_stack_push(window, true /* Animated */); window_set_background_color(window, GColorBlack); Layer *window_layer = window_get_root_layer(window); // Setup weather bar Layer *weather_holder = layer_create(GRect(0, 0, 144, 50)); layer_add_child(window_layer, weather_holder); icon_layer = bitmap_layer_create(GRect(8, 0, 40, 40)); layer_add_child(weather_holder, bitmap_layer_get_layer(icon_layer)); temp_layer = text_layer_create(GRect(32, 3, 144 - 40, 28)); text_layer_set_text_color(temp_layer, GColorWhite); text_layer_set_background_color(temp_layer, GColorClear); text_layer_set_font(temp_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD)); text_layer_set_text_alignment(temp_layer, GTextAlignmentRight); layer_add_child(weather_holder, text_layer_get_layer(temp_layer)); // Initialize date & time text Layer *date_holder = layer_create(GRect(0, 52, 144, 94)); layer_add_child(window_layer, date_holder); ResHandle roboto_21 = resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21); text_day_layer = text_layer_create(GRect(8, 0, 144-8, 25)); text_layer_set_text_color(text_day_layer, GColorWhite); text_layer_set_background_color(text_day_layer, GColorClear); text_layer_set_font(text_day_layer, fonts_load_custom_font(roboto_21)); layer_add_child(date_holder, text_layer_get_layer(text_day_layer)); text_date_layer = text_layer_create(GRect(8, 21, 144-8, 25)); text_layer_set_text_color(text_date_layer, GColorWhite); text_layer_set_background_color(text_date_layer, GColorClear); text_layer_set_font(text_date_layer, fonts_load_custom_font(roboto_21)); layer_add_child(date_holder, text_layer_get_layer(text_date_layer)); line_layer = layer_create(GRect(8, 51, 144-16, 2)); layer_set_update_proc(line_layer, line_layer_update_callback); layer_add_child(date_holder, line_layer); ResHandle roboto_49 = resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_49); text_time_layer = text_layer_create(GRect(7, 45, 144-7, 49)); text_layer_set_text_color(text_time_layer, GColorWhite); text_layer_set_background_color(text_time_layer, GColorClear); text_layer_set_font(text_time_layer, fonts_load_custom_font(roboto_49)); layer_add_child(date_holder, text_layer_get_layer(text_time_layer)); // Setup messaging const int inbound_size = 64; const int outbound_size = 64; app_message_open(inbound_size, outbound_size); Tuplet initial_values[] = { TupletInteger(WEATHER_ICON_KEY, (uint8_t) 13), TupletCString(WEATHER_TEMPERATURE_KEY, ""), TupletInteger(INVERT_COLOR_KEY, persist_read_bool(INVERT_COLOR_KEY)), }; app_sync_init(&sync, sync_buffer, sizeof(sync_buffer), initial_values, ARRAY_LENGTH(initial_values), sync_tuple_changed_callback, NULL, NULL); // FIXME testing code battery_text_layer = text_layer_create(GRect(0, 75, 144-8, 30)); text_layer_set_text_color(battery_text_layer, GColorWhite); text_layer_set_background_color(battery_text_layer, GColorClear); text_layer_set_font(battery_text_layer, fonts_load_custom_font(roboto_21)); text_layer_set_text_alignment(battery_text_layer, GTextAlignmentRight); layer_add_child(window_layer, text_layer_get_layer(battery_text_layer)); // Subscribe to notifications bluetooth_connection_service_subscribe(bluetooth_connection_changed); tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick); battery_state_service_subscribe(update_battery_state); // Update the battery on launch update_battery_state(battery_state_service_peek()); // TODO: Update display here to avoid blank display on launch? }
static void fix_properties(const bt_bdaddr_t* remote_addr, int num_properties, bt_property_t* properties) { static const bt_uuid_t uuid_zero; /* filled with zeros */ int i; for (i = 0; i < num_properties; ++i) { if (properties[i].type == BT_PROPERTY_SERVICE_RECORD) { /* Bug 1142007: BT_PROPERTY_SERVICE_RECORD returns * * { * .uuid = 0, * .channel = SCN, * .name = "\0" * } * * for every remote service. We replace the UUID with * the one we asked for in |get_remote_service_record|. */ struct get_remote_service_record_params* params; bt_service_record_t* rec; params = fetch_get_remote_service_record_params(remote_addr); if (!params) { ALOGW("no parameters for BT_PROPERTY_SERVICE_RECORD stored"); continue; /* no params stored; send record as-is */ } rec = properties[i].val; if (memcmp(&uuid_zero, &rec->uuid, sizeof(uuid_zero))) { free_get_remote_service_record_params(params); continue; /* record contains non-zero UUID; nothing to fix */ } /* We replace the property's UUID with the one we stored * for |get_remote_service_record|. That will make Gecko * recognize the notification correctly. The channel is * left as it is. We can set an arbitrary string for the * name. * * Remote devices can create their own names for services * they provide. We have no way of knowing them, so we set * the service's name as defined by the SDP spec and use * "\0" for any other service. Applications can at least * detect this case easily and use a generic string. */ memcpy(&rec->uuid, ¶ms->uuid, sizeof(rec->uuid)); strncpy(rec->name, lookup_service_name_by_uuid16( UUID16(rec->uuid.uu[2], rec->uuid.uu[3]), ""), sizeof(rec->name)); rec->name[ARRAY_LENGTH(rec->name) - 1] = '\0'; /* always terminate */ free_get_remote_service_record_params(params); } } }
/* Initialization */ void handle_init( void ) { window = window_create(); window_stack_push( window, true ); Layer *window_layer = window_get_root_layer( window ); // Read persistent data if ( persist_exists( SETTING_STATUS_KEY ) ) { current_status = persist_read_int( SETTING_STATUS_KEY ); } else { current_status = STATUS_ON; } if ( persist_exists( SETTING_WEATHERSTATUS_KEY ) ) { weather_status = persist_read_int( SETTING_WEATHERSTATUS_KEY ); } else { weather_status = WEATHER_ON; } if ( persist_exists( SETTING_LANGUAGE_KEY ) ) { current_language = persist_read_int( SETTING_LANGUAGE_KEY ); } else { current_language = LANG_EN; } if ( persist_exists( SETTING_FORMAT_KEY ) ) { current_format = persist_read_int( SETTING_FORMAT_KEY ); } else { current_format = FORMAT_WEEK; } if ( persist_exists( SETTING_INVERT_KEY ) ) { invert_format = persist_read_int( SETTING_INVERT_KEY ); } else { invert_format = INVERT_ON; } if ( persist_exists( BLUETOOTHVIBE_KEY ) ) { bluetoothvibe_status = persist_read_int( BLUETOOTHVIBE_KEY ); } else { bluetoothvibe_status = BLUETOOTHVIBE_ON; } if ( persist_exists( HOURLYVIBE_KEY ) ) { hourlyvibe_status = persist_read_int( HOURLYVIBE_KEY ); } else { hourlyvibe_status = HOURLYVIBE_ON; } if ( persist_exists( SECS_KEY ) ) { secs_status = persist_read_int( SECS_KEY ); } else { secs_status = SECS_ON; } // Read watchface settings from persistent data or use default values current_status = persist_exists( SETTING_STATUS_KEY ) ? persist_read_int( SETTING_STATUS_KEY ) : STATUS_ON; weather_status = persist_exists( SETTING_WEATHERSTATUS_KEY ) ? persist_read_int( SETTING_WEATHERSTATUS_KEY ) : WEATHER_ON; current_language = persist_exists( SETTING_LANGUAGE_KEY ) ? persist_read_int( SETTING_LANGUAGE_KEY ) : LANG_EN; current_format = persist_exists( SETTING_FORMAT_KEY ) ? persist_read_int( SETTING_FORMAT_KEY ) : FORMAT_WEEK; invert_format = persist_exists( SETTING_INVERT_KEY ) ? persist_read_int( SETTING_INVERT_KEY ) : INVERT_ON; bluetoothvibe_status = persist_exists( BLUETOOTHVIBE_KEY ) ? persist_read_int( BLUETOOTHVIBE_KEY ) : BLUETOOTHVIBE_ON; hourlyvibe_status = persist_exists( HOURLYVIBE_KEY ) ? persist_read_int( HOURLYVIBE_KEY ) : HOURLYVIBE_ON; secs_status = persist_exists( SECS_KEY ) ? persist_read_int( SECS_KEY ) : SECS_ON; // Background image background_image = gbitmap_create_with_resource( RESOURCE_ID_IMAGE_BACKGROUND ); background_layer = bitmap_layer_create( layer_get_frame( window_layer ) ); bitmap_layer_set_bitmap( background_layer, background_image ); layer_add_child( window_layer, bitmap_layer_get_layer( background_layer ) ); // Initial settings Tuplet initial_values[] = { TupletInteger( SETTING_STATUS_KEY, current_status ) , TupletInteger( SETTING_WEATHERSTATUS_KEY, weather_status ) , TupletInteger( SETTING_LANGUAGE_KEY, current_language ) , TupletInteger( SETTING_FORMAT_KEY, current_format ) , TupletInteger( SETTING_INVERT_KEY, invert_format ) , TupletInteger( BLUETOOTHVIBE_KEY, bluetoothvibe_status ) , TupletInteger( HOURLYVIBE_KEY, hourlyvibe_status ) , TupletInteger( SECS_KEY, secs_status ) , TupletInteger( SETTING_ICON_KEY, (uint8_t) 14) , TupletCString( SETTING_TEMPERATURE_KEY, "") }; // Open AppMessage to transfers app_message_open( 256 , 256 ); // Initialize AppSync app_sync_init( &app, sync_buffer , sizeof( sync_buffer ) , initial_values , ARRAY_LENGTH( initial_values ) , tuple_changed_callback , app_error_callback , NULL ); // Perform sync app_sync_set( &app, initial_values, ARRAY_LENGTH( initial_values ) ); appStarted = true; // Adjust GRect for Hours, Minutes and Blink to compensate for missing AM/PM indicator if ( clock_is_24h_style() ) { TIME_RECT.origin.y = TIME_RECT.origin.y + 1; } // Load fonts font_time = fonts_load_custom_font( resource_get_handle( RESOURCE_ID_FONT_LCARS_68 ) ); font_days = fonts_load_custom_font( resource_get_handle( RESOURCE_ID_FONT_LCARS_20 ) ); font_date = fonts_load_custom_font( resource_get_handle( RESOURCE_ID_FONT_LCARS_25 ) ); // Setup time layer text_time_layer = setup_text_layer( TIME_RECT, GTextAlignmentRight, font_time ); #ifdef PBL_COLOR text_layer_set_text_color(text_time_layer, GColorChromeYellow); #endif layer_add_child( window_layer, text_layer_get_layer( text_time_layer ) ); // Setup AM/PM name layer text_ampm_layer = setup_text_layer( AMPM_RECT, GTextAlignmentLeft, font_days ); layer_add_child( window_layer, text_layer_get_layer( text_ampm_layer ) ); // Setup days line layer text_days_layer = setup_text_layer( DAYS_RECT, GTextAlignmentLeft, font_days ); #ifdef PBL_COLOR text_layer_set_text_color(text_days_layer, GColorDarkGray); #endif layer_add_child( window_layer, text_layer_get_layer( text_days_layer ) ); text_layer_set_text( text_days_layer, day_lines[current_language] ); // Setup date layer text_date_layer = setup_text_layer( ( current_status == STATUS_ON ) ? DATE_RECT : OFF_DATE_RECT , GTextAlignmentLeft , font_date ); #ifdef PBL_COLOR text_layer_set_text_color(text_date_layer, GColorChromeYellow); #endif layer_add_child( window_layer, text_layer_get_layer( text_date_layer ) ); // Setup week layer text_week_layer = setup_text_layer( ( current_status == STATUS_ON ) ? WEEK_RECT : OFF_WEEK_RECT , GTextAlignmentLeft , font_date ); #ifdef PBL_COLOR text_layer_set_text_color(text_week_layer, GColorChromeYellow); #endif layer_add_child( window_layer, text_layer_get_layer( text_week_layer ) ); // Setup weather info Layer *weather_holder = layer_create(GRect(0, 0, 144, 168 )); layer_add_child(window_layer, weather_holder); icon_layer = bitmap_layer_create( ( weather_status == WEATHER_ON ) ? ICON_RECT : EMPTY_RECT ); // icon_layer = bitmap_layer_create( ICON_RECT ); layer_add_child(weather_holder, bitmap_layer_get_layer(icon_layer)); temp_layer = setup_text_layer( ( weather_status == WEATHER_ON ) ? TEMP_RECT : EMPTY_RECT , GTextAlignmentLeft , font_days ); //temp_layer = setup_text_layer( TEMP_RECT, GTextAlignmentLeft, font_days ); layer_add_child(weather_holder, text_layer_get_layer(temp_layer)); // Setup battery layer battery_layer = bitmap_layer_create( ( current_status == STATUS_ON ) ? BATT_RECT : EMPTY_RECT ); layer_add_child( window_layer, bitmap_layer_get_layer( battery_layer ) ); // Setup bluetooth layer bluetooth_layer = bitmap_layer_create( ( current_status == STATUS_ON ) ? BT_RECT : EMPTY_RECT ); layer_add_child( window_layer, bitmap_layer_get_layer( bluetooth_layer ) ); // Add inverter layer (indicator for the current day of the week) currentDayLayer = inverter_layer_create( EMPTY_RECT ); layer_add_child( window_layer, inverter_layer_get_layer( currentDayLayer ) ); // Setup seconds name layer text_secs_layer = setup_text_layer( SECS_RECT, GTextAlignmentLeft, font_days ); layer_add_child( window_layer, text_layer_get_layer( text_secs_layer ) ); // Subscribe to services tick_timer_service_subscribe( SECOND_UNIT, handle_tick ); // Force update to avoid a blank screen at startup of the watchface update_time(); }
PALETTE_INIT_MEMBER(unior_state,unior) { palette.set_pen_colors(0, unior_palette, ARRAY_LENGTH(unior_palette)); }
static void window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); static int row_height = 22; int it = 2; const int button_bar_width = 20; const int text_layer_width = 144 - button_bar_width; //Set up Window Action Bar up_arrow_icon = gbitmap_create_with_resource(RESOURCE_ID_ICON_UP_ARROW); down_arrow_icon = gbitmap_create_with_resource(RESOURCE_ID_ICON_DOWN_ARROW); settings_icon = gbitmap_create_with_resource(RESOURCE_ID_ICON_SETTINGS); window_action_bar = action_bar_layer_create(); action_bar_layer_add_to_window(window_action_bar, window); action_bar_layer_set_background_color(window_action_bar, GColorBlack); action_bar_layer_set_click_config_provider(window_action_bar, click_config_provider); action_bar_layer_set_icon(window_action_bar, BUTTON_ID_UP, up_arrow_icon); action_bar_layer_set_icon(window_action_bar, BUTTON_ID_DOWN, down_arrow_icon); action_bar_layer_set_icon(window_action_bar, BUTTON_ID_SELECT, settings_icon); // Area Name Layer area_name_layer = text_layer_create(GRect(0, -2, text_layer_width, 48)); text_layer_set_text_color(area_name_layer, GColorWhite); text_layer_set_background_color(area_name_layer, GColorClear); text_layer_set_font(area_name_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); text_layer_set_text_alignment(area_name_layer, GTextAlignmentCenter); text_layer_set_overflow_mode(area_name_layer, GTextOverflowModeWordWrap); layer_add_child(window_layer, text_layer_get_layer(area_name_layer)); // Weather Description Layer weather_layer = text_layer_create(GRect(0, it++ * row_height, text_layer_width, row_height)); text_layer_set_text_color(weather_layer, GColorWhite); text_layer_set_background_color(weather_layer, GColorClear); text_layer_set_font(weather_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18)); text_layer_set_text_alignment(weather_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(weather_layer)); // Snowfall Layer snowfall_layer = text_layer_create(GRect(0, it++ * row_height, text_layer_width, row_height)); text_layer_set_text_color(snowfall_layer, GColorWhite); text_layer_set_background_color(snowfall_layer, GColorClear); text_layer_set_font(snowfall_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18)); text_layer_set_text_alignment(snowfall_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(snowfall_layer)); // Temperature Layer temps_layer = text_layer_create(GRect(0, it++ * row_height, text_layer_width, row_height)); text_layer_set_text_color(temps_layer, GColorWhite); text_layer_set_background_color(temps_layer, GColorClear); text_layer_set_font(temps_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18)); text_layer_set_text_alignment(temps_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(temps_layer)); // Wind Layer wind_layer = text_layer_create(GRect(0, it++ * row_height, text_layer_width, row_height)); text_layer_set_text_color(wind_layer, GColorWhite); text_layer_set_background_color(wind_layer, GColorClear); text_layer_set_font(wind_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18)); text_layer_set_text_alignment(wind_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(wind_layer)); // Update Time Layer update_layer = text_layer_create(GRect(0, it++ * row_height + 4, text_layer_width, row_height)); text_layer_set_text_color(update_layer, GColorWhite); text_layer_set_background_color(update_layer, GColorClear); text_layer_set_font(update_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD)); text_layer_set_text_alignment(update_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(update_layer)); Tuplet initial_values[] = { TupletInteger(INDEX_KEY, (uint8_t) 0), TupletCString(AREA_NAME_KEY, "Loading..."), TupletCString(WEATHER_DESC_KEY, "Loading..."), TupletCString(WIND_KEY, "Wind: --- @ -- ---"), TupletCString(AREA_TEMPS_KEY, "Temp(--): -- to --"), TupletCString(AREA_SNOWFALL_KEY, "Snow(24h): -- "), TupletCString(UPDATE_TIME_KEY, "Updated @ --:--"), TupletInteger(UNITS_KEY, (uint8_t) 0), }; app_sync_init(&sync, sync_buffer, sizeof(sync_buffer), initial_values, ARRAY_LENGTH(initial_values), sync_tuple_changed_callback, sync_error_callback, NULL); send_cmd(); }
/* * Composite operation with pseudorandom images */ uint32_t test_composite (int testnum, int verbose) { int i; pixman_image_t * src_img; pixman_image_t * dst_img; pixman_region16_t clip; int dst_width, dst_height; int dst_stride; int dst_x, dst_y; int dst_bpp; pixman_op_t op; uint32_t * dst_bits; uint32_t crc32; pixman_format_code_t mask_format, dst_format; pixman_trapezoid_t *traps; int src_x, src_y; int n_traps; static pixman_color_t colors[] = { { 0xffff, 0xffff, 0xffff, 0xffff }, { 0x0000, 0x0000, 0x0000, 0x0000 }, { 0xabcd, 0xabcd, 0x0000, 0xabcd }, { 0x0000, 0x0000, 0x0000, 0xffff }, { 0x0101, 0x0101, 0x0101, 0x0101 }, { 0x7777, 0x6666, 0x5555, 0x9999 }, }; FLOAT_REGS_CORRUPTION_DETECTOR_START (); lcg_srand (testnum); op = RANDOM_ELT (operators); mask_format = RANDOM_ELT (mask_formats); /* Create source image */ if (lcg_rand_n (4) == 0) { src_img = pixman_image_create_solid_fill ( &(colors[lcg_rand_n (ARRAY_LENGTH (colors))])); src_x = 10; src_y = 234; } else { pixman_format_code_t src_format = RANDOM_ELT(formats); int src_bpp = (PIXMAN_FORMAT_BPP (src_format) + 7) / 8; int src_width = lcg_rand_n (MAX_SRC_WIDTH) + 1; int src_height = lcg_rand_n (MAX_SRC_HEIGHT) + 1; int src_stride = src_width * src_bpp + lcg_rand_n (MAX_STRIDE) * src_bpp; uint32_t *bits; src_x = -(src_width / 4) + lcg_rand_n (src_width * 3 / 2); src_y = -(src_height / 4) + lcg_rand_n (src_height * 3 / 2); src_stride = (src_stride + 3) & ~3; bits = (uint32_t *)make_random_bytes (src_stride * src_height); src_img = pixman_image_create_bits ( src_format, src_width, src_height, bits, src_stride); pixman_image_set_destroy_function (src_img, destroy_bits, bits); if (lcg_rand_n (8) == 0) { pixman_box16_t clip_boxes[2]; int n = lcg_rand_n (2) + 1; for (i = 0; i < n; i++) { clip_boxes[i].x1 = lcg_rand_n (src_width); clip_boxes[i].y1 = lcg_rand_n (src_height); clip_boxes[i].x2 = clip_boxes[i].x1 + lcg_rand_n (src_width - clip_boxes[i].x1); clip_boxes[i].y2 = clip_boxes[i].y1 + lcg_rand_n (src_height - clip_boxes[i].y1); if (verbose) { printf ("source clip box: [%d,%d-%d,%d]\n", clip_boxes[i].x1, clip_boxes[i].y1, clip_boxes[i].x2, clip_boxes[i].y2); } } pixman_region_init_rects (&clip, clip_boxes, n); pixman_image_set_clip_region (src_img, &clip); pixman_image_set_source_clipping (src_img, 1); pixman_region_fini (&clip); } image_endian_swap (src_img); } /* Create destination image */ { dst_format = RANDOM_ELT(formats); dst_bpp = (PIXMAN_FORMAT_BPP (dst_format) + 7) / 8; dst_width = lcg_rand_n (MAX_DST_WIDTH) + 1; dst_height = lcg_rand_n (MAX_DST_HEIGHT) + 1; dst_stride = dst_width * dst_bpp + lcg_rand_n (MAX_STRIDE) * dst_bpp; dst_stride = (dst_stride + 3) & ~3; dst_bits = (uint32_t *)make_random_bytes (dst_stride * dst_height); dst_x = -(dst_width / 4) + lcg_rand_n (dst_width * 3 / 2); dst_y = -(dst_height / 4) + lcg_rand_n (dst_height * 3 / 2); dst_img = pixman_image_create_bits ( dst_format, dst_width, dst_height, dst_bits, dst_stride); image_endian_swap (dst_img); } /* Create traps */ { int i; n_traps = lcg_rand_n (25); traps = fence_malloc (n_traps * sizeof (pixman_trapezoid_t)); for (i = 0; i < n_traps; ++i) { pixman_trapezoid_t *t = &(traps[i]); t->top = random_fixed (MAX_DST_HEIGHT) - MAX_DST_HEIGHT / 2; t->bottom = t->top + random_fixed (MAX_DST_HEIGHT); t->left.p1.x = random_fixed (MAX_DST_WIDTH) - MAX_DST_WIDTH / 2; t->left.p1.y = t->top - random_fixed (50); t->left.p2.x = random_fixed (MAX_DST_WIDTH) - MAX_DST_WIDTH / 2; t->left.p2.y = t->bottom + random_fixed (50); t->right.p1.x = t->left.p1.x + random_fixed (MAX_DST_WIDTH); t->right.p1.y = t->top - random_fixed (50); t->right.p2.x = t->left.p2.x + random_fixed (MAX_DST_WIDTH); t->right.p2.y = t->bottom - random_fixed (50); } } if (lcg_rand_n (8) == 0) { pixman_box16_t clip_boxes[2]; int n = lcg_rand_n (2) + 1; for (i = 0; i < n; i++) { clip_boxes[i].x1 = lcg_rand_n (dst_width); clip_boxes[i].y1 = lcg_rand_n (dst_height); clip_boxes[i].x2 = clip_boxes[i].x1 + lcg_rand_n (dst_width - clip_boxes[i].x1); clip_boxes[i].y2 = clip_boxes[i].y1 + lcg_rand_n (dst_height - clip_boxes[i].y1); if (verbose) { printf ("destination clip box: [%d,%d-%d,%d]\n", clip_boxes[i].x1, clip_boxes[i].y1, clip_boxes[i].x2, clip_boxes[i].y2); } } pixman_region_init_rects (&clip, clip_boxes, n); pixman_image_set_clip_region (dst_img, &clip); pixman_region_fini (&clip); } pixman_composite_trapezoids (op, src_img, dst_img, mask_format, src_x, src_y, dst_x, dst_y, n_traps, traps); if (dst_format == PIXMAN_x8r8g8b8) { /* ignore unused part */ for (i = 0; i < dst_stride * dst_height / 4; i++) dst_bits[i] &= 0xFFFFFF; } image_endian_swap (dst_img); if (verbose) { int j; for (i = 0; i < dst_height; i++) { for (j = 0; j < dst_stride; j++) printf ("%02X ", *((uint8_t *)dst_bits + i * dst_stride + j)); printf ("\n"); } } crc32 = compute_crc32 (0, dst_bits, dst_stride * dst_height); fence_free (dst_bits); pixman_image_unref (src_img); pixman_image_unref (dst_img); fence_free (traps); FLOAT_REGS_CORRUPTION_DETECTOR_FINISH (); return crc32; }
void ui_menu_add_change_folder::handle() { // process the menu const ui_menu_event *m_event = process(0); if (m_event != nullptr && m_event->itemref != nullptr) { if (m_event->iptkey == IPT_UI_SELECT) { int index = (FPTR)m_event->itemref - 1; const ui_menu_item &pitem = item[index]; // go up to the parent path if (!strcmp(pitem.text, "..")) { size_t first_sep = m_current_path.find_first_of(PATH_SEPARATOR[0]); size_t last_sep = m_current_path.find_last_of(PATH_SEPARATOR[0]); if (first_sep != last_sep) m_current_path.erase(++last_sep); } else { // if isn't a drive, appends the directory if (strcmp(pitem.subtext, "[DRIVE]") != 0) { if (m_current_path[m_current_path.length() - 1] == PATH_SEPARATOR[0]) m_current_path.append(pitem.text); else m_current_path.append(PATH_SEPARATOR).append(pitem.text); } else m_current_path = pitem.text; } // reset the char buffer also in this case if (m_search[0] != 0) m_search[0] = '\0'; reset(UI_MENU_RESET_SELECT_FIRST); } else if (m_event->iptkey == IPT_SPECIAL) { int buflen = strlen(m_search); bool update_selected = FALSE; // if it's a backspace and we can handle it, do so if ((m_event->unichar == 8 || m_event->unichar == 0x7f) && buflen > 0) { *(char *)utf8_previous_char(&m_search[buflen]) = 0; update_selected = TRUE; } // if it's any other key and we're not maxed out, update else if (m_event->unichar >= ' ' && m_event->unichar < 0x7f) { buflen += utf8_from_uchar(&m_search[buflen], ARRAY_LENGTH(m_search) - buflen, m_event->unichar); m_search[buflen] = 0; update_selected = TRUE; } // Tab key, save current path else if (m_event->unichar == 0x09) { std::string error_string; if (m_change) { if (machine().ui().options().exists(s_folders_entry[m_ref].option)) { machine().ui().options().set_value(s_folders_entry[m_ref].option, m_current_path.c_str(), OPTION_PRIORITY_CMDLINE, error_string); } else { if (strcmp(machine().options().value(s_folders_entry[m_ref].option), m_current_path.c_str()) != 0) { machine().options().set_value(s_folders_entry[m_ref].option, m_current_path.c_str(), OPTION_PRIORITY_CMDLINE, error_string); machine().options().mark_changed(s_folders_entry[m_ref].option); } } machine().datfile().reset_run(); } else { std::string tmppath; if (machine().ui().options().exists(s_folders_entry[m_ref].option)) { tmppath.assign(machine().ui().options().value(s_folders_entry[m_ref].option)).append(";").append(m_current_path.c_str()); } else { tmppath.assign(machine().options().value(s_folders_entry[m_ref].option)).append(";").append(m_current_path.c_str()); } if (machine().ui().options().exists(s_folders_entry[m_ref].option)) { machine().ui().options().set_value(s_folders_entry[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string); } else { if (strcmp(machine().options().value(s_folders_entry[m_ref].option), tmppath.c_str()) != 0) { machine().options().set_value(s_folders_entry[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string); machine().options().mark_changed(s_folders_entry[m_ref].option); } } } ui_menu::menu_stack->parent->reset(UI_MENU_RESET_SELECT_FIRST); ui_menu::stack_pop(machine()); } // check for entries which matches our search buffer if (update_selected) { const int cur_selected = selected; int entry, bestmatch = 0; // from current item to the end for (entry = cur_selected; entry < item.size(); entry++) if (item[entry].ref != nullptr && m_search[0] != 0) { int match = 0; for (int i = 0; i < ARRAY_LENGTH(m_search); i++) { if (core_strnicmp(item[entry].text, m_search, i) == 0) match = i; } if (match > bestmatch) { bestmatch = match; selected = entry; } } // and from the first item to current one for (entry = 0; entry < cur_selected; entry++) { if (item[entry].ref != nullptr && m_search[0] != 0) { int match = 0; for (int i = 0; i < ARRAY_LENGTH(m_search); i++) { if (core_strnicmp(item[entry].text, m_search, i) == 0) match = i; } if (match > bestmatch) { bestmatch = match; selected = entry; } } } } } else if (m_event->iptkey == IPT_UI_CANCEL) { // reset the char buffer also in this case if (m_search[0] != 0) m_search[0] = '\0'; } } }
CCockpit::CCockpit() { for(Sint32 ii=0;ii<enSwitchMax;ii++) { m_bSwitch[ii] = gxFalse; m_sAutoTimer[ii] = 0; m_bAutoSwitch[ii] = gxTrue; } m_sScore = 0; m_pMessage = NULL; m_fMessageScroll = ZERO; m_sMessageWait = 0; m_sMessagelength = 0; m_bMessageEnable = gxTrue; m_bArrow = gxFalse; m_sArrowWait = 100; m_sArrowRot = 0; m_pRaderDamage = NULL; m_pRaderControl = NULL; m_pMsgWindow = NULL; m_pStageClear = NULL; m_pBellowPoint = NULL; m_pBellowBurn = NULL; m_pRaderDamage = new CRaderDamage(); m_pRaderControl = new CRaderControl(); m_pMsgWindow = new CMsgWindow(); //バーニアゲージ m_pBellowPoint = new CBellowsSprite(); m_pBellowBurn = new CBellowsSprite(); for(Sint32 ii=0;ii<ARRAY_LENGTH( sHitPointTbl )/2;ii++) { m_pBellowPoint->AddPosition( sHitPointTbl[ii*2+0].x , sHitPointTbl[ii*2+0].y ,sHitPointTbl[ii*2+1].x , sHitPointTbl[ii*2+1].y ); } for(Sint32 ii=0;ii<ARRAY_LENGTH( sBurniaTbl )/2;ii++) { m_pBellowBurn->AddPosition( sBurniaTbl[ii*2+0].x , sBurniaTbl[ii*2+0].y ,sBurniaTbl[ii*2+1].x , sBurniaTbl[ii*2+1].y ); } m_bPlayerOut = gxFalse; m_bGameOver = gxFalse; m_sHitPoint = 100; m_sDispHitPoint = 0; m_sScore = 0; m_sScoreWait = 0; m_sDispScore = 0; m_sBurniaEnergy = 0; m_bSubWeapon = gxFalse; m_bOutogRange = gxFalse; m_sPlayerPosX = 0; m_sOperationrangeMin = -12000; m_sOperationrangeMax = 12000; m_sMissionTime = 0*60; m_sMissionSecFlah = 0; m_sConpaneTimer = 0; m_sNowLoadingRot = 0; m_sNowLoadingWait = 0; m_sWhiteFade = 0; m_bSplash = gxFalse; for(Sint32 jj=0;jj<enMessageMemMax;jj++) { m_sMsgIndex[ jj ] = -1; } m_sBlackMask = 0; m_bBlackMask = gxFalse; m_sWarningFrame = 0; m_sCockpitTimer = 0; m_sSplashAlpha = 0; //------------------------- //武器アイコン //------------------------- m_sWeaponType[0] = 0; m_sWeaponGauge[0] = 0; m_sWeaponRemain[0] = 0; m_sWeaponType[1] = 0; m_sWeaponGauge[1] = 0; m_sWeaponRemain[1] = 0; m_sHeight = 100; m_sStopCnt = 0; m_bSystemSound = gxTrue; m_pDanmaku = new StDanmaku[enDanmakuMax]; m_sScoreBairitsu = 1; }
void laserdisc_device::read_track_data() { // compute the chdhunk number we are going to read INT32 chdtrack = m_curtrack - 1 - VIRTUAL_LEAD_IN_TRACKS; chdtrack = MAX(chdtrack, 0); chdtrack = MIN(chdtrack, m_chdtracks - 1); UINT32 readhunk = chdtrack * 2 + m_fieldnum; // cheat and look up the metadata we are about to retrieve vbi_metadata vbidata = { 0 }; if (m_vbidata.count() != 0) vbi_metadata_unpack(&vbidata, NULL, &m_vbidata[readhunk * VBI_PACKED_BYTES]); // if we're in the lead-in area, force the VBI data to be standard lead-in if (m_curtrack - 1 < VIRTUAL_LEAD_IN_TRACKS) { vbidata.line16 = 0; vbidata.line17 = vbidata.line18 = vbidata.line1718 = VBI_CODE_LEADIN; } //printf("track %5d.%d: %06X %06X %06X\n", m_curtrack, m_fieldnum, vbidata.line16, vbidata.line17, vbidata.line18); // if we're about to read the first field in a frame, advance frame_data *frame = &m_frame[m_videoindex]; if ((vbidata.line1718 & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE) { if (frame->m_numfields >= 2) m_videoindex = (m_videoindex + 1) % ARRAY_LENGTH(m_frame); frame = &m_frame[m_videoindex]; frame->m_numfields = 0; } // if we're squelched, reset the frame counter if (m_videosquelch) frame->m_numfields = 0; // remember the last field number frame->m_lastfield = m_curtrack * 2 + m_fieldnum; // set the video target information m_avhuff_config.video.wrap(&frame->m_bitmap.pix16(m_fieldnum), frame->m_bitmap.width(), frame->m_bitmap.height() / 2, frame->m_bitmap.rowpixels() * 2); // set the audio target information if (m_audiobufin + m_audiomaxsamples <= m_audiobufsize) { // if we can fit without wrapping, just read the data directly m_avhuff_config.audio[0] = &m_audiobuffer[0][m_audiobufin]; m_avhuff_config.audio[1] = &m_audiobuffer[1][m_audiobufin]; } else { // otherwise, read to the beginning of the buffer m_avhuff_config.audio[0] = &m_audiobuffer[0][0]; m_avhuff_config.audio[1] = &m_audiobuffer[1][0]; } // override if we're not decoding m_avhuff_config.maxsamples = m_audiomaxsamples; m_avhuff_config.actsamples = &m_audiocursamples; m_audiocursamples = 0; // set the VBI data for the new field from our precomputed data if (m_vbidata.count() != 0) { UINT32 vbiframe; vbi_metadata_unpack(&m_metadata[m_fieldnum], &vbiframe, &m_vbidata[readhunk * VBI_PACKED_BYTES]); } // if we're in the lead-in area, force the VBI data to be standard lead-in if (m_curtrack - 1 < VIRTUAL_LEAD_IN_TRACKS) { m_metadata[m_fieldnum].line16 = 0; m_metadata[m_fieldnum].line17 = m_metadata[m_fieldnum].line18 = m_metadata[m_fieldnum].line1718 = VBI_CODE_LEADIN; } // configure the codec and then read m_readresult = CHDERR_FILE_NOT_FOUND; if (m_disc != NULL && !m_videosquelch) { m_readresult = m_disc->codec_configure(CHD_CODEC_AVHUFF, AVHUFF_CODEC_DECOMPRESS_CONFIG, &m_avhuff_config); if (m_readresult == CHDERR_NONE) { m_queued_hunknum = readhunk; m_readresult = CHDERR_OPERATION_PENDING; osd_work_item_queue(m_work_queue, read_async_static, this, WORK_ITEM_FLAG_AUTO_RELEASE); } } }
// The private constructor to create the default instance keyboard_trans_table::keyboard_trans_table() { m_table = s_default_table; m_table_size = ARRAY_LENGTH(s_default_table); }
void CollationCurrencyTest::currencyTest(/*char *par*/) { // All the currency symbols, in collation order static const UChar currency[][2] = { { 0x00A4, 0x0000}, /*00A4; L; [14 36, 03, 03] # [082B.0020.0002] # CURRENCY SIGN*/ { 0x00A2, 0x0000}, /*00A2; L; [14 38, 03, 03] # [082C.0020.0002] # CENT SIGN*/ { 0xFFE0, 0x0000}, /*FFE0; L; [14 38, 03, 05] # [082C.0020.0003] # FULLWIDTH CENT SIGN*/ { 0x0024, 0x0000}, /*0024; L; [14 3A, 03, 03] # [082D.0020.0002] # DOLLAR SIGN*/ { 0xFF04, 0x0000}, /*FF04; L; [14 3A, 03, 05] # [082D.0020.0003] # FULLWIDTH DOLLAR SIGN*/ { 0xFE69, 0x0000}, /*FE69; L; [14 3A, 03, 1D] # [082D.0020.000F] # SMALL DOLLAR SIGN*/ { 0x00A3, 0x0000}, /*00A3; L; [14 3C, 03, 03] # [082E.0020.0002] # POUND SIGN*/ { 0xFFE1, 0x0000}, /*FFE1; L; [14 3C, 03, 05] # [082E.0020.0003] # FULLWIDTH POUND SIGN*/ { 0x00A5, 0x0000}, /*00A5; L; [14 3E, 03, 03] # [082F.0020.0002] # YEN SIGN*/ { 0xFFE5, 0x0000}, /*FFE5; L; [14 3E, 03, 05] # [082F.0020.0003] # FULLWIDTH YEN SIGN*/ { 0x09F2, 0x0000}, /*09F2; L; [14 40, 03, 03] # [0830.0020.0002] # BENGALI RUPEE MARK*/ { 0x09F3, 0x0000}, /*09F3; L; [14 42, 03, 03] # [0831.0020.0002] # BENGALI RUPEE SIGN*/ { 0x0E3F, 0x0000}, /*0E3F; L; [14 44, 03, 03] # [0832.0020.0002] # THAI CURRENCY SYMBOL BAHT*/ { 0x17DB, 0x0000}, /*17DB; L; [14 46, 03, 03] # [0833.0020.0002] # KHMER CURRENCY SYMBOL RIEL*/ { 0x20A0, 0x0000}, /*20A0; L; [14 48, 03, 03] # [0834.0020.0002] # EURO-CURRENCY SIGN*/ { 0x20A1, 0x0000}, /*20A1; L; [14 4A, 03, 03] # [0835.0020.0002] # COLON SIGN*/ { 0x20A2, 0x0000}, /*20A2; L; [14 4C, 03, 03] # [0836.0020.0002] # CRUZEIRO SIGN*/ { 0x20A3, 0x0000}, /*20A3; L; [14 4E, 03, 03] # [0837.0020.0002] # FRENCH FRANC SIGN*/ { 0x20A4, 0x0000}, /*20A4; L; [14 50, 03, 03] # [0838.0020.0002] # LIRA SIGN*/ { 0x20A5, 0x0000}, /*20A5; L; [14 52, 03, 03] # [0839.0020.0002] # MILL SIGN*/ { 0x20A6, 0x0000}, /*20A6; L; [14 54, 03, 03] # [083A.0020.0002] # NAIRA SIGN*/ { 0x20A7, 0x0000}, /*20A7; L; [14 56, 03, 03] # [083B.0020.0002] # PESETA SIGN*/ { 0x20A9, 0x0000}, /*20A9; L; [14 58, 03, 03] # [083C.0020.0002] # WON SIGN*/ { 0xFFE6, 0x0000}, /*FFE6; L; [14 58, 03, 05] # [083C.0020.0003] # FULLWIDTH WON SIGN*/ { 0x20AA, 0x0000}, /*20AA; L; [14 5A, 03, 03] # [083D.0020.0002] # NEW SHEQEL SIGN*/ { 0x20AB, 0x0000}, /*20AB; L; [14 5C, 03, 03] # [083E.0020.0002] # DONG SIGN*/ { 0x20AC, 0x0000}, /*20AC; L; [14 5E, 03, 03] # [083F.0020.0002] # EURO SIGN*/ { 0x20AD, 0x0000}, /*20AD; L; [14 60, 03, 03] # [0840.0020.0002] # KIP SIGN*/ { 0x20AE, 0x0000}, /*20AE; L; [14 62, 03, 03] # [0841.0020.0002] # TUGRIK SIGN*/ { 0x20AF, 0x0000}, /*20AF; L; [14 64, 03, 03] # [0842.0020.0002] # DRACHMA SIGN*/ }; uint32_t i, j; UErrorCode status = U_ZERO_ERROR; Collator::EComparisonResult expectedResult = Collator::EQUAL; RuleBasedCollator *c = (RuleBasedCollator *)Collator::createInstance("en_US", status); if (U_FAILURE(status)) { errln ("Collator::createInstance() failed!"); return; } // Compare each currency symbol against all the // currency symbols, including itself for (i = 0; i < ARRAY_LENGTH(currency); i += 1) { for (j = 0; j < ARRAY_LENGTH(currency); j += 1) { UnicodeString source(currency[i], 1); UnicodeString target(currency[j], 1); if (i < j) { expectedResult = Collator::LESS; } else if ( i == j) { expectedResult = Collator::EQUAL; } else { expectedResult = Collator::GREATER; } Collator::EComparisonResult compareResult = c->compare(source, target); CollationKey sourceKey, targetKey; UErrorCode status = U_ZERO_ERROR; c->getCollationKey(source, sourceKey, status); if (U_FAILURE(status)) { errln("Couldn't get collationKey for source"); continue; } c->getCollationKey(target, targetKey, status); if (U_FAILURE(status)) { errln("Couldn't get collationKey for target"); continue; } Collator::EComparisonResult keyResult = sourceKey.compareTo(targetKey); reportCResult( source, target, sourceKey, targetKey, compareResult, keyResult, compareResult, expectedResult ); } } delete c; }
static int recurse_dir(int srcrootlen, int dstrootlen, const astring *srcdir, const astring *dstdir) { static const osd_dir_entry_type typelist[] = { ENTTYPE_DIR, ENTTYPE_FILE }; const astring *srcdir_subpath; core_file *indexfile = NULL; astring *indexname; int result = 0; int entindex; /* extract a normalized subpath */ srcdir_subpath = normalized_subpath(srcdir, srcrootlen + 1); if (srcdir_subpath == NULL) return 1; /* create an index file */ indexname = astring_alloc(); astring_printf(indexname, "%s%c%s", astring_c(dstdir), PATH_SEPARATOR[0], "index.html"); indexfile = create_file_and_output_header(indexname, "MAME Source Code", astring_c(srcdir_subpath)); astring_free(indexname); /* output the directory navigation */ core_fprintf(indexfile, "<h3>Viewing Directory: "); output_path_as_links(indexfile, srcdir_subpath, TRUE, FALSE); core_fprintf(indexfile, "</h3>"); astring_free((astring *)srcdir_subpath); /* iterate first over directories, then over files */ for (entindex = 0; entindex < ARRAY_LENGTH(typelist) && result == 0; entindex++) { osd_dir_entry_type entry_type = typelist[entindex]; const osd_directory_entry *entry; list_entry *list = NULL; list_entry **listarray; list_entry *curlist; osd_directory *dir; int found = 0; /* open the directory and iterate through it */ dir = osd_opendir(astring_c(srcdir)); if (dir == NULL) { result = 1; goto error; } /* build up the list of files */ while ((entry = osd_readdir(dir)) != NULL) if (entry->type == entry_type && entry->name[0] != '.') { list_entry *lentry = malloc(sizeof(*lentry)); lentry->name = astring_dupc(entry->name); lentry->next = list; list = lentry; found++; } /* close the directory */ osd_closedir(dir); /* skip if nothing found */ if (found == 0) continue; /* allocate memory for sorting */ listarray = malloc(sizeof(list_entry *) * found); found = 0; for (curlist = list; curlist != NULL; curlist = curlist->next) listarray[found++] = curlist; /* sort the list */ qsort(listarray, found, sizeof(listarray[0]), compare_list_entries); /* rebuild the list */ list = NULL; while (--found >= 0) { listarray[found]->next = list; list = listarray[found]; } /* iterate through each file */ for (curlist = list; curlist != NULL && result == 0; curlist = curlist->next) { astring *srcfile, *dstfile; /* add a header */ if (curlist == list) core_fprintf(indexfile, "\t<h2>%s</h2>\n\t<ul>\n", (entry_type == ENTTYPE_DIR) ? "Directories" : "Files"); /* build the source filename */ srcfile = astring_alloc(); astring_printf(srcfile, "%s%c%s", astring_c(srcdir), PATH_SEPARATOR[0], astring_c(curlist->name)); /* if we have a file, output it */ dstfile = astring_alloc(); if (entry_type == ENTTYPE_FILE) { file_type type = FILE_TYPE_INVALID; int extnum; /* make sure we care, first */ for (extnum = 0; extnum < ARRAY_LENGTH(extension_lookup); extnum++) if (core_filename_ends_with(astring_c(curlist->name), extension_lookup[extnum].extension)) { type = extension_lookup[extnum].type; break; } /* if we got a valid file, process it */ if (type != FILE_TYPE_INVALID) { astring_printf(dstfile, "%s%c%s.html", astring_c(dstdir), PATH_SEPARATOR[0], astring_c(curlist->name)); if (indexfile != NULL) core_fprintf(indexfile, "\t<li><a href=\"%s.html\">%s</a></li>\n", astring_c(curlist->name), astring_c(curlist->name)); result = output_file(type, srcrootlen, dstrootlen, srcfile, dstfile, astring_cmp(srcdir, dstdir) == 0); } } /* if we have a directory, recurse */ else { astring_printf(dstfile, "%s%c%s", astring_c(dstdir), PATH_SEPARATOR[0], astring_c(curlist->name)); if (indexfile != NULL) core_fprintf(indexfile, "\t<li><a href=\"%s/index.html\">%s/</a></li>\n", astring_c(curlist->name), astring_c(curlist->name)); result = recurse_dir(srcrootlen, dstrootlen, srcfile, dstfile); } /* free memory for the names */ astring_free(srcfile); astring_free(dstfile); } /* close the list if we found some stuff */ if (list != NULL) core_fprintf(indexfile, "\t</ul>\n"); /* free all the allocated entries */ while (list != NULL) { list_entry *next = list->next; astring_free((astring *)list->name); free(list); list = next; } } error: if (indexfile != NULL) output_footer_and_close_file(indexfile); return result; }