hexsha
stringlengths 40
40
| repo
stringlengths 5
105
| path
stringlengths 3
173
| license
sequence | language
stringclasses 1
value | identifier
stringlengths 1
438
| return_type
stringlengths 1
106
⌀ | original_string
stringlengths 21
40.7k
| original_docstring
stringlengths 18
13.4k
| docstring
stringlengths 11
3.24k
| docstring_tokens
sequence | code
stringlengths 14
20.4k
| code_tokens
sequence | short_docstring
stringlengths 0
4.36k
| short_docstring_tokens
sequence | comment
sequence | parameters
list | docstring_params
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | xml_file_write | void | void xml_file_write(xml_data_node *node, core_file *file)
{
/* ensure this is a root node */
if (node->name != NULL)
return;
/* output a simple header */
core_fprintf(file, "<?xml version=\"1.0\"?>\n");
core_fprintf(file, "<!-- This file is autogenerated; comments and unknown tags will be stripped -->\n");
/* loop over children of the root and output */
for (node = node->child; node; node = node->next)
write_node_recursive(node, 0, file);
} | /*-------------------------------------------------
xml_file_write - write an XML tree to a file
-------------------------------------------------*/ | write an XML tree to a file | [
"write",
"an",
"XML",
"tree",
"to",
"a",
"file"
] | void xml_file_write(xml_data_node *node, core_file *file)
{
if (node->name != NULL)
return;
core_fprintf(file, "<?xml version=\"1.0\"?>\n");
core_fprintf(file, "<!-- This file is autogenerated; comments and unknown tags will be stripped -->\n");
for (node = node->child; node; node = node->next)
write_node_recursive(node, 0, file);
} | [
"void",
"xml_file_write",
"(",
"xml_data_node",
"*",
"node",
",",
"core_file",
"*",
"file",
")",
"{",
"if",
"(",
"node",
"->",
"name",
"!=",
"NULL",
")",
"return",
";",
"core_fprintf",
"(",
"file",
",",
"\"",
"\\\"",
"\\\"",
"\\n",
"\"",
")",
";",
"core_fprintf",
"(",
"file",
",",
"\"",
"\\n",
"\"",
")",
";",
"for",
"(",
"node",
"=",
"node",
"->",
"child",
";",
"node",
";",
"node",
"=",
"node",
"->",
"next",
")",
"write_node_recursive",
"(",
"node",
",",
"0",
",",
"file",
")",
";",
"}"
] | xml_file_write - write an XML tree to a file | [
"xml_file_write",
"-",
"write",
"an",
"XML",
"tree",
"to",
"a",
"file"
] | [
"/* ensure this is a root node */",
"/* output a simple header */",
"/* loop over children of the root and output */"
] | [
{
"param": "node",
"type": "xml_data_node"
},
{
"param": "file",
"type": "core_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "xml_data_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type": "core_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | xml_count_children | int | int xml_count_children(xml_data_node *node)
{
int count = 0;
/* loop over children and count */
for (node = node->child; node; node = node->next)
count++;
return count;
} | /*-------------------------------------------------
xml_count_children - count the number of
child nodes
-------------------------------------------------*/ | count the number of
child nodes | [
"count",
"the",
"number",
"of",
"child",
"nodes"
] | int xml_count_children(xml_data_node *node)
{
int count = 0;
for (node = node->child; node; node = node->next)
count++;
return count;
} | [
"int",
"xml_count_children",
"(",
"xml_data_node",
"*",
"node",
")",
"{",
"int",
"count",
"=",
"0",
";",
"for",
"(",
"node",
"=",
"node",
"->",
"child",
";",
"node",
";",
"node",
"=",
"node",
"->",
"next",
")",
"count",
"++",
";",
"return",
"count",
";",
"}"
] | xml_count_children - count the number of
child nodes | [
"xml_count_children",
"-",
"count",
"the",
"number",
"of",
"child",
"nodes"
] | [
"/* loop over children and count */"
] | [
{
"param": "node",
"type": "xml_data_node"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "xml_data_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | xml_get_sibling | xml_data_node | xml_data_node *xml_get_sibling(xml_data_node *node, const char *name)
{
/* loop over siblings and find a matching name */
for ( ; node; node = node->next)
if (strcmp(node->name, name) == 0)
return node;
return NULL;
} | /*-------------------------------------------------
xml_get_sibling - find the next sibling of
the specified node with the specified tag
-------------------------------------------------*/ | find the next sibling of
the specified node with the specified tag | [
"find",
"the",
"next",
"sibling",
"of",
"the",
"specified",
"node",
"with",
"the",
"specified",
"tag"
] | xml_data_node *xml_get_sibling(xml_data_node *node, const char *name)
{
for ( ; node; node = node->next)
if (strcmp(node->name, name) == 0)
return node;
return NULL;
} | [
"xml_data_node",
"*",
"xml_get_sibling",
"(",
"xml_data_node",
"*",
"node",
",",
"const",
"char",
"*",
"name",
")",
"{",
"for",
"(",
";",
"node",
";",
"node",
"=",
"node",
"->",
"next",
")",
"if",
"(",
"strcmp",
"(",
"node",
"->",
"name",
",",
"name",
")",
"==",
"0",
")",
"return",
"node",
";",
"return",
"NULL",
";",
"}"
] | xml_get_sibling - find the next sibling of
the specified node with the specified tag | [
"xml_get_sibling",
"-",
"find",
"the",
"next",
"sibling",
"of",
"the",
"specified",
"node",
"with",
"the",
"specified",
"tag"
] | [
"/* loop over siblings and find a matching name */"
] | [
{
"param": "node",
"type": "xml_data_node"
},
{
"param": "name",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "xml_data_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | xml_find_matching_sibling | xml_data_node | xml_data_node *xml_find_matching_sibling(xml_data_node *node, const char *name, const char *attribute, const char *matchval)
{
/* loop over siblings and find a matching attribute */
for ( ; node; node = node->next)
{
/* can pass NULL as a wildcard for the node name */
if (name == NULL || strcmp(name, node->name) == 0)
{
/* find a matching attribute */
xml_attribute_node *attr = xml_get_attribute(node, attribute);
if (attr != NULL && strcmp(attr->value, matchval) == 0)
return node;
}
}
return NULL;
} | /*-------------------------------------------------
xml_find_matching_sibling - find the next
sibling of the specified node with the
specified tag or attribute/value pair
-------------------------------------------------*/ | find the next
sibling of the specified node with the
specified tag or attribute/value pair | [
"find",
"the",
"next",
"sibling",
"of",
"the",
"specified",
"node",
"with",
"the",
"specified",
"tag",
"or",
"attribute",
"/",
"value",
"pair"
] | xml_data_node *xml_find_matching_sibling(xml_data_node *node, const char *name, const char *attribute, const char *matchval)
{
for ( ; node; node = node->next)
{
if (name == NULL || strcmp(name, node->name) == 0)
{
xml_attribute_node *attr = xml_get_attribute(node, attribute);
if (attr != NULL && strcmp(attr->value, matchval) == 0)
return node;
}
}
return NULL;
} | [
"xml_data_node",
"*",
"xml_find_matching_sibling",
"(",
"xml_data_node",
"*",
"node",
",",
"const",
"char",
"*",
"name",
",",
"const",
"char",
"*",
"attribute",
",",
"const",
"char",
"*",
"matchval",
")",
"{",
"for",
"(",
";",
"node",
";",
"node",
"=",
"node",
"->",
"next",
")",
"{",
"if",
"(",
"name",
"==",
"NULL",
"||",
"strcmp",
"(",
"name",
",",
"node",
"->",
"name",
")",
"==",
"0",
")",
"{",
"xml_attribute_node",
"*",
"attr",
"=",
"xml_get_attribute",
"(",
"node",
",",
"attribute",
")",
";",
"if",
"(",
"attr",
"!=",
"NULL",
"&&",
"strcmp",
"(",
"attr",
"->",
"value",
",",
"matchval",
")",
"==",
"0",
")",
"return",
"node",
";",
"}",
"}",
"return",
"NULL",
";",
"}"
] | xml_find_matching_sibling - find the next
sibling of the specified node with the
specified tag or attribute/value pair | [
"xml_find_matching_sibling",
"-",
"find",
"the",
"next",
"sibling",
"of",
"the",
"specified",
"node",
"with",
"the",
"specified",
"tag",
"or",
"attribute",
"/",
"value",
"pair"
] | [
"/* loop over siblings and find a matching attribute */",
"/* can pass NULL as a wildcard for the node name */",
"/* find a matching attribute */"
] | [
{
"param": "node",
"type": "xml_data_node"
},
{
"param": "name",
"type": "char"
},
{
"param": "attribute",
"type": "char"
},
{
"param": "matchval",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "xml_data_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "attribute",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "matchval",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | xml_add_child | xml_data_node | xml_data_node *xml_add_child(xml_data_node *node, const char *name, const char *value)
{
/* just a standard add child */
return add_child(node, name, value);
} | /*-------------------------------------------------
xml_add_child - add a new child node to the
given node
-------------------------------------------------*/ | add a new child node to the
given node | [
"add",
"a",
"new",
"child",
"node",
"to",
"the",
"given",
"node"
] | xml_data_node *xml_add_child(xml_data_node *node, const char *name, const char *value)
{
return add_child(node, name, value);
} | [
"xml_data_node",
"*",
"xml_add_child",
"(",
"xml_data_node",
"*",
"node",
",",
"const",
"char",
"*",
"name",
",",
"const",
"char",
"*",
"value",
")",
"{",
"return",
"add_child",
"(",
"node",
",",
"name",
",",
"value",
")",
";",
"}"
] | xml_add_child - add a new child node to the
given node | [
"xml_add_child",
"-",
"add",
"a",
"new",
"child",
"node",
"to",
"the",
"given",
"node"
] | [
"/* just a standard add child */"
] | [
{
"param": "node",
"type": "xml_data_node"
},
{
"param": "name",
"type": "char"
},
{
"param": "value",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "xml_data_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "value",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | xml_get_or_add_child | xml_data_node | xml_data_node *xml_get_or_add_child(xml_data_node *node, const char *name, const char *value)
{
xml_data_node *child;
/* find the child first */
child = xml_get_sibling(node->child, name);
if (child != NULL)
return child;
/* if not found, do a standard add child */
return add_child(node, name, value);
} | /*-------------------------------------------------
xml_get_or_add_child - find a child node of
the specified type; if not found, add one
-------------------------------------------------*/ | find a child node of
the specified type; if not found, add one | [
"find",
"a",
"child",
"node",
"of",
"the",
"specified",
"type",
";",
"if",
"not",
"found",
"add",
"one"
] | xml_data_node *xml_get_or_add_child(xml_data_node *node, const char *name, const char *value)
{
xml_data_node *child;
child = xml_get_sibling(node->child, name);
if (child != NULL)
return child;
return add_child(node, name, value);
} | [
"xml_data_node",
"*",
"xml_get_or_add_child",
"(",
"xml_data_node",
"*",
"node",
",",
"const",
"char",
"*",
"name",
",",
"const",
"char",
"*",
"value",
")",
"{",
"xml_data_node",
"*",
"child",
";",
"child",
"=",
"xml_get_sibling",
"(",
"node",
"->",
"child",
",",
"name",
")",
";",
"if",
"(",
"child",
"!=",
"NULL",
")",
"return",
"child",
";",
"return",
"add_child",
"(",
"node",
",",
"name",
",",
"value",
")",
";",
"}"
] | xml_get_or_add_child - find a child node of
the specified type; if not found, add one | [
"xml_get_or_add_child",
"-",
"find",
"a",
"child",
"node",
"of",
"the",
"specified",
"type",
";",
"if",
"not",
"found",
"add",
"one"
] | [
"/* find the child first */",
"/* if not found, do a standard add child */"
] | [
{
"param": "node",
"type": "xml_data_node"
},
{
"param": "name",
"type": "char"
},
{
"param": "value",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "xml_data_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "value",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | xml_delete_node | void | void xml_delete_node(xml_data_node *node)
{
xml_data_node **pnode;
/* first unhook us from the list of children of our parent */
for (pnode = &node->parent->child; *pnode; pnode = &(*pnode)->next)
if (*pnode == node)
{
*pnode = node->next;
break;
}
/* now free ourselves and our children */
free_node_recursive(node);
} | /*-------------------------------------------------
xml_delete_node - delete a node and its
children
-------------------------------------------------*/ | delete a node and its
children | [
"delete",
"a",
"node",
"and",
"its",
"children"
] | void xml_delete_node(xml_data_node *node)
{
xml_data_node **pnode;
for (pnode = &node->parent->child; *pnode; pnode = &(*pnode)->next)
if (*pnode == node)
{
*pnode = node->next;
break;
}
free_node_recursive(node);
} | [
"void",
"xml_delete_node",
"(",
"xml_data_node",
"*",
"node",
")",
"{",
"xml_data_node",
"*",
"*",
"pnode",
";",
"for",
"(",
"pnode",
"=",
"&",
"node",
"->",
"parent",
"->",
"child",
";",
"*",
"pnode",
";",
"pnode",
"=",
"&",
"(",
"*",
"pnode",
")",
"->",
"next",
")",
"if",
"(",
"*",
"pnode",
"==",
"node",
")",
"{",
"*",
"pnode",
"=",
"node",
"->",
"next",
";",
"break",
";",
"}",
"free_node_recursive",
"(",
"node",
")",
";",
"}"
] | xml_delete_node - delete a node and its
children | [
"xml_delete_node",
"-",
"delete",
"a",
"node",
"and",
"its",
"children"
] | [
"/* first unhook us from the list of children of our parent */",
"/* now free ourselves and our children */"
] | [
{
"param": "node",
"type": "xml_data_node"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "xml_data_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | xml_get_attribute | xml_attribute_node | xml_attribute_node *xml_get_attribute(xml_data_node *node, const char *attribute)
{
xml_attribute_node *anode;
/* loop over attributes and find a match */
for (anode = node->attribute; anode; anode = anode->next)
if (strcmp(anode->name, attribute) == 0)
return anode;
return NULL;
} | /*-------------------------------------------------
xml_get_attribute - get the value of the
specified attribute, or NULL if not found
-------------------------------------------------*/ | get the value of the
specified attribute, or NULL if not found | [
"get",
"the",
"value",
"of",
"the",
"specified",
"attribute",
"or",
"NULL",
"if",
"not",
"found"
] | xml_attribute_node *xml_get_attribute(xml_data_node *node, const char *attribute)
{
xml_attribute_node *anode;
for (anode = node->attribute; anode; anode = anode->next)
if (strcmp(anode->name, attribute) == 0)
return anode;
return NULL;
} | [
"xml_attribute_node",
"*",
"xml_get_attribute",
"(",
"xml_data_node",
"*",
"node",
",",
"const",
"char",
"*",
"attribute",
")",
"{",
"xml_attribute_node",
"*",
"anode",
";",
"for",
"(",
"anode",
"=",
"node",
"->",
"attribute",
";",
"anode",
";",
"anode",
"=",
"anode",
"->",
"next",
")",
"if",
"(",
"strcmp",
"(",
"anode",
"->",
"name",
",",
"attribute",
")",
"==",
"0",
")",
"return",
"anode",
";",
"return",
"NULL",
";",
"}"
] | xml_get_attribute - get the value of the
specified attribute, or NULL if not found | [
"xml_get_attribute",
"-",
"get",
"the",
"value",
"of",
"the",
"specified",
"attribute",
"or",
"NULL",
"if",
"not",
"found"
] | [
"/* loop over attributes and find a match */"
] | [
{
"param": "node",
"type": "xml_data_node"
},
{
"param": "attribute",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "xml_data_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "attribute",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | xml_get_attribute_string | char | const char *xml_get_attribute_string(xml_data_node *node, const char *attribute, const char *defvalue)
{
xml_attribute_node *attr = xml_get_attribute(node, attribute);
return attr ? attr->value : defvalue;
} | /*-------------------------------------------------
xml_get_attribute_string - get the string
value of the specified attribute; if not
found, return = the provided default
-------------------------------------------------*/ | get the string
value of the specified attribute; if not
found, return = the provided default | [
"get",
"the",
"string",
"value",
"of",
"the",
"specified",
"attribute",
";",
"if",
"not",
"found",
"return",
"=",
"the",
"provided",
"default"
] | const char *xml_get_attribute_string(xml_data_node *node, const char *attribute, const char *defvalue)
{
xml_attribute_node *attr = xml_get_attribute(node, attribute);
return attr ? attr->value : defvalue;
} | [
"const",
"char",
"*",
"xml_get_attribute_string",
"(",
"xml_data_node",
"*",
"node",
",",
"const",
"char",
"*",
"attribute",
",",
"const",
"char",
"*",
"defvalue",
")",
"{",
"xml_attribute_node",
"*",
"attr",
"=",
"xml_get_attribute",
"(",
"node",
",",
"attribute",
")",
";",
"return",
"attr",
"?",
"attr",
"->",
"value",
":",
"defvalue",
";",
"}"
] | xml_get_attribute_string - get the string
value of the specified attribute; if not
found, return = the provided default | [
"xml_get_attribute_string",
"-",
"get",
"the",
"string",
"value",
"of",
"the",
"specified",
"attribute",
";",
"if",
"not",
"found",
"return",
"=",
"the",
"provided",
"default"
] | [] | [
{
"param": "node",
"type": "xml_data_node"
},
{
"param": "attribute",
"type": "char"
},
{
"param": "defvalue",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "xml_data_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "attribute",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "defvalue",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | xml_get_attribute_int | int | int xml_get_attribute_int(xml_data_node *node, const char *attribute, int defvalue)
{
const char *string = xml_get_attribute_string(node, attribute, NULL);
int value;
if (string == NULL)
return defvalue;
if (string[0] == '$')
return (sscanf(&string[1], "%X", &value) == 1) ? value : defvalue;
if (string[0] == '0' && string[1] == 'x')
return (sscanf(&string[2], "%X", &value) == 1) ? value : defvalue;
if (string[0] == '#')
return (sscanf(&string[1], "%d", &value) == 1) ? value : defvalue;
return (sscanf(&string[0], "%d", &value) == 1) ? value : defvalue;
} | /*-------------------------------------------------
xml_get_attribute_int - get the integer
value of the specified attribute; if not
found, return = the provided default
-------------------------------------------------*/ | get the integer
value of the specified attribute; if not
found, return = the provided default | [
"get",
"the",
"integer",
"value",
"of",
"the",
"specified",
"attribute",
";",
"if",
"not",
"found",
"return",
"=",
"the",
"provided",
"default"
] | int xml_get_attribute_int(xml_data_node *node, const char *attribute, int defvalue)
{
const char *string = xml_get_attribute_string(node, attribute, NULL);
int value;
if (string == NULL)
return defvalue;
if (string[0] == '$')
return (sscanf(&string[1], "%X", &value) == 1) ? value : defvalue;
if (string[0] == '0' && string[1] == 'x')
return (sscanf(&string[2], "%X", &value) == 1) ? value : defvalue;
if (string[0] == '#')
return (sscanf(&string[1], "%d", &value) == 1) ? value : defvalue;
return (sscanf(&string[0], "%d", &value) == 1) ? value : defvalue;
} | [
"int",
"xml_get_attribute_int",
"(",
"xml_data_node",
"*",
"node",
",",
"const",
"char",
"*",
"attribute",
",",
"int",
"defvalue",
")",
"{",
"const",
"char",
"*",
"string",
"=",
"xml_get_attribute_string",
"(",
"node",
",",
"attribute",
",",
"NULL",
")",
";",
"int",
"value",
";",
"if",
"(",
"string",
"==",
"NULL",
")",
"return",
"defvalue",
";",
"if",
"(",
"string",
"[",
"0",
"]",
"==",
"'",
"'",
")",
"return",
"(",
"sscanf",
"(",
"&",
"string",
"[",
"1",
"]",
",",
"\"",
"\"",
",",
"&",
"value",
")",
"==",
"1",
")",
"?",
"value",
":",
"defvalue",
";",
"if",
"(",
"string",
"[",
"0",
"]",
"==",
"'",
"'",
"&&",
"string",
"[",
"1",
"]",
"==",
"'",
"'",
")",
"return",
"(",
"sscanf",
"(",
"&",
"string",
"[",
"2",
"]",
",",
"\"",
"\"",
",",
"&",
"value",
")",
"==",
"1",
")",
"?",
"value",
":",
"defvalue",
";",
"if",
"(",
"string",
"[",
"0",
"]",
"==",
"'",
"'",
")",
"return",
"(",
"sscanf",
"(",
"&",
"string",
"[",
"1",
"]",
",",
"\"",
"\"",
",",
"&",
"value",
")",
"==",
"1",
")",
"?",
"value",
":",
"defvalue",
";",
"return",
"(",
"sscanf",
"(",
"&",
"string",
"[",
"0",
"]",
",",
"\"",
"\"",
",",
"&",
"value",
")",
"==",
"1",
")",
"?",
"value",
":",
"defvalue",
";",
"}"
] | xml_get_attribute_int - get the integer
value of the specified attribute; if not
found, return = the provided default | [
"xml_get_attribute_int",
"-",
"get",
"the",
"integer",
"value",
"of",
"the",
"specified",
"attribute",
";",
"if",
"not",
"found",
"return",
"=",
"the",
"provided",
"default"
] | [] | [
{
"param": "node",
"type": "xml_data_node"
},
{
"param": "attribute",
"type": "char"
},
{
"param": "defvalue",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "xml_data_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "attribute",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "defvalue",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | xml_get_attribute_int_format | int | int xml_get_attribute_int_format(xml_data_node *node, const char *attribute)
{
const char *string = xml_get_attribute_string(node, attribute, NULL);
if (string == NULL)
return XML_INT_FORMAT_DECIMAL;
if (string[0] == '$')
return XML_INT_FORMAT_HEX_DOLLAR;
if (string[0] == '0' && string[1] == 'x')
return XML_INT_FORMAT_HEX_C;
if (string[0] == '#')
return XML_INT_FORMAT_DECIMAL_POUND;
return XML_INT_FORMAT_DECIMAL;
} | /*-------------------------------------------------
xml_get_attribute_int_format - return the
format of the given integer attribute
-------------------------------------------------*/ | return the
format of the given integer attribute | [
"return",
"the",
"format",
"of",
"the",
"given",
"integer",
"attribute"
] | int xml_get_attribute_int_format(xml_data_node *node, const char *attribute)
{
const char *string = xml_get_attribute_string(node, attribute, NULL);
if (string == NULL)
return XML_INT_FORMAT_DECIMAL;
if (string[0] == '$')
return XML_INT_FORMAT_HEX_DOLLAR;
if (string[0] == '0' && string[1] == 'x')
return XML_INT_FORMAT_HEX_C;
if (string[0] == '#')
return XML_INT_FORMAT_DECIMAL_POUND;
return XML_INT_FORMAT_DECIMAL;
} | [
"int",
"xml_get_attribute_int_format",
"(",
"xml_data_node",
"*",
"node",
",",
"const",
"char",
"*",
"attribute",
")",
"{",
"const",
"char",
"*",
"string",
"=",
"xml_get_attribute_string",
"(",
"node",
",",
"attribute",
",",
"NULL",
")",
";",
"if",
"(",
"string",
"==",
"NULL",
")",
"return",
"XML_INT_FORMAT_DECIMAL",
";",
"if",
"(",
"string",
"[",
"0",
"]",
"==",
"'",
"'",
")",
"return",
"XML_INT_FORMAT_HEX_DOLLAR",
";",
"if",
"(",
"string",
"[",
"0",
"]",
"==",
"'",
"'",
"&&",
"string",
"[",
"1",
"]",
"==",
"'",
"'",
")",
"return",
"XML_INT_FORMAT_HEX_C",
";",
"if",
"(",
"string",
"[",
"0",
"]",
"==",
"'",
"'",
")",
"return",
"XML_INT_FORMAT_DECIMAL_POUND",
";",
"return",
"XML_INT_FORMAT_DECIMAL",
";",
"}"
] | xml_get_attribute_int_format - return the
format of the given integer attribute | [
"xml_get_attribute_int_format",
"-",
"return",
"the",
"format",
"of",
"the",
"given",
"integer",
"attribute"
] | [] | [
{
"param": "node",
"type": "xml_data_node"
},
{
"param": "attribute",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "xml_data_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "attribute",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | xml_get_attribute_float | float | float xml_get_attribute_float(xml_data_node *node, const char *attribute, float defvalue)
{
const char *string = xml_get_attribute_string(node, attribute, NULL);
float value;
if (string == NULL || sscanf(string, "%f", &value) != 1)
return defvalue;
return value;
} | /*-------------------------------------------------
xml_get_attribute_float - get the float
value of the specified attribute; if not
found, return = the provided default
-------------------------------------------------*/ | get the float
value of the specified attribute; if not
found, return = the provided default | [
"get",
"the",
"float",
"value",
"of",
"the",
"specified",
"attribute",
";",
"if",
"not",
"found",
"return",
"=",
"the",
"provided",
"default"
] | float xml_get_attribute_float(xml_data_node *node, const char *attribute, float defvalue)
{
const char *string = xml_get_attribute_string(node, attribute, NULL);
float value;
if (string == NULL || sscanf(string, "%f", &value) != 1)
return defvalue;
return value;
} | [
"float",
"xml_get_attribute_float",
"(",
"xml_data_node",
"*",
"node",
",",
"const",
"char",
"*",
"attribute",
",",
"float",
"defvalue",
")",
"{",
"const",
"char",
"*",
"string",
"=",
"xml_get_attribute_string",
"(",
"node",
",",
"attribute",
",",
"NULL",
")",
";",
"float",
"value",
";",
"if",
"(",
"string",
"==",
"NULL",
"||",
"sscanf",
"(",
"string",
",",
"\"",
"\"",
",",
"&",
"value",
")",
"!=",
"1",
")",
"return",
"defvalue",
";",
"return",
"value",
";",
"}"
] | xml_get_attribute_float - get the float
value of the specified attribute; if not
found, return = the provided default | [
"xml_get_attribute_float",
"-",
"get",
"the",
"float",
"value",
"of",
"the",
"specified",
"attribute",
";",
"if",
"not",
"found",
"return",
"=",
"the",
"provided",
"default"
] | [] | [
{
"param": "node",
"type": "xml_data_node"
},
{
"param": "attribute",
"type": "char"
},
{
"param": "defvalue",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "xml_data_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "attribute",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "defvalue",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | xml_set_attribute | xml_attribute_node | xml_attribute_node *xml_set_attribute(xml_data_node *node, const char *name, const char *value)
{
xml_attribute_node *anode;
/* first find an existing one to replace */
anode = xml_get_attribute(node, name);
/* if we found it, free the old value and replace it */
if (anode != NULL)
{
if (anode->value != NULL)
free((void *)anode->value);
anode->value = copystring(value);
}
/* otherwise, create a new node */
else
anode = add_attribute(node, name, value);
return anode;
} | /*-------------------------------------------------
xml_set_attribute - set a new attribute and
string value on the node
-------------------------------------------------*/ | set a new attribute and
string value on the node | [
"set",
"a",
"new",
"attribute",
"and",
"string",
"value",
"on",
"the",
"node"
] | xml_attribute_node *xml_set_attribute(xml_data_node *node, const char *name, const char *value)
{
xml_attribute_node *anode;
anode = xml_get_attribute(node, name);
if (anode != NULL)
{
if (anode->value != NULL)
free((void *)anode->value);
anode->value = copystring(value);
}
else
anode = add_attribute(node, name, value);
return anode;
} | [
"xml_attribute_node",
"*",
"xml_set_attribute",
"(",
"xml_data_node",
"*",
"node",
",",
"const",
"char",
"*",
"name",
",",
"const",
"char",
"*",
"value",
")",
"{",
"xml_attribute_node",
"*",
"anode",
";",
"anode",
"=",
"xml_get_attribute",
"(",
"node",
",",
"name",
")",
";",
"if",
"(",
"anode",
"!=",
"NULL",
")",
"{",
"if",
"(",
"anode",
"->",
"value",
"!=",
"NULL",
")",
"free",
"(",
"(",
"void",
"*",
")",
"anode",
"->",
"value",
")",
";",
"anode",
"->",
"value",
"=",
"copystring",
"(",
"value",
")",
";",
"}",
"else",
"anode",
"=",
"add_attribute",
"(",
"node",
",",
"name",
",",
"value",
")",
";",
"return",
"anode",
";",
"}"
] | xml_set_attribute - set a new attribute and
string value on the node | [
"xml_set_attribute",
"-",
"set",
"a",
"new",
"attribute",
"and",
"string",
"value",
"on",
"the",
"node"
] | [
"/* first find an existing one to replace */",
"/* if we found it, free the old value and replace it */",
"/* otherwise, create a new node */"
] | [
{
"param": "node",
"type": "xml_data_node"
},
{
"param": "name",
"type": "char"
},
{
"param": "value",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "xml_data_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "value",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | xml_set_attribute_int | xml_attribute_node | xml_attribute_node *xml_set_attribute_int(xml_data_node *node, const char *name, int value)
{
char buffer[100];
sprintf(buffer, "%d", value);
return xml_set_attribute(node, name, buffer);
} | /*-------------------------------------------------
xml_set_attribute_int - set a new attribute and
integer value on the node
-------------------------------------------------*/ | set a new attribute and
integer value on the node | [
"set",
"a",
"new",
"attribute",
"and",
"integer",
"value",
"on",
"the",
"node"
] | xml_attribute_node *xml_set_attribute_int(xml_data_node *node, const char *name, int value)
{
char buffer[100];
sprintf(buffer, "%d", value);
return xml_set_attribute(node, name, buffer);
} | [
"xml_attribute_node",
"*",
"xml_set_attribute_int",
"(",
"xml_data_node",
"*",
"node",
",",
"const",
"char",
"*",
"name",
",",
"int",
"value",
")",
"{",
"char",
"buffer",
"[",
"100",
"]",
";",
"sprintf",
"(",
"buffer",
",",
"\"",
"\"",
",",
"value",
")",
";",
"return",
"xml_set_attribute",
"(",
"node",
",",
"name",
",",
"buffer",
")",
";",
"}"
] | xml_set_attribute_int - set a new attribute and
integer value on the node | [
"xml_set_attribute_int",
"-",
"set",
"a",
"new",
"attribute",
"and",
"integer",
"value",
"on",
"the",
"node"
] | [] | [
{
"param": "node",
"type": "xml_data_node"
},
{
"param": "name",
"type": "char"
},
{
"param": "value",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "xml_data_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "value",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | xml_set_attribute_float | xml_attribute_node | xml_attribute_node *xml_set_attribute_float(xml_data_node *node, const char *name, float value)
{
char buffer[100];
sprintf(buffer, "%f", value);
return xml_set_attribute(node, name, buffer);
} | /*-------------------------------------------------
xml_set_attribute_int - set a new attribute and
float value on the node
-------------------------------------------------*/ | set a new attribute and
float value on the node | [
"set",
"a",
"new",
"attribute",
"and",
"float",
"value",
"on",
"the",
"node"
] | xml_attribute_node *xml_set_attribute_float(xml_data_node *node, const char *name, float value)
{
char buffer[100];
sprintf(buffer, "%f", value);
return xml_set_attribute(node, name, buffer);
} | [
"xml_attribute_node",
"*",
"xml_set_attribute_float",
"(",
"xml_data_node",
"*",
"node",
",",
"const",
"char",
"*",
"name",
",",
"float",
"value",
")",
"{",
"char",
"buffer",
"[",
"100",
"]",
";",
"sprintf",
"(",
"buffer",
",",
"\"",
"\"",
",",
"value",
")",
";",
"return",
"xml_set_attribute",
"(",
"node",
",",
"name",
",",
"buffer",
")",
";",
"}"
] | xml_set_attribute_int - set a new attribute and
float value on the node | [
"xml_set_attribute_int",
"-",
"set",
"a",
"new",
"attribute",
"and",
"float",
"value",
"on",
"the",
"node"
] | [] | [
{
"param": "node",
"type": "xml_data_node"
},
{
"param": "name",
"type": "char"
},
{
"param": "value",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "xml_data_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "value",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | xml_normalize_string | char | const char *xml_normalize_string(const char *string)
{
static char buffer[1024];
char *d = &buffer[0];
if (string != NULL)
{
while (*string)
{
switch (*string)
{
case '\"' : d += sprintf(d, """); break;
case '&' : d += sprintf(d, "&"); break;
case '<' : d += sprintf(d, "<"); break;
case '>' : d += sprintf(d, ">"); break;
default:
*d++ = *string;
}
++string;
}
}
*d++ = 0;
return buffer;
} | /*-------------------------------------------------
xml_normalize_string - normalize a string
to ensure it doesn't contain embedded tags
-------------------------------------------------*/ | normalize a string
to ensure it doesn't contain embedded tags | [
"normalize",
"a",
"string",
"to",
"ensure",
"it",
"doesn",
"'",
"t",
"contain",
"embedded",
"tags"
] | const char *xml_normalize_string(const char *string)
{
static char buffer[1024];
char *d = &buffer[0];
if (string != NULL)
{
while (*string)
{
switch (*string)
{
case '\"' : d += sprintf(d, """); break;
case '&' : d += sprintf(d, "&"); break;
case '<' : d += sprintf(d, "<"); break;
case '>' : d += sprintf(d, ">"); break;
default:
*d++ = *string;
}
++string;
}
}
*d++ = 0;
return buffer;
} | [
"const",
"char",
"*",
"xml_normalize_string",
"(",
"const",
"char",
"*",
"string",
")",
"{",
"static",
"char",
"buffer",
"[",
"1024",
"]",
";",
"char",
"*",
"d",
"=",
"&",
"buffer",
"[",
"0",
"]",
";",
"if",
"(",
"string",
"!=",
"NULL",
")",
"{",
"while",
"(",
"*",
"string",
")",
"{",
"switch",
"(",
"*",
"string",
")",
"{",
"case",
"'",
"\\\"",
"'",
":",
"d",
"+=",
"sprintf",
"(",
"d",
",",
"\"",
"\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"d",
"+=",
"sprintf",
"(",
"d",
",",
"\"",
"\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"d",
"+=",
"sprintf",
"(",
"d",
",",
"\"",
"\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"d",
"+=",
"sprintf",
"(",
"d",
",",
"\"",
"\"",
")",
";",
"break",
";",
"default",
":",
"*",
"d",
"++",
"=",
"*",
"string",
";",
"}",
"++",
"string",
";",
"}",
"}",
"*",
"d",
"++",
"=",
"0",
";",
"return",
"buffer",
";",
"}"
] | xml_normalize_string - normalize a string
to ensure it doesn't contain embedded tags | [
"xml_normalize_string",
"-",
"normalize",
"a",
"string",
"to",
"ensure",
"it",
"doesn",
"'",
"t",
"contain",
"embedded",
"tags"
] | [] | [
{
"param": "string",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "string",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | expat_element_start | void | static void expat_element_start(void *data, const XML_Char *name, const XML_Char **attributes)
{
xml_parse_info *parse_info = (xml_parse_info *) data;
xml_data_node **curnode = &parse_info->curnode;
xml_data_node *newnode;
int attr;
/* add a new child node to the current node */
newnode = add_child(*curnode, name, NULL);
if (newnode == NULL)
return;
/* remember the line number */
newnode->line = XML_GetCurrentLineNumber(parse_info->parser);
/* add all the attributes as well */
for (attr = 0; attributes[attr]; attr += 2)
add_attribute(newnode, attributes[attr+0], attributes[attr+1]);
/* set us up as the current node */
*curnode = newnode;
} | /*-------------------------------------------------
expat_element_start - expat callback for a new
element
-------------------------------------------------*/ | expat callback for a new
element | [
"expat",
"callback",
"for",
"a",
"new",
"element"
] | static void expat_element_start(void *data, const XML_Char *name, const XML_Char **attributes)
{
xml_parse_info *parse_info = (xml_parse_info *) data;
xml_data_node **curnode = &parse_info->curnode;
xml_data_node *newnode;
int attr;
newnode = add_child(*curnode, name, NULL);
if (newnode == NULL)
return;
newnode->line = XML_GetCurrentLineNumber(parse_info->parser);
for (attr = 0; attributes[attr]; attr += 2)
add_attribute(newnode, attributes[attr+0], attributes[attr+1]);
*curnode = newnode;
} | [
"static",
"void",
"expat_element_start",
"(",
"void",
"*",
"data",
",",
"const",
"XML_Char",
"*",
"name",
",",
"const",
"XML_Char",
"*",
"*",
"attributes",
")",
"{",
"xml_parse_info",
"*",
"parse_info",
"=",
"(",
"xml_parse_info",
"*",
")",
"data",
";",
"xml_data_node",
"*",
"*",
"curnode",
"=",
"&",
"parse_info",
"->",
"curnode",
";",
"xml_data_node",
"*",
"newnode",
";",
"int",
"attr",
";",
"newnode",
"=",
"add_child",
"(",
"*",
"curnode",
",",
"name",
",",
"NULL",
")",
";",
"if",
"(",
"newnode",
"==",
"NULL",
")",
"return",
";",
"newnode",
"->",
"line",
"=",
"XML_GetCurrentLineNumber",
"(",
"parse_info",
"->",
"parser",
")",
";",
"for",
"(",
"attr",
"=",
"0",
";",
"attributes",
"[",
"attr",
"]",
";",
"attr",
"+=",
"2",
")",
"add_attribute",
"(",
"newnode",
",",
"attributes",
"[",
"attr",
"+",
"0",
"]",
",",
"attributes",
"[",
"attr",
"+",
"1",
"]",
")",
";",
"*",
"curnode",
"=",
"newnode",
";",
"}"
] | expat_element_start - expat callback for a new
element | [
"expat_element_start",
"-",
"expat",
"callback",
"for",
"a",
"new",
"element"
] | [
"/* add a new child node to the current node */",
"/* remember the line number */",
"/* add all the attributes as well */",
"/* set us up as the current node */"
] | [
{
"param": "data",
"type": "void"
},
{
"param": "name",
"type": "XML_Char"
},
{
"param": "attributes",
"type": "XML_Char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "XML_Char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "attributes",
"type": "XML_Char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | expat_data | void | static void expat_data(void *data, const XML_Char *s, int len)
{
xml_parse_info *parse_info = (xml_parse_info *) data;
xml_data_node **curnode = &parse_info->curnode;
int oldlen = 0;
char *newdata;
/* if no data, skip */
if (len == 0)
return;
/* determine how much data we currently have */
if ((*curnode)->value != NULL)
oldlen = (int)strlen((*curnode)->value);
/* realloc */
newdata = (char *)realloc((void *)(*curnode)->value, oldlen + len + 1);
if (newdata == NULL)
return;
/* copy in the new data a NULL-terminate */
memcpy(&newdata[oldlen], s, len);
newdata[oldlen + len] = 0;
(*curnode)->value = newdata;
} | /*-------------------------------------------------
expat_data - expat callback for a additional
element data
-------------------------------------------------*/ | expat callback for a additional
element data | [
"expat",
"callback",
"for",
"a",
"additional",
"element",
"data"
] | static void expat_data(void *data, const XML_Char *s, int len)
{
xml_parse_info *parse_info = (xml_parse_info *) data;
xml_data_node **curnode = &parse_info->curnode;
int oldlen = 0;
char *newdata;
if (len == 0)
return;
if ((*curnode)->value != NULL)
oldlen = (int)strlen((*curnode)->value);
newdata = (char *)realloc((void *)(*curnode)->value, oldlen + len + 1);
if (newdata == NULL)
return;
memcpy(&newdata[oldlen], s, len);
newdata[oldlen + len] = 0;
(*curnode)->value = newdata;
} | [
"static",
"void",
"expat_data",
"(",
"void",
"*",
"data",
",",
"const",
"XML_Char",
"*",
"s",
",",
"int",
"len",
")",
"{",
"xml_parse_info",
"*",
"parse_info",
"=",
"(",
"xml_parse_info",
"*",
")",
"data",
";",
"xml_data_node",
"*",
"*",
"curnode",
"=",
"&",
"parse_info",
"->",
"curnode",
";",
"int",
"oldlen",
"=",
"0",
";",
"char",
"*",
"newdata",
";",
"if",
"(",
"len",
"==",
"0",
")",
"return",
";",
"if",
"(",
"(",
"*",
"curnode",
")",
"->",
"value",
"!=",
"NULL",
")",
"oldlen",
"=",
"(",
"int",
")",
"strlen",
"(",
"(",
"*",
"curnode",
")",
"->",
"value",
")",
";",
"newdata",
"=",
"(",
"char",
"*",
")",
"realloc",
"(",
"(",
"void",
"*",
")",
"(",
"*",
"curnode",
")",
"->",
"value",
",",
"oldlen",
"+",
"len",
"+",
"1",
")",
";",
"if",
"(",
"newdata",
"==",
"NULL",
")",
"return",
";",
"memcpy",
"(",
"&",
"newdata",
"[",
"oldlen",
"]",
",",
"s",
",",
"len",
")",
";",
"newdata",
"[",
"oldlen",
"+",
"len",
"]",
"=",
"0",
";",
"(",
"*",
"curnode",
")",
"->",
"value",
"=",
"newdata",
";",
"}"
] | expat_data - expat callback for a additional
element data | [
"expat_data",
"-",
"expat",
"callback",
"for",
"a",
"additional",
"element",
"data"
] | [
"/* if no data, skip */",
"/* determine how much data we currently have */",
"/* realloc */",
"/* copy in the new data a NULL-terminate */"
] | [
{
"param": "data",
"type": "void"
},
{
"param": "s",
"type": "XML_Char"
},
{
"param": "len",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "s",
"type": "XML_Char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "len",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | expat_element_end | void | static void expat_element_end(void *data, const XML_Char *name)
{
xml_parse_info *parse_info = (xml_parse_info *) data;
xml_data_node **curnode = &parse_info->curnode;
char *orig;
/* strip leading/trailing spaces from the value data */
orig = (char *)(*curnode)->value;
if (orig != NULL && !(parse_info->flags & XML_PARSE_FLAG_WHITESPACE_SIGNIFICANT))
{
char *start = orig;
char *end = start + strlen(start);
/* first strip leading spaces */
while (*start && isspace((UINT8)*start))
start++;
/* then strip trailing spaces */
while (end > start && isspace((UINT8)end[-1]))
end--;
/* if nothing left, just free it */
if (start == end)
{
free(orig);
(*curnode)->value = NULL;
}
/* otherwise, memmove the data */
else
{
memmove(orig, start, end - start);
orig[end - start] = 0;
}
}
/* back us up a node */
*curnode = (*curnode)->parent;
} | /*-------------------------------------------------
expat_element_end - expat callback for the end
of an element
-------------------------------------------------*/ | expat callback for the end
of an element | [
"expat",
"callback",
"for",
"the",
"end",
"of",
"an",
"element"
] | static void expat_element_end(void *data, const XML_Char *name)
{
xml_parse_info *parse_info = (xml_parse_info *) data;
xml_data_node **curnode = &parse_info->curnode;
char *orig;
orig = (char *)(*curnode)->value;
if (orig != NULL && !(parse_info->flags & XML_PARSE_FLAG_WHITESPACE_SIGNIFICANT))
{
char *start = orig;
char *end = start + strlen(start);
while (*start && isspace((UINT8)*start))
start++;
while (end > start && isspace((UINT8)end[-1]))
end--;
if (start == end)
{
free(orig);
(*curnode)->value = NULL;
}
else
{
memmove(orig, start, end - start);
orig[end - start] = 0;
}
}
*curnode = (*curnode)->parent;
} | [
"static",
"void",
"expat_element_end",
"(",
"void",
"*",
"data",
",",
"const",
"XML_Char",
"*",
"name",
")",
"{",
"xml_parse_info",
"*",
"parse_info",
"=",
"(",
"xml_parse_info",
"*",
")",
"data",
";",
"xml_data_node",
"*",
"*",
"curnode",
"=",
"&",
"parse_info",
"->",
"curnode",
";",
"char",
"*",
"orig",
";",
"orig",
"=",
"(",
"char",
"*",
")",
"(",
"*",
"curnode",
")",
"->",
"value",
";",
"if",
"(",
"orig",
"!=",
"NULL",
"&&",
"!",
"(",
"parse_info",
"->",
"flags",
"&",
"XML_PARSE_FLAG_WHITESPACE_SIGNIFICANT",
")",
")",
"{",
"char",
"*",
"start",
"=",
"orig",
";",
"char",
"*",
"end",
"=",
"start",
"+",
"strlen",
"(",
"start",
")",
";",
"while",
"(",
"*",
"start",
"&&",
"isspace",
"(",
"(",
"UINT8",
")",
"*",
"start",
")",
")",
"start",
"++",
";",
"while",
"(",
"end",
">",
"start",
"&&",
"isspace",
"(",
"(",
"UINT8",
")",
"end",
"[",
"-1",
"]",
")",
")",
"end",
"--",
";",
"if",
"(",
"start",
"==",
"end",
")",
"{",
"free",
"(",
"orig",
")",
";",
"(",
"*",
"curnode",
")",
"->",
"value",
"=",
"NULL",
";",
"}",
"else",
"{",
"memmove",
"(",
"orig",
",",
"start",
",",
"end",
"-",
"start",
")",
";",
"orig",
"[",
"end",
"-",
"start",
"]",
"=",
"0",
";",
"}",
"}",
"*",
"curnode",
"=",
"(",
"*",
"curnode",
")",
"->",
"parent",
";",
"}"
] | expat_element_end - expat callback for the end
of an element | [
"expat_element_end",
"-",
"expat",
"callback",
"for",
"the",
"end",
"of",
"an",
"element"
] | [
"/* strip leading/trailing spaces from the value data */",
"/* first strip leading spaces */",
"/* then strip trailing spaces */",
"/* if nothing left, just free it */",
"/* otherwise, memmove the data */",
"/* back us up a node */"
] | [
{
"param": "data",
"type": "void"
},
{
"param": "name",
"type": "XML_Char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "XML_Char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | add_child | xml_data_node | static xml_data_node *add_child(xml_data_node *parent, const char *name, const char *value)
{
xml_data_node **pnode;
xml_data_node *node;
/* new element: create a new node */
node = (xml_data_node *)malloc(sizeof(*node));
if (node == NULL)
return NULL;
/* initialize the members */
node->next = NULL;
node->parent = parent;
node->child = NULL;
node->name = copystring_lower(name);
if (node->name == NULL)
{
free(node);
return NULL;
}
node->value = copystring(value);
if (node->value == NULL && value != NULL)
{
free((void *)node->name);
free(node);
return NULL;
}
node->attribute = NULL;
/* add us to the end of the list of siblings */
for (pnode = &parent->child; *pnode; pnode = &(*pnode)->next) ;
*pnode = node;
return node;
} | /*-------------------------------------------------
add_child - add a new node to the parent
-------------------------------------------------*/ | add a new node to the parent | [
"add",
"a",
"new",
"node",
"to",
"the",
"parent"
] | static xml_data_node *add_child(xml_data_node *parent, const char *name, const char *value)
{
xml_data_node **pnode;
xml_data_node *node;
node = (xml_data_node *)malloc(sizeof(*node));
if (node == NULL)
return NULL;
node->next = NULL;
node->parent = parent;
node->child = NULL;
node->name = copystring_lower(name);
if (node->name == NULL)
{
free(node);
return NULL;
}
node->value = copystring(value);
if (node->value == NULL && value != NULL)
{
free((void *)node->name);
free(node);
return NULL;
}
node->attribute = NULL;
for (pnode = &parent->child; *pnode; pnode = &(*pnode)->next) ;
*pnode = node;
return node;
} | [
"static",
"xml_data_node",
"*",
"add_child",
"(",
"xml_data_node",
"*",
"parent",
",",
"const",
"char",
"*",
"name",
",",
"const",
"char",
"*",
"value",
")",
"{",
"xml_data_node",
"*",
"*",
"pnode",
";",
"xml_data_node",
"*",
"node",
";",
"node",
"=",
"(",
"xml_data_node",
"*",
")",
"malloc",
"(",
"sizeof",
"(",
"*",
"node",
")",
")",
";",
"if",
"(",
"node",
"==",
"NULL",
")",
"return",
"NULL",
";",
"node",
"->",
"next",
"=",
"NULL",
";",
"node",
"->",
"parent",
"=",
"parent",
";",
"node",
"->",
"child",
"=",
"NULL",
";",
"node",
"->",
"name",
"=",
"copystring_lower",
"(",
"name",
")",
";",
"if",
"(",
"node",
"->",
"name",
"==",
"NULL",
")",
"{",
"free",
"(",
"node",
")",
";",
"return",
"NULL",
";",
"}",
"node",
"->",
"value",
"=",
"copystring",
"(",
"value",
")",
";",
"if",
"(",
"node",
"->",
"value",
"==",
"NULL",
"&&",
"value",
"!=",
"NULL",
")",
"{",
"free",
"(",
"(",
"void",
"*",
")",
"node",
"->",
"name",
")",
";",
"free",
"(",
"node",
")",
";",
"return",
"NULL",
";",
"}",
"node",
"->",
"attribute",
"=",
"NULL",
";",
"for",
"(",
"pnode",
"=",
"&",
"parent",
"->",
"child",
";",
"*",
"pnode",
";",
"pnode",
"=",
"&",
"(",
"*",
"pnode",
")",
"->",
"next",
")",
";",
"*",
"pnode",
"=",
"node",
";",
"return",
"node",
";",
"}"
] | add_child - add a new node to the parent | [
"add_child",
"-",
"add",
"a",
"new",
"node",
"to",
"the",
"parent"
] | [
"/* new element: create a new node */",
"/* initialize the members */",
"/* add us to the end of the list of siblings */"
] | [
{
"param": "parent",
"type": "xml_data_node"
},
{
"param": "name",
"type": "char"
},
{
"param": "value",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "parent",
"type": "xml_data_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "value",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | add_attribute | xml_attribute_node | static xml_attribute_node *add_attribute(xml_data_node *node, const char *name, const char *value)
{
xml_attribute_node *anode, **panode;
/* allocate a new attribute node */
anode = (xml_attribute_node *)malloc(sizeof(*anode));
if (anode == NULL)
return NULL;
/* fill it in */
anode->next = NULL;
anode->name = copystring_lower(name);
if (anode->name == NULL)
{
free(anode);
return NULL;
}
anode->value = copystring(value);
if (anode->value == NULL)
{
free((void *)anode->name);
free(anode);
return NULL;
}
/* add us to the end of the list of attributes */
for (panode = &node->attribute; *panode; panode = &(*panode)->next) ;
*panode = anode;
return anode;
} | /*-------------------------------------------------
add_attribute - add a new attribute to the
given node
-------------------------------------------------*/ | add a new attribute to the
given node | [
"add",
"a",
"new",
"attribute",
"to",
"the",
"given",
"node"
] | static xml_attribute_node *add_attribute(xml_data_node *node, const char *name, const char *value)
{
xml_attribute_node *anode, **panode;
anode = (xml_attribute_node *)malloc(sizeof(*anode));
if (anode == NULL)
return NULL;
anode->next = NULL;
anode->name = copystring_lower(name);
if (anode->name == NULL)
{
free(anode);
return NULL;
}
anode->value = copystring(value);
if (anode->value == NULL)
{
free((void *)anode->name);
free(anode);
return NULL;
}
for (panode = &node->attribute; *panode; panode = &(*panode)->next) ;
*panode = anode;
return anode;
} | [
"static",
"xml_attribute_node",
"*",
"add_attribute",
"(",
"xml_data_node",
"*",
"node",
",",
"const",
"char",
"*",
"name",
",",
"const",
"char",
"*",
"value",
")",
"{",
"xml_attribute_node",
"*",
"anode",
",",
"*",
"*",
"panode",
";",
"anode",
"=",
"(",
"xml_attribute_node",
"*",
")",
"malloc",
"(",
"sizeof",
"(",
"*",
"anode",
")",
")",
";",
"if",
"(",
"anode",
"==",
"NULL",
")",
"return",
"NULL",
";",
"anode",
"->",
"next",
"=",
"NULL",
";",
"anode",
"->",
"name",
"=",
"copystring_lower",
"(",
"name",
")",
";",
"if",
"(",
"anode",
"->",
"name",
"==",
"NULL",
")",
"{",
"free",
"(",
"anode",
")",
";",
"return",
"NULL",
";",
"}",
"anode",
"->",
"value",
"=",
"copystring",
"(",
"value",
")",
";",
"if",
"(",
"anode",
"->",
"value",
"==",
"NULL",
")",
"{",
"free",
"(",
"(",
"void",
"*",
")",
"anode",
"->",
"name",
")",
";",
"free",
"(",
"anode",
")",
";",
"return",
"NULL",
";",
"}",
"for",
"(",
"panode",
"=",
"&",
"node",
"->",
"attribute",
";",
"*",
"panode",
";",
"panode",
"=",
"&",
"(",
"*",
"panode",
")",
"->",
"next",
")",
";",
"*",
"panode",
"=",
"anode",
";",
"return",
"anode",
";",
"}"
] | add_attribute - add a new attribute to the
given node | [
"add_attribute",
"-",
"add",
"a",
"new",
"attribute",
"to",
"the",
"given",
"node"
] | [
"/* allocate a new attribute node */",
"/* fill it in */",
"/* add us to the end of the list of attributes */"
] | [
{
"param": "node",
"type": "xml_data_node"
},
{
"param": "name",
"type": "char"
},
{
"param": "value",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "xml_data_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "value",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | write_node_recursive | void | static void write_node_recursive(xml_data_node *node, int indent, core_file *file)
{
xml_attribute_node *anode;
xml_data_node *child;
/* output this tag */
core_fprintf(file, "%*s<%s", indent, "", node->name);
/* output any attributes */
for (anode = node->attribute; anode; anode = anode->next)
core_fprintf(file, " %s=\"%s\"", anode->name, anode->value);
/* if there are no children and no value, end the tag here */
if (node->child == NULL && node->value == NULL)
core_fprintf(file, " />\n");
/* otherwise, close this tag and output more stuff */
else
{
core_fprintf(file, ">\n");
/* if there is a value, output that here */
if (node->value != NULL)
core_fprintf(file, "%*s%s\n", indent + 4, "", node->value);
/* loop over children and output them as well */
if (node->child != NULL)
{
for (child = node->child; child; child = child->next)
write_node_recursive(child, indent + 4, file);
}
/* write a closing tag */
core_fprintf(file, "%*s</%s>\n", indent, "", node->name);
}
} | /*-------------------------------------------------
write_node_recursive - recursively write
an XML node and its children to a file
-------------------------------------------------*/ | recursively write
an XML node and its children to a file | [
"recursively",
"write",
"an",
"XML",
"node",
"and",
"its",
"children",
"to",
"a",
"file"
] | static void write_node_recursive(xml_data_node *node, int indent, core_file *file)
{
xml_attribute_node *anode;
xml_data_node *child;
core_fprintf(file, "%*s<%s", indent, "", node->name);
for (anode = node->attribute; anode; anode = anode->next)
core_fprintf(file, " %s=\"%s\"", anode->name, anode->value);
if (node->child == NULL && node->value == NULL)
core_fprintf(file, " />\n");
else
{
core_fprintf(file, ">\n");
if (node->value != NULL)
core_fprintf(file, "%*s%s\n", indent + 4, "", node->value);
if (node->child != NULL)
{
for (child = node->child; child; child = child->next)
write_node_recursive(child, indent + 4, file);
}
core_fprintf(file, "%*s</%s>\n", indent, "", node->name);
}
} | [
"static",
"void",
"write_node_recursive",
"(",
"xml_data_node",
"*",
"node",
",",
"int",
"indent",
",",
"core_file",
"*",
"file",
")",
"{",
"xml_attribute_node",
"*",
"anode",
";",
"xml_data_node",
"*",
"child",
";",
"core_fprintf",
"(",
"file",
",",
"\"",
"\"",
",",
"indent",
",",
"\"",
"\"",
",",
"node",
"->",
"name",
")",
";",
"for",
"(",
"anode",
"=",
"node",
"->",
"attribute",
";",
"anode",
";",
"anode",
"=",
"anode",
"->",
"next",
")",
"core_fprintf",
"(",
"file",
",",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"anode",
"->",
"name",
",",
"anode",
"->",
"value",
")",
";",
"if",
"(",
"node",
"->",
"child",
"==",
"NULL",
"&&",
"node",
"->",
"value",
"==",
"NULL",
")",
"core_fprintf",
"(",
"file",
",",
"\"",
"\\n",
"\"",
")",
";",
"else",
"{",
"core_fprintf",
"(",
"file",
",",
"\"",
"\\n",
"\"",
")",
";",
"if",
"(",
"node",
"->",
"value",
"!=",
"NULL",
")",
"core_fprintf",
"(",
"file",
",",
"\"",
"\\n",
"\"",
",",
"indent",
"+",
"4",
",",
"\"",
"\"",
",",
"node",
"->",
"value",
")",
";",
"if",
"(",
"node",
"->",
"child",
"!=",
"NULL",
")",
"{",
"for",
"(",
"child",
"=",
"node",
"->",
"child",
";",
"child",
";",
"child",
"=",
"child",
"->",
"next",
")",
"write_node_recursive",
"(",
"child",
",",
"indent",
"+",
"4",
",",
"file",
")",
";",
"}",
"core_fprintf",
"(",
"file",
",",
"\"",
"\\n",
"\"",
",",
"indent",
",",
"\"",
"\"",
",",
"node",
"->",
"name",
")",
";",
"}",
"}"
] | write_node_recursive - recursively write
an XML node and its children to a file | [
"write_node_recursive",
"-",
"recursively",
"write",
"an",
"XML",
"node",
"and",
"its",
"children",
"to",
"a",
"file"
] | [
"/* output this tag */",
"/* output any attributes */",
"/* if there are no children and no value, end the tag here */",
"/* otherwise, close this tag and output more stuff */",
"/* if there is a value, output that here */",
"/* loop over children and output them as well */",
"/* write a closing tag */"
] | [
{
"param": "node",
"type": "xml_data_node"
},
{
"param": "indent",
"type": "int"
},
{
"param": "file",
"type": "core_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "xml_data_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "indent",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type": "core_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c46a328572438f4f9f64412947473c9d48299ab | lofunz/mieme | Reloaded/trunk/src/lib/util/xmlfile.c | [
"Unlicense"
] | C | free_node_recursive | void | static void free_node_recursive(xml_data_node *node)
{
xml_attribute_node *anode, *nanode;
xml_data_node *child, *nchild;
/* free name/value */
if (node->name != NULL)
free((void *)node->name);
if (node->value != NULL)
free((void *)node->value);
/* free attributes */
for (anode = node->attribute; anode; anode = nanode)
{
/* free name/value */
if (anode->name != NULL)
free((void *)anode->name);
if (anode->value != NULL)
free((void *)anode->value);
/* note the next node and free this node */
nanode = anode->next;
free(anode);
}
/* free the children */
for (child = node->child; child; child = nchild)
{
/* note the next node and free this node */
nchild = child->next;
free_node_recursive(child);
}
/* finally free ourself */
free(node);
} | /*-------------------------------------------------
free_node_recursive - recursively free
the data allocated to an XML node
-------------------------------------------------*/ | recursively free
the data allocated to an XML node | [
"recursively",
"free",
"the",
"data",
"allocated",
"to",
"an",
"XML",
"node"
] | static void free_node_recursive(xml_data_node *node)
{
xml_attribute_node *anode, *nanode;
xml_data_node *child, *nchild;
if (node->name != NULL)
free((void *)node->name);
if (node->value != NULL)
free((void *)node->value);
for (anode = node->attribute; anode; anode = nanode)
{
if (anode->name != NULL)
free((void *)anode->name);
if (anode->value != NULL)
free((void *)anode->value);
nanode = anode->next;
free(anode);
}
for (child = node->child; child; child = nchild)
{
nchild = child->next;
free_node_recursive(child);
}
free(node);
} | [
"static",
"void",
"free_node_recursive",
"(",
"xml_data_node",
"*",
"node",
")",
"{",
"xml_attribute_node",
"*",
"anode",
",",
"*",
"nanode",
";",
"xml_data_node",
"*",
"child",
",",
"*",
"nchild",
";",
"if",
"(",
"node",
"->",
"name",
"!=",
"NULL",
")",
"free",
"(",
"(",
"void",
"*",
")",
"node",
"->",
"name",
")",
";",
"if",
"(",
"node",
"->",
"value",
"!=",
"NULL",
")",
"free",
"(",
"(",
"void",
"*",
")",
"node",
"->",
"value",
")",
";",
"for",
"(",
"anode",
"=",
"node",
"->",
"attribute",
";",
"anode",
";",
"anode",
"=",
"nanode",
")",
"{",
"if",
"(",
"anode",
"->",
"name",
"!=",
"NULL",
")",
"free",
"(",
"(",
"void",
"*",
")",
"anode",
"->",
"name",
")",
";",
"if",
"(",
"anode",
"->",
"value",
"!=",
"NULL",
")",
"free",
"(",
"(",
"void",
"*",
")",
"anode",
"->",
"value",
")",
";",
"nanode",
"=",
"anode",
"->",
"next",
";",
"free",
"(",
"anode",
")",
";",
"}",
"for",
"(",
"child",
"=",
"node",
"->",
"child",
";",
"child",
";",
"child",
"=",
"nchild",
")",
"{",
"nchild",
"=",
"child",
"->",
"next",
";",
"free_node_recursive",
"(",
"child",
")",
";",
"}",
"free",
"(",
"node",
")",
";",
"}"
] | free_node_recursive - recursively free
the data allocated to an XML node | [
"free_node_recursive",
"-",
"recursively",
"free",
"the",
"data",
"allocated",
"to",
"an",
"XML",
"node"
] | [
"/* free name/value */",
"/* free attributes */",
"/* free name/value */",
"/* note the next node and free this node */",
"/* free the children */",
"/* note the next node and free this node */",
"/* finally free ourself */"
] | [
{
"param": "node",
"type": "xml_data_node"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "xml_data_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
02f6efcef29e107fa99ffa01cf9979338e99f5f0 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/clifront.c | [
"Unlicense"
] | C | execute_simple_commands | int | static int execute_simple_commands(core_options *options, const char *exename)
{
/* help? */
if (options_get_bool(options, CLIOPTION_HELP))
{
display_help();
return MAMERR_NONE;
}
/* showusage? */
if (options_get_bool(options, CLIOPTION_SHOWUSAGE))
{
mame_printf_info("Usage: %s [%s] [options]\n\nOptions:\n", exename, GAMENOUN);
options_output_help(options, help_output);
return MAMERR_NONE;
}
/* validate? */
if (options_get_bool(options, CLIOPTION_VALIDATE))
{
extern int mame_validitychecks(const game_driver *driver);
return mame_validitychecks(NULL);
}
return -1;
} | /*-------------------------------------------------
execute_simple_commands - execute basic
commands that don't require any context
-------------------------------------------------*/ | execute basic
commands that don't require any context | [
"execute",
"basic",
"commands",
"that",
"don",
"'",
"t",
"require",
"any",
"context"
] | static int execute_simple_commands(core_options *options, const char *exename)
{
if (options_get_bool(options, CLIOPTION_HELP))
{
display_help();
return MAMERR_NONE;
}
if (options_get_bool(options, CLIOPTION_SHOWUSAGE))
{
mame_printf_info("Usage: %s [%s] [options]\n\nOptions:\n", exename, GAMENOUN);
options_output_help(options, help_output);
return MAMERR_NONE;
}
if (options_get_bool(options, CLIOPTION_VALIDATE))
{
extern int mame_validitychecks(const game_driver *driver);
return mame_validitychecks(NULL);
}
return -1;
} | [
"static",
"int",
"execute_simple_commands",
"(",
"core_options",
"*",
"options",
",",
"const",
"char",
"*",
"exename",
")",
"{",
"if",
"(",
"options_get_bool",
"(",
"options",
",",
"CLIOPTION_HELP",
")",
")",
"{",
"display_help",
"(",
")",
";",
"return",
"MAMERR_NONE",
";",
"}",
"if",
"(",
"options_get_bool",
"(",
"options",
",",
"CLIOPTION_SHOWUSAGE",
")",
")",
"{",
"mame_printf_info",
"(",
"\"",
"\\n",
"\\n",
"\\n",
"\"",
",",
"exename",
",",
"GAMENOUN",
")",
";",
"options_output_help",
"(",
"options",
",",
"help_output",
")",
";",
"return",
"MAMERR_NONE",
";",
"}",
"if",
"(",
"options_get_bool",
"(",
"options",
",",
"CLIOPTION_VALIDATE",
")",
")",
"{",
"extern",
"int",
"mame_validitychecks",
"(",
"const",
"game_driver",
"*",
"driver",
")",
";",
"return",
"mame_validitychecks",
"(",
"NULL",
")",
";",
"}",
"return",
"-1",
";",
"}"
] | execute_simple_commands - execute basic
commands that don't require any context | [
"execute_simple_commands",
"-",
"execute",
"basic",
"commands",
"that",
"don",
"'",
"t",
"require",
"any",
"context"
] | [
"/* help? */",
"/* showusage? */",
"/* validate? */"
] | [
{
"param": "options",
"type": "core_options"
},
{
"param": "exename",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "options",
"type": "core_options",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "exename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
02f6efcef29e107fa99ffa01cf9979338e99f5f0 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/clifront.c | [
"Unlicense"
] | C | cli_info_listxml | int | int cli_info_listxml(core_options *options, const char *gamename)
{
/* since print_mame_xml expands the machine driver, we need to set things up */
init_resource_tracking();
print_mame_xml(stdout, drivers, gamename);
/* clean up our tracked resources */
exit_resource_tracking();
return MAMERR_NONE;
} | /*-------------------------------------------------
cli_info_listxml - output the XML data for one
or more games
-------------------------------------------------*/ | output the XML data for one
or more games | [
"output",
"the",
"XML",
"data",
"for",
"one",
"or",
"more",
"games"
] | int cli_info_listxml(core_options *options, const char *gamename)
{
init_resource_tracking();
print_mame_xml(stdout, drivers, gamename);
exit_resource_tracking();
return MAMERR_NONE;
} | [
"int",
"cli_info_listxml",
"(",
"core_options",
"*",
"options",
",",
"const",
"char",
"*",
"gamename",
")",
"{",
"init_resource_tracking",
"(",
")",
";",
"print_mame_xml",
"(",
"stdout",
",",
"drivers",
",",
"gamename",
")",
";",
"exit_resource_tracking",
"(",
")",
";",
"return",
"MAMERR_NONE",
";",
"}"
] | cli_info_listxml - output the XML data for one
or more games | [
"cli_info_listxml",
"-",
"output",
"the",
"XML",
"data",
"for",
"one",
"or",
"more",
"games"
] | [
"/* since print_mame_xml expands the machine driver, we need to set things up */",
"/* clean up our tracked resources */"
] | [
{
"param": "options",
"type": "core_options"
},
{
"param": "gamename",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "options",
"type": "core_options",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gamename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
02f6efcef29e107fa99ffa01cf9979338e99f5f0 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/clifront.c | [
"Unlicense"
] | C | cli_info_listfull | int | int cli_info_listfull(core_options *options, const char *gamename)
{
int drvindex, count = 0;
/* iterate over drivers */
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if ((drivers[drvindex]->flags & GAME_NO_STANDALONE) == 0 && mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
/* print the header on the first one */
if (count == 0)
mame_printf_info("Name: Description:\n");
/* output the remaining information */
mame_printf_info("%-18s\"%s\"\n", drivers[drvindex]->name, drivers[drvindex]->description);
count++;
}
/* return an error if none found */
return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
} | /*-------------------------------------------------
cli_info_listfull - output the name and description
of one or more games
-------------------------------------------------*/ | output the name and description
of one or more games | [
"output",
"the",
"name",
"and",
"description",
"of",
"one",
"or",
"more",
"games"
] | int cli_info_listfull(core_options *options, const char *gamename)
{
int drvindex, count = 0;
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if ((drivers[drvindex]->flags & GAME_NO_STANDALONE) == 0 && mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
if (count == 0)
mame_printf_info("Name: Description:\n");
mame_printf_info("%-18s\"%s\"\n", drivers[drvindex]->name, drivers[drvindex]->description);
count++;
}
return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
} | [
"int",
"cli_info_listfull",
"(",
"core_options",
"*",
"options",
",",
"const",
"char",
"*",
"gamename",
")",
"{",
"int",
"drvindex",
",",
"count",
"=",
"0",
";",
"for",
"(",
"drvindex",
"=",
"0",
";",
"drivers",
"[",
"drvindex",
"]",
"!=",
"NULL",
";",
"drvindex",
"++",
")",
"if",
"(",
"(",
"drivers",
"[",
"drvindex",
"]",
"->",
"flags",
"&",
"GAME_NO_STANDALONE",
")",
"==",
"0",
"&&",
"mame_strwildcmp",
"(",
"gamename",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"name",
")",
"==",
"0",
")",
"{",
"if",
"(",
"count",
"==",
"0",
")",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
")",
";",
"mame_printf_info",
"(",
"\"",
"\\\"",
"\\\"",
"\\n",
"\"",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"name",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"description",
")",
";",
"count",
"++",
";",
"}",
"return",
"(",
"count",
">",
"0",
")",
"?",
"MAMERR_NONE",
":",
"MAMERR_NO_SUCH_GAME",
";",
"}"
] | cli_info_listfull - output the name and description
of one or more games | [
"cli_info_listfull",
"-",
"output",
"the",
"name",
"and",
"description",
"of",
"one",
"or",
"more",
"games"
] | [
"/* iterate over drivers */",
"/* print the header on the first one */",
"/* output the remaining information */",
"/* return an error if none found */"
] | [
{
"param": "options",
"type": "core_options"
},
{
"param": "gamename",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "options",
"type": "core_options",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gamename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
02f6efcef29e107fa99ffa01cf9979338e99f5f0 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/clifront.c | [
"Unlicense"
] | C | cli_info_listsource | int | int cli_info_listsource(core_options *options, const char *gamename)
{
astring *filename = astring_alloc();
int drvindex, count = 0;
/* iterate over drivers */
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
/* output the remaining information */
mame_printf_info("%-16s %s\n", drivers[drvindex]->name, astring_c(core_filename_extract_base(filename, drivers[drvindex]->source_file, FALSE)));
count++;
}
/* return an error if none found */
astring_free(filename);
return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
} | /*-------------------------------------------------
cli_info_listsource - output the name and source
filename of one or more games
-------------------------------------------------*/ | output the name and source
filename of one or more games | [
"output",
"the",
"name",
"and",
"source",
"filename",
"of",
"one",
"or",
"more",
"games"
] | int cli_info_listsource(core_options *options, const char *gamename)
{
astring *filename = astring_alloc();
int drvindex, count = 0;
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
mame_printf_info("%-16s %s\n", drivers[drvindex]->name, astring_c(core_filename_extract_base(filename, drivers[drvindex]->source_file, FALSE)));
count++;
}
astring_free(filename);
return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
} | [
"int",
"cli_info_listsource",
"(",
"core_options",
"*",
"options",
",",
"const",
"char",
"*",
"gamename",
")",
"{",
"astring",
"*",
"filename",
"=",
"astring_alloc",
"(",
")",
";",
"int",
"drvindex",
",",
"count",
"=",
"0",
";",
"for",
"(",
"drvindex",
"=",
"0",
";",
"drivers",
"[",
"drvindex",
"]",
"!=",
"NULL",
";",
"drvindex",
"++",
")",
"if",
"(",
"mame_strwildcmp",
"(",
"gamename",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"name",
")",
"==",
"0",
")",
"{",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"name",
",",
"astring_c",
"(",
"core_filename_extract_base",
"(",
"filename",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"source_file",
",",
"FALSE",
")",
")",
")",
";",
"count",
"++",
";",
"}",
"astring_free",
"(",
"filename",
")",
";",
"return",
"(",
"count",
">",
"0",
")",
"?",
"MAMERR_NONE",
":",
"MAMERR_NO_SUCH_GAME",
";",
"}"
] | cli_info_listsource - output the name and source
filename of one or more games | [
"cli_info_listsource",
"-",
"output",
"the",
"name",
"and",
"source",
"filename",
"of",
"one",
"or",
"more",
"games"
] | [
"/* iterate over drivers */",
"/* output the remaining information */",
"/* return an error if none found */"
] | [
{
"param": "options",
"type": "core_options"
},
{
"param": "gamename",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "options",
"type": "core_options",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gamename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
02f6efcef29e107fa99ffa01cf9979338e99f5f0 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/clifront.c | [
"Unlicense"
] | C | cli_info_listclones | int | int cli_info_listclones(core_options *options, const char *gamename)
{
int drvindex, count = 0;
/* iterate over drivers */
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
{
const game_driver *clone_of = driver_get_clone(drivers[drvindex]);
/* if we are a clone, and either our name matches the gamename, or the clone's name matches, display us */
if (clone_of != NULL && (clone_of->flags & GAME_IS_BIOS_ROOT) == 0)
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0 || mame_strwildcmp(gamename, clone_of->name) == 0)
{
/* print the header on the first one */
if (count == 0)
mame_printf_info("Name: Clone of:\n");
/* output the remaining information */
mame_printf_info("%-16s %-8s\n", drivers[drvindex]->name, clone_of->name);
count++;
}
}
/* return an error if none found */
return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
} | /*-------------------------------------------------
cli_info_listclones - output the name and source
filename of one or more games
-------------------------------------------------*/ | output the name and source
filename of one or more games | [
"output",
"the",
"name",
"and",
"source",
"filename",
"of",
"one",
"or",
"more",
"games"
] | int cli_info_listclones(core_options *options, const char *gamename)
{
int drvindex, count = 0;
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
{
const game_driver *clone_of = driver_get_clone(drivers[drvindex]);
if (clone_of != NULL && (clone_of->flags & GAME_IS_BIOS_ROOT) == 0)
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0 || mame_strwildcmp(gamename, clone_of->name) == 0)
{
if (count == 0)
mame_printf_info("Name: Clone of:\n");
mame_printf_info("%-16s %-8s\n", drivers[drvindex]->name, clone_of->name);
count++;
}
}
return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
} | [
"int",
"cli_info_listclones",
"(",
"core_options",
"*",
"options",
",",
"const",
"char",
"*",
"gamename",
")",
"{",
"int",
"drvindex",
",",
"count",
"=",
"0",
";",
"for",
"(",
"drvindex",
"=",
"0",
";",
"drivers",
"[",
"drvindex",
"]",
"!=",
"NULL",
";",
"drvindex",
"++",
")",
"{",
"const",
"game_driver",
"*",
"clone_of",
"=",
"driver_get_clone",
"(",
"drivers",
"[",
"drvindex",
"]",
")",
";",
"if",
"(",
"clone_of",
"!=",
"NULL",
"&&",
"(",
"clone_of",
"->",
"flags",
"&",
"GAME_IS_BIOS_ROOT",
")",
"==",
"0",
")",
"if",
"(",
"mame_strwildcmp",
"(",
"gamename",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"name",
")",
"==",
"0",
"||",
"mame_strwildcmp",
"(",
"gamename",
",",
"clone_of",
"->",
"name",
")",
"==",
"0",
")",
"{",
"if",
"(",
"count",
"==",
"0",
")",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
")",
";",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"name",
",",
"clone_of",
"->",
"name",
")",
";",
"count",
"++",
";",
"}",
"}",
"return",
"(",
"count",
">",
"0",
")",
"?",
"MAMERR_NONE",
":",
"MAMERR_NO_SUCH_GAME",
";",
"}"
] | cli_info_listclones - output the name and source
filename of one or more games | [
"cli_info_listclones",
"-",
"output",
"the",
"name",
"and",
"source",
"filename",
"of",
"one",
"or",
"more",
"games"
] | [
"/* iterate over drivers */",
"/* if we are a clone, and either our name matches the gamename, or the clone's name matches, display us */",
"/* print the header on the first one */",
"/* output the remaining information */",
"/* return an error if none found */"
] | [
{
"param": "options",
"type": "core_options"
},
{
"param": "gamename",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "options",
"type": "core_options",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gamename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
02f6efcef29e107fa99ffa01cf9979338e99f5f0 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/clifront.c | [
"Unlicense"
] | C | cli_info_listbrothers | int | int cli_info_listbrothers(core_options *options, const char *gamename)
{
UINT8 *didit = alloc_array_or_die(UINT8, driver_list_get_count(drivers));
astring *filename = astring_alloc();
int drvindex, count = 0;
memset(didit, 0, driver_list_get_count(drivers));
/* iterate over drivers */
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if (!didit[drvindex] && mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
int matchindex;
didit[drvindex] = TRUE;
if (count > 0)
mame_printf_info("\n");
mame_printf_info("%s ... other drivers in %s:\n", drivers[drvindex]->name, astring_c(core_filename_extract_base(filename, drivers[drvindex]->source_file, FALSE)));
/* now iterate again over drivers, finding those with the same source file */
for (matchindex = 0; drivers[matchindex]; matchindex++)
if (matchindex != drvindex && strcmp(drivers[drvindex]->source_file, drivers[matchindex]->source_file) == 0)
{
const char *matchstring = (mame_strwildcmp(gamename, drivers[matchindex]->name) == 0) ? "-> " : " ";
const game_driver *clone_of = driver_get_clone(drivers[matchindex]);
if (clone_of != NULL && (clone_of->flags & GAME_IS_BIOS_ROOT) == 0)
mame_printf_info("%s%-16s [%s]\n", matchstring, drivers[matchindex]->name, clone_of->name);
else
mame_printf_info("%s%s\n", matchstring, drivers[matchindex]->name);
didit[matchindex] = TRUE;
}
count++;
}
/* return an error if none found */
astring_free(filename);
free(didit);
return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
} | /*-------------------------------------------------
cli_info_listbrothers - output the name and
source filename of one or more games
-------------------------------------------------*/ | output the name and
source filename of one or more games | [
"output",
"the",
"name",
"and",
"source",
"filename",
"of",
"one",
"or",
"more",
"games"
] | int cli_info_listbrothers(core_options *options, const char *gamename)
{
UINT8 *didit = alloc_array_or_die(UINT8, driver_list_get_count(drivers));
astring *filename = astring_alloc();
int drvindex, count = 0;
memset(didit, 0, driver_list_get_count(drivers));
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if (!didit[drvindex] && mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
int matchindex;
didit[drvindex] = TRUE;
if (count > 0)
mame_printf_info("\n");
mame_printf_info("%s ... other drivers in %s:\n", drivers[drvindex]->name, astring_c(core_filename_extract_base(filename, drivers[drvindex]->source_file, FALSE)));
for (matchindex = 0; drivers[matchindex]; matchindex++)
if (matchindex != drvindex && strcmp(drivers[drvindex]->source_file, drivers[matchindex]->source_file) == 0)
{
const char *matchstring = (mame_strwildcmp(gamename, drivers[matchindex]->name) == 0) ? "-> " : " ";
const game_driver *clone_of = driver_get_clone(drivers[matchindex]);
if (clone_of != NULL && (clone_of->flags & GAME_IS_BIOS_ROOT) == 0)
mame_printf_info("%s%-16s [%s]\n", matchstring, drivers[matchindex]->name, clone_of->name);
else
mame_printf_info("%s%s\n", matchstring, drivers[matchindex]->name);
didit[matchindex] = TRUE;
}
count++;
}
astring_free(filename);
free(didit);
return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
} | [
"int",
"cli_info_listbrothers",
"(",
"core_options",
"*",
"options",
",",
"const",
"char",
"*",
"gamename",
")",
"{",
"UINT8",
"*",
"didit",
"=",
"alloc_array_or_die",
"(",
"UINT8",
",",
"driver_list_get_count",
"(",
"drivers",
")",
")",
";",
"astring",
"*",
"filename",
"=",
"astring_alloc",
"(",
")",
";",
"int",
"drvindex",
",",
"count",
"=",
"0",
";",
"memset",
"(",
"didit",
",",
"0",
",",
"driver_list_get_count",
"(",
"drivers",
")",
")",
";",
"for",
"(",
"drvindex",
"=",
"0",
";",
"drivers",
"[",
"drvindex",
"]",
"!=",
"NULL",
";",
"drvindex",
"++",
")",
"if",
"(",
"!",
"didit",
"[",
"drvindex",
"]",
"&&",
"mame_strwildcmp",
"(",
"gamename",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"name",
")",
"==",
"0",
")",
"{",
"int",
"matchindex",
";",
"didit",
"[",
"drvindex",
"]",
"=",
"TRUE",
";",
"if",
"(",
"count",
">",
"0",
")",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
")",
";",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"name",
",",
"astring_c",
"(",
"core_filename_extract_base",
"(",
"filename",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"source_file",
",",
"FALSE",
")",
")",
")",
";",
"for",
"(",
"matchindex",
"=",
"0",
";",
"drivers",
"[",
"matchindex",
"]",
";",
"matchindex",
"++",
")",
"if",
"(",
"matchindex",
"!=",
"drvindex",
"&&",
"strcmp",
"(",
"drivers",
"[",
"drvindex",
"]",
"->",
"source_file",
",",
"drivers",
"[",
"matchindex",
"]",
"->",
"source_file",
")",
"==",
"0",
")",
"{",
"const",
"char",
"*",
"matchstring",
"=",
"(",
"mame_strwildcmp",
"(",
"gamename",
",",
"drivers",
"[",
"matchindex",
"]",
"->",
"name",
")",
"==",
"0",
")",
"?",
"\"",
"\"",
":",
"\"",
"\"",
";",
"const",
"game_driver",
"*",
"clone_of",
"=",
"driver_get_clone",
"(",
"drivers",
"[",
"matchindex",
"]",
")",
";",
"if",
"(",
"clone_of",
"!=",
"NULL",
"&&",
"(",
"clone_of",
"->",
"flags",
"&",
"GAME_IS_BIOS_ROOT",
")",
"==",
"0",
")",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
",",
"matchstring",
",",
"drivers",
"[",
"matchindex",
"]",
"->",
"name",
",",
"clone_of",
"->",
"name",
")",
";",
"else",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
",",
"matchstring",
",",
"drivers",
"[",
"matchindex",
"]",
"->",
"name",
")",
";",
"didit",
"[",
"matchindex",
"]",
"=",
"TRUE",
";",
"}",
"count",
"++",
";",
"}",
"astring_free",
"(",
"filename",
")",
";",
"free",
"(",
"didit",
")",
";",
"return",
"(",
"count",
">",
"0",
")",
"?",
"MAMERR_NONE",
":",
"MAMERR_NO_SUCH_GAME",
";",
"}"
] | cli_info_listbrothers - output the name and
source filename of one or more games | [
"cli_info_listbrothers",
"-",
"output",
"the",
"name",
"and",
"source",
"filename",
"of",
"one",
"or",
"more",
"games"
] | [
"/* iterate over drivers */",
"/* now iterate again over drivers, finding those with the same source file */",
"/* return an error if none found */"
] | [
{
"param": "options",
"type": "core_options"
},
{
"param": "gamename",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "options",
"type": "core_options",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gamename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
02f6efcef29e107fa99ffa01cf9979338e99f5f0 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/clifront.c | [
"Unlicense"
] | C | cli_info_listcrc | int | int cli_info_listcrc(core_options *options, const char *gamename)
{
int drvindex, count = 0;
/* iterate over drivers */
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
machine_config *config = machine_config_alloc(drivers[drvindex]->machine_config);
const rom_entry *region, *rom;
const rom_source *source;
/* iterate over sources, regions, and then ROMs within the region */
for (source = rom_first_source(drivers[drvindex], config); source != NULL; source = rom_next_source(drivers[drvindex], config, source))
for (region = rom_first_region(drivers[drvindex], source); region; region = rom_next_region(region))
for (rom = rom_first_file(region); rom; rom = rom_next_file(rom))
{
char hashbuf[HASH_BUF_SIZE];
/* if we have a CRC, display it */
if (hash_data_extract_printable_checksum(ROM_GETHASHDATA(rom), HASH_CRC, hashbuf))
mame_printf_info("%s %-12s %s\n", hashbuf, ROM_GETNAME(rom), drivers[drvindex]->description);
}
count++;
machine_config_free(config);
}
/* return an error if none found */
return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
} | /*-------------------------------------------------
cli_info_listcrc - output the CRC and name of
all ROMs referenced by MAME
-------------------------------------------------*/ | output the CRC and name of
all ROMs referenced by MAME | [
"output",
"the",
"CRC",
"and",
"name",
"of",
"all",
"ROMs",
"referenced",
"by",
"MAME"
] | int cli_info_listcrc(core_options *options, const char *gamename)
{
int drvindex, count = 0;
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
machine_config *config = machine_config_alloc(drivers[drvindex]->machine_config);
const rom_entry *region, *rom;
const rom_source *source;
for (source = rom_first_source(drivers[drvindex], config); source != NULL; source = rom_next_source(drivers[drvindex], config, source))
for (region = rom_first_region(drivers[drvindex], source); region; region = rom_next_region(region))
for (rom = rom_first_file(region); rom; rom = rom_next_file(rom))
{
char hashbuf[HASH_BUF_SIZE];
if (hash_data_extract_printable_checksum(ROM_GETHASHDATA(rom), HASH_CRC, hashbuf))
mame_printf_info("%s %-12s %s\n", hashbuf, ROM_GETNAME(rom), drivers[drvindex]->description);
}
count++;
machine_config_free(config);
}
return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
} | [
"int",
"cli_info_listcrc",
"(",
"core_options",
"*",
"options",
",",
"const",
"char",
"*",
"gamename",
")",
"{",
"int",
"drvindex",
",",
"count",
"=",
"0",
";",
"for",
"(",
"drvindex",
"=",
"0",
";",
"drivers",
"[",
"drvindex",
"]",
"!=",
"NULL",
";",
"drvindex",
"++",
")",
"if",
"(",
"mame_strwildcmp",
"(",
"gamename",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"name",
")",
"==",
"0",
")",
"{",
"machine_config",
"*",
"config",
"=",
"machine_config_alloc",
"(",
"drivers",
"[",
"drvindex",
"]",
"->",
"machine_config",
")",
";",
"const",
"rom_entry",
"*",
"region",
",",
"*",
"rom",
";",
"const",
"rom_source",
"*",
"source",
";",
"for",
"(",
"source",
"=",
"rom_first_source",
"(",
"drivers",
"[",
"drvindex",
"]",
",",
"config",
")",
";",
"source",
"!=",
"NULL",
";",
"source",
"=",
"rom_next_source",
"(",
"drivers",
"[",
"drvindex",
"]",
",",
"config",
",",
"source",
")",
")",
"for",
"(",
"region",
"=",
"rom_first_region",
"(",
"drivers",
"[",
"drvindex",
"]",
",",
"source",
")",
";",
"region",
";",
"region",
"=",
"rom_next_region",
"(",
"region",
")",
")",
"for",
"(",
"rom",
"=",
"rom_first_file",
"(",
"region",
")",
";",
"rom",
";",
"rom",
"=",
"rom_next_file",
"(",
"rom",
")",
")",
"{",
"char",
"hashbuf",
"[",
"HASH_BUF_SIZE",
"]",
";",
"if",
"(",
"hash_data_extract_printable_checksum",
"(",
"ROM_GETHASHDATA",
"(",
"rom",
")",
",",
"HASH_CRC",
",",
"hashbuf",
")",
")",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
",",
"hashbuf",
",",
"ROM_GETNAME",
"(",
"rom",
")",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"description",
")",
";",
"}",
"count",
"++",
";",
"machine_config_free",
"(",
"config",
")",
";",
"}",
"return",
"(",
"count",
">",
"0",
")",
"?",
"MAMERR_NONE",
":",
"MAMERR_NO_SUCH_GAME",
";",
"}"
] | cli_info_listcrc - output the CRC and name of
all ROMs referenced by MAME | [
"cli_info_listcrc",
"-",
"output",
"the",
"CRC",
"and",
"name",
"of",
"all",
"ROMs",
"referenced",
"by",
"MAME"
] | [
"/* iterate over drivers */",
"/* iterate over sources, regions, and then ROMs within the region */",
"/* if we have a CRC, display it */",
"/* return an error if none found */"
] | [
{
"param": "options",
"type": "core_options"
},
{
"param": "gamename",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "options",
"type": "core_options",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gamename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
02f6efcef29e107fa99ffa01cf9979338e99f5f0 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/clifront.c | [
"Unlicense"
] | C | cli_info_listroms | int | int cli_info_listroms(core_options *options, const char *gamename)
{
int drvindex, count = 0;
/* iterate over drivers */
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
machine_config *config = machine_config_alloc(drivers[drvindex]->machine_config);
const rom_entry *region, *rom;
const rom_source *source;
/* print the header */
if (count > 0)
mame_printf_info("\n");
mame_printf_info("This is the list of the ROMs required for driver \"%s\".\n"
"Name Size Checksum\n", drivers[drvindex]->name);
/* iterate over sources, regions and then ROMs within the region */
for (source = rom_first_source(drivers[drvindex], config); source != NULL; source = rom_next_source(drivers[drvindex], config, source))
for (region = rom_first_region(drivers[drvindex], source); region != NULL; region = rom_next_region(region))
for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom))
{
const char *name = ROM_GETNAME(rom);
const char *hash = ROM_GETHASHDATA(rom);
char hashbuf[HASH_BUF_SIZE];
int length = -1;
/* accumulate the total length of all chunks */
if (ROMREGION_ISROMDATA(region))
length = rom_file_size(rom);
/* start with the name */
mame_printf_info("%-12s ", name);
/* output the length next */
if (length >= 0)
mame_printf_info("%7d", length);
else
mame_printf_info(" ");
/* output the hash data */
if (!hash_data_has_info(hash, HASH_INFO_NO_DUMP))
{
if (hash_data_has_info(hash, HASH_INFO_BAD_DUMP))
mame_printf_info(" BAD");
hash_data_print(hash, 0, hashbuf);
mame_printf_info(" %s", hashbuf);
}
else
mame_printf_info(" NO GOOD DUMP KNOWN");
/* end with a CR */
mame_printf_info("\n");
}
count++;
machine_config_free(config);
}
return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
} | /*-------------------------------------------------
cli_info_listroms - output the list of ROMs
referenced by a given game or set of games
-------------------------------------------------*/ | output the list of ROMs
referenced by a given game or set of games | [
"output",
"the",
"list",
"of",
"ROMs",
"referenced",
"by",
"a",
"given",
"game",
"or",
"set",
"of",
"games"
] | int cli_info_listroms(core_options *options, const char *gamename)
{
int drvindex, count = 0;
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
machine_config *config = machine_config_alloc(drivers[drvindex]->machine_config);
const rom_entry *region, *rom;
const rom_source *source;
if (count > 0)
mame_printf_info("\n");
mame_printf_info("This is the list of the ROMs required for driver \"%s\".\n"
"Name Size Checksum\n", drivers[drvindex]->name);
for (source = rom_first_source(drivers[drvindex], config); source != NULL; source = rom_next_source(drivers[drvindex], config, source))
for (region = rom_first_region(drivers[drvindex], source); region != NULL; region = rom_next_region(region))
for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom))
{
const char *name = ROM_GETNAME(rom);
const char *hash = ROM_GETHASHDATA(rom);
char hashbuf[HASH_BUF_SIZE];
int length = -1;
if (ROMREGION_ISROMDATA(region))
length = rom_file_size(rom);
mame_printf_info("%-12s ", name);
if (length >= 0)
mame_printf_info("%7d", length);
else
mame_printf_info(" ");
if (!hash_data_has_info(hash, HASH_INFO_NO_DUMP))
{
if (hash_data_has_info(hash, HASH_INFO_BAD_DUMP))
mame_printf_info(" BAD");
hash_data_print(hash, 0, hashbuf);
mame_printf_info(" %s", hashbuf);
}
else
mame_printf_info(" NO GOOD DUMP KNOWN");
mame_printf_info("\n");
}
count++;
machine_config_free(config);
}
return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
} | [
"int",
"cli_info_listroms",
"(",
"core_options",
"*",
"options",
",",
"const",
"char",
"*",
"gamename",
")",
"{",
"int",
"drvindex",
",",
"count",
"=",
"0",
";",
"for",
"(",
"drvindex",
"=",
"0",
";",
"drivers",
"[",
"drvindex",
"]",
"!=",
"NULL",
";",
"drvindex",
"++",
")",
"if",
"(",
"mame_strwildcmp",
"(",
"gamename",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"name",
")",
"==",
"0",
")",
"{",
"machine_config",
"*",
"config",
"=",
"machine_config_alloc",
"(",
"drivers",
"[",
"drvindex",
"]",
"->",
"machine_config",
")",
";",
"const",
"rom_entry",
"*",
"region",
",",
"*",
"rom",
";",
"const",
"rom_source",
"*",
"source",
";",
"if",
"(",
"count",
">",
"0",
")",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
")",
";",
"mame_printf_info",
"(",
"\"",
"\\\"",
"\\\"",
"\\n",
"\"",
"\"",
"\\n",
"\"",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"name",
")",
";",
"for",
"(",
"source",
"=",
"rom_first_source",
"(",
"drivers",
"[",
"drvindex",
"]",
",",
"config",
")",
";",
"source",
"!=",
"NULL",
";",
"source",
"=",
"rom_next_source",
"(",
"drivers",
"[",
"drvindex",
"]",
",",
"config",
",",
"source",
")",
")",
"for",
"(",
"region",
"=",
"rom_first_region",
"(",
"drivers",
"[",
"drvindex",
"]",
",",
"source",
")",
";",
"region",
"!=",
"NULL",
";",
"region",
"=",
"rom_next_region",
"(",
"region",
")",
")",
"for",
"(",
"rom",
"=",
"rom_first_file",
"(",
"region",
")",
";",
"rom",
"!=",
"NULL",
";",
"rom",
"=",
"rom_next_file",
"(",
"rom",
")",
")",
"{",
"const",
"char",
"*",
"name",
"=",
"ROM_GETNAME",
"(",
"rom",
")",
";",
"const",
"char",
"*",
"hash",
"=",
"ROM_GETHASHDATA",
"(",
"rom",
")",
";",
"char",
"hashbuf",
"[",
"HASH_BUF_SIZE",
"]",
";",
"int",
"length",
"=",
"-1",
";",
"if",
"(",
"ROMREGION_ISROMDATA",
"(",
"region",
")",
")",
"length",
"=",
"rom_file_size",
"(",
"rom",
")",
";",
"mame_printf_info",
"(",
"\"",
"\"",
",",
"name",
")",
";",
"if",
"(",
"length",
">=",
"0",
")",
"mame_printf_info",
"(",
"\"",
"\"",
",",
"length",
")",
";",
"else",
"mame_printf_info",
"(",
"\"",
"\"",
")",
";",
"if",
"(",
"!",
"hash_data_has_info",
"(",
"hash",
",",
"HASH_INFO_NO_DUMP",
")",
")",
"{",
"if",
"(",
"hash_data_has_info",
"(",
"hash",
",",
"HASH_INFO_BAD_DUMP",
")",
")",
"mame_printf_info",
"(",
"\"",
"\"",
")",
";",
"hash_data_print",
"(",
"hash",
",",
"0",
",",
"hashbuf",
")",
";",
"mame_printf_info",
"(",
"\"",
"\"",
",",
"hashbuf",
")",
";",
"}",
"else",
"mame_printf_info",
"(",
"\"",
"\"",
")",
";",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
")",
";",
"}",
"count",
"++",
";",
"machine_config_free",
"(",
"config",
")",
";",
"}",
"return",
"(",
"count",
">",
"0",
")",
"?",
"MAMERR_NONE",
":",
"MAMERR_NO_SUCH_GAME",
";",
"}"
] | cli_info_listroms - output the list of ROMs
referenced by a given game or set of games | [
"cli_info_listroms",
"-",
"output",
"the",
"list",
"of",
"ROMs",
"referenced",
"by",
"a",
"given",
"game",
"or",
"set",
"of",
"games"
] | [
"/* iterate over drivers */",
"/* print the header */",
"/* iterate over sources, regions and then ROMs within the region */",
"/* accumulate the total length of all chunks */",
"/* start with the name */",
"/* output the length next */",
"/* output the hash data */",
"/* end with a CR */"
] | [
{
"param": "options",
"type": "core_options"
},
{
"param": "gamename",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "options",
"type": "core_options",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gamename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
02f6efcef29e107fa99ffa01cf9979338e99f5f0 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/clifront.c | [
"Unlicense"
] | C | cli_info_listsamples | int | int cli_info_listsamples(core_options *options, const char *gamename)
{
int count = 0;
#if (HAS_SAMPLES)
int drvindex;
/* since we expand the machine driver, we need to set things up */
init_resource_tracking();
/* iterate over drivers */
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
machine_config *config = machine_config_alloc(drivers[drvindex]->machine_config);
const device_config *device;
/* find samples interfaces */
for (device = sound_first(config); device != NULL; device = sound_next(device))
if (sound_get_type(device) == SOUND_SAMPLES)
{
const char *const *samplenames = ((const samples_interface *)device->static_config)->samplenames;
int sampnum;
/* if the list is legit, walk it and print the sample info */
if (samplenames != NULL)
for (sampnum = 0; samplenames[sampnum] != NULL; sampnum++)
mame_printf_info("%s\n", samplenames[sampnum]);
}
count++;
machine_config_free(config);
}
/* clean up our tracked resources */
exit_resource_tracking();
#else
mame_printf_error("Samples not supported in this build\n");
#endif
return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
} | /*-------------------------------------------------
cli_info_listsamples - output the list of samples
referenced by a given game or set of games
-------------------------------------------------*/ | output the list of samples
referenced by a given game or set of games | [
"output",
"the",
"list",
"of",
"samples",
"referenced",
"by",
"a",
"given",
"game",
"or",
"set",
"of",
"games"
] | int cli_info_listsamples(core_options *options, const char *gamename)
{
int count = 0;
#if (HAS_SAMPLES)
int drvindex;
init_resource_tracking();
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
machine_config *config = machine_config_alloc(drivers[drvindex]->machine_config);
const device_config *device;
for (device = sound_first(config); device != NULL; device = sound_next(device))
if (sound_get_type(device) == SOUND_SAMPLES)
{
const char *const *samplenames = ((const samples_interface *)device->static_config)->samplenames;
int sampnum;
if (samplenames != NULL)
for (sampnum = 0; samplenames[sampnum] != NULL; sampnum++)
mame_printf_info("%s\n", samplenames[sampnum]);
}
count++;
machine_config_free(config);
}
exit_resource_tracking();
#else
mame_printf_error("Samples not supported in this build\n");
#endif
return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
} | [
"int",
"cli_info_listsamples",
"(",
"core_options",
"*",
"options",
",",
"const",
"char",
"*",
"gamename",
")",
"{",
"int",
"count",
"=",
"0",
";",
"#if",
"(",
"HAS_SAMPLES",
")",
"\n",
"int",
"drvindex",
";",
"init_resource_tracking",
"(",
")",
";",
"for",
"(",
"drvindex",
"=",
"0",
";",
"drivers",
"[",
"drvindex",
"]",
"!=",
"NULL",
";",
"drvindex",
"++",
")",
"if",
"(",
"mame_strwildcmp",
"(",
"gamename",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"name",
")",
"==",
"0",
")",
"{",
"machine_config",
"*",
"config",
"=",
"machine_config_alloc",
"(",
"drivers",
"[",
"drvindex",
"]",
"->",
"machine_config",
")",
";",
"const",
"device_config",
"*",
"device",
";",
"for",
"(",
"device",
"=",
"sound_first",
"(",
"config",
")",
";",
"device",
"!=",
"NULL",
";",
"device",
"=",
"sound_next",
"(",
"device",
")",
")",
"if",
"(",
"sound_get_type",
"(",
"device",
")",
"==",
"SOUND_SAMPLES",
")",
"{",
"const",
"char",
"*",
"const",
"*",
"samplenames",
"=",
"(",
"(",
"const",
"samples_interface",
"*",
")",
"device",
"->",
"static_config",
")",
"->",
"samplenames",
";",
"int",
"sampnum",
";",
"if",
"(",
"samplenames",
"!=",
"NULL",
")",
"for",
"(",
"sampnum",
"=",
"0",
";",
"samplenames",
"[",
"sampnum",
"]",
"!=",
"NULL",
";",
"sampnum",
"++",
")",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
",",
"samplenames",
"[",
"sampnum",
"]",
")",
";",
"}",
"count",
"++",
";",
"machine_config_free",
"(",
"config",
")",
";",
"}",
"exit_resource_tracking",
"(",
")",
";",
"#else",
"mame_printf_error",
"(",
"\"",
"\\n",
"\"",
")",
";",
"#endif",
"return",
"(",
"count",
">",
"0",
")",
"?",
"MAMERR_NONE",
":",
"MAMERR_NO_SUCH_GAME",
";",
"}"
] | cli_info_listsamples - output the list of samples
referenced by a given game or set of games | [
"cli_info_listsamples",
"-",
"output",
"the",
"list",
"of",
"samples",
"referenced",
"by",
"a",
"given",
"game",
"or",
"set",
"of",
"games"
] | [
"/* since we expand the machine driver, we need to set things up */",
"/* iterate over drivers */",
"/* find samples interfaces */",
"/* if the list is legit, walk it and print the sample info */",
"/* clean up our tracked resources */"
] | [
{
"param": "options",
"type": "core_options"
},
{
"param": "gamename",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "options",
"type": "core_options",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gamename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
02f6efcef29e107fa99ffa01cf9979338e99f5f0 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/clifront.c | [
"Unlicense"
] | C | info_verifyroms | int | static int info_verifyroms(core_options *options, const char *gamename)
{
int correct = 0;
int incorrect = 0;
int notfound = 0;
int drvindex;
/* iterate over drivers */
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
audit_record *audit;
int audit_records;
int res;
/* audit the ROMs in this set */
audit_records = audit_images(options, drivers[drvindex], AUDIT_VALIDATE_FAST, &audit);
res = audit_summary(drivers[drvindex], audit_records, audit, TRUE);
if (audit_records > 0)
free(audit);
/* if not found, count that and leave it at that */
if (res == NOTFOUND)
notfound++;
/* else display information about what we discovered */
else
{
const game_driver *clone_of;
/* output the name of the driver and its clone */
mame_printf_info("romset %s ", drivers[drvindex]->name);
clone_of = driver_get_clone(drivers[drvindex]);
if (clone_of != NULL)
mame_printf_info("[%s] ", clone_of->name);
/* switch off of the result */
switch (res)
{
case INCORRECT:
mame_printf_info("is bad\n");
incorrect++;
break;
case CORRECT:
mame_printf_info("is good\n");
correct++;
break;
case BEST_AVAILABLE:
mame_printf_info("is best available\n");
correct++;
break;
}
}
}
/* clear out any cached files */
zip_file_cache_clear();
/* if we didn't get anything at all, display a generic end message */
if (correct + incorrect == 0)
{
if (notfound > 0)
mame_printf_info("romset \"%s\" not found!\n", gamename);
else
mame_printf_info("romset \"%s\" not supported!\n", gamename);
return MAMERR_NO_SUCH_GAME;
}
/* otherwise, print a summary */
else
{
mame_printf_info("%d romsets found, %d were OK.\n", correct + incorrect, correct);
return (incorrect > 0) ? MAMERR_MISSING_FILES : MAMERR_NONE;
}
} | /*-------------------------------------------------
info_verifyroms - verify the ROM sets of
one or more games
-------------------------------------------------*/ | verify the ROM sets of
one or more games | [
"verify",
"the",
"ROM",
"sets",
"of",
"one",
"or",
"more",
"games"
] | static int info_verifyroms(core_options *options, const char *gamename)
{
int correct = 0;
int incorrect = 0;
int notfound = 0;
int drvindex;
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
audit_record *audit;
int audit_records;
int res;
audit_records = audit_images(options, drivers[drvindex], AUDIT_VALIDATE_FAST, &audit);
res = audit_summary(drivers[drvindex], audit_records, audit, TRUE);
if (audit_records > 0)
free(audit);
if (res == NOTFOUND)
notfound++;
else
{
const game_driver *clone_of;
mame_printf_info("romset %s ", drivers[drvindex]->name);
clone_of = driver_get_clone(drivers[drvindex]);
if (clone_of != NULL)
mame_printf_info("[%s] ", clone_of->name);
switch (res)
{
case INCORRECT:
mame_printf_info("is bad\n");
incorrect++;
break;
case CORRECT:
mame_printf_info("is good\n");
correct++;
break;
case BEST_AVAILABLE:
mame_printf_info("is best available\n");
correct++;
break;
}
}
}
zip_file_cache_clear();
if (correct + incorrect == 0)
{
if (notfound > 0)
mame_printf_info("romset \"%s\" not found!\n", gamename);
else
mame_printf_info("romset \"%s\" not supported!\n", gamename);
return MAMERR_NO_SUCH_GAME;
}
else
{
mame_printf_info("%d romsets found, %d were OK.\n", correct + incorrect, correct);
return (incorrect > 0) ? MAMERR_MISSING_FILES : MAMERR_NONE;
}
} | [
"static",
"int",
"info_verifyroms",
"(",
"core_options",
"*",
"options",
",",
"const",
"char",
"*",
"gamename",
")",
"{",
"int",
"correct",
"=",
"0",
";",
"int",
"incorrect",
"=",
"0",
";",
"int",
"notfound",
"=",
"0",
";",
"int",
"drvindex",
";",
"for",
"(",
"drvindex",
"=",
"0",
";",
"drivers",
"[",
"drvindex",
"]",
"!=",
"NULL",
";",
"drvindex",
"++",
")",
"if",
"(",
"mame_strwildcmp",
"(",
"gamename",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"name",
")",
"==",
"0",
")",
"{",
"audit_record",
"*",
"audit",
";",
"int",
"audit_records",
";",
"int",
"res",
";",
"audit_records",
"=",
"audit_images",
"(",
"options",
",",
"drivers",
"[",
"drvindex",
"]",
",",
"AUDIT_VALIDATE_FAST",
",",
"&",
"audit",
")",
";",
"res",
"=",
"audit_summary",
"(",
"drivers",
"[",
"drvindex",
"]",
",",
"audit_records",
",",
"audit",
",",
"TRUE",
")",
";",
"if",
"(",
"audit_records",
">",
"0",
")",
"free",
"(",
"audit",
")",
";",
"if",
"(",
"res",
"==",
"NOTFOUND",
")",
"notfound",
"++",
";",
"else",
"{",
"const",
"game_driver",
"*",
"clone_of",
";",
"mame_printf_info",
"(",
"\"",
"\"",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"name",
")",
";",
"clone_of",
"=",
"driver_get_clone",
"(",
"drivers",
"[",
"drvindex",
"]",
")",
";",
"if",
"(",
"clone_of",
"!=",
"NULL",
")",
"mame_printf_info",
"(",
"\"",
"\"",
",",
"clone_of",
"->",
"name",
")",
";",
"switch",
"(",
"res",
")",
"{",
"case",
"INCORRECT",
":",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
")",
";",
"incorrect",
"++",
";",
"break",
";",
"case",
"CORRECT",
":",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
")",
";",
"correct",
"++",
";",
"break",
";",
"case",
"BEST_AVAILABLE",
":",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
")",
";",
"correct",
"++",
";",
"break",
";",
"}",
"}",
"}",
"zip_file_cache_clear",
"(",
")",
";",
"if",
"(",
"correct",
"+",
"incorrect",
"==",
"0",
")",
"{",
"if",
"(",
"notfound",
">",
"0",
")",
"mame_printf_info",
"(",
"\"",
"\\\"",
"\\\"",
"\\n",
"\"",
",",
"gamename",
")",
";",
"else",
"mame_printf_info",
"(",
"\"",
"\\\"",
"\\\"",
"\\n",
"\"",
",",
"gamename",
")",
";",
"return",
"MAMERR_NO_SUCH_GAME",
";",
"}",
"else",
"{",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
",",
"correct",
"+",
"incorrect",
",",
"correct",
")",
";",
"return",
"(",
"incorrect",
">",
"0",
")",
"?",
"MAMERR_MISSING_FILES",
":",
"MAMERR_NONE",
";",
"}",
"}"
] | info_verifyroms - verify the ROM sets of
one or more games | [
"info_verifyroms",
"-",
"verify",
"the",
"ROM",
"sets",
"of",
"one",
"or",
"more",
"games"
] | [
"/* iterate over drivers */",
"/* audit the ROMs in this set */",
"/* if not found, count that and leave it at that */",
"/* else display information about what we discovered */",
"/* output the name of the driver and its clone */",
"/* switch off of the result */",
"/* clear out any cached files */",
"/* if we didn't get anything at all, display a generic end message */",
"/* otherwise, print a summary */"
] | [
{
"param": "options",
"type": "core_options"
},
{
"param": "gamename",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "options",
"type": "core_options",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gamename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
02f6efcef29e107fa99ffa01cf9979338e99f5f0 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/clifront.c | [
"Unlicense"
] | C | info_verifysamples | int | static int info_verifysamples(core_options *options, const char *gamename)
{
int correct = 0;
int incorrect = 0;
int notfound = FALSE;
int drvindex;
/* now iterate over drivers */
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
audit_record *audit;
int audit_records;
int res;
/* audit the samples in this set */
audit_records = audit_samples(options, drivers[drvindex], &audit);
res = audit_summary(drivers[drvindex], audit_records, audit, TRUE);
if (audit_records > 0)
free(audit);
else
continue;
/* if not found, print a message and set the flag */
if (res == NOTFOUND)
{
mame_printf_error("sampleset \"%s\" not found!\n", drivers[drvindex]->name);
notfound = TRUE;
}
/* else display information about what we discovered */
else
{
mame_printf_info("sampleset %s ", drivers[drvindex]->name);
/* switch off of the result */
switch (res)
{
case INCORRECT:
mame_printf_info("is bad\n");
incorrect++;
break;
case CORRECT:
mame_printf_info("is good\n");
correct++;
break;
case BEST_AVAILABLE:
mame_printf_info("is best available\n");
correct++;
break;
}
}
}
/* clear out any cached files */
zip_file_cache_clear();
/* if we didn't get anything at all because of an unsupported set, display message */
if (correct + incorrect == 0)
{
if (!notfound)
mame_printf_error("sampleset \"%s\" not supported!\n", gamename);
return MAMERR_NO_SUCH_GAME;
}
/* otherwise, print a summary */
else
{
mame_printf_info("%d samplesets found, %d were OK.\n", correct + incorrect, correct);
return (incorrect > 0) ? MAMERR_MISSING_FILES : MAMERR_NONE;
}
} | /*-------------------------------------------------
info_verifysamples - verify the sample sets of
one or more games
-------------------------------------------------*/ | verify the sample sets of
one or more games | [
"verify",
"the",
"sample",
"sets",
"of",
"one",
"or",
"more",
"games"
] | static int info_verifysamples(core_options *options, const char *gamename)
{
int correct = 0;
int incorrect = 0;
int notfound = FALSE;
int drvindex;
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
audit_record *audit;
int audit_records;
int res;
audit_records = audit_samples(options, drivers[drvindex], &audit);
res = audit_summary(drivers[drvindex], audit_records, audit, TRUE);
if (audit_records > 0)
free(audit);
else
continue;
if (res == NOTFOUND)
{
mame_printf_error("sampleset \"%s\" not found!\n", drivers[drvindex]->name);
notfound = TRUE;
}
else
{
mame_printf_info("sampleset %s ", drivers[drvindex]->name);
switch (res)
{
case INCORRECT:
mame_printf_info("is bad\n");
incorrect++;
break;
case CORRECT:
mame_printf_info("is good\n");
correct++;
break;
case BEST_AVAILABLE:
mame_printf_info("is best available\n");
correct++;
break;
}
}
}
zip_file_cache_clear();
if (correct + incorrect == 0)
{
if (!notfound)
mame_printf_error("sampleset \"%s\" not supported!\n", gamename);
return MAMERR_NO_SUCH_GAME;
}
else
{
mame_printf_info("%d samplesets found, %d were OK.\n", correct + incorrect, correct);
return (incorrect > 0) ? MAMERR_MISSING_FILES : MAMERR_NONE;
}
} | [
"static",
"int",
"info_verifysamples",
"(",
"core_options",
"*",
"options",
",",
"const",
"char",
"*",
"gamename",
")",
"{",
"int",
"correct",
"=",
"0",
";",
"int",
"incorrect",
"=",
"0",
";",
"int",
"notfound",
"=",
"FALSE",
";",
"int",
"drvindex",
";",
"for",
"(",
"drvindex",
"=",
"0",
";",
"drivers",
"[",
"drvindex",
"]",
"!=",
"NULL",
";",
"drvindex",
"++",
")",
"if",
"(",
"mame_strwildcmp",
"(",
"gamename",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"name",
")",
"==",
"0",
")",
"{",
"audit_record",
"*",
"audit",
";",
"int",
"audit_records",
";",
"int",
"res",
";",
"audit_records",
"=",
"audit_samples",
"(",
"options",
",",
"drivers",
"[",
"drvindex",
"]",
",",
"&",
"audit",
")",
";",
"res",
"=",
"audit_summary",
"(",
"drivers",
"[",
"drvindex",
"]",
",",
"audit_records",
",",
"audit",
",",
"TRUE",
")",
";",
"if",
"(",
"audit_records",
">",
"0",
")",
"free",
"(",
"audit",
")",
";",
"else",
"continue",
";",
"if",
"(",
"res",
"==",
"NOTFOUND",
")",
"{",
"mame_printf_error",
"(",
"\"",
"\\\"",
"\\\"",
"\\n",
"\"",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"name",
")",
";",
"notfound",
"=",
"TRUE",
";",
"}",
"else",
"{",
"mame_printf_info",
"(",
"\"",
"\"",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"name",
")",
";",
"switch",
"(",
"res",
")",
"{",
"case",
"INCORRECT",
":",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
")",
";",
"incorrect",
"++",
";",
"break",
";",
"case",
"CORRECT",
":",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
")",
";",
"correct",
"++",
";",
"break",
";",
"case",
"BEST_AVAILABLE",
":",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
")",
";",
"correct",
"++",
";",
"break",
";",
"}",
"}",
"}",
"zip_file_cache_clear",
"(",
")",
";",
"if",
"(",
"correct",
"+",
"incorrect",
"==",
"0",
")",
"{",
"if",
"(",
"!",
"notfound",
")",
"mame_printf_error",
"(",
"\"",
"\\\"",
"\\\"",
"\\n",
"\"",
",",
"gamename",
")",
";",
"return",
"MAMERR_NO_SUCH_GAME",
";",
"}",
"else",
"{",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
",",
"correct",
"+",
"incorrect",
",",
"correct",
")",
";",
"return",
"(",
"incorrect",
">",
"0",
")",
"?",
"MAMERR_MISSING_FILES",
":",
"MAMERR_NONE",
";",
"}",
"}"
] | info_verifysamples - verify the sample sets of
one or more games | [
"info_verifysamples",
"-",
"verify",
"the",
"sample",
"sets",
"of",
"one",
"or",
"more",
"games"
] | [
"/* now iterate over drivers */",
"/* audit the samples in this set */",
"/* if not found, print a message and set the flag */",
"/* else display information about what we discovered */",
"/* switch off of the result */",
"/* clear out any cached files */",
"/* if we didn't get anything at all because of an unsupported set, display message */",
"/* otherwise, print a summary */"
] | [
{
"param": "options",
"type": "core_options"
},
{
"param": "gamename",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "options",
"type": "core_options",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gamename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
02f6efcef29e107fa99ffa01cf9979338e99f5f0 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/clifront.c | [
"Unlicense"
] | C | info_romident | int | static int info_romident(core_options *options, const char *gamename)
{
romident_status status;
/* a NULL gamename is a fatal error */
if (gamename == NULL)
return MAMERR_FATALERROR;
/* do the identification */
romident(gamename, &status);
/* clear out any cached files */
zip_file_cache_clear();
/* return the appropriate error code */
if (status.matches == status.total)
return MAMERR_NONE;
else if (status.matches == status.total - status.nonroms)
return MAMERR_IDENT_NONROMS;
else if (status.matches > 0)
return MAMERR_IDENT_PARTIAL;
else
return MAMERR_IDENT_NONE;
} | /*-------------------------------------------------
info_romident - identify ROMs by looking for
matches in our internal database
-------------------------------------------------*/ | identify ROMs by looking for
matches in our internal database | [
"identify",
"ROMs",
"by",
"looking",
"for",
"matches",
"in",
"our",
"internal",
"database"
] | static int info_romident(core_options *options, const char *gamename)
{
romident_status status;
if (gamename == NULL)
return MAMERR_FATALERROR;
romident(gamename, &status);
zip_file_cache_clear();
if (status.matches == status.total)
return MAMERR_NONE;
else if (status.matches == status.total - status.nonroms)
return MAMERR_IDENT_NONROMS;
else if (status.matches > 0)
return MAMERR_IDENT_PARTIAL;
else
return MAMERR_IDENT_NONE;
} | [
"static",
"int",
"info_romident",
"(",
"core_options",
"*",
"options",
",",
"const",
"char",
"*",
"gamename",
")",
"{",
"romident_status",
"status",
";",
"if",
"(",
"gamename",
"==",
"NULL",
")",
"return",
"MAMERR_FATALERROR",
";",
"romident",
"(",
"gamename",
",",
"&",
"status",
")",
";",
"zip_file_cache_clear",
"(",
")",
";",
"if",
"(",
"status",
".",
"matches",
"==",
"status",
".",
"total",
")",
"return",
"MAMERR_NONE",
";",
"else",
"if",
"(",
"status",
".",
"matches",
"==",
"status",
".",
"total",
"-",
"status",
".",
"nonroms",
")",
"return",
"MAMERR_IDENT_NONROMS",
";",
"else",
"if",
"(",
"status",
".",
"matches",
">",
"0",
")",
"return",
"MAMERR_IDENT_PARTIAL",
";",
"else",
"return",
"MAMERR_IDENT_NONE",
";",
"}"
] | info_romident - identify ROMs by looking for
matches in our internal database | [
"info_romident",
"-",
"identify",
"ROMs",
"by",
"looking",
"for",
"matches",
"in",
"our",
"internal",
"database"
] | [
"/* a NULL gamename is a fatal error */",
"/* do the identification */",
"/* clear out any cached files */",
"/* return the appropriate error code */"
] | [
{
"param": "options",
"type": "core_options"
},
{
"param": "gamename",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "options",
"type": "core_options",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gamename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
02f6efcef29e107fa99ffa01cf9979338e99f5f0 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/clifront.c | [
"Unlicense"
] | C | identify_file | void | static void identify_file(const char *name, romident_status *status)
{
file_error filerr;
osd_file *file;
UINT64 length;
/* open for read and process if it opens and has a valid length */
filerr = osd_open(name, OPEN_FLAG_READ, &file, &length);
if (filerr == FILERR_NONE && length > 0 && (UINT32)length == length)
{
UINT8 *data = (UINT8 *)malloc(length);
if (data != NULL)
{
UINT32 bytes;
/* read file data into RAM and identify it */
filerr = osd_read(file, data, 0, length, &bytes);
if (filerr == FILERR_NONE)
identify_data(name, data, bytes, status);
free(data);
}
osd_close(file);
}
} | /*-------------------------------------------------
identify_file - identify a file; if it is a
ZIP file, scan it and identify all enclosed
files
-------------------------------------------------*/ | identify a file; if it is a
ZIP file, scan it and identify all enclosed
files | [
"identify",
"a",
"file",
";",
"if",
"it",
"is",
"a",
"ZIP",
"file",
"scan",
"it",
"and",
"identify",
"all",
"enclosed",
"files"
] | static void identify_file(const char *name, romident_status *status)
{
file_error filerr;
osd_file *file;
UINT64 length;
filerr = osd_open(name, OPEN_FLAG_READ, &file, &length);
if (filerr == FILERR_NONE && length > 0 && (UINT32)length == length)
{
UINT8 *data = (UINT8 *)malloc(length);
if (data != NULL)
{
UINT32 bytes;
filerr = osd_read(file, data, 0, length, &bytes);
if (filerr == FILERR_NONE)
identify_data(name, data, bytes, status);
free(data);
}
osd_close(file);
}
} | [
"static",
"void",
"identify_file",
"(",
"const",
"char",
"*",
"name",
",",
"romident_status",
"*",
"status",
")",
"{",
"file_error",
"filerr",
";",
"osd_file",
"*",
"file",
";",
"UINT64",
"length",
";",
"filerr",
"=",
"osd_open",
"(",
"name",
",",
"OPEN_FLAG_READ",
",",
"&",
"file",
",",
"&",
"length",
")",
";",
"if",
"(",
"filerr",
"==",
"FILERR_NONE",
"&&",
"length",
">",
"0",
"&&",
"(",
"UINT32",
")",
"length",
"==",
"length",
")",
"{",
"UINT8",
"*",
"data",
"=",
"(",
"UINT8",
"*",
")",
"malloc",
"(",
"length",
")",
";",
"if",
"(",
"data",
"!=",
"NULL",
")",
"{",
"UINT32",
"bytes",
";",
"filerr",
"=",
"osd_read",
"(",
"file",
",",
"data",
",",
"0",
",",
"length",
",",
"&",
"bytes",
")",
";",
"if",
"(",
"filerr",
"==",
"FILERR_NONE",
")",
"identify_data",
"(",
"name",
",",
"data",
",",
"bytes",
",",
"status",
")",
";",
"free",
"(",
"data",
")",
";",
"}",
"osd_close",
"(",
"file",
")",
";",
"}",
"}"
] | identify_file - identify a file; if it is a
ZIP file, scan it and identify all enclosed
files | [
"identify_file",
"-",
"identify",
"a",
"file",
";",
"if",
"it",
"is",
"a",
"ZIP",
"file",
"scan",
"it",
"and",
"identify",
"all",
"enclosed",
"files"
] | [
"/* open for read and process if it opens and has a valid length */",
"/* read file data into RAM and identify it */"
] | [
{
"param": "name",
"type": "char"
},
{
"param": "status",
"type": "romident_status"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "status",
"type": "romident_status",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
02f6efcef29e107fa99ffa01cf9979338e99f5f0 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/clifront.c | [
"Unlicense"
] | C | identify_data | void | static void identify_data(const char *name, const UINT8 *data, int length, romident_status *status)
{
char hash[HASH_BUF_SIZE];
UINT8 *tempjed = NULL;
astring *basename;
int found = 0;
jed_data jed;
/* if this is a '.jed' file, process it into raw bits first */
if (core_filename_ends_with(name, ".jed") && jed_parse(data, length, &jed) == JEDERR_NONE)
{
/* now determine the new data length and allocate temporary memory for it */
length = jedbin_output(&jed, NULL, 0);
tempjed = (UINT8 *)malloc(length);
if (tempjed == NULL)
return;
/* create a binary output of the JED data and use that instead */
jedbin_output(&jed, tempjed, length);
data = tempjed;
}
/* compute the hash of the data */
hash_data_clear(hash);
hash_compute(hash, data, length, HASH_SHA1 | HASH_CRC);
/* output the name */
status->total++;
basename = core_filename_extract_base(astring_alloc(), name, FALSE);
mame_printf_info("%-20s", astring_c(basename));
astring_free(basename);
/* see if we can find a match in the ROMs */
match_roms(hash, length, &found);
/* if we didn't find it, try to guess what it might be */
if (found == 0)
{
/* if not a power of 2, assume it is a non-ROM file */
if ((length & (length - 1)) != 0)
{
mame_printf_info("NOT A ROM\n");
status->nonroms++;
}
/* otherwise, it's just not a match */
else
mame_printf_info("NO MATCH\n");
}
/* if we did find it, count it as a match */
else
status->matches++;
/* free any temporary JED data */
if (tempjed != NULL)
free(tempjed);
} | /*-------------------------------------------------
identify_data - identify a buffer full of
data; if it comes from a .JED file, parse the
fusemap into raw data first
-------------------------------------------------*/ | identify a buffer full of
data; if it comes from a .JED file, parse the
fusemap into raw data first | [
"identify",
"a",
"buffer",
"full",
"of",
"data",
";",
"if",
"it",
"comes",
"from",
"a",
".",
"JED",
"file",
"parse",
"the",
"fusemap",
"into",
"raw",
"data",
"first"
] | static void identify_data(const char *name, const UINT8 *data, int length, romident_status *status)
{
char hash[HASH_BUF_SIZE];
UINT8 *tempjed = NULL;
astring *basename;
int found = 0;
jed_data jed;
if (core_filename_ends_with(name, ".jed") && jed_parse(data, length, &jed) == JEDERR_NONE)
{
length = jedbin_output(&jed, NULL, 0);
tempjed = (UINT8 *)malloc(length);
if (tempjed == NULL)
return;
jedbin_output(&jed, tempjed, length);
data = tempjed;
}
hash_data_clear(hash);
hash_compute(hash, data, length, HASH_SHA1 | HASH_CRC);
status->total++;
basename = core_filename_extract_base(astring_alloc(), name, FALSE);
mame_printf_info("%-20s", astring_c(basename));
astring_free(basename);
match_roms(hash, length, &found);
if (found == 0)
{
if ((length & (length - 1)) != 0)
{
mame_printf_info("NOT A ROM\n");
status->nonroms++;
}
else
mame_printf_info("NO MATCH\n");
}
else
status->matches++;
if (tempjed != NULL)
free(tempjed);
} | [
"static",
"void",
"identify_data",
"(",
"const",
"char",
"*",
"name",
",",
"const",
"UINT8",
"*",
"data",
",",
"int",
"length",
",",
"romident_status",
"*",
"status",
")",
"{",
"char",
"hash",
"[",
"HASH_BUF_SIZE",
"]",
";",
"UINT8",
"*",
"tempjed",
"=",
"NULL",
";",
"astring",
"*",
"basename",
";",
"int",
"found",
"=",
"0",
";",
"jed_data",
"jed",
";",
"if",
"(",
"core_filename_ends_with",
"(",
"name",
",",
"\"",
"\"",
")",
"&&",
"jed_parse",
"(",
"data",
",",
"length",
",",
"&",
"jed",
")",
"==",
"JEDERR_NONE",
")",
"{",
"length",
"=",
"jedbin_output",
"(",
"&",
"jed",
",",
"NULL",
",",
"0",
")",
";",
"tempjed",
"=",
"(",
"UINT8",
"*",
")",
"malloc",
"(",
"length",
")",
";",
"if",
"(",
"tempjed",
"==",
"NULL",
")",
"return",
";",
"jedbin_output",
"(",
"&",
"jed",
",",
"tempjed",
",",
"length",
")",
";",
"data",
"=",
"tempjed",
";",
"}",
"hash_data_clear",
"(",
"hash",
")",
";",
"hash_compute",
"(",
"hash",
",",
"data",
",",
"length",
",",
"HASH_SHA1",
"|",
"HASH_CRC",
")",
";",
"status",
"->",
"total",
"++",
";",
"basename",
"=",
"core_filename_extract_base",
"(",
"astring_alloc",
"(",
")",
",",
"name",
",",
"FALSE",
")",
";",
"mame_printf_info",
"(",
"\"",
"\"",
",",
"astring_c",
"(",
"basename",
")",
")",
";",
"astring_free",
"(",
"basename",
")",
";",
"match_roms",
"(",
"hash",
",",
"length",
",",
"&",
"found",
")",
";",
"if",
"(",
"found",
"==",
"0",
")",
"{",
"if",
"(",
"(",
"length",
"&",
"(",
"length",
"-",
"1",
")",
")",
"!=",
"0",
")",
"{",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
")",
";",
"status",
"->",
"nonroms",
"++",
";",
"}",
"else",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
")",
";",
"}",
"else",
"status",
"->",
"matches",
"++",
";",
"if",
"(",
"tempjed",
"!=",
"NULL",
")",
"free",
"(",
"tempjed",
")",
";",
"}"
] | identify_data - identify a buffer full of
data; if it comes from a .JED file, parse the
fusemap into raw data first | [
"identify_data",
"-",
"identify",
"a",
"buffer",
"full",
"of",
"data",
";",
"if",
"it",
"comes",
"from",
"a",
".",
"JED",
"file",
"parse",
"the",
"fusemap",
"into",
"raw",
"data",
"first"
] | [
"/* if this is a '.jed' file, process it into raw bits first */",
"/* now determine the new data length and allocate temporary memory for it */",
"/* create a binary output of the JED data and use that instead */",
"/* compute the hash of the data */",
"/* output the name */",
"/* see if we can find a match in the ROMs */",
"/* if we didn't find it, try to guess what it might be */",
"/* if not a power of 2, assume it is a non-ROM file */",
"/* otherwise, it's just not a match */",
"/* if we did find it, count it as a match */",
"/* free any temporary JED data */"
] | [
{
"param": "name",
"type": "char"
},
{
"param": "data",
"type": "UINT8"
},
{
"param": "length",
"type": "int"
},
{
"param": "status",
"type": "romident_status"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "length",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "status",
"type": "romident_status",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
02f6efcef29e107fa99ffa01cf9979338e99f5f0 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/clifront.c | [
"Unlicense"
] | C | match_roms | void | static void match_roms(const char *hash, int length, int *found)
{
int drvindex;
/* iterate over drivers */
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
{
machine_config *config = machine_config_alloc(drivers[drvindex]->machine_config);
const rom_entry *region, *rom;
const rom_source *source;
/* iterate over sources, regions and files within the region */
for (source = rom_first_source(drivers[drvindex], config); source != NULL; source = rom_next_source(drivers[drvindex], config, source))
for (region = rom_first_region(drivers[drvindex], source); region; region = rom_next_region(region))
for (rom = rom_first_file(region); rom; rom = rom_next_file(rom))
if (hash_data_is_equal(hash, ROM_GETHASHDATA(rom), 0))
{
int baddump = hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_BAD_DUMP);
/* output information about the match */
if (*found != 0)
mame_printf_info(" ");
mame_printf_info("= %s%-20s %s\n", baddump ? "(BAD) " : "", ROM_GETNAME(rom), drivers[drvindex]->description);
(*found)++;
}
machine_config_free(config);
}
} | /*-------------------------------------------------
match_roms - scan for a matching ROM by hash
-------------------------------------------------*/ | scan for a matching ROM by hash | [
"scan",
"for",
"a",
"matching",
"ROM",
"by",
"hash"
] | static void match_roms(const char *hash, int length, int *found)
{
int drvindex;
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
{
machine_config *config = machine_config_alloc(drivers[drvindex]->machine_config);
const rom_entry *region, *rom;
const rom_source *source;
for (source = rom_first_source(drivers[drvindex], config); source != NULL; source = rom_next_source(drivers[drvindex], config, source))
for (region = rom_first_region(drivers[drvindex], source); region; region = rom_next_region(region))
for (rom = rom_first_file(region); rom; rom = rom_next_file(rom))
if (hash_data_is_equal(hash, ROM_GETHASHDATA(rom), 0))
{
int baddump = hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_BAD_DUMP);
if (*found != 0)
mame_printf_info(" ");
mame_printf_info("= %s%-20s %s\n", baddump ? "(BAD) " : "", ROM_GETNAME(rom), drivers[drvindex]->description);
(*found)++;
}
machine_config_free(config);
}
} | [
"static",
"void",
"match_roms",
"(",
"const",
"char",
"*",
"hash",
",",
"int",
"length",
",",
"int",
"*",
"found",
")",
"{",
"int",
"drvindex",
";",
"for",
"(",
"drvindex",
"=",
"0",
";",
"drivers",
"[",
"drvindex",
"]",
"!=",
"NULL",
";",
"drvindex",
"++",
")",
"{",
"machine_config",
"*",
"config",
"=",
"machine_config_alloc",
"(",
"drivers",
"[",
"drvindex",
"]",
"->",
"machine_config",
")",
";",
"const",
"rom_entry",
"*",
"region",
",",
"*",
"rom",
";",
"const",
"rom_source",
"*",
"source",
";",
"for",
"(",
"source",
"=",
"rom_first_source",
"(",
"drivers",
"[",
"drvindex",
"]",
",",
"config",
")",
";",
"source",
"!=",
"NULL",
";",
"source",
"=",
"rom_next_source",
"(",
"drivers",
"[",
"drvindex",
"]",
",",
"config",
",",
"source",
")",
")",
"for",
"(",
"region",
"=",
"rom_first_region",
"(",
"drivers",
"[",
"drvindex",
"]",
",",
"source",
")",
";",
"region",
";",
"region",
"=",
"rom_next_region",
"(",
"region",
")",
")",
"for",
"(",
"rom",
"=",
"rom_first_file",
"(",
"region",
")",
";",
"rom",
";",
"rom",
"=",
"rom_next_file",
"(",
"rom",
")",
")",
"if",
"(",
"hash_data_is_equal",
"(",
"hash",
",",
"ROM_GETHASHDATA",
"(",
"rom",
")",
",",
"0",
")",
")",
"{",
"int",
"baddump",
"=",
"hash_data_has_info",
"(",
"ROM_GETHASHDATA",
"(",
"rom",
")",
",",
"HASH_INFO_BAD_DUMP",
")",
";",
"if",
"(",
"*",
"found",
"!=",
"0",
")",
"mame_printf_info",
"(",
"\"",
"\"",
")",
";",
"mame_printf_info",
"(",
"\"",
"\\n",
"\"",
",",
"baddump",
"?",
"\"",
"\"",
":",
"\"",
"\"",
",",
"ROM_GETNAME",
"(",
"rom",
")",
",",
"drivers",
"[",
"drvindex",
"]",
"->",
"description",
")",
";",
"(",
"*",
"found",
")",
"++",
";",
"}",
"machine_config_free",
"(",
"config",
")",
";",
"}",
"}"
] | match_roms - scan for a matching ROM by hash | [
"match_roms",
"-",
"scan",
"for",
"a",
"matching",
"ROM",
"by",
"hash"
] | [
"/* iterate over drivers */",
"/* iterate over sources, regions and files within the region */",
"/* output information about the match */"
] | [
{
"param": "hash",
"type": "char"
},
{
"param": "length",
"type": "int"
},
{
"param": "found",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hash",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "length",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "found",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0714f1698c0cb3db3b95c08984078991913432b6 | lofunz/mieme | Reloaded/trunk/src/mame/drivers/videopkr.c | [
"Unlicense"
] | C | count_7dig | void | static void count_7dig(unsigned long data, UINT8 index)
{
UINT8 i;
char strn[8];
sprintf(strn,"%7lu",data);
for (i = 0; i < 7; i++)
{
output_set_digit_value(index+i, dec_7seg((strn[6 - i] | 0x10) - 0x30));
}
} | /* Display a seven digit counter on layout - Index points to less significant digit*/ | Display a seven digit counter on layout - Index points to less significant digit | [
"Display",
"a",
"seven",
"digit",
"counter",
"on",
"layout",
"-",
"Index",
"points",
"to",
"less",
"significant",
"digit"
] | static void count_7dig(unsigned long data, UINT8 index)
{
UINT8 i;
char strn[8];
sprintf(strn,"%7lu",data);
for (i = 0; i < 7; i++)
{
output_set_digit_value(index+i, dec_7seg((strn[6 - i] | 0x10) - 0x30));
}
} | [
"static",
"void",
"count_7dig",
"(",
"unsigned",
"long",
"data",
",",
"UINT8",
"index",
")",
"{",
"UINT8",
"i",
";",
"char",
"strn",
"[",
"8",
"]",
";",
"sprintf",
"(",
"strn",
",",
"\"",
"\"",
",",
"data",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"7",
";",
"i",
"++",
")",
"{",
"output_set_digit_value",
"(",
"index",
"+",
"i",
",",
"dec_7seg",
"(",
"(",
"strn",
"[",
"6",
"-",
"i",
"]",
"|",
"0x10",
")",
"-",
"0x30",
")",
")",
";",
"}",
"}"
] | Display a seven digit counter on layout - Index points to less significant digit | [
"Display",
"a",
"seven",
"digit",
"counter",
"on",
"layout",
"-",
"Index",
"points",
"to",
"less",
"significant",
"digit"
] | [] | [
{
"param": "data",
"type": "unsigned long"
},
{
"param": "index",
"type": "UINT8"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data",
"type": "unsigned long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "index",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7a5ac232225c4dc69a1067fd695fdcb71d55aeb0 | lofunz/mieme | Reloaded/trunk/src/mame/video/vigilant.c | [
"Unlicense"
] | C | update_background | void | static void update_background(running_machine *machine)
{
int row,col,page;
int charcode;
charcode=0;
/* There are only three background ROMs (4 on bunccaneers!) */
for (page=0; page<4; page++)
{
for( row=0; row<256; row++ )
{
for( col=0; col<512; col+=32 )
{
drawgfx_opaque(bg_bitmap,
0,machine->gfx[2],
charcode,
row < 128 ? 0 : 1,
0,0,
512*page + col,row);
charcode++;
}
}
}
} | /***************************************************************************
update_background
There are three background ROMs, each one contains a 512x256 picture.
Redraw them if the palette changes.
**************************************************************************/ | update_background
There are three background ROMs, each one contains a 512x256 picture.
Redraw them if the palette changes. | [
"update_background",
"There",
"are",
"three",
"background",
"ROMs",
"each",
"one",
"contains",
"a",
"512x256",
"picture",
".",
"Redraw",
"them",
"if",
"the",
"palette",
"changes",
"."
] | static void update_background(running_machine *machine)
{
int row,col,page;
int charcode;
charcode=0;
for (page=0; page<4; page++)
{
for( row=0; row<256; row++ )
{
for( col=0; col<512; col+=32 )
{
drawgfx_opaque(bg_bitmap,
0,machine->gfx[2],
charcode,
row < 128 ? 0 : 1,
0,0,
512*page + col,row);
charcode++;
}
}
}
} | [
"static",
"void",
"update_background",
"(",
"running_machine",
"*",
"machine",
")",
"{",
"int",
"row",
",",
"col",
",",
"page",
";",
"int",
"charcode",
";",
"charcode",
"=",
"0",
";",
"for",
"(",
"page",
"=",
"0",
";",
"page",
"<",
"4",
";",
"page",
"++",
")",
"{",
"for",
"(",
"row",
"=",
"0",
";",
"row",
"<",
"256",
";",
"row",
"++",
")",
"{",
"for",
"(",
"col",
"=",
"0",
";",
"col",
"<",
"512",
";",
"col",
"+=",
"32",
")",
"{",
"drawgfx_opaque",
"(",
"bg_bitmap",
",",
"0",
",",
"machine",
"->",
"gfx",
"[",
"2",
"]",
",",
"charcode",
",",
"row",
"<",
"128",
"?",
"0",
":",
"1",
",",
"0",
",",
"0",
",",
"512",
"*",
"page",
"+",
"col",
",",
"row",
")",
";",
"charcode",
"++",
";",
"}",
"}",
"}",
"}"
] | update_background
There are three background ROMs, each one contains a 512x256 picture. | [
"update_background",
"There",
"are",
"three",
"background",
"ROMs",
"each",
"one",
"contains",
"a",
"512x256",
"picture",
"."
] | [
"/* There are only three background ROMs (4 on bunccaneers!) */"
] | [
{
"param": "machine",
"type": "running_machine"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "machine",
"type": "running_machine",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8a873410ae483e3ab84054cfc204f5098c13c202 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/drivers/pgm.c | [
"Unlicense"
] | C | expand_32x32x5bpp | void | static void expand_32x32x5bpp(running_machine *machine)
{
UINT8 *src = memory_region ( machine, "gfx1" );
UINT8 *dst = memory_region ( machine, "gfx2" );
size_t srcsize = memory_region_length( machine, "gfx1" );
int cnt, pix;
for (cnt = 0; cnt < srcsize/5 ; cnt ++)
{
pix = ((src[0+5*cnt] >> 0)& 0x1f ); dst[0+8*cnt]=pix;
pix = ((src[0+5*cnt] >> 5)& 0x07) | ((src[1+5*cnt] << 3) & 0x18);dst[1+8*cnt]=pix;
pix = ((src[1+5*cnt] >> 2)& 0x1f ); dst[2+8*cnt]=pix;
pix = ((src[1+5*cnt] >> 7)& 0x01) | ((src[2+5*cnt] << 1) & 0x1e);dst[3+8*cnt]=pix;
pix = ((src[2+5*cnt] >> 4)& 0x0f) | ((src[3+5*cnt] << 4) & 0x10);dst[4+8*cnt]=pix;
pix = ((src[3+5*cnt] >> 1)& 0x1f ); dst[5+8*cnt]=pix;
pix = ((src[3+5*cnt] >> 6)& 0x03) | ((src[4+5*cnt] << 2) & 0x1c);dst[6+8*cnt]=pix;
pix = ((src[4+5*cnt] >> 3)& 0x1f ); dst[7+8*cnt]=pix;
}
} | /* This function expands the 32x32 5-bit data into a format which is easier to
decode in MAME */ | This function expands the 32x32 5-bit data into a format which is easier to
decode in MAME | [
"This",
"function",
"expands",
"the",
"32x32",
"5",
"-",
"bit",
"data",
"into",
"a",
"format",
"which",
"is",
"easier",
"to",
"decode",
"in",
"MAME"
] | static void expand_32x32x5bpp(running_machine *machine)
{
UINT8 *src = memory_region ( machine, "gfx1" );
UINT8 *dst = memory_region ( machine, "gfx2" );
size_t srcsize = memory_region_length( machine, "gfx1" );
int cnt, pix;
for (cnt = 0; cnt < srcsize/5 ; cnt ++)
{
pix = ((src[0+5*cnt] >> 0)& 0x1f ); dst[0+8*cnt]=pix;
pix = ((src[0+5*cnt] >> 5)& 0x07) | ((src[1+5*cnt] << 3) & 0x18);dst[1+8*cnt]=pix;
pix = ((src[1+5*cnt] >> 2)& 0x1f ); dst[2+8*cnt]=pix;
pix = ((src[1+5*cnt] >> 7)& 0x01) | ((src[2+5*cnt] << 1) & 0x1e);dst[3+8*cnt]=pix;
pix = ((src[2+5*cnt] >> 4)& 0x0f) | ((src[3+5*cnt] << 4) & 0x10);dst[4+8*cnt]=pix;
pix = ((src[3+5*cnt] >> 1)& 0x1f ); dst[5+8*cnt]=pix;
pix = ((src[3+5*cnt] >> 6)& 0x03) | ((src[4+5*cnt] << 2) & 0x1c);dst[6+8*cnt]=pix;
pix = ((src[4+5*cnt] >> 3)& 0x1f ); dst[7+8*cnt]=pix;
}
} | [
"static",
"void",
"expand_32x32x5bpp",
"(",
"running_machine",
"*",
"machine",
")",
"{",
"UINT8",
"*",
"src",
"=",
"memory_region",
"(",
"machine",
",",
"\"",
"\"",
")",
";",
"UINT8",
"*",
"dst",
"=",
"memory_region",
"(",
"machine",
",",
"\"",
"\"",
")",
";",
"size_t",
"srcsize",
"=",
"memory_region_length",
"(",
"machine",
",",
"\"",
"\"",
")",
";",
"int",
"cnt",
",",
"pix",
";",
"for",
"(",
"cnt",
"=",
"0",
";",
"cnt",
"<",
"srcsize",
"/",
"5",
";",
"cnt",
"++",
")",
"{",
"pix",
"=",
"(",
"(",
"src",
"[",
"0",
"+",
"5",
"*",
"cnt",
"]",
">>",
"0",
")",
"&",
"0x1f",
")",
";",
"dst",
"[",
"0",
"+",
"8",
"*",
"cnt",
"]",
"=",
"pix",
";",
"pix",
"=",
"(",
"(",
"src",
"[",
"0",
"+",
"5",
"*",
"cnt",
"]",
">>",
"5",
")",
"&",
"0x07",
")",
"|",
"(",
"(",
"src",
"[",
"1",
"+",
"5",
"*",
"cnt",
"]",
"<<",
"3",
")",
"&",
"0x18",
")",
";",
"dst",
"[",
"1",
"+",
"8",
"*",
"cnt",
"]",
"=",
"pix",
";",
"pix",
"=",
"(",
"(",
"src",
"[",
"1",
"+",
"5",
"*",
"cnt",
"]",
">>",
"2",
")",
"&",
"0x1f",
")",
";",
"dst",
"[",
"2",
"+",
"8",
"*",
"cnt",
"]",
"=",
"pix",
";",
"pix",
"=",
"(",
"(",
"src",
"[",
"1",
"+",
"5",
"*",
"cnt",
"]",
">>",
"7",
")",
"&",
"0x01",
")",
"|",
"(",
"(",
"src",
"[",
"2",
"+",
"5",
"*",
"cnt",
"]",
"<<",
"1",
")",
"&",
"0x1e",
")",
";",
"dst",
"[",
"3",
"+",
"8",
"*",
"cnt",
"]",
"=",
"pix",
";",
"pix",
"=",
"(",
"(",
"src",
"[",
"2",
"+",
"5",
"*",
"cnt",
"]",
">>",
"4",
")",
"&",
"0x0f",
")",
"|",
"(",
"(",
"src",
"[",
"3",
"+",
"5",
"*",
"cnt",
"]",
"<<",
"4",
")",
"&",
"0x10",
")",
";",
"dst",
"[",
"4",
"+",
"8",
"*",
"cnt",
"]",
"=",
"pix",
";",
"pix",
"=",
"(",
"(",
"src",
"[",
"3",
"+",
"5",
"*",
"cnt",
"]",
">>",
"1",
")",
"&",
"0x1f",
")",
";",
"dst",
"[",
"5",
"+",
"8",
"*",
"cnt",
"]",
"=",
"pix",
";",
"pix",
"=",
"(",
"(",
"src",
"[",
"3",
"+",
"5",
"*",
"cnt",
"]",
">>",
"6",
")",
"&",
"0x03",
")",
"|",
"(",
"(",
"src",
"[",
"4",
"+",
"5",
"*",
"cnt",
"]",
"<<",
"2",
")",
"&",
"0x1c",
")",
";",
"dst",
"[",
"6",
"+",
"8",
"*",
"cnt",
"]",
"=",
"pix",
";",
"pix",
"=",
"(",
"(",
"src",
"[",
"4",
"+",
"5",
"*",
"cnt",
"]",
">>",
"3",
")",
"&",
"0x1f",
")",
";",
"dst",
"[",
"7",
"+",
"8",
"*",
"cnt",
"]",
"=",
"pix",
";",
"}",
"}"
] | This function expands the 32x32 5-bit data into a format which is easier to
decode in MAME | [
"This",
"function",
"expands",
"the",
"32x32",
"5",
"-",
"bit",
"data",
"into",
"a",
"format",
"which",
"is",
"easier",
"to",
"decode",
"in",
"MAME"
] | [] | [
{
"param": "machine",
"type": "running_machine"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "machine",
"type": "running_machine",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fe7f05d03ea88883580d13d203f8b6ab3c2f585 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/cp1610/cp1610.c | [
"Unlicense"
] | C | cp1610_negr | void | static void cp1610_negr(cp1610_state *cpustate, int n)
{
UINT32 temp;
CLR_SZOC;
temp = (cpustate->r[n] ^ 0xffff) + 1;
SET_COV(0,temp,1);
cpustate->r[n] = temp&0xffff;
SET_SZ(cpustate->r[n]);
cpustate->icount -= 6;
} | /***************************************************
* S Z C OV 0 000 100 ddd
* x x x x NEGR Rd
***************************************************/ | S Z C OV 0 000 100 ddd
x x x x NEGR Rd | [
"S",
"Z",
"C",
"OV",
"0",
"000",
"100",
"ddd",
"x",
"x",
"x",
"x",
"NEGR",
"Rd"
] | static void cp1610_negr(cp1610_state *cpustate, int n)
{
UINT32 temp;
CLR_SZOC;
temp = (cpustate->r[n] ^ 0xffff) + 1;
SET_COV(0,temp,1);
cpustate->r[n] = temp&0xffff;
SET_SZ(cpustate->r[n]);
cpustate->icount -= 6;
} | [
"static",
"void",
"cp1610_negr",
"(",
"cp1610_state",
"*",
"cpustate",
",",
"int",
"n",
")",
"{",
"UINT32",
"temp",
";",
"CLR_SZOC",
";",
"temp",
"=",
"(",
"cpustate",
"->",
"r",
"[",
"n",
"]",
"^",
"0xffff",
")",
"+",
"1",
";",
"SET_COV",
"(",
"0",
",",
"temp",
",",
"1",
")",
";",
"cpustate",
"->",
"r",
"[",
"n",
"]",
"=",
"temp",
"&",
"0xffff",
";",
"SET_SZ",
"(",
"cpustate",
"->",
"r",
"[",
"n",
"]",
")",
";",
"cpustate",
"->",
"icount",
"-=",
"6",
";",
"}"
] | S Z C OV 0 000 100 ddd
x x x x NEGR Rd | [
"S",
"Z",
"C",
"OV",
"0",
"000",
"100",
"ddd",
"x",
"x",
"x",
"x",
"NEGR",
"Rd"
] | [] | [
{
"param": "cpustate",
"type": "cp1610_state"
},
{
"param": "n",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpustate",
"type": "cp1610_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fe7f05d03ea88883580d13d203f8b6ab3c2f585 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/cp1610/cp1610.c | [
"Unlicense"
] | C | cp1610_adcr | void | static void cp1610_adcr(cp1610_state *cpustate, int n)
{
UINT16 offset = 0;
if (cpustate->flags & C)
offset = 1;
CLR_SZOC;
SET_COV(cpustate->r[n],offset,0);
cpustate->r[n] += offset;
SET_SZ(cpustate->r[n]);
cpustate->icount -= 6;
} | /***************************************************
* S Z C OV 0 000 101 ddd
* x x x x ADCR Rd
***************************************************/ | S Z C OV 0 000 101 ddd
x x x x ADCR Rd | [
"S",
"Z",
"C",
"OV",
"0",
"000",
"101",
"ddd",
"x",
"x",
"x",
"x",
"ADCR",
"Rd"
] | static void cp1610_adcr(cp1610_state *cpustate, int n)
{
UINT16 offset = 0;
if (cpustate->flags & C)
offset = 1;
CLR_SZOC;
SET_COV(cpustate->r[n],offset,0);
cpustate->r[n] += offset;
SET_SZ(cpustate->r[n]);
cpustate->icount -= 6;
} | [
"static",
"void",
"cp1610_adcr",
"(",
"cp1610_state",
"*",
"cpustate",
",",
"int",
"n",
")",
"{",
"UINT16",
"offset",
"=",
"0",
";",
"if",
"(",
"cpustate",
"->",
"flags",
"&",
"C",
")",
"offset",
"=",
"1",
";",
"CLR_SZOC",
";",
"SET_COV",
"(",
"cpustate",
"->",
"r",
"[",
"n",
"]",
",",
"offset",
",",
"0",
")",
";",
"cpustate",
"->",
"r",
"[",
"n",
"]",
"+=",
"offset",
";",
"SET_SZ",
"(",
"cpustate",
"->",
"r",
"[",
"n",
"]",
")",
";",
"cpustate",
"->",
"icount",
"-=",
"6",
";",
"}"
] | S Z C OV 0 000 101 ddd
x x x x ADCR Rd | [
"S",
"Z",
"C",
"OV",
"0",
"000",
"101",
"ddd",
"x",
"x",
"x",
"x",
"ADCR",
"Rd"
] | [] | [
{
"param": "cpustate",
"type": "cp1610_state"
},
{
"param": "n",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpustate",
"type": "cp1610_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fe7f05d03ea88883580d13d203f8b6ab3c2f585 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/cp1610/cp1610.c | [
"Unlicense"
] | C | cp1610_rswd | void | static void cp1610_rswd(cp1610_state *cpustate, int n)
{
cpustate->flags = cpustate->r[n];
cpustate->icount -= 6;
} | /***************************************************
* S Z C OV 0 000 111 sss
* x x x x RSWD Rs
***************************************************/ | S Z C OV 0 000 111 sss
x x x x RSWD Rs | [
"S",
"Z",
"C",
"OV",
"0",
"000",
"111",
"sss",
"x",
"x",
"x",
"x",
"RSWD",
"Rs"
] | static void cp1610_rswd(cp1610_state *cpustate, int n)
{
cpustate->flags = cpustate->r[n];
cpustate->icount -= 6;
} | [
"static",
"void",
"cp1610_rswd",
"(",
"cp1610_state",
"*",
"cpustate",
",",
"int",
"n",
")",
"{",
"cpustate",
"->",
"flags",
"=",
"cpustate",
"->",
"r",
"[",
"n",
"]",
";",
"cpustate",
"->",
"icount",
"-=",
"6",
";",
"}"
] | S Z C OV 0 000 111 sss
x x x x RSWD Rs | [
"S",
"Z",
"C",
"OV",
"0",
"000",
"111",
"sss",
"x",
"x",
"x",
"x",
"RSWD",
"Rs"
] | [] | [
{
"param": "cpustate",
"type": "cp1610_state"
},
{
"param": "n",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpustate",
"type": "cp1610_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fe7f05d03ea88883580d13d203f8b6ab3c2f585 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/cp1610/cp1610.c | [
"Unlicense"
] | C | cp1610_addr | void | static void cp1610_addr(cp1610_state *cpustate, int s, int d)
{
CLR_SZOC;
SET_COV(cpustate->r[s],cpustate->r[d],0);
cpustate->r[d] += cpustate->r[s];
SET_SZ(cpustate->r[d]);
cpustate->icount -= 6;
} | /***************************************************
* S Z C OV 0 011 sss ddd
* x x x x ADDR Rs, Rd
***************************************************/ | S Z C OV 0 011 sss ddd
x x x x ADDR Rs, Rd | [
"S",
"Z",
"C",
"OV",
"0",
"011",
"sss",
"ddd",
"x",
"x",
"x",
"x",
"ADDR",
"Rs",
"Rd"
] | static void cp1610_addr(cp1610_state *cpustate, int s, int d)
{
CLR_SZOC;
SET_COV(cpustate->r[s],cpustate->r[d],0);
cpustate->r[d] += cpustate->r[s];
SET_SZ(cpustate->r[d]);
cpustate->icount -= 6;
} | [
"static",
"void",
"cp1610_addr",
"(",
"cp1610_state",
"*",
"cpustate",
",",
"int",
"s",
",",
"int",
"d",
")",
"{",
"CLR_SZOC",
";",
"SET_COV",
"(",
"cpustate",
"->",
"r",
"[",
"s",
"]",
",",
"cpustate",
"->",
"r",
"[",
"d",
"]",
",",
"0",
")",
";",
"cpustate",
"->",
"r",
"[",
"d",
"]",
"+=",
"cpustate",
"->",
"r",
"[",
"s",
"]",
";",
"SET_SZ",
"(",
"cpustate",
"->",
"r",
"[",
"d",
"]",
")",
";",
"cpustate",
"->",
"icount",
"-=",
"6",
";",
"}"
] | S Z C OV 0 011 sss ddd
x x x x ADDR Rs, Rd | [
"S",
"Z",
"C",
"OV",
"0",
"011",
"sss",
"ddd",
"x",
"x",
"x",
"x",
"ADDR",
"Rs",
"Rd"
] | [] | [
{
"param": "cpustate",
"type": "cp1610_state"
},
{
"param": "s",
"type": "int"
},
{
"param": "d",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpustate",
"type": "cp1610_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "s",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "d",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fe7f05d03ea88883580d13d203f8b6ab3c2f585 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/cp1610/cp1610.c | [
"Unlicense"
] | C | cp1610_subr | void | static void cp1610_subr(cp1610_state *cpustate, int s, int d)
{
CLR_SZOC;
SET_COV(cpustate->r[d],(UINT32)((cpustate->r[s]^0xffff)+1),1);
cpustate->r[d] -= cpustate->r[s];
SET_SZ(cpustate->r[d]);
cpustate->icount -= 6;
} | /***************************************************
* S Z C OV 0 100 sss ddd
* x x x x SUBR Rs, Rd
***************************************************/ | S Z C OV 0 100 sss ddd
x x x x SUBR Rs, Rd | [
"S",
"Z",
"C",
"OV",
"0",
"100",
"sss",
"ddd",
"x",
"x",
"x",
"x",
"SUBR",
"Rs",
"Rd"
] | static void cp1610_subr(cp1610_state *cpustate, int s, int d)
{
CLR_SZOC;
SET_COV(cpustate->r[d],(UINT32)((cpustate->r[s]^0xffff)+1),1);
cpustate->r[d] -= cpustate->r[s];
SET_SZ(cpustate->r[d]);
cpustate->icount -= 6;
} | [
"static",
"void",
"cp1610_subr",
"(",
"cp1610_state",
"*",
"cpustate",
",",
"int",
"s",
",",
"int",
"d",
")",
"{",
"CLR_SZOC",
";",
"SET_COV",
"(",
"cpustate",
"->",
"r",
"[",
"d",
"]",
",",
"(",
"UINT32",
")",
"(",
"(",
"cpustate",
"->",
"r",
"[",
"s",
"]",
"^",
"0xffff",
")",
"+",
"1",
")",
",",
"1",
")",
";",
"cpustate",
"->",
"r",
"[",
"d",
"]",
"-=",
"cpustate",
"->",
"r",
"[",
"s",
"]",
";",
"SET_SZ",
"(",
"cpustate",
"->",
"r",
"[",
"d",
"]",
")",
";",
"cpustate",
"->",
"icount",
"-=",
"6",
";",
"}"
] | S Z C OV 0 100 sss ddd
x x x x SUBR Rs, Rd | [
"S",
"Z",
"C",
"OV",
"0",
"100",
"sss",
"ddd",
"x",
"x",
"x",
"x",
"SUBR",
"Rs",
"Rd"
] | [] | [
{
"param": "cpustate",
"type": "cp1610_state"
},
{
"param": "s",
"type": "int"
},
{
"param": "d",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpustate",
"type": "cp1610_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "s",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "d",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fe7f05d03ea88883580d13d203f8b6ab3c2f585 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/cp1610/cp1610.c | [
"Unlicense"
] | C | cp1610_cmpr | void | static void cp1610_cmpr(cp1610_state *cpustate, int s, int d)
{
UINT16 temp;
CLR_SZOC;
SET_COV(cpustate->r[d],(UINT32)((cpustate->r[s]^0xffff)+1),1);
temp = cpustate->r[d] - cpustate->r[s];
SET_SZ(temp);
cpustate->icount -= 6;
} | /***************************************************
* S Z C OV 0 101 sss ddd
* x x x x CMPR Rs, Rd
***************************************************/ | S Z C OV 0 101 sss ddd
x x x x CMPR Rs, Rd | [
"S",
"Z",
"C",
"OV",
"0",
"101",
"sss",
"ddd",
"x",
"x",
"x",
"x",
"CMPR",
"Rs",
"Rd"
] | static void cp1610_cmpr(cp1610_state *cpustate, int s, int d)
{
UINT16 temp;
CLR_SZOC;
SET_COV(cpustate->r[d],(UINT32)((cpustate->r[s]^0xffff)+1),1);
temp = cpustate->r[d] - cpustate->r[s];
SET_SZ(temp);
cpustate->icount -= 6;
} | [
"static",
"void",
"cp1610_cmpr",
"(",
"cp1610_state",
"*",
"cpustate",
",",
"int",
"s",
",",
"int",
"d",
")",
"{",
"UINT16",
"temp",
";",
"CLR_SZOC",
";",
"SET_COV",
"(",
"cpustate",
"->",
"r",
"[",
"d",
"]",
",",
"(",
"UINT32",
")",
"(",
"(",
"cpustate",
"->",
"r",
"[",
"s",
"]",
"^",
"0xffff",
")",
"+",
"1",
")",
",",
"1",
")",
";",
"temp",
"=",
"cpustate",
"->",
"r",
"[",
"d",
"]",
"-",
"cpustate",
"->",
"r",
"[",
"s",
"]",
";",
"SET_SZ",
"(",
"temp",
")",
";",
"cpustate",
"->",
"icount",
"-=",
"6",
";",
"}"
] | S Z C OV 0 101 sss ddd
x x x x CMPR Rs, Rd | [
"S",
"Z",
"C",
"OV",
"0",
"101",
"sss",
"ddd",
"x",
"x",
"x",
"x",
"CMPR",
"Rs",
"Rd"
] | [] | [
{
"param": "cpustate",
"type": "cp1610_state"
},
{
"param": "s",
"type": "int"
},
{
"param": "d",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpustate",
"type": "cp1610_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "s",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "d",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fe7f05d03ea88883580d13d203f8b6ab3c2f585 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/cp1610/cp1610.c | [
"Unlicense"
] | C | cp1610_add | void | static void cp1610_add(cp1610_state *cpustate, int d)
{
UINT16 addr = cp1610_readop(cpustate->r[7]);
UINT16 data = cp1610_readmem16(addr);
cpustate->r[7]++;
CLR_SZOC;
SET_COV(cpustate->r[d],data,0);
cpustate->r[d] += data;
SET_SZ(cpustate->r[d]);
cpustate->icount -= 10;
} | /***************************************************
* S Z C OV 1 011 000 ddd a aaa aaa aaa aaa aaa
* x x x x ADD ADDR, Rd
***************************************************/ | S Z C OV 1 011 000 ddd a aaa aaa aaa aaa aaa
x x x x ADD ADDR, Rd | [
"S",
"Z",
"C",
"OV",
"1",
"011",
"000",
"ddd",
"a",
"aaa",
"aaa",
"aaa",
"aaa",
"aaa",
"x",
"x",
"x",
"x",
"ADD",
"ADDR",
"Rd"
] | static void cp1610_add(cp1610_state *cpustate, int d)
{
UINT16 addr = cp1610_readop(cpustate->r[7]);
UINT16 data = cp1610_readmem16(addr);
cpustate->r[7]++;
CLR_SZOC;
SET_COV(cpustate->r[d],data,0);
cpustate->r[d] += data;
SET_SZ(cpustate->r[d]);
cpustate->icount -= 10;
} | [
"static",
"void",
"cp1610_add",
"(",
"cp1610_state",
"*",
"cpustate",
",",
"int",
"d",
")",
"{",
"UINT16",
"addr",
"=",
"cp1610_readop",
"(",
"cpustate",
"->",
"r",
"[",
"7",
"]",
")",
";",
"UINT16",
"data",
"=",
"cp1610_readmem16",
"(",
"addr",
")",
";",
"cpustate",
"->",
"r",
"[",
"7",
"]",
"++",
";",
"CLR_SZOC",
";",
"SET_COV",
"(",
"cpustate",
"->",
"r",
"[",
"d",
"]",
",",
"data",
",",
"0",
")",
";",
"cpustate",
"->",
"r",
"[",
"d",
"]",
"+=",
"data",
";",
"SET_SZ",
"(",
"cpustate",
"->",
"r",
"[",
"d",
"]",
")",
";",
"cpustate",
"->",
"icount",
"-=",
"10",
";",
"}"
] | S Z C OV 1 011 000 ddd a aaa aaa aaa aaa aaa
x x x x ADD ADDR, Rd | [
"S",
"Z",
"C",
"OV",
"1",
"011",
"000",
"ddd",
"a",
"aaa",
"aaa",
"aaa",
"aaa",
"aaa",
"x",
"x",
"x",
"x",
"ADD",
"ADDR",
"Rd"
] | [] | [
{
"param": "cpustate",
"type": "cp1610_state"
},
{
"param": "d",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpustate",
"type": "cp1610_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "d",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fe7f05d03ea88883580d13d203f8b6ab3c2f585 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/cp1610/cp1610.c | [
"Unlicense"
] | C | cp1610_sub | void | static void cp1610_sub(cp1610_state *cpustate, int d)
{
UINT16 addr = cp1610_readop(cpustate->r[7]);
UINT32 data = cp1610_readmem16(addr);
cpustate->r[7]++;
CLR_SZOC;
data = (data ^ 0xffff) + 1;
SET_COV(cpustate->r[d],data,1);
data &= 0xffff;
cpustate->r[d] += data;
SET_SZ(cpustate->r[d]);
cpustate->icount -= 10;
} | /***************************************************
* S Z C OV 1 100 000 ddd a aaa aaa aaa aaa aaa
* x x x x SUB ADDR, Rd
***************************************************/ | S Z C OV 1 100 000 ddd a aaa aaa aaa aaa aaa
x x x x SUB ADDR, Rd | [
"S",
"Z",
"C",
"OV",
"1",
"100",
"000",
"ddd",
"a",
"aaa",
"aaa",
"aaa",
"aaa",
"aaa",
"x",
"x",
"x",
"x",
"SUB",
"ADDR",
"Rd"
] | static void cp1610_sub(cp1610_state *cpustate, int d)
{
UINT16 addr = cp1610_readop(cpustate->r[7]);
UINT32 data = cp1610_readmem16(addr);
cpustate->r[7]++;
CLR_SZOC;
data = (data ^ 0xffff) + 1;
SET_COV(cpustate->r[d],data,1);
data &= 0xffff;
cpustate->r[d] += data;
SET_SZ(cpustate->r[d]);
cpustate->icount -= 10;
} | [
"static",
"void",
"cp1610_sub",
"(",
"cp1610_state",
"*",
"cpustate",
",",
"int",
"d",
")",
"{",
"UINT16",
"addr",
"=",
"cp1610_readop",
"(",
"cpustate",
"->",
"r",
"[",
"7",
"]",
")",
";",
"UINT32",
"data",
"=",
"cp1610_readmem16",
"(",
"addr",
")",
";",
"cpustate",
"->",
"r",
"[",
"7",
"]",
"++",
";",
"CLR_SZOC",
";",
"data",
"=",
"(",
"data",
"^",
"0xffff",
")",
"+",
"1",
";",
"SET_COV",
"(",
"cpustate",
"->",
"r",
"[",
"d",
"]",
",",
"data",
",",
"1",
")",
";",
"data",
"&=",
"0xffff",
";",
"cpustate",
"->",
"r",
"[",
"d",
"]",
"+=",
"data",
";",
"SET_SZ",
"(",
"cpustate",
"->",
"r",
"[",
"d",
"]",
")",
";",
"cpustate",
"->",
"icount",
"-=",
"10",
";",
"}"
] | S Z C OV 1 100 000 ddd a aaa aaa aaa aaa aaa
x x x x SUB ADDR, Rd | [
"S",
"Z",
"C",
"OV",
"1",
"100",
"000",
"ddd",
"a",
"aaa",
"aaa",
"aaa",
"aaa",
"aaa",
"x",
"x",
"x",
"x",
"SUB",
"ADDR",
"Rd"
] | [] | [
{
"param": "cpustate",
"type": "cp1610_state"
},
{
"param": "d",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpustate",
"type": "cp1610_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "d",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fe7f05d03ea88883580d13d203f8b6ab3c2f585 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/cp1610/cp1610.c | [
"Unlicense"
] | C | cp1610_cmp | void | static void cp1610_cmp(cp1610_state *cpustate, int d)
{
UINT16 addr = cp1610_readop(cpustate->r[7]);
UINT32 data = cp1610_readmem16(addr);
UINT16 res;
cpustate->r[7]++;
CLR_SZOC;
data = (data ^ 0xffff) + 1;
SET_COV(cpustate->r[d],data,1);
data &= 0xffff;
res = cpustate->r[d] + data;
SET_SZ(res);
cpustate->icount -= 10;
} | /***************************************************
* S Z C OV 1 101 000 ddd a aaa aaa aaa aaa aaa
* x x x x CMP ADDR, Rd
***************************************************/ | S Z C OV 1 101 000 ddd a aaa aaa aaa aaa aaa
x x x x CMP ADDR, Rd | [
"S",
"Z",
"C",
"OV",
"1",
"101",
"000",
"ddd",
"a",
"aaa",
"aaa",
"aaa",
"aaa",
"aaa",
"x",
"x",
"x",
"x",
"CMP",
"ADDR",
"Rd"
] | static void cp1610_cmp(cp1610_state *cpustate, int d)
{
UINT16 addr = cp1610_readop(cpustate->r[7]);
UINT32 data = cp1610_readmem16(addr);
UINT16 res;
cpustate->r[7]++;
CLR_SZOC;
data = (data ^ 0xffff) + 1;
SET_COV(cpustate->r[d],data,1);
data &= 0xffff;
res = cpustate->r[d] + data;
SET_SZ(res);
cpustate->icount -= 10;
} | [
"static",
"void",
"cp1610_cmp",
"(",
"cp1610_state",
"*",
"cpustate",
",",
"int",
"d",
")",
"{",
"UINT16",
"addr",
"=",
"cp1610_readop",
"(",
"cpustate",
"->",
"r",
"[",
"7",
"]",
")",
";",
"UINT32",
"data",
"=",
"cp1610_readmem16",
"(",
"addr",
")",
";",
"UINT16",
"res",
";",
"cpustate",
"->",
"r",
"[",
"7",
"]",
"++",
";",
"CLR_SZOC",
";",
"data",
"=",
"(",
"data",
"^",
"0xffff",
")",
"+",
"1",
";",
"SET_COV",
"(",
"cpustate",
"->",
"r",
"[",
"d",
"]",
",",
"data",
",",
"1",
")",
";",
"data",
"&=",
"0xffff",
";",
"res",
"=",
"cpustate",
"->",
"r",
"[",
"d",
"]",
"+",
"data",
";",
"SET_SZ",
"(",
"res",
")",
";",
"cpustate",
"->",
"icount",
"-=",
"10",
";",
"}"
] | S Z C OV 1 101 000 ddd a aaa aaa aaa aaa aaa
x x x x CMP ADDR, Rd | [
"S",
"Z",
"C",
"OV",
"1",
"101",
"000",
"ddd",
"a",
"aaa",
"aaa",
"aaa",
"aaa",
"aaa",
"x",
"x",
"x",
"x",
"CMP",
"ADDR",
"Rd"
] | [] | [
{
"param": "cpustate",
"type": "cp1610_state"
},
{
"param": "d",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpustate",
"type": "cp1610_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "d",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fe7f05d03ea88883580d13d203f8b6ab3c2f585 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/cp1610/cp1610.c | [
"Unlicense"
] | C | cp1610_and | void | static void cp1610_and(cp1610_state *cpustate, int d)
{
UINT16 addr = cp1610_readop(cpustate->r[7]);
UINT16 data = cp1610_readmem16(addr);
cpustate->r[7]++;
CLR_SZ;
cpustate->r[d] &= data;
SET_SZ(cpustate->r[d]);
cpustate->icount -= 10;
} | /***************************************************
* S Z C OV 1 110 000 ddd a aaa aaa aaa aaa aaa
* x x - - AND ADDR, Rd
***************************************************/ | S Z C OV 1 110 000 ddd a aaa aaa aaa aaa aaa
x x - - AND ADDR, Rd | [
"S",
"Z",
"C",
"OV",
"1",
"110",
"000",
"ddd",
"a",
"aaa",
"aaa",
"aaa",
"aaa",
"aaa",
"x",
"x",
"-",
"-",
"AND",
"ADDR",
"Rd"
] | static void cp1610_and(cp1610_state *cpustate, int d)
{
UINT16 addr = cp1610_readop(cpustate->r[7]);
UINT16 data = cp1610_readmem16(addr);
cpustate->r[7]++;
CLR_SZ;
cpustate->r[d] &= data;
SET_SZ(cpustate->r[d]);
cpustate->icount -= 10;
} | [
"static",
"void",
"cp1610_and",
"(",
"cp1610_state",
"*",
"cpustate",
",",
"int",
"d",
")",
"{",
"UINT16",
"addr",
"=",
"cp1610_readop",
"(",
"cpustate",
"->",
"r",
"[",
"7",
"]",
")",
";",
"UINT16",
"data",
"=",
"cp1610_readmem16",
"(",
"addr",
")",
";",
"cpustate",
"->",
"r",
"[",
"7",
"]",
"++",
";",
"CLR_SZ",
";",
"cpustate",
"->",
"r",
"[",
"d",
"]",
"&=",
"data",
";",
"SET_SZ",
"(",
"cpustate",
"->",
"r",
"[",
"d",
"]",
")",
";",
"cpustate",
"->",
"icount",
"-=",
"10",
";",
"}"
] | S Z C OV 1 110 000 ddd a aaa aaa aaa aaa aaa
x x - - AND ADDR, Rd | [
"S",
"Z",
"C",
"OV",
"1",
"110",
"000",
"ddd",
"a",
"aaa",
"aaa",
"aaa",
"aaa",
"aaa",
"x",
"x",
"-",
"-",
"AND",
"ADDR",
"Rd"
] | [] | [
{
"param": "cpustate",
"type": "cp1610_state"
},
{
"param": "d",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpustate",
"type": "cp1610_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "d",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fe7f05d03ea88883580d13d203f8b6ab3c2f585 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/cp1610/cp1610.c | [
"Unlicense"
] | C | cp1610_xor | void | static void cp1610_xor(cp1610_state *cpustate, int d)
{
UINT16 addr = cp1610_readop(cpustate->r[7]);
UINT16 data = cp1610_readmem16(addr);
cpustate->r[7]++;
CLR_SZ;
cpustate->r[d] ^= data;
SET_SZ(cpustate->r[d]);
cpustate->icount -= 10;
} | /***************************************************
* S Z C OV 1 111 000 ddd a aaa aaa aaa aaa aaa
* x x - - XOR ADDR, Rd
***************************************************/ | S Z C OV 1 111 000 ddd a aaa aaa aaa aaa aaa
x x - - XOR ADDR, Rd | [
"S",
"Z",
"C",
"OV",
"1",
"111",
"000",
"ddd",
"a",
"aaa",
"aaa",
"aaa",
"aaa",
"aaa",
"x",
"x",
"-",
"-",
"XOR",
"ADDR",
"Rd"
] | static void cp1610_xor(cp1610_state *cpustate, int d)
{
UINT16 addr = cp1610_readop(cpustate->r[7]);
UINT16 data = cp1610_readmem16(addr);
cpustate->r[7]++;
CLR_SZ;
cpustate->r[d] ^= data;
SET_SZ(cpustate->r[d]);
cpustate->icount -= 10;
} | [
"static",
"void",
"cp1610_xor",
"(",
"cp1610_state",
"*",
"cpustate",
",",
"int",
"d",
")",
"{",
"UINT16",
"addr",
"=",
"cp1610_readop",
"(",
"cpustate",
"->",
"r",
"[",
"7",
"]",
")",
";",
"UINT16",
"data",
"=",
"cp1610_readmem16",
"(",
"addr",
")",
";",
"cpustate",
"->",
"r",
"[",
"7",
"]",
"++",
";",
"CLR_SZ",
";",
"cpustate",
"->",
"r",
"[",
"d",
"]",
"^=",
"data",
";",
"SET_SZ",
"(",
"cpustate",
"->",
"r",
"[",
"d",
"]",
")",
";",
"cpustate",
"->",
"icount",
"-=",
"10",
";",
"}"
] | S Z C OV 1 111 000 ddd a aaa aaa aaa aaa aaa
x x - - XOR ADDR, Rd | [
"S",
"Z",
"C",
"OV",
"1",
"111",
"000",
"ddd",
"a",
"aaa",
"aaa",
"aaa",
"aaa",
"aaa",
"x",
"x",
"-",
"-",
"XOR",
"ADDR",
"Rd"
] | [] | [
{
"param": "cpustate",
"type": "cp1610_state"
},
{
"param": "d",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpustate",
"type": "cp1610_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "d",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fe7f05d03ea88883580d13d203f8b6ab3c2f585 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/cp1610/cp1610.c | [
"Unlicense"
] | C | cp1610_sdbd_addi | void | static void cp1610_sdbd_addi(cp1610_state *cpustate, int d)
{
UINT16 addr;
UINT16 temp;
CLR_SZOC;
addr = cp1610_readop(cpustate->r[7]) & 0xff;
cpustate->r[7]++;
addr |= (cp1610_readop(cpustate->r[7]) << 8);
cpustate->r[7]++;
temp = addr;
SET_COV(cpustate->r[d],temp,0);
cpustate->r[d] += temp;
SET_SZ(cpustate->r[d]);
cpustate->icount -= 14;
} | /************************************************************************
* S Z C OV 0x001 1 011 111 ddd x xxx xLL LLL LLL x xxx xUU UUU UUU
* x x x x SDBD, ADDI I-I, Rd
************************************************************************/ | S Z C OV 0x001 1 011 111 ddd x xxx xLL LLL LLL x xxx xUU UUU UUU
x x x x SDBD, ADDI I-I, Rd | [
"S",
"Z",
"C",
"OV",
"0x001",
"1",
"011",
"111",
"ddd",
"x",
"xxx",
"xLL",
"LLL",
"LLL",
"x",
"xxx",
"xUU",
"UUU",
"UUU",
"x",
"x",
"x",
"x",
"SDBD",
"ADDI",
"I",
"-",
"I",
"Rd"
] | static void cp1610_sdbd_addi(cp1610_state *cpustate, int d)
{
UINT16 addr;
UINT16 temp;
CLR_SZOC;
addr = cp1610_readop(cpustate->r[7]) & 0xff;
cpustate->r[7]++;
addr |= (cp1610_readop(cpustate->r[7]) << 8);
cpustate->r[7]++;
temp = addr;
SET_COV(cpustate->r[d],temp,0);
cpustate->r[d] += temp;
SET_SZ(cpustate->r[d]);
cpustate->icount -= 14;
} | [
"static",
"void",
"cp1610_sdbd_addi",
"(",
"cp1610_state",
"*",
"cpustate",
",",
"int",
"d",
")",
"{",
"UINT16",
"addr",
";",
"UINT16",
"temp",
";",
"CLR_SZOC",
";",
"addr",
"=",
"cp1610_readop",
"(",
"cpustate",
"->",
"r",
"[",
"7",
"]",
")",
"&",
"0xff",
";",
"cpustate",
"->",
"r",
"[",
"7",
"]",
"++",
";",
"addr",
"|=",
"(",
"cp1610_readop",
"(",
"cpustate",
"->",
"r",
"[",
"7",
"]",
")",
"<<",
"8",
")",
";",
"cpustate",
"->",
"r",
"[",
"7",
"]",
"++",
";",
"temp",
"=",
"addr",
";",
"SET_COV",
"(",
"cpustate",
"->",
"r",
"[",
"d",
"]",
",",
"temp",
",",
"0",
")",
";",
"cpustate",
"->",
"r",
"[",
"d",
"]",
"+=",
"temp",
";",
"SET_SZ",
"(",
"cpustate",
"->",
"r",
"[",
"d",
"]",
")",
";",
"cpustate",
"->",
"icount",
"-=",
"14",
";",
"}"
] | S Z C OV 0x001 1 011 111 ddd x xxx xLL LLL LLL x xxx xUU UUU UUU
x x x x SDBD, ADDI I-I, Rd | [
"S",
"Z",
"C",
"OV",
"0x001",
"1",
"011",
"111",
"ddd",
"x",
"xxx",
"xLL",
"LLL",
"LLL",
"x",
"xxx",
"xUU",
"UUU",
"UUU",
"x",
"x",
"x",
"x",
"SDBD",
"ADDI",
"I",
"-",
"I",
"Rd"
] | [] | [
{
"param": "cpustate",
"type": "cp1610_state"
},
{
"param": "d",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpustate",
"type": "cp1610_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "d",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fe7f05d03ea88883580d13d203f8b6ab3c2f585 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/cp1610/cp1610.c | [
"Unlicense"
] | C | cp1610_sdbd_subi | void | static void cp1610_sdbd_subi(cp1610_state *cpustate, int d)
{
UINT16 addr;
UINT32 temp;
CLR_SZOC;
addr = cp1610_readop(cpustate->r[7]) & 0xff;
cpustate->r[7]++;
addr |= (cp1610_readop(cpustate->r[7]) << 8);
cpustate->r[7]++;
temp = addr;
temp = (temp ^ 0xffff) + 1;
SET_COV(cpustate->r[d],temp,1);
temp &= 0xffff;
cpustate->r[d] += temp;
SET_SZ(cpustate->r[d]);
cpustate->icount -= 14;
} | /************************************************************************
* S Z C OV 0x001 1 100 111 ddd x xxx xLL LLL LLL x xxx xUU UUU UUU
* x x x x SDBD, SUBI I-I, Rd
************************************************************************/ | S Z C OV 0x001 1 100 111 ddd x xxx xLL LLL LLL x xxx xUU UUU UUU
x x x x SDBD, SUBI I-I, Rd | [
"S",
"Z",
"C",
"OV",
"0x001",
"1",
"100",
"111",
"ddd",
"x",
"xxx",
"xLL",
"LLL",
"LLL",
"x",
"xxx",
"xUU",
"UUU",
"UUU",
"x",
"x",
"x",
"x",
"SDBD",
"SUBI",
"I",
"-",
"I",
"Rd"
] | static void cp1610_sdbd_subi(cp1610_state *cpustate, int d)
{
UINT16 addr;
UINT32 temp;
CLR_SZOC;
addr = cp1610_readop(cpustate->r[7]) & 0xff;
cpustate->r[7]++;
addr |= (cp1610_readop(cpustate->r[7]) << 8);
cpustate->r[7]++;
temp = addr;
temp = (temp ^ 0xffff) + 1;
SET_COV(cpustate->r[d],temp,1);
temp &= 0xffff;
cpustate->r[d] += temp;
SET_SZ(cpustate->r[d]);
cpustate->icount -= 14;
} | [
"static",
"void",
"cp1610_sdbd_subi",
"(",
"cp1610_state",
"*",
"cpustate",
",",
"int",
"d",
")",
"{",
"UINT16",
"addr",
";",
"UINT32",
"temp",
";",
"CLR_SZOC",
";",
"addr",
"=",
"cp1610_readop",
"(",
"cpustate",
"->",
"r",
"[",
"7",
"]",
")",
"&",
"0xff",
";",
"cpustate",
"->",
"r",
"[",
"7",
"]",
"++",
";",
"addr",
"|=",
"(",
"cp1610_readop",
"(",
"cpustate",
"->",
"r",
"[",
"7",
"]",
")",
"<<",
"8",
")",
";",
"cpustate",
"->",
"r",
"[",
"7",
"]",
"++",
";",
"temp",
"=",
"addr",
";",
"temp",
"=",
"(",
"temp",
"^",
"0xffff",
")",
"+",
"1",
";",
"SET_COV",
"(",
"cpustate",
"->",
"r",
"[",
"d",
"]",
",",
"temp",
",",
"1",
")",
";",
"temp",
"&=",
"0xffff",
";",
"cpustate",
"->",
"r",
"[",
"d",
"]",
"+=",
"temp",
";",
"SET_SZ",
"(",
"cpustate",
"->",
"r",
"[",
"d",
"]",
")",
";",
"cpustate",
"->",
"icount",
"-=",
"14",
";",
"}"
] | S Z C OV 0x001 1 100 111 ddd x xxx xLL LLL LLL x xxx xUU UUU UUU
x x x x SDBD, SUBI I-I, Rd | [
"S",
"Z",
"C",
"OV",
"0x001",
"1",
"100",
"111",
"ddd",
"x",
"xxx",
"xLL",
"LLL",
"LLL",
"x",
"xxx",
"xUU",
"UUU",
"UUU",
"x",
"x",
"x",
"x",
"SDBD",
"SUBI",
"I",
"-",
"I",
"Rd"
] | [] | [
{
"param": "cpustate",
"type": "cp1610_state"
},
{
"param": "d",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpustate",
"type": "cp1610_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "d",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fe7f05d03ea88883580d13d203f8b6ab3c2f585 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/cp1610/cp1610.c | [
"Unlicense"
] | C | cp1610_sdbd_cmpi | void | static void cp1610_sdbd_cmpi(cp1610_state *cpustate, int d)
{
UINT16 addr;
UINT32 temp;
UINT16 temp2;
CLR_SZOC;
addr = cp1610_readop(cpustate->r[7]) & 0xff;
cpustate->r[7]++;
addr |= (cp1610_readop(cpustate->r[7]) << 8);
cpustate->r[7]++;
temp = addr;
temp = (temp ^ 0xffff) + 1;
SET_COV(cpustate->r[d],temp,1);
temp &= 0xffff;
temp2 = cpustate->r[d] + temp;
SET_SZ(temp2);
cpustate->icount -= 14;
} | /************************************************************************
* S Z C OV 0x001 1 101 111 ddd x xxx xLL LLL LLL x xxx xUU UUU UUU
* x x x x SDBD, CMPI I-I, Rd
************************************************************************/ | S Z C OV 0x001 1 101 111 ddd x xxx xLL LLL LLL x xxx xUU UUU UUU
x x x x SDBD, CMPI I-I, Rd | [
"S",
"Z",
"C",
"OV",
"0x001",
"1",
"101",
"111",
"ddd",
"x",
"xxx",
"xLL",
"LLL",
"LLL",
"x",
"xxx",
"xUU",
"UUU",
"UUU",
"x",
"x",
"x",
"x",
"SDBD",
"CMPI",
"I",
"-",
"I",
"Rd"
] | static void cp1610_sdbd_cmpi(cp1610_state *cpustate, int d)
{
UINT16 addr;
UINT32 temp;
UINT16 temp2;
CLR_SZOC;
addr = cp1610_readop(cpustate->r[7]) & 0xff;
cpustate->r[7]++;
addr |= (cp1610_readop(cpustate->r[7]) << 8);
cpustate->r[7]++;
temp = addr;
temp = (temp ^ 0xffff) + 1;
SET_COV(cpustate->r[d],temp,1);
temp &= 0xffff;
temp2 = cpustate->r[d] + temp;
SET_SZ(temp2);
cpustate->icount -= 14;
} | [
"static",
"void",
"cp1610_sdbd_cmpi",
"(",
"cp1610_state",
"*",
"cpustate",
",",
"int",
"d",
")",
"{",
"UINT16",
"addr",
";",
"UINT32",
"temp",
";",
"UINT16",
"temp2",
";",
"CLR_SZOC",
";",
"addr",
"=",
"cp1610_readop",
"(",
"cpustate",
"->",
"r",
"[",
"7",
"]",
")",
"&",
"0xff",
";",
"cpustate",
"->",
"r",
"[",
"7",
"]",
"++",
";",
"addr",
"|=",
"(",
"cp1610_readop",
"(",
"cpustate",
"->",
"r",
"[",
"7",
"]",
")",
"<<",
"8",
")",
";",
"cpustate",
"->",
"r",
"[",
"7",
"]",
"++",
";",
"temp",
"=",
"addr",
";",
"temp",
"=",
"(",
"temp",
"^",
"0xffff",
")",
"+",
"1",
";",
"SET_COV",
"(",
"cpustate",
"->",
"r",
"[",
"d",
"]",
",",
"temp",
",",
"1",
")",
";",
"temp",
"&=",
"0xffff",
";",
"temp2",
"=",
"cpustate",
"->",
"r",
"[",
"d",
"]",
"+",
"temp",
";",
"SET_SZ",
"(",
"temp2",
")",
";",
"cpustate",
"->",
"icount",
"-=",
"14",
";",
"}"
] | S Z C OV 0x001 1 101 111 ddd x xxx xLL LLL LLL x xxx xUU UUU UUU
x x x x SDBD, CMPI I-I, Rd | [
"S",
"Z",
"C",
"OV",
"0x001",
"1",
"101",
"111",
"ddd",
"x",
"xxx",
"xLL",
"LLL",
"LLL",
"x",
"xxx",
"xUU",
"UUU",
"UUU",
"x",
"x",
"x",
"x",
"SDBD",
"CMPI",
"I",
"-",
"I",
"Rd"
] | [] | [
{
"param": "cpustate",
"type": "cp1610_state"
},
{
"param": "d",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpustate",
"type": "cp1610_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "d",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fe7f05d03ea88883580d13d203f8b6ab3c2f585 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/cp1610/cp1610.c | [
"Unlicense"
] | C | cp1610_sdbd_andi | void | static void cp1610_sdbd_andi(cp1610_state *cpustate, int d)
{
UINT16 addr;
CLR_SZ;
addr = cp1610_readop(cpustate->r[7]) & 0xff;
cpustate->r[7]++;
addr |= (cp1610_readop(cpustate->r[7]) << 8);
cpustate->r[7]++;
cpustate->r[d] &= addr;
SET_SZ(cpustate->r[d]);
cpustate->icount -= 14;
} | /************************************************************************
* S Z C OV 0x001 1 110 111 ddd x xxx xLL LLL LLL x xxx xUU UUU UUU
* x x - - SDBD, ANDI I-I, Rd
************************************************************************/ | S Z C OV 0x001 1 110 111 ddd x xxx xLL LLL LLL x xxx xUU UUU UUU
x x - - SDBD, ANDI I-I, Rd | [
"S",
"Z",
"C",
"OV",
"0x001",
"1",
"110",
"111",
"ddd",
"x",
"xxx",
"xLL",
"LLL",
"LLL",
"x",
"xxx",
"xUU",
"UUU",
"UUU",
"x",
"x",
"-",
"-",
"SDBD",
"ANDI",
"I",
"-",
"I",
"Rd"
] | static void cp1610_sdbd_andi(cp1610_state *cpustate, int d)
{
UINT16 addr;
CLR_SZ;
addr = cp1610_readop(cpustate->r[7]) & 0xff;
cpustate->r[7]++;
addr |= (cp1610_readop(cpustate->r[7]) << 8);
cpustate->r[7]++;
cpustate->r[d] &= addr;
SET_SZ(cpustate->r[d]);
cpustate->icount -= 14;
} | [
"static",
"void",
"cp1610_sdbd_andi",
"(",
"cp1610_state",
"*",
"cpustate",
",",
"int",
"d",
")",
"{",
"UINT16",
"addr",
";",
"CLR_SZ",
";",
"addr",
"=",
"cp1610_readop",
"(",
"cpustate",
"->",
"r",
"[",
"7",
"]",
")",
"&",
"0xff",
";",
"cpustate",
"->",
"r",
"[",
"7",
"]",
"++",
";",
"addr",
"|=",
"(",
"cp1610_readop",
"(",
"cpustate",
"->",
"r",
"[",
"7",
"]",
")",
"<<",
"8",
")",
";",
"cpustate",
"->",
"r",
"[",
"7",
"]",
"++",
";",
"cpustate",
"->",
"r",
"[",
"d",
"]",
"&=",
"addr",
";",
"SET_SZ",
"(",
"cpustate",
"->",
"r",
"[",
"d",
"]",
")",
";",
"cpustate",
"->",
"icount",
"-=",
"14",
";",
"}"
] | S Z C OV 0x001 1 110 111 ddd x xxx xLL LLL LLL x xxx xUU UUU UUU
x x - - SDBD, ANDI I-I, Rd | [
"S",
"Z",
"C",
"OV",
"0x001",
"1",
"110",
"111",
"ddd",
"x",
"xxx",
"xLL",
"LLL",
"LLL",
"x",
"xxx",
"xUU",
"UUU",
"UUU",
"x",
"x",
"-",
"-",
"SDBD",
"ANDI",
"I",
"-",
"I",
"Rd"
] | [] | [
{
"param": "cpustate",
"type": "cp1610_state"
},
{
"param": "d",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpustate",
"type": "cp1610_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "d",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fe7f05d03ea88883580d13d203f8b6ab3c2f585 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/cp1610/cp1610.c | [
"Unlicense"
] | C | cp1610_sdbd_xori | void | static void cp1610_sdbd_xori(cp1610_state *cpustate, int d)
{
UINT16 addr;
CLR_SZ;
addr = cp1610_readop(cpustate->r[7]) & 0xff;
cpustate->r[7]++;
addr |= (cp1610_readop(cpustate->r[7]) << 8);
cpustate->r[7]++;
cpustate->r[d] ^= addr;
SET_SZ(cpustate->r[d]);
cpustate->icount -= 14;
} | /************************************************************************
* S Z C OV 0x001 1 111 111 ddd x xxx xLL LLL LLL x xxx xUU UUU UUU
* x x - - SDBD, XORI I-I, Rd
************************************************************************/ | S Z C OV 0x001 1 111 111 ddd x xxx xLL LLL LLL x xxx xUU UUU UUU
x x - - SDBD, XORI I-I, Rd | [
"S",
"Z",
"C",
"OV",
"0x001",
"1",
"111",
"111",
"ddd",
"x",
"xxx",
"xLL",
"LLL",
"LLL",
"x",
"xxx",
"xUU",
"UUU",
"UUU",
"x",
"x",
"-",
"-",
"SDBD",
"XORI",
"I",
"-",
"I",
"Rd"
] | static void cp1610_sdbd_xori(cp1610_state *cpustate, int d)
{
UINT16 addr;
CLR_SZ;
addr = cp1610_readop(cpustate->r[7]) & 0xff;
cpustate->r[7]++;
addr |= (cp1610_readop(cpustate->r[7]) << 8);
cpustate->r[7]++;
cpustate->r[d] ^= addr;
SET_SZ(cpustate->r[d]);
cpustate->icount -= 14;
} | [
"static",
"void",
"cp1610_sdbd_xori",
"(",
"cp1610_state",
"*",
"cpustate",
",",
"int",
"d",
")",
"{",
"UINT16",
"addr",
";",
"CLR_SZ",
";",
"addr",
"=",
"cp1610_readop",
"(",
"cpustate",
"->",
"r",
"[",
"7",
"]",
")",
"&",
"0xff",
";",
"cpustate",
"->",
"r",
"[",
"7",
"]",
"++",
";",
"addr",
"|=",
"(",
"cp1610_readop",
"(",
"cpustate",
"->",
"r",
"[",
"7",
"]",
")",
"<<",
"8",
")",
";",
"cpustate",
"->",
"r",
"[",
"7",
"]",
"++",
";",
"cpustate",
"->",
"r",
"[",
"d",
"]",
"^=",
"addr",
";",
"SET_SZ",
"(",
"cpustate",
"->",
"r",
"[",
"d",
"]",
")",
";",
"cpustate",
"->",
"icount",
"-=",
"14",
";",
"}"
] | S Z C OV 0x001 1 111 111 ddd x xxx xLL LLL LLL x xxx xUU UUU UUU
x x - - SDBD, XORI I-I, Rd | [
"S",
"Z",
"C",
"OV",
"0x001",
"1",
"111",
"111",
"ddd",
"x",
"xxx",
"xLL",
"LLL",
"LLL",
"x",
"xxx",
"xUU",
"UUU",
"UUU",
"x",
"x",
"-",
"-",
"SDBD",
"XORI",
"I",
"-",
"I",
"Rd"
] | [] | [
{
"param": "cpustate",
"type": "cp1610_state"
},
{
"param": "d",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpustate",
"type": "cp1610_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "d",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fe7f05d03ea88883580d13d203f8b6ab3c2f585 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/cp1610/cp1610.c | [
"Unlicense"
] | C | cp1610_je | void | static void cp1610_je(cp1610_state *cpustate, UINT16 addr)
{
cpustate->r[7] = addr;
cpustate->intr_enabled = 1;
} | /***************************************************
* S Z C OV 1 1aa aaa a01 x xxx xxa aaa aaa aaa
* - - - - JE ADDR
***************************************************/ | S Z C OV 1 1aa aaa a01 x xxx xxa aaa aaa aaa
- - - - JE ADDR | [
"S",
"Z",
"C",
"OV",
"1",
"1aa",
"aaa",
"a01",
"x",
"xxx",
"xxa",
"aaa",
"aaa",
"aaa",
"-",
"-",
"-",
"-",
"JE",
"ADDR"
] | static void cp1610_je(cp1610_state *cpustate, UINT16 addr)
{
cpustate->r[7] = addr;
cpustate->intr_enabled = 1;
} | [
"static",
"void",
"cp1610_je",
"(",
"cp1610_state",
"*",
"cpustate",
",",
"UINT16",
"addr",
")",
"{",
"cpustate",
"->",
"r",
"[",
"7",
"]",
"=",
"addr",
";",
"cpustate",
"->",
"intr_enabled",
"=",
"1",
";",
"}"
] | S Z C OV 1 1aa aaa a01 x xxx xxa aaa aaa aaa
- - - - JE ADDR | [
"S",
"Z",
"C",
"OV",
"1",
"1aa",
"aaa",
"a01",
"x",
"xxx",
"xxa",
"aaa",
"aaa",
"aaa",
"-",
"-",
"-",
"-",
"JE",
"ADDR"
] | [] | [
{
"param": "cpustate",
"type": "cp1610_state"
},
{
"param": "addr",
"type": "UINT16"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpustate",
"type": "cp1610_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addr",
"type": "UINT16",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fe7f05d03ea88883580d13d203f8b6ab3c2f585 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/cp1610/cp1610.c | [
"Unlicense"
] | C | cp1610_jd | void | static void cp1610_jd(cp1610_state *cpustate, UINT16 addr)
{
cpustate->r[7] = addr;
cpustate->intr_enabled = 0;
} | /***************************************************
* S Z C OV 1 1aa aaa a10 x xxx xxa aaa aaa aaa
* - - - - JD ADDR
***************************************************/ | S Z C OV 1 1aa aaa a10 x xxx xxa aaa aaa aaa
- - - - JD ADDR | [
"S",
"Z",
"C",
"OV",
"1",
"1aa",
"aaa",
"a10",
"x",
"xxx",
"xxa",
"aaa",
"aaa",
"aaa",
"-",
"-",
"-",
"-",
"JD",
"ADDR"
] | static void cp1610_jd(cp1610_state *cpustate, UINT16 addr)
{
cpustate->r[7] = addr;
cpustate->intr_enabled = 0;
} | [
"static",
"void",
"cp1610_jd",
"(",
"cp1610_state",
"*",
"cpustate",
",",
"UINT16",
"addr",
")",
"{",
"cpustate",
"->",
"r",
"[",
"7",
"]",
"=",
"addr",
";",
"cpustate",
"->",
"intr_enabled",
"=",
"0",
";",
"}"
] | S Z C OV 1 1aa aaa a10 x xxx xxa aaa aaa aaa
- - - - JD ADDR | [
"S",
"Z",
"C",
"OV",
"1",
"1aa",
"aaa",
"a10",
"x",
"xxx",
"xxa",
"aaa",
"aaa",
"aaa",
"-",
"-",
"-",
"-",
"JD",
"ADDR"
] | [] | [
{
"param": "cpustate",
"type": "cp1610_state"
},
{
"param": "addr",
"type": "UINT16"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpustate",
"type": "cp1610_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addr",
"type": "UINT16",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d18814cd002b0da898aedc0ff43283170e6682a1 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/drivers/segac2.c | [
"Unlicense"
] | C | recompute_palette_tables | void | static void recompute_palette_tables(void)
{
int i;
for (i = 0; i < 4; i++)
{
int bgpal = 0x000 + bg_palbase * 0x40 + i * 0x10;
int sppal = 0x100 + sp_palbase * 0x40 + i * 0x10;
if (!segac2_alt_palette_mode)
{
segac2_bg_pal_lookup[i] = 0x200 * palbank + bgpal;
segac2_sp_pal_lookup[i] = 0x200 * palbank + sppal;
}
else
{
segac2_bg_pal_lookup[i] = 0x200 * palbank + ((bgpal << 1) & 0x180) + ((~bgpal >> 2) & 0x40) + (bgpal & 0x30);
segac2_sp_pal_lookup[i] = 0x200 * palbank + ((~sppal << 2) & 0x100) + ((sppal << 2) & 0x80) + ((~sppal >> 2) & 0x40) + ((sppal >> 2) & 0x20) + (sppal & 0x10);
}
}
} | /******************************************************************************
Palette Tables
*******************************************************************************
Both the background and sprites within the VDP have 4 possible palettes
to select from. External hardware on the C2 boards, controlled by the
EPM5032 chip and the I/O chip, allows for more complex palette selection.
The actual palette entry comes from:
Bits 10-9 = output from I/O port H
Bits 8-5 = output from EPM5032
Bits 4-0 = direct from the VDP
In order to compute bits 8-5, the EPM5032 gets the sprite/background
output line along with the two bits of palette info. For most games, the
two bits of palette info map straight through as follows:
Bits 10-9 = output from I/O port H
Bits 8 = sprite/background select
Bits 7-6 = palette selected by writing to prot_w
Bits 5-4 = direct from the VDP palette select
Bits 3-0 = direct from the VDP
However, because there are 4 bits completely controlled by the EPM5032,
it doesn't have to always map this way. An alternate palette mode can
be selected which alters the output palette by swizzling the color
RAM address bits.
******************************************************************************/ | Palette Tables
Both the background and sprites within the VDP have 4 possible palettes
to select from. External hardware on the C2 boards, controlled by the
EPM5032 chip and the I/O chip, allows for more complex palette selection.
The actual palette entry comes from.
Bits 10-9 = output from I/O port H
Bits 8-5 = output from EPM5032
Bits 4-0 = direct from the VDP
In order to compute bits 8-5, the EPM5032 gets the sprite/background
output line along with the two bits of palette info. For most games, the
two bits of palette info map straight through as follows.
However, because there are 4 bits completely controlled by the EPM5032,
it doesn't have to always map this way. An alternate palette mode can
be selected which alters the output palette by swizzling the color
RAM address bits. | [
"Palette",
"Tables",
"Both",
"the",
"background",
"and",
"sprites",
"within",
"the",
"VDP",
"have",
"4",
"possible",
"palettes",
"to",
"select",
"from",
".",
"External",
"hardware",
"on",
"the",
"C2",
"boards",
"controlled",
"by",
"the",
"EPM5032",
"chip",
"and",
"the",
"I",
"/",
"O",
"chip",
"allows",
"for",
"more",
"complex",
"palette",
"selection",
".",
"The",
"actual",
"palette",
"entry",
"comes",
"from",
".",
"Bits",
"10",
"-",
"9",
"=",
"output",
"from",
"I",
"/",
"O",
"port",
"H",
"Bits",
"8",
"-",
"5",
"=",
"output",
"from",
"EPM5032",
"Bits",
"4",
"-",
"0",
"=",
"direct",
"from",
"the",
"VDP",
"In",
"order",
"to",
"compute",
"bits",
"8",
"-",
"5",
"the",
"EPM5032",
"gets",
"the",
"sprite",
"/",
"background",
"output",
"line",
"along",
"with",
"the",
"two",
"bits",
"of",
"palette",
"info",
".",
"For",
"most",
"games",
"the",
"two",
"bits",
"of",
"palette",
"info",
"map",
"straight",
"through",
"as",
"follows",
".",
"However",
"because",
"there",
"are",
"4",
"bits",
"completely",
"controlled",
"by",
"the",
"EPM5032",
"it",
"doesn",
"'",
"t",
"have",
"to",
"always",
"map",
"this",
"way",
".",
"An",
"alternate",
"palette",
"mode",
"can",
"be",
"selected",
"which",
"alters",
"the",
"output",
"palette",
"by",
"swizzling",
"the",
"color",
"RAM",
"address",
"bits",
"."
] | static void recompute_palette_tables(void)
{
int i;
for (i = 0; i < 4; i++)
{
int bgpal = 0x000 + bg_palbase * 0x40 + i * 0x10;
int sppal = 0x100 + sp_palbase * 0x40 + i * 0x10;
if (!segac2_alt_palette_mode)
{
segac2_bg_pal_lookup[i] = 0x200 * palbank + bgpal;
segac2_sp_pal_lookup[i] = 0x200 * palbank + sppal;
}
else
{
segac2_bg_pal_lookup[i] = 0x200 * palbank + ((bgpal << 1) & 0x180) + ((~bgpal >> 2) & 0x40) + (bgpal & 0x30);
segac2_sp_pal_lookup[i] = 0x200 * palbank + ((~sppal << 2) & 0x100) + ((sppal << 2) & 0x80) + ((~sppal >> 2) & 0x40) + ((sppal >> 2) & 0x20) + (sppal & 0x10);
}
}
} | [
"static",
"void",
"recompute_palette_tables",
"(",
"void",
")",
"{",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"4",
";",
"i",
"++",
")",
"{",
"int",
"bgpal",
"=",
"0x000",
"+",
"bg_palbase",
"*",
"0x40",
"+",
"i",
"*",
"0x10",
";",
"int",
"sppal",
"=",
"0x100",
"+",
"sp_palbase",
"*",
"0x40",
"+",
"i",
"*",
"0x10",
";",
"if",
"(",
"!",
"segac2_alt_palette_mode",
")",
"{",
"segac2_bg_pal_lookup",
"[",
"i",
"]",
"=",
"0x200",
"*",
"palbank",
"+",
"bgpal",
";",
"segac2_sp_pal_lookup",
"[",
"i",
"]",
"=",
"0x200",
"*",
"palbank",
"+",
"sppal",
";",
"}",
"else",
"{",
"segac2_bg_pal_lookup",
"[",
"i",
"]",
"=",
"0x200",
"*",
"palbank",
"+",
"(",
"(",
"bgpal",
"<<",
"1",
")",
"&",
"0x180",
")",
"+",
"(",
"(",
"~",
"bgpal",
">>",
"2",
")",
"&",
"0x40",
")",
"+",
"(",
"bgpal",
"&",
"0x30",
")",
";",
"segac2_sp_pal_lookup",
"[",
"i",
"]",
"=",
"0x200",
"*",
"palbank",
"+",
"(",
"(",
"~",
"sppal",
"<<",
"2",
")",
"&",
"0x100",
")",
"+",
"(",
"(",
"sppal",
"<<",
"2",
")",
"&",
"0x80",
")",
"+",
"(",
"(",
"~",
"sppal",
">>",
"2",
")",
"&",
"0x40",
")",
"+",
"(",
"(",
"sppal",
">>",
"2",
")",
"&",
"0x20",
")",
"+",
"(",
"sppal",
"&",
"0x10",
")",
";",
"}",
"}",
"}"
] | Palette Tables
Both the background and sprites within the VDP have 4 possible palettes
to select from. | [
"Palette",
"Tables",
"Both",
"the",
"background",
"and",
"sprites",
"within",
"the",
"VDP",
"have",
"4",
"possible",
"palettes",
"to",
"select",
"from",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
2093696428b41847056dea1cac7973de4aa16b2b | lofunz/mieme | Reloaded/trunk/src/mame/machine/vertigo.c | [
"Unlicense"
] | C | vertigo_update_irq | void | void vertigo_update_irq(running_device *device)
{
if (irq_state < 7)
cputag_set_input_line(device->machine, "maincpu", irq_state ^ 7, CLEAR_LINE);
irq_state = ttl74148_output_r(device);
if (irq_state < 7)
cputag_set_input_line(device->machine, "maincpu", irq_state ^ 7, ASSERT_LINE);
} | /*************************************
*
* IRQ handling. The priority encoder
* has to be emulated. Otherwise
* interrupts are lost.
*
*************************************/ | IRQ handling. The priority encoder
has to be emulated. Otherwise
interrupts are lost. | [
"IRQ",
"handling",
".",
"The",
"priority",
"encoder",
"has",
"to",
"be",
"emulated",
".",
"Otherwise",
"interrupts",
"are",
"lost",
"."
] | void vertigo_update_irq(running_device *device)
{
if (irq_state < 7)
cputag_set_input_line(device->machine, "maincpu", irq_state ^ 7, CLEAR_LINE);
irq_state = ttl74148_output_r(device);
if (irq_state < 7)
cputag_set_input_line(device->machine, "maincpu", irq_state ^ 7, ASSERT_LINE);
} | [
"void",
"vertigo_update_irq",
"(",
"running_device",
"*",
"device",
")",
"{",
"if",
"(",
"irq_state",
"<",
"7",
")",
"cputag_set_input_line",
"(",
"device",
"->",
"machine",
",",
"\"",
"\"",
",",
"irq_state",
"^",
"7",
",",
"CLEAR_LINE",
")",
";",
"irq_state",
"=",
"ttl74148_output_r",
"(",
"device",
")",
";",
"if",
"(",
"irq_state",
"<",
"7",
")",
"cputag_set_input_line",
"(",
"device",
"->",
"machine",
",",
"\"",
"\"",
",",
"irq_state",
"^",
"7",
",",
"ASSERT_LINE",
")",
";",
"}"
] | IRQ handling. | [
"IRQ",
"handling",
"."
] | [] | [
{
"param": "device",
"type": "running_device"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "device",
"type": "running_device",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
401e8cdb4b9a9d7cae545da5cb405e4a22de1f0e | lofunz/mieme | Reloaded/trunk/src/mame/video/tecmo16.c | [
"Unlicense"
] | C | blendbitmaps | void | static void blendbitmaps(running_machine *machine,
bitmap_t *dest,bitmap_t *src1,bitmap_t *src2,bitmap_t *src3,
int sx,int sy,const rectangle *clip)
{
int ox;
int oy;
int ex;
int ey;
/* check bounds */
ox = sx;
oy = sy;
ex = sx + src1->width - 1;
if (sx < 0) sx = 0;
if (sx < clip->min_x) sx = clip->min_x;
if (ex >= dest->width) ex = dest->width - 1;
if (ex > clip->max_x) ex = clip->max_x;
if (sx > ex) return;
ey = sy + src1->height - 1;
if (sy < 0) sy = 0;
if (sy < clip->min_y) sy = clip->min_y;
if (ey >= dest->height) ey = dest->height - 1;
if (ey > clip->max_y) ey = clip->max_y;
if (sy > ey) return;
{
const pen_t *paldata = machine->pens;
UINT32 *end;
UINT16 *sd1 = (UINT16 *)src1->base; /* source data */
UINT16 *sd2 = (UINT16 *)src2->base;
UINT16 *sd3 = (UINT16 *)src3->base;
int sw = ex-sx+1; /* source width */
int sh = ey-sy+1; /* source height */
int sm = src1->rowpixels; /* source modulo */
UINT32 *dd = BITMAP_ADDR32(dest, sy, sx); /* dest data */
int dm = dest->rowpixels; /* dest modulo */
sd1 += (sx-ox);
sd1 += sm * (sy-oy);
sd2 += (sx-ox);
sd2 += sm * (sy-oy);
sd3 += (sx-ox);
sd3 += sm * (sy-oy);
sm -= sw;
dm -= sw;
while (sh)
{
#define BLENDPIXEL(x) if (sd3[x]) { \
if (sd2[x]) { \
dd[x] = paldata[sd2[x] | 0x0400] + paldata[sd3[x]]; \
} else { \
dd[x] = paldata[sd1[x] | 0x0400] + paldata[sd3[x]]; \
} \
} else { \
if (sd2[x]) { \
if (sd2[x] & 0x0800) { \
dd[x] = paldata[sd1[x] | 0x0400] + paldata[sd2[x]]; \
} else { \
dd[x] = paldata[sd2[x]]; \
} \
} else { \
dd[x] = paldata[sd1[x]]; \
} \
}
end = dd + sw;
while (dd <= end - 8)
{
BLENDPIXEL(0);
BLENDPIXEL(1);
BLENDPIXEL(2);
BLENDPIXEL(3);
BLENDPIXEL(4);
BLENDPIXEL(5);
BLENDPIXEL(6);
BLENDPIXEL(7);
dd += 8;
sd1 += 8;
sd2 += 8;
sd3 += 8;
}
while (dd < end)
{
BLENDPIXEL(0);
dd++;
sd1++;
sd2++;
sd3++;
}
dd += dm;
sd1 += sm;
sd2 += sm;
sd3 += sm;
sh--;
#undef BLENDPIXEL
}
}
} | /* mix & blend the paletted 16-bit tile and sprite bitmaps into an RGB 32-bit bitmap */ | mix & blend the paletted 16-bit tile and sprite bitmaps into an RGB 32-bit bitmap | [
"mix",
"&",
"blend",
"the",
"paletted",
"16",
"-",
"bit",
"tile",
"and",
"sprite",
"bitmaps",
"into",
"an",
"RGB",
"32",
"-",
"bit",
"bitmap"
] | static void blendbitmaps(running_machine *machine,
bitmap_t *dest,bitmap_t *src1,bitmap_t *src2,bitmap_t *src3,
int sx,int sy,const rectangle *clip)
{
int ox;
int oy;
int ex;
int ey;
ox = sx;
oy = sy;
ex = sx + src1->width - 1;
if (sx < 0) sx = 0;
if (sx < clip->min_x) sx = clip->min_x;
if (ex >= dest->width) ex = dest->width - 1;
if (ex > clip->max_x) ex = clip->max_x;
if (sx > ex) return;
ey = sy + src1->height - 1;
if (sy < 0) sy = 0;
if (sy < clip->min_y) sy = clip->min_y;
if (ey >= dest->height) ey = dest->height - 1;
if (ey > clip->max_y) ey = clip->max_y;
if (sy > ey) return;
{
const pen_t *paldata = machine->pens;
UINT32 *end;
UINT16 *sd1 = (UINT16 *)src1->base;
UINT16 *sd2 = (UINT16 *)src2->base;
UINT16 *sd3 = (UINT16 *)src3->base;
int sw = ex-sx+1;
int sh = ey-sy+1;
int sm = src1->rowpixels;
UINT32 *dd = BITMAP_ADDR32(dest, sy, sx);
int dm = dest->rowpixels;
sd1 += (sx-ox);
sd1 += sm * (sy-oy);
sd2 += (sx-ox);
sd2 += sm * (sy-oy);
sd3 += (sx-ox);
sd3 += sm * (sy-oy);
sm -= sw;
dm -= sw;
while (sh)
{
#define BLENDPIXEL(x) if (sd3[x]) { \
if (sd2[x]) { \
dd[x] = paldata[sd2[x] | 0x0400] + paldata[sd3[x]]; \
} else { \
dd[x] = paldata[sd1[x] | 0x0400] + paldata[sd3[x]]; \
} \
} else { \
if (sd2[x]) { \
if (sd2[x] & 0x0800) { \
dd[x] = paldata[sd1[x] | 0x0400] + paldata[sd2[x]]; \
} else { \
dd[x] = paldata[sd2[x]]; \
} \
} else { \
dd[x] = paldata[sd1[x]]; \
} \
}
end = dd + sw;
while (dd <= end - 8)
{
BLENDPIXEL(0);
BLENDPIXEL(1);
BLENDPIXEL(2);
BLENDPIXEL(3);
BLENDPIXEL(4);
BLENDPIXEL(5);
BLENDPIXEL(6);
BLENDPIXEL(7);
dd += 8;
sd1 += 8;
sd2 += 8;
sd3 += 8;
}
while (dd < end)
{
BLENDPIXEL(0);
dd++;
sd1++;
sd2++;
sd3++;
}
dd += dm;
sd1 += sm;
sd2 += sm;
sd3 += sm;
sh--;
#undef BLENDPIXEL
}
}
} | [
"static",
"void",
"blendbitmaps",
"(",
"running_machine",
"*",
"machine",
",",
"bitmap_t",
"*",
"dest",
",",
"bitmap_t",
"*",
"src1",
",",
"bitmap_t",
"*",
"src2",
",",
"bitmap_t",
"*",
"src3",
",",
"int",
"sx",
",",
"int",
"sy",
",",
"const",
"rectangle",
"*",
"clip",
")",
"{",
"int",
"ox",
";",
"int",
"oy",
";",
"int",
"ex",
";",
"int",
"ey",
";",
"ox",
"=",
"sx",
";",
"oy",
"=",
"sy",
";",
"ex",
"=",
"sx",
"+",
"src1",
"->",
"width",
"-",
"1",
";",
"if",
"(",
"sx",
"<",
"0",
")",
"sx",
"=",
"0",
";",
"if",
"(",
"sx",
"<",
"clip",
"->",
"min_x",
")",
"sx",
"=",
"clip",
"->",
"min_x",
";",
"if",
"(",
"ex",
">=",
"dest",
"->",
"width",
")",
"ex",
"=",
"dest",
"->",
"width",
"-",
"1",
";",
"if",
"(",
"ex",
">",
"clip",
"->",
"max_x",
")",
"ex",
"=",
"clip",
"->",
"max_x",
";",
"if",
"(",
"sx",
">",
"ex",
")",
"return",
";",
"ey",
"=",
"sy",
"+",
"src1",
"->",
"height",
"-",
"1",
";",
"if",
"(",
"sy",
"<",
"0",
")",
"sy",
"=",
"0",
";",
"if",
"(",
"sy",
"<",
"clip",
"->",
"min_y",
")",
"sy",
"=",
"clip",
"->",
"min_y",
";",
"if",
"(",
"ey",
">=",
"dest",
"->",
"height",
")",
"ey",
"=",
"dest",
"->",
"height",
"-",
"1",
";",
"if",
"(",
"ey",
">",
"clip",
"->",
"max_y",
")",
"ey",
"=",
"clip",
"->",
"max_y",
";",
"if",
"(",
"sy",
">",
"ey",
")",
"return",
";",
"{",
"const",
"pen_t",
"*",
"paldata",
"=",
"machine",
"->",
"pens",
";",
"UINT32",
"*",
"end",
";",
"UINT16",
"*",
"sd1",
"=",
"(",
"UINT16",
"*",
")",
"src1",
"->",
"base",
";",
"UINT16",
"*",
"sd2",
"=",
"(",
"UINT16",
"*",
")",
"src2",
"->",
"base",
";",
"UINT16",
"*",
"sd3",
"=",
"(",
"UINT16",
"*",
")",
"src3",
"->",
"base",
";",
"int",
"sw",
"=",
"ex",
"-",
"sx",
"+",
"1",
";",
"int",
"sh",
"=",
"ey",
"-",
"sy",
"+",
"1",
";",
"int",
"sm",
"=",
"src1",
"->",
"rowpixels",
";",
"UINT32",
"*",
"dd",
"=",
"BITMAP_ADDR32",
"(",
"dest",
",",
"sy",
",",
"sx",
")",
";",
"int",
"dm",
"=",
"dest",
"->",
"rowpixels",
";",
"sd1",
"+=",
"(",
"sx",
"-",
"ox",
")",
";",
"sd1",
"+=",
"sm",
"*",
"(",
"sy",
"-",
"oy",
")",
";",
"sd2",
"+=",
"(",
"sx",
"-",
"ox",
")",
";",
"sd2",
"+=",
"sm",
"*",
"(",
"sy",
"-",
"oy",
")",
";",
"sd3",
"+=",
"(",
"sx",
"-",
"ox",
")",
";",
"sd3",
"+=",
"sm",
"*",
"(",
"sy",
"-",
"oy",
")",
";",
"sm",
"-=",
"sw",
";",
"dm",
"-=",
"sw",
";",
"while",
"(",
"sh",
")",
"{",
"#define",
"BLENDPIXEL",
"(",
"x",
")",
"\tif (sd3[x]) {\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\t\t\t\t\t\t\tif (sd2[x]) {\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\t\t\t\t\t\t\t\tdd[x] = paldata[sd2[x] | 0x0400] + paldata[sd3[x]];\t\t\t\\\r\n\t\t\t\t\t\t\t} else {\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\t\t\t\t\t\t\t\tdd[x] = paldata[sd1[x] | 0x0400] + paldata[sd3[x]];\t\t\t\\\r\n\t\t\t\t\t\t\t}\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\t\t\t\t\t\t} else {\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\t\t\t\t\t\t\tif (sd2[x]) {\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\t\t\t\t\t\t\t\tif (sd2[x] & 0x0800) {\t\t\t\t\t\t\t\t\t\t\\\r\n\t\t\t\t\t\t\t\t\tdd[x] = paldata[sd1[x] | 0x0400] + paldata[sd2[x]];\t\t\\\r\n\t\t\t\t\t\t\t\t} else {\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\t\t\t\t\t\t\t\t\tdd[x] = paldata[sd2[x]];\t\t\t\t\t\t\t\t\\\r\n\t\t\t\t\t\t\t\t}\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\t\t\t\t\t\t\t} else {\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\t\t\t\t\t\t\t\tdd[x] = paldata[sd1[x]];\t\t\t\t\t\t\t\t\t\\\r\n\t\t\t\t\t\t\t}\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\t\t\t\t\t\t}\r",
"\n",
"end",
"=",
"dd",
"+",
"sw",
";",
"while",
"(",
"dd",
"<=",
"end",
"-",
"8",
")",
"{",
"BLENDPIXEL",
"(",
"0",
")",
";",
"BLENDPIXEL",
"(",
"1",
")",
";",
"BLENDPIXEL",
"(",
"2",
")",
";",
"BLENDPIXEL",
"(",
"3",
")",
";",
"BLENDPIXEL",
"(",
"4",
")",
";",
"BLENDPIXEL",
"(",
"5",
")",
";",
"BLENDPIXEL",
"(",
"6",
")",
";",
"BLENDPIXEL",
"(",
"7",
")",
";",
"dd",
"+=",
"8",
";",
"sd1",
"+=",
"8",
";",
"sd2",
"+=",
"8",
";",
"sd3",
"+=",
"8",
";",
"}",
"while",
"(",
"dd",
"<",
"end",
")",
"{",
"BLENDPIXEL",
"(",
"0",
")",
";",
"dd",
"++",
";",
"sd1",
"++",
";",
"sd2",
"++",
";",
"sd3",
"++",
";",
"}",
"dd",
"+=",
"dm",
";",
"sd1",
"+=",
"sm",
";",
"sd2",
"+=",
"sm",
";",
"sd3",
"+=",
"sm",
";",
"sh",
"--",
";",
"#undef",
" BLENDPIXEL\r",
"\n",
"}",
"}",
"}"
] | mix & blend the paletted 16-bit tile and sprite bitmaps into an RGB 32-bit bitmap | [
"mix",
"&",
"blend",
"the",
"paletted",
"16",
"-",
"bit",
"tile",
"and",
"sprite",
"bitmaps",
"into",
"an",
"RGB",
"32",
"-",
"bit",
"bitmap"
] | [
"/* check bounds */",
"/* source data */",
"/* source width */",
"/* source height */",
"/* source modulo */",
"/* dest data */",
"/* dest modulo */"
] | [
{
"param": "machine",
"type": "running_machine"
},
{
"param": "dest",
"type": "bitmap_t"
},
{
"param": "src1",
"type": "bitmap_t"
},
{
"param": "src2",
"type": "bitmap_t"
},
{
"param": "src3",
"type": "bitmap_t"
},
{
"param": "sx",
"type": "int"
},
{
"param": "sy",
"type": "int"
},
{
"param": "clip",
"type": "rectangle"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "machine",
"type": "running_machine",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dest",
"type": "bitmap_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "src1",
"type": "bitmap_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "src2",
"type": "bitmap_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "src3",
"type": "bitmap_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sx",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sy",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "clip",
"type": "rectangle",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
77df33a0b4eb454a288e27afa3364923f9bf387e | lofunz/mieme | Reloaded/trunk/src/emu/sound/tms5110.c | [
"Unlicense"
] | C | FIFO_data_write | void | static void FIFO_data_write(tms5110_state *tms, int data)
{
/* add this bit to the FIFO */
if (tms->fifo_count < FIFO_SIZE)
{
tms->fifo[tms->fifo_tail] = (data&1); /* set bit to 1 or 0 */
tms->fifo_tail = (tms->fifo_tail + 1) % FIFO_SIZE;
tms->fifo_count++;
if (DEBUG_5110) logerror("Added bit to FIFO (size=%2d)\n", tms->fifo_count);
}
else
{
if (DEBUG_5110) logerror("Ran out of room in the FIFO!\n");
}
} | /******************************************************************************************
FIFO_data_write -- handle bit data write to the TMS5110 (as a result of toggling M0 pin)
******************************************************************************************/ | - handle bit data write to the TMS5110 (as a result of toggling M0 pin) | [
"-",
"handle",
"bit",
"data",
"write",
"to",
"the",
"TMS5110",
"(",
"as",
"a",
"result",
"of",
"toggling",
"M0",
"pin",
")"
] | static void FIFO_data_write(tms5110_state *tms, int data)
{
if (tms->fifo_count < FIFO_SIZE)
{
tms->fifo[tms->fifo_tail] = (data&1);
tms->fifo_tail = (tms->fifo_tail + 1) % FIFO_SIZE;
tms->fifo_count++;
if (DEBUG_5110) logerror("Added bit to FIFO (size=%2d)\n", tms->fifo_count);
}
else
{
if (DEBUG_5110) logerror("Ran out of room in the FIFO!\n");
}
} | [
"static",
"void",
"FIFO_data_write",
"(",
"tms5110_state",
"*",
"tms",
",",
"int",
"data",
")",
"{",
"if",
"(",
"tms",
"->",
"fifo_count",
"<",
"FIFO_SIZE",
")",
"{",
"tms",
"->",
"fifo",
"[",
"tms",
"->",
"fifo_tail",
"]",
"=",
"(",
"data",
"&",
"1",
")",
";",
"tms",
"->",
"fifo_tail",
"=",
"(",
"tms",
"->",
"fifo_tail",
"+",
"1",
")",
"%",
"FIFO_SIZE",
";",
"tms",
"->",
"fifo_count",
"++",
";",
"if",
"(",
"DEBUG_5110",
")",
"logerror",
"(",
"\"",
"\\n",
"\"",
",",
"tms",
"->",
"fifo_count",
")",
";",
"}",
"else",
"{",
"if",
"(",
"DEBUG_5110",
")",
"logerror",
"(",
"\"",
"\\n",
"\"",
")",
";",
"}",
"}"
] | FIFO_data_write -- handle bit data write to the TMS5110 (as a result of toggling M0 pin) | [
"FIFO_data_write",
"--",
"handle",
"bit",
"data",
"write",
"to",
"the",
"TMS5110",
"(",
"as",
"a",
"result",
"of",
"toggling",
"M0",
"pin",
")"
] | [
"/* add this bit to the FIFO */",
"/* set bit to 1 or 0 */"
] | [
{
"param": "tms",
"type": "tms5110_state"
},
{
"param": "data",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tms",
"type": "tms5110_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
77df33a0b4eb454a288e27afa3364923f9bf387e | lofunz/mieme | Reloaded/trunk/src/emu/sound/tms5110.c | [
"Unlicense"
] | C | extract_bits | int | static int extract_bits(tms5110_state *tms, int count)
{
int val = 0;
while (count--)
{
val = (val << 1) | (tms->fifo[tms->fifo_head] & 1);
tms->fifo_count--;
tms->fifo_head = (tms->fifo_head + 1) % FIFO_SIZE;
}
return val;
} | /******************************************************************************************
extract_bits -- extract a specific number of bits from the FIFO
******************************************************************************************/ | - extract a specific number of bits from the FIFO | [
"-",
"extract",
"a",
"specific",
"number",
"of",
"bits",
"from",
"the",
"FIFO"
] | static int extract_bits(tms5110_state *tms, int count)
{
int val = 0;
while (count--)
{
val = (val << 1) | (tms->fifo[tms->fifo_head] & 1);
tms->fifo_count--;
tms->fifo_head = (tms->fifo_head + 1) % FIFO_SIZE;
}
return val;
} | [
"static",
"int",
"extract_bits",
"(",
"tms5110_state",
"*",
"tms",
",",
"int",
"count",
")",
"{",
"int",
"val",
"=",
"0",
";",
"while",
"(",
"count",
"--",
")",
"{",
"val",
"=",
"(",
"val",
"<<",
"1",
")",
"|",
"(",
"tms",
"->",
"fifo",
"[",
"tms",
"->",
"fifo_head",
"]",
"&",
"1",
")",
";",
"tms",
"->",
"fifo_count",
"--",
";",
"tms",
"->",
"fifo_head",
"=",
"(",
"tms",
"->",
"fifo_head",
"+",
"1",
")",
"%",
"FIFO_SIZE",
";",
"}",
"return",
"val",
";",
"}"
] | extract_bits -- extract a specific number of bits from the FIFO | [
"extract_bits",
"--",
"extract",
"a",
"specific",
"number",
"of",
"bits",
"from",
"the",
"FIFO"
] | [] | [
{
"param": "tms",
"type": "tms5110_state"
},
{
"param": "count",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tms",
"type": "tms5110_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "count",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
77df33a0b4eb454a288e27afa3364923f9bf387e | lofunz/mieme | Reloaded/trunk/src/emu/sound/tms5110.c | [
"Unlicense"
] | C | tms5110_PDC_set | void | void tms5110_PDC_set(tms5110_state *tms, int data)
{
if (tms->PDC != (data & 0x1) )
{
tms->PDC = data & 0x1;
if (tms->PDC == 0) /* toggling 1->0 processes command on CTL_pins */
{
/* first pdc toggles output, next toggles input */
switch (tms->state)
{
case CTL_STATE_INPUT:
/* continue */
break;
case CTL_STATE_NEXT_OUTPUT:
tms->state = CTL_STATE_OUTPUT;
return;
case CTL_STATE_OUTPUT:
tms->state = CTL_STATE_INPUT;
return;
}
/* the only real commands we handle now are SPEAK and RESET */
if (tms->next_is_address)
{
tms->next_is_address = FALSE;
tms->address = tms->address | ((tms->CTL_pins & 0x0F)<<tms->addr_bit);
tms->addr_bit = (tms->addr_bit + 4) % 12;
tms->schedule_dummy_read = TRUE;
if (tms->set_load_address)
tms->set_load_address(tms->device, tms->address);
new_int_write_addr(tms, tms->CTL_pins & 0x0F);
}
else
{
switch (tms->CTL_pins & 0xe) /*CTL1 - don't care*/
{
case TMS5110_CMD_SPEAK:
perform_dummy_read(tms);
tms->speaking_now = 1;
//should FIFO be cleared now ?????
break;
case TMS5110_CMD_RESET:
perform_dummy_read(tms);
tms->device->reset();
break;
case TMS5110_CMD_READ_BIT:
if (tms->schedule_dummy_read)
perform_dummy_read(tms);
else
{
request_bits(tms, 1);
tms->CTL_pins = (tms->CTL_pins & 0x0E) | extract_bits(tms, 1);
}
break;
case TMS5110_CMD_LOAD_ADDRESS:
tms->next_is_address = TRUE;
break;
case TMS5110_CMD_READ_BRANCH:
new_int_write(tms, 0,1,1,0);
new_int_write(tms, 1,1,1,0);
new_int_write(tms, 0,1,1,0);
new_int_write(tms, 0,0,0,0);
new_int_write(tms, 1,0,0,0);
new_int_write(tms, 0,0,0,0);
tms->schedule_dummy_read = FALSE;
break;
case TMS5110_CMD_TEST_TALK:
tms->state = CTL_STATE_NEXT_OUTPUT;
break;
default:
logerror("tms5110.c: unknown command: 0x%02x\n", tms->CTL_pins);
break;
}
}
}
}
} | /******************************************************************************************
PDC_set -- set Processor Data Clock. Execute CTL_pins command on hi-lo transition.
******************************************************************************************/ | - set Processor Data Clock. Execute CTL_pins command on hi-lo transition. | [
"-",
"set",
"Processor",
"Data",
"Clock",
".",
"Execute",
"CTL_pins",
"command",
"on",
"hi",
"-",
"lo",
"transition",
"."
] | void tms5110_PDC_set(tms5110_state *tms, int data)
{
if (tms->PDC != (data & 0x1) )
{
tms->PDC = data & 0x1;
if (tms->PDC == 0)
{
switch (tms->state)
{
case CTL_STATE_INPUT:
break;
case CTL_STATE_NEXT_OUTPUT:
tms->state = CTL_STATE_OUTPUT;
return;
case CTL_STATE_OUTPUT:
tms->state = CTL_STATE_INPUT;
return;
}
if (tms->next_is_address)
{
tms->next_is_address = FALSE;
tms->address = tms->address | ((tms->CTL_pins & 0x0F)<<tms->addr_bit);
tms->addr_bit = (tms->addr_bit + 4) % 12;
tms->schedule_dummy_read = TRUE;
if (tms->set_load_address)
tms->set_load_address(tms->device, tms->address);
new_int_write_addr(tms, tms->CTL_pins & 0x0F);
}
else
{
switch (tms->CTL_pins & 0xe)
{
case TMS5110_CMD_SPEAK:
perform_dummy_read(tms);
tms->speaking_now = 1;
break;
case TMS5110_CMD_RESET:
perform_dummy_read(tms);
tms->device->reset();
break;
case TMS5110_CMD_READ_BIT:
if (tms->schedule_dummy_read)
perform_dummy_read(tms);
else
{
request_bits(tms, 1);
tms->CTL_pins = (tms->CTL_pins & 0x0E) | extract_bits(tms, 1);
}
break;
case TMS5110_CMD_LOAD_ADDRESS:
tms->next_is_address = TRUE;
break;
case TMS5110_CMD_READ_BRANCH:
new_int_write(tms, 0,1,1,0);
new_int_write(tms, 1,1,1,0);
new_int_write(tms, 0,1,1,0);
new_int_write(tms, 0,0,0,0);
new_int_write(tms, 1,0,0,0);
new_int_write(tms, 0,0,0,0);
tms->schedule_dummy_read = FALSE;
break;
case TMS5110_CMD_TEST_TALK:
tms->state = CTL_STATE_NEXT_OUTPUT;
break;
default:
logerror("tms5110.c: unknown command: 0x%02x\n", tms->CTL_pins);
break;
}
}
}
}
} | [
"void",
"tms5110_PDC_set",
"(",
"tms5110_state",
"*",
"tms",
",",
"int",
"data",
")",
"{",
"if",
"(",
"tms",
"->",
"PDC",
"!=",
"(",
"data",
"&",
"0x1",
")",
")",
"{",
"tms",
"->",
"PDC",
"=",
"data",
"&",
"0x1",
";",
"if",
"(",
"tms",
"->",
"PDC",
"==",
"0",
")",
"{",
"switch",
"(",
"tms",
"->",
"state",
")",
"{",
"case",
"CTL_STATE_INPUT",
":",
"break",
";",
"case",
"CTL_STATE_NEXT_OUTPUT",
":",
"tms",
"->",
"state",
"=",
"CTL_STATE_OUTPUT",
";",
"return",
";",
"case",
"CTL_STATE_OUTPUT",
":",
"tms",
"->",
"state",
"=",
"CTL_STATE_INPUT",
";",
"return",
";",
"}",
"if",
"(",
"tms",
"->",
"next_is_address",
")",
"{",
"tms",
"->",
"next_is_address",
"=",
"FALSE",
";",
"tms",
"->",
"address",
"=",
"tms",
"->",
"address",
"|",
"(",
"(",
"tms",
"->",
"CTL_pins",
"&",
"0x0F",
")",
"<<",
"tms",
"->",
"addr_bit",
")",
";",
"tms",
"->",
"addr_bit",
"=",
"(",
"tms",
"->",
"addr_bit",
"+",
"4",
")",
"%",
"12",
";",
"tms",
"->",
"schedule_dummy_read",
"=",
"TRUE",
";",
"if",
"(",
"tms",
"->",
"set_load_address",
")",
"tms",
"->",
"set_load_address",
"(",
"tms",
"->",
"device",
",",
"tms",
"->",
"address",
")",
";",
"new_int_write_addr",
"(",
"tms",
",",
"tms",
"->",
"CTL_pins",
"&",
"0x0F",
")",
";",
"}",
"else",
"{",
"switch",
"(",
"tms",
"->",
"CTL_pins",
"&",
"0xe",
")",
"{",
"case",
"TMS5110_CMD_SPEAK",
":",
"perform_dummy_read",
"(",
"tms",
")",
";",
"tms",
"->",
"speaking_now",
"=",
"1",
";",
"break",
";",
"case",
"TMS5110_CMD_RESET",
":",
"perform_dummy_read",
"(",
"tms",
")",
";",
"tms",
"->",
"device",
"->",
"reset",
"(",
")",
";",
"break",
";",
"case",
"TMS5110_CMD_READ_BIT",
":",
"if",
"(",
"tms",
"->",
"schedule_dummy_read",
")",
"perform_dummy_read",
"(",
"tms",
")",
";",
"else",
"{",
"request_bits",
"(",
"tms",
",",
"1",
")",
";",
"tms",
"->",
"CTL_pins",
"=",
"(",
"tms",
"->",
"CTL_pins",
"&",
"0x0E",
")",
"|",
"extract_bits",
"(",
"tms",
",",
"1",
")",
";",
"}",
"break",
";",
"case",
"TMS5110_CMD_LOAD_ADDRESS",
":",
"tms",
"->",
"next_is_address",
"=",
"TRUE",
";",
"break",
";",
"case",
"TMS5110_CMD_READ_BRANCH",
":",
"new_int_write",
"(",
"tms",
",",
"0",
",",
"1",
",",
"1",
",",
"0",
")",
";",
"new_int_write",
"(",
"tms",
",",
"1",
",",
"1",
",",
"1",
",",
"0",
")",
";",
"new_int_write",
"(",
"tms",
",",
"0",
",",
"1",
",",
"1",
",",
"0",
")",
";",
"new_int_write",
"(",
"tms",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
";",
"new_int_write",
"(",
"tms",
",",
"1",
",",
"0",
",",
"0",
",",
"0",
")",
";",
"new_int_write",
"(",
"tms",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
";",
"tms",
"->",
"schedule_dummy_read",
"=",
"FALSE",
";",
"break",
";",
"case",
"TMS5110_CMD_TEST_TALK",
":",
"tms",
"->",
"state",
"=",
"CTL_STATE_NEXT_OUTPUT",
";",
"break",
";",
"default",
":",
"logerror",
"(",
"\"",
"\\n",
"\"",
",",
"tms",
"->",
"CTL_pins",
")",
";",
"break",
";",
"}",
"}",
"}",
"}",
"}"
] | PDC_set -- set Processor Data Clock. | [
"PDC_set",
"--",
"set",
"Processor",
"Data",
"Clock",
"."
] | [
"/* toggling 1->0 processes command on CTL_pins */",
"/* first pdc toggles output, next toggles input */",
"/* continue */",
"/* the only real commands we handle now are SPEAK and RESET */",
"/*CTL1 - don't care*/",
"//should FIFO be cleared now ?????\r"
] | [
{
"param": "tms",
"type": "tms5110_state"
},
{
"param": "data",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tms",
"type": "tms5110_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
77df33a0b4eb454a288e27afa3364923f9bf387e | lofunz/mieme | Reloaded/trunk/src/emu/sound/tms5110.c | [
"Unlicense"
] | C | parse_frame | void | static void parse_frame(tms5110_state *tms)
{
int bits, indx, i, rep_flag;
#if (DEBUG_5110)
int ene;
#endif
/* count the total number of bits available */
bits = tms->fifo_count;
/* attempt to extract the energy index */
bits -= tms->coeff->energy_bits;
if (bits < 0)
{
request_bits( tms,-bits ); /* toggle M0 to receive needed bits */
bits = 0;
}
indx = extract_bits(tms,tms->coeff->energy_bits);
tms->new_energy = tms->coeff->energytable[indx];
#if (DEBUG_5110)
ene = indx;
#endif
/* if the energy index is 0 or 15, we're done */
if ((indx == 0) || (indx == 15))
{
if (DEBUG_5110) logerror(" (4-bit energy=%d frame)\n",tms->new_energy);
/* clear the k's */
if (indx == 0)
{
for (i = 0; i < tms->coeff->num_k; i++)
tms->new_k[i] = 0;
}
/* clear fifo if stop frame encountered */
if (indx == 15)
{
if (DEBUG_5110) logerror(" (4-bit energy=%d STOP frame)\n",tms->new_energy);
tms->fifo_head = tms->fifo_tail = tms->fifo_count = 0;
}
return;
}
/* attempt to extract the repeat flag */
bits -= 1;
if (bits < 0)
{
request_bits( tms,-bits ); /* toggle M0 to receive needed bits */
bits = 0;
}
rep_flag = extract_bits(tms,1);
/* attempt to extract the pitch */
bits -= tms->coeff->pitch_bits;
if (bits < 0)
{
request_bits( tms,-bits ); /* toggle M0 to receive needed bits */
bits = 0;
}
indx = extract_bits(tms,tms->coeff->pitch_bits);
tms->new_pitch = tms->coeff->pitchtable[indx];
/* if this is a repeat frame, just copy the k's */
if (rep_flag)
{
//actually, we do nothing because the k's were already loaded (on parsing the previous frame)
if (DEBUG_5110) logerror(" (10-bit energy=%d pitch=%d rep=%d frame)\n", tms->new_energy, tms->new_pitch, rep_flag);
return;
}
/* if the pitch index was zero, we need 4 k's */
if (indx == 0)
{
/* attempt to extract 4 K's */
bits -= 18;
if (bits < 0)
{
request_bits( tms,-bits ); /* toggle M0 to receive needed bits */
bits = 0;
}
for (i = 0; i < 4; i++)
tms->new_k[i] = tms->coeff->ktable[i][extract_bits(tms,tms->coeff->kbits[i])];
/* and clear the rest of the new_k[] */
for (i = 4; i < tms->coeff->num_k; i++)
tms->new_k[i] = 0;
if (DEBUG_5110) logerror(" (28-bit energy=%d pitch=%d rep=%d 4K frame)\n", tms->new_energy, tms->new_pitch, rep_flag);
return;
}
/* else we need 10 K's */
bits -= 39;
if (bits < 0)
{
request_bits( tms,-bits ); /* toggle M0 to receive needed bits */
bits = 0;
}
#if (DEBUG_5110)
printf("FrameDump %02d ", ene);
for (i = 0; i < tms->coeff->num_k; i++)
{
int x;
x = extract_bits(tms, tms->coeff->kbits[i]);
tms->new_k[i] = tms->coeff->ktable[i][x];
printf("%02d ", x);
}
printf("\n");
#else
for (i = 0; i < tms->coeff->num_k; i++)
{
int x;
x = extract_bits(tms, tms->coeff->kbits[i]);
tms->new_k[i] = tms->coeff->ktable[i][x];
}
#endif
if (DEBUG_5110) logerror(" (49-bit energy=%d pitch=%d rep=%d 10K frame)\n", tms->new_energy, tms->new_pitch, rep_flag);
} | /******************************************************************************************
parse_frame -- parse a new frame's worth of data; returns 0 if not enough bits in buffer
******************************************************************************************/ | - parse a new frame's worth of data; returns 0 if not enough bits in buffer | [
"-",
"parse",
"a",
"new",
"frame",
"'",
"s",
"worth",
"of",
"data",
";",
"returns",
"0",
"if",
"not",
"enough",
"bits",
"in",
"buffer"
] | static void parse_frame(tms5110_state *tms)
{
int bits, indx, i, rep_flag;
#if (DEBUG_5110)
int ene;
#endif
bits = tms->fifo_count;
bits -= tms->coeff->energy_bits;
if (bits < 0)
{
request_bits( tms,-bits );
bits = 0;
}
indx = extract_bits(tms,tms->coeff->energy_bits);
tms->new_energy = tms->coeff->energytable[indx];
#if (DEBUG_5110)
ene = indx;
#endif
if ((indx == 0) || (indx == 15))
{
if (DEBUG_5110) logerror(" (4-bit energy=%d frame)\n",tms->new_energy);
if (indx == 0)
{
for (i = 0; i < tms->coeff->num_k; i++)
tms->new_k[i] = 0;
}
if (indx == 15)
{
if (DEBUG_5110) logerror(" (4-bit energy=%d STOP frame)\n",tms->new_energy);
tms->fifo_head = tms->fifo_tail = tms->fifo_count = 0;
}
return;
}
bits -= 1;
if (bits < 0)
{
request_bits( tms,-bits );
bits = 0;
}
rep_flag = extract_bits(tms,1);
bits -= tms->coeff->pitch_bits;
if (bits < 0)
{
request_bits( tms,-bits );
bits = 0;
}
indx = extract_bits(tms,tms->coeff->pitch_bits);
tms->new_pitch = tms->coeff->pitchtable[indx];
if (rep_flag)
{
if (DEBUG_5110) logerror(" (10-bit energy=%d pitch=%d rep=%d frame)\n", tms->new_energy, tms->new_pitch, rep_flag);
return;
}
if (indx == 0)
{
bits -= 18;
if (bits < 0)
{
request_bits( tms,-bits );
bits = 0;
}
for (i = 0; i < 4; i++)
tms->new_k[i] = tms->coeff->ktable[i][extract_bits(tms,tms->coeff->kbits[i])];
for (i = 4; i < tms->coeff->num_k; i++)
tms->new_k[i] = 0;
if (DEBUG_5110) logerror(" (28-bit energy=%d pitch=%d rep=%d 4K frame)\n", tms->new_energy, tms->new_pitch, rep_flag);
return;
}
bits -= 39;
if (bits < 0)
{
request_bits( tms,-bits );
bits = 0;
}
#if (DEBUG_5110)
printf("FrameDump %02d ", ene);
for (i = 0; i < tms->coeff->num_k; i++)
{
int x;
x = extract_bits(tms, tms->coeff->kbits[i]);
tms->new_k[i] = tms->coeff->ktable[i][x];
printf("%02d ", x);
}
printf("\n");
#else
for (i = 0; i < tms->coeff->num_k; i++)
{
int x;
x = extract_bits(tms, tms->coeff->kbits[i]);
tms->new_k[i] = tms->coeff->ktable[i][x];
}
#endif
if (DEBUG_5110) logerror(" (49-bit energy=%d pitch=%d rep=%d 10K frame)\n", tms->new_energy, tms->new_pitch, rep_flag);
} | [
"static",
"void",
"parse_frame",
"(",
"tms5110_state",
"*",
"tms",
")",
"{",
"int",
"bits",
",",
"indx",
",",
"i",
",",
"rep_flag",
";",
"#if",
"(",
"DEBUG_5110",
")",
"\n",
"int",
"ene",
";",
"#endif",
"bits",
"=",
"tms",
"->",
"fifo_count",
";",
"bits",
"-=",
"tms",
"->",
"coeff",
"->",
"energy_bits",
";",
"if",
"(",
"bits",
"<",
"0",
")",
"{",
"request_bits",
"(",
"tms",
",",
"-",
"bits",
")",
";",
"bits",
"=",
"0",
";",
"}",
"indx",
"=",
"extract_bits",
"(",
"tms",
",",
"tms",
"->",
"coeff",
"->",
"energy_bits",
")",
";",
"tms",
"->",
"new_energy",
"=",
"tms",
"->",
"coeff",
"->",
"energytable",
"[",
"indx",
"]",
";",
"#if",
"(",
"DEBUG_5110",
")",
"\n",
"ene",
"=",
"indx",
";",
"#endif",
"if",
"(",
"(",
"indx",
"==",
"0",
")",
"||",
"(",
"indx",
"==",
"15",
")",
")",
"{",
"if",
"(",
"DEBUG_5110",
")",
"logerror",
"(",
"\"",
"\\n",
"\"",
",",
"tms",
"->",
"new_energy",
")",
";",
"if",
"(",
"indx",
"==",
"0",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"tms",
"->",
"coeff",
"->",
"num_k",
";",
"i",
"++",
")",
"tms",
"->",
"new_k",
"[",
"i",
"]",
"=",
"0",
";",
"}",
"if",
"(",
"indx",
"==",
"15",
")",
"{",
"if",
"(",
"DEBUG_5110",
")",
"logerror",
"(",
"\"",
"\\n",
"\"",
",",
"tms",
"->",
"new_energy",
")",
";",
"tms",
"->",
"fifo_head",
"=",
"tms",
"->",
"fifo_tail",
"=",
"tms",
"->",
"fifo_count",
"=",
"0",
";",
"}",
"return",
";",
"}",
"bits",
"-=",
"1",
";",
"if",
"(",
"bits",
"<",
"0",
")",
"{",
"request_bits",
"(",
"tms",
",",
"-",
"bits",
")",
";",
"bits",
"=",
"0",
";",
"}",
"rep_flag",
"=",
"extract_bits",
"(",
"tms",
",",
"1",
")",
";",
"bits",
"-=",
"tms",
"->",
"coeff",
"->",
"pitch_bits",
";",
"if",
"(",
"bits",
"<",
"0",
")",
"{",
"request_bits",
"(",
"tms",
",",
"-",
"bits",
")",
";",
"bits",
"=",
"0",
";",
"}",
"indx",
"=",
"extract_bits",
"(",
"tms",
",",
"tms",
"->",
"coeff",
"->",
"pitch_bits",
")",
";",
"tms",
"->",
"new_pitch",
"=",
"tms",
"->",
"coeff",
"->",
"pitchtable",
"[",
"indx",
"]",
";",
"if",
"(",
"rep_flag",
")",
"{",
"if",
"(",
"DEBUG_5110",
")",
"logerror",
"(",
"\"",
"\\n",
"\"",
",",
"tms",
"->",
"new_energy",
",",
"tms",
"->",
"new_pitch",
",",
"rep_flag",
")",
";",
"return",
";",
"}",
"if",
"(",
"indx",
"==",
"0",
")",
"{",
"bits",
"-=",
"18",
";",
"if",
"(",
"bits",
"<",
"0",
")",
"{",
"request_bits",
"(",
"tms",
",",
"-",
"bits",
")",
";",
"bits",
"=",
"0",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"4",
";",
"i",
"++",
")",
"tms",
"->",
"new_k",
"[",
"i",
"]",
"=",
"tms",
"->",
"coeff",
"->",
"ktable",
"[",
"i",
"]",
"[",
"extract_bits",
"(",
"tms",
",",
"tms",
"->",
"coeff",
"->",
"kbits",
"[",
"i",
"]",
")",
"]",
";",
"for",
"(",
"i",
"=",
"4",
";",
"i",
"<",
"tms",
"->",
"coeff",
"->",
"num_k",
";",
"i",
"++",
")",
"tms",
"->",
"new_k",
"[",
"i",
"]",
"=",
"0",
";",
"if",
"(",
"DEBUG_5110",
")",
"logerror",
"(",
"\"",
"\\n",
"\"",
",",
"tms",
"->",
"new_energy",
",",
"tms",
"->",
"new_pitch",
",",
"rep_flag",
")",
";",
"return",
";",
"}",
"bits",
"-=",
"39",
";",
"if",
"(",
"bits",
"<",
"0",
")",
"{",
"request_bits",
"(",
"tms",
",",
"-",
"bits",
")",
";",
"bits",
"=",
"0",
";",
"}",
"#if",
"(",
"DEBUG_5110",
")",
"\n",
"printf",
"(",
"\"",
"\"",
",",
"ene",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"tms",
"->",
"coeff",
"->",
"num_k",
";",
"i",
"++",
")",
"{",
"int",
"x",
";",
"x",
"=",
"extract_bits",
"(",
"tms",
",",
"tms",
"->",
"coeff",
"->",
"kbits",
"[",
"i",
"]",
")",
";",
"tms",
"->",
"new_k",
"[",
"i",
"]",
"=",
"tms",
"->",
"coeff",
"->",
"ktable",
"[",
"i",
"]",
"[",
"x",
"]",
";",
"printf",
"(",
"\"",
"\"",
",",
"x",
")",
";",
"}",
"printf",
"(",
"\"",
"\\n",
"\"",
")",
";",
"#else",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"tms",
"->",
"coeff",
"->",
"num_k",
";",
"i",
"++",
")",
"{",
"int",
"x",
";",
"x",
"=",
"extract_bits",
"(",
"tms",
",",
"tms",
"->",
"coeff",
"->",
"kbits",
"[",
"i",
"]",
")",
";",
"tms",
"->",
"new_k",
"[",
"i",
"]",
"=",
"tms",
"->",
"coeff",
"->",
"ktable",
"[",
"i",
"]",
"[",
"x",
"]",
";",
"}",
"#endif",
"if",
"(",
"DEBUG_5110",
")",
"logerror",
"(",
"\"",
"\\n",
"\"",
",",
"tms",
"->",
"new_energy",
",",
"tms",
"->",
"new_pitch",
",",
"rep_flag",
")",
";",
"}"
] | parse_frame -- parse a new frame's worth of data; returns 0 if not enough bits in buffer | [
"parse_frame",
"--",
"parse",
"a",
"new",
"frame",
"'",
"s",
"worth",
"of",
"data",
";",
"returns",
"0",
"if",
"not",
"enough",
"bits",
"in",
"buffer"
] | [
"/* count the total number of bits available */",
"/* attempt to extract the energy index */",
"/* toggle M0 to receive needed bits */",
"/* if the energy index is 0 or 15, we're done */",
"/* clear the k's */",
"/* clear fifo if stop frame encountered */",
"/* attempt to extract the repeat flag */",
"/* toggle M0 to receive needed bits */",
"/* attempt to extract the pitch */",
"/* toggle M0 to receive needed bits */",
"/* if this is a repeat frame, just copy the k's */",
"//actually, we do nothing because the k's were already loaded (on parsing the previous frame)\r",
"/* if the pitch index was zero, we need 4 k's */",
"/* attempt to extract 4 K's */",
"/* toggle M0 to receive needed bits */",
"/* and clear the rest of the new_k[] */",
"/* else we need 10 K's */",
"/* toggle M0 to receive needed bits */"
] | [
{
"param": "tms",
"type": "tms5110_state"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tms",
"type": "tms5110_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
77df33a0b4eb454a288e27afa3364923f9bf387e | lofunz/mieme | Reloaded/trunk/src/emu/sound/tms5110.c | [
"Unlicense"
] | C | tms5110_ready_r | int | int tms5110_ready_r(running_device *device)
{
tms5110_state *tms = get_safe_token(device);
/* bring up to date first */
stream_update(tms->stream);
return (tms->fifo_count < FIFO_SIZE-1);
} | /******************************************************************************
tms5110_ready_r -- return the not ready status from the sound chip
******************************************************************************/ | - return the not ready status from the sound chip | [
"-",
"return",
"the",
"not",
"ready",
"status",
"from",
"the",
"sound",
"chip"
] | int tms5110_ready_r(running_device *device)
{
tms5110_state *tms = get_safe_token(device);
stream_update(tms->stream);
return (tms->fifo_count < FIFO_SIZE-1);
} | [
"int",
"tms5110_ready_r",
"(",
"running_device",
"*",
"device",
")",
"{",
"tms5110_state",
"*",
"tms",
"=",
"get_safe_token",
"(",
"device",
")",
";",
"stream_update",
"(",
"tms",
"->",
"stream",
")",
";",
"return",
"(",
"tms",
"->",
"fifo_count",
"<",
"FIFO_SIZE",
"-",
"1",
")",
";",
"}"
] | tms5110_ready_r -- return the not ready status from the sound chip | [
"tms5110_ready_r",
"--",
"return",
"the",
"not",
"ready",
"status",
"from",
"the",
"sound",
"chip"
] | [
"/* bring up to date first */"
] | [
{
"param": "device",
"type": "running_device"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "device",
"type": "running_device",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6edb324ad45ca219ceb20b53b93d9dce47c16cd9 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/video/astrocde.c | [
"Unlicense"
] | C | init_sparklestar | void | static void init_sparklestar(running_machine *machine)
{
UINT32 shiftreg;
int i;
/* reset global sparkle state */
astrocade_sparkle[0] = astrocade_sparkle[1] = astrocade_sparkle[2] = astrocade_sparkle[3] = 0;
/* allocate memory for the sparkle/star array */
sparklestar = auto_alloc_array(machine, UINT8, RNG_PERIOD);
/* generate the data for the sparkle/star array */
for (shiftreg = i = 0; i < RNG_PERIOD; i++)
{
UINT8 newbit;
/* clock the shift register */
newbit = ((shiftreg >> 12) ^ ~shiftreg) & 1;
shiftreg = (shiftreg >> 1) | (newbit << 16);
/* extract the sparkle/star intensity here */
/* this is controlled by the shift register at U17/U19/U18 */
sparklestar[i] = (((shiftreg >> 4) & 1) << 3) |
(((shiftreg >> 12) & 1) << 2) |
(((shiftreg >> 16) & 1) << 1) |
(((shiftreg >> 8) & 1) << 0);
/* determine the star enable here */
/* this is controlled by the shift register at U17/U12/U11 */
if ((shiftreg & 0xff) == 0xfe)
sparklestar[i] |= 0x10;
}
} | /*
Counters at U15/U16:
On VERTDR, load 0x33 into counters at U15/U16
On HORZDR, clock counters, stopping at overflow to 0x00 (prevents sparkle in VBLANK)
Shift registers at U17/U12/U11:
cleared on vertdr
clocked at 7M (pixel clock)
taps from bit 4, 8, 12, 16 control sparkle intensity
Shift registers at U17/U19/U18:
cleared on reset
clocked at 7M (pixel clock)
if bits 0-7 == 0xfe, a star is generated
Both shift registers are the same with identical feedback.
We use one array to hold both shift registers. Bits 0-3
bits hold the intensity, and bit 4 holds whether or not
a star is present.
We must use independent lookups for each case. For the star
lookup, we need to compute the pixel index relative to the
end of VBLANK and use that (which at 455*262 is guaranteed
to be less than RNG_PERIOD).
For the sparkle lookup, we need to compute the pixel index
relative to the beginning of time and use that, mod RNG_PERIOD.
*/ | Counters at U15/U16:
On VERTDR, load 0x33 into counters at U15/U16
On HORZDR, clock counters, stopping at overflow to 0x00 (prevents sparkle in VBLANK)
Shift registers at U17/U12/U11:
cleared on vertdr
clocked at 7M (pixel clock)
taps from bit 4, 8, 12, 16 control sparkle intensity
Shift registers at U17/U19/U18:
cleared on reset
clocked at 7M (pixel clock)
if bits 0-7 == 0xfe, a star is generated
Both shift registers are the same with identical feedback.
We use one array to hold both shift registers. Bits 0-3
bits hold the intensity, and bit 4 holds whether or not
a star is present.
We must use independent lookups for each case. For the star
lookup, we need to compute the pixel index relative to the
end of VBLANK and use that (which at 455*262 is guaranteed
to be less than RNG_PERIOD).
For the sparkle lookup, we need to compute the pixel index
relative to the beginning of time and use that, mod RNG_PERIOD. | [
"Counters",
"at",
"U15",
"/",
"U16",
":",
"On",
"VERTDR",
"load",
"0x33",
"into",
"counters",
"at",
"U15",
"/",
"U16",
"On",
"HORZDR",
"clock",
"counters",
"stopping",
"at",
"overflow",
"to",
"0x00",
"(",
"prevents",
"sparkle",
"in",
"VBLANK",
")",
"Shift",
"registers",
"at",
"U17",
"/",
"U12",
"/",
"U11",
":",
"cleared",
"on",
"vertdr",
"clocked",
"at",
"7M",
"(",
"pixel",
"clock",
")",
"taps",
"from",
"bit",
"4",
"8",
"12",
"16",
"control",
"sparkle",
"intensity",
"Shift",
"registers",
"at",
"U17",
"/",
"U19",
"/",
"U18",
":",
"cleared",
"on",
"reset",
"clocked",
"at",
"7M",
"(",
"pixel",
"clock",
")",
"if",
"bits",
"0",
"-",
"7",
"==",
"0xfe",
"a",
"star",
"is",
"generated",
"Both",
"shift",
"registers",
"are",
"the",
"same",
"with",
"identical",
"feedback",
".",
"We",
"use",
"one",
"array",
"to",
"hold",
"both",
"shift",
"registers",
".",
"Bits",
"0",
"-",
"3",
"bits",
"hold",
"the",
"intensity",
"and",
"bit",
"4",
"holds",
"whether",
"or",
"not",
"a",
"star",
"is",
"present",
".",
"We",
"must",
"use",
"independent",
"lookups",
"for",
"each",
"case",
".",
"For",
"the",
"star",
"lookup",
"we",
"need",
"to",
"compute",
"the",
"pixel",
"index",
"relative",
"to",
"the",
"end",
"of",
"VBLANK",
"and",
"use",
"that",
"(",
"which",
"at",
"455",
"*",
"262",
"is",
"guaranteed",
"to",
"be",
"less",
"than",
"RNG_PERIOD",
")",
".",
"For",
"the",
"sparkle",
"lookup",
"we",
"need",
"to",
"compute",
"the",
"pixel",
"index",
"relative",
"to",
"the",
"beginning",
"of",
"time",
"and",
"use",
"that",
"mod",
"RNG_PERIOD",
"."
] | static void init_sparklestar(running_machine *machine)
{
UINT32 shiftreg;
int i;
astrocade_sparkle[0] = astrocade_sparkle[1] = astrocade_sparkle[2] = astrocade_sparkle[3] = 0;
sparklestar = auto_alloc_array(machine, UINT8, RNG_PERIOD);
for (shiftreg = i = 0; i < RNG_PERIOD; i++)
{
UINT8 newbit;
newbit = ((shiftreg >> 12) ^ ~shiftreg) & 1;
shiftreg = (shiftreg >> 1) | (newbit << 16);
sparklestar[i] = (((shiftreg >> 4) & 1) << 3) |
(((shiftreg >> 12) & 1) << 2) |
(((shiftreg >> 16) & 1) << 1) |
(((shiftreg >> 8) & 1) << 0);
if ((shiftreg & 0xff) == 0xfe)
sparklestar[i] |= 0x10;
}
} | [
"static",
"void",
"init_sparklestar",
"(",
"running_machine",
"*",
"machine",
")",
"{",
"UINT32",
"shiftreg",
";",
"int",
"i",
";",
"astrocade_sparkle",
"[",
"0",
"]",
"=",
"astrocade_sparkle",
"[",
"1",
"]",
"=",
"astrocade_sparkle",
"[",
"2",
"]",
"=",
"astrocade_sparkle",
"[",
"3",
"]",
"=",
"0",
";",
"sparklestar",
"=",
"auto_alloc_array",
"(",
"machine",
",",
"UINT8",
",",
"RNG_PERIOD",
")",
";",
"for",
"(",
"shiftreg",
"=",
"i",
"=",
"0",
";",
"i",
"<",
"RNG_PERIOD",
";",
"i",
"++",
")",
"{",
"UINT8",
"newbit",
";",
"newbit",
"=",
"(",
"(",
"shiftreg",
">>",
"12",
")",
"^",
"~",
"shiftreg",
")",
"&",
"1",
";",
"shiftreg",
"=",
"(",
"shiftreg",
">>",
"1",
")",
"|",
"(",
"newbit",
"<<",
"16",
")",
";",
"sparklestar",
"[",
"i",
"]",
"=",
"(",
"(",
"(",
"shiftreg",
">>",
"4",
")",
"&",
"1",
")",
"<<",
"3",
")",
"|",
"(",
"(",
"(",
"shiftreg",
">>",
"12",
")",
"&",
"1",
")",
"<<",
"2",
")",
"|",
"(",
"(",
"(",
"shiftreg",
">>",
"16",
")",
"&",
"1",
")",
"<<",
"1",
")",
"|",
"(",
"(",
"(",
"shiftreg",
">>",
"8",
")",
"&",
"1",
")",
"<<",
"0",
")",
";",
"if",
"(",
"(",
"shiftreg",
"&",
"0xff",
")",
"==",
"0xfe",
")",
"sparklestar",
"[",
"i",
"]",
"|=",
"0x10",
";",
"}",
"}"
] | Counters at U15/U16:
On VERTDR, load 0x33 into counters at U15/U16
On HORZDR, clock counters, stopping at overflow to 0x00 (prevents sparkle in VBLANK) | [
"Counters",
"at",
"U15",
"/",
"U16",
":",
"On",
"VERTDR",
"load",
"0x33",
"into",
"counters",
"at",
"U15",
"/",
"U16",
"On",
"HORZDR",
"clock",
"counters",
"stopping",
"at",
"overflow",
"to",
"0x00",
"(",
"prevents",
"sparkle",
"in",
"VBLANK",
")"
] | [
"/* reset global sparkle state */",
"/* allocate memory for the sparkle/star array */",
"/* generate the data for the sparkle/star array */",
"/* clock the shift register */",
"/* extract the sparkle/star intensity here */",
"/* this is controlled by the shift register at U17/U19/U18 */",
"/* determine the star enable here */",
"/* this is controlled by the shift register at U17/U12/U11 */"
] | [
{
"param": "machine",
"type": "running_machine"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "machine",
"type": "running_machine",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
77fb4e7285076f9df179515a0fb7986141320327 | lofunz/mieme | Reloaded/trunk/src/mame/video/silkroad.c | [
"Unlicense"
] | C | draw_sprites | void | static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{
silkroad_state *state = machine->driver_data<silkroad_state>();
const gfx_element *gfx = machine->gfx[0];
UINT32 *source = state->sprram;
UINT32 *finish = source + 0x1000/4;
while( source < finish )
{
int xpos = (source[0] & 0x01ff0000) >> 16;
int ypos = (source[0] & 0x0000ffff);
int tileno = (source[1] & 0xffff0000) >> 16;
int attr = (source[1] & 0x0000ffff);
int flipx = (attr & 0x0080);
int width = ((attr & 0x0f00) >> 8) + 1;
int wcount;
int color = (attr & 0x003f) ;
int pri = ((attr & 0x1000)>>12); // Priority (1 = Low)
int pri_mask = ~((1 << (pri+1)) - 1); // Above the first "pri" levels
// attr & 0x2000 -> another priority bit?
if ( (source[1] & 0xff00) == 0xff00 ) break;
if ( (attr & 0x8000) == 0x8000 ) tileno+=0x10000;
if (!flipx)
{
for (wcount=0;wcount<width;wcount++)
{
pdrawgfx_transpen(bitmap,cliprect,gfx,tileno+wcount,color,0,0,xpos+wcount*16+8,ypos,machine->priority_bitmap,pri_mask,0);
}
}
else
{
for (wcount=width;wcount>0;wcount--)
{
pdrawgfx_transpen(bitmap,cliprect,gfx,tileno+(width-wcount),color,1,0,xpos+wcount*16-16+8,ypos,machine->priority_bitmap,pri_mask,0);
}
}
source += 2;
}
} | /* Sprites probably need to be delayed */
/* Some scroll layers may need to be offset slightly? */
/* Check Sprite Colours after redump */
/* Clean Up */
/* is theres a bg colour register? */ | Sprites probably need to be delayed
Some scroll layers may need to be offset slightly. | [
"Sprites",
"probably",
"need",
"to",
"be",
"delayed",
"Some",
"scroll",
"layers",
"may",
"need",
"to",
"be",
"offset",
"slightly",
"."
] | static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{
silkroad_state *state = machine->driver_data<silkroad_state>();
const gfx_element *gfx = machine->gfx[0];
UINT32 *source = state->sprram;
UINT32 *finish = source + 0x1000/4;
while( source < finish )
{
int xpos = (source[0] & 0x01ff0000) >> 16;
int ypos = (source[0] & 0x0000ffff);
int tileno = (source[1] & 0xffff0000) >> 16;
int attr = (source[1] & 0x0000ffff);
int flipx = (attr & 0x0080);
int width = ((attr & 0x0f00) >> 8) + 1;
int wcount;
int color = (attr & 0x003f) ;
int pri = ((attr & 0x1000)>>12);
int pri_mask = ~((1 << (pri+1)) - 1);
if ( (source[1] & 0xff00) == 0xff00 ) break;
if ( (attr & 0x8000) == 0x8000 ) tileno+=0x10000;
if (!flipx)
{
for (wcount=0;wcount<width;wcount++)
{
pdrawgfx_transpen(bitmap,cliprect,gfx,tileno+wcount,color,0,0,xpos+wcount*16+8,ypos,machine->priority_bitmap,pri_mask,0);
}
}
else
{
for (wcount=width;wcount>0;wcount--)
{
pdrawgfx_transpen(bitmap,cliprect,gfx,tileno+(width-wcount),color,1,0,xpos+wcount*16-16+8,ypos,machine->priority_bitmap,pri_mask,0);
}
}
source += 2;
}
} | [
"static",
"void",
"draw_sprites",
"(",
"running_machine",
"*",
"machine",
",",
"bitmap_t",
"*",
"bitmap",
",",
"const",
"rectangle",
"*",
"cliprect",
")",
"{",
"silkroad_state",
"*",
"state",
"=",
"machine",
"->",
"driver_data",
"<",
"silkroad_state",
">",
"(",
"",
")",
";",
"const",
"gfx_element",
"*",
"gfx",
"=",
"machine",
"->",
"gfx",
"[",
"0",
"]",
";",
"UINT32",
"*",
"source",
"=",
"state",
"->",
"sprram",
";",
"UINT32",
"*",
"finish",
"=",
"source",
"+",
"0x1000",
"/",
"4",
";",
"while",
"(",
"source",
"<",
"finish",
")",
"{",
"int",
"xpos",
"=",
"(",
"source",
"[",
"0",
"]",
"&",
"0x01ff0000",
")",
">>",
"16",
";",
"int",
"ypos",
"=",
"(",
"source",
"[",
"0",
"]",
"&",
"0x0000ffff",
")",
";",
"int",
"tileno",
"=",
"(",
"source",
"[",
"1",
"]",
"&",
"0xffff0000",
")",
">>",
"16",
";",
"int",
"attr",
"=",
"(",
"source",
"[",
"1",
"]",
"&",
"0x0000ffff",
")",
";",
"int",
"flipx",
"=",
"(",
"attr",
"&",
"0x0080",
")",
";",
"int",
"width",
"=",
"(",
"(",
"attr",
"&",
"0x0f00",
")",
">>",
"8",
")",
"+",
"1",
";",
"int",
"wcount",
";",
"int",
"color",
"=",
"(",
"attr",
"&",
"0x003f",
")",
";",
"int",
"pri",
"=",
"(",
"(",
"attr",
"&",
"0x1000",
")",
">>",
"12",
")",
";",
"int",
"pri_mask",
"=",
"~",
"(",
"(",
"1",
"<<",
"(",
"pri",
"+",
"1",
")",
")",
"-",
"1",
")",
";",
"if",
"(",
"(",
"source",
"[",
"1",
"]",
"&",
"0xff00",
")",
"==",
"0xff00",
")",
"break",
";",
"if",
"(",
"(",
"attr",
"&",
"0x8000",
")",
"==",
"0x8000",
")",
"tileno",
"+=",
"0x10000",
";",
"if",
"(",
"!",
"flipx",
")",
"{",
"for",
"(",
"wcount",
"=",
"0",
";",
"wcount",
"<",
"width",
";",
"wcount",
"++",
")",
"{",
"pdrawgfx_transpen",
"(",
"bitmap",
",",
"cliprect",
",",
"gfx",
",",
"tileno",
"+",
"wcount",
",",
"color",
",",
"0",
",",
"0",
",",
"xpos",
"+",
"wcount",
"*",
"16",
"+",
"8",
",",
"ypos",
",",
"machine",
"->",
"priority_bitmap",
",",
"pri_mask",
",",
"0",
")",
";",
"}",
"}",
"else",
"{",
"for",
"(",
"wcount",
"=",
"width",
";",
"wcount",
">",
"0",
";",
"wcount",
"--",
")",
"{",
"pdrawgfx_transpen",
"(",
"bitmap",
",",
"cliprect",
",",
"gfx",
",",
"tileno",
"+",
"(",
"width",
"-",
"wcount",
")",
",",
"color",
",",
"1",
",",
"0",
",",
"xpos",
"+",
"wcount",
"*",
"16",
"-",
"16",
"+",
"8",
",",
"ypos",
",",
"machine",
"->",
"priority_bitmap",
",",
"pri_mask",
",",
"0",
")",
";",
"}",
"}",
"source",
"+=",
"2",
";",
"}",
"}"
] | Sprites probably need to be delayed
Some scroll layers may need to be offset slightly? | [
"Sprites",
"probably",
"need",
"to",
"be",
"delayed",
"Some",
"scroll",
"layers",
"may",
"need",
"to",
"be",
"offset",
"slightly?"
] | [
"// Priority (1 = Low)\r",
"// Above the first \"pri\" levels\r",
"// attr & 0x2000 -> another priority bit?\r"
] | [
{
"param": "machine",
"type": "running_machine"
},
{
"param": "bitmap",
"type": "bitmap_t"
},
{
"param": "cliprect",
"type": "rectangle"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "machine",
"type": "running_machine",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bitmap",
"type": "bitmap_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cliprect",
"type": "rectangle",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ea4899ef3f7ca1cdd95923792e0bcda9468b9526 | lofunz/mieme | Reloaded/trunk/src/mame/video/kchamp.c | [
"Unlicense"
] | C | kchamp_draw_sprites | void | static void kchamp_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{
kchamp_state *state = machine->driver_data<kchamp_state>();
UINT8 *spriteram = state->spriteram;
int offs;
for (offs = 0; offs < 0x100; offs += 4)
{
int attr = spriteram[offs + 2];
int bank = 1 + ((attr & 0x60) >> 5);
int code = spriteram[offs + 1] + ((attr & 0x10) << 4);
int color = attr & 0x0f;
int flipx = 0;
int flipy = attr & 0x80;
int sx = spriteram[offs + 3] - 8;
int sy = 247 - spriteram[offs];
if (flip_screen_get(machine))
{
sx = 240 - sx;
sy = 240 - sy;
flipx = !flipx;
flipy = !flipy;
}
drawgfx_transpen(bitmap, cliprect, machine->gfx[bank], code, color, flipx, flipy, sx, sy, 0);
}
} | /*
Sprites
-------
Offset Encoding
0 YYYYYYYY
1 TTTTTTTT
2 FGGTCCCC
3 XXXXXXXX
*/ | Sprites
Offset Encoding
0 YYYYYYYY
1 TTTTTTTT
2 FGGTCCCC
3 XXXXXXXX | [
"Sprites",
"Offset",
"Encoding",
"0",
"YYYYYYYY",
"1",
"TTTTTTTT",
"2",
"FGGTCCCC",
"3",
"XXXXXXXX"
] | static void kchamp_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{
kchamp_state *state = machine->driver_data<kchamp_state>();
UINT8 *spriteram = state->spriteram;
int offs;
for (offs = 0; offs < 0x100; offs += 4)
{
int attr = spriteram[offs + 2];
int bank = 1 + ((attr & 0x60) >> 5);
int code = spriteram[offs + 1] + ((attr & 0x10) << 4);
int color = attr & 0x0f;
int flipx = 0;
int flipy = attr & 0x80;
int sx = spriteram[offs + 3] - 8;
int sy = 247 - spriteram[offs];
if (flip_screen_get(machine))
{
sx = 240 - sx;
sy = 240 - sy;
flipx = !flipx;
flipy = !flipy;
}
drawgfx_transpen(bitmap, cliprect, machine->gfx[bank], code, color, flipx, flipy, sx, sy, 0);
}
} | [
"static",
"void",
"kchamp_draw_sprites",
"(",
"running_machine",
"*",
"machine",
",",
"bitmap_t",
"*",
"bitmap",
",",
"const",
"rectangle",
"*",
"cliprect",
")",
"{",
"kchamp_state",
"*",
"state",
"=",
"machine",
"->",
"driver_data",
"<",
"kchamp_state",
">",
"(",
"",
")",
";",
"UINT8",
"*",
"spriteram",
"=",
"state",
"->",
"spriteram",
";",
"int",
"offs",
";",
"for",
"(",
"offs",
"=",
"0",
";",
"offs",
"<",
"0x100",
";",
"offs",
"+=",
"4",
")",
"{",
"int",
"attr",
"=",
"spriteram",
"[",
"offs",
"+",
"2",
"]",
";",
"int",
"bank",
"=",
"1",
"+",
"(",
"(",
"attr",
"&",
"0x60",
")",
">>",
"5",
")",
";",
"int",
"code",
"=",
"spriteram",
"[",
"offs",
"+",
"1",
"]",
"+",
"(",
"(",
"attr",
"&",
"0x10",
")",
"<<",
"4",
")",
";",
"int",
"color",
"=",
"attr",
"&",
"0x0f",
";",
"int",
"flipx",
"=",
"0",
";",
"int",
"flipy",
"=",
"attr",
"&",
"0x80",
";",
"int",
"sx",
"=",
"spriteram",
"[",
"offs",
"+",
"3",
"]",
"-",
"8",
";",
"int",
"sy",
"=",
"247",
"-",
"spriteram",
"[",
"offs",
"]",
";",
"if",
"(",
"flip_screen_get",
"(",
"machine",
")",
")",
"{",
"sx",
"=",
"240",
"-",
"sx",
";",
"sy",
"=",
"240",
"-",
"sy",
";",
"flipx",
"=",
"!",
"flipx",
";",
"flipy",
"=",
"!",
"flipy",
";",
"}",
"drawgfx_transpen",
"(",
"bitmap",
",",
"cliprect",
",",
"machine",
"->",
"gfx",
"[",
"bank",
"]",
",",
"code",
",",
"color",
",",
"flipx",
",",
"flipy",
",",
"sx",
",",
"sy",
",",
"0",
")",
";",
"}",
"}"
] | Sprites | [
"Sprites"
] | [] | [
{
"param": "machine",
"type": "running_machine"
},
{
"param": "bitmap",
"type": "bitmap_t"
},
{
"param": "cliprect",
"type": "rectangle"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "machine",
"type": "running_machine",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bitmap",
"type": "bitmap_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cliprect",
"type": "rectangle",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d835fd6445aba612019120fc378673b23aba8150 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/chdman.c | [
"Unlicense"
] | C | print_big_int | void | static void print_big_int(UINT64 intvalue, char *output)
{
int chunk;
chunk = intvalue % 1000;
intvalue /= 1000;
if (intvalue != 0)
{
print_big_int(intvalue, output);
strcat(output, ",");
sprintf(&output[strlen(output)], "%03d", chunk);
}
else
sprintf(&output[strlen(output)], "%d", chunk);
} | /*-------------------------------------------------
print_big_int - 64-bit int printing with
commas
-------------------------------------------------*/ | 64-bit int printing with
commas | [
"64",
"-",
"bit",
"int",
"printing",
"with",
"commas"
] | static void print_big_int(UINT64 intvalue, char *output)
{
int chunk;
chunk = intvalue % 1000;
intvalue /= 1000;
if (intvalue != 0)
{
print_big_int(intvalue, output);
strcat(output, ",");
sprintf(&output[strlen(output)], "%03d", chunk);
}
else
sprintf(&output[strlen(output)], "%d", chunk);
} | [
"static",
"void",
"print_big_int",
"(",
"UINT64",
"intvalue",
",",
"char",
"*",
"output",
")",
"{",
"int",
"chunk",
";",
"chunk",
"=",
"intvalue",
"%",
"1000",
";",
"intvalue",
"/=",
"1000",
";",
"if",
"(",
"intvalue",
"!=",
"0",
")",
"{",
"print_big_int",
"(",
"intvalue",
",",
"output",
")",
";",
"strcat",
"(",
"output",
",",
"\"",
"\"",
")",
";",
"sprintf",
"(",
"&",
"output",
"[",
"strlen",
"(",
"output",
")",
"]",
",",
"\"",
"\"",
",",
"chunk",
")",
";",
"}",
"else",
"sprintf",
"(",
"&",
"output",
"[",
"strlen",
"(",
"output",
")",
"]",
",",
"\"",
"\"",
",",
"chunk",
")",
";",
"}"
] | print_big_int - 64-bit int printing with
commas | [
"print_big_int",
"-",
"64",
"-",
"bit",
"int",
"printing",
"with",
"commas"
] | [] | [
{
"param": "intvalue",
"type": "UINT64"
},
{
"param": "output",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "intvalue",
"type": "UINT64",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "output",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d835fd6445aba612019120fc378673b23aba8150 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/chdman.c | [
"Unlicense"
] | C | big_int_string | char | static char *big_int_string(UINT64 intvalue)
{
static char buffer[256];
buffer[0] = 0;
print_big_int(intvalue, buffer);
return buffer;
} | /*-------------------------------------------------
big_int_string - return a string for a big
integer
-------------------------------------------------*/ | return a string for a big
integer | [
"return",
"a",
"string",
"for",
"a",
"big",
"integer"
] | static char *big_int_string(UINT64 intvalue)
{
static char buffer[256];
buffer[0] = 0;
print_big_int(intvalue, buffer);
return buffer;
} | [
"static",
"char",
"*",
"big_int_string",
"(",
"UINT64",
"intvalue",
")",
"{",
"static",
"char",
"buffer",
"[",
"256",
"]",
";",
"buffer",
"[",
"0",
"]",
"=",
"0",
";",
"print_big_int",
"(",
"intvalue",
",",
"buffer",
")",
";",
"return",
"buffer",
";",
"}"
] | big_int_string - return a string for a big
integer | [
"big_int_string",
"-",
"return",
"a",
"string",
"for",
"a",
"big",
"integer"
] | [] | [
{
"param": "intvalue",
"type": "UINT64"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "intvalue",
"type": "UINT64",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d835fd6445aba612019120fc378673b23aba8150 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/chdman.c | [
"Unlicense"
] | C | guess_chs | chd_error | static chd_error guess_chs(const char *filename, int offset, int sectorsize, UINT32 *cylinders, UINT32 *heads, UINT32 *sectors, UINT32 *bps)
{
UINT32 totalsecs, hds, secs;
UINT64 filesize;
/* if this is a direct physical drive read, handle it specially */
if (osd_get_physical_drive_geometry(filename, cylinders, heads, sectors, bps))
return CHDERR_NONE;
/* compute the filesize */
filesize = get_file_size(filename);
if (filesize <= offset)
{
fprintf(stderr, "Invalid file '%s'\n", filename);
return CHDERR_INVALID_FILE;
}
filesize -= offset;
/* validate the size */
if (filesize % sectorsize != 0)
{
fprintf(stderr, "Can't guess CHS values because data size is not divisible by the sector size\n");
return CHDERR_INVALID_FILE;
}
totalsecs = filesize / sectorsize;
/* now find a valid value */
for (secs = 63; secs > 1; secs--)
if (totalsecs % secs == 0)
{
size_t totalhds = totalsecs / secs;
for (hds = 16; hds > 1; hds--)
if (totalhds % hds == 0)
{
*cylinders = totalhds / hds;
*heads = hds;
*sectors = secs;
*bps = sectorsize;
return CHDERR_NONE;
}
}
/* ack, it didn't work! */
fprintf(stderr, "Can't guess CHS values because no logical combination works!\n");
return CHDERR_INVALID_FILE;
} | /*-------------------------------------------------
guess_chs - given a file and an offset,
compute a best guess CHS value set
-------------------------------------------------*/ | given a file and an offset,
compute a best guess CHS value set | [
"given",
"a",
"file",
"and",
"an",
"offset",
"compute",
"a",
"best",
"guess",
"CHS",
"value",
"set"
] | static chd_error guess_chs(const char *filename, int offset, int sectorsize, UINT32 *cylinders, UINT32 *heads, UINT32 *sectors, UINT32 *bps)
{
UINT32 totalsecs, hds, secs;
UINT64 filesize;
if (osd_get_physical_drive_geometry(filename, cylinders, heads, sectors, bps))
return CHDERR_NONE;
filesize = get_file_size(filename);
if (filesize <= offset)
{
fprintf(stderr, "Invalid file '%s'\n", filename);
return CHDERR_INVALID_FILE;
}
filesize -= offset;
if (filesize % sectorsize != 0)
{
fprintf(stderr, "Can't guess CHS values because data size is not divisible by the sector size\n");
return CHDERR_INVALID_FILE;
}
totalsecs = filesize / sectorsize;
for (secs = 63; secs > 1; secs--)
if (totalsecs % secs == 0)
{
size_t totalhds = totalsecs / secs;
for (hds = 16; hds > 1; hds--)
if (totalhds % hds == 0)
{
*cylinders = totalhds / hds;
*heads = hds;
*sectors = secs;
*bps = sectorsize;
return CHDERR_NONE;
}
}
fprintf(stderr, "Can't guess CHS values because no logical combination works!\n");
return CHDERR_INVALID_FILE;
} | [
"static",
"chd_error",
"guess_chs",
"(",
"const",
"char",
"*",
"filename",
",",
"int",
"offset",
",",
"int",
"sectorsize",
",",
"UINT32",
"*",
"cylinders",
",",
"UINT32",
"*",
"heads",
",",
"UINT32",
"*",
"sectors",
",",
"UINT32",
"*",
"bps",
")",
"{",
"UINT32",
"totalsecs",
",",
"hds",
",",
"secs",
";",
"UINT64",
"filesize",
";",
"if",
"(",
"osd_get_physical_drive_geometry",
"(",
"filename",
",",
"cylinders",
",",
"heads",
",",
"sectors",
",",
"bps",
")",
")",
"return",
"CHDERR_NONE",
";",
"filesize",
"=",
"get_file_size",
"(",
"filename",
")",
";",
"if",
"(",
"filesize",
"<=",
"offset",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"filename",
")",
";",
"return",
"CHDERR_INVALID_FILE",
";",
"}",
"filesize",
"-=",
"offset",
";",
"if",
"(",
"filesize",
"%",
"sectorsize",
"!=",
"0",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
")",
";",
"return",
"CHDERR_INVALID_FILE",
";",
"}",
"totalsecs",
"=",
"filesize",
"/",
"sectorsize",
";",
"for",
"(",
"secs",
"=",
"63",
";",
"secs",
">",
"1",
";",
"secs",
"--",
")",
"if",
"(",
"totalsecs",
"%",
"secs",
"==",
"0",
")",
"{",
"size_t",
"totalhds",
"=",
"totalsecs",
"/",
"secs",
";",
"for",
"(",
"hds",
"=",
"16",
";",
"hds",
">",
"1",
";",
"hds",
"--",
")",
"if",
"(",
"totalhds",
"%",
"hds",
"==",
"0",
")",
"{",
"*",
"cylinders",
"=",
"totalhds",
"/",
"hds",
";",
"*",
"heads",
"=",
"hds",
";",
"*",
"sectors",
"=",
"secs",
";",
"*",
"bps",
"=",
"sectorsize",
";",
"return",
"CHDERR_NONE",
";",
"}",
"}",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
")",
";",
"return",
"CHDERR_INVALID_FILE",
";",
"}"
] | guess_chs - given a file and an offset,
compute a best guess CHS value set | [
"guess_chs",
"-",
"given",
"a",
"file",
"and",
"an",
"offset",
"compute",
"a",
"best",
"guess",
"CHS",
"value",
"set"
] | [
"/* if this is a direct physical drive read, handle it specially */",
"/* compute the filesize */",
"/* validate the size */",
"/* now find a valid value */",
"/* ack, it didn't work! */"
] | [
{
"param": "filename",
"type": "char"
},
{
"param": "offset",
"type": "int"
},
{
"param": "sectorsize",
"type": "int"
},
{
"param": "cylinders",
"type": "UINT32"
},
{
"param": "heads",
"type": "UINT32"
},
{
"param": "sectors",
"type": "UINT32"
},
{
"param": "bps",
"type": "UINT32"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offset",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sectorsize",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cylinders",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "heads",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sectors",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bps",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d835fd6445aba612019120fc378673b23aba8150 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/chdman.c | [
"Unlicense"
] | C | do_createhd | int | static int do_createhd(int argc, char *argv[], int param)
{
UINT32 guess_cylinders = 0, guess_heads = 0, guess_sectors = 0, guess_sectorsize = 0;
UINT32 cylinders, heads, sectors, sectorsize, hunksize, totalsectors, offset;
const char *inputfile, *outputfile = NULL;
chd_error err = CHDERR_NONE;
UINT32 identdatasize = 0;
UINT8 *identdata = NULL;
chd_file *chd = NULL;
char metadata[256];
/* if a file is provided for argument 4 (ident filename), then shift the remaining arguments down */
if (argc >= 5)
{
char *scan;
/* if there are any non-digits in the 'offset', then treat it as a ident file */
for (scan = argv[4]; *scan != 0; scan++)
if (!isdigit((UINT8)*scan))
break;
if (*scan != 0)
{
/* attempt to load the file */
file_error filerr = core_fload(argv[4], (void **)&identdata, &identdatasize);
if (filerr != FILERR_NONE)
{
fprintf(stderr, "Error opening ident file '%s'\n", argv[4]);
return 1;
}
/* shift the remaining arguments down */
if (argc > 5)
memmove(&argv[4], &argv[5], (argc - 5) * sizeof(argv[0]));
argc--;
}
}
/* require 4-5, or 8-10 args total */
if (argc != 4 && argc != 5 && argc != 8 && argc != 9 && argc != 10)
return usage();
/* extract the first few parameters */
inputfile = argv[2];
outputfile = argv[3];
offset = (argc >= 5) ? atoi(argv[4]) : (get_file_size(inputfile) % IDE_SECTOR_SIZE);
/* if less than 8 parameters, we need to guess the CHS values */
if (argc < 8)
{
if (identdata != NULL)
err = get_chs_from_ident(inputfile, offset, identdata, identdatasize, &guess_cylinders, &guess_heads, &guess_sectors, &guess_sectorsize);
else
err = guess_chs(inputfile, offset, IDE_SECTOR_SIZE, &guess_cylinders, &guess_heads, &guess_sectors, &guess_sectorsize);
if (err != CHDERR_NONE)
goto cleanup;
}
/* parse the remaining parameters */
cylinders = (argc >= 6) ? atoi(argv[5]) : guess_cylinders;
heads = (argc >= 7) ? atoi(argv[6]) : guess_heads;
sectors = (argc >= 8) ? atoi(argv[7]) : guess_sectors;
sectorsize = (argc >= 9) ? atoi(argv[8]) : guess_sectorsize;
if (sectorsize == 0) sectorsize = IDE_SECTOR_SIZE;
hunksize = (argc >= 10) ? atoi(argv[9]) : (sectorsize > 4096) ? sectorsize : ((4096 / sectorsize) * sectorsize);
totalsectors = cylinders * heads * sectors;
/* print some info */
printf("Input file: %s\n", inputfile);
printf("Output file: %s\n", outputfile);
printf("Input offset: %d\n", offset);
printf("Cylinders: %d\n", cylinders);
printf("Heads: %d\n", heads);
printf("Sectors: %d\n", sectors);
printf("Bytes/sector: %d\n", sectorsize);
printf("Sectors/hunk: %d\n", hunksize / sectorsize);
printf("Logical size: %s\n", big_int_string((UINT64)totalsectors * (UINT64)sectorsize));
/* create the new hard drive */
err = chd_create(outputfile, (UINT64)totalsectors * (UINT64)sectorsize, hunksize, CHDCOMPRESSION_ZLIB_PLUS, NULL);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error creating CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
/* open the new hard drive */
err = chd_open(outputfile, CHD_OPEN_READWRITE, NULL, &chd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening new CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
/* write the metadata */
sprintf(metadata, HARD_DISK_METADATA_FORMAT, cylinders, heads, sectors, sectorsize);
err = chd_set_metadata(chd, HARD_DISK_METADATA_TAG, 0, metadata, strlen(metadata) + 1, CHD_MDFLAGS_CHECKSUM);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error adding hard disk metadata: %s\n", chd_error_string(err));
goto cleanup;
}
/* write the ident if present */
if (identdata != NULL)
{
err = chd_set_metadata(chd, HARD_DISK_IDENT_METADATA_TAG, 0, identdata, identdatasize, CHD_MDFLAGS_CHECKSUM);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error adding hard disk metadata: %s\n", chd_error_string(err));
goto cleanup;
}
}
/* compress the hard drive */
err = chdman_compress_file(chd, inputfile, offset);
if (err != CHDERR_NONE)
fprintf(stderr, "Error during compression: %s\n", chd_error_string(err));
cleanup:
/* close everything down */
if (chd != NULL)
chd_close(chd);
if (err != CHDERR_NONE)
osd_rmfile(outputfile);
if (identdata != NULL)
free(identdata);
return (err != CHDERR_NONE);
} | /*-------------------------------------------------
do_createhd - create a new compressed hard
disk image from a raw file
-------------------------------------------------*/ | create a new compressed hard
disk image from a raw file | [
"create",
"a",
"new",
"compressed",
"hard",
"disk",
"image",
"from",
"a",
"raw",
"file"
] | static int do_createhd(int argc, char *argv[], int param)
{
UINT32 guess_cylinders = 0, guess_heads = 0, guess_sectors = 0, guess_sectorsize = 0;
UINT32 cylinders, heads, sectors, sectorsize, hunksize, totalsectors, offset;
const char *inputfile, *outputfile = NULL;
chd_error err = CHDERR_NONE;
UINT32 identdatasize = 0;
UINT8 *identdata = NULL;
chd_file *chd = NULL;
char metadata[256];
if (argc >= 5)
{
char *scan;
for (scan = argv[4]; *scan != 0; scan++)
if (!isdigit((UINT8)*scan))
break;
if (*scan != 0)
{
file_error filerr = core_fload(argv[4], (void **)&identdata, &identdatasize);
if (filerr != FILERR_NONE)
{
fprintf(stderr, "Error opening ident file '%s'\n", argv[4]);
return 1;
}
if (argc > 5)
memmove(&argv[4], &argv[5], (argc - 5) * sizeof(argv[0]));
argc--;
}
}
if (argc != 4 && argc != 5 && argc != 8 && argc != 9 && argc != 10)
return usage();
inputfile = argv[2];
outputfile = argv[3];
offset = (argc >= 5) ? atoi(argv[4]) : (get_file_size(inputfile) % IDE_SECTOR_SIZE);
if (argc < 8)
{
if (identdata != NULL)
err = get_chs_from_ident(inputfile, offset, identdata, identdatasize, &guess_cylinders, &guess_heads, &guess_sectors, &guess_sectorsize);
else
err = guess_chs(inputfile, offset, IDE_SECTOR_SIZE, &guess_cylinders, &guess_heads, &guess_sectors, &guess_sectorsize);
if (err != CHDERR_NONE)
goto cleanup;
}
cylinders = (argc >= 6) ? atoi(argv[5]) : guess_cylinders;
heads = (argc >= 7) ? atoi(argv[6]) : guess_heads;
sectors = (argc >= 8) ? atoi(argv[7]) : guess_sectors;
sectorsize = (argc >= 9) ? atoi(argv[8]) : guess_sectorsize;
if (sectorsize == 0) sectorsize = IDE_SECTOR_SIZE;
hunksize = (argc >= 10) ? atoi(argv[9]) : (sectorsize > 4096) ? sectorsize : ((4096 / sectorsize) * sectorsize);
totalsectors = cylinders * heads * sectors;
printf("Input file: %s\n", inputfile);
printf("Output file: %s\n", outputfile);
printf("Input offset: %d\n", offset);
printf("Cylinders: %d\n", cylinders);
printf("Heads: %d\n", heads);
printf("Sectors: %d\n", sectors);
printf("Bytes/sector: %d\n", sectorsize);
printf("Sectors/hunk: %d\n", hunksize / sectorsize);
printf("Logical size: %s\n", big_int_string((UINT64)totalsectors * (UINT64)sectorsize));
err = chd_create(outputfile, (UINT64)totalsectors * (UINT64)sectorsize, hunksize, CHDCOMPRESSION_ZLIB_PLUS, NULL);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error creating CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
err = chd_open(outputfile, CHD_OPEN_READWRITE, NULL, &chd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening new CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
sprintf(metadata, HARD_DISK_METADATA_FORMAT, cylinders, heads, sectors, sectorsize);
err = chd_set_metadata(chd, HARD_DISK_METADATA_TAG, 0, metadata, strlen(metadata) + 1, CHD_MDFLAGS_CHECKSUM);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error adding hard disk metadata: %s\n", chd_error_string(err));
goto cleanup;
}
if (identdata != NULL)
{
err = chd_set_metadata(chd, HARD_DISK_IDENT_METADATA_TAG, 0, identdata, identdatasize, CHD_MDFLAGS_CHECKSUM);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error adding hard disk metadata: %s\n", chd_error_string(err));
goto cleanup;
}
}
err = chdman_compress_file(chd, inputfile, offset);
if (err != CHDERR_NONE)
fprintf(stderr, "Error during compression: %s\n", chd_error_string(err));
cleanup:
if (chd != NULL)
chd_close(chd);
if (err != CHDERR_NONE)
osd_rmfile(outputfile);
if (identdata != NULL)
free(identdata);
return (err != CHDERR_NONE);
} | [
"static",
"int",
"do_createhd",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
",",
"int",
"param",
")",
"{",
"UINT32",
"guess_cylinders",
"=",
"0",
",",
"guess_heads",
"=",
"0",
",",
"guess_sectors",
"=",
"0",
",",
"guess_sectorsize",
"=",
"0",
";",
"UINT32",
"cylinders",
",",
"heads",
",",
"sectors",
",",
"sectorsize",
",",
"hunksize",
",",
"totalsectors",
",",
"offset",
";",
"const",
"char",
"*",
"inputfile",
",",
"*",
"outputfile",
"=",
"NULL",
";",
"chd_error",
"err",
"=",
"CHDERR_NONE",
";",
"UINT32",
"identdatasize",
"=",
"0",
";",
"UINT8",
"*",
"identdata",
"=",
"NULL",
";",
"chd_file",
"*",
"chd",
"=",
"NULL",
";",
"char",
"metadata",
"[",
"256",
"]",
";",
"if",
"(",
"argc",
">=",
"5",
")",
"{",
"char",
"*",
"scan",
";",
"for",
"(",
"scan",
"=",
"argv",
"[",
"4",
"]",
";",
"*",
"scan",
"!=",
"0",
";",
"scan",
"++",
")",
"if",
"(",
"!",
"isdigit",
"(",
"(",
"UINT8",
")",
"*",
"scan",
")",
")",
"break",
";",
"if",
"(",
"*",
"scan",
"!=",
"0",
")",
"{",
"file_error",
"filerr",
"=",
"core_fload",
"(",
"argv",
"[",
"4",
"]",
",",
"(",
"void",
"*",
"*",
")",
"&",
"identdata",
",",
"&",
"identdatasize",
")",
";",
"if",
"(",
"filerr",
"!=",
"FILERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"argv",
"[",
"4",
"]",
")",
";",
"return",
"1",
";",
"}",
"if",
"(",
"argc",
">",
"5",
")",
"memmove",
"(",
"&",
"argv",
"[",
"4",
"]",
",",
"&",
"argv",
"[",
"5",
"]",
",",
"(",
"argc",
"-",
"5",
")",
"*",
"sizeof",
"(",
"argv",
"[",
"0",
"]",
")",
")",
";",
"argc",
"--",
";",
"}",
"}",
"if",
"(",
"argc",
"!=",
"4",
"&&",
"argc",
"!=",
"5",
"&&",
"argc",
"!=",
"8",
"&&",
"argc",
"!=",
"9",
"&&",
"argc",
"!=",
"10",
")",
"return",
"usage",
"(",
")",
";",
"inputfile",
"=",
"argv",
"[",
"2",
"]",
";",
"outputfile",
"=",
"argv",
"[",
"3",
"]",
";",
"offset",
"=",
"(",
"argc",
">=",
"5",
")",
"?",
"atoi",
"(",
"argv",
"[",
"4",
"]",
")",
":",
"(",
"get_file_size",
"(",
"inputfile",
")",
"%",
"IDE_SECTOR_SIZE",
")",
";",
"if",
"(",
"argc",
"<",
"8",
")",
"{",
"if",
"(",
"identdata",
"!=",
"NULL",
")",
"err",
"=",
"get_chs_from_ident",
"(",
"inputfile",
",",
"offset",
",",
"identdata",
",",
"identdatasize",
",",
"&",
"guess_cylinders",
",",
"&",
"guess_heads",
",",
"&",
"guess_sectors",
",",
"&",
"guess_sectorsize",
")",
";",
"else",
"err",
"=",
"guess_chs",
"(",
"inputfile",
",",
"offset",
",",
"IDE_SECTOR_SIZE",
",",
"&",
"guess_cylinders",
",",
"&",
"guess_heads",
",",
"&",
"guess_sectors",
",",
"&",
"guess_sectorsize",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"goto",
"cleanup",
";",
"}",
"cylinders",
"=",
"(",
"argc",
">=",
"6",
")",
"?",
"atoi",
"(",
"argv",
"[",
"5",
"]",
")",
":",
"guess_cylinders",
";",
"heads",
"=",
"(",
"argc",
">=",
"7",
")",
"?",
"atoi",
"(",
"argv",
"[",
"6",
"]",
")",
":",
"guess_heads",
";",
"sectors",
"=",
"(",
"argc",
">=",
"8",
")",
"?",
"atoi",
"(",
"argv",
"[",
"7",
"]",
")",
":",
"guess_sectors",
";",
"sectorsize",
"=",
"(",
"argc",
">=",
"9",
")",
"?",
"atoi",
"(",
"argv",
"[",
"8",
"]",
")",
":",
"guess_sectorsize",
";",
"if",
"(",
"sectorsize",
"==",
"0",
")",
"sectorsize",
"=",
"IDE_SECTOR_SIZE",
";",
"hunksize",
"=",
"(",
"argc",
">=",
"10",
")",
"?",
"atoi",
"(",
"argv",
"[",
"9",
"]",
")",
":",
"(",
"sectorsize",
">",
"4096",
")",
"?",
"sectorsize",
":",
"(",
"(",
"4096",
"/",
"sectorsize",
")",
"*",
"sectorsize",
")",
";",
"totalsectors",
"=",
"cylinders",
"*",
"heads",
"*",
"sectors",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"inputfile",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"outputfile",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"offset",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"cylinders",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"heads",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"sectors",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"sectorsize",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"hunksize",
"/",
"sectorsize",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"big_int_string",
"(",
"(",
"UINT64",
")",
"totalsectors",
"*",
"(",
"UINT64",
")",
"sectorsize",
")",
")",
";",
"err",
"=",
"chd_create",
"(",
"outputfile",
",",
"(",
"UINT64",
")",
"totalsectors",
"*",
"(",
"UINT64",
")",
"sectorsize",
",",
"hunksize",
",",
"CHDCOMPRESSION_ZLIB_PLUS",
",",
"NULL",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"chd_open",
"(",
"outputfile",
",",
"CHD_OPEN_READWRITE",
",",
"NULL",
",",
"&",
"chd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"sprintf",
"(",
"metadata",
",",
"HARD_DISK_METADATA_FORMAT",
",",
"cylinders",
",",
"heads",
",",
"sectors",
",",
"sectorsize",
")",
";",
"err",
"=",
"chd_set_metadata",
"(",
"chd",
",",
"HARD_DISK_METADATA_TAG",
",",
"0",
",",
"metadata",
",",
"strlen",
"(",
"metadata",
")",
"+",
"1",
",",
"CHD_MDFLAGS_CHECKSUM",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"if",
"(",
"identdata",
"!=",
"NULL",
")",
"{",
"err",
"=",
"chd_set_metadata",
"(",
"chd",
",",
"HARD_DISK_IDENT_METADATA_TAG",
",",
"0",
",",
"identdata",
",",
"identdatasize",
",",
"CHD_MDFLAGS_CHECKSUM",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"}",
"err",
"=",
"chdman_compress_file",
"(",
"chd",
",",
"inputfile",
",",
"offset",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"cleanup",
":",
"if",
"(",
"chd",
"!=",
"NULL",
")",
"chd_close",
"(",
"chd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"osd_rmfile",
"(",
"outputfile",
")",
";",
"if",
"(",
"identdata",
"!=",
"NULL",
")",
"free",
"(",
"identdata",
")",
";",
"return",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
";",
"}"
] | do_createhd - create a new compressed hard
disk image from a raw file | [
"do_createhd",
"-",
"create",
"a",
"new",
"compressed",
"hard",
"disk",
"image",
"from",
"a",
"raw",
"file"
] | [
"/* if a file is provided for argument 4 (ident filename), then shift the remaining arguments down */",
"/* if there are any non-digits in the 'offset', then treat it as a ident file */",
"/* attempt to load the file */",
"/* shift the remaining arguments down */",
"/* require 4-5, or 8-10 args total */",
"/* extract the first few parameters */",
"/* if less than 8 parameters, we need to guess the CHS values */",
"/* parse the remaining parameters */",
"/* print some info */",
"/* create the new hard drive */",
"/* open the new hard drive */",
"/* write the metadata */",
"/* write the ident if present */",
"/* compress the hard drive */",
"/* close everything down */"
] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
},
{
"param": "param",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "argc",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "argv",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "param",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d835fd6445aba612019120fc378673b23aba8150 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/chdman.c | [
"Unlicense"
] | C | do_createraw | int | static int do_createraw(int argc, char *argv[], int param)
{
const char *inputfile, *outputfile;
UINT32 hunksize, offset;
UINT64 logicalbytes;
chd_file *chd = NULL;
chd_error err;
/* require 4, 5, or 6 args total */
if (argc != 4 && argc != 5 && argc != 6)
return usage();
/* extract the first few parameters */
inputfile = argv[2];
outputfile = argv[3];
offset = (argc >= 5) ? atoi(argv[4]) : 0;
hunksize = (argc >= 6) ? atoi(argv[5]) : 4096;
logicalbytes = get_file_size(inputfile) - offset;
/* print some info */
printf("Input file: %s\n", inputfile);
printf("Output file: %s\n", outputfile);
printf("Input offset: %d\n", offset);
printf("Bytes/hunk: %d\n", hunksize);
printf("Logical size: %s\n", big_int_string(logicalbytes));
/* create the new CHD */
err = chd_create(outputfile, logicalbytes, hunksize, CHDCOMPRESSION_ZLIB_PLUS, NULL);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error creating CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
/* open the new CHD */
err = chd_open(outputfile, CHD_OPEN_READWRITE, NULL, &chd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening new CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
/* compress the CHD */
err = chdman_compress_file(chd, inputfile, offset);
if (err != CHDERR_NONE)
fprintf(stderr, "Error during compression: %s\n", chd_error_string(err));
cleanup:
/* close everything down */
if (chd != NULL)
chd_close(chd);
if (err != CHDERR_NONE)
osd_rmfile(outputfile);
return (err != CHDERR_NONE);
} | /*-------------------------------------------------
do_createraw - create a new compressed raw
image from a raw file
-------------------------------------------------*/ | create a new compressed raw
image from a raw file | [
"create",
"a",
"new",
"compressed",
"raw",
"image",
"from",
"a",
"raw",
"file"
] | static int do_createraw(int argc, char *argv[], int param)
{
const char *inputfile, *outputfile;
UINT32 hunksize, offset;
UINT64 logicalbytes;
chd_file *chd = NULL;
chd_error err;
if (argc != 4 && argc != 5 && argc != 6)
return usage();
inputfile = argv[2];
outputfile = argv[3];
offset = (argc >= 5) ? atoi(argv[4]) : 0;
hunksize = (argc >= 6) ? atoi(argv[5]) : 4096;
logicalbytes = get_file_size(inputfile) - offset;
printf("Input file: %s\n", inputfile);
printf("Output file: %s\n", outputfile);
printf("Input offset: %d\n", offset);
printf("Bytes/hunk: %d\n", hunksize);
printf("Logical size: %s\n", big_int_string(logicalbytes));
err = chd_create(outputfile, logicalbytes, hunksize, CHDCOMPRESSION_ZLIB_PLUS, NULL);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error creating CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
err = chd_open(outputfile, CHD_OPEN_READWRITE, NULL, &chd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening new CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
err = chdman_compress_file(chd, inputfile, offset);
if (err != CHDERR_NONE)
fprintf(stderr, "Error during compression: %s\n", chd_error_string(err));
cleanup:
if (chd != NULL)
chd_close(chd);
if (err != CHDERR_NONE)
osd_rmfile(outputfile);
return (err != CHDERR_NONE);
} | [
"static",
"int",
"do_createraw",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
",",
"int",
"param",
")",
"{",
"const",
"char",
"*",
"inputfile",
",",
"*",
"outputfile",
";",
"UINT32",
"hunksize",
",",
"offset",
";",
"UINT64",
"logicalbytes",
";",
"chd_file",
"*",
"chd",
"=",
"NULL",
";",
"chd_error",
"err",
";",
"if",
"(",
"argc",
"!=",
"4",
"&&",
"argc",
"!=",
"5",
"&&",
"argc",
"!=",
"6",
")",
"return",
"usage",
"(",
")",
";",
"inputfile",
"=",
"argv",
"[",
"2",
"]",
";",
"outputfile",
"=",
"argv",
"[",
"3",
"]",
";",
"offset",
"=",
"(",
"argc",
">=",
"5",
")",
"?",
"atoi",
"(",
"argv",
"[",
"4",
"]",
")",
":",
"0",
";",
"hunksize",
"=",
"(",
"argc",
">=",
"6",
")",
"?",
"atoi",
"(",
"argv",
"[",
"5",
"]",
")",
":",
"4096",
";",
"logicalbytes",
"=",
"get_file_size",
"(",
"inputfile",
")",
"-",
"offset",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"inputfile",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"outputfile",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"offset",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"hunksize",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"big_int_string",
"(",
"logicalbytes",
")",
")",
";",
"err",
"=",
"chd_create",
"(",
"outputfile",
",",
"logicalbytes",
",",
"hunksize",
",",
"CHDCOMPRESSION_ZLIB_PLUS",
",",
"NULL",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"chd_open",
"(",
"outputfile",
",",
"CHD_OPEN_READWRITE",
",",
"NULL",
",",
"&",
"chd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"chdman_compress_file",
"(",
"chd",
",",
"inputfile",
",",
"offset",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"cleanup",
":",
"if",
"(",
"chd",
"!=",
"NULL",
")",
"chd_close",
"(",
"chd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"osd_rmfile",
"(",
"outputfile",
")",
";",
"return",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
";",
"}"
] | do_createraw - create a new compressed raw
image from a raw file | [
"do_createraw",
"-",
"create",
"a",
"new",
"compressed",
"raw",
"image",
"from",
"a",
"raw",
"file"
] | [
"/* require 4, 5, or 6 args total */",
"/* extract the first few parameters */",
"/* print some info */",
"/* create the new CHD */",
"/* open the new CHD */",
"/* compress the CHD */",
"/* close everything down */"
] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
},
{
"param": "param",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "argc",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "argv",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "param",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d835fd6445aba612019120fc378673b23aba8150 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/chdman.c | [
"Unlicense"
] | C | do_createcd | int | static int do_createcd(int argc, char *argv[], int param)
{
static chdcd_track_input_info track_info;
static cdrom_toc toc;
UINT32 hunksize = CD_FRAME_SIZE * CD_FRAMES_PER_HUNK;
UINT32 sectorsize = CD_FRAME_SIZE;
const char *inputfile, *outputfile;
core_file *srcfile = NULL;
UINT32 origtotalsectors;
chd_file *chd = NULL;
UINT8 *cache = NULL;
UINT32 totalsectors;
double ratio = 1.0;
UINT32 totalhunks;
file_error filerr;
chd_error err;
int i;
/* require 4 args total */
if (argc != 4)
return usage();
/* extract the data */
inputfile = argv[2];
outputfile = argv[3];
/* allocate a cache */
cache = (UINT8 *)malloc(hunksize);
if (cache == NULL)
{
fprintf(stderr, "Out of memory allocating temporary buffer\n");
err = CHDERR_OUT_OF_MEMORY;
goto cleanup;
}
/* setup the CDROM module and get the disc info */
err = chdcd_parse_toc(inputfile, &toc, &track_info);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error reading input file: %s\n", chd_error_string(err));
goto cleanup;
}
/* pad each track to a hunk boundry. cdrom.c will deal with this on the read side */
for (i = 0; i < toc.numtrks; i++)
{
int hunks = (toc.tracks[i].frames + CD_FRAMES_PER_HUNK - 1) / CD_FRAMES_PER_HUNK;
toc.tracks[i].extraframes = hunks * CD_FRAMES_PER_HUNK - toc.tracks[i].frames;
}
/* count up the total number of frames */
origtotalsectors = totalsectors = 0;
for (i = 0; i < toc.numtrks; i++)
{
origtotalsectors += toc.tracks[i].frames;
totalsectors += toc.tracks[i].frames + toc.tracks[i].extraframes;
}
printf("\nCD-ROM %s has %d tracks and %d total frames\n", inputfile, toc.numtrks, origtotalsectors);
/* create the new CHD file */
err = chd_create(outputfile, (UINT64)totalsectors * (UINT64)sectorsize, hunksize, CHDCOMPRESSION_ZLIB_PLUS, NULL);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error creating CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
/* open the new CHD file */
err = chd_open(outputfile, CHD_OPEN_READWRITE, NULL, &chd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening new CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
/* write the metadata */
err = cdrom_write_metadata(chd, &toc);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error adding CD-ROM metadata: %s\n", chd_error_string(err));
goto cleanup;
}
/* begin state for writing */
err = chd_compress_begin(chd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error compressing: %s\n", chd_error_string(err));
goto cleanup;
}
/* loop over tracks */
totalhunks = 0;
for (i = 0; i < toc.numtrks; i++)
{
int frames = 0;
int bytespersector = toc.tracks[i].datasize + toc.tracks[i].subsize;
int trackhunks = (toc.tracks[i].frames + toc.tracks[i].extraframes) / CD_FRAMES_PER_HUNK;
UINT64 sourcefileoffset = track_info.offset[i];
int curhunk;
/* open the input file for this track */
filerr = core_fopen(track_info.fname[i], OPEN_FLAG_READ, &srcfile);
if (filerr != FILERR_NONE)
{
fprintf(stderr, "Unable to open file: %s\n", track_info.fname[i]);
err = CHDERR_FILE_NOT_FOUND;
goto cleanup;
}
printf("Track %d/%d (%s:%d,%d frames,%d hunks,swap %d)\n", i+1, toc.numtrks, track_info.fname[i], track_info.offset[i], toc.tracks[i].frames, trackhunks, track_info.swap[i]);
/* loop over hunks */
for (curhunk = 0; curhunk < trackhunks; curhunk++, totalhunks++)
{
int secnum;
progress(FALSE, "Compressing hunk %d/%d... (ratio=%d%%) \r", totalhunks, chd_get_header(chd)->totalhunks, (int)(ratio * 100));
/* loop over sectors in this hunk, reading the source data into a fixed start location */
/* relative to the start; we zero out the buffer ahead of time to ensure that unpopulated */
/* areas are cleared */
memset(cache, 0, hunksize);
for (secnum = 0; secnum < CD_FRAMES_PER_HUNK; secnum++)
{
if (frames < toc.tracks[i].frames)
{
core_fseek(srcfile, sourcefileoffset, SEEK_SET);
core_fread(srcfile, &cache[secnum * CD_FRAME_SIZE], bytespersector);
if (track_info.swap[i])
{
int swapindex;
for (swapindex = 0; swapindex < 2352; swapindex += 2 )
{
int swapoffset = ( secnum * CD_FRAME_SIZE ) + swapindex;
int swaptemp = cache[ swapoffset ];
cache[ swapoffset ] = cache[ swapoffset + 1 ];
cache[ swapoffset + 1 ] = swaptemp;
}
}
}
sourcefileoffset += bytespersector;
frames++;
}
/* compress the current hunk */
err = chd_compress_hunk(chd, cache, &ratio);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error during compression: %s\n", chd_error_string(err));
goto cleanup;
}
}
/* close the file */
core_fclose(srcfile);
srcfile = NULL;
}
/* cleanup */
err = chd_compress_finish(chd, TRUE);
if (err != CHDERR_NONE)
fprintf(stderr, "Error during compression finalization: %s\n", chd_error_string(err));
else
progress(TRUE, "Compression complete ... final ratio = %d%% \n", (int)(100.0 * ratio));
cleanup:
if (cache != NULL)
free(cache);
if (srcfile != NULL)
core_fclose(srcfile);
if (chd != NULL)
chd_close(chd);
if (err != CHDERR_NONE)
osd_rmfile(outputfile);
return (err != CHDERR_NONE);
} | /*-------------------------------------------------
do_createcd - create a new compressed CD
image from a raw file
-------------------------------------------------*/ | create a new compressed CD
image from a raw file | [
"create",
"a",
"new",
"compressed",
"CD",
"image",
"from",
"a",
"raw",
"file"
] | static int do_createcd(int argc, char *argv[], int param)
{
static chdcd_track_input_info track_info;
static cdrom_toc toc;
UINT32 hunksize = CD_FRAME_SIZE * CD_FRAMES_PER_HUNK;
UINT32 sectorsize = CD_FRAME_SIZE;
const char *inputfile, *outputfile;
core_file *srcfile = NULL;
UINT32 origtotalsectors;
chd_file *chd = NULL;
UINT8 *cache = NULL;
UINT32 totalsectors;
double ratio = 1.0;
UINT32 totalhunks;
file_error filerr;
chd_error err;
int i;
if (argc != 4)
return usage();
inputfile = argv[2];
outputfile = argv[3];
cache = (UINT8 *)malloc(hunksize);
if (cache == NULL)
{
fprintf(stderr, "Out of memory allocating temporary buffer\n");
err = CHDERR_OUT_OF_MEMORY;
goto cleanup;
}
err = chdcd_parse_toc(inputfile, &toc, &track_info);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error reading input file: %s\n", chd_error_string(err));
goto cleanup;
}
for (i = 0; i < toc.numtrks; i++)
{
int hunks = (toc.tracks[i].frames + CD_FRAMES_PER_HUNK - 1) / CD_FRAMES_PER_HUNK;
toc.tracks[i].extraframes = hunks * CD_FRAMES_PER_HUNK - toc.tracks[i].frames;
}
origtotalsectors = totalsectors = 0;
for (i = 0; i < toc.numtrks; i++)
{
origtotalsectors += toc.tracks[i].frames;
totalsectors += toc.tracks[i].frames + toc.tracks[i].extraframes;
}
printf("\nCD-ROM %s has %d tracks and %d total frames\n", inputfile, toc.numtrks, origtotalsectors);
err = chd_create(outputfile, (UINT64)totalsectors * (UINT64)sectorsize, hunksize, CHDCOMPRESSION_ZLIB_PLUS, NULL);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error creating CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
err = chd_open(outputfile, CHD_OPEN_READWRITE, NULL, &chd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening new CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
err = cdrom_write_metadata(chd, &toc);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error adding CD-ROM metadata: %s\n", chd_error_string(err));
goto cleanup;
}
err = chd_compress_begin(chd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error compressing: %s\n", chd_error_string(err));
goto cleanup;
}
totalhunks = 0;
for (i = 0; i < toc.numtrks; i++)
{
int frames = 0;
int bytespersector = toc.tracks[i].datasize + toc.tracks[i].subsize;
int trackhunks = (toc.tracks[i].frames + toc.tracks[i].extraframes) / CD_FRAMES_PER_HUNK;
UINT64 sourcefileoffset = track_info.offset[i];
int curhunk;
filerr = core_fopen(track_info.fname[i], OPEN_FLAG_READ, &srcfile);
if (filerr != FILERR_NONE)
{
fprintf(stderr, "Unable to open file: %s\n", track_info.fname[i]);
err = CHDERR_FILE_NOT_FOUND;
goto cleanup;
}
printf("Track %d/%d (%s:%d,%d frames,%d hunks,swap %d)\n", i+1, toc.numtrks, track_info.fname[i], track_info.offset[i], toc.tracks[i].frames, trackhunks, track_info.swap[i]);
for (curhunk = 0; curhunk < trackhunks; curhunk++, totalhunks++)
{
int secnum;
progress(FALSE, "Compressing hunk %d/%d... (ratio=%d%%) \r", totalhunks, chd_get_header(chd)->totalhunks, (int)(ratio * 100));
memset(cache, 0, hunksize);
for (secnum = 0; secnum < CD_FRAMES_PER_HUNK; secnum++)
{
if (frames < toc.tracks[i].frames)
{
core_fseek(srcfile, sourcefileoffset, SEEK_SET);
core_fread(srcfile, &cache[secnum * CD_FRAME_SIZE], bytespersector);
if (track_info.swap[i])
{
int swapindex;
for (swapindex = 0; swapindex < 2352; swapindex += 2 )
{
int swapoffset = ( secnum * CD_FRAME_SIZE ) + swapindex;
int swaptemp = cache[ swapoffset ];
cache[ swapoffset ] = cache[ swapoffset + 1 ];
cache[ swapoffset + 1 ] = swaptemp;
}
}
}
sourcefileoffset += bytespersector;
frames++;
}
err = chd_compress_hunk(chd, cache, &ratio);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error during compression: %s\n", chd_error_string(err));
goto cleanup;
}
}
core_fclose(srcfile);
srcfile = NULL;
}
err = chd_compress_finish(chd, TRUE);
if (err != CHDERR_NONE)
fprintf(stderr, "Error during compression finalization: %s\n", chd_error_string(err));
else
progress(TRUE, "Compression complete ... final ratio = %d%% \n", (int)(100.0 * ratio));
cleanup:
if (cache != NULL)
free(cache);
if (srcfile != NULL)
core_fclose(srcfile);
if (chd != NULL)
chd_close(chd);
if (err != CHDERR_NONE)
osd_rmfile(outputfile);
return (err != CHDERR_NONE);
} | [
"static",
"int",
"do_createcd",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
",",
"int",
"param",
")",
"{",
"static",
"chdcd_track_input_info",
"track_info",
";",
"static",
"cdrom_toc",
"toc",
";",
"UINT32",
"hunksize",
"=",
"CD_FRAME_SIZE",
"*",
"CD_FRAMES_PER_HUNK",
";",
"UINT32",
"sectorsize",
"=",
"CD_FRAME_SIZE",
";",
"const",
"char",
"*",
"inputfile",
",",
"*",
"outputfile",
";",
"core_file",
"*",
"srcfile",
"=",
"NULL",
";",
"UINT32",
"origtotalsectors",
";",
"chd_file",
"*",
"chd",
"=",
"NULL",
";",
"UINT8",
"*",
"cache",
"=",
"NULL",
";",
"UINT32",
"totalsectors",
";",
"double",
"ratio",
"=",
"1.0",
";",
"UINT32",
"totalhunks",
";",
"file_error",
"filerr",
";",
"chd_error",
"err",
";",
"int",
"i",
";",
"if",
"(",
"argc",
"!=",
"4",
")",
"return",
"usage",
"(",
")",
";",
"inputfile",
"=",
"argv",
"[",
"2",
"]",
";",
"outputfile",
"=",
"argv",
"[",
"3",
"]",
";",
"cache",
"=",
"(",
"UINT8",
"*",
")",
"malloc",
"(",
"hunksize",
")",
";",
"if",
"(",
"cache",
"==",
"NULL",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
")",
";",
"err",
"=",
"CHDERR_OUT_OF_MEMORY",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"chdcd_parse_toc",
"(",
"inputfile",
",",
"&",
"toc",
",",
"&",
"track_info",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"toc",
".",
"numtrks",
";",
"i",
"++",
")",
"{",
"int",
"hunks",
"=",
"(",
"toc",
".",
"tracks",
"[",
"i",
"]",
".",
"frames",
"+",
"CD_FRAMES_PER_HUNK",
"-",
"1",
")",
"/",
"CD_FRAMES_PER_HUNK",
";",
"toc",
".",
"tracks",
"[",
"i",
"]",
".",
"extraframes",
"=",
"hunks",
"*",
"CD_FRAMES_PER_HUNK",
"-",
"toc",
".",
"tracks",
"[",
"i",
"]",
".",
"frames",
";",
"}",
"origtotalsectors",
"=",
"totalsectors",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"toc",
".",
"numtrks",
";",
"i",
"++",
")",
"{",
"origtotalsectors",
"+=",
"toc",
".",
"tracks",
"[",
"i",
"]",
".",
"frames",
";",
"totalsectors",
"+=",
"toc",
".",
"tracks",
"[",
"i",
"]",
".",
"frames",
"+",
"toc",
".",
"tracks",
"[",
"i",
"]",
".",
"extraframes",
";",
"}",
"printf",
"(",
"\"",
"\\n",
"\\n",
"\"",
",",
"inputfile",
",",
"toc",
".",
"numtrks",
",",
"origtotalsectors",
")",
";",
"err",
"=",
"chd_create",
"(",
"outputfile",
",",
"(",
"UINT64",
")",
"totalsectors",
"*",
"(",
"UINT64",
")",
"sectorsize",
",",
"hunksize",
",",
"CHDCOMPRESSION_ZLIB_PLUS",
",",
"NULL",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"chd_open",
"(",
"outputfile",
",",
"CHD_OPEN_READWRITE",
",",
"NULL",
",",
"&",
"chd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"cdrom_write_metadata",
"(",
"chd",
",",
"&",
"toc",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"chd_compress_begin",
"(",
"chd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"totalhunks",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"toc",
".",
"numtrks",
";",
"i",
"++",
")",
"{",
"int",
"frames",
"=",
"0",
";",
"int",
"bytespersector",
"=",
"toc",
".",
"tracks",
"[",
"i",
"]",
".",
"datasize",
"+",
"toc",
".",
"tracks",
"[",
"i",
"]",
".",
"subsize",
";",
"int",
"trackhunks",
"=",
"(",
"toc",
".",
"tracks",
"[",
"i",
"]",
".",
"frames",
"+",
"toc",
".",
"tracks",
"[",
"i",
"]",
".",
"extraframes",
")",
"/",
"CD_FRAMES_PER_HUNK",
";",
"UINT64",
"sourcefileoffset",
"=",
"track_info",
".",
"offset",
"[",
"i",
"]",
";",
"int",
"curhunk",
";",
"filerr",
"=",
"core_fopen",
"(",
"track_info",
".",
"fname",
"[",
"i",
"]",
",",
"OPEN_FLAG_READ",
",",
"&",
"srcfile",
")",
";",
"if",
"(",
"filerr",
"!=",
"FILERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"track_info",
".",
"fname",
"[",
"i",
"]",
")",
";",
"err",
"=",
"CHDERR_FILE_NOT_FOUND",
";",
"goto",
"cleanup",
";",
"}",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"i",
"+",
"1",
",",
"toc",
".",
"numtrks",
",",
"track_info",
".",
"fname",
"[",
"i",
"]",
",",
"track_info",
".",
"offset",
"[",
"i",
"]",
",",
"toc",
".",
"tracks",
"[",
"i",
"]",
".",
"frames",
",",
"trackhunks",
",",
"track_info",
".",
"swap",
"[",
"i",
"]",
")",
";",
"for",
"(",
"curhunk",
"=",
"0",
";",
"curhunk",
"<",
"trackhunks",
";",
"curhunk",
"++",
",",
"totalhunks",
"++",
")",
"{",
"int",
"secnum",
";",
"progress",
"(",
"FALSE",
",",
"\"",
"\\r",
"\"",
",",
"totalhunks",
",",
"chd_get_header",
"(",
"chd",
")",
"->",
"totalhunks",
",",
"(",
"int",
")",
"(",
"ratio",
"*",
"100",
")",
")",
";",
"memset",
"(",
"cache",
",",
"0",
",",
"hunksize",
")",
";",
"for",
"(",
"secnum",
"=",
"0",
";",
"secnum",
"<",
"CD_FRAMES_PER_HUNK",
";",
"secnum",
"++",
")",
"{",
"if",
"(",
"frames",
"<",
"toc",
".",
"tracks",
"[",
"i",
"]",
".",
"frames",
")",
"{",
"core_fseek",
"(",
"srcfile",
",",
"sourcefileoffset",
",",
"SEEK_SET",
")",
";",
"core_fread",
"(",
"srcfile",
",",
"&",
"cache",
"[",
"secnum",
"*",
"CD_FRAME_SIZE",
"]",
",",
"bytespersector",
")",
";",
"if",
"(",
"track_info",
".",
"swap",
"[",
"i",
"]",
")",
"{",
"int",
"swapindex",
";",
"for",
"(",
"swapindex",
"=",
"0",
";",
"swapindex",
"<",
"2352",
";",
"swapindex",
"+=",
"2",
")",
"{",
"int",
"swapoffset",
"=",
"(",
"secnum",
"*",
"CD_FRAME_SIZE",
")",
"+",
"swapindex",
";",
"int",
"swaptemp",
"=",
"cache",
"[",
"swapoffset",
"]",
";",
"cache",
"[",
"swapoffset",
"]",
"=",
"cache",
"[",
"swapoffset",
"+",
"1",
"]",
";",
"cache",
"[",
"swapoffset",
"+",
"1",
"]",
"=",
"swaptemp",
";",
"}",
"}",
"}",
"sourcefileoffset",
"+=",
"bytespersector",
";",
"frames",
"++",
";",
"}",
"err",
"=",
"chd_compress_hunk",
"(",
"chd",
",",
"cache",
",",
"&",
"ratio",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"}",
"core_fclose",
"(",
"srcfile",
")",
";",
"srcfile",
"=",
"NULL",
";",
"}",
"err",
"=",
"chd_compress_finish",
"(",
"chd",
",",
"TRUE",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"else",
"progress",
"(",
"TRUE",
",",
"\"",
"\\n",
"\"",
",",
"(",
"int",
")",
"(",
"100.0",
"*",
"ratio",
")",
")",
";",
"cleanup",
":",
"if",
"(",
"cache",
"!=",
"NULL",
")",
"free",
"(",
"cache",
")",
";",
"if",
"(",
"srcfile",
"!=",
"NULL",
")",
"core_fclose",
"(",
"srcfile",
")",
";",
"if",
"(",
"chd",
"!=",
"NULL",
")",
"chd_close",
"(",
"chd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"osd_rmfile",
"(",
"outputfile",
")",
";",
"return",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
";",
"}"
] | do_createcd - create a new compressed CD
image from a raw file | [
"do_createcd",
"-",
"create",
"a",
"new",
"compressed",
"CD",
"image",
"from",
"a",
"raw",
"file"
] | [
"/* require 4 args total */",
"/* extract the data */",
"/* allocate a cache */",
"/* setup the CDROM module and get the disc info */",
"/* pad each track to a hunk boundry. cdrom.c will deal with this on the read side */",
"/* count up the total number of frames */",
"/* create the new CHD file */",
"/* open the new CHD file */",
"/* write the metadata */",
"/* begin state for writing */",
"/* loop over tracks */",
"/* open the input file for this track */",
"/* loop over hunks */",
"/* loop over sectors in this hunk, reading the source data into a fixed start location */",
"/* relative to the start; we zero out the buffer ahead of time to ensure that unpopulated */",
"/* areas are cleared */",
"/* compress the current hunk */",
"/* close the file */",
"/* cleanup */"
] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
},
{
"param": "param",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "argc",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "argv",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "param",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d835fd6445aba612019120fc378673b23aba8150 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/chdman.c | [
"Unlicense"
] | C | do_createblankhd | int | static int do_createblankhd(int argc, char *argv[], int param)
{
UINT32 cylinders, heads, sectors, sectorsize, hunksize, totalsectors, hunknum;
const char *outputfile;
chd_file *chd = NULL;
UINT8 *cache = NULL;
char metadata[256];
chd_error err;
/* require 6, 7, or 8 args total */
if (argc != 6 && argc != 7 && argc != 8)
return usage();
/* extract the data */
outputfile = argv[2];
cylinders = atoi(argv[3]);
heads = atoi(argv[4]);
sectors = atoi(argv[5]);
sectorsize = (argc >= 7) ? atoi(argv[6]) : IDE_SECTOR_SIZE;
if (sectorsize == 0) sectorsize = IDE_SECTOR_SIZE;
hunksize = (argc >= 8) ? atoi(argv[7]) : (sectorsize > 4096) ? sectorsize : ((4096 / sectorsize) * sectorsize);
totalsectors = cylinders * heads * sectors;
/* print some info */
printf("Output file: %s\n", outputfile);
printf("Cylinders: %d\n", cylinders);
printf("Heads: %d\n", heads);
printf("Sectors: %d\n", sectors);
printf("Bytes/sector: %d\n", sectorsize);
printf("Sectors/hunk: %d\n", hunksize / sectorsize);
printf("Logical size: %s\n", big_int_string((UINT64)totalsectors * (UINT64)sectorsize));
/* create the new hard drive */
err = chd_create(outputfile, (UINT64)totalsectors * (UINT64)sectorsize, hunksize, CHDCOMPRESSION_NONE, NULL);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error creating CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
/* open the new hard drive */
err = chd_open(outputfile, CHD_OPEN_READWRITE, NULL, &chd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening new CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
/* write the metadata */
sprintf(metadata, HARD_DISK_METADATA_FORMAT, cylinders, heads, sectors, sectorsize);
err = chd_set_metadata(chd, HARD_DISK_METADATA_TAG, 0, metadata, strlen(metadata) + 1, CHD_MDFLAGS_CHECKSUM);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error adding hard disk metadata: %s\n", chd_error_string(err));
goto cleanup;
}
/* alloc and zero buffer*/
cache = (UINT8 *)malloc(hunksize);
if (cache == NULL)
{
fprintf(stderr, "Error allocating memory buffer\n");
err = CHDERR_OUT_OF_MEMORY;
goto cleanup;
}
memset(cache, 0, hunksize);
/* Zero every hunk */
for (hunknum = 0; hunknum < chd_get_header(chd)->totalhunks; hunknum++)
{
/* progress */
progress(hunknum == 0, "Zeroing hunk %d/%d... \r", hunknum, chd_get_header(chd)->totalhunks);
/* write out the data */
err = chd_write(chd, hunknum, cache);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error writing CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
}
progress(TRUE, "Creation complete! \n");
cleanup:
/* close everything down */
if (cache != NULL)
free(cache);
if (chd != NULL)
chd_close(chd);
if (err != CHDERR_NONE)
osd_rmfile(outputfile);
return (err != CHDERR_NONE);
} | /*-------------------------------------------------
do_createblankhd - create a new non-compressed
hard disk image, with all hunks filled with 0s
-------------------------------------------------*/ | create a new non-compressed
hard disk image, with all hunks filled with 0s | [
"create",
"a",
"new",
"non",
"-",
"compressed",
"hard",
"disk",
"image",
"with",
"all",
"hunks",
"filled",
"with",
"0s"
] | static int do_createblankhd(int argc, char *argv[], int param)
{
UINT32 cylinders, heads, sectors, sectorsize, hunksize, totalsectors, hunknum;
const char *outputfile;
chd_file *chd = NULL;
UINT8 *cache = NULL;
char metadata[256];
chd_error err;
if (argc != 6 && argc != 7 && argc != 8)
return usage();
outputfile = argv[2];
cylinders = atoi(argv[3]);
heads = atoi(argv[4]);
sectors = atoi(argv[5]);
sectorsize = (argc >= 7) ? atoi(argv[6]) : IDE_SECTOR_SIZE;
if (sectorsize == 0) sectorsize = IDE_SECTOR_SIZE;
hunksize = (argc >= 8) ? atoi(argv[7]) : (sectorsize > 4096) ? sectorsize : ((4096 / sectorsize) * sectorsize);
totalsectors = cylinders * heads * sectors;
printf("Output file: %s\n", outputfile);
printf("Cylinders: %d\n", cylinders);
printf("Heads: %d\n", heads);
printf("Sectors: %d\n", sectors);
printf("Bytes/sector: %d\n", sectorsize);
printf("Sectors/hunk: %d\n", hunksize / sectorsize);
printf("Logical size: %s\n", big_int_string((UINT64)totalsectors * (UINT64)sectorsize));
err = chd_create(outputfile, (UINT64)totalsectors * (UINT64)sectorsize, hunksize, CHDCOMPRESSION_NONE, NULL);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error creating CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
err = chd_open(outputfile, CHD_OPEN_READWRITE, NULL, &chd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening new CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
sprintf(metadata, HARD_DISK_METADATA_FORMAT, cylinders, heads, sectors, sectorsize);
err = chd_set_metadata(chd, HARD_DISK_METADATA_TAG, 0, metadata, strlen(metadata) + 1, CHD_MDFLAGS_CHECKSUM);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error adding hard disk metadata: %s\n", chd_error_string(err));
goto cleanup;
}
cache = (UINT8 *)malloc(hunksize);
if (cache == NULL)
{
fprintf(stderr, "Error allocating memory buffer\n");
err = CHDERR_OUT_OF_MEMORY;
goto cleanup;
}
memset(cache, 0, hunksize);
for (hunknum = 0; hunknum < chd_get_header(chd)->totalhunks; hunknum++)
{
progress(hunknum == 0, "Zeroing hunk %d/%d... \r", hunknum, chd_get_header(chd)->totalhunks);
err = chd_write(chd, hunknum, cache);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error writing CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
}
progress(TRUE, "Creation complete! \n");
cleanup:
if (cache != NULL)
free(cache);
if (chd != NULL)
chd_close(chd);
if (err != CHDERR_NONE)
osd_rmfile(outputfile);
return (err != CHDERR_NONE);
} | [
"static",
"int",
"do_createblankhd",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
",",
"int",
"param",
")",
"{",
"UINT32",
"cylinders",
",",
"heads",
",",
"sectors",
",",
"sectorsize",
",",
"hunksize",
",",
"totalsectors",
",",
"hunknum",
";",
"const",
"char",
"*",
"outputfile",
";",
"chd_file",
"*",
"chd",
"=",
"NULL",
";",
"UINT8",
"*",
"cache",
"=",
"NULL",
";",
"char",
"metadata",
"[",
"256",
"]",
";",
"chd_error",
"err",
";",
"if",
"(",
"argc",
"!=",
"6",
"&&",
"argc",
"!=",
"7",
"&&",
"argc",
"!=",
"8",
")",
"return",
"usage",
"(",
")",
";",
"outputfile",
"=",
"argv",
"[",
"2",
"]",
";",
"cylinders",
"=",
"atoi",
"(",
"argv",
"[",
"3",
"]",
")",
";",
"heads",
"=",
"atoi",
"(",
"argv",
"[",
"4",
"]",
")",
";",
"sectors",
"=",
"atoi",
"(",
"argv",
"[",
"5",
"]",
")",
";",
"sectorsize",
"=",
"(",
"argc",
">=",
"7",
")",
"?",
"atoi",
"(",
"argv",
"[",
"6",
"]",
")",
":",
"IDE_SECTOR_SIZE",
";",
"if",
"(",
"sectorsize",
"==",
"0",
")",
"sectorsize",
"=",
"IDE_SECTOR_SIZE",
";",
"hunksize",
"=",
"(",
"argc",
">=",
"8",
")",
"?",
"atoi",
"(",
"argv",
"[",
"7",
"]",
")",
":",
"(",
"sectorsize",
">",
"4096",
")",
"?",
"sectorsize",
":",
"(",
"(",
"4096",
"/",
"sectorsize",
")",
"*",
"sectorsize",
")",
";",
"totalsectors",
"=",
"cylinders",
"*",
"heads",
"*",
"sectors",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"outputfile",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"cylinders",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"heads",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"sectors",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"sectorsize",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"hunksize",
"/",
"sectorsize",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"big_int_string",
"(",
"(",
"UINT64",
")",
"totalsectors",
"*",
"(",
"UINT64",
")",
"sectorsize",
")",
")",
";",
"err",
"=",
"chd_create",
"(",
"outputfile",
",",
"(",
"UINT64",
")",
"totalsectors",
"*",
"(",
"UINT64",
")",
"sectorsize",
",",
"hunksize",
",",
"CHDCOMPRESSION_NONE",
",",
"NULL",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"chd_open",
"(",
"outputfile",
",",
"CHD_OPEN_READWRITE",
",",
"NULL",
",",
"&",
"chd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"sprintf",
"(",
"metadata",
",",
"HARD_DISK_METADATA_FORMAT",
",",
"cylinders",
",",
"heads",
",",
"sectors",
",",
"sectorsize",
")",
";",
"err",
"=",
"chd_set_metadata",
"(",
"chd",
",",
"HARD_DISK_METADATA_TAG",
",",
"0",
",",
"metadata",
",",
"strlen",
"(",
"metadata",
")",
"+",
"1",
",",
"CHD_MDFLAGS_CHECKSUM",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"cache",
"=",
"(",
"UINT8",
"*",
")",
"malloc",
"(",
"hunksize",
")",
";",
"if",
"(",
"cache",
"==",
"NULL",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
")",
";",
"err",
"=",
"CHDERR_OUT_OF_MEMORY",
";",
"goto",
"cleanup",
";",
"}",
"memset",
"(",
"cache",
",",
"0",
",",
"hunksize",
")",
";",
"for",
"(",
"hunknum",
"=",
"0",
";",
"hunknum",
"<",
"chd_get_header",
"(",
"chd",
")",
"->",
"totalhunks",
";",
"hunknum",
"++",
")",
"{",
"progress",
"(",
"hunknum",
"==",
"0",
",",
"\"",
"\\r",
"\"",
",",
"hunknum",
",",
"chd_get_header",
"(",
"chd",
")",
"->",
"totalhunks",
")",
";",
"err",
"=",
"chd_write",
"(",
"chd",
",",
"hunknum",
",",
"cache",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"}",
"progress",
"(",
"TRUE",
",",
"\"",
"\\n",
"\"",
")",
";",
"cleanup",
":",
"if",
"(",
"cache",
"!=",
"NULL",
")",
"free",
"(",
"cache",
")",
";",
"if",
"(",
"chd",
"!=",
"NULL",
")",
"chd_close",
"(",
"chd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"osd_rmfile",
"(",
"outputfile",
")",
";",
"return",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
";",
"}"
] | do_createblankhd - create a new non-compressed
hard disk image, with all hunks filled with 0s | [
"do_createblankhd",
"-",
"create",
"a",
"new",
"non",
"-",
"compressed",
"hard",
"disk",
"image",
"with",
"all",
"hunks",
"filled",
"with",
"0s"
] | [
"/* require 6, 7, or 8 args total */",
"/* extract the data */",
"/* print some info */",
"/* create the new hard drive */",
"/* open the new hard drive */",
"/* write the metadata */",
"/* alloc and zero buffer*/",
"/* Zero every hunk */",
"/* progress */",
"/* write out the data */",
"/* close everything down */"
] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
},
{
"param": "param",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "argc",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "argv",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "param",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d835fd6445aba612019120fc378673b23aba8150 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/chdman.c | [
"Unlicense"
] | C | do_copydata | int | static int do_copydata(int argc, char *argv[], int param)
{
const char *inputfile, *outputfile;
chd_file *outputchd = NULL;
chd_file *inputchd = NULL;
chd_error err;
/* require 4 args total */
if (argc != 4)
return usage();
/* extract the data */
inputfile = argv[2];
outputfile = argv[3];
/* print some info */
printf("Input file: %s\n", inputfile);
printf("Output file: %s\n", outputfile);
/* open the src hard drive */
err = chd_open(inputfile, CHD_OPEN_READ, NULL, &inputchd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening src CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
/* open the dest hard drive */
err = chd_open(outputfile, CHD_OPEN_READWRITE, NULL, &outputchd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening dest CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
/* compress the source into the dest */
err = chdman_compress_chd(outputchd, inputchd, 0);
if (err != CHDERR_NONE)
fprintf(stderr, "Error during compression: %s\n", chd_error_string(err));
cleanup:
/* close everything down */
if (outputchd != NULL)
chd_close(outputchd);
if (inputchd != NULL)
chd_close(inputchd);
if (err != CHDERR_NONE)
osd_rmfile(outputfile);
return (err != CHDERR_NONE);
} | /*-------------------------------------------------
do_copydata - copy all hunks of data from one
CHD file to another. The hunk sizes do not
need to match. If the source is shorter than
the destination, the source data will be
padded with 0s.
-------------------------------------------------*/ | copy all hunks of data from one
CHD file to another. The hunk sizes do not
need to match. If the source is shorter than
the destination, the source data will be
padded with 0s. | [
"copy",
"all",
"hunks",
"of",
"data",
"from",
"one",
"CHD",
"file",
"to",
"another",
".",
"The",
"hunk",
"sizes",
"do",
"not",
"need",
"to",
"match",
".",
"If",
"the",
"source",
"is",
"shorter",
"than",
"the",
"destination",
"the",
"source",
"data",
"will",
"be",
"padded",
"with",
"0s",
"."
] | static int do_copydata(int argc, char *argv[], int param)
{
const char *inputfile, *outputfile;
chd_file *outputchd = NULL;
chd_file *inputchd = NULL;
chd_error err;
if (argc != 4)
return usage();
inputfile = argv[2];
outputfile = argv[3];
printf("Input file: %s\n", inputfile);
printf("Output file: %s\n", outputfile);
err = chd_open(inputfile, CHD_OPEN_READ, NULL, &inputchd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening src CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
err = chd_open(outputfile, CHD_OPEN_READWRITE, NULL, &outputchd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening dest CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
err = chdman_compress_chd(outputchd, inputchd, 0);
if (err != CHDERR_NONE)
fprintf(stderr, "Error during compression: %s\n", chd_error_string(err));
cleanup:
if (outputchd != NULL)
chd_close(outputchd);
if (inputchd != NULL)
chd_close(inputchd);
if (err != CHDERR_NONE)
osd_rmfile(outputfile);
return (err != CHDERR_NONE);
} | [
"static",
"int",
"do_copydata",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
",",
"int",
"param",
")",
"{",
"const",
"char",
"*",
"inputfile",
",",
"*",
"outputfile",
";",
"chd_file",
"*",
"outputchd",
"=",
"NULL",
";",
"chd_file",
"*",
"inputchd",
"=",
"NULL",
";",
"chd_error",
"err",
";",
"if",
"(",
"argc",
"!=",
"4",
")",
"return",
"usage",
"(",
")",
";",
"inputfile",
"=",
"argv",
"[",
"2",
"]",
";",
"outputfile",
"=",
"argv",
"[",
"3",
"]",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"inputfile",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"outputfile",
")",
";",
"err",
"=",
"chd_open",
"(",
"inputfile",
",",
"CHD_OPEN_READ",
",",
"NULL",
",",
"&",
"inputchd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"chd_open",
"(",
"outputfile",
",",
"CHD_OPEN_READWRITE",
",",
"NULL",
",",
"&",
"outputchd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"chdman_compress_chd",
"(",
"outputchd",
",",
"inputchd",
",",
"0",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"cleanup",
":",
"if",
"(",
"outputchd",
"!=",
"NULL",
")",
"chd_close",
"(",
"outputchd",
")",
";",
"if",
"(",
"inputchd",
"!=",
"NULL",
")",
"chd_close",
"(",
"inputchd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"osd_rmfile",
"(",
"outputfile",
")",
";",
"return",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
";",
"}"
] | do_copydata - copy all hunks of data from one
CHD file to another. | [
"do_copydata",
"-",
"copy",
"all",
"hunks",
"of",
"data",
"from",
"one",
"CHD",
"file",
"to",
"another",
"."
] | [
"/* require 4 args total */",
"/* extract the data */",
"/* print some info */",
"/* open the src hard drive */",
"/* open the dest hard drive */",
"/* compress the source into the dest */",
"/* close everything down */"
] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
},
{
"param": "param",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "argc",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "argv",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "param",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d835fd6445aba612019120fc378673b23aba8150 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/chdman.c | [
"Unlicense"
] | C | do_extract | int | static int do_extract(int argc, char *argv[], int param)
{
const char *inputfile, *outputfile;
core_file *outfile = NULL;
chd_file *infile = NULL;
const chd_header *header;
UINT64 bytesremaining;
void *hunk = NULL;
file_error filerr;
chd_error err;
int hunknum;
/* require 4 args total */
if (argc != 4)
return usage();
/* extract the data */
inputfile = argv[2];
outputfile = argv[3];
/* print some info */
printf("Input file: %s\n", inputfile);
printf("Output file: %s\n", outputfile);
/* get the header */
err = chd_open(inputfile, CHD_OPEN_READ, NULL, &infile);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening CHD file '%s': %s\n", inputfile, chd_error_string(err));
goto cleanup;
}
header = chd_get_header(infile);
/* allocate memory to hold a hunk */
hunk = malloc(header->hunkbytes);
if (hunk == NULL)
{
fprintf(stderr, "Out of memory allocating hunk buffer!\n");
err = CHDERR_OUT_OF_MEMORY;
goto cleanup;
}
/* create the output file */
filerr = core_fopen(outputfile, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &outfile);
if (filerr != FILERR_NONE)
{
fprintf(stderr, "Error opening output file '%s'\n", outputfile);
err = CHDERR_CANT_CREATE_FILE;
goto cleanup;
}
/* loop over hunks, reading and writing */
bytesremaining = header->logicalbytes;
for (hunknum = 0; hunknum < header->totalhunks; hunknum++)
{
UINT32 byteswritten, bytes_to_write;
/* progress */
progress(hunknum == 0, "Extracting hunk %d/%d... \r", hunknum, header->totalhunks);
/* read the hunk into a buffer */
err = chd_read(infile, hunknum, hunk);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error reading hunk %d from CHD file: %s\n", hunknum, chd_error_string(err));
goto cleanup;
}
/* write the hunk to the file */
bytes_to_write = MIN(bytesremaining, header->hunkbytes);
core_fseek(outfile, (UINT64)hunknum * (UINT64)header->hunkbytes, SEEK_SET);
byteswritten = core_fwrite(outfile, hunk, bytes_to_write);
if (byteswritten != bytes_to_write)
{
fprintf(stderr, "Error writing hunk %d to output file: %s\n", hunknum, chd_error_string(CHDERR_WRITE_ERROR));
err = CHDERR_WRITE_ERROR;
goto cleanup;
}
bytesremaining -= byteswritten;
}
progress(TRUE, "Extraction complete! \n");
cleanup:
/* clean up our mess */
if (outfile != NULL)
core_fclose(outfile);
if (hunk != NULL)
free(hunk);
if (infile != NULL)
chd_close(infile);
if (err != CHDERR_NONE)
osd_rmfile(outputfile);
return (err != CHDERR_NONE);
} | /*-------------------------------------------------
do_extract - extract a raw file from a
CHD image
-------------------------------------------------*/ | extract a raw file from a
CHD image | [
"extract",
"a",
"raw",
"file",
"from",
"a",
"CHD",
"image"
] | static int do_extract(int argc, char *argv[], int param)
{
const char *inputfile, *outputfile;
core_file *outfile = NULL;
chd_file *infile = NULL;
const chd_header *header;
UINT64 bytesremaining;
void *hunk = NULL;
file_error filerr;
chd_error err;
int hunknum;
if (argc != 4)
return usage();
inputfile = argv[2];
outputfile = argv[3];
printf("Input file: %s\n", inputfile);
printf("Output file: %s\n", outputfile);
err = chd_open(inputfile, CHD_OPEN_READ, NULL, &infile);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening CHD file '%s': %s\n", inputfile, chd_error_string(err));
goto cleanup;
}
header = chd_get_header(infile);
hunk = malloc(header->hunkbytes);
if (hunk == NULL)
{
fprintf(stderr, "Out of memory allocating hunk buffer!\n");
err = CHDERR_OUT_OF_MEMORY;
goto cleanup;
}
filerr = core_fopen(outputfile, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &outfile);
if (filerr != FILERR_NONE)
{
fprintf(stderr, "Error opening output file '%s'\n", outputfile);
err = CHDERR_CANT_CREATE_FILE;
goto cleanup;
}
bytesremaining = header->logicalbytes;
for (hunknum = 0; hunknum < header->totalhunks; hunknum++)
{
UINT32 byteswritten, bytes_to_write;
progress(hunknum == 0, "Extracting hunk %d/%d... \r", hunknum, header->totalhunks);
err = chd_read(infile, hunknum, hunk);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error reading hunk %d from CHD file: %s\n", hunknum, chd_error_string(err));
goto cleanup;
}
bytes_to_write = MIN(bytesremaining, header->hunkbytes);
core_fseek(outfile, (UINT64)hunknum * (UINT64)header->hunkbytes, SEEK_SET);
byteswritten = core_fwrite(outfile, hunk, bytes_to_write);
if (byteswritten != bytes_to_write)
{
fprintf(stderr, "Error writing hunk %d to output file: %s\n", hunknum, chd_error_string(CHDERR_WRITE_ERROR));
err = CHDERR_WRITE_ERROR;
goto cleanup;
}
bytesremaining -= byteswritten;
}
progress(TRUE, "Extraction complete! \n");
cleanup:
if (outfile != NULL)
core_fclose(outfile);
if (hunk != NULL)
free(hunk);
if (infile != NULL)
chd_close(infile);
if (err != CHDERR_NONE)
osd_rmfile(outputfile);
return (err != CHDERR_NONE);
} | [
"static",
"int",
"do_extract",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
",",
"int",
"param",
")",
"{",
"const",
"char",
"*",
"inputfile",
",",
"*",
"outputfile",
";",
"core_file",
"*",
"outfile",
"=",
"NULL",
";",
"chd_file",
"*",
"infile",
"=",
"NULL",
";",
"const",
"chd_header",
"*",
"header",
";",
"UINT64",
"bytesremaining",
";",
"void",
"*",
"hunk",
"=",
"NULL",
";",
"file_error",
"filerr",
";",
"chd_error",
"err",
";",
"int",
"hunknum",
";",
"if",
"(",
"argc",
"!=",
"4",
")",
"return",
"usage",
"(",
")",
";",
"inputfile",
"=",
"argv",
"[",
"2",
"]",
";",
"outputfile",
"=",
"argv",
"[",
"3",
"]",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"inputfile",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"outputfile",
")",
";",
"err",
"=",
"chd_open",
"(",
"inputfile",
",",
"CHD_OPEN_READ",
",",
"NULL",
",",
"&",
"infile",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"inputfile",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"header",
"=",
"chd_get_header",
"(",
"infile",
")",
";",
"hunk",
"=",
"malloc",
"(",
"header",
"->",
"hunkbytes",
")",
";",
"if",
"(",
"hunk",
"==",
"NULL",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
")",
";",
"err",
"=",
"CHDERR_OUT_OF_MEMORY",
";",
"goto",
"cleanup",
";",
"}",
"filerr",
"=",
"core_fopen",
"(",
"outputfile",
",",
"OPEN_FLAG_WRITE",
"|",
"OPEN_FLAG_CREATE",
",",
"&",
"outfile",
")",
";",
"if",
"(",
"filerr",
"!=",
"FILERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"outputfile",
")",
";",
"err",
"=",
"CHDERR_CANT_CREATE_FILE",
";",
"goto",
"cleanup",
";",
"}",
"bytesremaining",
"=",
"header",
"->",
"logicalbytes",
";",
"for",
"(",
"hunknum",
"=",
"0",
";",
"hunknum",
"<",
"header",
"->",
"totalhunks",
";",
"hunknum",
"++",
")",
"{",
"UINT32",
"byteswritten",
",",
"bytes_to_write",
";",
"progress",
"(",
"hunknum",
"==",
"0",
",",
"\"",
"\\r",
"\"",
",",
"hunknum",
",",
"header",
"->",
"totalhunks",
")",
";",
"err",
"=",
"chd_read",
"(",
"infile",
",",
"hunknum",
",",
"hunk",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"hunknum",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"bytes_to_write",
"=",
"MIN",
"(",
"bytesremaining",
",",
"header",
"->",
"hunkbytes",
")",
";",
"core_fseek",
"(",
"outfile",
",",
"(",
"UINT64",
")",
"hunknum",
"*",
"(",
"UINT64",
")",
"header",
"->",
"hunkbytes",
",",
"SEEK_SET",
")",
";",
"byteswritten",
"=",
"core_fwrite",
"(",
"outfile",
",",
"hunk",
",",
"bytes_to_write",
")",
";",
"if",
"(",
"byteswritten",
"!=",
"bytes_to_write",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"hunknum",
",",
"chd_error_string",
"(",
"CHDERR_WRITE_ERROR",
")",
")",
";",
"err",
"=",
"CHDERR_WRITE_ERROR",
";",
"goto",
"cleanup",
";",
"}",
"bytesremaining",
"-=",
"byteswritten",
";",
"}",
"progress",
"(",
"TRUE",
",",
"\"",
"\\n",
"\"",
")",
";",
"cleanup",
":",
"if",
"(",
"outfile",
"!=",
"NULL",
")",
"core_fclose",
"(",
"outfile",
")",
";",
"if",
"(",
"hunk",
"!=",
"NULL",
")",
"free",
"(",
"hunk",
")",
";",
"if",
"(",
"infile",
"!=",
"NULL",
")",
"chd_close",
"(",
"infile",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"osd_rmfile",
"(",
"outputfile",
")",
";",
"return",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
";",
"}"
] | do_extract - extract a raw file from a
CHD image | [
"do_extract",
"-",
"extract",
"a",
"raw",
"file",
"from",
"a",
"CHD",
"image"
] | [
"/* require 4 args total */",
"/* extract the data */",
"/* print some info */",
"/* get the header */",
"/* allocate memory to hold a hunk */",
"/* create the output file */",
"/* loop over hunks, reading and writing */",
"/* progress */",
"/* read the hunk into a buffer */",
"/* write the hunk to the file */",
"/* clean up our mess */"
] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
},
{
"param": "param",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "argc",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "argv",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "param",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d835fd6445aba612019120fc378673b23aba8150 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/chdman.c | [
"Unlicense"
] | C | do_verify | int | static int do_verify(int argc, char *argv[], int param)
{
chd_verify_result verify;
const char *inputfile;
chd_file *chd = NULL;
chd_header header;
int fixed = FALSE;
chd_error err;
int i;
/* require 3 args total */
if (argc != 3)
return usage();
/* extract the data */
inputfile = argv[2];
/* print some info */
printf("Input file: %s\n", inputfile);
/* open the CHD file */
err = chd_open(inputfile, CHD_OPEN_READ, NULL, &chd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
header = *chd_get_header(chd);
/* verify the CHD data */
err = chd_verify_begin(chd);
if (err == CHDERR_NONE)
{
UINT32 hunknum;
for (hunknum = 0; hunknum < header.totalhunks; hunknum++)
{
/* progress */
progress(FALSE, "Verifying hunk %d/%d... \r", hunknum, header.totalhunks);
/* verify the data */
err = chd_verify_hunk(chd);
if (err != CHDERR_NONE)
break;
}
/* finish it */
if (err == CHDERR_NONE)
err = chd_verify_finish(chd, &verify);
}
/* handle errors */
if (err != CHDERR_NONE)
{
if (err == CHDERR_CANT_VERIFY)
fprintf(stderr, "Can't verify this type of image (probably writeable)\n");
else
fprintf(stderr, "\nError during verify: %s\n", chd_error_string(err));
goto cleanup;
}
/* verify the MD5 */
if (header.version <= 3)
{
if (memcmp(header.md5, verify.md5, sizeof(header.md5)) == 0)
printf("MD5 verification successful!\n");
else
{
fprintf(stderr, "Error: MD5 in header = ");
for (i = 0; i < CHD_MD5_BYTES; i++)
fprintf(stderr, "%02x", header.md5[i]);
fprintf(stderr, "\n");
fprintf(stderr, " actual MD5 = ");
for (i = 0; i < CHD_MD5_BYTES; i++)
fprintf(stderr, "%02x", verify.md5[i]);
fprintf(stderr, "\n");
/* fix it */
if (param)
{
memcpy(header.md5, verify.md5, sizeof(header.md5));
fixed = TRUE;
}
}
}
/* verify the SHA1 */
if (header.version >= 3)
{
if (memcmp(header.sha1, verify.sha1, sizeof(header.sha1)) == 0)
printf("SHA1 verification successful!\n");
else
{
fprintf(stderr, "Error: SHA1 in header = ");
for (i = 0; i < CHD_SHA1_BYTES; i++)
fprintf(stderr, "%02x", header.sha1[i]);
fprintf(stderr, "\n");
fprintf(stderr, " actual SHA1 = ");
for (i = 0; i < CHD_SHA1_BYTES; i++)
fprintf(stderr, "%02x", verify.sha1[i]);
fprintf(stderr, "\n");
/* fix it */
if (param)
{
memcpy(header.sha1, verify.sha1, sizeof(header.sha1));
fixed = TRUE;
}
/* verify the raw SHA1 */
if (header.version >= 4)
{
if (memcmp(header.rawsha1, verify.rawsha1, sizeof(header.rawsha1)) != 0)
{
fprintf(stderr, "Error: raw SHA1 in header = ");
for (i = 0; i < CHD_SHA1_BYTES; i++)
fprintf(stderr, "%02x", header.rawsha1[i]);
fprintf(stderr, "\n");
fprintf(stderr, " actual raw SHA1 = ");
for (i = 0; i < CHD_SHA1_BYTES; i++)
fprintf(stderr, "%02x", verify.rawsha1[i]);
fprintf(stderr, "\n");
/* fix it */
if (param)
{
memcpy(header.rawsha1, verify.rawsha1, sizeof(header.rawsha1));
fixed = TRUE;
}
}
}
}
}
/* close the drive */
chd_close(chd);
chd = NULL;
/* update the header */
if (fixed)
{
err = chd_set_header(inputfile, &header);
if (err != CHDERR_NONE)
fprintf(stderr, "Error writing new header: %s\n", chd_error_string(err));
else
printf("Updated header successfully\n");
}
cleanup:
/* close everything down */
if (chd != NULL)
chd_close(chd);
return (err != CHDERR_NONE);
} | /*-------------------------------------------------
do_verify - validate the MD5/SHA1 on a drive
image
-------------------------------------------------*/ | validate the MD5/SHA1 on a drive
image | [
"validate",
"the",
"MD5",
"/",
"SHA1",
"on",
"a",
"drive",
"image"
] | static int do_verify(int argc, char *argv[], int param)
{
chd_verify_result verify;
const char *inputfile;
chd_file *chd = NULL;
chd_header header;
int fixed = FALSE;
chd_error err;
int i;
if (argc != 3)
return usage();
inputfile = argv[2];
printf("Input file: %s\n", inputfile);
err = chd_open(inputfile, CHD_OPEN_READ, NULL, &chd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
header = *chd_get_header(chd);
err = chd_verify_begin(chd);
if (err == CHDERR_NONE)
{
UINT32 hunknum;
for (hunknum = 0; hunknum < header.totalhunks; hunknum++)
{
progress(FALSE, "Verifying hunk %d/%d... \r", hunknum, header.totalhunks);
err = chd_verify_hunk(chd);
if (err != CHDERR_NONE)
break;
}
if (err == CHDERR_NONE)
err = chd_verify_finish(chd, &verify);
}
if (err != CHDERR_NONE)
{
if (err == CHDERR_CANT_VERIFY)
fprintf(stderr, "Can't verify this type of image (probably writeable)\n");
else
fprintf(stderr, "\nError during verify: %s\n", chd_error_string(err));
goto cleanup;
}
if (header.version <= 3)
{
if (memcmp(header.md5, verify.md5, sizeof(header.md5)) == 0)
printf("MD5 verification successful!\n");
else
{
fprintf(stderr, "Error: MD5 in header = ");
for (i = 0; i < CHD_MD5_BYTES; i++)
fprintf(stderr, "%02x", header.md5[i]);
fprintf(stderr, "\n");
fprintf(stderr, " actual MD5 = ");
for (i = 0; i < CHD_MD5_BYTES; i++)
fprintf(stderr, "%02x", verify.md5[i]);
fprintf(stderr, "\n");
if (param)
{
memcpy(header.md5, verify.md5, sizeof(header.md5));
fixed = TRUE;
}
}
}
if (header.version >= 3)
{
if (memcmp(header.sha1, verify.sha1, sizeof(header.sha1)) == 0)
printf("SHA1 verification successful!\n");
else
{
fprintf(stderr, "Error: SHA1 in header = ");
for (i = 0; i < CHD_SHA1_BYTES; i++)
fprintf(stderr, "%02x", header.sha1[i]);
fprintf(stderr, "\n");
fprintf(stderr, " actual SHA1 = ");
for (i = 0; i < CHD_SHA1_BYTES; i++)
fprintf(stderr, "%02x", verify.sha1[i]);
fprintf(stderr, "\n");
if (param)
{
memcpy(header.sha1, verify.sha1, sizeof(header.sha1));
fixed = TRUE;
}
if (header.version >= 4)
{
if (memcmp(header.rawsha1, verify.rawsha1, sizeof(header.rawsha1)) != 0)
{
fprintf(stderr, "Error: raw SHA1 in header = ");
for (i = 0; i < CHD_SHA1_BYTES; i++)
fprintf(stderr, "%02x", header.rawsha1[i]);
fprintf(stderr, "\n");
fprintf(stderr, " actual raw SHA1 = ");
for (i = 0; i < CHD_SHA1_BYTES; i++)
fprintf(stderr, "%02x", verify.rawsha1[i]);
fprintf(stderr, "\n");
if (param)
{
memcpy(header.rawsha1, verify.rawsha1, sizeof(header.rawsha1));
fixed = TRUE;
}
}
}
}
}
chd_close(chd);
chd = NULL;
if (fixed)
{
err = chd_set_header(inputfile, &header);
if (err != CHDERR_NONE)
fprintf(stderr, "Error writing new header: %s\n", chd_error_string(err));
else
printf("Updated header successfully\n");
}
cleanup:
if (chd != NULL)
chd_close(chd);
return (err != CHDERR_NONE);
} | [
"static",
"int",
"do_verify",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
",",
"int",
"param",
")",
"{",
"chd_verify_result",
"verify",
";",
"const",
"char",
"*",
"inputfile",
";",
"chd_file",
"*",
"chd",
"=",
"NULL",
";",
"chd_header",
"header",
";",
"int",
"fixed",
"=",
"FALSE",
";",
"chd_error",
"err",
";",
"int",
"i",
";",
"if",
"(",
"argc",
"!=",
"3",
")",
"return",
"usage",
"(",
")",
";",
"inputfile",
"=",
"argv",
"[",
"2",
"]",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"inputfile",
")",
";",
"err",
"=",
"chd_open",
"(",
"inputfile",
",",
"CHD_OPEN_READ",
",",
"NULL",
",",
"&",
"chd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"header",
"=",
"*",
"chd_get_header",
"(",
"chd",
")",
";",
"err",
"=",
"chd_verify_begin",
"(",
"chd",
")",
";",
"if",
"(",
"err",
"==",
"CHDERR_NONE",
")",
"{",
"UINT32",
"hunknum",
";",
"for",
"(",
"hunknum",
"=",
"0",
";",
"hunknum",
"<",
"header",
".",
"totalhunks",
";",
"hunknum",
"++",
")",
"{",
"progress",
"(",
"FALSE",
",",
"\"",
"\\r",
"\"",
",",
"hunknum",
",",
"header",
".",
"totalhunks",
")",
";",
"err",
"=",
"chd_verify_hunk",
"(",
"chd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"break",
";",
"}",
"if",
"(",
"err",
"==",
"CHDERR_NONE",
")",
"err",
"=",
"chd_verify_finish",
"(",
"chd",
",",
"&",
"verify",
")",
";",
"}",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"if",
"(",
"err",
"==",
"CHDERR_CANT_VERIFY",
")",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
")",
";",
"else",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"if",
"(",
"header",
".",
"version",
"<=",
"3",
")",
"{",
"if",
"(",
"memcmp",
"(",
"header",
".",
"md5",
",",
"verify",
".",
"md5",
",",
"sizeof",
"(",
"header",
".",
"md5",
")",
")",
"==",
"0",
")",
"printf",
"(",
"\"",
"\\n",
"\"",
")",
";",
"else",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\"",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"CHD_MD5_BYTES",
";",
"i",
"++",
")",
"fprintf",
"(",
"stderr",
",",
"\"",
"\"",
",",
"header",
".",
"md5",
"[",
"i",
"]",
")",
";",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
")",
";",
"fprintf",
"(",
"stderr",
",",
"\"",
"\"",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"CHD_MD5_BYTES",
";",
"i",
"++",
")",
"fprintf",
"(",
"stderr",
",",
"\"",
"\"",
",",
"verify",
".",
"md5",
"[",
"i",
"]",
")",
";",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
")",
";",
"if",
"(",
"param",
")",
"{",
"memcpy",
"(",
"header",
".",
"md5",
",",
"verify",
".",
"md5",
",",
"sizeof",
"(",
"header",
".",
"md5",
")",
")",
";",
"fixed",
"=",
"TRUE",
";",
"}",
"}",
"}",
"if",
"(",
"header",
".",
"version",
">=",
"3",
")",
"{",
"if",
"(",
"memcmp",
"(",
"header",
".",
"sha1",
",",
"verify",
".",
"sha1",
",",
"sizeof",
"(",
"header",
".",
"sha1",
")",
")",
"==",
"0",
")",
"printf",
"(",
"\"",
"\\n",
"\"",
")",
";",
"else",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\"",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"CHD_SHA1_BYTES",
";",
"i",
"++",
")",
"fprintf",
"(",
"stderr",
",",
"\"",
"\"",
",",
"header",
".",
"sha1",
"[",
"i",
"]",
")",
";",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
")",
";",
"fprintf",
"(",
"stderr",
",",
"\"",
"\"",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"CHD_SHA1_BYTES",
";",
"i",
"++",
")",
"fprintf",
"(",
"stderr",
",",
"\"",
"\"",
",",
"verify",
".",
"sha1",
"[",
"i",
"]",
")",
";",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
")",
";",
"if",
"(",
"param",
")",
"{",
"memcpy",
"(",
"header",
".",
"sha1",
",",
"verify",
".",
"sha1",
",",
"sizeof",
"(",
"header",
".",
"sha1",
")",
")",
";",
"fixed",
"=",
"TRUE",
";",
"}",
"if",
"(",
"header",
".",
"version",
">=",
"4",
")",
"{",
"if",
"(",
"memcmp",
"(",
"header",
".",
"rawsha1",
",",
"verify",
".",
"rawsha1",
",",
"sizeof",
"(",
"header",
".",
"rawsha1",
")",
")",
"!=",
"0",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\"",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"CHD_SHA1_BYTES",
";",
"i",
"++",
")",
"fprintf",
"(",
"stderr",
",",
"\"",
"\"",
",",
"header",
".",
"rawsha1",
"[",
"i",
"]",
")",
";",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
")",
";",
"fprintf",
"(",
"stderr",
",",
"\"",
"\"",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"CHD_SHA1_BYTES",
";",
"i",
"++",
")",
"fprintf",
"(",
"stderr",
",",
"\"",
"\"",
",",
"verify",
".",
"rawsha1",
"[",
"i",
"]",
")",
";",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
")",
";",
"if",
"(",
"param",
")",
"{",
"memcpy",
"(",
"header",
".",
"rawsha1",
",",
"verify",
".",
"rawsha1",
",",
"sizeof",
"(",
"header",
".",
"rawsha1",
")",
")",
";",
"fixed",
"=",
"TRUE",
";",
"}",
"}",
"}",
"}",
"}",
"chd_close",
"(",
"chd",
")",
";",
"chd",
"=",
"NULL",
";",
"if",
"(",
"fixed",
")",
"{",
"err",
"=",
"chd_set_header",
"(",
"inputfile",
",",
"&",
"header",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"else",
"printf",
"(",
"\"",
"\\n",
"\"",
")",
";",
"}",
"cleanup",
":",
"if",
"(",
"chd",
"!=",
"NULL",
")",
"chd_close",
"(",
"chd",
")",
";",
"return",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
";",
"}"
] | do_verify - validate the MD5/SHA1 on a drive
image | [
"do_verify",
"-",
"validate",
"the",
"MD5",
"/",
"SHA1",
"on",
"a",
"drive",
"image"
] | [
"/* require 3 args total */",
"/* extract the data */",
"/* print some info */",
"/* open the CHD file */",
"/* verify the CHD data */",
"/* progress */",
"/* verify the data */",
"/* finish it */",
"/* handle errors */",
"/* verify the MD5 */",
"/* fix it */",
"/* verify the SHA1 */",
"/* fix it */",
"/* verify the raw SHA1 */",
"/* fix it */",
"/* close the drive */",
"/* update the header */",
"/* close everything down */"
] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
},
{
"param": "param",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "argc",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "argv",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "param",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d835fd6445aba612019120fc378673b23aba8150 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/chdman.c | [
"Unlicense"
] | C | do_merge_update_chomp | int | static int do_merge_update_chomp(int argc, char *argv[], int param)
{
const char *parentfile, *inputfile, *outputfile;
const chd_header *inputheader;
chd_file *parentchd = NULL;
chd_file *outputchd = NULL;
chd_file *inputchd = NULL;
UINT32 maxhunk = ~0;
chd_error err;
/* require 4-5 args total */
if (param == OPERATION_UPDATE && argc != 4)
return usage();
if ((param == OPERATION_MERGE || param == OPERATION_CHOMP) && argc != 5)
return usage();
/* extract the data */
if (param == OPERATION_MERGE)
{
parentfile = argv[2];
inputfile = argv[3];
outputfile = argv[4];
}
else
{
parentfile = NULL;
inputfile = argv[2];
outputfile = argv[3];
if (param == OPERATION_CHOMP)
maxhunk = atoi(argv[4]);
}
/* print some info */
if (parentfile != NULL)
{
printf("Parent file: %s\n", parentfile);
printf("Diff file: %s\n", inputfile);
}
else
printf("Input file: %s\n", inputfile);
printf("Output file: %s\n", outputfile);
if (param == OPERATION_CHOMP)
printf("Maximum hunk: %d\n", maxhunk);
/* open the parent CHD */
if (parentfile != NULL)
{
err = chd_open(parentfile, CHD_OPEN_READ, NULL, &parentchd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening CHD file '%s': %s\n", parentfile, chd_error_string(err));
goto cleanup;
}
}
/* open the diff CHD */
err = chd_open(inputfile, CHD_OPEN_READ, parentchd, &inputchd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening CHD file '%s': %s\n", inputfile, chd_error_string(err));
goto cleanup;
}
inputheader = chd_get_header(inputchd);
#if ENABLE_CUSTOM_CHOMP
/* if we're chomping with a auto parameter, now is the time to figure it out */
if (param == OPERATION_CHOMP && maxhunk == 0)
if (handle_custom_chomp(argv[4], inputchd, &maxhunk) != CHDERR_NONE)
return 1;
#endif
/* create the new merged CHD */
err = chd_create(outputfile, inputheader->logicalbytes, inputheader->hunkbytes, inputheader->compression, NULL);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error creating CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
/* open the new CHD */
err = chd_open(outputfile, CHD_OPEN_READWRITE, NULL, &outputchd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening new CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
/* clone the metadata from the input file (which should have inherited from the parent) */
err = chdman_clone_metadata(inputchd, outputchd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error cloning metadata: %s\n", chd_error_string(err));
goto cleanup;
}
/* do the compression; our interface will route reads for us */
err = chdman_compress_chd(outputchd, inputchd, (param == OPERATION_CHOMP) ? (maxhunk + 1) : 0);
if (err != CHDERR_NONE)
fprintf(stderr, "Error during compression: %s\n", chd_error_string(err));
cleanup:
/* close everything down */
if (outputchd != NULL)
chd_close(outputchd);
if (inputchd != NULL)
chd_close(inputchd);
if (parentchd != NULL)
chd_close(parentchd);
if (err != CHDERR_NONE)
osd_rmfile(outputfile);
return (err != CHDERR_NONE);
} | /*-------------------------------------------------
do_merge_update_chomp - merge a parent and its
child together (also works for update & chomp)
-------------------------------------------------*/ | merge a parent and its
child together (also works for update & chomp) | [
"merge",
"a",
"parent",
"and",
"its",
"child",
"together",
"(",
"also",
"works",
"for",
"update",
"&",
"chomp",
")"
] | static int do_merge_update_chomp(int argc, char *argv[], int param)
{
const char *parentfile, *inputfile, *outputfile;
const chd_header *inputheader;
chd_file *parentchd = NULL;
chd_file *outputchd = NULL;
chd_file *inputchd = NULL;
UINT32 maxhunk = ~0;
chd_error err;
if (param == OPERATION_UPDATE && argc != 4)
return usage();
if ((param == OPERATION_MERGE || param == OPERATION_CHOMP) && argc != 5)
return usage();
if (param == OPERATION_MERGE)
{
parentfile = argv[2];
inputfile = argv[3];
outputfile = argv[4];
}
else
{
parentfile = NULL;
inputfile = argv[2];
outputfile = argv[3];
if (param == OPERATION_CHOMP)
maxhunk = atoi(argv[4]);
}
if (parentfile != NULL)
{
printf("Parent file: %s\n", parentfile);
printf("Diff file: %s\n", inputfile);
}
else
printf("Input file: %s\n", inputfile);
printf("Output file: %s\n", outputfile);
if (param == OPERATION_CHOMP)
printf("Maximum hunk: %d\n", maxhunk);
if (parentfile != NULL)
{
err = chd_open(parentfile, CHD_OPEN_READ, NULL, &parentchd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening CHD file '%s': %s\n", parentfile, chd_error_string(err));
goto cleanup;
}
}
err = chd_open(inputfile, CHD_OPEN_READ, parentchd, &inputchd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening CHD file '%s': %s\n", inputfile, chd_error_string(err));
goto cleanup;
}
inputheader = chd_get_header(inputchd);
#if ENABLE_CUSTOM_CHOMP
if (param == OPERATION_CHOMP && maxhunk == 0)
if (handle_custom_chomp(argv[4], inputchd, &maxhunk) != CHDERR_NONE)
return 1;
#endif
err = chd_create(outputfile, inputheader->logicalbytes, inputheader->hunkbytes, inputheader->compression, NULL);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error creating CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
err = chd_open(outputfile, CHD_OPEN_READWRITE, NULL, &outputchd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening new CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
err = chdman_clone_metadata(inputchd, outputchd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error cloning metadata: %s\n", chd_error_string(err));
goto cleanup;
}
err = chdman_compress_chd(outputchd, inputchd, (param == OPERATION_CHOMP) ? (maxhunk + 1) : 0);
if (err != CHDERR_NONE)
fprintf(stderr, "Error during compression: %s\n", chd_error_string(err));
cleanup:
if (outputchd != NULL)
chd_close(outputchd);
if (inputchd != NULL)
chd_close(inputchd);
if (parentchd != NULL)
chd_close(parentchd);
if (err != CHDERR_NONE)
osd_rmfile(outputfile);
return (err != CHDERR_NONE);
} | [
"static",
"int",
"do_merge_update_chomp",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
",",
"int",
"param",
")",
"{",
"const",
"char",
"*",
"parentfile",
",",
"*",
"inputfile",
",",
"*",
"outputfile",
";",
"const",
"chd_header",
"*",
"inputheader",
";",
"chd_file",
"*",
"parentchd",
"=",
"NULL",
";",
"chd_file",
"*",
"outputchd",
"=",
"NULL",
";",
"chd_file",
"*",
"inputchd",
"=",
"NULL",
";",
"UINT32",
"maxhunk",
"=",
"~",
"0",
";",
"chd_error",
"err",
";",
"if",
"(",
"param",
"==",
"OPERATION_UPDATE",
"&&",
"argc",
"!=",
"4",
")",
"return",
"usage",
"(",
")",
";",
"if",
"(",
"(",
"param",
"==",
"OPERATION_MERGE",
"||",
"param",
"==",
"OPERATION_CHOMP",
")",
"&&",
"argc",
"!=",
"5",
")",
"return",
"usage",
"(",
")",
";",
"if",
"(",
"param",
"==",
"OPERATION_MERGE",
")",
"{",
"parentfile",
"=",
"argv",
"[",
"2",
"]",
";",
"inputfile",
"=",
"argv",
"[",
"3",
"]",
";",
"outputfile",
"=",
"argv",
"[",
"4",
"]",
";",
"}",
"else",
"{",
"parentfile",
"=",
"NULL",
";",
"inputfile",
"=",
"argv",
"[",
"2",
"]",
";",
"outputfile",
"=",
"argv",
"[",
"3",
"]",
";",
"if",
"(",
"param",
"==",
"OPERATION_CHOMP",
")",
"maxhunk",
"=",
"atoi",
"(",
"argv",
"[",
"4",
"]",
")",
";",
"}",
"if",
"(",
"parentfile",
"!=",
"NULL",
")",
"{",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"parentfile",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"inputfile",
")",
";",
"}",
"else",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"inputfile",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"outputfile",
")",
";",
"if",
"(",
"param",
"==",
"OPERATION_CHOMP",
")",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"maxhunk",
")",
";",
"if",
"(",
"parentfile",
"!=",
"NULL",
")",
"{",
"err",
"=",
"chd_open",
"(",
"parentfile",
",",
"CHD_OPEN_READ",
",",
"NULL",
",",
"&",
"parentchd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"parentfile",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"}",
"err",
"=",
"chd_open",
"(",
"inputfile",
",",
"CHD_OPEN_READ",
",",
"parentchd",
",",
"&",
"inputchd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"inputfile",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"inputheader",
"=",
"chd_get_header",
"(",
"inputchd",
")",
";",
"#if",
"ENABLE_CUSTOM_CHOMP",
"\n",
"if",
"(",
"param",
"==",
"OPERATION_CHOMP",
"&&",
"maxhunk",
"==",
"0",
")",
"if",
"(",
"handle_custom_chomp",
"(",
"argv",
"[",
"4",
"]",
",",
"inputchd",
",",
"&",
"maxhunk",
")",
"!=",
"CHDERR_NONE",
")",
"return",
"1",
";",
"#endif",
"err",
"=",
"chd_create",
"(",
"outputfile",
",",
"inputheader",
"->",
"logicalbytes",
",",
"inputheader",
"->",
"hunkbytes",
",",
"inputheader",
"->",
"compression",
",",
"NULL",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"chd_open",
"(",
"outputfile",
",",
"CHD_OPEN_READWRITE",
",",
"NULL",
",",
"&",
"outputchd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"chdman_clone_metadata",
"(",
"inputchd",
",",
"outputchd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"chdman_compress_chd",
"(",
"outputchd",
",",
"inputchd",
",",
"(",
"param",
"==",
"OPERATION_CHOMP",
")",
"?",
"(",
"maxhunk",
"+",
"1",
")",
":",
"0",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"cleanup",
":",
"if",
"(",
"outputchd",
"!=",
"NULL",
")",
"chd_close",
"(",
"outputchd",
")",
";",
"if",
"(",
"inputchd",
"!=",
"NULL",
")",
"chd_close",
"(",
"inputchd",
")",
";",
"if",
"(",
"parentchd",
"!=",
"NULL",
")",
"chd_close",
"(",
"parentchd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"osd_rmfile",
"(",
"outputfile",
")",
";",
"return",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
";",
"}"
] | do_merge_update_chomp - merge a parent and its
child together (also works for update & chomp) | [
"do_merge_update_chomp",
"-",
"merge",
"a",
"parent",
"and",
"its",
"child",
"together",
"(",
"also",
"works",
"for",
"update",
"&",
"chomp",
")"
] | [
"/* require 4-5 args total */",
"/* extract the data */",
"/* print some info */",
"/* open the parent CHD */",
"/* open the diff CHD */",
"/* if we're chomping with a auto parameter, now is the time to figure it out */",
"/* create the new merged CHD */",
"/* open the new CHD */",
"/* clone the metadata from the input file (which should have inherited from the parent) */",
"/* do the compression; our interface will route reads for us */",
"/* close everything down */"
] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
},
{
"param": "param",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "argc",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "argv",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "param",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d835fd6445aba612019120fc378673b23aba8150 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/chdman.c | [
"Unlicense"
] | C | do_diff | int | static int do_diff(int argc, char *argv[], int param)
{
const char *parentfile = NULL, *inputfile = NULL, *outputfile = NULL;
chd_file *parentchd = NULL;
chd_file *outputchd = NULL;
chd_file *inputchd = NULL;
chd_error err;
/* require 5 args total */
if (argc != 5)
return usage();
/* extract the data */
parentfile = argv[2];
inputfile = argv[3];
outputfile = argv[4];
/* print some info */
printf("Parent file: %s\n", parentfile);
printf("Input file: %s\n", inputfile);
printf("Diff file: %s\n", outputfile);
/* open the soon-to-be-parent CHD */
err = chd_open(parentfile, CHD_OPEN_READ, NULL, &parentchd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening CHD file '%s': %s\n", parentfile, chd_error_string(err));
goto cleanup;
}
/* open the input CHD */
err = chd_open(inputfile, CHD_OPEN_READ, NULL, &inputchd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening CHD file '%s': %s\n", inputfile, chd_error_string(err));
goto cleanup;
}
/* create the new CHD as a diff against the parent */
err = chd_create(outputfile, 0, 0, chd_get_header(parentchd)->compression, parentchd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error creating CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
/* open the new CHD */
err = chd_open(outputfile, CHD_OPEN_READWRITE, parentchd, &outputchd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening new CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
/* do the compression; our interface will route reads for us */
err = chdman_compress_chd(outputchd, inputchd, 0);
if (err != CHDERR_NONE)
fprintf(stderr, "Error during compression: %s\n", chd_error_string(err));
cleanup:
/* close everything down */
if (outputchd != NULL)
chd_close(outputchd);
if (inputchd != NULL)
chd_close(inputchd);
if (parentchd != NULL)
chd_close(parentchd);
if (err != CHDERR_NONE)
osd_rmfile(outputfile);
return (err != CHDERR_NONE);
} | /*-------------------------------------------------
do_diff - generate a difference between two
CHD files
-------------------------------------------------*/ | generate a difference between two
CHD files | [
"generate",
"a",
"difference",
"between",
"two",
"CHD",
"files"
] | static int do_diff(int argc, char *argv[], int param)
{
const char *parentfile = NULL, *inputfile = NULL, *outputfile = NULL;
chd_file *parentchd = NULL;
chd_file *outputchd = NULL;
chd_file *inputchd = NULL;
chd_error err;
if (argc != 5)
return usage();
parentfile = argv[2];
inputfile = argv[3];
outputfile = argv[4];
printf("Parent file: %s\n", parentfile);
printf("Input file: %s\n", inputfile);
printf("Diff file: %s\n", outputfile);
err = chd_open(parentfile, CHD_OPEN_READ, NULL, &parentchd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening CHD file '%s': %s\n", parentfile, chd_error_string(err));
goto cleanup;
}
err = chd_open(inputfile, CHD_OPEN_READ, NULL, &inputchd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening CHD file '%s': %s\n", inputfile, chd_error_string(err));
goto cleanup;
}
err = chd_create(outputfile, 0, 0, chd_get_header(parentchd)->compression, parentchd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error creating CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
err = chd_open(outputfile, CHD_OPEN_READWRITE, parentchd, &outputchd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening new CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
err = chdman_compress_chd(outputchd, inputchd, 0);
if (err != CHDERR_NONE)
fprintf(stderr, "Error during compression: %s\n", chd_error_string(err));
cleanup:
if (outputchd != NULL)
chd_close(outputchd);
if (inputchd != NULL)
chd_close(inputchd);
if (parentchd != NULL)
chd_close(parentchd);
if (err != CHDERR_NONE)
osd_rmfile(outputfile);
return (err != CHDERR_NONE);
} | [
"static",
"int",
"do_diff",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
",",
"int",
"param",
")",
"{",
"const",
"char",
"*",
"parentfile",
"=",
"NULL",
",",
"*",
"inputfile",
"=",
"NULL",
",",
"*",
"outputfile",
"=",
"NULL",
";",
"chd_file",
"*",
"parentchd",
"=",
"NULL",
";",
"chd_file",
"*",
"outputchd",
"=",
"NULL",
";",
"chd_file",
"*",
"inputchd",
"=",
"NULL",
";",
"chd_error",
"err",
";",
"if",
"(",
"argc",
"!=",
"5",
")",
"return",
"usage",
"(",
")",
";",
"parentfile",
"=",
"argv",
"[",
"2",
"]",
";",
"inputfile",
"=",
"argv",
"[",
"3",
"]",
";",
"outputfile",
"=",
"argv",
"[",
"4",
"]",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"parentfile",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"inputfile",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"outputfile",
")",
";",
"err",
"=",
"chd_open",
"(",
"parentfile",
",",
"CHD_OPEN_READ",
",",
"NULL",
",",
"&",
"parentchd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"parentfile",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"chd_open",
"(",
"inputfile",
",",
"CHD_OPEN_READ",
",",
"NULL",
",",
"&",
"inputchd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"inputfile",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"chd_create",
"(",
"outputfile",
",",
"0",
",",
"0",
",",
"chd_get_header",
"(",
"parentchd",
")",
"->",
"compression",
",",
"parentchd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"chd_open",
"(",
"outputfile",
",",
"CHD_OPEN_READWRITE",
",",
"parentchd",
",",
"&",
"outputchd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"chdman_compress_chd",
"(",
"outputchd",
",",
"inputchd",
",",
"0",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"cleanup",
":",
"if",
"(",
"outputchd",
"!=",
"NULL",
")",
"chd_close",
"(",
"outputchd",
")",
";",
"if",
"(",
"inputchd",
"!=",
"NULL",
")",
"chd_close",
"(",
"inputchd",
")",
";",
"if",
"(",
"parentchd",
"!=",
"NULL",
")",
"chd_close",
"(",
"parentchd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"osd_rmfile",
"(",
"outputfile",
")",
";",
"return",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
";",
"}"
] | do_diff - generate a difference between two
CHD files | [
"do_diff",
"-",
"generate",
"a",
"difference",
"between",
"two",
"CHD",
"files"
] | [
"/* require 5 args total */",
"/* extract the data */",
"/* print some info */",
"/* open the soon-to-be-parent CHD */",
"/* open the input CHD */",
"/* create the new CHD as a diff against the parent */",
"/* open the new CHD */",
"/* do the compression; our interface will route reads for us */",
"/* close everything down */"
] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
},
{
"param": "param",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "argc",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "argv",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "param",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d835fd6445aba612019120fc378673b23aba8150 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/chdman.c | [
"Unlicense"
] | C | do_setchs | int | static int do_setchs(int argc, char *argv[], int param)
{
int oldcyls, oldhds, oldsecs, oldsecsize;
UINT8 was_readonly = FALSE;
UINT64 old_logicalbytes;
const char *inoutfile;
chd_file *chd = NULL;
int cyls, hds, secs;
char metadata[256];
chd_header header;
chd_error err;
/* require 6 args total */
if (argc != 6)
return usage();
/* extract the data */
inoutfile = argv[2];
cyls = atoi(argv[3]);
hds = atoi(argv[4]);
secs = atoi(argv[5]);
/* print some info */
printf("Input file: %s\n", inoutfile);
printf("Cylinders: %d\n", cyls);
printf("Heads: %d\n", hds);
printf("Sectors: %d\n", secs);
/* open the file read-only and get the header */
err = chd_open(inoutfile, CHD_OPEN_READ, NULL, &chd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening CHD file '%s' read-only: %s\n", inoutfile, chd_error_string(err));
goto cleanup;
}
header = *chd_get_header(chd);
chd_close(chd);
chd = NULL;
/* if the drive is not writeable, note that, and make it so */
if (!(header.flags & CHDFLAGS_IS_WRITEABLE))
{
was_readonly = TRUE;
header.flags |= CHDFLAGS_IS_WRITEABLE;
/* write the new header */
err = chd_set_header(inoutfile, &header);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error making CHD file writeable: %s\n", chd_error_string(err));
goto cleanup;
}
}
/* open the file read/write */
err = chd_open(inoutfile, CHD_OPEN_READWRITE, NULL, &chd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening CHD file '%s' read/write: %s\n", inoutfile, chd_error_string(err));
goto cleanup;
}
/* get the hard disk metadata */
err = chd_get_metadata(chd, HARD_DISK_METADATA_TAG, 0, metadata, sizeof(metadata), NULL, NULL, NULL);
if (err != CHDERR_NONE || sscanf(metadata, HARD_DISK_METADATA_FORMAT, &oldcyls, &oldhds, &oldsecs, &oldsecsize) != 4)
{
fprintf(stderr, "CHD file '%s' is not a hard disk!\n", inoutfile);
err = CHDERR_INVALID_FILE;
goto cleanup;
}
/* write our own */
sprintf(metadata, HARD_DISK_METADATA_FORMAT, cyls, hds, secs, oldsecsize);
err = chd_set_metadata(chd, HARD_DISK_METADATA_TAG, 0, metadata, strlen(metadata) + 1, CHD_MDFLAGS_CHECKSUM);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error writing new metadata to CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
/* get the header and compute the new logical size */
header = *chd_get_header(chd);
old_logicalbytes = header.logicalbytes;
header.logicalbytes = (UINT64)cyls * (UINT64)hds * (UINT64)secs * (UINT64)oldsecsize;
/* close the file */
chd_close(chd);
chd = NULL;
/* restore the read-only state */
if (was_readonly)
header.flags &= ~CHDFLAGS_IS_WRITEABLE;
/* set the new logical size */
if (header.logicalbytes != old_logicalbytes || was_readonly)
{
err = chd_set_header(inoutfile, &header);
if (err != CHDERR_NONE)
fprintf(stderr, "Error writing new header to CHD file: %s\n", chd_error_string(err));
}
/* print a warning if the size is different */
if (header.logicalbytes < old_logicalbytes)
fprintf(stderr, "WARNING: new size is smaller; run chdman -update to reclaim empty space\n");
else if (header.logicalbytes > old_logicalbytes)
fprintf(stderr, "WARNING: new size is larger; run chdman -update to account for new empty space\n");
cleanup:
if (chd != NULL)
chd_close(chd);
if (err != CHDERR_NONE && was_readonly)
{
header.flags &= ~CHDFLAGS_IS_WRITEABLE;
chd_set_header(inoutfile, &header);
}
return (err != CHDERR_NONE);
} | /*-------------------------------------------------
do_setchs - change the CHS values on a hard
disk image
-------------------------------------------------*/ | change the CHS values on a hard
disk image | [
"change",
"the",
"CHS",
"values",
"on",
"a",
"hard",
"disk",
"image"
] | static int do_setchs(int argc, char *argv[], int param)
{
int oldcyls, oldhds, oldsecs, oldsecsize;
UINT8 was_readonly = FALSE;
UINT64 old_logicalbytes;
const char *inoutfile;
chd_file *chd = NULL;
int cyls, hds, secs;
char metadata[256];
chd_header header;
chd_error err;
if (argc != 6)
return usage();
inoutfile = argv[2];
cyls = atoi(argv[3]);
hds = atoi(argv[4]);
secs = atoi(argv[5]);
printf("Input file: %s\n", inoutfile);
printf("Cylinders: %d\n", cyls);
printf("Heads: %d\n", hds);
printf("Sectors: %d\n", secs);
err = chd_open(inoutfile, CHD_OPEN_READ, NULL, &chd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening CHD file '%s' read-only: %s\n", inoutfile, chd_error_string(err));
goto cleanup;
}
header = *chd_get_header(chd);
chd_close(chd);
chd = NULL;
if (!(header.flags & CHDFLAGS_IS_WRITEABLE))
{
was_readonly = TRUE;
header.flags |= CHDFLAGS_IS_WRITEABLE;
err = chd_set_header(inoutfile, &header);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error making CHD file writeable: %s\n", chd_error_string(err));
goto cleanup;
}
}
err = chd_open(inoutfile, CHD_OPEN_READWRITE, NULL, &chd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening CHD file '%s' read/write: %s\n", inoutfile, chd_error_string(err));
goto cleanup;
}
err = chd_get_metadata(chd, HARD_DISK_METADATA_TAG, 0, metadata, sizeof(metadata), NULL, NULL, NULL);
if (err != CHDERR_NONE || sscanf(metadata, HARD_DISK_METADATA_FORMAT, &oldcyls, &oldhds, &oldsecs, &oldsecsize) != 4)
{
fprintf(stderr, "CHD file '%s' is not a hard disk!\n", inoutfile);
err = CHDERR_INVALID_FILE;
goto cleanup;
}
sprintf(metadata, HARD_DISK_METADATA_FORMAT, cyls, hds, secs, oldsecsize);
err = chd_set_metadata(chd, HARD_DISK_METADATA_TAG, 0, metadata, strlen(metadata) + 1, CHD_MDFLAGS_CHECKSUM);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error writing new metadata to CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
header = *chd_get_header(chd);
old_logicalbytes = header.logicalbytes;
header.logicalbytes = (UINT64)cyls * (UINT64)hds * (UINT64)secs * (UINT64)oldsecsize;
chd_close(chd);
chd = NULL;
if (was_readonly)
header.flags &= ~CHDFLAGS_IS_WRITEABLE;
if (header.logicalbytes != old_logicalbytes || was_readonly)
{
err = chd_set_header(inoutfile, &header);
if (err != CHDERR_NONE)
fprintf(stderr, "Error writing new header to CHD file: %s\n", chd_error_string(err));
}
if (header.logicalbytes < old_logicalbytes)
fprintf(stderr, "WARNING: new size is smaller; run chdman -update to reclaim empty space\n");
else if (header.logicalbytes > old_logicalbytes)
fprintf(stderr, "WARNING: new size is larger; run chdman -update to account for new empty space\n");
cleanup:
if (chd != NULL)
chd_close(chd);
if (err != CHDERR_NONE && was_readonly)
{
header.flags &= ~CHDFLAGS_IS_WRITEABLE;
chd_set_header(inoutfile, &header);
}
return (err != CHDERR_NONE);
} | [
"static",
"int",
"do_setchs",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
",",
"int",
"param",
")",
"{",
"int",
"oldcyls",
",",
"oldhds",
",",
"oldsecs",
",",
"oldsecsize",
";",
"UINT8",
"was_readonly",
"=",
"FALSE",
";",
"UINT64",
"old_logicalbytes",
";",
"const",
"char",
"*",
"inoutfile",
";",
"chd_file",
"*",
"chd",
"=",
"NULL",
";",
"int",
"cyls",
",",
"hds",
",",
"secs",
";",
"char",
"metadata",
"[",
"256",
"]",
";",
"chd_header",
"header",
";",
"chd_error",
"err",
";",
"if",
"(",
"argc",
"!=",
"6",
")",
"return",
"usage",
"(",
")",
";",
"inoutfile",
"=",
"argv",
"[",
"2",
"]",
";",
"cyls",
"=",
"atoi",
"(",
"argv",
"[",
"3",
"]",
")",
";",
"hds",
"=",
"atoi",
"(",
"argv",
"[",
"4",
"]",
")",
";",
"secs",
"=",
"atoi",
"(",
"argv",
"[",
"5",
"]",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"inoutfile",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"cyls",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"hds",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"secs",
")",
";",
"err",
"=",
"chd_open",
"(",
"inoutfile",
",",
"CHD_OPEN_READ",
",",
"NULL",
",",
"&",
"chd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"inoutfile",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"header",
"=",
"*",
"chd_get_header",
"(",
"chd",
")",
";",
"chd_close",
"(",
"chd",
")",
";",
"chd",
"=",
"NULL",
";",
"if",
"(",
"!",
"(",
"header",
".",
"flags",
"&",
"CHDFLAGS_IS_WRITEABLE",
")",
")",
"{",
"was_readonly",
"=",
"TRUE",
";",
"header",
".",
"flags",
"|=",
"CHDFLAGS_IS_WRITEABLE",
";",
"err",
"=",
"chd_set_header",
"(",
"inoutfile",
",",
"&",
"header",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"}",
"err",
"=",
"chd_open",
"(",
"inoutfile",
",",
"CHD_OPEN_READWRITE",
",",
"NULL",
",",
"&",
"chd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"inoutfile",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"chd_get_metadata",
"(",
"chd",
",",
"HARD_DISK_METADATA_TAG",
",",
"0",
",",
"metadata",
",",
"sizeof",
"(",
"metadata",
")",
",",
"NULL",
",",
"NULL",
",",
"NULL",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
"||",
"sscanf",
"(",
"metadata",
",",
"HARD_DISK_METADATA_FORMAT",
",",
"&",
"oldcyls",
",",
"&",
"oldhds",
",",
"&",
"oldsecs",
",",
"&",
"oldsecsize",
")",
"!=",
"4",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"inoutfile",
")",
";",
"err",
"=",
"CHDERR_INVALID_FILE",
";",
"goto",
"cleanup",
";",
"}",
"sprintf",
"(",
"metadata",
",",
"HARD_DISK_METADATA_FORMAT",
",",
"cyls",
",",
"hds",
",",
"secs",
",",
"oldsecsize",
")",
";",
"err",
"=",
"chd_set_metadata",
"(",
"chd",
",",
"HARD_DISK_METADATA_TAG",
",",
"0",
",",
"metadata",
",",
"strlen",
"(",
"metadata",
")",
"+",
"1",
",",
"CHD_MDFLAGS_CHECKSUM",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"header",
"=",
"*",
"chd_get_header",
"(",
"chd",
")",
";",
"old_logicalbytes",
"=",
"header",
".",
"logicalbytes",
";",
"header",
".",
"logicalbytes",
"=",
"(",
"UINT64",
")",
"cyls",
"*",
"(",
"UINT64",
")",
"hds",
"*",
"(",
"UINT64",
")",
"secs",
"*",
"(",
"UINT64",
")",
"oldsecsize",
";",
"chd_close",
"(",
"chd",
")",
";",
"chd",
"=",
"NULL",
";",
"if",
"(",
"was_readonly",
")",
"header",
".",
"flags",
"&=",
"~",
"CHDFLAGS_IS_WRITEABLE",
";",
"if",
"(",
"header",
".",
"logicalbytes",
"!=",
"old_logicalbytes",
"||",
"was_readonly",
")",
"{",
"err",
"=",
"chd_set_header",
"(",
"inoutfile",
",",
"&",
"header",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"}",
"if",
"(",
"header",
".",
"logicalbytes",
"<",
"old_logicalbytes",
")",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
")",
";",
"else",
"if",
"(",
"header",
".",
"logicalbytes",
">",
"old_logicalbytes",
")",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
")",
";",
"cleanup",
":",
"if",
"(",
"chd",
"!=",
"NULL",
")",
"chd_close",
"(",
"chd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
"&&",
"was_readonly",
")",
"{",
"header",
".",
"flags",
"&=",
"~",
"CHDFLAGS_IS_WRITEABLE",
";",
"chd_set_header",
"(",
"inoutfile",
",",
"&",
"header",
")",
";",
"}",
"return",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
";",
"}"
] | do_setchs - change the CHS values on a hard
disk image | [
"do_setchs",
"-",
"change",
"the",
"CHS",
"values",
"on",
"a",
"hard",
"disk",
"image"
] | [
"/* require 6 args total */",
"/* extract the data */",
"/* print some info */",
"/* open the file read-only and get the header */",
"/* if the drive is not writeable, note that, and make it so */",
"/* write the new header */",
"/* open the file read/write */",
"/* get the hard disk metadata */",
"/* write our own */",
"/* get the header and compute the new logical size */",
"/* close the file */",
"/* restore the read-only state */",
"/* set the new logical size */",
"/* print a warning if the size is different */"
] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
},
{
"param": "param",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "argc",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "argv",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "param",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d835fd6445aba612019120fc378673b23aba8150 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/chdman.c | [
"Unlicense"
] | C | do_addmeta | int | static int do_addmeta(int argc, char *argv[], int param)
{
const char *inoutfile, *srcfile, *tagstring;
UINT8 was_readonly = FALSE;
UINT8 *metadata = NULL;
chd_file *chd = NULL;
chd_header header;
file_error filerr;
UINT32 metalength;
UINT32 metaindex;
UINT32 metatag;
chd_error err;
/* require 5 or 6 args total */
if (argc != 5 && argc != 6)
return usage();
/* extract the data */
inoutfile = argv[2];
tagstring = argv[3];
if (argc == 5)
{
metaindex = 0;
srcfile = argv[4];
}
else
{
metaindex = atoi(argv[4]);
srcfile = argv[5];
}
/* verify the tag */
if (strlen(tagstring) > 4)
{
fprintf(stderr, "Invalid tag '%s'; must be 4 characters or less\n", tagstring);
return CHDERR_INVALID_PARAMETER;
}
metatag = ((tagstring[0] == 0) ? ' ' : tagstring[0]) << 24;
metatag |= ((tagstring[1] == 0) ? ' ' : tagstring[1]) << 16;
metatag |= ((tagstring[2] == 0) ? ' ' : tagstring[2]) << 8;
metatag |= ((tagstring[3] == 0) ? ' ' : tagstring[3]) << 0;
/* print some info */
printf("Input file: %s\n", inoutfile);
printf("Tag: '%c%c%c%c'\n", (metatag >> 24) & 0xff, (metatag >> 16) & 0xff, (metatag >> 8) & 0xff, metatag & 0xff);
printf("Index: %d\n", metaindex);
printf("Source file: %s\n", srcfile);
/* open the file read-only and get the header */
err = chd_open(inoutfile, CHD_OPEN_READ, NULL, &chd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening CHD file '%s' read-only: %s\n", inoutfile, chd_error_string(err));
goto cleanup;
}
header = *chd_get_header(chd);
chd_close(chd);
chd = NULL;
/* if the drive is not writeable, note that, and make it so */
if (!(header.flags & CHDFLAGS_IS_WRITEABLE))
{
was_readonly = TRUE;
header.flags |= CHDFLAGS_IS_WRITEABLE;
/* write the new header */
err = chd_set_header(inoutfile, &header);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error making CHD file writeable: %s\n", chd_error_string(err));
goto cleanup;
}
}
/* open the file read/write */
err = chd_open(inoutfile, CHD_OPEN_READWRITE, NULL, &chd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening CHD file '%s' read/write: %s\n", inoutfile, chd_error_string(err));
goto cleanup;
}
/* attempt to open the source file */
filerr = core_fload(srcfile, (void **)&metadata, &metalength);
if (filerr != FILERR_NONE)
{
fprintf(stderr, "Error opening source file '%s'\n", srcfile);
err = CHDERR_FILE_NOT_FOUND;
goto cleanup;
}
/* if it's text, strip any trailing Ctrl-Z and CR/LF and add a trailing NULL */
if (param)
{
metadata = (UINT8 *)realloc(metadata, metalength + 1);
if (metadata == NULL)
{
fprintf(stderr, "Out of memory preparing metadata\n");
err = CHDERR_OUT_OF_MEMORY;
goto cleanup;
}
metadata[metalength++] = 0;
while (metalength > 0 && (metadata[metalength - 2] == 0x0a || metadata[metalength - 2] == 0x0d || metadata[metalength - 2] == 0x1a))
metadata[--metalength] = 0;
}
/* write the new metadata */
err = chd_set_metadata(chd, metatag, metaindex, metadata, metalength, CHD_MDFLAGS_CHECKSUM);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error writing new metadata to CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
header = *chd_get_header(chd);
/* close the file */
chd_close(chd);
chd = NULL;
/* restore the read-only state */
if (was_readonly)
{
header.flags &= ~CHDFLAGS_IS_WRITEABLE;
err = chd_set_header(inoutfile, &header);
if (err != CHDERR_NONE)
fprintf(stderr, "Error writing new header to CHD file: %s\n", chd_error_string(err));
}
if (err == CHDERR_NONE)
printf("Metadata added successfully as %s\n", param ? "text" : "binary");
cleanup:
if (metadata != NULL)
free(metadata);
if (chd != NULL)
chd_close(chd);
if (err != CHDERR_NONE && was_readonly)
{
header.flags &= ~CHDFLAGS_IS_WRITEABLE;
chd_set_header(inoutfile, &header);
}
return (err != CHDERR_NONE);
} | /*-------------------------------------------------
do_addmeta - add metadata to a CHD from a
file
-------------------------------------------------*/ | add metadata to a CHD from a
file | [
"add",
"metadata",
"to",
"a",
"CHD",
"from",
"a",
"file"
] | static int do_addmeta(int argc, char *argv[], int param)
{
const char *inoutfile, *srcfile, *tagstring;
UINT8 was_readonly = FALSE;
UINT8 *metadata = NULL;
chd_file *chd = NULL;
chd_header header;
file_error filerr;
UINT32 metalength;
UINT32 metaindex;
UINT32 metatag;
chd_error err;
if (argc != 5 && argc != 6)
return usage();
inoutfile = argv[2];
tagstring = argv[3];
if (argc == 5)
{
metaindex = 0;
srcfile = argv[4];
}
else
{
metaindex = atoi(argv[4]);
srcfile = argv[5];
}
if (strlen(tagstring) > 4)
{
fprintf(stderr, "Invalid tag '%s'; must be 4 characters or less\n", tagstring);
return CHDERR_INVALID_PARAMETER;
}
metatag = ((tagstring[0] == 0) ? ' ' : tagstring[0]) << 24;
metatag |= ((tagstring[1] == 0) ? ' ' : tagstring[1]) << 16;
metatag |= ((tagstring[2] == 0) ? ' ' : tagstring[2]) << 8;
metatag |= ((tagstring[3] == 0) ? ' ' : tagstring[3]) << 0;
printf("Input file: %s\n", inoutfile);
printf("Tag: '%c%c%c%c'\n", (metatag >> 24) & 0xff, (metatag >> 16) & 0xff, (metatag >> 8) & 0xff, metatag & 0xff);
printf("Index: %d\n", metaindex);
printf("Source file: %s\n", srcfile);
err = chd_open(inoutfile, CHD_OPEN_READ, NULL, &chd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening CHD file '%s' read-only: %s\n", inoutfile, chd_error_string(err));
goto cleanup;
}
header = *chd_get_header(chd);
chd_close(chd);
chd = NULL;
if (!(header.flags & CHDFLAGS_IS_WRITEABLE))
{
was_readonly = TRUE;
header.flags |= CHDFLAGS_IS_WRITEABLE;
err = chd_set_header(inoutfile, &header);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error making CHD file writeable: %s\n", chd_error_string(err));
goto cleanup;
}
}
err = chd_open(inoutfile, CHD_OPEN_READWRITE, NULL, &chd);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error opening CHD file '%s' read/write: %s\n", inoutfile, chd_error_string(err));
goto cleanup;
}
filerr = core_fload(srcfile, (void **)&metadata, &metalength);
if (filerr != FILERR_NONE)
{
fprintf(stderr, "Error opening source file '%s'\n", srcfile);
err = CHDERR_FILE_NOT_FOUND;
goto cleanup;
}
if (param)
{
metadata = (UINT8 *)realloc(metadata, metalength + 1);
if (metadata == NULL)
{
fprintf(stderr, "Out of memory preparing metadata\n");
err = CHDERR_OUT_OF_MEMORY;
goto cleanup;
}
metadata[metalength++] = 0;
while (metalength > 0 && (metadata[metalength - 2] == 0x0a || metadata[metalength - 2] == 0x0d || metadata[metalength - 2] == 0x1a))
metadata[--metalength] = 0;
}
err = chd_set_metadata(chd, metatag, metaindex, metadata, metalength, CHD_MDFLAGS_CHECKSUM);
if (err != CHDERR_NONE)
{
fprintf(stderr, "Error writing new metadata to CHD file: %s\n", chd_error_string(err));
goto cleanup;
}
header = *chd_get_header(chd);
chd_close(chd);
chd = NULL;
if (was_readonly)
{
header.flags &= ~CHDFLAGS_IS_WRITEABLE;
err = chd_set_header(inoutfile, &header);
if (err != CHDERR_NONE)
fprintf(stderr, "Error writing new header to CHD file: %s\n", chd_error_string(err));
}
if (err == CHDERR_NONE)
printf("Metadata added successfully as %s\n", param ? "text" : "binary");
cleanup:
if (metadata != NULL)
free(metadata);
if (chd != NULL)
chd_close(chd);
if (err != CHDERR_NONE && was_readonly)
{
header.flags &= ~CHDFLAGS_IS_WRITEABLE;
chd_set_header(inoutfile, &header);
}
return (err != CHDERR_NONE);
} | [
"static",
"int",
"do_addmeta",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
",",
"int",
"param",
")",
"{",
"const",
"char",
"*",
"inoutfile",
",",
"*",
"srcfile",
",",
"*",
"tagstring",
";",
"UINT8",
"was_readonly",
"=",
"FALSE",
";",
"UINT8",
"*",
"metadata",
"=",
"NULL",
";",
"chd_file",
"*",
"chd",
"=",
"NULL",
";",
"chd_header",
"header",
";",
"file_error",
"filerr",
";",
"UINT32",
"metalength",
";",
"UINT32",
"metaindex",
";",
"UINT32",
"metatag",
";",
"chd_error",
"err",
";",
"if",
"(",
"argc",
"!=",
"5",
"&&",
"argc",
"!=",
"6",
")",
"return",
"usage",
"(",
")",
";",
"inoutfile",
"=",
"argv",
"[",
"2",
"]",
";",
"tagstring",
"=",
"argv",
"[",
"3",
"]",
";",
"if",
"(",
"argc",
"==",
"5",
")",
"{",
"metaindex",
"=",
"0",
";",
"srcfile",
"=",
"argv",
"[",
"4",
"]",
";",
"}",
"else",
"{",
"metaindex",
"=",
"atoi",
"(",
"argv",
"[",
"4",
"]",
")",
";",
"srcfile",
"=",
"argv",
"[",
"5",
"]",
";",
"}",
"if",
"(",
"strlen",
"(",
"tagstring",
")",
">",
"4",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"tagstring",
")",
";",
"return",
"CHDERR_INVALID_PARAMETER",
";",
"}",
"metatag",
"=",
"(",
"(",
"tagstring",
"[",
"0",
"]",
"==",
"0",
")",
"?",
"'",
"'",
":",
"tagstring",
"[",
"0",
"]",
")",
"<<",
"24",
";",
"metatag",
"|=",
"(",
"(",
"tagstring",
"[",
"1",
"]",
"==",
"0",
")",
"?",
"'",
"'",
":",
"tagstring",
"[",
"1",
"]",
")",
"<<",
"16",
";",
"metatag",
"|=",
"(",
"(",
"tagstring",
"[",
"2",
"]",
"==",
"0",
")",
"?",
"'",
"'",
":",
"tagstring",
"[",
"2",
"]",
")",
"<<",
"8",
";",
"metatag",
"|=",
"(",
"(",
"tagstring",
"[",
"3",
"]",
"==",
"0",
")",
"?",
"'",
"'",
":",
"tagstring",
"[",
"3",
"]",
")",
"<<",
"0",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"inoutfile",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"(",
"metatag",
">>",
"24",
")",
"&",
"0xff",
",",
"(",
"metatag",
">>",
"16",
")",
"&",
"0xff",
",",
"(",
"metatag",
">>",
"8",
")",
"&",
"0xff",
",",
"metatag",
"&",
"0xff",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"metaindex",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"srcfile",
")",
";",
"err",
"=",
"chd_open",
"(",
"inoutfile",
",",
"CHD_OPEN_READ",
",",
"NULL",
",",
"&",
"chd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"inoutfile",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"header",
"=",
"*",
"chd_get_header",
"(",
"chd",
")",
";",
"chd_close",
"(",
"chd",
")",
";",
"chd",
"=",
"NULL",
";",
"if",
"(",
"!",
"(",
"header",
".",
"flags",
"&",
"CHDFLAGS_IS_WRITEABLE",
")",
")",
"{",
"was_readonly",
"=",
"TRUE",
";",
"header",
".",
"flags",
"|=",
"CHDFLAGS_IS_WRITEABLE",
";",
"err",
"=",
"chd_set_header",
"(",
"inoutfile",
",",
"&",
"header",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"}",
"err",
"=",
"chd_open",
"(",
"inoutfile",
",",
"CHD_OPEN_READWRITE",
",",
"NULL",
",",
"&",
"chd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"inoutfile",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"filerr",
"=",
"core_fload",
"(",
"srcfile",
",",
"(",
"void",
"*",
"*",
")",
"&",
"metadata",
",",
"&",
"metalength",
")",
";",
"if",
"(",
"filerr",
"!=",
"FILERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"srcfile",
")",
";",
"err",
"=",
"CHDERR_FILE_NOT_FOUND",
";",
"goto",
"cleanup",
";",
"}",
"if",
"(",
"param",
")",
"{",
"metadata",
"=",
"(",
"UINT8",
"*",
")",
"realloc",
"(",
"metadata",
",",
"metalength",
"+",
"1",
")",
";",
"if",
"(",
"metadata",
"==",
"NULL",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
")",
";",
"err",
"=",
"CHDERR_OUT_OF_MEMORY",
";",
"goto",
"cleanup",
";",
"}",
"metadata",
"[",
"metalength",
"++",
"]",
"=",
"0",
";",
"while",
"(",
"metalength",
">",
"0",
"&&",
"(",
"metadata",
"[",
"metalength",
"-",
"2",
"]",
"==",
"0x0a",
"||",
"metadata",
"[",
"metalength",
"-",
"2",
"]",
"==",
"0x0d",
"||",
"metadata",
"[",
"metalength",
"-",
"2",
"]",
"==",
"0x1a",
")",
")",
"metadata",
"[",
"--",
"metalength",
"]",
"=",
"0",
";",
"}",
"err",
"=",
"chd_set_metadata",
"(",
"chd",
",",
"metatag",
",",
"metaindex",
",",
"metadata",
",",
"metalength",
",",
"CHD_MDFLAGS_CHECKSUM",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"goto",
"cleanup",
";",
"}",
"header",
"=",
"*",
"chd_get_header",
"(",
"chd",
")",
";",
"chd_close",
"(",
"chd",
")",
";",
"chd",
"=",
"NULL",
";",
"if",
"(",
"was_readonly",
")",
"{",
"header",
".",
"flags",
"&=",
"~",
"CHDFLAGS_IS_WRITEABLE",
";",
"err",
"=",
"chd_set_header",
"(",
"inoutfile",
",",
"&",
"header",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"chd_error_string",
"(",
"err",
")",
")",
";",
"}",
"if",
"(",
"err",
"==",
"CHDERR_NONE",
")",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"param",
"?",
"\"",
"\"",
":",
"\"",
"\"",
")",
";",
"cleanup",
":",
"if",
"(",
"metadata",
"!=",
"NULL",
")",
"free",
"(",
"metadata",
")",
";",
"if",
"(",
"chd",
"!=",
"NULL",
")",
"chd_close",
"(",
"chd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
"&&",
"was_readonly",
")",
"{",
"header",
".",
"flags",
"&=",
"~",
"CHDFLAGS_IS_WRITEABLE",
";",
"chd_set_header",
"(",
"inoutfile",
",",
"&",
"header",
")",
";",
"}",
"return",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
";",
"}"
] | do_addmeta - add metadata to a CHD from a
file | [
"do_addmeta",
"-",
"add",
"metadata",
"to",
"a",
"CHD",
"from",
"a",
"file"
] | [
"/* require 5 or 6 args total */",
"/* extract the data */",
"/* verify the tag */",
"/* print some info */",
"/* open the file read-only and get the header */",
"/* if the drive is not writeable, note that, and make it so */",
"/* write the new header */",
"/* open the file read/write */",
"/* attempt to open the source file */",
"/* if it's text, strip any trailing Ctrl-Z and CR/LF and add a trailing NULL */",
"/* write the new metadata */",
"/* close the file */",
"/* restore the read-only state */"
] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
},
{
"param": "param",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "argc",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "argv",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "param",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d835fd6445aba612019120fc378673b23aba8150 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/chdman.c | [
"Unlicense"
] | C | chdman_compress_file | chd_error | static chd_error chdman_compress_file(chd_file *chd, const char *rawfile, UINT32 offset)
{
core_file *sourcefile;
const chd_header *header;
UINT64 sourceoffset = 0;
UINT8 *cache = NULL;
double ratio = 1.0;
file_error filerr;
chd_error err;
int hunknum;
/* open the raw file */
filerr = core_fopen(rawfile, OPEN_FLAG_READ, &sourcefile);
if (filerr != FILERR_NONE)
{
err = CHDERR_FILE_NOT_FOUND;
goto cleanup;
}
/* get the header */
header = chd_get_header(chd);
cache = (UINT8 *)malloc(header->hunkbytes);
if (cache == NULL)
{
err = CHDERR_OUT_OF_MEMORY;
goto cleanup;
}
/* begin compressing */
err = chd_compress_begin(chd);
if (err != CHDERR_NONE)
goto cleanup;
/* loop over source hunks until we run out */
for (hunknum = 0; hunknum < header->totalhunks; hunknum++)
{
UINT32 bytesread;
/* progress */
progress(hunknum == 0, "Compressing hunk %d/%d... (ratio=%d%%) \r", hunknum, header->totalhunks, (int)(100.0 * ratio));
/* read the data */
core_fseek(sourcefile, sourceoffset + offset, SEEK_SET);
bytesread = core_fread(sourcefile, cache, header->hunkbytes);
if (bytesread < header->hunkbytes)
memset(&cache[bytesread], 0, header->hunkbytes - bytesread);
/* append the data */
err = chd_compress_hunk(chd, cache, &ratio);
if (err != CHDERR_NONE)
goto cleanup;
/* prepare for the next hunk */
sourceoffset += header->hunkbytes;
}
/* finish compression */
err = chd_compress_finish(chd, TRUE);
if (err != CHDERR_NONE)
goto cleanup;
/* final progress update */
progress(TRUE, "Compression complete ... final ratio = %d%% \n", (int)(100.0 * ratio));
cleanup:
if (sourcefile != NULL)
core_fclose(sourcefile);
if (cache != NULL)
free(cache);
return err;
} | /*-------------------------------------------------
chdman_compress_file - compress a regular
file via the compression interfaces
-------------------------------------------------*/ | compress a regular
file via the compression interfaces | [
"compress",
"a",
"regular",
"file",
"via",
"the",
"compression",
"interfaces"
] | static chd_error chdman_compress_file(chd_file *chd, const char *rawfile, UINT32 offset)
{
core_file *sourcefile;
const chd_header *header;
UINT64 sourceoffset = 0;
UINT8 *cache = NULL;
double ratio = 1.0;
file_error filerr;
chd_error err;
int hunknum;
filerr = core_fopen(rawfile, OPEN_FLAG_READ, &sourcefile);
if (filerr != FILERR_NONE)
{
err = CHDERR_FILE_NOT_FOUND;
goto cleanup;
}
header = chd_get_header(chd);
cache = (UINT8 *)malloc(header->hunkbytes);
if (cache == NULL)
{
err = CHDERR_OUT_OF_MEMORY;
goto cleanup;
}
err = chd_compress_begin(chd);
if (err != CHDERR_NONE)
goto cleanup;
for (hunknum = 0; hunknum < header->totalhunks; hunknum++)
{
UINT32 bytesread;
progress(hunknum == 0, "Compressing hunk %d/%d... (ratio=%d%%) \r", hunknum, header->totalhunks, (int)(100.0 * ratio));
core_fseek(sourcefile, sourceoffset + offset, SEEK_SET);
bytesread = core_fread(sourcefile, cache, header->hunkbytes);
if (bytesread < header->hunkbytes)
memset(&cache[bytesread], 0, header->hunkbytes - bytesread);
err = chd_compress_hunk(chd, cache, &ratio);
if (err != CHDERR_NONE)
goto cleanup;
sourceoffset += header->hunkbytes;
}
err = chd_compress_finish(chd, TRUE);
if (err != CHDERR_NONE)
goto cleanup;
progress(TRUE, "Compression complete ... final ratio = %d%% \n", (int)(100.0 * ratio));
cleanup:
if (sourcefile != NULL)
core_fclose(sourcefile);
if (cache != NULL)
free(cache);
return err;
} | [
"static",
"chd_error",
"chdman_compress_file",
"(",
"chd_file",
"*",
"chd",
",",
"const",
"char",
"*",
"rawfile",
",",
"UINT32",
"offset",
")",
"{",
"core_file",
"*",
"sourcefile",
";",
"const",
"chd_header",
"*",
"header",
";",
"UINT64",
"sourceoffset",
"=",
"0",
";",
"UINT8",
"*",
"cache",
"=",
"NULL",
";",
"double",
"ratio",
"=",
"1.0",
";",
"file_error",
"filerr",
";",
"chd_error",
"err",
";",
"int",
"hunknum",
";",
"filerr",
"=",
"core_fopen",
"(",
"rawfile",
",",
"OPEN_FLAG_READ",
",",
"&",
"sourcefile",
")",
";",
"if",
"(",
"filerr",
"!=",
"FILERR_NONE",
")",
"{",
"err",
"=",
"CHDERR_FILE_NOT_FOUND",
";",
"goto",
"cleanup",
";",
"}",
"header",
"=",
"chd_get_header",
"(",
"chd",
")",
";",
"cache",
"=",
"(",
"UINT8",
"*",
")",
"malloc",
"(",
"header",
"->",
"hunkbytes",
")",
";",
"if",
"(",
"cache",
"==",
"NULL",
")",
"{",
"err",
"=",
"CHDERR_OUT_OF_MEMORY",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"chd_compress_begin",
"(",
"chd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"goto",
"cleanup",
";",
"for",
"(",
"hunknum",
"=",
"0",
";",
"hunknum",
"<",
"header",
"->",
"totalhunks",
";",
"hunknum",
"++",
")",
"{",
"UINT32",
"bytesread",
";",
"progress",
"(",
"hunknum",
"==",
"0",
",",
"\"",
"\\r",
"\"",
",",
"hunknum",
",",
"header",
"->",
"totalhunks",
",",
"(",
"int",
")",
"(",
"100.0",
"*",
"ratio",
")",
")",
";",
"core_fseek",
"(",
"sourcefile",
",",
"sourceoffset",
"+",
"offset",
",",
"SEEK_SET",
")",
";",
"bytesread",
"=",
"core_fread",
"(",
"sourcefile",
",",
"cache",
",",
"header",
"->",
"hunkbytes",
")",
";",
"if",
"(",
"bytesread",
"<",
"header",
"->",
"hunkbytes",
")",
"memset",
"(",
"&",
"cache",
"[",
"bytesread",
"]",
",",
"0",
",",
"header",
"->",
"hunkbytes",
"-",
"bytesread",
")",
";",
"err",
"=",
"chd_compress_hunk",
"(",
"chd",
",",
"cache",
",",
"&",
"ratio",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"goto",
"cleanup",
";",
"sourceoffset",
"+=",
"header",
"->",
"hunkbytes",
";",
"}",
"err",
"=",
"chd_compress_finish",
"(",
"chd",
",",
"TRUE",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"goto",
"cleanup",
";",
"progress",
"(",
"TRUE",
",",
"\"",
"\\n",
"\"",
",",
"(",
"int",
")",
"(",
"100.0",
"*",
"ratio",
")",
")",
";",
"cleanup",
":",
"if",
"(",
"sourcefile",
"!=",
"NULL",
")",
"core_fclose",
"(",
"sourcefile",
")",
";",
"if",
"(",
"cache",
"!=",
"NULL",
")",
"free",
"(",
"cache",
")",
";",
"return",
"err",
";",
"}"
] | chdman_compress_file - compress a regular
file via the compression interfaces | [
"chdman_compress_file",
"-",
"compress",
"a",
"regular",
"file",
"via",
"the",
"compression",
"interfaces"
] | [
"/* open the raw file */",
"/* get the header */",
"/* begin compressing */",
"/* loop over source hunks until we run out */",
"/* progress */",
"/* read the data */",
"/* append the data */",
"/* prepare for the next hunk */",
"/* finish compression */",
"/* final progress update */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "rawfile",
"type": "char"
},
{
"param": "offset",
"type": "UINT32"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rawfile",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offset",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d835fd6445aba612019120fc378673b23aba8150 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/chdman.c | [
"Unlicense"
] | C | chdman_compress_chd | chd_error | static chd_error chdman_compress_chd(chd_file *chd, chd_file *source, UINT32 totalhunks)
{
const chd_header *source_header;
const chd_header *header;
UINT8 *source_cache = NULL;
UINT64 source_offset = 0;
UINT32 source_bytes = 0;
UINT8 *cache = NULL;
double ratio = 1.0;
chd_error err, verifyerr;
int hunknum;
/* get the header */
header = chd_get_header(chd);
cache = (UINT8 *)malloc(header->hunkbytes);
if (cache == NULL)
{
err = CHDERR_OUT_OF_MEMORY;
goto cleanup;
}
/* get the source CHD header */
source_header = chd_get_header(source);
source_cache = (UINT8 *)malloc(source_header->hunkbytes);
if (source_cache == NULL)
{
err = CHDERR_OUT_OF_MEMORY;
goto cleanup;
}
/* begin compressing */
err = chd_compress_begin(chd);
if (err != CHDERR_NONE)
goto cleanup;
/* also begin verifying the source driver */
verifyerr = chd_verify_begin(source);
/* a zero count means the natural number */
if (totalhunks == 0)
totalhunks = source_header->totalhunks;
/* loop over source hunks until we run out */
for (hunknum = 0; hunknum < totalhunks; hunknum++)
{
UINT32 bytesremaining = header->hunkbytes;
UINT8 *dest = cache;
/* progress */
progress(hunknum == 0, "Compressing hunk %d/%d... (ratio=%d%%) \r", hunknum, totalhunks, (int)(100.0 * ratio));
/* read the data */
while (bytesremaining > 0)
{
/* if we have data in the buffer, copy it */
if (source_bytes > 0)
{
UINT32 bytestocopy = MIN(bytesremaining, source_bytes);
memcpy(dest, &source_cache[source_header->hunkbytes - source_bytes], bytestocopy);
dest += bytestocopy;
source_bytes -= bytestocopy;
bytesremaining -= bytestocopy;
}
/* otherwise, read in another hunk of the source */
else
{
/* verify the next hunk */
if (verifyerr == CHDERR_NONE)
err = chd_verify_hunk(source);
/* then read it (should be the same) */
err = chd_read(source, source_offset / source_header->hunkbytes, source_cache);
if (err != CHDERR_NONE)
memset(source_cache, 0, source_header->hunkbytes);
source_bytes = source_header->hunkbytes;
source_offset += source_bytes;
}
}
/* append the data */
err = chd_compress_hunk(chd, cache, &ratio);
if (err != CHDERR_NONE)
goto cleanup;
}
/* if we read all the source data, verify the checksums */
if (verifyerr == CHDERR_NONE && source_offset >= source_header->logicalbytes)
{
static const UINT8 empty_checksum[CHD_SHA1_BYTES] = { 0 };
chd_verify_result verify;
int i;
/* get the final values */
err = chd_verify_finish(source, &verify);
/* check the MD5 */
if (memcmp(source_header->md5, empty_checksum, CHD_MD5_BYTES) != 0)
{
if (memcmp(source_header->md5, verify.md5, CHD_MD5_BYTES) != 0)
{
progress(TRUE, "WARNING: expected input MD5 = ");
for (i = 0; i < CHD_MD5_BYTES; i++)
progress(TRUE, "%02x", source_header->md5[i]);
progress(TRUE, "\n");
progress(TRUE, " actual MD5 = ");
for (i = 0; i < CHD_MD5_BYTES; i++)
progress(TRUE, "%02x", verify.md5[i]);
progress(TRUE, "\n");
}
else
progress(TRUE, "Input MD5 verified \n");
}
/* check the SHA1 */
if (memcmp(source_header->sha1, empty_checksum, CHD_SHA1_BYTES) != 0)
{
if (memcmp(source_header->sha1, verify.sha1, CHD_SHA1_BYTES) != 0)
{
progress(TRUE, "WARNING: expected input SHA1 = ");
for (i = 0; i < CHD_SHA1_BYTES; i++)
progress(TRUE, "%02x", source_header->sha1[i]);
progress(TRUE, "\n");
progress(TRUE, " actual SHA1 = ");
for (i = 0; i < CHD_SHA1_BYTES; i++)
progress(TRUE, "%02x", verify.sha1[i]);
progress(TRUE, "\n");
}
else
progress(TRUE, "Input SHA1 verified \n");
}
}
/* finish compression */
err = chd_compress_finish(chd, !(source_header->flags & CHDFLAGS_IS_WRITEABLE));
if (err != CHDERR_NONE)
goto cleanup;
/* final progress update */
progress(TRUE, "Compression complete ... final ratio = %d%% \n", (int)(100.0 * ratio));
cleanup:
if (source_cache != NULL)
free(source_cache);
if (cache != NULL)
free(cache);
return err;
} | /*-------------------------------------------------
chdman_compress_chd - (re)compress a CHD file
via the compression interfaces
-------------------------------------------------*/ | (re)compress a CHD file
via the compression interfaces | [
"(",
"re",
")",
"compress",
"a",
"CHD",
"file",
"via",
"the",
"compression",
"interfaces"
] | static chd_error chdman_compress_chd(chd_file *chd, chd_file *source, UINT32 totalhunks)
{
const chd_header *source_header;
const chd_header *header;
UINT8 *source_cache = NULL;
UINT64 source_offset = 0;
UINT32 source_bytes = 0;
UINT8 *cache = NULL;
double ratio = 1.0;
chd_error err, verifyerr;
int hunknum;
header = chd_get_header(chd);
cache = (UINT8 *)malloc(header->hunkbytes);
if (cache == NULL)
{
err = CHDERR_OUT_OF_MEMORY;
goto cleanup;
}
source_header = chd_get_header(source);
source_cache = (UINT8 *)malloc(source_header->hunkbytes);
if (source_cache == NULL)
{
err = CHDERR_OUT_OF_MEMORY;
goto cleanup;
}
err = chd_compress_begin(chd);
if (err != CHDERR_NONE)
goto cleanup;
verifyerr = chd_verify_begin(source);
if (totalhunks == 0)
totalhunks = source_header->totalhunks;
for (hunknum = 0; hunknum < totalhunks; hunknum++)
{
UINT32 bytesremaining = header->hunkbytes;
UINT8 *dest = cache;
progress(hunknum == 0, "Compressing hunk %d/%d... (ratio=%d%%) \r", hunknum, totalhunks, (int)(100.0 * ratio));
while (bytesremaining > 0)
{
if (source_bytes > 0)
{
UINT32 bytestocopy = MIN(bytesremaining, source_bytes);
memcpy(dest, &source_cache[source_header->hunkbytes - source_bytes], bytestocopy);
dest += bytestocopy;
source_bytes -= bytestocopy;
bytesremaining -= bytestocopy;
}
else
{
if (verifyerr == CHDERR_NONE)
err = chd_verify_hunk(source);
err = chd_read(source, source_offset / source_header->hunkbytes, source_cache);
if (err != CHDERR_NONE)
memset(source_cache, 0, source_header->hunkbytes);
source_bytes = source_header->hunkbytes;
source_offset += source_bytes;
}
}
err = chd_compress_hunk(chd, cache, &ratio);
if (err != CHDERR_NONE)
goto cleanup;
}
if (verifyerr == CHDERR_NONE && source_offset >= source_header->logicalbytes)
{
static const UINT8 empty_checksum[CHD_SHA1_BYTES] = { 0 };
chd_verify_result verify;
int i;
err = chd_verify_finish(source, &verify);
if (memcmp(source_header->md5, empty_checksum, CHD_MD5_BYTES) != 0)
{
if (memcmp(source_header->md5, verify.md5, CHD_MD5_BYTES) != 0)
{
progress(TRUE, "WARNING: expected input MD5 = ");
for (i = 0; i < CHD_MD5_BYTES; i++)
progress(TRUE, "%02x", source_header->md5[i]);
progress(TRUE, "\n");
progress(TRUE, " actual MD5 = ");
for (i = 0; i < CHD_MD5_BYTES; i++)
progress(TRUE, "%02x", verify.md5[i]);
progress(TRUE, "\n");
}
else
progress(TRUE, "Input MD5 verified \n");
}
if (memcmp(source_header->sha1, empty_checksum, CHD_SHA1_BYTES) != 0)
{
if (memcmp(source_header->sha1, verify.sha1, CHD_SHA1_BYTES) != 0)
{
progress(TRUE, "WARNING: expected input SHA1 = ");
for (i = 0; i < CHD_SHA1_BYTES; i++)
progress(TRUE, "%02x", source_header->sha1[i]);
progress(TRUE, "\n");
progress(TRUE, " actual SHA1 = ");
for (i = 0; i < CHD_SHA1_BYTES; i++)
progress(TRUE, "%02x", verify.sha1[i]);
progress(TRUE, "\n");
}
else
progress(TRUE, "Input SHA1 verified \n");
}
}
err = chd_compress_finish(chd, !(source_header->flags & CHDFLAGS_IS_WRITEABLE));
if (err != CHDERR_NONE)
goto cleanup;
progress(TRUE, "Compression complete ... final ratio = %d%% \n", (int)(100.0 * ratio));
cleanup:
if (source_cache != NULL)
free(source_cache);
if (cache != NULL)
free(cache);
return err;
} | [
"static",
"chd_error",
"chdman_compress_chd",
"(",
"chd_file",
"*",
"chd",
",",
"chd_file",
"*",
"source",
",",
"UINT32",
"totalhunks",
")",
"{",
"const",
"chd_header",
"*",
"source_header",
";",
"const",
"chd_header",
"*",
"header",
";",
"UINT8",
"*",
"source_cache",
"=",
"NULL",
";",
"UINT64",
"source_offset",
"=",
"0",
";",
"UINT32",
"source_bytes",
"=",
"0",
";",
"UINT8",
"*",
"cache",
"=",
"NULL",
";",
"double",
"ratio",
"=",
"1.0",
";",
"chd_error",
"err",
",",
"verifyerr",
";",
"int",
"hunknum",
";",
"header",
"=",
"chd_get_header",
"(",
"chd",
")",
";",
"cache",
"=",
"(",
"UINT8",
"*",
")",
"malloc",
"(",
"header",
"->",
"hunkbytes",
")",
";",
"if",
"(",
"cache",
"==",
"NULL",
")",
"{",
"err",
"=",
"CHDERR_OUT_OF_MEMORY",
";",
"goto",
"cleanup",
";",
"}",
"source_header",
"=",
"chd_get_header",
"(",
"source",
")",
";",
"source_cache",
"=",
"(",
"UINT8",
"*",
")",
"malloc",
"(",
"source_header",
"->",
"hunkbytes",
")",
";",
"if",
"(",
"source_cache",
"==",
"NULL",
")",
"{",
"err",
"=",
"CHDERR_OUT_OF_MEMORY",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"chd_compress_begin",
"(",
"chd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"goto",
"cleanup",
";",
"verifyerr",
"=",
"chd_verify_begin",
"(",
"source",
")",
";",
"if",
"(",
"totalhunks",
"==",
"0",
")",
"totalhunks",
"=",
"source_header",
"->",
"totalhunks",
";",
"for",
"(",
"hunknum",
"=",
"0",
";",
"hunknum",
"<",
"totalhunks",
";",
"hunknum",
"++",
")",
"{",
"UINT32",
"bytesremaining",
"=",
"header",
"->",
"hunkbytes",
";",
"UINT8",
"*",
"dest",
"=",
"cache",
";",
"progress",
"(",
"hunknum",
"==",
"0",
",",
"\"",
"\\r",
"\"",
",",
"hunknum",
",",
"totalhunks",
",",
"(",
"int",
")",
"(",
"100.0",
"*",
"ratio",
")",
")",
";",
"while",
"(",
"bytesremaining",
">",
"0",
")",
"{",
"if",
"(",
"source_bytes",
">",
"0",
")",
"{",
"UINT32",
"bytestocopy",
"=",
"MIN",
"(",
"bytesremaining",
",",
"source_bytes",
")",
";",
"memcpy",
"(",
"dest",
",",
"&",
"source_cache",
"[",
"source_header",
"->",
"hunkbytes",
"-",
"source_bytes",
"]",
",",
"bytestocopy",
")",
";",
"dest",
"+=",
"bytestocopy",
";",
"source_bytes",
"-=",
"bytestocopy",
";",
"bytesremaining",
"-=",
"bytestocopy",
";",
"}",
"else",
"{",
"if",
"(",
"verifyerr",
"==",
"CHDERR_NONE",
")",
"err",
"=",
"chd_verify_hunk",
"(",
"source",
")",
";",
"err",
"=",
"chd_read",
"(",
"source",
",",
"source_offset",
"/",
"source_header",
"->",
"hunkbytes",
",",
"source_cache",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"memset",
"(",
"source_cache",
",",
"0",
",",
"source_header",
"->",
"hunkbytes",
")",
";",
"source_bytes",
"=",
"source_header",
"->",
"hunkbytes",
";",
"source_offset",
"+=",
"source_bytes",
";",
"}",
"}",
"err",
"=",
"chd_compress_hunk",
"(",
"chd",
",",
"cache",
",",
"&",
"ratio",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"goto",
"cleanup",
";",
"}",
"if",
"(",
"verifyerr",
"==",
"CHDERR_NONE",
"&&",
"source_offset",
">=",
"source_header",
"->",
"logicalbytes",
")",
"{",
"static",
"const",
"UINT8",
"empty_checksum",
"[",
"CHD_SHA1_BYTES",
"]",
"=",
"{",
"0",
"}",
";",
"chd_verify_result",
"verify",
";",
"int",
"i",
";",
"err",
"=",
"chd_verify_finish",
"(",
"source",
",",
"&",
"verify",
")",
";",
"if",
"(",
"memcmp",
"(",
"source_header",
"->",
"md5",
",",
"empty_checksum",
",",
"CHD_MD5_BYTES",
")",
"!=",
"0",
")",
"{",
"if",
"(",
"memcmp",
"(",
"source_header",
"->",
"md5",
",",
"verify",
".",
"md5",
",",
"CHD_MD5_BYTES",
")",
"!=",
"0",
")",
"{",
"progress",
"(",
"TRUE",
",",
"\"",
"\"",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"CHD_MD5_BYTES",
";",
"i",
"++",
")",
"progress",
"(",
"TRUE",
",",
"\"",
"\"",
",",
"source_header",
"->",
"md5",
"[",
"i",
"]",
")",
";",
"progress",
"(",
"TRUE",
",",
"\"",
"\\n",
"\"",
")",
";",
"progress",
"(",
"TRUE",
",",
"\"",
"\"",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"CHD_MD5_BYTES",
";",
"i",
"++",
")",
"progress",
"(",
"TRUE",
",",
"\"",
"\"",
",",
"verify",
".",
"md5",
"[",
"i",
"]",
")",
";",
"progress",
"(",
"TRUE",
",",
"\"",
"\\n",
"\"",
")",
";",
"}",
"else",
"progress",
"(",
"TRUE",
",",
"\"",
"\\n",
"\"",
")",
";",
"}",
"if",
"(",
"memcmp",
"(",
"source_header",
"->",
"sha1",
",",
"empty_checksum",
",",
"CHD_SHA1_BYTES",
")",
"!=",
"0",
")",
"{",
"if",
"(",
"memcmp",
"(",
"source_header",
"->",
"sha1",
",",
"verify",
".",
"sha1",
",",
"CHD_SHA1_BYTES",
")",
"!=",
"0",
")",
"{",
"progress",
"(",
"TRUE",
",",
"\"",
"\"",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"CHD_SHA1_BYTES",
";",
"i",
"++",
")",
"progress",
"(",
"TRUE",
",",
"\"",
"\"",
",",
"source_header",
"->",
"sha1",
"[",
"i",
"]",
")",
";",
"progress",
"(",
"TRUE",
",",
"\"",
"\\n",
"\"",
")",
";",
"progress",
"(",
"TRUE",
",",
"\"",
"\"",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"CHD_SHA1_BYTES",
";",
"i",
"++",
")",
"progress",
"(",
"TRUE",
",",
"\"",
"\"",
",",
"verify",
".",
"sha1",
"[",
"i",
"]",
")",
";",
"progress",
"(",
"TRUE",
",",
"\"",
"\\n",
"\"",
")",
";",
"}",
"else",
"progress",
"(",
"TRUE",
",",
"\"",
"\\n",
"\"",
")",
";",
"}",
"}",
"err",
"=",
"chd_compress_finish",
"(",
"chd",
",",
"!",
"(",
"source_header",
"->",
"flags",
"&",
"CHDFLAGS_IS_WRITEABLE",
")",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"goto",
"cleanup",
";",
"progress",
"(",
"TRUE",
",",
"\"",
"\\n",
"\"",
",",
"(",
"int",
")",
"(",
"100.0",
"*",
"ratio",
")",
")",
";",
"cleanup",
":",
"if",
"(",
"source_cache",
"!=",
"NULL",
")",
"free",
"(",
"source_cache",
")",
";",
"if",
"(",
"cache",
"!=",
"NULL",
")",
"free",
"(",
"cache",
")",
";",
"return",
"err",
";",
"}"
] | chdman_compress_chd - (re)compress a CHD file
via the compression interfaces | [
"chdman_compress_chd",
"-",
"(",
"re",
")",
"compress",
"a",
"CHD",
"file",
"via",
"the",
"compression",
"interfaces"
] | [
"/* get the header */",
"/* get the source CHD header */",
"/* begin compressing */",
"/* also begin verifying the source driver */",
"/* a zero count means the natural number */",
"/* loop over source hunks until we run out */",
"/* progress */",
"/* read the data */",
"/* if we have data in the buffer, copy it */",
"/* otherwise, read in another hunk of the source */",
"/* verify the next hunk */",
"/* then read it (should be the same) */",
"/* append the data */",
"/* if we read all the source data, verify the checksums */",
"/* get the final values */",
"/* check the MD5 */",
"/* check the SHA1 */",
"/* finish compression */",
"/* final progress update */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "source",
"type": "chd_file"
},
{
"param": "totalhunks",
"type": "UINT32"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "source",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "totalhunks",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d835fd6445aba612019120fc378673b23aba8150 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/chdman.c | [
"Unlicense"
] | C | chdman_clone_metadata | chd_error | static chd_error chdman_clone_metadata(chd_file *source, chd_file *dest)
{
const chd_header *header = chd_get_header(source);
UINT8 metabuffer[MAX(4096, sizeof(cdrom_toc))];
UINT32 metatag, metasize, metaindex;
UINT8 metaflags;
chd_error err;
/* clone the metadata */
for (metaindex = 0; ; metaindex++)
{
/* fetch the next piece of metadata */
err = chd_get_metadata(source, CHDMETATAG_WILDCARD, metaindex, metabuffer, sizeof(metabuffer), &metasize, &metatag, &metaflags);
if (err != CHDERR_NONE)
{
if (err == CHDERR_METADATA_NOT_FOUND)
err = CHDERR_NONE;
break;
}
/* promote certain bits of metadata to checksummed for older CHDs */
if (header->version <= 3)
{
if (metatag == HARD_DISK_METADATA_TAG || metatag == CDROM_OLD_METADATA_TAG ||
metatag == CDROM_TRACK_METADATA_TAG || metatag == AV_METADATA_TAG ||
metatag == AV_LD_METADATA_TAG)
{
metaflags |= CHD_MDFLAGS_CHECKSUM;
}
/* convert old-style CD-ROM data to newer */
if (metatag == CDROM_OLD_METADATA_TAG)
{
cdrom_toc *toc = (cdrom_toc *)metabuffer;
err = cdrom_parse_metadata(source, toc);
if (err == CHDERR_NONE)
err = cdrom_write_metadata(dest, toc);
if (err == CHDERR_NONE)
continue;
}
}
/* if that fit, just write it back from the temporary buffer */
if (metasize <= sizeof(metabuffer))
{
/* write it to the target */
err = chd_set_metadata(dest, metatag, CHD_METAINDEX_APPEND, metabuffer, metasize, metaflags);
if (err != CHDERR_NONE)
break;
}
/* otherwise, allocate a bigger temporary buffer */
else
{
UINT8 *allocbuffer = (UINT8 *)malloc(metasize);
if (allocbuffer == NULL)
{
err = CHDERR_OUT_OF_MEMORY;
break;
}
/* re-read the whole thing */
err = chd_get_metadata(source, CHDMETATAG_WILDCARD, metaindex, allocbuffer, metasize, &metasize, &metatag, &metaflags);
if (err != CHDERR_NONE)
{
free(allocbuffer);
break;
}
/* write it to the target */
err = chd_set_metadata(dest, metatag, CHD_METAINDEX_APPEND, allocbuffer, metasize, metaflags);
free(allocbuffer);
if (err != CHDERR_NONE)
break;
}
}
return err;
} | /*-------------------------------------------------
chdman_clone_metadata - clone the metadata from
one CHD to a second
-------------------------------------------------*/ | clone the metadata from
one CHD to a second | [
"clone",
"the",
"metadata",
"from",
"one",
"CHD",
"to",
"a",
"second"
] | static chd_error chdman_clone_metadata(chd_file *source, chd_file *dest)
{
const chd_header *header = chd_get_header(source);
UINT8 metabuffer[MAX(4096, sizeof(cdrom_toc))];
UINT32 metatag, metasize, metaindex;
UINT8 metaflags;
chd_error err;
for (metaindex = 0; ; metaindex++)
{
err = chd_get_metadata(source, CHDMETATAG_WILDCARD, metaindex, metabuffer, sizeof(metabuffer), &metasize, &metatag, &metaflags);
if (err != CHDERR_NONE)
{
if (err == CHDERR_METADATA_NOT_FOUND)
err = CHDERR_NONE;
break;
}
if (header->version <= 3)
{
if (metatag == HARD_DISK_METADATA_TAG || metatag == CDROM_OLD_METADATA_TAG ||
metatag == CDROM_TRACK_METADATA_TAG || metatag == AV_METADATA_TAG ||
metatag == AV_LD_METADATA_TAG)
{
metaflags |= CHD_MDFLAGS_CHECKSUM;
}
if (metatag == CDROM_OLD_METADATA_TAG)
{
cdrom_toc *toc = (cdrom_toc *)metabuffer;
err = cdrom_parse_metadata(source, toc);
if (err == CHDERR_NONE)
err = cdrom_write_metadata(dest, toc);
if (err == CHDERR_NONE)
continue;
}
}
if (metasize <= sizeof(metabuffer))
{
err = chd_set_metadata(dest, metatag, CHD_METAINDEX_APPEND, metabuffer, metasize, metaflags);
if (err != CHDERR_NONE)
break;
}
else
{
UINT8 *allocbuffer = (UINT8 *)malloc(metasize);
if (allocbuffer == NULL)
{
err = CHDERR_OUT_OF_MEMORY;
break;
}
err = chd_get_metadata(source, CHDMETATAG_WILDCARD, metaindex, allocbuffer, metasize, &metasize, &metatag, &metaflags);
if (err != CHDERR_NONE)
{
free(allocbuffer);
break;
}
err = chd_set_metadata(dest, metatag, CHD_METAINDEX_APPEND, allocbuffer, metasize, metaflags);
free(allocbuffer);
if (err != CHDERR_NONE)
break;
}
}
return err;
} | [
"static",
"chd_error",
"chdman_clone_metadata",
"(",
"chd_file",
"*",
"source",
",",
"chd_file",
"*",
"dest",
")",
"{",
"const",
"chd_header",
"*",
"header",
"=",
"chd_get_header",
"(",
"source",
")",
";",
"UINT8",
"metabuffer",
"[",
"MAX",
"(",
"4096",
",",
"sizeof",
"(",
"cdrom_toc",
")",
")",
"]",
";",
"UINT32",
"metatag",
",",
"metasize",
",",
"metaindex",
";",
"UINT8",
"metaflags",
";",
"chd_error",
"err",
";",
"for",
"(",
"metaindex",
"=",
"0",
";",
";",
"metaindex",
"++",
")",
"{",
"err",
"=",
"chd_get_metadata",
"(",
"source",
",",
"CHDMETATAG_WILDCARD",
",",
"metaindex",
",",
"metabuffer",
",",
"sizeof",
"(",
"metabuffer",
")",
",",
"&",
"metasize",
",",
"&",
"metatag",
",",
"&",
"metaflags",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"if",
"(",
"err",
"==",
"CHDERR_METADATA_NOT_FOUND",
")",
"err",
"=",
"CHDERR_NONE",
";",
"break",
";",
"}",
"if",
"(",
"header",
"->",
"version",
"<=",
"3",
")",
"{",
"if",
"(",
"metatag",
"==",
"HARD_DISK_METADATA_TAG",
"||",
"metatag",
"==",
"CDROM_OLD_METADATA_TAG",
"||",
"metatag",
"==",
"CDROM_TRACK_METADATA_TAG",
"||",
"metatag",
"==",
"AV_METADATA_TAG",
"||",
"metatag",
"==",
"AV_LD_METADATA_TAG",
")",
"{",
"metaflags",
"|=",
"CHD_MDFLAGS_CHECKSUM",
";",
"}",
"if",
"(",
"metatag",
"==",
"CDROM_OLD_METADATA_TAG",
")",
"{",
"cdrom_toc",
"*",
"toc",
"=",
"(",
"cdrom_toc",
"*",
")",
"metabuffer",
";",
"err",
"=",
"cdrom_parse_metadata",
"(",
"source",
",",
"toc",
")",
";",
"if",
"(",
"err",
"==",
"CHDERR_NONE",
")",
"err",
"=",
"cdrom_write_metadata",
"(",
"dest",
",",
"toc",
")",
";",
"if",
"(",
"err",
"==",
"CHDERR_NONE",
")",
"continue",
";",
"}",
"}",
"if",
"(",
"metasize",
"<=",
"sizeof",
"(",
"metabuffer",
")",
")",
"{",
"err",
"=",
"chd_set_metadata",
"(",
"dest",
",",
"metatag",
",",
"CHD_METAINDEX_APPEND",
",",
"metabuffer",
",",
"metasize",
",",
"metaflags",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"break",
";",
"}",
"else",
"{",
"UINT8",
"*",
"allocbuffer",
"=",
"(",
"UINT8",
"*",
")",
"malloc",
"(",
"metasize",
")",
";",
"if",
"(",
"allocbuffer",
"==",
"NULL",
")",
"{",
"err",
"=",
"CHDERR_OUT_OF_MEMORY",
";",
"break",
";",
"}",
"err",
"=",
"chd_get_metadata",
"(",
"source",
",",
"CHDMETATAG_WILDCARD",
",",
"metaindex",
",",
"allocbuffer",
",",
"metasize",
",",
"&",
"metasize",
",",
"&",
"metatag",
",",
"&",
"metaflags",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"free",
"(",
"allocbuffer",
")",
";",
"break",
";",
"}",
"err",
"=",
"chd_set_metadata",
"(",
"dest",
",",
"metatag",
",",
"CHD_METAINDEX_APPEND",
",",
"allocbuffer",
",",
"metasize",
",",
"metaflags",
")",
";",
"free",
"(",
"allocbuffer",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"break",
";",
"}",
"}",
"return",
"err",
";",
"}"
] | chdman_clone_metadata - clone the metadata from
one CHD to a second | [
"chdman_clone_metadata",
"-",
"clone",
"the",
"metadata",
"from",
"one",
"CHD",
"to",
"a",
"second"
] | [
"/* clone the metadata */",
"/* fetch the next piece of metadata */",
"/* promote certain bits of metadata to checksummed for older CHDs */",
"/* convert old-style CD-ROM data to newer */",
"/* if that fit, just write it back from the temporary buffer */",
"/* write it to the target */",
"/* otherwise, allocate a bigger temporary buffer */",
"/* re-read the whole thing */",
"/* write it to the target */"
] | [
{
"param": "source",
"type": "chd_file"
},
{
"param": "dest",
"type": "chd_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "source",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dest",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d528771797fae2919f1177088547f86fb9c0b32e | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/sound/okim6295.c | [
"Unlicense"
] | C | okim6295_set_bank_base | void | void okim6295_set_bank_base(const device_config *device, int base)
{
okim6295_state *info = get_safe_token(device);
stream_update(info->stream);
/* if we are setting a non-zero base, and we have no bank, allocate one */
if (info->bank_num == -1 && base != 0)
{
info->bank_num = memory_find_unused_bank(device->machine);
if (info->bank_num == -1)
fatalerror("Unable to allocate bank for oki6295 device '%s'", device->tag);
/* override our memory map with a bank */
memory_install_read8_handler(device->space[0], 0x00000, 0x3ffff, 0, 0, (read8_space_func)SMH_BANK(info->bank_num));
}
/* if we have a bank number, set the base pointer */
if (info->bank_num != -1)
{
info->bank_offs = base;
memory_set_bankptr(device->machine, info->bank_num, device->region + base);
}
} | /**********************************************************************************************
okim6295_set_bank_base -- set the base of the bank for a given voice on a given chip
***********************************************************************************************/ | - set the base of the bank for a given voice on a given chip | [
"-",
"set",
"the",
"base",
"of",
"the",
"bank",
"for",
"a",
"given",
"voice",
"on",
"a",
"given",
"chip"
] | void okim6295_set_bank_base(const device_config *device, int base)
{
okim6295_state *info = get_safe_token(device);
stream_update(info->stream);
if (info->bank_num == -1 && base != 0)
{
info->bank_num = memory_find_unused_bank(device->machine);
if (info->bank_num == -1)
fatalerror("Unable to allocate bank for oki6295 device '%s'", device->tag);
memory_install_read8_handler(device->space[0], 0x00000, 0x3ffff, 0, 0, (read8_space_func)SMH_BANK(info->bank_num));
}
if (info->bank_num != -1)
{
info->bank_offs = base;
memory_set_bankptr(device->machine, info->bank_num, device->region + base);
}
} | [
"void",
"okim6295_set_bank_base",
"(",
"const",
"device_config",
"*",
"device",
",",
"int",
"base",
")",
"{",
"okim6295_state",
"*",
"info",
"=",
"get_safe_token",
"(",
"device",
")",
";",
"stream_update",
"(",
"info",
"->",
"stream",
")",
";",
"if",
"(",
"info",
"->",
"bank_num",
"==",
"-1",
"&&",
"base",
"!=",
"0",
")",
"{",
"info",
"->",
"bank_num",
"=",
"memory_find_unused_bank",
"(",
"device",
"->",
"machine",
")",
";",
"if",
"(",
"info",
"->",
"bank_num",
"==",
"-1",
")",
"fatalerror",
"(",
"\"",
"\"",
",",
"device",
"->",
"tag",
")",
";",
"memory_install_read8_handler",
"(",
"device",
"->",
"space",
"[",
"0",
"]",
",",
"0x00000",
",",
"0x3ffff",
",",
"0",
",",
"0",
",",
"(",
"read8_space_func",
")",
"SMH_BANK",
"(",
"info",
"->",
"bank_num",
")",
")",
";",
"}",
"if",
"(",
"info",
"->",
"bank_num",
"!=",
"-1",
")",
"{",
"info",
"->",
"bank_offs",
"=",
"base",
";",
"memory_set_bankptr",
"(",
"device",
"->",
"machine",
",",
"info",
"->",
"bank_num",
",",
"device",
"->",
"region",
"+",
"base",
")",
";",
"}",
"}"
] | okim6295_set_bank_base -- set the base of the bank for a given voice on a given chip | [
"okim6295_set_bank_base",
"--",
"set",
"the",
"base",
"of",
"the",
"bank",
"for",
"a",
"given",
"voice",
"on",
"a",
"given",
"chip"
] | [
"/* if we are setting a non-zero base, and we have no bank, allocate one */",
"/* override our memory map with a bank */",
"/* if we have a bank number, set the base pointer */"
] | [
{
"param": "device",
"type": "device_config"
},
{
"param": "base",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "device",
"type": "device_config",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "base",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d528771797fae2919f1177088547f86fb9c0b32e | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/sound/okim6295.c | [
"Unlicense"
] | C | okim6295_set_pin7 | void | void okim6295_set_pin7(const device_config *device, int pin7)
{
okim6295_state *info = get_safe_token(device);
int divisor = pin7 ? 132 : 165;
stream_set_sample_rate(info->stream, info->master_clock/divisor);
} | /**********************************************************************************************
okim6295_set_pin7 -- adjust pin 7, which controls the internal clock division
***********************************************************************************************/ | - adjust pin 7, which controls the internal clock division | [
"-",
"adjust",
"pin",
"7",
"which",
"controls",
"the",
"internal",
"clock",
"division"
] | void okim6295_set_pin7(const device_config *device, int pin7)
{
okim6295_state *info = get_safe_token(device);
int divisor = pin7 ? 132 : 165;
stream_set_sample_rate(info->stream, info->master_clock/divisor);
} | [
"void",
"okim6295_set_pin7",
"(",
"const",
"device_config",
"*",
"device",
",",
"int",
"pin7",
")",
"{",
"okim6295_state",
"*",
"info",
"=",
"get_safe_token",
"(",
"device",
")",
";",
"int",
"divisor",
"=",
"pin7",
"?",
"132",
":",
"165",
";",
"stream_set_sample_rate",
"(",
"info",
"->",
"stream",
",",
"info",
"->",
"master_clock",
"/",
"divisor",
")",
";",
"}"
] | okim6295_set_pin7 -- adjust pin 7, which controls the internal clock division | [
"okim6295_set_pin7",
"--",
"adjust",
"pin",
"7",
"which",
"controls",
"the",
"internal",
"clock",
"division"
] | [] | [
{
"param": "device",
"type": "device_config"
},
{
"param": "pin7",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "device",
"type": "device_config",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pin7",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
59137e34a27870ceaa8ce6e85143ce71fda21698 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/sound/sp0256.c | [
"Unlicense"
] | C | limit | INT16 | static INT16 limit(INT16 s)
{
#ifdef HIGH_QUALITY /* Higher quality than the original, but who cares? */
if (s > 8191) return 8191;
if (s < -8192) return -8192;
#else
if (s > 127) return 127;
if (s < -128) return -128;
#endif
return s;
} | /* ======================================================================== */
/* LIMIT -- Limiter function for digital sample output. */
/* ======================================================================== */ | LIMIT -- Limiter function for digital sample output. | [
"LIMIT",
"--",
"Limiter",
"function",
"for",
"digital",
"sample",
"output",
"."
] | static INT16 limit(INT16 s)
{
#ifdef HIGH_QUALITY
if (s > 8191) return 8191;
if (s < -8192) return -8192;
#else
if (s > 127) return 127;
if (s < -128) return -128;
#endif
return s;
} | [
"static",
"INT16",
"limit",
"(",
"INT16",
"s",
")",
"{",
"#ifdef",
"HIGH_QUALITY",
"if",
"(",
"s",
">",
"8191",
")",
"return",
"8191",
";",
"if",
"(",
"s",
"<",
"-8192",
")",
"return",
"-8192",
";",
"#else",
"if",
"(",
"s",
">",
"127",
")",
"return",
"127",
";",
"if",
"(",
"s",
"<",
"-128",
")",
"return",
"-128",
";",
"#endif",
"return",
"s",
";",
"}"
] | LIMIT -- Limiter function for digital sample output. | [
"LIMIT",
"--",
"Limiter",
"function",
"for",
"digital",
"sample",
"output",
"."
] | [
"/* Higher quality than the original, but who cares? */"
] | [
{
"param": "s",
"type": "INT16"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "s",
"type": "INT16",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
59137e34a27870ceaa8ce6e85143ce71fda21698 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/sound/sp0256.c | [
"Unlicense"
] | C | lpc12_regdec | void | static void lpc12_regdec(struct lpc12_t *f)
{
int i;
/* -------------------------------------------------------------------- */
/* Decode the Amplitude and Period registers. Force the 'cnt' to 0 */
/* to get an initial impulse. We compensate elsewhere by setting */
/* the repeat count to "repeat + 1". */
/* -------------------------------------------------------------------- */
f->amp = (f->r[0] & 0x1F) << (((f->r[0] & 0xE0) >> 5) + 0);
f->cnt = 0;
f->per = f->r[1];
/* -------------------------------------------------------------------- */
/* Decode the filter coefficients from the quant table. */
/* -------------------------------------------------------------------- */
for (i = 0; i < 6; i++)
{
#define IQ(x) (((x) & 0x80) ? qtbl[0x7F & -(x)] : -qtbl[(x)])
f->b_coef[stage_map[i]] = IQ(f->r[2 + 2*i]);
f->f_coef[stage_map[i]] = IQ(f->r[3 + 2*i]);
}
/* -------------------------------------------------------------------- */
/* Set the Interp flag based on whether we have interpolation parms */
/* -------------------------------------------------------------------- */
f->interp = f->r[14] || f->r[15];
return;
} | /* ======================================================================== */
/* LPC12_REGDEC -- Decode the register set in the filter bank. */
/* ======================================================================== */ | - Decode the register set in the filter bank. | [
"-",
"Decode",
"the",
"register",
"set",
"in",
"the",
"filter",
"bank",
"."
] | static void lpc12_regdec(struct lpc12_t *f)
{
int i;
f->amp = (f->r[0] & 0x1F) << (((f->r[0] & 0xE0) >> 5) + 0);
f->cnt = 0;
f->per = f->r[1];
for (i = 0; i < 6; i++)
{
#define IQ(x) (((x) & 0x80) ? qtbl[0x7F & -(x)] : -qtbl[(x)])
f->b_coef[stage_map[i]] = IQ(f->r[2 + 2*i]);
f->f_coef[stage_map[i]] = IQ(f->r[3 + 2*i]);
}
f->interp = f->r[14] || f->r[15];
return;
} | [
"static",
"void",
"lpc12_regdec",
"(",
"struct",
"lpc12_t",
"*",
"f",
")",
"{",
"int",
"i",
";",
"f",
"->",
"amp",
"=",
"(",
"f",
"->",
"r",
"[",
"0",
"]",
"&",
"0x1F",
")",
"<<",
"(",
"(",
"(",
"f",
"->",
"r",
"[",
"0",
"]",
"&",
"0xE0",
")",
">>",
"5",
")",
"+",
"0",
")",
";",
"f",
"->",
"cnt",
"=",
"0",
";",
"f",
"->",
"per",
"=",
"f",
"->",
"r",
"[",
"1",
"]",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"6",
";",
"i",
"++",
")",
"{",
"#define",
"IQ",
"(",
"x",
")",
" (((x) & 0x80) ? qtbl[0x7F & -(x)] : -qtbl[(x)])",
"\n\n",
"f",
"->",
"b_coef",
"[",
"stage_map",
"[",
"i",
"]",
"]",
"=",
"IQ",
"(",
"f",
"->",
"r",
"[",
"2",
"+",
"2",
"*",
"i",
"]",
")",
";",
"f",
"->",
"f_coef",
"[",
"stage_map",
"[",
"i",
"]",
"]",
"=",
"IQ",
"(",
"f",
"->",
"r",
"[",
"3",
"+",
"2",
"*",
"i",
"]",
")",
";",
"}",
"f",
"->",
"interp",
"=",
"f",
"->",
"r",
"[",
"14",
"]",
"||",
"f",
"->",
"r",
"[",
"15",
"]",
";",
"return",
";",
"}"
] | LPC12_REGDEC -- Decode the register set in the filter bank. | [
"LPC12_REGDEC",
"--",
"Decode",
"the",
"register",
"set",
"in",
"the",
"filter",
"bank",
"."
] | [
"/* -------------------------------------------------------------------- */",
"/* Decode the Amplitude and Period registers. Force the 'cnt' to 0 */",
"/* to get an initial impulse. We compensate elsewhere by setting */",
"/* the repeat count to \"repeat + 1\". */",
"/* -------------------------------------------------------------------- */",
"/* -------------------------------------------------------------------- */",
"/* Decode the filter coefficients from the quant table. */",
"/* -------------------------------------------------------------------- */",
"/* -------------------------------------------------------------------- */",
"/* Set the Interp flag based on whether we have interpolation parms */",
"/* -------------------------------------------------------------------- */"
] | [
{
"param": "f",
"type": "struct lpc12_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "f",
"type": "struct lpc12_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6c206383e2b4903e7a8ee3fbef5909b66ffa37cc | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/m68000/m68kcpu.c | [
"Unlicense"
] | C | m68008_read_immediate_16 | UINT16 | static UINT16 m68008_read_immediate_16(const address_space *space, offs_t address)
{
offs_t addr = address;
return (memory_decrypted_read_byte(space, addr) << 8) | (memory_decrypted_read_byte(space, addr + 1));
} | /****************************************************************************
* 8-bit data memory interface
****************************************************************************/ | 8-bit data memory interface | [
"8",
"-",
"bit",
"data",
"memory",
"interface"
] | static UINT16 m68008_read_immediate_16(const address_space *space, offs_t address)
{
offs_t addr = address;
return (memory_decrypted_read_byte(space, addr) << 8) | (memory_decrypted_read_byte(space, addr + 1));
} | [
"static",
"UINT16",
"m68008_read_immediate_16",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"address",
")",
"{",
"offs_t",
"addr",
"=",
"address",
";",
"return",
"(",
"memory_decrypted_read_byte",
"(",
"space",
",",
"addr",
")",
"<<",
"8",
")",
"|",
"(",
"memory_decrypted_read_byte",
"(",
"space",
",",
"addr",
"+",
"1",
")",
")",
";",
"}"
] | 8-bit data memory interface | [
"8",
"-",
"bit",
"data",
"memory",
"interface"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "address",
"type": "offs_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "address",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6c206383e2b4903e7a8ee3fbef5909b66ffa37cc | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/m68000/m68kcpu.c | [
"Unlicense"
] | C | read_immediate_16 | UINT16 | static UINT16 read_immediate_16(const address_space *space, offs_t address)
{
m68ki_cpu_core *m68k = get_safe_token(space->cpu);
return memory_decrypted_read_word(space, (address) ^ m68k->memory.opcode_xor);
} | /****************************************************************************
* 16-bit data memory interface
****************************************************************************/ | 16-bit data memory interface | [
"16",
"-",
"bit",
"data",
"memory",
"interface"
] | static UINT16 read_immediate_16(const address_space *space, offs_t address)
{
m68ki_cpu_core *m68k = get_safe_token(space->cpu);
return memory_decrypted_read_word(space, (address) ^ m68k->memory.opcode_xor);
} | [
"static",
"UINT16",
"read_immediate_16",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"address",
")",
"{",
"m68ki_cpu_core",
"*",
"m68k",
"=",
"get_safe_token",
"(",
"space",
"->",
"cpu",
")",
";",
"return",
"memory_decrypted_read_word",
"(",
"space",
",",
"(",
"address",
")",
"^",
"m68k",
"->",
"memory",
".",
"opcode_xor",
")",
";",
"}"
] | 16-bit data memory interface | [
"16",
"-",
"bit",
"data",
"memory",
"interface"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "address",
"type": "offs_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "address",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6c206383e2b4903e7a8ee3fbef5909b66ffa37cc | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/m68000/m68kcpu.c | [
"Unlicense"
] | C | readword_d32 | UINT16 | static UINT16 readword_d32(const address_space *space, offs_t address)
{
UINT16 result;
if (!(address & 1))
return memory_read_word_32be(space, address);
result = memory_read_byte_32be(space, address) << 8;
return result | memory_read_byte_32be(space, address + 1);
} | /* potentially misaligned 16-bit reads with a 32-bit data bus (and 24-bit address bus) */ | potentially misaligned 16-bit reads with a 32-bit data bus (and 24-bit address bus) | [
"potentially",
"misaligned",
"16",
"-",
"bit",
"reads",
"with",
"a",
"32",
"-",
"bit",
"data",
"bus",
"(",
"and",
"24",
"-",
"bit",
"address",
"bus",
")"
] | static UINT16 readword_d32(const address_space *space, offs_t address)
{
UINT16 result;
if (!(address & 1))
return memory_read_word_32be(space, address);
result = memory_read_byte_32be(space, address) << 8;
return result | memory_read_byte_32be(space, address + 1);
} | [
"static",
"UINT16",
"readword_d32",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"address",
")",
"{",
"UINT16",
"result",
";",
"if",
"(",
"!",
"(",
"address",
"&",
"1",
")",
")",
"return",
"memory_read_word_32be",
"(",
"space",
",",
"address",
")",
";",
"result",
"=",
"memory_read_byte_32be",
"(",
"space",
",",
"address",
")",
"<<",
"8",
";",
"return",
"result",
"|",
"memory_read_byte_32be",
"(",
"space",
",",
"address",
"+",
"1",
")",
";",
"}"
] | potentially misaligned 16-bit reads with a 32-bit data bus (and 24-bit address bus) | [
"potentially",
"misaligned",
"16",
"-",
"bit",
"reads",
"with",
"a",
"32",
"-",
"bit",
"data",
"bus",
"(",
"and",
"24",
"-",
"bit",
"address",
"bus",
")"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "address",
"type": "offs_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "address",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6c206383e2b4903e7a8ee3fbef5909b66ffa37cc | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/m68000/m68kcpu.c | [
"Unlicense"
] | C | writeword_d32 | void | static void writeword_d32(const address_space *space, offs_t address, UINT16 data)
{
if (!(address & 1))
{
memory_write_word_32be(space, address, data);
return;
}
memory_write_byte_32be(space, address, data >> 8);
memory_write_byte_32be(space, address + 1, data);
} | /* potentially misaligned 16-bit writes with a 32-bit data bus (and 24-bit address bus) */ | potentially misaligned 16-bit writes with a 32-bit data bus (and 24-bit address bus) | [
"potentially",
"misaligned",
"16",
"-",
"bit",
"writes",
"with",
"a",
"32",
"-",
"bit",
"data",
"bus",
"(",
"and",
"24",
"-",
"bit",
"address",
"bus",
")"
] | static void writeword_d32(const address_space *space, offs_t address, UINT16 data)
{
if (!(address & 1))
{
memory_write_word_32be(space, address, data);
return;
}
memory_write_byte_32be(space, address, data >> 8);
memory_write_byte_32be(space, address + 1, data);
} | [
"static",
"void",
"writeword_d32",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"address",
",",
"UINT16",
"data",
")",
"{",
"if",
"(",
"!",
"(",
"address",
"&",
"1",
")",
")",
"{",
"memory_write_word_32be",
"(",
"space",
",",
"address",
",",
"data",
")",
";",
"return",
";",
"}",
"memory_write_byte_32be",
"(",
"space",
",",
"address",
",",
"data",
">>",
"8",
")",
";",
"memory_write_byte_32be",
"(",
"space",
",",
"address",
"+",
"1",
",",
"data",
")",
";",
"}"
] | potentially misaligned 16-bit writes with a 32-bit data bus (and 24-bit address bus) | [
"potentially",
"misaligned",
"16",
"-",
"bit",
"writes",
"with",
"a",
"32",
"-",
"bit",
"data",
"bus",
"(",
"and",
"24",
"-",
"bit",
"address",
"bus",
")"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "address",
"type": "offs_t"
},
{
"param": "data",
"type": "UINT16"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "address",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": "UINT16",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6c206383e2b4903e7a8ee3fbef5909b66ffa37cc | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/m68000/m68kcpu.c | [
"Unlicense"
] | C | readlong_d32 | UINT32 | static UINT32 readlong_d32(const address_space *space, offs_t address)
{
UINT32 result;
if (!(address & 3))
return memory_read_dword_32be(space, address);
else if (!(address & 1))
{
result = memory_read_word_32be(space, address) << 16;
return result | memory_read_word_32be(space, address + 2);
}
result = memory_read_byte_32be(space, address) << 24;
result |= memory_read_word_32be(space, address + 1) << 8;
return result | memory_read_byte_32be(space, address + 3);
} | /* potentially misaligned 32-bit reads with a 32-bit data bus (and 24-bit address bus) */ | potentially misaligned 32-bit reads with a 32-bit data bus (and 24-bit address bus) | [
"potentially",
"misaligned",
"32",
"-",
"bit",
"reads",
"with",
"a",
"32",
"-",
"bit",
"data",
"bus",
"(",
"and",
"24",
"-",
"bit",
"address",
"bus",
")"
] | static UINT32 readlong_d32(const address_space *space, offs_t address)
{
UINT32 result;
if (!(address & 3))
return memory_read_dword_32be(space, address);
else if (!(address & 1))
{
result = memory_read_word_32be(space, address) << 16;
return result | memory_read_word_32be(space, address + 2);
}
result = memory_read_byte_32be(space, address) << 24;
result |= memory_read_word_32be(space, address + 1) << 8;
return result | memory_read_byte_32be(space, address + 3);
} | [
"static",
"UINT32",
"readlong_d32",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"address",
")",
"{",
"UINT32",
"result",
";",
"if",
"(",
"!",
"(",
"address",
"&",
"3",
")",
")",
"return",
"memory_read_dword_32be",
"(",
"space",
",",
"address",
")",
";",
"else",
"if",
"(",
"!",
"(",
"address",
"&",
"1",
")",
")",
"{",
"result",
"=",
"memory_read_word_32be",
"(",
"space",
",",
"address",
")",
"<<",
"16",
";",
"return",
"result",
"|",
"memory_read_word_32be",
"(",
"space",
",",
"address",
"+",
"2",
")",
";",
"}",
"result",
"=",
"memory_read_byte_32be",
"(",
"space",
",",
"address",
")",
"<<",
"24",
";",
"result",
"|=",
"memory_read_word_32be",
"(",
"space",
",",
"address",
"+",
"1",
")",
"<<",
"8",
";",
"return",
"result",
"|",
"memory_read_byte_32be",
"(",
"space",
",",
"address",
"+",
"3",
")",
";",
"}"
] | potentially misaligned 32-bit reads with a 32-bit data bus (and 24-bit address bus) | [
"potentially",
"misaligned",
"32",
"-",
"bit",
"reads",
"with",
"a",
"32",
"-",
"bit",
"data",
"bus",
"(",
"and",
"24",
"-",
"bit",
"address",
"bus",
")"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "address",
"type": "offs_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "address",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6c206383e2b4903e7a8ee3fbef5909b66ffa37cc | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/m68000/m68kcpu.c | [
"Unlicense"
] | C | writelong_d32 | void | static void writelong_d32(const address_space *space, offs_t address, UINT32 data)
{
if (!(address & 3))
{
memory_write_dword_32be(space, address, data);
return;
}
else if (!(address & 1))
{
memory_write_word_32be(space, address, data >> 16);
memory_write_word_32be(space, address + 2, data);
return;
}
memory_write_byte_32be(space, address, data >> 24);
memory_write_word_32be(space, address + 1, data >> 8);
memory_write_byte_32be(space, address + 3, data);
} | /* potentially misaligned 32-bit writes with a 32-bit data bus (and 24-bit address bus) */ | potentially misaligned 32-bit writes with a 32-bit data bus (and 24-bit address bus) | [
"potentially",
"misaligned",
"32",
"-",
"bit",
"writes",
"with",
"a",
"32",
"-",
"bit",
"data",
"bus",
"(",
"and",
"24",
"-",
"bit",
"address",
"bus",
")"
] | static void writelong_d32(const address_space *space, offs_t address, UINT32 data)
{
if (!(address & 3))
{
memory_write_dword_32be(space, address, data);
return;
}
else if (!(address & 1))
{
memory_write_word_32be(space, address, data >> 16);
memory_write_word_32be(space, address + 2, data);
return;
}
memory_write_byte_32be(space, address, data >> 24);
memory_write_word_32be(space, address + 1, data >> 8);
memory_write_byte_32be(space, address + 3, data);
} | [
"static",
"void",
"writelong_d32",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"address",
",",
"UINT32",
"data",
")",
"{",
"if",
"(",
"!",
"(",
"address",
"&",
"3",
")",
")",
"{",
"memory_write_dword_32be",
"(",
"space",
",",
"address",
",",
"data",
")",
";",
"return",
";",
"}",
"else",
"if",
"(",
"!",
"(",
"address",
"&",
"1",
")",
")",
"{",
"memory_write_word_32be",
"(",
"space",
",",
"address",
",",
"data",
">>",
"16",
")",
";",
"memory_write_word_32be",
"(",
"space",
",",
"address",
"+",
"2",
",",
"data",
")",
";",
"return",
";",
"}",
"memory_write_byte_32be",
"(",
"space",
",",
"address",
",",
"data",
">>",
"24",
")",
";",
"memory_write_word_32be",
"(",
"space",
",",
"address",
"+",
"1",
",",
"data",
">>",
"8",
")",
";",
"memory_write_byte_32be",
"(",
"space",
",",
"address",
"+",
"3",
",",
"data",
")",
";",
"}"
] | potentially misaligned 32-bit writes with a 32-bit data bus (and 24-bit address bus) | [
"potentially",
"misaligned",
"32",
"-",
"bit",
"writes",
"with",
"a",
"32",
"-",
"bit",
"data",
"bus",
"(",
"and",
"24",
"-",
"bit",
"address",
"bus",
")"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "address",
"type": "offs_t"
},
{
"param": "data",
"type": "UINT32"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "address",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6c206383e2b4903e7a8ee3fbef5909b66ffa37cc | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/m68000/m68kcpu.c | [
"Unlicense"
] | C | read_byte_32_mmu | UINT8 | static UINT8 read_byte_32_mmu(const address_space *space, offs_t address)
{
m68ki_cpu_core *m68k = get_safe_token(space->cpu);
if (m68k->pmmu_enabled)
{
address = pmmu_translate_addr(m68k, address);
}
return memory_read_byte_32be(space, address);
} | /* interface for 32-bit data bus with PMMU (68EC020, 68020) */ | interface for 32-bit data bus with PMMU (68EC020, 68020) | [
"interface",
"for",
"32",
"-",
"bit",
"data",
"bus",
"with",
"PMMU",
"(",
"68EC020",
"68020",
")"
] | static UINT8 read_byte_32_mmu(const address_space *space, offs_t address)
{
m68ki_cpu_core *m68k = get_safe_token(space->cpu);
if (m68k->pmmu_enabled)
{
address = pmmu_translate_addr(m68k, address);
}
return memory_read_byte_32be(space, address);
} | [
"static",
"UINT8",
"read_byte_32_mmu",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"address",
")",
"{",
"m68ki_cpu_core",
"*",
"m68k",
"=",
"get_safe_token",
"(",
"space",
"->",
"cpu",
")",
";",
"if",
"(",
"m68k",
"->",
"pmmu_enabled",
")",
"{",
"address",
"=",
"pmmu_translate_addr",
"(",
"m68k",
",",
"address",
")",
";",
"}",
"return",
"memory_read_byte_32be",
"(",
"space",
",",
"address",
")",
";",
"}"
] | interface for 32-bit data bus with PMMU (68EC020, 68020) | [
"interface",
"for",
"32",
"-",
"bit",
"data",
"bus",
"with",
"PMMU",
"(",
"68EC020",
"68020",
")"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "address",
"type": "offs_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "address",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6c206383e2b4903e7a8ee3fbef5909b66ffa37cc | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/m68000/m68kcpu.c | [
"Unlicense"
] | C | readword_d32_mmu | UINT16 | static UINT16 readword_d32_mmu(const address_space *space, offs_t address)
{
m68ki_cpu_core *m68k = get_safe_token(space->cpu);
UINT16 result;
if (m68k->pmmu_enabled)
{
address = pmmu_translate_addr(m68k, address);
}
if (!(address & 1))
return memory_read_word_32be(space, address);
result = memory_read_byte_32be(space, address) << 8;
return result | memory_read_byte_32be(space, address + 1);
} | /* potentially misaligned 16-bit reads with a 32-bit data bus (and 24-bit address bus) */ | potentially misaligned 16-bit reads with a 32-bit data bus (and 24-bit address bus) | [
"potentially",
"misaligned",
"16",
"-",
"bit",
"reads",
"with",
"a",
"32",
"-",
"bit",
"data",
"bus",
"(",
"and",
"24",
"-",
"bit",
"address",
"bus",
")"
] | static UINT16 readword_d32_mmu(const address_space *space, offs_t address)
{
m68ki_cpu_core *m68k = get_safe_token(space->cpu);
UINT16 result;
if (m68k->pmmu_enabled)
{
address = pmmu_translate_addr(m68k, address);
}
if (!(address & 1))
return memory_read_word_32be(space, address);
result = memory_read_byte_32be(space, address) << 8;
return result | memory_read_byte_32be(space, address + 1);
} | [
"static",
"UINT16",
"readword_d32_mmu",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"address",
")",
"{",
"m68ki_cpu_core",
"*",
"m68k",
"=",
"get_safe_token",
"(",
"space",
"->",
"cpu",
")",
";",
"UINT16",
"result",
";",
"if",
"(",
"m68k",
"->",
"pmmu_enabled",
")",
"{",
"address",
"=",
"pmmu_translate_addr",
"(",
"m68k",
",",
"address",
")",
";",
"}",
"if",
"(",
"!",
"(",
"address",
"&",
"1",
")",
")",
"return",
"memory_read_word_32be",
"(",
"space",
",",
"address",
")",
";",
"result",
"=",
"memory_read_byte_32be",
"(",
"space",
",",
"address",
")",
"<<",
"8",
";",
"return",
"result",
"|",
"memory_read_byte_32be",
"(",
"space",
",",
"address",
"+",
"1",
")",
";",
"}"
] | potentially misaligned 16-bit reads with a 32-bit data bus (and 24-bit address bus) | [
"potentially",
"misaligned",
"16",
"-",
"bit",
"reads",
"with",
"a",
"32",
"-",
"bit",
"data",
"bus",
"(",
"and",
"24",
"-",
"bit",
"address",
"bus",
")"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "address",
"type": "offs_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "address",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6c206383e2b4903e7a8ee3fbef5909b66ffa37cc | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/m68000/m68kcpu.c | [
"Unlicense"
] | C | writeword_d32_mmu | void | static void writeword_d32_mmu(const address_space *space, offs_t address, UINT16 data)
{
m68ki_cpu_core *m68k = get_safe_token(space->cpu);
if (m68k->pmmu_enabled)
{
address = pmmu_translate_addr(m68k, address);
}
if (!(address & 1))
{
memory_write_word_32be(space, address, data);
return;
}
memory_write_byte_32be(space, address, data >> 8);
memory_write_byte_32be(space, address + 1, data);
} | /* potentially misaligned 16-bit writes with a 32-bit data bus (and 24-bit address bus) */ | potentially misaligned 16-bit writes with a 32-bit data bus (and 24-bit address bus) | [
"potentially",
"misaligned",
"16",
"-",
"bit",
"writes",
"with",
"a",
"32",
"-",
"bit",
"data",
"bus",
"(",
"and",
"24",
"-",
"bit",
"address",
"bus",
")"
] | static void writeword_d32_mmu(const address_space *space, offs_t address, UINT16 data)
{
m68ki_cpu_core *m68k = get_safe_token(space->cpu);
if (m68k->pmmu_enabled)
{
address = pmmu_translate_addr(m68k, address);
}
if (!(address & 1))
{
memory_write_word_32be(space, address, data);
return;
}
memory_write_byte_32be(space, address, data >> 8);
memory_write_byte_32be(space, address + 1, data);
} | [
"static",
"void",
"writeword_d32_mmu",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"address",
",",
"UINT16",
"data",
")",
"{",
"m68ki_cpu_core",
"*",
"m68k",
"=",
"get_safe_token",
"(",
"space",
"->",
"cpu",
")",
";",
"if",
"(",
"m68k",
"->",
"pmmu_enabled",
")",
"{",
"address",
"=",
"pmmu_translate_addr",
"(",
"m68k",
",",
"address",
")",
";",
"}",
"if",
"(",
"!",
"(",
"address",
"&",
"1",
")",
")",
"{",
"memory_write_word_32be",
"(",
"space",
",",
"address",
",",
"data",
")",
";",
"return",
";",
"}",
"memory_write_byte_32be",
"(",
"space",
",",
"address",
",",
"data",
">>",
"8",
")",
";",
"memory_write_byte_32be",
"(",
"space",
",",
"address",
"+",
"1",
",",
"data",
")",
";",
"}"
] | potentially misaligned 16-bit writes with a 32-bit data bus (and 24-bit address bus) | [
"potentially",
"misaligned",
"16",
"-",
"bit",
"writes",
"with",
"a",
"32",
"-",
"bit",
"data",
"bus",
"(",
"and",
"24",
"-",
"bit",
"address",
"bus",
")"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "address",
"type": "offs_t"
},
{
"param": "data",
"type": "UINT16"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "address",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": "UINT16",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.