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
6b3f3a42553d6602ab7cfadd1cc1914206d0a431
lofunz/mieme
Reloaded/trunk/src/mame/machine/snesdsp1.c
[ "Unlicense" ]
C
dsp1_gyrate
void
static void dsp1_gyrate( INT16 *input, INT16 *output ) { INT16 Az = input[0]; INT16 Ax = input[1]; INT16 Ay = input[2]; INT16 U = input[3]; INT16 F = input[4]; INT16 L = input[5]; INT16* Rz = &output[0]; INT16* Rx = &output[1]; INT16* Ry = &output[2]; INT16 CSec, ESec, CSin, C, E; INT16 SinAy = dsp1_sin(Ay); INT16 CosAy = dsp1_cos(Ay); inverse(dsp1_cos(Ax), 0, &CSec, &ESec); // Rotation Around Z normalize_double(U * CosAy - F * SinAy, &C, &E); E = ESec - E; normalize(C * CSec >> 15, &C, &E); *Rz = Az + denormalize_and_clip(C, E); // Rotation Around X *Rx = Ax + (U * SinAy >> 15) + (F * CosAy >> 15); // Rotation Around Y normalize_double(U * CosAy + F * SinAy, &C, &E); E = ESec - E; normalize(dsp1_sin(Ax), &CSin, &E); normalize(-(C * (CSec * CSin >> 15) >> 15), &C, &E); *Ry = Ay + denormalize_and_clip(C, E) + L; }
// This command determines the final attitude angles after the body with attitude angles (Ax, Ay, Az) with // respect to the global coordinates is rotated by the minor angular displacements (DeltaF, DeltaL, DeltaU). // It means that the XYZ axes are rotated by (Ax, Ay, Az) to obtain the FLU axes and, then, these // are rotated by (DeltaF, DeltaL, DeltaU). The command calculates and return the new FLU angles respect to the // XYZ system (Rx, Ry, Rz) // The formulae are: // Rx = Ax + (DeltaU*sin(Ay)+DeltaF*cos(Ay)) // Ry = Ay + DeltaL - tan(Ax)*(DeltaU*cos(Ay)+DeltaF*sin(Ay)) // Rz = Az + sec(Ax)*(DeltaU*cos(Ay)-DeltaF*sin(Ay)) // // Now the discussion: according to the official documentation, as described in various commands, you pass from // XYZ to FLU by doing the rotations in the order Y, X, Z. In this command, the formulae are coherent with the // fact that Y is the first axis to do a rotation around it. However, in the "attitude" command, while the official // document describe it that way, we have discovered, when reverse engineering the command, that the calculated // matrix do the rotation around Y in the second place. This incoherent behaviour of various commands is, in my // opinion, a pretty severe implementation error. However, if you only use small "minor displacements", the error term // introduced by that incoherence should be almost negligible.
This command determines the final attitude angles after the body with attitude angles (Ax, Ay, Az) with respect to the global coordinates is rotated by the minor angular displacements (DeltaF, DeltaL, DeltaU). It means that the XYZ axes are rotated by (Ax, Ay, Az) to obtain the FLU axes and, then, these are rotated by (DeltaF, DeltaL, DeltaU). Now the discussion: according to the official documentation, as described in various commands, you pass from XYZ to FLU by doing the rotations in the order Y, X, Z. In this command, the formulae are coherent with the fact that Y is the first axis to do a rotation around it. However, in the "attitude" command, while the official document describe it that way, we have discovered, when reverse engineering the command, that the calculated matrix do the rotation around Y in the second place. This incoherent behaviour of various commands is, in my opinion, a pretty severe implementation error. However, if you only use small "minor displacements", the error term introduced by that incoherence should be almost negligible.
[ "This", "command", "determines", "the", "final", "attitude", "angles", "after", "the", "body", "with", "attitude", "angles", "(", "Ax", "Ay", "Az", ")", "with", "respect", "to", "the", "global", "coordinates", "is", "rotated", "by", "the", "minor", "angular", "displacements", "(", "DeltaF", "DeltaL", "DeltaU", ")", ".", "It", "means", "that", "the", "XYZ", "axes", "are", "rotated", "by", "(", "Ax", "Ay", "Az", ")", "to", "obtain", "the", "FLU", "axes", "and", "then", "these", "are", "rotated", "by", "(", "DeltaF", "DeltaL", "DeltaU", ")", ".", "Now", "the", "discussion", ":", "according", "to", "the", "official", "documentation", "as", "described", "in", "various", "commands", "you", "pass", "from", "XYZ", "to", "FLU", "by", "doing", "the", "rotations", "in", "the", "order", "Y", "X", "Z", ".", "In", "this", "command", "the", "formulae", "are", "coherent", "with", "the", "fact", "that", "Y", "is", "the", "first", "axis", "to", "do", "a", "rotation", "around", "it", ".", "However", "in", "the", "\"", "attitude", "\"", "command", "while", "the", "official", "document", "describe", "it", "that", "way", "we", "have", "discovered", "when", "reverse", "engineering", "the", "command", "that", "the", "calculated", "matrix", "do", "the", "rotation", "around", "Y", "in", "the", "second", "place", ".", "This", "incoherent", "behaviour", "of", "various", "commands", "is", "in", "my", "opinion", "a", "pretty", "severe", "implementation", "error", ".", "However", "if", "you", "only", "use", "small", "\"", "minor", "displacements", "\"", "the", "error", "term", "introduced", "by", "that", "incoherence", "should", "be", "almost", "negligible", "." ]
static void dsp1_gyrate( INT16 *input, INT16 *output ) { INT16 Az = input[0]; INT16 Ax = input[1]; INT16 Ay = input[2]; INT16 U = input[3]; INT16 F = input[4]; INT16 L = input[5]; INT16* Rz = &output[0]; INT16* Rx = &output[1]; INT16* Ry = &output[2]; INT16 CSec, ESec, CSin, C, E; INT16 SinAy = dsp1_sin(Ay); INT16 CosAy = dsp1_cos(Ay); inverse(dsp1_cos(Ax), 0, &CSec, &ESec); normalize_double(U * CosAy - F * SinAy, &C, &E); E = ESec - E; normalize(C * CSec >> 15, &C, &E); *Rz = Az + denormalize_and_clip(C, E); *Rx = Ax + (U * SinAy >> 15) + (F * CosAy >> 15); normalize_double(U * CosAy + F * SinAy, &C, &E); E = ESec - E; normalize(dsp1_sin(Ax), &CSin, &E); normalize(-(C * (CSec * CSin >> 15) >> 15), &C, &E); *Ry = Ay + denormalize_and_clip(C, E) + L; }
[ "static", "void", "dsp1_gyrate", "(", "INT16", "*", "input", ",", "INT16", "*", "output", ")", "{", "INT16", "Az", "=", "input", "[", "0", "]", ";", "INT16", "Ax", "=", "input", "[", "1", "]", ";", "INT16", "Ay", "=", "input", "[", "2", "]", ";", "INT16", "U", "=", "input", "[", "3", "]", ";", "INT16", "F", "=", "input", "[", "4", "]", ";", "INT16", "L", "=", "input", "[", "5", "]", ";", "INT16", "*", "Rz", "=", "&", "output", "[", "0", "]", ";", "INT16", "*", "Rx", "=", "&", "output", "[", "1", "]", ";", "INT16", "*", "Ry", "=", "&", "output", "[", "2", "]", ";", "INT16", "CSec", ",", "ESec", ",", "CSin", ",", "C", ",", "E", ";", "INT16", "SinAy", "=", "dsp1_sin", "(", "Ay", ")", ";", "INT16", "CosAy", "=", "dsp1_cos", "(", "Ay", ")", ";", "inverse", "(", "dsp1_cos", "(", "Ax", ")", ",", "0", ",", "&", "CSec", ",", "&", "ESec", ")", ";", "normalize_double", "(", "U", "*", "CosAy", "-", "F", "*", "SinAy", ",", "&", "C", ",", "&", "E", ")", ";", "E", "=", "ESec", "-", "E", ";", "normalize", "(", "C", "*", "CSec", ">>", "15", ",", "&", "C", ",", "&", "E", ")", ";", "*", "Rz", "=", "Az", "+", "denormalize_and_clip", "(", "C", ",", "E", ")", ";", "*", "Rx", "=", "Ax", "+", "(", "U", "*", "SinAy", ">>", "15", ")", "+", "(", "F", "*", "CosAy", ">>", "15", ")", ";", "normalize_double", "(", "U", "*", "CosAy", "+", "F", "*", "SinAy", ",", "&", "C", ",", "&", "E", ")", ";", "E", "=", "ESec", "-", "E", ";", "normalize", "(", "dsp1_sin", "(", "Ax", ")", ",", "&", "CSin", ",", "&", "E", ")", ";", "normalize", "(", "-", "(", "C", "*", "(", "CSec", "*", "CSin", ">>", "15", ")", ">>", "15", ")", ",", "&", "C", ",", "&", "E", ")", ";", "*", "Ry", "=", "Ay", "+", "denormalize_and_clip", "(", "C", ",", "E", ")", "+", "L", ";", "}" ]
This command determines the final attitude angles after the body with attitude angles (Ax, Ay, Az) with respect to the global coordinates is rotated by the minor angular displacements (DeltaF, DeltaL, DeltaU).
[ "This", "command", "determines", "the", "final", "attitude", "angles", "after", "the", "body", "with", "attitude", "angles", "(", "Ax", "Ay", "Az", ")", "with", "respect", "to", "the", "global", "coordinates", "is", "rotated", "by", "the", "minor", "angular", "displacements", "(", "DeltaF", "DeltaL", "DeltaU", ")", "." ]
[ "// Rotation Around Z\r", "// Rotation Around X\r", "// Rotation Around Y\r" ]
[ { "param": "input", "type": "INT16" }, { "param": "output", "type": "INT16" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "input", "type": "INT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "output", "type": "INT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6b3f3a42553d6602ab7cfadd1cc1914206d0a431
lofunz/mieme
Reloaded/trunk/src/mame/machine/snesdsp1.c
[ "Unlicense" ]
C
dsp1_raster
void
static void dsp1_raster( INT16 *input, INT16 *output ) { INT16 Vs = input[0]; INT16* An = &output[0]; INT16* Bn = &output[1]; INT16* Cn = &output[2]; INT16* Dn = &output[3]; INT16 C, E, C1, E1; inverse((Vs * dsp1_state.shared.SinAzs >> 15) + dsp1_state.shared.VOffset, 7, &C, &E); E += dsp1_state.shared.CentreZ_E; C1 = C * dsp1_state.shared.CentreZ_C >> 15; E1 = E + dsp1_state.shared.SecAZS_E2; normalize(C1, &C, &E); C = denormalize_and_clip(C, E); *An = C * dsp1_state.shared.CosAas >> 15; *Cn = C * dsp1_state.shared.SinAas >> 15; normalize(C1 * dsp1_state.shared.SecAZS_C2 >> 15, &C, &E1); C = denormalize_and_clip(C, E1); *Bn = C * -dsp1_state.shared.SinAas >> 15; *Dn = C * dsp1_state.shared.CosAas >> 15; }
// Calculates the matrix which transform an object situated on a raster line (Vs) into // his projection over the ground. The modified SecAZS is used here, so // i don't understand the fine details, but, basically, it's done // this way: The vertical offset between the point of projection and the // raster line is calculated (Vs*SinAzs>>15)+VOffset, then the height of // the center of projection is measured in that units (*CentreZ_C). If, now // you consider the "reference case" (center of projection at an unit of height), // the projection of a thin strip containing the raster line will have the same // width (as the raster line would be on the ground in this case, but will suffer a // change of scale in height (as the ground and the vertical axis would form an angle of 180-Azs degrees). // This scale factor, when the angle 'center of screen-center of projection-raster line' is small, // can be aproximated by the one of the center of the screen, 1/cos(Azs).(**) (Here is when it's used // SecAZS). By last, you have to consider the effect of the azimuth angle Aas, and you are done. // // Using matrix notation: // |A B| Centre_ZS | cos(Aas) -sin(Aas)| | 1 0 | // ProjectionMatrix = | | = ----------- * | | * | | // |C D| Vs*sin(Azs) | sin(Aas) cos(Aas)| | 0 sec(Azs)| // // (**) // If Les=1, the vertical offset between the center // of projection and the center of the screen is Cos(Azs); then, if the vertical // offset is 1, the ratio of the projection over the ground respect to the // line on the screen is 1/cos(Azs).
Calculates the matrix which transform an object situated on a raster line (Vs) into his projection over the ground. The modified SecAZS is used here, so i don't understand the fine details, but, basically, it's done this way: The vertical offset between the point of projection and the raster line is calculated (Vs*SinAzs>>15)+VOffset, then the height of the center of projection is measured in that units (*CentreZ_C). If, now you consider the "reference case" (center of projection at an unit of height), the projection of a thin strip containing the raster line will have the same width (as the raster line would be on the ground in this case, but will suffer a change of scale in height (as the ground and the vertical axis would form an angle of 180-Azs degrees). This scale factor, when the angle 'center of screen-center of projection-raster line' is small, can be aproximated by the one of the center of the screen, 1/cos(Azs).(**) (Here is when it's used SecAZS). By last, you have to consider the effect of the azimuth angle Aas, and you are done. (**) If Les=1, the vertical offset between the center of projection and the center of the screen is Cos(Azs); then, if the vertical offset is 1, the ratio of the projection over the ground respect to the line on the screen is 1/cos(Azs).
[ "Calculates", "the", "matrix", "which", "transform", "an", "object", "situated", "on", "a", "raster", "line", "(", "Vs", ")", "into", "his", "projection", "over", "the", "ground", ".", "The", "modified", "SecAZS", "is", "used", "here", "so", "i", "don", "'", "t", "understand", "the", "fine", "details", "but", "basically", "it", "'", "s", "done", "this", "way", ":", "The", "vertical", "offset", "between", "the", "point", "of", "projection", "and", "the", "raster", "line", "is", "calculated", "(", "Vs", "*", "SinAzs", ">>", "15", ")", "+", "VOffset", "then", "the", "height", "of", "the", "center", "of", "projection", "is", "measured", "in", "that", "units", "(", "*", "CentreZ_C", ")", ".", "If", "now", "you", "consider", "the", "\"", "reference", "case", "\"", "(", "center", "of", "projection", "at", "an", "unit", "of", "height", ")", "the", "projection", "of", "a", "thin", "strip", "containing", "the", "raster", "line", "will", "have", "the", "same", "width", "(", "as", "the", "raster", "line", "would", "be", "on", "the", "ground", "in", "this", "case", "but", "will", "suffer", "a", "change", "of", "scale", "in", "height", "(", "as", "the", "ground", "and", "the", "vertical", "axis", "would", "form", "an", "angle", "of", "180", "-", "Azs", "degrees", ")", ".", "This", "scale", "factor", "when", "the", "angle", "'", "center", "of", "screen", "-", "center", "of", "projection", "-", "raster", "line", "'", "is", "small", "can", "be", "aproximated", "by", "the", "one", "of", "the", "center", "of", "the", "screen", "1", "/", "cos", "(", "Azs", ")", ".", "(", "**", ")", "(", "Here", "is", "when", "it", "'", "s", "used", "SecAZS", ")", ".", "By", "last", "you", "have", "to", "consider", "the", "effect", "of", "the", "azimuth", "angle", "Aas", "and", "you", "are", "done", ".", "(", "**", ")", "If", "Les", "=", "1", "the", "vertical", "offset", "between", "the", "center", "of", "projection", "and", "the", "center", "of", "the", "screen", "is", "Cos", "(", "Azs", ")", ";", "then", "if", "the", "vertical", "offset", "is", "1", "the", "ratio", "of", "the", "projection", "over", "the", "ground", "respect", "to", "the", "line", "on", "the", "screen", "is", "1", "/", "cos", "(", "Azs", ")", "." ]
static void dsp1_raster( INT16 *input, INT16 *output ) { INT16 Vs = input[0]; INT16* An = &output[0]; INT16* Bn = &output[1]; INT16* Cn = &output[2]; INT16* Dn = &output[3]; INT16 C, E, C1, E1; inverse((Vs * dsp1_state.shared.SinAzs >> 15) + dsp1_state.shared.VOffset, 7, &C, &E); E += dsp1_state.shared.CentreZ_E; C1 = C * dsp1_state.shared.CentreZ_C >> 15; E1 = E + dsp1_state.shared.SecAZS_E2; normalize(C1, &C, &E); C = denormalize_and_clip(C, E); *An = C * dsp1_state.shared.CosAas >> 15; *Cn = C * dsp1_state.shared.SinAas >> 15; normalize(C1 * dsp1_state.shared.SecAZS_C2 >> 15, &C, &E1); C = denormalize_and_clip(C, E1); *Bn = C * -dsp1_state.shared.SinAas >> 15; *Dn = C * dsp1_state.shared.CosAas >> 15; }
[ "static", "void", "dsp1_raster", "(", "INT16", "*", "input", ",", "INT16", "*", "output", ")", "{", "INT16", "Vs", "=", "input", "[", "0", "]", ";", "INT16", "*", "An", "=", "&", "output", "[", "0", "]", ";", "INT16", "*", "Bn", "=", "&", "output", "[", "1", "]", ";", "INT16", "*", "Cn", "=", "&", "output", "[", "2", "]", ";", "INT16", "*", "Dn", "=", "&", "output", "[", "3", "]", ";", "INT16", "C", ",", "E", ",", "C1", ",", "E1", ";", "inverse", "(", "(", "Vs", "*", "dsp1_state", ".", "shared", ".", "SinAzs", ">>", "15", ")", "+", "dsp1_state", ".", "shared", ".", "VOffset", ",", "7", ",", "&", "C", ",", "&", "E", ")", ";", "E", "+=", "dsp1_state", ".", "shared", ".", "CentreZ_E", ";", "C1", "=", "C", "*", "dsp1_state", ".", "shared", ".", "CentreZ_C", ">>", "15", ";", "E1", "=", "E", "+", "dsp1_state", ".", "shared", ".", "SecAZS_E2", ";", "normalize", "(", "C1", ",", "&", "C", ",", "&", "E", ")", ";", "C", "=", "denormalize_and_clip", "(", "C", ",", "E", ")", ";", "*", "An", "=", "C", "*", "dsp1_state", ".", "shared", ".", "CosAas", ">>", "15", ";", "*", "Cn", "=", "C", "*", "dsp1_state", ".", "shared", ".", "SinAas", ">>", "15", ";", "normalize", "(", "C1", "*", "dsp1_state", ".", "shared", ".", "SecAZS_C2", ">>", "15", ",", "&", "C", ",", "&", "E1", ")", ";", "C", "=", "denormalize_and_clip", "(", "C", ",", "E1", ")", ";", "*", "Bn", "=", "C", "*", "-", "dsp1_state", ".", "shared", ".", "SinAas", ">>", "15", ";", "*", "Dn", "=", "C", "*", "dsp1_state", ".", "shared", ".", "CosAas", ">>", "15", ";", "}" ]
Calculates the matrix which transform an object situated on a raster line (Vs) into his projection over the ground.
[ "Calculates", "the", "matrix", "which", "transform", "an", "object", "situated", "on", "a", "raster", "line", "(", "Vs", ")", "into", "his", "projection", "over", "the", "ground", "." ]
[]
[ { "param": "input", "type": "INT16" }, { "param": "output", "type": "INT16" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "input", "type": "INT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "output", "type": "INT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6b3f3a42553d6602ab7cfadd1cc1914206d0a431
lofunz/mieme
Reloaded/trunk/src/mame/machine/snesdsp1.c
[ "Unlicense" ]
C
dsp1_target
void
static void dsp1_target( INT16 *input, INT16 *output ) { INT16 H = input[0]; INT16 V = input[1]; INT16* X = &output[0]; INT16* Y = &output[1]; INT16 C, E, C1, E1; inverse((V * dsp1_state.shared.SinAzs >> 15) + dsp1_state.shared.VOffset, 8, &C, &E); E += dsp1_state.shared.CentreZ_E; C1 = C * dsp1_state.shared.CentreZ_C >> 15; E1 = E + dsp1_state.shared.SecAZS_E1; H <<= 8; normalize(C1, &C, &E); C = denormalize_and_clip(C, E) * H >> 15; *X = dsp1_state.shared.CentreX + (C * dsp1_state.shared.CosAas >> 15); *Y = dsp1_state.shared.CentreY - (C * dsp1_state.shared.SinAas >> 15); V <<= 8; normalize(C1 * dsp1_state.shared.SecAZS_C1 >> 15, &C, &E1); C = denormalize_and_clip(C, E1) * V >> 15; *X += C * -dsp1_state.shared.SinAas >> 15; *Y += C * dsp1_state.shared.CosAas >> 15; }
// Calculate the projection over the ground of a selected point of screen // It simply apply the projection matrix described in the "Raster" command // to the vector (H,V) transposed, and add the result to the position of // the centre of projection. // The only special point to take into account is the directions on the screen: // H is positive rightward, but V is positive downward; this is why // the signs take that configuration
Calculate the projection over the ground of a selected point of screen It simply apply the projection matrix described in the "Raster" command to the vector (H,V) transposed, and add the result to the position of the centre of projection. The only special point to take into account is the directions on the screen: H is positive rightward, but V is positive downward; this is why the signs take that configuration
[ "Calculate", "the", "projection", "over", "the", "ground", "of", "a", "selected", "point", "of", "screen", "It", "simply", "apply", "the", "projection", "matrix", "described", "in", "the", "\"", "Raster", "\"", "command", "to", "the", "vector", "(", "H", "V", ")", "transposed", "and", "add", "the", "result", "to", "the", "position", "of", "the", "centre", "of", "projection", ".", "The", "only", "special", "point", "to", "take", "into", "account", "is", "the", "directions", "on", "the", "screen", ":", "H", "is", "positive", "rightward", "but", "V", "is", "positive", "downward", ";", "this", "is", "why", "the", "signs", "take", "that", "configuration" ]
static void dsp1_target( INT16 *input, INT16 *output ) { INT16 H = input[0]; INT16 V = input[1]; INT16* X = &output[0]; INT16* Y = &output[1]; INT16 C, E, C1, E1; inverse((V * dsp1_state.shared.SinAzs >> 15) + dsp1_state.shared.VOffset, 8, &C, &E); E += dsp1_state.shared.CentreZ_E; C1 = C * dsp1_state.shared.CentreZ_C >> 15; E1 = E + dsp1_state.shared.SecAZS_E1; H <<= 8; normalize(C1, &C, &E); C = denormalize_and_clip(C, E) * H >> 15; *X = dsp1_state.shared.CentreX + (C * dsp1_state.shared.CosAas >> 15); *Y = dsp1_state.shared.CentreY - (C * dsp1_state.shared.SinAas >> 15); V <<= 8; normalize(C1 * dsp1_state.shared.SecAZS_C1 >> 15, &C, &E1); C = denormalize_and_clip(C, E1) * V >> 15; *X += C * -dsp1_state.shared.SinAas >> 15; *Y += C * dsp1_state.shared.CosAas >> 15; }
[ "static", "void", "dsp1_target", "(", "INT16", "*", "input", ",", "INT16", "*", "output", ")", "{", "INT16", "H", "=", "input", "[", "0", "]", ";", "INT16", "V", "=", "input", "[", "1", "]", ";", "INT16", "*", "X", "=", "&", "output", "[", "0", "]", ";", "INT16", "*", "Y", "=", "&", "output", "[", "1", "]", ";", "INT16", "C", ",", "E", ",", "C1", ",", "E1", ";", "inverse", "(", "(", "V", "*", "dsp1_state", ".", "shared", ".", "SinAzs", ">>", "15", ")", "+", "dsp1_state", ".", "shared", ".", "VOffset", ",", "8", ",", "&", "C", ",", "&", "E", ")", ";", "E", "+=", "dsp1_state", ".", "shared", ".", "CentreZ_E", ";", "C1", "=", "C", "*", "dsp1_state", ".", "shared", ".", "CentreZ_C", ">>", "15", ";", "E1", "=", "E", "+", "dsp1_state", ".", "shared", ".", "SecAZS_E1", ";", "H", "<<=", "8", ";", "normalize", "(", "C1", ",", "&", "C", ",", "&", "E", ")", ";", "C", "=", "denormalize_and_clip", "(", "C", ",", "E", ")", "*", "H", ">>", "15", ";", "*", "X", "=", "dsp1_state", ".", "shared", ".", "CentreX", "+", "(", "C", "*", "dsp1_state", ".", "shared", ".", "CosAas", ">>", "15", ")", ";", "*", "Y", "=", "dsp1_state", ".", "shared", ".", "CentreY", "-", "(", "C", "*", "dsp1_state", ".", "shared", ".", "SinAas", ">>", "15", ")", ";", "V", "<<=", "8", ";", "normalize", "(", "C1", "*", "dsp1_state", ".", "shared", ".", "SecAZS_C1", ">>", "15", ",", "&", "C", ",", "&", "E1", ")", ";", "C", "=", "denormalize_and_clip", "(", "C", ",", "E1", ")", "*", "V", ">>", "15", ";", "*", "X", "+=", "C", "*", "-", "dsp1_state", ".", "shared", ".", "SinAas", ">>", "15", ";", "*", "Y", "+=", "C", "*", "dsp1_state", ".", "shared", ".", "CosAas", ">>", "15", ";", "}" ]
Calculate the projection over the ground of a selected point of screen It simply apply the projection matrix described in the "Raster" command to the vector (H,V) transposed, and add the result to the position of the centre of projection.
[ "Calculate", "the", "projection", "over", "the", "ground", "of", "a", "selected", "point", "of", "screen", "It", "simply", "apply", "the", "projection", "matrix", "described", "in", "the", "\"", "Raster", "\"", "command", "to", "the", "vector", "(", "H", "V", ")", "transposed", "and", "add", "the", "result", "to", "the", "position", "of", "the", "centre", "of", "projection", "." ]
[]
[ { "param": "input", "type": "INT16" }, { "param": "output", "type": "INT16" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "input", "type": "INT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "output", "type": "INT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6b3f3a42553d6602ab7cfadd1cc1914206d0a431
lofunz/mieme
Reloaded/trunk/src/mame/machine/snesdsp1.c
[ "Unlicense" ]
C
dsp1_sin
INT16
static INT16 dsp1_sin( INT16 Angle ) { INT32 S; if (Angle < 0) { if (Angle == -32768) return 0; return -dsp1_sin(-Angle); } S = dsp1_sin_table[Angle >> 8] + (dsp1_mul_table[Angle & 0xff] * dsp1_sin_table[0x40 + (Angle >> 8)] >> 15); if (S > 32767) S = 32767; return (INT16) S; }
// Calculate the sine of the input parameter // this is done by linear interpolation between // the points of a look-up table
Calculate the sine of the input parameter this is done by linear interpolation between the points of a look-up table
[ "Calculate", "the", "sine", "of", "the", "input", "parameter", "this", "is", "done", "by", "linear", "interpolation", "between", "the", "points", "of", "a", "look", "-", "up", "table" ]
static INT16 dsp1_sin( INT16 Angle ) { INT32 S; if (Angle < 0) { if (Angle == -32768) return 0; return -dsp1_sin(-Angle); } S = dsp1_sin_table[Angle >> 8] + (dsp1_mul_table[Angle & 0xff] * dsp1_sin_table[0x40 + (Angle >> 8)] >> 15); if (S > 32767) S = 32767; return (INT16) S; }
[ "static", "INT16", "dsp1_sin", "(", "INT16", "Angle", ")", "{", "INT32", "S", ";", "if", "(", "Angle", "<", "0", ")", "{", "if", "(", "Angle", "==", "-32768", ")", "return", "0", ";", "return", "-", "dsp1_sin", "(", "-", "Angle", ")", ";", "}", "S", "=", "dsp1_sin_table", "[", "Angle", ">>", "8", "]", "+", "(", "dsp1_mul_table", "[", "Angle", "&", "0xff", "]", "*", "dsp1_sin_table", "[", "0x40", "+", "(", "Angle", ">>", "8", ")", "]", ">>", "15", ")", ";", "if", "(", "S", ">", "32767", ")", "S", "=", "32767", ";", "return", "(", "INT16", ")", "S", ";", "}" ]
Calculate the sine of the input parameter this is done by linear interpolation between the points of a look-up table
[ "Calculate", "the", "sine", "of", "the", "input", "parameter", "this", "is", "done", "by", "linear", "interpolation", "between", "the", "points", "of", "a", "look", "-", "up", "table" ]
[]
[ { "param": "Angle", "type": "INT16" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "Angle", "type": "INT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6b3f3a42553d6602ab7cfadd1cc1914206d0a431
lofunz/mieme
Reloaded/trunk/src/mame/machine/snesdsp1.c
[ "Unlicense" ]
C
dsp1_cos
INT16
static INT16 dsp1_cos( INT16 Angle ) { INT32 S; if (Angle < 0) { if (Angle == -32768) return -32768; Angle = -Angle; } S = dsp1_sin_table[0x40 + (Angle >> 8)] - (dsp1_mul_table[Angle & 0xff] * dsp1_sin_table[Angle >> 8] >> 15); if (S < -32768) S = -32767; return (INT16) S; }
// Calculate the cosine of the input parameter. // It's used the same method than in sin(INT16)
Calculate the cosine of the input parameter. It's used the same method than in sin(INT16)
[ "Calculate", "the", "cosine", "of", "the", "input", "parameter", ".", "It", "'", "s", "used", "the", "same", "method", "than", "in", "sin", "(", "INT16", ")" ]
static INT16 dsp1_cos( INT16 Angle ) { INT32 S; if (Angle < 0) { if (Angle == -32768) return -32768; Angle = -Angle; } S = dsp1_sin_table[0x40 + (Angle >> 8)] - (dsp1_mul_table[Angle & 0xff] * dsp1_sin_table[Angle >> 8] >> 15); if (S < -32768) S = -32767; return (INT16) S; }
[ "static", "INT16", "dsp1_cos", "(", "INT16", "Angle", ")", "{", "INT32", "S", ";", "if", "(", "Angle", "<", "0", ")", "{", "if", "(", "Angle", "==", "-32768", ")", "return", "-32768", ";", "Angle", "=", "-", "Angle", ";", "}", "S", "=", "dsp1_sin_table", "[", "0x40", "+", "(", "Angle", ">>", "8", ")", "]", "-", "(", "dsp1_mul_table", "[", "Angle", "&", "0xff", "]", "*", "dsp1_sin_table", "[", "Angle", ">>", "8", "]", ">>", "15", ")", ";", "if", "(", "S", "<", "-32768", ")", "S", "=", "-32767", ";", "return", "(", "INT16", ")", "S", ";", "}" ]
Calculate the cosine of the input parameter.
[ "Calculate", "the", "cosine", "of", "the", "input", "parameter", "." ]
[]
[ { "param": "Angle", "type": "INT16" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "Angle", "type": "INT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6b3f3a42553d6602ab7cfadd1cc1914206d0a431
lofunz/mieme
Reloaded/trunk/src/mame/machine/snesdsp1.c
[ "Unlicense" ]
C
inverse
void
static void inverse( INT16 Coefficient, INT16 Exponent, INT16 *iCoefficient, INT16 *iExponent ) { // Step One: Division by Zero if (Coefficient == 0x0000) { *iCoefficient = 0x7fff; *iExponent = 0x002f; } else { INT16 Sign = 1; // Step Two: Remove Sign if (Coefficient < 0) { if (Coefficient < -32767) Coefficient = -32767; Coefficient = -Coefficient; Sign = -1; } // Step Three: Normalize while (Coefficient < 0x4000) { Coefficient <<= 1; Exponent--; } // Step Four: Special Case if (Coefficient == 0x4000) if (Sign == 1) *iCoefficient = 0x7fff; else { *iCoefficient = -0x4000; Exponent--; } else { // Step Five: Initial Guess INT16 i = dsp1_state.DataRom[((Coefficient - 0x4000) >> 7) + 0x0065]; // Step Six: Iterate Newton's Method i = (i + (-i * (Coefficient * i >> 15) >> 15)) << 1; i = (i + (-i * (Coefficient * i >> 15) >> 15)) << 1; *iCoefficient = i * Sign; } *iExponent = 1 - Exponent; } }
// Determines the inverse of a floating point decimal number // iCoefficient*2^iExponent = 1/(Coefficient*2^Exponent), with the output // normalized (iCoefficient represents a number whose absolute value is between 1/2 and 1) // To invert 'Coefficient' a first initial guess is taken from a look-up table // and, then, two iterations of the Newton method (applied to the function // f(x)=1/(2*x)-Coefficient) are done. This results in a close approximation (iCoefficient) to a number 'y' // that verify Coefficient*y=1/2. This is why you have to correct the exponent by one // unit at the end.
Determines the inverse of a floating point decimal number iCoefficient*2^iExponent = 1/(Coefficient*2^Exponent), with the output normalized (iCoefficient represents a number whose absolute value is between 1/2 and 1) To invert 'Coefficient' a first initial guess is taken from a look-up table and, then, two iterations of the Newton method (applied to the function f(x)=1/(2*x)-Coefficient) are done. This results in a close approximation (iCoefficient) to a number 'y' that verify Coefficient*y=1/2. This is why you have to correct the exponent by one unit at the end.
[ "Determines", "the", "inverse", "of", "a", "floating", "point", "decimal", "number", "iCoefficient", "*", "2^iExponent", "=", "1", "/", "(", "Coefficient", "*", "2^Exponent", ")", "with", "the", "output", "normalized", "(", "iCoefficient", "represents", "a", "number", "whose", "absolute", "value", "is", "between", "1", "/", "2", "and", "1", ")", "To", "invert", "'", "Coefficient", "'", "a", "first", "initial", "guess", "is", "taken", "from", "a", "look", "-", "up", "table", "and", "then", "two", "iterations", "of", "the", "Newton", "method", "(", "applied", "to", "the", "function", "f", "(", "x", ")", "=", "1", "/", "(", "2", "*", "x", ")", "-", "Coefficient", ")", "are", "done", ".", "This", "results", "in", "a", "close", "approximation", "(", "iCoefficient", ")", "to", "a", "number", "'", "y", "'", "that", "verify", "Coefficient", "*", "y", "=", "1", "/", "2", ".", "This", "is", "why", "you", "have", "to", "correct", "the", "exponent", "by", "one", "unit", "at", "the", "end", "." ]
static void inverse( INT16 Coefficient, INT16 Exponent, INT16 *iCoefficient, INT16 *iExponent ) { if (Coefficient == 0x0000) { *iCoefficient = 0x7fff; *iExponent = 0x002f; } else { INT16 Sign = 1; if (Coefficient < 0) { if (Coefficient < -32767) Coefficient = -32767; Coefficient = -Coefficient; Sign = -1; } while (Coefficient < 0x4000) { Coefficient <<= 1; Exponent--; } if (Coefficient == 0x4000) if (Sign == 1) *iCoefficient = 0x7fff; else { *iCoefficient = -0x4000; Exponent--; } else { INT16 i = dsp1_state.DataRom[((Coefficient - 0x4000) >> 7) + 0x0065]; i = (i + (-i * (Coefficient * i >> 15) >> 15)) << 1; i = (i + (-i * (Coefficient * i >> 15) >> 15)) << 1; *iCoefficient = i * Sign; } *iExponent = 1 - Exponent; } }
[ "static", "void", "inverse", "(", "INT16", "Coefficient", ",", "INT16", "Exponent", ",", "INT16", "*", "iCoefficient", ",", "INT16", "*", "iExponent", ")", "{", "if", "(", "Coefficient", "==", "0x0000", ")", "{", "*", "iCoefficient", "=", "0x7fff", ";", "*", "iExponent", "=", "0x002f", ";", "}", "else", "{", "INT16", "Sign", "=", "1", ";", "if", "(", "Coefficient", "<", "0", ")", "{", "if", "(", "Coefficient", "<", "-32767", ")", "Coefficient", "=", "-32767", ";", "Coefficient", "=", "-", "Coefficient", ";", "Sign", "=", "-1", ";", "}", "while", "(", "Coefficient", "<", "0x4000", ")", "{", "Coefficient", "<<=", "1", ";", "Exponent", "--", ";", "}", "if", "(", "Coefficient", "==", "0x4000", ")", "if", "(", "Sign", "==", "1", ")", "*", "iCoefficient", "=", "0x7fff", ";", "else", "{", "*", "iCoefficient", "=", "-0x4000", ";", "Exponent", "--", ";", "}", "else", "{", "INT16", "i", "=", "dsp1_state", ".", "DataRom", "[", "(", "(", "Coefficient", "-", "0x4000", ")", ">>", "7", ")", "+", "0x0065", "]", ";", "i", "=", "(", "i", "+", "(", "-", "i", "*", "(", "Coefficient", "*", "i", ">>", "15", ")", ">>", "15", ")", ")", "<<", "1", ";", "i", "=", "(", "i", "+", "(", "-", "i", "*", "(", "Coefficient", "*", "i", ">>", "15", ")", ">>", "15", ")", ")", "<<", "1", ";", "*", "iCoefficient", "=", "i", "*", "Sign", ";", "}", "*", "iExponent", "=", "1", "-", "Exponent", ";", "}", "}" ]
Determines the inverse of a floating point decimal number iCoefficient*2^iExponent = 1/(Coefficient*2^Exponent), with the output normalized (iCoefficient represents a number whose absolute value is between 1/2 and 1) To invert 'Coefficient' a first initial guess is taken from a look-up table and, then, two iterations of the Newton method (applied to the function f(x)=1/(2*x)-Coefficient) are done.
[ "Determines", "the", "inverse", "of", "a", "floating", "point", "decimal", "number", "iCoefficient", "*", "2^iExponent", "=", "1", "/", "(", "Coefficient", "*", "2^Exponent", ")", "with", "the", "output", "normalized", "(", "iCoefficient", "represents", "a", "number", "whose", "absolute", "value", "is", "between", "1", "/", "2", "and", "1", ")", "To", "invert", "'", "Coefficient", "'", "a", "first", "initial", "guess", "is", "taken", "from", "a", "look", "-", "up", "table", "and", "then", "two", "iterations", "of", "the", "Newton", "method", "(", "applied", "to", "the", "function", "f", "(", "x", ")", "=", "1", "/", "(", "2", "*", "x", ")", "-", "Coefficient", ")", "are", "done", "." ]
[ "// Step One: Division by Zero\r", "// Step Two: Remove Sign\r", "// Step Three: Normalize\r", "// Step Four: Special Case\r", "// Step Five: Initial Guess\r", "// Step Six: Iterate Newton's Method\r" ]
[ { "param": "Coefficient", "type": "INT16" }, { "param": "Exponent", "type": "INT16" }, { "param": "iCoefficient", "type": "INT16" }, { "param": "iExponent", "type": "INT16" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "Coefficient", "type": "INT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "Exponent", "type": "INT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "iCoefficient", "type": "INT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "iExponent", "type": "INT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6b3f3a42553d6602ab7cfadd1cc1914206d0a431
lofunz/mieme
Reloaded/trunk/src/mame/machine/snesdsp1.c
[ "Unlicense" ]
C
normalize_double
void
static void normalize_double( INT32 Product, INT16 *Coefficient, INT16 *Exponent ) { INT16 n = Product & 0x7fff; INT16 m = Product >> 15; INT16 i = 0x4000; INT16 e = 0; if (m < 0) while ((m & i) && i) { i >>= 1; e++; } else while (!(m & i) && i) { i >>= 1; e++; } if (e > 0) { *Coefficient = m * dsp1_state.DataRom[0x0021 + e] << 1; if (e < 15) *Coefficient += n * dsp1_state.DataRom[0x0040 - e] >> 15; else { i = 0x4000; if (m < 0) while ((n & i) && i) { i >>= 1; e++; } else while (!(n & i) && i) { i >>= 1; e++; } if (e > 15) *Coefficient = n * dsp1_state.DataRom[0x0012 + e] << 1; else *Coefficient += n; } } else *Coefficient = m; *Exponent = e; }
// Same than 'normalize' but with an INT32 input
Same than 'normalize' but with an INT32 input
[ "Same", "than", "'", "normalize", "'", "but", "with", "an", "INT32", "input" ]
static void normalize_double( INT32 Product, INT16 *Coefficient, INT16 *Exponent ) { INT16 n = Product & 0x7fff; INT16 m = Product >> 15; INT16 i = 0x4000; INT16 e = 0; if (m < 0) while ((m & i) && i) { i >>= 1; e++; } else while (!(m & i) && i) { i >>= 1; e++; } if (e > 0) { *Coefficient = m * dsp1_state.DataRom[0x0021 + e] << 1; if (e < 15) *Coefficient += n * dsp1_state.DataRom[0x0040 - e] >> 15; else { i = 0x4000; if (m < 0) while ((n & i) && i) { i >>= 1; e++; } else while (!(n & i) && i) { i >>= 1; e++; } if (e > 15) *Coefficient = n * dsp1_state.DataRom[0x0012 + e] << 1; else *Coefficient += n; } } else *Coefficient = m; *Exponent = e; }
[ "static", "void", "normalize_double", "(", "INT32", "Product", ",", "INT16", "*", "Coefficient", ",", "INT16", "*", "Exponent", ")", "{", "INT16", "n", "=", "Product", "&", "0x7fff", ";", "INT16", "m", "=", "Product", ">>", "15", ";", "INT16", "i", "=", "0x4000", ";", "INT16", "e", "=", "0", ";", "if", "(", "m", "<", "0", ")", "while", "(", "(", "m", "&", "i", ")", "&&", "i", ")", "{", "i", ">>=", "1", ";", "e", "++", ";", "}", "else", "while", "(", "!", "(", "m", "&", "i", ")", "&&", "i", ")", "{", "i", ">>=", "1", ";", "e", "++", ";", "}", "if", "(", "e", ">", "0", ")", "{", "*", "Coefficient", "=", "m", "*", "dsp1_state", ".", "DataRom", "[", "0x0021", "+", "e", "]", "<<", "1", ";", "if", "(", "e", "<", "15", ")", "*", "Coefficient", "+=", "n", "*", "dsp1_state", ".", "DataRom", "[", "0x0040", "-", "e", "]", ">>", "15", ";", "else", "{", "i", "=", "0x4000", ";", "if", "(", "m", "<", "0", ")", "while", "(", "(", "n", "&", "i", ")", "&&", "i", ")", "{", "i", ">>=", "1", ";", "e", "++", ";", "}", "else", "while", "(", "!", "(", "n", "&", "i", ")", "&&", "i", ")", "{", "i", ">>=", "1", ";", "e", "++", ";", "}", "if", "(", "e", ">", "15", ")", "*", "Coefficient", "=", "n", "*", "dsp1_state", ".", "DataRom", "[", "0x0012", "+", "e", "]", "<<", "1", ";", "else", "*", "Coefficient", "+=", "n", ";", "}", "}", "else", "*", "Coefficient", "=", "m", ";", "*", "Exponent", "=", "e", ";", "}" ]
Same than 'normalize' but with an INT32 input
[ "Same", "than", "'", "normalize", "'", "but", "with", "an", "INT32", "input" ]
[]
[ { "param": "Product", "type": "INT32" }, { "param": "Coefficient", "type": "INT16" }, { "param": "Exponent", "type": "INT16" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "Product", "type": "INT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "Coefficient", "type": "INT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "Exponent", "type": "INT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
37bc0f5b2acd126d67d188224caad80e5769c395
lofunz/mieme
Reloaded/trunk/src/mame/video/taito_z.c
[ "Unlicense" ]
C
contcirc_draw_sprites_16x8
void
static void contcirc_draw_sprites_16x8( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int y_offs ) { taitoz_state *state = machine->driver_data<taitoz_state>(); UINT16 *spritemap = (UINT16 *)memory_region(machine, "user1"); UINT16 *spriteram = state->spriteram; int offs, data, tilenum, color, flipx, flipy; int x, y, priority, curx, cury; int sprites_flipscreen = 0; int zoomx, zoomy, zx, zy; int sprite_chunk, map_offset, code, j, k, px, py; int bad_chunks; static const int primasks[2] = { 0xf0, 0xfc }; for (offs = 0; offs < state->spriteram_size / 2; offs += 4) { data = spriteram[offs + 0]; zoomy = (data & 0xfe00) >> 9; y = data & 0x1ff; data = spriteram[offs + 1]; tilenum = data & 0x7ff; /* $80000 spritemap rom maps up to $7ff 128x128 sprites */ data = spriteram[offs + 2]; priority = (data & 0x8000) >> 15; flipx = (data & 0x4000) >> 14; flipy = (data & 0x2000) >> 13; // ??? x = data & 0x1ff; // correct mask? data = spriteram[offs + 3]; color = (data & 0xff00) >> 8; zoomx = (data & 0x7f); if (!tilenum) continue; map_offset = tilenum << 7; zoomx += 1; zoomy += 1; y += y_offs; y += (128 - zoomy); /* treat coords as signed */ if (x > 0x140) x -= 0x200; if (y > 0x140) y -= 0x200; bad_chunks = 0; for (sprite_chunk = 0; sprite_chunk < 128; sprite_chunk++) { k = sprite_chunk % 8; /* 8 sprite chunks per row */ j = sprite_chunk / 8; /* 16 rows */ px = flipx ? (7 - k) : k; /* pick tiles back to front for x and y flips */ py = flipy ? (15 - j) : j; code = spritemap[map_offset + px + (py << 3)]; if (code == 0xffff) bad_chunks++; curx = x + ((k * zoomx) / 8); cury = y + ((j * zoomy) / 16); zx = x + (((k + 1) * zoomx) / 8) - curx; zy = y + (((j + 1) * zoomy) / 16) - cury; if (sprites_flipscreen) { /* -zx/y is there to fix zoomed sprite coords in screenflip. drawgfxzoom does not know to draw from flip-side of sprites when screen is flipped; so we must correct the coords ourselves. */ curx = 320 - curx - zx; cury = 256 - cury - zy; flipx = !flipx; flipy = !flipy; } pdrawgfxzoom_transpen(bitmap,cliprect,machine->gfx[0], code, color, flipx,flipy, curx,cury, zx<<12,zy<<13,machine->priority_bitmap,primasks[priority],0); } if (bad_chunks) logerror("Sprite number %04x had %02x invalid chunks\n", tilenum, bad_chunks); } }
/************************************************************ SPRITE DRAW ROUTINES These draw a series of small tiles ("chunks") together to create each big sprite. The spritemap rom provides the lookup table for this. E.g. Spacegun looks up 16x8 sprite chunks from the spritemap rom, creating this 64x64 sprite (numbers are the word offset into the spritemap rom): 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Chasehq/Nightstr are the only games to build from 16x16 tiles. They are also more complicated to draw, as they have 3 different aggregation formats [32/64/128 x 128] whereas the other games stick to one, typically 64x64. All the games make heavy use of sprite zooming. I'm 99% sure there are probably just two levels of sprite priority - under and over the road - but this isn't certain. *** [The routines for the 16x8 tile games seem to have large common elements that could be extracted as subroutines.] NB: unused portions of the spritemap rom contain hex FF's. It is a useful coding check to warn in the log if these are being accessed. [They can be inadvertently while spriteram is being tested, take no notice of that.] BUT: Nightstr uses code 0x3ff as a mask sprite. This references 0x1ff00-ff in spritemap rom, which is an 0xff fill. This must be accessing sprite chunk 0x3fff: in other words the top bits are thrown away and so accessing chunk 0xfe45 would display chunk 0x3e45 etc. Aquajack/Spacegun (modified table from Raine; size of bit masks verified in Spacegun code) Byte | Bit(s) | Description -----+76543210+------------------------------------- 0 |xxxxxxx.| ZoomY (0 min, 63 max - msb unused as sprites are 64x64) 0 |.......x| Y position (High) 1 |xxxxxxxx| Y position (Low) 2 |x.......| Priority (0=sprites high) 2 |.x......| Flip X 2 |..?????.| unknown/unused ? 2 |.......x| X position (High) 3 |xxxxxxxx| X position (Low) 4 |xxxxxxxx| Palette bank 5 |?.......| unknown/unused ? 5 |.xxxxxxx| ZoomX (0 min, 63 max - msb unused as sprites are 64x64) 6 |x.......| Flip Y ? 6 |.??.....| unknown/unused ? 6 |...xxxxx| Sprite Tile high (msb unused - half of spritemap rom empty) 7 |xxxxxxxx| Sprite Tile low Continental circus (modified Raine table): note similar format. The zoom msb is actually used, as sprites are 128x128. ---+-------------------+-------------- 0 | xxxxxxx. ........ | ZoomY 0 | .......x xxxxxxxx | Y position // unsure about Flip Y 2 | .....xxx xxxxxxxx | Sprite Tile 4 | x....... ........ | Priority (0=sprites high) 4 | .x...... ........ | Flip X 4 | .......x xxxxxxxx | X position 6 | xxxxxxxx ........ | Palette bank 6 | ........ .xxxxxxx | ZoomX ---+-------------------+-------------- Bshark/Chasehq/Nightstr/SCI (modified Raine table): similar format. The zoom msb is only used for 128x128 sprites. -----+--------+------------------------ Byte | Bit(s) | Description -----+76543210+------------------------ 0 |xxxxxxx.| ZoomY 0 |.......x| Y position (High) 1 |xxxxxxxx| Y position (Low) 2 |x.......| Priority (0=sprites high) 2 |.xxxxxxx| Palette bank (High) 3 |x.......| Palette bank (Low) 3 |.xxxxxxx| ZoomX 4 |x.......| Flip Y 4 |.x......| Flip X 4 |.......x| X position (High) 5 |xxxxxxxx| X position (Low) 6 |...xxxxx| Sprite Tile (High) 7 |xxxxxxxx| Sprite Tile (Low) -----+--------+------------------------ [Raine Chasehq sprite plotting is peculiar. It determines the type of big sprite by reference to the zoomx and y. Therefore it says that the big sprite number is 0-0x7ff across ALL three sizes and you can't distinguish them by tilenum. FWIW I seem to be ok just using zoomx.] TODO: Contcirc, Aquajack, Spacegun need flip y bit to be confirmed ********************************************************/
SPRITE DRAW ROUTINES These draw a series of small tiles ("chunks") together to create each big sprite. The spritemap rom provides the lookup table for this. Chasehq/Nightstr are the only games to build from 16x16 tiles. They are also more complicated to draw, as they have 3 different aggregation formats [32/64/128 x 128] whereas the other games stick to one, typically 64x64. All the games make heavy use of sprite zooming. I'm 99% sure there are probably just two levels of sprite priority - under and over the road - but this isn't certain. [The routines for the 16x8 tile games seem to have large common elements that could be extracted as subroutines.] unused portions of the spritemap rom contain hex FF's. It is a useful coding check to warn in the log if these are being accessed. [They can be inadvertently while spriteram is being tested, take no notice of that.] Nightstr uses code 0x3ff as a mask sprite. This references 0x1ff00-ff in spritemap rom, which is an 0xff fill. This must be accessing sprite chunk 0x3fff: in other words the top bits are thrown away and so accessing chunk 0xfe45 would display chunk 0x3e45 etc. Aquajack/Spacegun (modified table from Raine; size of bit masks verified in Spacegun code) Continental circus (modified Raine table): note similar format. The zoom msb is actually used, as sprites are 128x128. Bshark/Chasehq/Nightstr/SCI (modified Raine table): similar format. The zoom msb is only used for 128x128 sprites. [Raine Chasehq sprite plotting is peculiar. It determines the type of big sprite by reference to the zoomx and y. Therefore it says that the big sprite number is 0-0x7ff across ALL three sizes and you can't distinguish them by tilenum. FWIW I seem to be ok just using zoomx.] Contcirc, Aquajack, Spacegun need flip y bit to be confirmed
[ "SPRITE", "DRAW", "ROUTINES", "These", "draw", "a", "series", "of", "small", "tiles", "(", "\"", "chunks", "\"", ")", "together", "to", "create", "each", "big", "sprite", ".", "The", "spritemap", "rom", "provides", "the", "lookup", "table", "for", "this", ".", "Chasehq", "/", "Nightstr", "are", "the", "only", "games", "to", "build", "from", "16x16", "tiles", ".", "They", "are", "also", "more", "complicated", "to", "draw", "as", "they", "have", "3", "different", "aggregation", "formats", "[", "32", "/", "64", "/", "128", "x", "128", "]", "whereas", "the", "other", "games", "stick", "to", "one", "typically", "64x64", ".", "All", "the", "games", "make", "heavy", "use", "of", "sprite", "zooming", ".", "I", "'", "m", "99%", "sure", "there", "are", "probably", "just", "two", "levels", "of", "sprite", "priority", "-", "under", "and", "over", "the", "road", "-", "but", "this", "isn", "'", "t", "certain", ".", "[", "The", "routines", "for", "the", "16x8", "tile", "games", "seem", "to", "have", "large", "common", "elements", "that", "could", "be", "extracted", "as", "subroutines", ".", "]", "unused", "portions", "of", "the", "spritemap", "rom", "contain", "hex", "FF", "'", "s", ".", "It", "is", "a", "useful", "coding", "check", "to", "warn", "in", "the", "log", "if", "these", "are", "being", "accessed", ".", "[", "They", "can", "be", "inadvertently", "while", "spriteram", "is", "being", "tested", "take", "no", "notice", "of", "that", ".", "]", "Nightstr", "uses", "code", "0x3ff", "as", "a", "mask", "sprite", ".", "This", "references", "0x1ff00", "-", "ff", "in", "spritemap", "rom", "which", "is", "an", "0xff", "fill", ".", "This", "must", "be", "accessing", "sprite", "chunk", "0x3fff", ":", "in", "other", "words", "the", "top", "bits", "are", "thrown", "away", "and", "so", "accessing", "chunk", "0xfe45", "would", "display", "chunk", "0x3e45", "etc", ".", "Aquajack", "/", "Spacegun", "(", "modified", "table", "from", "Raine", ";", "size", "of", "bit", "masks", "verified", "in", "Spacegun", "code", ")", "Continental", "circus", "(", "modified", "Raine", "table", ")", ":", "note", "similar", "format", ".", "The", "zoom", "msb", "is", "actually", "used", "as", "sprites", "are", "128x128", ".", "Bshark", "/", "Chasehq", "/", "Nightstr", "/", "SCI", "(", "modified", "Raine", "table", ")", ":", "similar", "format", ".", "The", "zoom", "msb", "is", "only", "used", "for", "128x128", "sprites", ".", "[", "Raine", "Chasehq", "sprite", "plotting", "is", "peculiar", ".", "It", "determines", "the", "type", "of", "big", "sprite", "by", "reference", "to", "the", "zoomx", "and", "y", ".", "Therefore", "it", "says", "that", "the", "big", "sprite", "number", "is", "0", "-", "0x7ff", "across", "ALL", "three", "sizes", "and", "you", "can", "'", "t", "distinguish", "them", "by", "tilenum", ".", "FWIW", "I", "seem", "to", "be", "ok", "just", "using", "zoomx", ".", "]", "Contcirc", "Aquajack", "Spacegun", "need", "flip", "y", "bit", "to", "be", "confirmed" ]
static void contcirc_draw_sprites_16x8( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int y_offs ) { taitoz_state *state = machine->driver_data<taitoz_state>(); UINT16 *spritemap = (UINT16 *)memory_region(machine, "user1"); UINT16 *spriteram = state->spriteram; int offs, data, tilenum, color, flipx, flipy; int x, y, priority, curx, cury; int sprites_flipscreen = 0; int zoomx, zoomy, zx, zy; int sprite_chunk, map_offset, code, j, k, px, py; int bad_chunks; static const int primasks[2] = { 0xf0, 0xfc }; for (offs = 0; offs < state->spriteram_size / 2; offs += 4) { data = spriteram[offs + 0]; zoomy = (data & 0xfe00) >> 9; y = data & 0x1ff; data = spriteram[offs + 1]; tilenum = data & 0x7ff; data = spriteram[offs + 2]; priority = (data & 0x8000) >> 15; flipx = (data & 0x4000) >> 14; flipy = (data & 0x2000) >> 13; x = data & 0x1ff; data = spriteram[offs + 3]; color = (data & 0xff00) >> 8; zoomx = (data & 0x7f); if (!tilenum) continue; map_offset = tilenum << 7; zoomx += 1; zoomy += 1; y += y_offs; y += (128 - zoomy); if (x > 0x140) x -= 0x200; if (y > 0x140) y -= 0x200; bad_chunks = 0; for (sprite_chunk = 0; sprite_chunk < 128; sprite_chunk++) { k = sprite_chunk % 8; j = sprite_chunk / 8; px = flipx ? (7 - k) : k; py = flipy ? (15 - j) : j; code = spritemap[map_offset + px + (py << 3)]; if (code == 0xffff) bad_chunks++; curx = x + ((k * zoomx) / 8); cury = y + ((j * zoomy) / 16); zx = x + (((k + 1) * zoomx) / 8) - curx; zy = y + (((j + 1) * zoomy) / 16) - cury; if (sprites_flipscreen) { curx = 320 - curx - zx; cury = 256 - cury - zy; flipx = !flipx; flipy = !flipy; } pdrawgfxzoom_transpen(bitmap,cliprect,machine->gfx[0], code, color, flipx,flipy, curx,cury, zx<<12,zy<<13,machine->priority_bitmap,primasks[priority],0); } if (bad_chunks) logerror("Sprite number %04x had %02x invalid chunks\n", tilenum, bad_chunks); } }
[ "static", "void", "contcirc_draw_sprites_16x8", "(", "running_machine", "*", "machine", ",", "bitmap_t", "*", "bitmap", ",", "const", "rectangle", "*", "cliprect", ",", "int", "y_offs", ")", "{", "taitoz_state", "*", "state", "=", "machine", "->", "driver_data", "<", "taitoz_state", ">", "(", "", ")", ";", "UINT16", "*", "spritemap", "=", "(", "UINT16", "*", ")", "memory_region", "(", "machine", ",", "\"", "\"", ")", ";", "UINT16", "*", "spriteram", "=", "state", "->", "spriteram", ";", "int", "offs", ",", "data", ",", "tilenum", ",", "color", ",", "flipx", ",", "flipy", ";", "int", "x", ",", "y", ",", "priority", ",", "curx", ",", "cury", ";", "int", "sprites_flipscreen", "=", "0", ";", "int", "zoomx", ",", "zoomy", ",", "zx", ",", "zy", ";", "int", "sprite_chunk", ",", "map_offset", ",", "code", ",", "j", ",", "k", ",", "px", ",", "py", ";", "int", "bad_chunks", ";", "static", "const", "int", "primasks", "[", "2", "]", "=", "{", "0xf0", ",", "0xfc", "}", ";", "for", "(", "offs", "=", "0", ";", "offs", "<", "state", "->", "spriteram_size", "/", "2", ";", "offs", "+=", "4", ")", "{", "data", "=", "spriteram", "[", "offs", "+", "0", "]", ";", "zoomy", "=", "(", "data", "&", "0xfe00", ")", ">>", "9", ";", "y", "=", "data", "&", "0x1ff", ";", "data", "=", "spriteram", "[", "offs", "+", "1", "]", ";", "tilenum", "=", "data", "&", "0x7ff", ";", "data", "=", "spriteram", "[", "offs", "+", "2", "]", ";", "priority", "=", "(", "data", "&", "0x8000", ")", ">>", "15", ";", "flipx", "=", "(", "data", "&", "0x4000", ")", ">>", "14", ";", "flipy", "=", "(", "data", "&", "0x2000", ")", ">>", "13", ";", "x", "=", "data", "&", "0x1ff", ";", "data", "=", "spriteram", "[", "offs", "+", "3", "]", ";", "color", "=", "(", "data", "&", "0xff00", ")", ">>", "8", ";", "zoomx", "=", "(", "data", "&", "0x7f", ")", ";", "if", "(", "!", "tilenum", ")", "continue", ";", "map_offset", "=", "tilenum", "<<", "7", ";", "zoomx", "+=", "1", ";", "zoomy", "+=", "1", ";", "y", "+=", "y_offs", ";", "y", "+=", "(", "128", "-", "zoomy", ")", ";", "if", "(", "x", ">", "0x140", ")", "x", "-=", "0x200", ";", "if", "(", "y", ">", "0x140", ")", "y", "-=", "0x200", ";", "bad_chunks", "=", "0", ";", "for", "(", "sprite_chunk", "=", "0", ";", "sprite_chunk", "<", "128", ";", "sprite_chunk", "++", ")", "{", "k", "=", "sprite_chunk", "%", "8", ";", "j", "=", "sprite_chunk", "/", "8", ";", "px", "=", "flipx", "?", "(", "7", "-", "k", ")", ":", "k", ";", "py", "=", "flipy", "?", "(", "15", "-", "j", ")", ":", "j", ";", "code", "=", "spritemap", "[", "map_offset", "+", "px", "+", "(", "py", "<<", "3", ")", "]", ";", "if", "(", "code", "==", "0xffff", ")", "bad_chunks", "++", ";", "curx", "=", "x", "+", "(", "(", "k", "*", "zoomx", ")", "/", "8", ")", ";", "cury", "=", "y", "+", "(", "(", "j", "*", "zoomy", ")", "/", "16", ")", ";", "zx", "=", "x", "+", "(", "(", "(", "k", "+", "1", ")", "*", "zoomx", ")", "/", "8", ")", "-", "curx", ";", "zy", "=", "y", "+", "(", "(", "(", "j", "+", "1", ")", "*", "zoomy", ")", "/", "16", ")", "-", "cury", ";", "if", "(", "sprites_flipscreen", ")", "{", "curx", "=", "320", "-", "curx", "-", "zx", ";", "cury", "=", "256", "-", "cury", "-", "zy", ";", "flipx", "=", "!", "flipx", ";", "flipy", "=", "!", "flipy", ";", "}", "pdrawgfxzoom_transpen", "(", "bitmap", ",", "cliprect", ",", "machine", "->", "gfx", "[", "0", "]", ",", "code", ",", "color", ",", "flipx", ",", "flipy", ",", "curx", ",", "cury", ",", "zx", "<<", "12", ",", "zy", "<<", "13", ",", "machine", "->", "priority_bitmap", ",", "primasks", "[", "priority", "]", ",", "0", ")", ";", "}", "if", "(", "bad_chunks", ")", "logerror", "(", "\"", "\\n", "\"", ",", "tilenum", ",", "bad_chunks", ")", ";", "}", "}" ]
SPRITE DRAW ROUTINES These draw a series of small tiles ("chunks") together to create each big sprite.
[ "SPRITE", "DRAW", "ROUTINES", "These", "draw", "a", "series", "of", "small", "tiles", "(", "\"", "chunks", "\"", ")", "together", "to", "create", "each", "big", "sprite", "." ]
[ "/* $80000 spritemap rom maps up to $7ff 128x128 sprites */", "// ???\r", "// correct mask?\r", "/* treat coords as signed */", "/* 8 sprite chunks per row */", "/* 16 rows */", "/* pick tiles back to front for x and y flips */", "/* -zx/y is there to fix zoomed sprite coords in screenflip.\r\n drawgfxzoom does not know to draw from flip-side of sprites when\r\n screen is flipped; so we must correct the coords ourselves. */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "bitmap", "type": "bitmap_t" }, { "param": "cliprect", "type": "rectangle" }, { "param": "y_offs", "type": "int" } ]
{ "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 }, { "identifier": "y_offs", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e4b5eb8a1fda76f346d31597c4ba042759d77491
lofunz/mieme
Reloaded/trunk/src/mame/video/metro.c
[ "Unlicense" ]
C
draw_layers
void
static void draw_layers( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri, int layers_ctrl ) { metro_state *state = machine->driver_data<metro_state>(); UINT16 layers_pri = state->videoregs[0x10 / 2]; int layer; /* Draw all the layers with priority == pri */ for (layer = 2; layer >= 0; layer--) // tilemap[2] below? { if (pri == ((layers_pri >> (layer * 2)) & 3)) { /* Scroll and Window values */ UINT16 sy = state->scroll[layer * 2 + 0]; UINT16 sx = state->scroll[layer * 2 + 1]; UINT16 wy = state->window[layer * 2 + 0]; UINT16 wx = state->window[layer * 2 + 1]; if (BIT(layers_ctrl, layer)) // for debug { UINT16* tilemapram = 0; if (layer==0) tilemapram = state->vram_0; else if (layer==1) tilemapram = state->vram_1; else if (layer==2) tilemapram = state->vram_2; draw_tilemap(machine, bitmap, cliprect, 0, 1 << (3 - pri), sx, sy, wx, wy, 0, tilemapram, layer); if (state->support_16x16) draw_tilemap(machine, bitmap, cliprect, 0, 1 << (3 - pri), sx, sy, wx, wy, 1, tilemapram, layer); } } } }
/* Draw all the layers that match the given priority */
Draw all the layers that match the given priority
[ "Draw", "all", "the", "layers", "that", "match", "the", "given", "priority" ]
static void draw_layers( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri, int layers_ctrl ) { metro_state *state = machine->driver_data<metro_state>(); UINT16 layers_pri = state->videoregs[0x10 / 2]; int layer; for (layer = 2; layer >= 0; layer--) { if (pri == ((layers_pri >> (layer * 2)) & 3)) { UINT16 sy = state->scroll[layer * 2 + 0]; UINT16 sx = state->scroll[layer * 2 + 1]; UINT16 wy = state->window[layer * 2 + 0]; UINT16 wx = state->window[layer * 2 + 1]; if (BIT(layers_ctrl, layer)) { UINT16* tilemapram = 0; if (layer==0) tilemapram = state->vram_0; else if (layer==1) tilemapram = state->vram_1; else if (layer==2) tilemapram = state->vram_2; draw_tilemap(machine, bitmap, cliprect, 0, 1 << (3 - pri), sx, sy, wx, wy, 0, tilemapram, layer); if (state->support_16x16) draw_tilemap(machine, bitmap, cliprect, 0, 1 << (3 - pri), sx, sy, wx, wy, 1, tilemapram, layer); } } } }
[ "static", "void", "draw_layers", "(", "running_machine", "*", "machine", ",", "bitmap_t", "*", "bitmap", ",", "const", "rectangle", "*", "cliprect", ",", "int", "pri", ",", "int", "layers_ctrl", ")", "{", "metro_state", "*", "state", "=", "machine", "->", "driver_data", "<", "metro_state", ">", "(", "", ")", ";", "UINT16", "layers_pri", "=", "state", "->", "videoregs", "[", "0x10", "/", "2", "]", ";", "int", "layer", ";", "for", "(", "layer", "=", "2", ";", "layer", ">=", "0", ";", "layer", "--", ")", "{", "if", "(", "pri", "==", "(", "(", "layers_pri", ">>", "(", "layer", "*", "2", ")", ")", "&", "3", ")", ")", "{", "UINT16", "sy", "=", "state", "->", "scroll", "[", "layer", "*", "2", "+", "0", "]", ";", "UINT16", "sx", "=", "state", "->", "scroll", "[", "layer", "*", "2", "+", "1", "]", ";", "UINT16", "wy", "=", "state", "->", "window", "[", "layer", "*", "2", "+", "0", "]", ";", "UINT16", "wx", "=", "state", "->", "window", "[", "layer", "*", "2", "+", "1", "]", ";", "if", "(", "BIT", "(", "layers_ctrl", ",", "layer", ")", ")", "{", "UINT16", "*", "tilemapram", "=", "0", ";", "if", "(", "layer", "==", "0", ")", "tilemapram", "=", "state", "->", "vram_0", ";", "else", "if", "(", "layer", "==", "1", ")", "tilemapram", "=", "state", "->", "vram_1", ";", "else", "if", "(", "layer", "==", "2", ")", "tilemapram", "=", "state", "->", "vram_2", ";", "draw_tilemap", "(", "machine", ",", "bitmap", ",", "cliprect", ",", "0", ",", "1", "<<", "(", "3", "-", "pri", ")", ",", "sx", ",", "sy", ",", "wx", ",", "wy", ",", "0", ",", "tilemapram", ",", "layer", ")", ";", "if", "(", "state", "->", "support_16x16", ")", "draw_tilemap", "(", "machine", ",", "bitmap", ",", "cliprect", ",", "0", ",", "1", "<<", "(", "3", "-", "pri", ")", ",", "sx", ",", "sy", ",", "wx", ",", "wy", ",", "1", ",", "tilemapram", ",", "layer", ")", ";", "}", "}", "}", "}" ]
Draw all the layers that match the given priority
[ "Draw", "all", "the", "layers", "that", "match", "the", "given", "priority" ]
[ "/* Draw all the layers with priority == pri */", "// tilemap[2] below?\r", "/* Scroll and Window values */", "// for debug\r" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "bitmap", "type": "bitmap_t" }, { "param": "cliprect", "type": "rectangle" }, { "param": "pri", "type": "int" }, { "param": "layers_ctrl", "type": "int" } ]
{ "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 }, { "identifier": "pri", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "layers_ctrl", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
810fbc8a113123a7031b16d5390abe98031b3b26
lofunz/mieme
Reloaded/trunk/src/emu/cpu/pdp1/pdp1.c
[ "Unlicense" ]
C
pulse_start_clear
void
static void pulse_start_clear(pdp1_state *cpustate) { /* processor registers */ PC = 0; /* according to maintainance manual p. 6-17 */ IR = 0; /* according to maintainance manual p. 6-13 */ /*MB = 0;*/ /* ??? */ /*MA = 0;*/ /* ??? */ /*AC = 0;*/ /* ??? */ /*IO = 0;*/ /* ??? */ /*PF = 0;*/ /* ??? */ /* processor state flip-flops */ cpustate->run = 0; /* ??? */ cpustate->cycle = 0; /* mere guess */ cpustate->defer = 0; /* mere guess */ cpustate->brk_ctr = 0; /* mere guess */ cpustate->ov = 0; /* according to maintainance manual p. 7-18 */ cpustate->rim = 0; /* ??? */ cpustate->sbm = 0; /* ??? */ EXD = 0; /* according to maintainance manual p. 8-16 */ cpustate->exc = 0; /* according to maintainance manual p. 8-16 */ cpustate->ioc = 1; /* according to maintainance manual p. 6-10 */ cpustate->ioh = 0; /* according to maintainance manual p. 6-10 */ cpustate->ios = 0; /* according to maintainance manual p. 6-10 */ cpustate->b1 = cpustate->type_20_sbs ? 0 : 1; /* mere guess */ cpustate->b2 = 0; /* mere guess */ cpustate->b4 = 0; /* mere guess */ cpustate->rim_step = 0; cpustate->sbs_restore = 0; /* mere guess */ cpustate->no_sequence_break = 0; /* mere guess */ field_interrupt(cpustate); /* now, we kindly ask IO devices to reset, too */ if (cpustate->io_sc_callback) (*cpustate->io_sc_callback)(cpustate->device); }
/* Simulate a pulse on start/clear line: reset most registers and flip-flops, and initialize a few emulator state variables. */
Simulate a pulse on start/clear line: reset most registers and flip-flops, and initialize a few emulator state variables.
[ "Simulate", "a", "pulse", "on", "start", "/", "clear", "line", ":", "reset", "most", "registers", "and", "flip", "-", "flops", "and", "initialize", "a", "few", "emulator", "state", "variables", "." ]
static void pulse_start_clear(pdp1_state *cpustate) { PC = 0; IR = 0; cpustate->run = 0; cpustate->cycle = 0; cpustate->defer = 0; cpustate->brk_ctr = 0; cpustate->ov = 0; cpustate->rim = 0; cpustate->sbm = 0; EXD = 0; cpustate->exc = 0; cpustate->ioc = 1; cpustate->ioh = 0; cpustate->ios = 0; cpustate->b1 = cpustate->type_20_sbs ? 0 : 1; cpustate->b2 = 0; cpustate->b4 = 0; cpustate->rim_step = 0; cpustate->sbs_restore = 0; cpustate->no_sequence_break = 0; field_interrupt(cpustate); if (cpustate->io_sc_callback) (*cpustate->io_sc_callback)(cpustate->device); }
[ "static", "void", "pulse_start_clear", "(", "pdp1_state", "*", "cpustate", ")", "{", "PC", "=", "0", ";", "IR", "=", "0", ";", "cpustate", "->", "run", "=", "0", ";", "cpustate", "->", "cycle", "=", "0", ";", "cpustate", "->", "defer", "=", "0", ";", "cpustate", "->", "brk_ctr", "=", "0", ";", "cpustate", "->", "ov", "=", "0", ";", "cpustate", "->", "rim", "=", "0", ";", "cpustate", "->", "sbm", "=", "0", ";", "EXD", "=", "0", ";", "cpustate", "->", "exc", "=", "0", ";", "cpustate", "->", "ioc", "=", "1", ";", "cpustate", "->", "ioh", "=", "0", ";", "cpustate", "->", "ios", "=", "0", ";", "cpustate", "->", "b1", "=", "cpustate", "->", "type_20_sbs", "?", "0", ":", "1", ";", "cpustate", "->", "b2", "=", "0", ";", "cpustate", "->", "b4", "=", "0", ";", "cpustate", "->", "rim_step", "=", "0", ";", "cpustate", "->", "sbs_restore", "=", "0", ";", "cpustate", "->", "no_sequence_break", "=", "0", ";", "field_interrupt", "(", "cpustate", ")", ";", "if", "(", "cpustate", "->", "io_sc_callback", ")", "(", "*", "cpustate", "->", "io_sc_callback", ")", "(", "cpustate", "->", "device", ")", ";", "}" ]
Simulate a pulse on start/clear line: reset most registers and flip-flops, and initialize a few emulator state variables.
[ "Simulate", "a", "pulse", "on", "start", "/", "clear", "line", ":", "reset", "most", "registers", "and", "flip", "-", "flops", "and", "initialize", "a", "few", "emulator", "state", "variables", "." ]
[ "/* processor registers */", "/* according to maintainance manual p. 6-17 */", "/* according to maintainance manual p. 6-13 */", "/*MB = 0;*/", "/* ??? */", "/*MA = 0;*/", "/* ??? */", "/*AC = 0;*/", "/* ??? */", "/*IO = 0;*/", "/* ??? */", "/*PF = 0;*/", "/* ??? */", "/* processor state flip-flops */", "/* ??? */", "/* mere guess */", "/* mere guess */", "/* mere guess */", "/* according to maintainance manual p. 7-18 */", "/* ??? */", "/* ??? */", "/* according to maintainance manual p. 8-16 */", "/* according to maintainance manual p. 8-16 */", "/* according to maintainance manual p. 6-10 */", "/* according to maintainance manual p. 6-10 */", "/* according to maintainance manual p. 6-10 */", "/* mere guess */", "/* mere guess */", "/* mere guess */", "/* mere guess */", "/* mere guess */", "/* now, we kindly ask IO devices to reset, too */" ]
[ { "param": "cpustate", "type": "pdp1_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cpustate", "type": "pdp1_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
64451960c90002806359a6234fa882329c7738e3
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/leland.c
[ "Unlicense" ]
C
mayhem_bankswitch
void
void mayhem_bankswitch(running_machine *machine) { UINT8 *address; battery_ram_enable = ((sound_port_bank & 0x24) == 0); address = (!(sound_port_bank & 0x04)) ? &master_base[0x10000] : &master_base[0x1c000]; memory_set_bankptr(machine, 1, address); address = battery_ram_enable ? battery_ram : &address[0x8000]; memory_set_bankptr(machine, 2, address); }
/* bankswitching for Mayhem 2002, Power Play, World Series Baseball, and Alley Master */
bankswitching for Mayhem 2002, Power Play, World Series Baseball, and Alley Master
[ "bankswitching", "for", "Mayhem", "2002", "Power", "Play", "World", "Series", "Baseball", "and", "Alley", "Master" ]
void mayhem_bankswitch(running_machine *machine) { UINT8 *address; battery_ram_enable = ((sound_port_bank & 0x24) == 0); address = (!(sound_port_bank & 0x04)) ? &master_base[0x10000] : &master_base[0x1c000]; memory_set_bankptr(machine, 1, address); address = battery_ram_enable ? battery_ram : &address[0x8000]; memory_set_bankptr(machine, 2, address); }
[ "void", "mayhem_bankswitch", "(", "running_machine", "*", "machine", ")", "{", "UINT8", "*", "address", ";", "battery_ram_enable", "=", "(", "(", "sound_port_bank", "&", "0x24", ")", "==", "0", ")", ";", "address", "=", "(", "!", "(", "sound_port_bank", "&", "0x04", ")", ")", "?", "&", "master_base", "[", "0x10000", "]", ":", "&", "master_base", "[", "0x1c000", "]", ";", "memory_set_bankptr", "(", "machine", ",", "1", ",", "address", ")", ";", "address", "=", "battery_ram_enable", "?", "battery_ram", ":", "&", "address", "[", "0x8000", "]", ";", "memory_set_bankptr", "(", "machine", ",", "2", ",", "address", ")", ";", "}" ]
bankswitching for Mayhem 2002, Power Play, World Series Baseball, and Alley Master
[ "bankswitching", "for", "Mayhem", "2002", "Power", "Play", "World", "Series", "Baseball", "and", "Alley", "Master" ]
[]
[ { "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": [] }
64451960c90002806359a6234fa882329c7738e3
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/leland.c
[ "Unlicense" ]
C
basebal2_bankswitch
void
void basebal2_bankswitch(running_machine *machine) { UINT8 *address; battery_ram_enable = (top_board_bank & 0x80); if (!battery_ram_enable) address = (!(sound_port_bank & 0x04)) ? &master_base[0x10000] : &master_base[0x1c000]; else address = (!(top_board_bank & 0x40)) ? &master_base[0x28000] : &master_base[0x30000]; memory_set_bankptr(machine, 1, address); address = battery_ram_enable ? battery_ram : &address[0x8000]; memory_set_bankptr(machine, 2, address); }
/* bankswitching for Baseball the Season II, Super Baseball, and Strike Zone */
bankswitching for Baseball the Season II, Super Baseball, and Strike Zone
[ "bankswitching", "for", "Baseball", "the", "Season", "II", "Super", "Baseball", "and", "Strike", "Zone" ]
void basebal2_bankswitch(running_machine *machine) { UINT8 *address; battery_ram_enable = (top_board_bank & 0x80); if (!battery_ram_enable) address = (!(sound_port_bank & 0x04)) ? &master_base[0x10000] : &master_base[0x1c000]; else address = (!(top_board_bank & 0x40)) ? &master_base[0x28000] : &master_base[0x30000]; memory_set_bankptr(machine, 1, address); address = battery_ram_enable ? battery_ram : &address[0x8000]; memory_set_bankptr(machine, 2, address); }
[ "void", "basebal2_bankswitch", "(", "running_machine", "*", "machine", ")", "{", "UINT8", "*", "address", ";", "battery_ram_enable", "=", "(", "top_board_bank", "&", "0x80", ")", ";", "if", "(", "!", "battery_ram_enable", ")", "address", "=", "(", "!", "(", "sound_port_bank", "&", "0x04", ")", ")", "?", "&", "master_base", "[", "0x10000", "]", ":", "&", "master_base", "[", "0x1c000", "]", ";", "else", "address", "=", "(", "!", "(", "top_board_bank", "&", "0x40", ")", ")", "?", "&", "master_base", "[", "0x28000", "]", ":", "&", "master_base", "[", "0x30000", "]", ";", "memory_set_bankptr", "(", "machine", ",", "1", ",", "address", ")", ";", "address", "=", "battery_ram_enable", "?", "battery_ram", ":", "&", "address", "[", "0x8000", "]", ";", "memory_set_bankptr", "(", "machine", ",", "2", ",", "address", ")", ";", "}" ]
bankswitching for Baseball the Season II, Super Baseball, and Strike Zone
[ "bankswitching", "for", "Baseball", "the", "Season", "II", "Super", "Baseball", "and", "Strike", "Zone" ]
[]
[ { "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": [] }
64451960c90002806359a6234fa882329c7738e3
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/leland.c
[ "Unlicense" ]
C
viper_bankswitch
void
void viper_bankswitch(running_machine *machine) { static const UINT32 bank_list[] = { 0x02000, 0x10000, 0x18000, 0x02000 }; UINT8 *address; battery_ram_enable = ((alternate_bank & 0x04) != 0); address = &master_base[bank_list[alternate_bank & 3]]; if (bank_list[alternate_bank & 3] >= master_length) { logerror("%s:Master bank %02X out of range!\n", cpuexec_describe_context(machine), alternate_bank & 3); address = &master_base[bank_list[0]]; } memory_set_bankptr(machine, 1, address); address = battery_ram_enable ? battery_ram : &master_base[0xa000]; memory_set_bankptr(machine, 2, address); }
/* bankswitching for Viper, Quarterback, Team Quarterback, and All American Football */
bankswitching for Viper, Quarterback, Team Quarterback, and All American Football
[ "bankswitching", "for", "Viper", "Quarterback", "Team", "Quarterback", "and", "All", "American", "Football" ]
void viper_bankswitch(running_machine *machine) { static const UINT32 bank_list[] = { 0x02000, 0x10000, 0x18000, 0x02000 }; UINT8 *address; battery_ram_enable = ((alternate_bank & 0x04) != 0); address = &master_base[bank_list[alternate_bank & 3]]; if (bank_list[alternate_bank & 3] >= master_length) { logerror("%s:Master bank %02X out of range!\n", cpuexec_describe_context(machine), alternate_bank & 3); address = &master_base[bank_list[0]]; } memory_set_bankptr(machine, 1, address); address = battery_ram_enable ? battery_ram : &master_base[0xa000]; memory_set_bankptr(machine, 2, address); }
[ "void", "viper_bankswitch", "(", "running_machine", "*", "machine", ")", "{", "static", "const", "UINT32", "bank_list", "[", "]", "=", "{", "0x02000", ",", "0x10000", ",", "0x18000", ",", "0x02000", "}", ";", "UINT8", "*", "address", ";", "battery_ram_enable", "=", "(", "(", "alternate_bank", "&", "0x04", ")", "!=", "0", ")", ";", "address", "=", "&", "master_base", "[", "bank_list", "[", "alternate_bank", "&", "3", "]", "]", ";", "if", "(", "bank_list", "[", "alternate_bank", "&", "3", "]", ">=", "master_length", ")", "{", "logerror", "(", "\"", "\\n", "\"", ",", "cpuexec_describe_context", "(", "machine", ")", ",", "alternate_bank", "&", "3", ")", ";", "address", "=", "&", "master_base", "[", "bank_list", "[", "0", "]", "]", ";", "}", "memory_set_bankptr", "(", "machine", ",", "1", ",", "address", ")", ";", "address", "=", "battery_ram_enable", "?", "battery_ram", ":", "&", "master_base", "[", "0xa000", "]", ";", "memory_set_bankptr", "(", "machine", ",", "2", ",", "address", ")", ";", "}" ]
bankswitching for Viper, Quarterback, Team Quarterback, and All American Football
[ "bankswitching", "for", "Viper", "Quarterback", "Team", "Quarterback", "and", "All", "American", "Football" ]
[]
[ { "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": [] }
64451960c90002806359a6234fa882329c7738e3
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/leland.c
[ "Unlicense" ]
C
offroad_bankswitch
void
void offroad_bankswitch(running_machine *machine) { static const UINT32 bank_list[] = { 0x02000, 0x02000, 0x10000, 0x18000, 0x20000, 0x28000, 0x30000, 0x38000 }; UINT8 *address; battery_ram_enable = ((alternate_bank & 7) == 1); address = &master_base[bank_list[alternate_bank & 7]]; if (bank_list[alternate_bank & 7] >= master_length) { logerror("%s:Master bank %02X out of range!\n", cpuexec_describe_context(machine), alternate_bank & 7); address = &master_base[bank_list[0]]; } memory_set_bankptr(machine, 1, address); address = battery_ram_enable ? battery_ram : &master_base[0xa000]; memory_set_bankptr(machine, 2, address); }
/* bankswitching for Super Offroad, Super Offroad Track Pack, and Pig Out */
bankswitching for Super Offroad, Super Offroad Track Pack, and Pig Out
[ "bankswitching", "for", "Super", "Offroad", "Super", "Offroad", "Track", "Pack", "and", "Pig", "Out" ]
void offroad_bankswitch(running_machine *machine) { static const UINT32 bank_list[] = { 0x02000, 0x02000, 0x10000, 0x18000, 0x20000, 0x28000, 0x30000, 0x38000 }; UINT8 *address; battery_ram_enable = ((alternate_bank & 7) == 1); address = &master_base[bank_list[alternate_bank & 7]]; if (bank_list[alternate_bank & 7] >= master_length) { logerror("%s:Master bank %02X out of range!\n", cpuexec_describe_context(machine), alternate_bank & 7); address = &master_base[bank_list[0]]; } memory_set_bankptr(machine, 1, address); address = battery_ram_enable ? battery_ram : &master_base[0xa000]; memory_set_bankptr(machine, 2, address); }
[ "void", "offroad_bankswitch", "(", "running_machine", "*", "machine", ")", "{", "static", "const", "UINT32", "bank_list", "[", "]", "=", "{", "0x02000", ",", "0x02000", ",", "0x10000", ",", "0x18000", ",", "0x20000", ",", "0x28000", ",", "0x30000", ",", "0x38000", "}", ";", "UINT8", "*", "address", ";", "battery_ram_enable", "=", "(", "(", "alternate_bank", "&", "7", ")", "==", "1", ")", ";", "address", "=", "&", "master_base", "[", "bank_list", "[", "alternate_bank", "&", "7", "]", "]", ";", "if", "(", "bank_list", "[", "alternate_bank", "&", "7", "]", ">=", "master_length", ")", "{", "logerror", "(", "\"", "\\n", "\"", ",", "cpuexec_describe_context", "(", "machine", ")", ",", "alternate_bank", "&", "7", ")", ";", "address", "=", "&", "master_base", "[", "bank_list", "[", "0", "]", "]", ";", "}", "memory_set_bankptr", "(", "machine", ",", "1", ",", "address", ")", ";", "address", "=", "battery_ram_enable", "?", "battery_ram", ":", "&", "master_base", "[", "0xa000", "]", ";", "memory_set_bankptr", "(", "machine", ",", "2", ",", "address", ")", ";", "}" ]
bankswitching for Super Offroad, Super Offroad Track Pack, and Pig Out
[ "bankswitching", "for", "Super", "Offroad", "Super", "Offroad", "Track", "Pack", "and", "Pig", "Out" ]
[]
[ { "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": [] }
64451960c90002806359a6234fa882329c7738e3
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/leland.c
[ "Unlicense" ]
C
ataxx_bankswitch
void
void ataxx_bankswitch(running_machine *machine) { static const UINT32 bank_list[] = { 0x02000, 0x18000, 0x20000, 0x28000, 0x30000, 0x38000, 0x40000, 0x48000, 0x50000, 0x58000, 0x60000, 0x68000, 0x70000, 0x78000, 0x80000, 0x88000 }; UINT8 *address; battery_ram_enable = ((master_bank & 0x30) == 0x10); address = &master_base[bank_list[master_bank & 15]]; if (bank_list[master_bank & 15] >= master_length) { logerror("%s:Master bank %02X out of range!\n", cpuexec_describe_context(machine), master_bank & 15); address = &master_base[bank_list[0]]; } memory_set_bankptr(machine, 1, address); if (battery_ram_enable) address = battery_ram; else if ((master_bank & 0x30) == 0x20) address = &ataxx_qram[(master_bank & 0xc0) << 8]; else address = &master_base[0xa000]; memory_set_bankptr(machine, 2, address); wcol_enable = ((master_bank & 0x30) == 0x30); }
/* bankswitching for Ataxx, WSF, Indy Heat, and Brute Force */
bankswitching for Ataxx, WSF, Indy Heat, and Brute Force
[ "bankswitching", "for", "Ataxx", "WSF", "Indy", "Heat", "and", "Brute", "Force" ]
void ataxx_bankswitch(running_machine *machine) { static const UINT32 bank_list[] = { 0x02000, 0x18000, 0x20000, 0x28000, 0x30000, 0x38000, 0x40000, 0x48000, 0x50000, 0x58000, 0x60000, 0x68000, 0x70000, 0x78000, 0x80000, 0x88000 }; UINT8 *address; battery_ram_enable = ((master_bank & 0x30) == 0x10); address = &master_base[bank_list[master_bank & 15]]; if (bank_list[master_bank & 15] >= master_length) { logerror("%s:Master bank %02X out of range!\n", cpuexec_describe_context(machine), master_bank & 15); address = &master_base[bank_list[0]]; } memory_set_bankptr(machine, 1, address); if (battery_ram_enable) address = battery_ram; else if ((master_bank & 0x30) == 0x20) address = &ataxx_qram[(master_bank & 0xc0) << 8]; else address = &master_base[0xa000]; memory_set_bankptr(machine, 2, address); wcol_enable = ((master_bank & 0x30) == 0x30); }
[ "void", "ataxx_bankswitch", "(", "running_machine", "*", "machine", ")", "{", "static", "const", "UINT32", "bank_list", "[", "]", "=", "{", "0x02000", ",", "0x18000", ",", "0x20000", ",", "0x28000", ",", "0x30000", ",", "0x38000", ",", "0x40000", ",", "0x48000", ",", "0x50000", ",", "0x58000", ",", "0x60000", ",", "0x68000", ",", "0x70000", ",", "0x78000", ",", "0x80000", ",", "0x88000", "}", ";", "UINT8", "*", "address", ";", "battery_ram_enable", "=", "(", "(", "master_bank", "&", "0x30", ")", "==", "0x10", ")", ";", "address", "=", "&", "master_base", "[", "bank_list", "[", "master_bank", "&", "15", "]", "]", ";", "if", "(", "bank_list", "[", "master_bank", "&", "15", "]", ">=", "master_length", ")", "{", "logerror", "(", "\"", "\\n", "\"", ",", "cpuexec_describe_context", "(", "machine", ")", ",", "master_bank", "&", "15", ")", ";", "address", "=", "&", "master_base", "[", "bank_list", "[", "0", "]", "]", ";", "}", "memory_set_bankptr", "(", "machine", ",", "1", ",", "address", ")", ";", "if", "(", "battery_ram_enable", ")", "address", "=", "battery_ram", ";", "else", "if", "(", "(", "master_bank", "&", "0x30", ")", "==", "0x20", ")", "address", "=", "&", "ataxx_qram", "[", "(", "master_bank", "&", "0xc0", ")", "<<", "8", "]", ";", "else", "address", "=", "&", "master_base", "[", "0xa000", "]", ";", "memory_set_bankptr", "(", "machine", ",", "2", ",", "address", ")", ";", "wcol_enable", "=", "(", "(", "master_bank", "&", "0x30", ")", "==", "0x30", ")", ";", "}" ]
bankswitching for Ataxx, WSF, Indy Heat, and Brute Force
[ "bankswitching", "for", "Ataxx", "WSF", "Indy", "Heat", "and", "Brute", "Force" ]
[]
[ { "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": [] }
64451960c90002806359a6234fa882329c7738e3
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/leland.c
[ "Unlicense" ]
C
leland_init_eeprom
void
void leland_init_eeprom(running_machine *machine, UINT8 default_val, const UINT16 *data, UINT8 serial_offset, UINT8 serial_type) { static const eeprom_interface eeprom_intf = { 6, 16, "110", "101", "111" }; UINT8 xorval = (serial_type == SERIAL_TYPE_ADD_XOR || serial_type == SERIAL_TYPE_ENCRYPT_XOR) ? 0xff : 0x00; UINT32 serial; /* initialize everything to the default value */ memset(eeprom_data, default_val, sizeof(eeprom_data)); /* fill in the preset data */ while (*data != 0xffff) { int offset = *data++; int value = *data++; eeprom_data[offset * 2 + 0] = value >> 8; eeprom_data[offset * 2 + 1] = value & 0xff; } /* pick a serial number -- examples of real serial numbers: Team QB: 21101957 AAFB: 26101119 and 26101039 */ serial = 0x12345678; /* switch off the serial number type */ switch (serial_type) { case SERIAL_TYPE_ADD: case SERIAL_TYPE_ADD_XOR: { int i; for (i = 0; i < 10; i++) { int digit; if (i >= 8) digit = 0; else digit = ((serial << (i * 4)) >> 28) & 15; digit = ('0' + digit) * 2; eeprom_data[serial_offset * 2 + 0 + (i ^ 1)] = (digit / 3) ^ xorval; eeprom_data[serial_offset * 2 + 10 + (i ^ 1)] = (digit / 3) ^ xorval; eeprom_data[serial_offset * 2 + 20 + (i ^ 1)] = (digit - (2 * (digit / 3))) ^ xorval; } break; } case SERIAL_TYPE_ENCRYPT: case SERIAL_TYPE_ENCRYPT_XOR: { int d, e, h, l; /* break the serial number out into pieces */ l = (serial >> 24) & 0xff; h = (serial >> 16) & 0xff; e = (serial >> 8) & 0xff; d = serial & 0xff; /* decrypt the data */ h = ((h ^ 0x2a ^ l) ^ 0xff) + 5; d = ((d + 0x2a) ^ e) ^ 0xff; l ^= e; e ^= 0x2a; /* store the bytes */ eeprom_data[serial_offset * 2 + 0] = h ^ xorval; eeprom_data[serial_offset * 2 + 1] = l ^ xorval; eeprom_data[serial_offset * 2 + 2] = d ^ xorval; eeprom_data[serial_offset * 2 + 3] = e ^ xorval; break; } } eeprom_init(machine, &eeprom_intf); }
/************************************* * * EEPROM handling (64 x 16bits) * *************************************/
EEPROM handling (64 x 16bits)
[ "EEPROM", "handling", "(", "64", "x", "16bits", ")" ]
void leland_init_eeprom(running_machine *machine, UINT8 default_val, const UINT16 *data, UINT8 serial_offset, UINT8 serial_type) { static const eeprom_interface eeprom_intf = { 6, 16, "110", "101", "111" }; UINT8 xorval = (serial_type == SERIAL_TYPE_ADD_XOR || serial_type == SERIAL_TYPE_ENCRYPT_XOR) ? 0xff : 0x00; UINT32 serial; memset(eeprom_data, default_val, sizeof(eeprom_data)); while (*data != 0xffff) { int offset = *data++; int value = *data++; eeprom_data[offset * 2 + 0] = value >> 8; eeprom_data[offset * 2 + 1] = value & 0xff; } serial = 0x12345678; switch (serial_type) { case SERIAL_TYPE_ADD: case SERIAL_TYPE_ADD_XOR: { int i; for (i = 0; i < 10; i++) { int digit; if (i >= 8) digit = 0; else digit = ((serial << (i * 4)) >> 28) & 15; digit = ('0' + digit) * 2; eeprom_data[serial_offset * 2 + 0 + (i ^ 1)] = (digit / 3) ^ xorval; eeprom_data[serial_offset * 2 + 10 + (i ^ 1)] = (digit / 3) ^ xorval; eeprom_data[serial_offset * 2 + 20 + (i ^ 1)] = (digit - (2 * (digit / 3))) ^ xorval; } break; } case SERIAL_TYPE_ENCRYPT: case SERIAL_TYPE_ENCRYPT_XOR: { int d, e, h, l; l = (serial >> 24) & 0xff; h = (serial >> 16) & 0xff; e = (serial >> 8) & 0xff; d = serial & 0xff; h = ((h ^ 0x2a ^ l) ^ 0xff) + 5; d = ((d + 0x2a) ^ e) ^ 0xff; l ^= e; e ^= 0x2a; eeprom_data[serial_offset * 2 + 0] = h ^ xorval; eeprom_data[serial_offset * 2 + 1] = l ^ xorval; eeprom_data[serial_offset * 2 + 2] = d ^ xorval; eeprom_data[serial_offset * 2 + 3] = e ^ xorval; break; } } eeprom_init(machine, &eeprom_intf); }
[ "void", "leland_init_eeprom", "(", "running_machine", "*", "machine", ",", "UINT8", "default_val", ",", "const", "UINT16", "*", "data", ",", "UINT8", "serial_offset", ",", "UINT8", "serial_type", ")", "{", "static", "const", "eeprom_interface", "eeprom_intf", "=", "{", "6", ",", "16", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ";", "UINT8", "xorval", "=", "(", "serial_type", "==", "SERIAL_TYPE_ADD_XOR", "||", "serial_type", "==", "SERIAL_TYPE_ENCRYPT_XOR", ")", "?", "0xff", ":", "0x00", ";", "UINT32", "serial", ";", "memset", "(", "eeprom_data", ",", "default_val", ",", "sizeof", "(", "eeprom_data", ")", ")", ";", "while", "(", "*", "data", "!=", "0xffff", ")", "{", "int", "offset", "=", "*", "data", "++", ";", "int", "value", "=", "*", "data", "++", ";", "eeprom_data", "[", "offset", "*", "2", "+", "0", "]", "=", "value", ">>", "8", ";", "eeprom_data", "[", "offset", "*", "2", "+", "1", "]", "=", "value", "&", "0xff", ";", "}", "serial", "=", "0x12345678", ";", "switch", "(", "serial_type", ")", "{", "case", "SERIAL_TYPE_ADD", ":", "case", "SERIAL_TYPE_ADD_XOR", ":", "{", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "10", ";", "i", "++", ")", "{", "int", "digit", ";", "if", "(", "i", ">=", "8", ")", "digit", "=", "0", ";", "else", "digit", "=", "(", "(", "serial", "<<", "(", "i", "*", "4", ")", ")", ">>", "28", ")", "&", "15", ";", "digit", "=", "(", "'", "'", "+", "digit", ")", "*", "2", ";", "eeprom_data", "[", "serial_offset", "*", "2", "+", "0", "+", "(", "i", "^", "1", ")", "]", "=", "(", "digit", "/", "3", ")", "^", "xorval", ";", "eeprom_data", "[", "serial_offset", "*", "2", "+", "10", "+", "(", "i", "^", "1", ")", "]", "=", "(", "digit", "/", "3", ")", "^", "xorval", ";", "eeprom_data", "[", "serial_offset", "*", "2", "+", "20", "+", "(", "i", "^", "1", ")", "]", "=", "(", "digit", "-", "(", "2", "*", "(", "digit", "/", "3", ")", ")", ")", "^", "xorval", ";", "}", "break", ";", "}", "case", "SERIAL_TYPE_ENCRYPT", ":", "case", "SERIAL_TYPE_ENCRYPT_XOR", ":", "{", "int", "d", ",", "e", ",", "h", ",", "l", ";", "l", "=", "(", "serial", ">>", "24", ")", "&", "0xff", ";", "h", "=", "(", "serial", ">>", "16", ")", "&", "0xff", ";", "e", "=", "(", "serial", ">>", "8", ")", "&", "0xff", ";", "d", "=", "serial", "&", "0xff", ";", "h", "=", "(", "(", "h", "^", "0x2a", "^", "l", ")", "^", "0xff", ")", "+", "5", ";", "d", "=", "(", "(", "d", "+", "0x2a", ")", "^", "e", ")", "^", "0xff", ";", "l", "^=", "e", ";", "e", "^=", "0x2a", ";", "eeprom_data", "[", "serial_offset", "*", "2", "+", "0", "]", "=", "h", "^", "xorval", ";", "eeprom_data", "[", "serial_offset", "*", "2", "+", "1", "]", "=", "l", "^", "xorval", ";", "eeprom_data", "[", "serial_offset", "*", "2", "+", "2", "]", "=", "d", "^", "xorval", ";", "eeprom_data", "[", "serial_offset", "*", "2", "+", "3", "]", "=", "e", "^", "xorval", ";", "break", ";", "}", "}", "eeprom_init", "(", "machine", ",", "&", "eeprom_intf", ")", ";", "}" ]
EEPROM handling (64 x 16bits)
[ "EEPROM", "handling", "(", "64", "x", "16bits", ")" ]
[ "/* initialize everything to the default value */", "/* fill in the preset data */", "/* pick a serial number -- examples of real serial numbers:\n\n Team QB: 21101957\n AAFB: 26101119 and 26101039\n */", "/* switch off the serial number type */", "/* break the serial number out into pieces */", "/* decrypt the data */", "/* store the bytes */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "default_val", "type": "UINT8" }, { "param": "data", "type": "UINT16" }, { "param": "serial_offset", "type": "UINT8" }, { "param": "serial_type", "type": "UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "default_val", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "UINT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "serial_offset", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "serial_type", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
64451960c90002806359a6234fa882329c7738e3
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/leland.c
[ "Unlicense" ]
C
ataxx_init_eeprom
void
void ataxx_init_eeprom(running_machine *machine, UINT8 default_val, const UINT16 *data, UINT8 serial_offset) { static const eeprom_interface eeprom_intf = { 7, 16, "000001100", "000001010", 0, "0000010000000000", "0000010011000000", 1 }; UINT32 serial; /* initialize everything to the default value */ memset(eeprom_data, default_val, sizeof(eeprom_data)); /* fill in the preset data */ while (*data != 0xffff) { int offset = *data++; int value = *data++; eeprom_data[offset * 2 + 0] = value >> 8; eeprom_data[offset * 2 + 1] = value & 0xff; } /* pick a serial number -- examples of real serial numbers: WSF: 30101190 Indy Heat: 31201339 */ serial = 0x12345678; /* encrypt the serial number */ { int d, e, h, l; /* break the serial number out into pieces */ l = (serial >> 24) & 0xff; h = (serial >> 16) & 0xff; e = (serial >> 8) & 0xff; d = serial & 0xff; /* decrypt the data */ h = ((h ^ 0x2a ^ l) ^ 0xff) + 5; d = ((d + 0x2a) ^ e) ^ 0xff; l ^= e; e ^= 0x2a; /* store the bytes */ eeprom_data[serial_offset * 2 + 0] = h; eeprom_data[serial_offset * 2 + 1] = l; eeprom_data[serial_offset * 2 + 2] = d; eeprom_data[serial_offset * 2 + 3] = e; } /* compute the checksum */ { int i, sum = 0; for (i = 0; i < 0x7f * 2; i++) sum += eeprom_data[i]; sum ^= 0xffff; eeprom_data[0x7f * 2 + 0] = (sum >> 8) & 0xff; eeprom_data[0x7f * 2 + 1] = sum & 0xff; eeprom_init(machine, &eeprom_intf); } }
/************************************* * * EEPROM handling (128 x 16bits) * *************************************/
EEPROM handling (128 x 16bits)
[ "EEPROM", "handling", "(", "128", "x", "16bits", ")" ]
void ataxx_init_eeprom(running_machine *machine, UINT8 default_val, const UINT16 *data, UINT8 serial_offset) { static const eeprom_interface eeprom_intf = { 7, 16, "000001100", "000001010", 0, "0000010000000000", "0000010011000000", 1 }; UINT32 serial; memset(eeprom_data, default_val, sizeof(eeprom_data)); while (*data != 0xffff) { int offset = *data++; int value = *data++; eeprom_data[offset * 2 + 0] = value >> 8; eeprom_data[offset * 2 + 1] = value & 0xff; } serial = 0x12345678; { int d, e, h, l; l = (serial >> 24) & 0xff; h = (serial >> 16) & 0xff; e = (serial >> 8) & 0xff; d = serial & 0xff; h = ((h ^ 0x2a ^ l) ^ 0xff) + 5; d = ((d + 0x2a) ^ e) ^ 0xff; l ^= e; e ^= 0x2a; eeprom_data[serial_offset * 2 + 0] = h; eeprom_data[serial_offset * 2 + 1] = l; eeprom_data[serial_offset * 2 + 2] = d; eeprom_data[serial_offset * 2 + 3] = e; } { int i, sum = 0; for (i = 0; i < 0x7f * 2; i++) sum += eeprom_data[i]; sum ^= 0xffff; eeprom_data[0x7f * 2 + 0] = (sum >> 8) & 0xff; eeprom_data[0x7f * 2 + 1] = sum & 0xff; eeprom_init(machine, &eeprom_intf); } }
[ "void", "ataxx_init_eeprom", "(", "running_machine", "*", "machine", ",", "UINT8", "default_val", ",", "const", "UINT16", "*", "data", ",", "UINT8", "serial_offset", ")", "{", "static", "const", "eeprom_interface", "eeprom_intf", "=", "{", "7", ",", "16", ",", "\"", "\"", ",", "\"", "\"", ",", "0", ",", "\"", "\"", ",", "\"", "\"", ",", "1", "}", ";", "UINT32", "serial", ";", "memset", "(", "eeprom_data", ",", "default_val", ",", "sizeof", "(", "eeprom_data", ")", ")", ";", "while", "(", "*", "data", "!=", "0xffff", ")", "{", "int", "offset", "=", "*", "data", "++", ";", "int", "value", "=", "*", "data", "++", ";", "eeprom_data", "[", "offset", "*", "2", "+", "0", "]", "=", "value", ">>", "8", ";", "eeprom_data", "[", "offset", "*", "2", "+", "1", "]", "=", "value", "&", "0xff", ";", "}", "serial", "=", "0x12345678", ";", "{", "int", "d", ",", "e", ",", "h", ",", "l", ";", "l", "=", "(", "serial", ">>", "24", ")", "&", "0xff", ";", "h", "=", "(", "serial", ">>", "16", ")", "&", "0xff", ";", "e", "=", "(", "serial", ">>", "8", ")", "&", "0xff", ";", "d", "=", "serial", "&", "0xff", ";", "h", "=", "(", "(", "h", "^", "0x2a", "^", "l", ")", "^", "0xff", ")", "+", "5", ";", "d", "=", "(", "(", "d", "+", "0x2a", ")", "^", "e", ")", "^", "0xff", ";", "l", "^=", "e", ";", "e", "^=", "0x2a", ";", "eeprom_data", "[", "serial_offset", "*", "2", "+", "0", "]", "=", "h", ";", "eeprom_data", "[", "serial_offset", "*", "2", "+", "1", "]", "=", "l", ";", "eeprom_data", "[", "serial_offset", "*", "2", "+", "2", "]", "=", "d", ";", "eeprom_data", "[", "serial_offset", "*", "2", "+", "3", "]", "=", "e", ";", "}", "{", "int", "i", ",", "sum", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "0x7f", "*", "2", ";", "i", "++", ")", "sum", "+=", "eeprom_data", "[", "i", "]", ";", "sum", "^=", "0xffff", ";", "eeprom_data", "[", "0x7f", "*", "2", "+", "0", "]", "=", "(", "sum", ">>", "8", ")", "&", "0xff", ";", "eeprom_data", "[", "0x7f", "*", "2", "+", "1", "]", "=", "sum", "&", "0xff", ";", "eeprom_init", "(", "machine", ",", "&", "eeprom_intf", ")", ";", "}", "}" ]
EEPROM handling (128 x 16bits)
[ "EEPROM", "handling", "(", "128", "x", "16bits", ")" ]
[ "/* initialize everything to the default value */", "/* fill in the preset data */", "/* pick a serial number -- examples of real serial numbers:\n\n WSF: 30101190\n Indy Heat: 31201339\n */", "/* encrypt the serial number */", "/* break the serial number out into pieces */", "/* decrypt the data */", "/* store the bytes */", "/* compute the checksum */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "default_val", "type": "UINT8" }, { "param": "data", "type": "UINT16" }, { "param": "serial_offset", "type": "UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "default_val", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "UINT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "serial_offset", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
64451960c90002806359a6234fa882329c7738e3
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/leland.c
[ "Unlicense" ]
C
keycard_r
int
static int keycard_r(running_machine *machine) { int result = 0; if (LOG_KEYCARDS_FULL) logerror(" (%s:keycard_r)\n", cpuexec_describe_context(machine)); /* if we have a valid keycard read state, we're reading from the keycard */ if (keycard_state & 0x80) { /* clock in new data */ if (keycard_bit == 1) { keycard_shift = 0xff; /* no data, but this is where we would clock it in */ if (LOG_KEYCARDS) logerror(" (clocked in %02X)\n", keycard_shift); } /* clock in the bit */ result = (~keycard_shift & 1) << ((keycard_state >> 4) & 3); if (LOG_KEYCARDS) logerror(" (read %02X)\n", result); } return result; }
/*-------------------------------------------------------------------- A note about keycards: These were apparently static programmable ROMs that could be inserted into certain games. The games would then save/load statistics on them. The data is accessed via a serial protocol, which is implemented below. There are two known commands that are written; each command is 3 bytes and accesses 128 bytes of data from the keycard: 62 00 80 9D 00 80 the last byte appears to specify the length of data to transfer. The format of the data on the card is pretty heavily encrypted. The first 7 bytes read serves as a header: D5 43 49 4E 2A xx yy where xx is a game-specific key, and yy is the complement of the key. For example, World Series Baseball uses 04/FB. Alley Master uses 05/FA. The last 112 bytes of data is encrypted via the following method: for (i = 16, b = 0x70, r = 0x08; i < 128; i++, b--, r += 0x10) { UINT8 a = original_data[i] ^ 0xff; a = (a >> 3) | (a << 5); a = (((a ^ r) + 1 + b) ^ b) - b; encrypted_data[i] = a; } The data that is encrypted is stored alternating with a checksum byte. The checksum for a value A is ((A ^ 0xa5) + 0x27) ^ 0x34. --------------------------------------------------------------------*/
A note about keycards: These were apparently static programmable ROMs that could be inserted into certain games. The games would then save/load statistics on them. The data is accessed via a serial protocol, which is implemented below. There are two known commands that are written; each command is 3 bytes and accesses 128 bytes of data from the keycard. the last byte appears to specify the length of data to transfer. The format of the data on the card is pretty heavily encrypted. The first 7 bytes read serves as a header. The last 112 bytes of data is encrypted via the following method. The data that is encrypted is stored alternating with a checksum byte.
[ "A", "note", "about", "keycards", ":", "These", "were", "apparently", "static", "programmable", "ROMs", "that", "could", "be", "inserted", "into", "certain", "games", ".", "The", "games", "would", "then", "save", "/", "load", "statistics", "on", "them", ".", "The", "data", "is", "accessed", "via", "a", "serial", "protocol", "which", "is", "implemented", "below", ".", "There", "are", "two", "known", "commands", "that", "are", "written", ";", "each", "command", "is", "3", "bytes", "and", "accesses", "128", "bytes", "of", "data", "from", "the", "keycard", ".", "the", "last", "byte", "appears", "to", "specify", "the", "length", "of", "data", "to", "transfer", ".", "The", "format", "of", "the", "data", "on", "the", "card", "is", "pretty", "heavily", "encrypted", ".", "The", "first", "7", "bytes", "read", "serves", "as", "a", "header", ".", "The", "last", "112", "bytes", "of", "data", "is", "encrypted", "via", "the", "following", "method", ".", "The", "data", "that", "is", "encrypted", "is", "stored", "alternating", "with", "a", "checksum", "byte", "." ]
static int keycard_r(running_machine *machine) { int result = 0; if (LOG_KEYCARDS_FULL) logerror(" (%s:keycard_r)\n", cpuexec_describe_context(machine)); if (keycard_state & 0x80) { if (keycard_bit == 1) { keycard_shift = 0xff; if (LOG_KEYCARDS) logerror(" (clocked in %02X)\n", keycard_shift); } result = (~keycard_shift & 1) << ((keycard_state >> 4) & 3); if (LOG_KEYCARDS) logerror(" (read %02X)\n", result); } return result; }
[ "static", "int", "keycard_r", "(", "running_machine", "*", "machine", ")", "{", "int", "result", "=", "0", ";", "if", "(", "LOG_KEYCARDS_FULL", ")", "logerror", "(", "\"", "\\n", "\"", ",", "cpuexec_describe_context", "(", "machine", ")", ")", ";", "if", "(", "keycard_state", "&", "0x80", ")", "{", "if", "(", "keycard_bit", "==", "1", ")", "{", "keycard_shift", "=", "0xff", ";", "if", "(", "LOG_KEYCARDS", ")", "logerror", "(", "\"", "\\n", "\"", ",", "keycard_shift", ")", ";", "}", "result", "=", "(", "~", "keycard_shift", "&", "1", ")", "<<", "(", "(", "keycard_state", ">>", "4", ")", "&", "3", ")", ";", "if", "(", "LOG_KEYCARDS", ")", "logerror", "(", "\"", "\\n", "\"", ",", "result", ")", ";", "}", "return", "result", ";", "}" ]
A note about keycards: These were apparently static programmable ROMs that could be inserted into certain games.
[ "A", "note", "about", "keycards", ":", "These", "were", "apparently", "static", "programmable", "ROMs", "that", "could", "be", "inserted", "into", "certain", "games", "." ]
[ "/* if we have a valid keycard read state, we're reading from the keycard */", "/* clock in new data */", "/* no data, but this is where we would clock it in */", "/* clock in the bit */" ]
[ { "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": [] }
d6059a80e6789564ec465ad192d7e674b8c87636
lofunz/mieme
Reloaded/trunk/src/emu/cpu/sharc/sharcops.c
[ "Unlicense" ]
C
sharcop_do_until_counter_imm
void
static void sharcop_do_until_counter_imm(SHARC_REGS *cpustate) { UINT16 data = (UINT16)(cpustate->opcode >> 24); int offset = SIGN_EXTEND24(cpustate->opcode & 0xffffff); UINT32 address = cpustate->pc + offset; int type; int cond = 0xf; /* until LCE (loop counter expired */ int distance = abs(offset); if (distance == 1) { type = 1; } else if (distance == 2) { type = 2; } else { type = 3; } cpustate->lcntr = data; if (cpustate->lcntr > 0) { PUSH_PC(cpustate, cpustate->pc+1); PUSH_LOOP(cpustate, address | (type << 30) | (cond << 24), cpustate->lcntr); } }
/* do until counter expired, LCNTR immediate */
do until counter expired, LCNTR immediate
[ "do", "until", "counter", "expired", "LCNTR", "immediate" ]
static void sharcop_do_until_counter_imm(SHARC_REGS *cpustate) { UINT16 data = (UINT16)(cpustate->opcode >> 24); int offset = SIGN_EXTEND24(cpustate->opcode & 0xffffff); UINT32 address = cpustate->pc + offset; int type; int cond = 0xf; int distance = abs(offset); if (distance == 1) { type = 1; } else if (distance == 2) { type = 2; } else { type = 3; } cpustate->lcntr = data; if (cpustate->lcntr > 0) { PUSH_PC(cpustate, cpustate->pc+1); PUSH_LOOP(cpustate, address | (type << 30) | (cond << 24), cpustate->lcntr); } }
[ "static", "void", "sharcop_do_until_counter_imm", "(", "SHARC_REGS", "*", "cpustate", ")", "{", "UINT16", "data", "=", "(", "UINT16", ")", "(", "cpustate", "->", "opcode", ">>", "24", ")", ";", "int", "offset", "=", "SIGN_EXTEND24", "(", "cpustate", "->", "opcode", "&", "0xffffff", ")", ";", "UINT32", "address", "=", "cpustate", "->", "pc", "+", "offset", ";", "int", "type", ";", "int", "cond", "=", "0xf", ";", "int", "distance", "=", "abs", "(", "offset", ")", ";", "if", "(", "distance", "==", "1", ")", "{", "type", "=", "1", ";", "}", "else", "if", "(", "distance", "==", "2", ")", "{", "type", "=", "2", ";", "}", "else", "{", "type", "=", "3", ";", "}", "cpustate", "->", "lcntr", "=", "data", ";", "if", "(", "cpustate", "->", "lcntr", ">", "0", ")", "{", "PUSH_PC", "(", "cpustate", ",", "cpustate", "->", "pc", "+", "1", ")", ";", "PUSH_LOOP", "(", "cpustate", ",", "address", "|", "(", "type", "<<", "30", ")", "|", "(", "cond", "<<", "24", ")", ",", "cpustate", "->", "lcntr", ")", ";", "}", "}" ]
do until counter expired, LCNTR immediate
[ "do", "until", "counter", "expired", "LCNTR", "immediate" ]
[ "/* until LCE (loop counter expired */" ]
[ { "param": "cpustate", "type": "SHARC_REGS" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cpustate", "type": "SHARC_REGS", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d6059a80e6789564ec465ad192d7e674b8c87636
lofunz/mieme
Reloaded/trunk/src/emu/cpu/sharc/sharcops.c
[ "Unlicense" ]
C
sharcop_do_until_counter_ureg
void
static void sharcop_do_until_counter_ureg(SHARC_REGS *cpustate) { int ureg = (cpustate->opcode >> 32) & 0xff; int offset = SIGN_EXTEND24(cpustate->opcode & 0xffffff); UINT32 address = cpustate->pc + offset; int type; int cond = 0xf; /* until LCE (loop counter expired */ int distance = abs(offset); if (distance == 1) { type = 1; } else if (distance == 2) { type = 2; } else { type = 3; } cpustate->lcntr = GET_UREG(cpustate, ureg); if (cpustate->lcntr > 0) { PUSH_PC(cpustate, cpustate->pc+1); PUSH_LOOP(cpustate, address | (type << 30) | (cond << 24), cpustate->lcntr); } }
/* do until counter expired, LCNTR from UREG */
do until counter expired, LCNTR from UREG
[ "do", "until", "counter", "expired", "LCNTR", "from", "UREG" ]
static void sharcop_do_until_counter_ureg(SHARC_REGS *cpustate) { int ureg = (cpustate->opcode >> 32) & 0xff; int offset = SIGN_EXTEND24(cpustate->opcode & 0xffffff); UINT32 address = cpustate->pc + offset; int type; int cond = 0xf; int distance = abs(offset); if (distance == 1) { type = 1; } else if (distance == 2) { type = 2; } else { type = 3; } cpustate->lcntr = GET_UREG(cpustate, ureg); if (cpustate->lcntr > 0) { PUSH_PC(cpustate, cpustate->pc+1); PUSH_LOOP(cpustate, address | (type << 30) | (cond << 24), cpustate->lcntr); } }
[ "static", "void", "sharcop_do_until_counter_ureg", "(", "SHARC_REGS", "*", "cpustate", ")", "{", "int", "ureg", "=", "(", "cpustate", "->", "opcode", ">>", "32", ")", "&", "0xff", ";", "int", "offset", "=", "SIGN_EXTEND24", "(", "cpustate", "->", "opcode", "&", "0xffffff", ")", ";", "UINT32", "address", "=", "cpustate", "->", "pc", "+", "offset", ";", "int", "type", ";", "int", "cond", "=", "0xf", ";", "int", "distance", "=", "abs", "(", "offset", ")", ";", "if", "(", "distance", "==", "1", ")", "{", "type", "=", "1", ";", "}", "else", "if", "(", "distance", "==", "2", ")", "{", "type", "=", "2", ";", "}", "else", "{", "type", "=", "3", ";", "}", "cpustate", "->", "lcntr", "=", "GET_UREG", "(", "cpustate", ",", "ureg", ")", ";", "if", "(", "cpustate", "->", "lcntr", ">", "0", ")", "{", "PUSH_PC", "(", "cpustate", ",", "cpustate", "->", "pc", "+", "1", ")", ";", "PUSH_LOOP", "(", "cpustate", ",", "address", "|", "(", "type", "<<", "30", ")", "|", "(", "cond", "<<", "24", ")", ",", "cpustate", "->", "lcntr", ")", ";", "}", "}" ]
do until counter expired, LCNTR from UREG
[ "do", "until", "counter", "expired", "LCNTR", "from", "UREG" ]
[ "/* until LCE (loop counter expired */" ]
[ { "param": "cpustate", "type": "SHARC_REGS" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cpustate", "type": "SHARC_REGS", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d6059a80e6789564ec465ad192d7e674b8c87636
lofunz/mieme
Reloaded/trunk/src/emu/cpu/sharc/sharcops.c
[ "Unlicense" ]
C
sharcop_push_pop_stacks
void
static void sharcop_push_pop_stacks(SHARC_REGS *cpustate) { if (cpustate->opcode & U64(0x008000000000)) { fatalerror("sharcop_push_pop_stacks: push loop not implemented"); } if (cpustate->opcode & U64(0x004000000000)) { fatalerror("sharcop_push_pop_stacks: pop loop not implemented"); } if (cpustate->opcode & U64(0x002000000000)) { //fatalerror("sharcop_push_pop_stacks: push sts not implemented"); PUSH_STATUS_STACK(cpustate); } if (cpustate->opcode & U64(0x001000000000)) { //fatalerror("sharcop_push_pop_stacks: pop sts not implemented"); POP_STATUS_STACK(cpustate); } if (cpustate->opcode & U64(0x000800000000)) { PUSH_PC(cpustate, cpustate->pcstk); } if (cpustate->opcode & U64(0x000400000000)) { POP_PC(cpustate); } }
/* push/pop stacks / flush cache */
push/pop stacks / flush cache
[ "push", "/", "pop", "stacks", "/", "flush", "cache" ]
static void sharcop_push_pop_stacks(SHARC_REGS *cpustate) { if (cpustate->opcode & U64(0x008000000000)) { fatalerror("sharcop_push_pop_stacks: push loop not implemented"); } if (cpustate->opcode & U64(0x004000000000)) { fatalerror("sharcop_push_pop_stacks: pop loop not implemented"); } if (cpustate->opcode & U64(0x002000000000)) { PUSH_STATUS_STACK(cpustate); } if (cpustate->opcode & U64(0x001000000000)) { POP_STATUS_STACK(cpustate); } if (cpustate->opcode & U64(0x000800000000)) { PUSH_PC(cpustate, cpustate->pcstk); } if (cpustate->opcode & U64(0x000400000000)) { POP_PC(cpustate); } }
[ "static", "void", "sharcop_push_pop_stacks", "(", "SHARC_REGS", "*", "cpustate", ")", "{", "if", "(", "cpustate", "->", "opcode", "&", "U64", "(", "0x008000000000", ")", ")", "{", "fatalerror", "(", "\"", "\"", ")", ";", "}", "if", "(", "cpustate", "->", "opcode", "&", "U64", "(", "0x004000000000", ")", ")", "{", "fatalerror", "(", "\"", "\"", ")", ";", "}", "if", "(", "cpustate", "->", "opcode", "&", "U64", "(", "0x002000000000", ")", ")", "{", "PUSH_STATUS_STACK", "(", "cpustate", ")", ";", "}", "if", "(", "cpustate", "->", "opcode", "&", "U64", "(", "0x001000000000", ")", ")", "{", "POP_STATUS_STACK", "(", "cpustate", ")", ";", "}", "if", "(", "cpustate", "->", "opcode", "&", "U64", "(", "0x000800000000", ")", ")", "{", "PUSH_PC", "(", "cpustate", ",", "cpustate", "->", "pcstk", ")", ";", "}", "if", "(", "cpustate", "->", "opcode", "&", "U64", "(", "0x000400000000", ")", ")", "{", "POP_PC", "(", "cpustate", ")", ";", "}", "}" ]
push/pop stacks / flush cache
[ "push", "/", "pop", "stacks", "/", "flush", "cache" ]
[ "//fatalerror(\"sharcop_push_pop_stacks: push sts not implemented\");\r", "//fatalerror(\"sharcop_push_pop_stacks: pop sts not implemented\");\r" ]
[ { "param": "cpustate", "type": "SHARC_REGS" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cpustate", "type": "SHARC_REGS", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4b64a9813bd3f2cfea9f2fad3cd62a31192c4f2a
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/video/generic.c
[ "Unlicense" ]
C
generic_video_init
void
void generic_video_init(running_machine *machine) { videoram = NULL; videoram16 = NULL; videoram32 = NULL; videoram_size = 0; colorram = NULL; colorram16 = NULL; colorram32 = NULL; spriteram = NULL; spriteram16 = NULL; spriteram32 = NULL; spriteram_2 = NULL; spriteram16_2 = NULL; spriteram32_2 = NULL; spriteram_3 = NULL; spriteram16_3 = NULL; spriteram32_3 = NULL; buffered_spriteram = NULL; buffered_spriteram16 = NULL; buffered_spriteram32 = NULL; buffered_spriteram_2 = NULL; buffered_spriteram16_2 = NULL; buffered_spriteram32_2 = NULL; spriteram_size = 0; /* ... here just for convenience */ spriteram_2_size = 0; spriteram_3_size = 0; tmpbitmap = NULL; flip_screen_x = flip_screen_y = 0; state_save_register_item(machine, "video", NULL, 0, flip_screen_x); state_save_register_item(machine, "video", NULL, 0, flip_screen_y); }
/*------------------------------------------------- generic_video_init - initialize globals and register for save states -------------------------------------------------*/
initialize globals and register for save states
[ "initialize", "globals", "and", "register", "for", "save", "states" ]
void generic_video_init(running_machine *machine) { videoram = NULL; videoram16 = NULL; videoram32 = NULL; videoram_size = 0; colorram = NULL; colorram16 = NULL; colorram32 = NULL; spriteram = NULL; spriteram16 = NULL; spriteram32 = NULL; spriteram_2 = NULL; spriteram16_2 = NULL; spriteram32_2 = NULL; spriteram_3 = NULL; spriteram16_3 = NULL; spriteram32_3 = NULL; buffered_spriteram = NULL; buffered_spriteram16 = NULL; buffered_spriteram32 = NULL; buffered_spriteram_2 = NULL; buffered_spriteram16_2 = NULL; buffered_spriteram32_2 = NULL; spriteram_size = 0; spriteram_2_size = 0; spriteram_3_size = 0; tmpbitmap = NULL; flip_screen_x = flip_screen_y = 0; state_save_register_item(machine, "video", NULL, 0, flip_screen_x); state_save_register_item(machine, "video", NULL, 0, flip_screen_y); }
[ "void", "generic_video_init", "(", "running_machine", "*", "machine", ")", "{", "videoram", "=", "NULL", ";", "videoram16", "=", "NULL", ";", "videoram32", "=", "NULL", ";", "videoram_size", "=", "0", ";", "colorram", "=", "NULL", ";", "colorram16", "=", "NULL", ";", "colorram32", "=", "NULL", ";", "spriteram", "=", "NULL", ";", "spriteram16", "=", "NULL", ";", "spriteram32", "=", "NULL", ";", "spriteram_2", "=", "NULL", ";", "spriteram16_2", "=", "NULL", ";", "spriteram32_2", "=", "NULL", ";", "spriteram_3", "=", "NULL", ";", "spriteram16_3", "=", "NULL", ";", "spriteram32_3", "=", "NULL", ";", "buffered_spriteram", "=", "NULL", ";", "buffered_spriteram16", "=", "NULL", ";", "buffered_spriteram32", "=", "NULL", ";", "buffered_spriteram_2", "=", "NULL", ";", "buffered_spriteram16_2", "=", "NULL", ";", "buffered_spriteram32_2", "=", "NULL", ";", "spriteram_size", "=", "0", ";", "spriteram_2_size", "=", "0", ";", "spriteram_3_size", "=", "0", ";", "tmpbitmap", "=", "NULL", ";", "flip_screen_x", "=", "flip_screen_y", "=", "0", ";", "state_save_register_item", "(", "machine", ",", "\"", "\"", ",", "NULL", ",", "0", ",", "flip_screen_x", ")", ";", "state_save_register_item", "(", "machine", ",", "\"", "\"", ",", "NULL", ",", "0", ",", "flip_screen_y", ")", ";", "}" ]
generic_video_init - initialize globals and register for save states
[ "generic_video_init", "-", "initialize", "globals", "and", "register", "for", "save", "states" ]
[ "/* ... here just for convenience */" ]
[ { "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": [] }
4b64a9813bd3f2cfea9f2fad3cd62a31192c4f2a
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/video/generic.c
[ "Unlicense" ]
C
flip_screen_set_no_update
void
void flip_screen_set_no_update(running_machine *machine, int on) { /* flip_screen_y is not updated on purpose * this function is for drivers which * where writing to flip_screen_x to * bypass update_flip */ flip_screen_x = on; }
/*------------------------------------------------- flip_screen_set_no_update - set global flip do not call update_flip. -------------------------------------------------*/
set global flip do not call update_flip.
[ "set", "global", "flip", "do", "not", "call", "update_flip", "." ]
void flip_screen_set_no_update(running_machine *machine, int on) { flip_screen_x = on; }
[ "void", "flip_screen_set_no_update", "(", "running_machine", "*", "machine", ",", "int", "on", ")", "{", "flip_screen_x", "=", "on", ";", "}" ]
flip_screen_set_no_update - set global flip do not call update_flip.
[ "flip_screen_set_no_update", "-", "set", "global", "flip", "do", "not", "call", "update_flip", "." ]
[ "/* flip_screen_y is not updated on purpose\n * this function is for drivers which\n * where writing to flip_screen_x to\n * bypass update_flip\n */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "on", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "on", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a838f2106c77c50d3479bdae5d6829178dc18267
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/drivers/thunderx.c
[ "Unlicense" ]
C
run_collisions
void
static void run_collisions(int s0, int e0, int s1, int e1, int cm, int hm) { UINT8* p0; UINT8* p1; int ii,jj; p0 = &pmcram[16 + 5*s0]; for (ii = s0; ii < e0; ii++, p0 += 5) { int l0,r0,b0,t0; // check valid if (!(p0[0] & cm)) continue; // get area l0 = p0[3] - p0[1]; r0 = p0[3] + p0[1]; t0 = p0[4] - p0[2]; b0 = p0[4] + p0[2]; p1 = &pmcram[16 + 5*s1]; for (jj = s1; jj < e1; jj++,p1 += 5) { int l1,r1,b1,t1; // check valid if (!(p1[0] & hm)) continue; // get area l1 = p1[3] - p1[1]; r1 = p1[3] + p1[1]; t1 = p1[4] - p1[2]; b1 = p1[4] + p1[2]; // overlap check if (l1 >= r0) continue; if (l0 >= r1) continue; if (t1 >= b0) continue; if (t0 >= b1) continue; // set flags p0[0] = (p0[0] & 0x9f) | (p1[0] & 0x04) | 0x10; p1[0] = (p1[0] & 0x9f) | 0x10; } } }
// run_collisions // // collide objects from s0 to e0 against // objects from s1 to e1 // // only compare objects with the specified bits (cm) set in their flags // only set object 0's hit bit if (hm & 0x40) is true // // the data format is: // // +0 : flags // +1 : width (4 pixel units) // +2 : height (4 pixel units) // +3 : x (2 pixel units) of center of object // +4 : y (2 pixel units) of center of object
run_collisions collide objects from s0 to e0 against objects from s1 to e1 only compare objects with the specified bits (cm) set in their flags only set object 0's hit bit if (hm & 0x40) is true the data format is.
[ "run_collisions", "collide", "objects", "from", "s0", "to", "e0", "against", "objects", "from", "s1", "to", "e1", "only", "compare", "objects", "with", "the", "specified", "bits", "(", "cm", ")", "set", "in", "their", "flags", "only", "set", "object", "0", "'", "s", "hit", "bit", "if", "(", "hm", "&", "0x40", ")", "is", "true", "the", "data", "format", "is", "." ]
static void run_collisions(int s0, int e0, int s1, int e1, int cm, int hm) { UINT8* p0; UINT8* p1; int ii,jj; p0 = &pmcram[16 + 5*s0]; for (ii = s0; ii < e0; ii++, p0 += 5) { int l0,r0,b0,t0; if (!(p0[0] & cm)) continue; l0 = p0[3] - p0[1]; r0 = p0[3] + p0[1]; t0 = p0[4] - p0[2]; b0 = p0[4] + p0[2]; p1 = &pmcram[16 + 5*s1]; for (jj = s1; jj < e1; jj++,p1 += 5) { int l1,r1,b1,t1; if (!(p1[0] & hm)) continue; l1 = p1[3] - p1[1]; r1 = p1[3] + p1[1]; t1 = p1[4] - p1[2]; b1 = p1[4] + p1[2]; if (l1 >= r0) continue; if (l0 >= r1) continue; if (t1 >= b0) continue; if (t0 >= b1) continue; p0[0] = (p0[0] & 0x9f) | (p1[0] & 0x04) | 0x10; p1[0] = (p1[0] & 0x9f) | 0x10; } } }
[ "static", "void", "run_collisions", "(", "int", "s0", ",", "int", "e0", ",", "int", "s1", ",", "int", "e1", ",", "int", "cm", ",", "int", "hm", ")", "{", "UINT8", "*", "p0", ";", "UINT8", "*", "p1", ";", "int", "ii", ",", "jj", ";", "p0", "=", "&", "pmcram", "[", "16", "+", "5", "*", "s0", "]", ";", "for", "(", "ii", "=", "s0", ";", "ii", "<", "e0", ";", "ii", "++", ",", "p0", "+=", "5", ")", "{", "int", "l0", ",", "r0", ",", "b0", ",", "t0", ";", "if", "(", "!", "(", "p0", "[", "0", "]", "&", "cm", ")", ")", "continue", ";", "l0", "=", "p0", "[", "3", "]", "-", "p0", "[", "1", "]", ";", "r0", "=", "p0", "[", "3", "]", "+", "p0", "[", "1", "]", ";", "t0", "=", "p0", "[", "4", "]", "-", "p0", "[", "2", "]", ";", "b0", "=", "p0", "[", "4", "]", "+", "p0", "[", "2", "]", ";", "p1", "=", "&", "pmcram", "[", "16", "+", "5", "*", "s1", "]", ";", "for", "(", "jj", "=", "s1", ";", "jj", "<", "e1", ";", "jj", "++", ",", "p1", "+=", "5", ")", "{", "int", "l1", ",", "r1", ",", "b1", ",", "t1", ";", "if", "(", "!", "(", "p1", "[", "0", "]", "&", "hm", ")", ")", "continue", ";", "l1", "=", "p1", "[", "3", "]", "-", "p1", "[", "1", "]", ";", "r1", "=", "p1", "[", "3", "]", "+", "p1", "[", "1", "]", ";", "t1", "=", "p1", "[", "4", "]", "-", "p1", "[", "2", "]", ";", "b1", "=", "p1", "[", "4", "]", "+", "p1", "[", "2", "]", ";", "if", "(", "l1", ">=", "r0", ")", "continue", ";", "if", "(", "l0", ">=", "r1", ")", "continue", ";", "if", "(", "t1", ">=", "b0", ")", "continue", ";", "if", "(", "t0", ">=", "b1", ")", "continue", ";", "p0", "[", "0", "]", "=", "(", "p0", "[", "0", "]", "&", "0x9f", ")", "|", "(", "p1", "[", "0", "]", "&", "0x04", ")", "|", "0x10", ";", "p1", "[", "0", "]", "=", "(", "p1", "[", "0", "]", "&", "0x9f", ")", "|", "0x10", ";", "}", "}", "}" ]
run_collisions collide objects from s0 to e0 against objects from s1 to e1
[ "run_collisions", "collide", "objects", "from", "s0", "to", "e0", "against", "objects", "from", "s1", "to", "e1" ]
[ "// check valid", "// get area", "// check valid", "// get area", "// overlap check", "// set flags" ]
[ { "param": "s0", "type": "int" }, { "param": "e0", "type": "int" }, { "param": "s1", "type": "int" }, { "param": "e1", "type": "int" }, { "param": "cm", "type": "int" }, { "param": "hm", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "s0", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "e0", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "s1", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "e1", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cm", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "hm", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba1d5cef869a2c59c0294c06ee4b58d5388d98c2
lofunz/mieme
Reloaded/trunk/src/mame/drivers/bnstars.c
[ "Unlicense" ]
C
draw_sprites
void
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT32 *sprram_top, size_t sprram_size, int region) { /*************************************************************************** Sprites Drawing Offset: Bits: Meaning: 0.w fedc ba98 ---- ---- ---- ---- 7654 ---- Priority ---- ---- ---- 3--- ---- ---- ---- -2-- Draw this sprite ---- ---- ---- --1- Flip Y ---- ---- ---- ---0 Flip X 1.w fedc ba98 ---- ---- Tile's Y position in the tile page (*) ---- ---- 7654 3210 Tile's X position in the tile page (*) 2.w fedc ---- ---- ---- Color ---- ba98 7654 3210 Tile Page (32x32 tiles = 256x256 pixels each) 3.w fedc ba98 ---- ---- Y Size - 1 (*) ---- ---- 7654 3210 X Size - 1 (*) 4.w fedc ba-- ---- ---- ---- --98 7654 3210 Y (Signed) 5.w fedc b--- ---- ---- ---- -a98 7654 3210 X (Signed) 6.w fedc ba98 7654 3210 Zoom Y 7.w fedc ba98 7654 3210 Zoom X (*) 1 pixel granularity ***************************************************************************/ int tx, ty, sx, sy, flipx, flipy; int xsize, ysize, xzoom, yzoom; int code, attr, color, size, pri, pri_mask; gfx_element *gfx = machine->gfx[region]; UINT32 *source = sprram_top; const UINT32 *finish = sprram_top + (sprram_size - 0x10) / 4; if (ms32_reverse_sprite_order == 1) { source = sprram_top + (sprram_size - 0x10) / 4; finish = sprram_top; } for (;ms32_reverse_sprite_order ? (source>=finish) : (source<finish); ms32_reverse_sprite_order ? (source-=4) : (source+=4)) { attr = source[ 0 ]; if ((attr & 0x0004) == 0) continue; flipx = attr & 1; flipy = attr & 2; pri = (attr >> 4)&0xf; code = source[ 1 ]; color = source[ 2 ]; tx = (code >> 0) & 0xff; ty = (code >> 8) & 0xff; code = (color & 0x0fff); color = (color >> 12) & 0xf; size = source[ 3 ]; xsize = ((size >> 0) & 0xff) + 1; ysize = ((size >> 8) & 0xff) + 1; sy = source[ 4 ]; sx = source[ 5 ]; sx = (sx & 0x3ff) - (sx & 0x400); sy = (sy & 0x1ff) - (sy & 0x200); xzoom = (source[ 6 ]&0xffff); yzoom = (source[ 7 ]&0xffff); if (!yzoom || !xzoom) continue; yzoom = 0x1000000/yzoom; xzoom = 0x1000000/xzoom; // there are surely also shadows (see gametngk) but how they're enabled we don't know if (flipscreen) { sx = 320 - ((xsize*xzoom)>>16) - sx; sy = 224 - ((ysize*yzoom)>>16) - sy; flipx = !flipx; flipy = !flipy; } /* TODO: priority handling is completely wrong, but better than nothing */ if (pri == 0x0) pri_mask = 0x00; else if (pri <= 0xd) pri_mask = 0xf0; else if (pri <= 0xe) pri_mask = 0xfc; else pri_mask = 0xfe; gfx_element_set_source_clip(gfx, tx, xsize, ty, ysize); pdrawgfxzoom_transpen(bitmap, cliprect, gfx, code, color, flipx, flipy, sx,sy, xzoom, yzoom, machine->priority_bitmap,pri_mask, 0); } /* end sprite loop */ }
/* SPRITES based on tetrisp2 for now, readd priority bits later */
SPRITES based on tetrisp2 for now, readd priority bits later
[ "SPRITES", "based", "on", "tetrisp2", "for", "now", "readd", "priority", "bits", "later" ]
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT32 *sprram_top, size_t sprram_size, int region) { int tx, ty, sx, sy, flipx, flipy; int xsize, ysize, xzoom, yzoom; int code, attr, color, size, pri, pri_mask; gfx_element *gfx = machine->gfx[region]; UINT32 *source = sprram_top; const UINT32 *finish = sprram_top + (sprram_size - 0x10) / 4; if (ms32_reverse_sprite_order == 1) { source = sprram_top + (sprram_size - 0x10) / 4; finish = sprram_top; } for (;ms32_reverse_sprite_order ? (source>=finish) : (source<finish); ms32_reverse_sprite_order ? (source-=4) : (source+=4)) { attr = source[ 0 ]; if ((attr & 0x0004) == 0) continue; flipx = attr & 1; flipy = attr & 2; pri = (attr >> 4)&0xf; code = source[ 1 ]; color = source[ 2 ]; tx = (code >> 0) & 0xff; ty = (code >> 8) & 0xff; code = (color & 0x0fff); color = (color >> 12) & 0xf; size = source[ 3 ]; xsize = ((size >> 0) & 0xff) + 1; ysize = ((size >> 8) & 0xff) + 1; sy = source[ 4 ]; sx = source[ 5 ]; sx = (sx & 0x3ff) - (sx & 0x400); sy = (sy & 0x1ff) - (sy & 0x200); xzoom = (source[ 6 ]&0xffff); yzoom = (source[ 7 ]&0xffff); if (!yzoom || !xzoom) continue; yzoom = 0x1000000/yzoom; xzoom = 0x1000000/xzoom; if (flipscreen) { sx = 320 - ((xsize*xzoom)>>16) - sx; sy = 224 - ((ysize*yzoom)>>16) - sy; flipx = !flipx; flipy = !flipy; } if (pri == 0x0) pri_mask = 0x00; else if (pri <= 0xd) pri_mask = 0xf0; else if (pri <= 0xe) pri_mask = 0xfc; else pri_mask = 0xfe; gfx_element_set_source_clip(gfx, tx, xsize, ty, ysize); pdrawgfxzoom_transpen(bitmap, cliprect, gfx, code, color, flipx, flipy, sx,sy, xzoom, yzoom, machine->priority_bitmap,pri_mask, 0); } }
[ "static", "void", "draw_sprites", "(", "running_machine", "*", "machine", ",", "bitmap_t", "*", "bitmap", ",", "const", "rectangle", "*", "cliprect", ",", "UINT32", "*", "sprram_top", ",", "size_t", "sprram_size", ",", "int", "region", ")", "{", "int", "tx", ",", "ty", ",", "sx", ",", "sy", ",", "flipx", ",", "flipy", ";", "int", "xsize", ",", "ysize", ",", "xzoom", ",", "yzoom", ";", "int", "code", ",", "attr", ",", "color", ",", "size", ",", "pri", ",", "pri_mask", ";", "gfx_element", "*", "gfx", "=", "machine", "->", "gfx", "[", "region", "]", ";", "UINT32", "*", "source", "=", "sprram_top", ";", "const", "UINT32", "*", "finish", "=", "sprram_top", "+", "(", "sprram_size", "-", "0x10", ")", "/", "4", ";", "if", "(", "ms32_reverse_sprite_order", "==", "1", ")", "{", "source", "=", "sprram_top", "+", "(", "sprram_size", "-", "0x10", ")", "/", "4", ";", "finish", "=", "sprram_top", ";", "}", "for", "(", ";", "ms32_reverse_sprite_order", "?", "(", "source", ">=", "finish", ")", ":", "(", "source", "<", "finish", ")", ";", "ms32_reverse_sprite_order", "?", "(", "source", "-=", "4", ")", ":", "(", "source", "+=", "4", ")", ")", "{", "attr", "=", "source", "[", "0", "]", ";", "if", "(", "(", "attr", "&", "0x0004", ")", "==", "0", ")", "continue", ";", "flipx", "=", "attr", "&", "1", ";", "flipy", "=", "attr", "&", "2", ";", "pri", "=", "(", "attr", ">>", "4", ")", "&", "0xf", ";", "code", "=", "source", "[", "1", "]", ";", "color", "=", "source", "[", "2", "]", ";", "tx", "=", "(", "code", ">>", "0", ")", "&", "0xff", ";", "ty", "=", "(", "code", ">>", "8", ")", "&", "0xff", ";", "code", "=", "(", "color", "&", "0x0fff", ")", ";", "color", "=", "(", "color", ">>", "12", ")", "&", "0xf", ";", "size", "=", "source", "[", "3", "]", ";", "xsize", "=", "(", "(", "size", ">>", "0", ")", "&", "0xff", ")", "+", "1", ";", "ysize", "=", "(", "(", "size", ">>", "8", ")", "&", "0xff", ")", "+", "1", ";", "sy", "=", "source", "[", "4", "]", ";", "sx", "=", "source", "[", "5", "]", ";", "sx", "=", "(", "sx", "&", "0x3ff", ")", "-", "(", "sx", "&", "0x400", ")", ";", "sy", "=", "(", "sy", "&", "0x1ff", ")", "-", "(", "sy", "&", "0x200", ")", ";", "xzoom", "=", "(", "source", "[", "6", "]", "&", "0xffff", ")", ";", "yzoom", "=", "(", "source", "[", "7", "]", "&", "0xffff", ")", ";", "if", "(", "!", "yzoom", "||", "!", "xzoom", ")", "continue", ";", "yzoom", "=", "0x1000000", "/", "yzoom", ";", "xzoom", "=", "0x1000000", "/", "xzoom", ";", "if", "(", "flipscreen", ")", "{", "sx", "=", "320", "-", "(", "(", "xsize", "*", "xzoom", ")", ">>", "16", ")", "-", "sx", ";", "sy", "=", "224", "-", "(", "(", "ysize", "*", "yzoom", ")", ">>", "16", ")", "-", "sy", ";", "flipx", "=", "!", "flipx", ";", "flipy", "=", "!", "flipy", ";", "}", "if", "(", "pri", "==", "0x0", ")", "pri_mask", "=", "0x00", ";", "else", "if", "(", "pri", "<=", "0xd", ")", "pri_mask", "=", "0xf0", ";", "else", "if", "(", "pri", "<=", "0xe", ")", "pri_mask", "=", "0xfc", ";", "else", "pri_mask", "=", "0xfe", ";", "gfx_element_set_source_clip", "(", "gfx", ",", "tx", ",", "xsize", ",", "ty", ",", "ysize", ")", ";", "pdrawgfxzoom_transpen", "(", "bitmap", ",", "cliprect", ",", "gfx", ",", "code", ",", "color", ",", "flipx", ",", "flipy", ",", "sx", ",", "sy", ",", "xzoom", ",", "yzoom", ",", "machine", "->", "priority_bitmap", ",", "pri_mask", ",", "0", ")", ";", "}", "}" ]
SPRITES based on tetrisp2 for now, readd priority bits later
[ "SPRITES", "based", "on", "tetrisp2", "for", "now", "readd", "priority", "bits", "later" ]
[ "/***************************************************************************\r\n\r\n\r\n Sprites Drawing\r\n\r\n Offset: Bits: Meaning:\r\n\r\n 0.w fedc ba98 ---- ----\r\n ---- ---- 7654 ---- Priority\r\n ---- ---- ---- 3---\r\n ---- ---- ---- -2-- Draw this sprite\r\n ---- ---- ---- --1- Flip Y\r\n ---- ---- ---- ---0 Flip X\r\n\r\n 1.w fedc ba98 ---- ---- Tile's Y position in the tile page (*)\r\n ---- ---- 7654 3210 Tile's X position in the tile page (*)\r\n\r\n 2.w fedc ---- ---- ---- Color\r\n ---- ba98 7654 3210 Tile Page (32x32 tiles = 256x256 pixels each)\r\n\r\n 3.w fedc ba98 ---- ---- Y Size - 1 (*)\r\n ---- ---- 7654 3210 X Size - 1 (*)\r\n\r\n 4.w fedc ba-- ---- ----\r\n ---- --98 7654 3210 Y (Signed)\r\n\r\n 5.w fedc b--- ---- ----\r\n ---- -a98 7654 3210 X (Signed)\r\n\r\n 6.w fedc ba98 7654 3210 Zoom Y\r\n\r\n 7.w fedc ba98 7654 3210 Zoom X\r\n\r\n(*) 1 pixel granularity\r\n\r\n***************************************************************************/", "// there are surely also shadows (see gametngk) but how they're enabled we don't know\r", "/* TODO: priority handling is completely wrong, but better than nothing */", "/* end sprite loop */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "bitmap", "type": "bitmap_t" }, { "param": "cliprect", "type": "rectangle" }, { "param": "sprram_top", "type": "UINT32" }, { "param": "sprram_size", "type": "size_t" }, { "param": "region", "type": "int" } ]
{ "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 }, { "identifier": "sprram_top", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sprram_size", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "region", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba7ee6877b54e2849359c6b55c2b32ede852c314
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/cps2crpt.c
[ "Unlicense" ]
C
expand_1st_key
void
static void expand_1st_key(UINT32 *dstkey, const UINT32 *srckey) { static const int bits[96] = { 33, 58, 49, 36, 0, 31, 22, 30, 3, 16, 5, 53, 10, 41, 23, 19, 27, 39, 43, 6, 34, 12, 61, 21, 48, 13, 32, 35, 6, 42, 43, 14, 21, 41, 52, 25, 18, 47, 46, 37, 57, 53, 20, 8, 55, 54, 59, 60, 27, 33, 35, 18, 8, 15, 63, 1, 50, 44, 16, 46, 5, 4, 45, 51, 38, 25, 13, 11, 62, 29, 48, 2, 59, 61, 62, 56, 51, 57, 54, 9, 24, 63, 22, 7, 26, 42, 45, 40, 23, 14, 2, 31, 52, 28, 44, 17, }; int i; dstkey[0] = 0; dstkey[1] = 0; dstkey[2] = 0; dstkey[3] = 0; for (i = 0; i < 96; ++i) dstkey[i / 24] |= BIT(srckey[bits[i] / 32], bits[i] % 32) << (i % 24); }
// srckey is the 64-bit master key (2x32 bits) // dstkey will contain the 96-bit key for the 1st FN (4x24 bits)
srckey is the 64-bit master key (2x32 bits) dstkey will contain the 96-bit key for the 1st FN (4x24 bits)
[ "srckey", "is", "the", "64", "-", "bit", "master", "key", "(", "2x32", "bits", ")", "dstkey", "will", "contain", "the", "96", "-", "bit", "key", "for", "the", "1st", "FN", "(", "4x24", "bits", ")" ]
static void expand_1st_key(UINT32 *dstkey, const UINT32 *srckey) { static const int bits[96] = { 33, 58, 49, 36, 0, 31, 22, 30, 3, 16, 5, 53, 10, 41, 23, 19, 27, 39, 43, 6, 34, 12, 61, 21, 48, 13, 32, 35, 6, 42, 43, 14, 21, 41, 52, 25, 18, 47, 46, 37, 57, 53, 20, 8, 55, 54, 59, 60, 27, 33, 35, 18, 8, 15, 63, 1, 50, 44, 16, 46, 5, 4, 45, 51, 38, 25, 13, 11, 62, 29, 48, 2, 59, 61, 62, 56, 51, 57, 54, 9, 24, 63, 22, 7, 26, 42, 45, 40, 23, 14, 2, 31, 52, 28, 44, 17, }; int i; dstkey[0] = 0; dstkey[1] = 0; dstkey[2] = 0; dstkey[3] = 0; for (i = 0; i < 96; ++i) dstkey[i / 24] |= BIT(srckey[bits[i] / 32], bits[i] % 32) << (i % 24); }
[ "static", "void", "expand_1st_key", "(", "UINT32", "*", "dstkey", ",", "const", "UINT32", "*", "srckey", ")", "{", "static", "const", "int", "bits", "[", "96", "]", "=", "{", "33", ",", "58", ",", "49", ",", "36", ",", "0", ",", "31", ",", "22", ",", "30", ",", "3", ",", "16", ",", "5", ",", "53", ",", "10", ",", "41", ",", "23", ",", "19", ",", "27", ",", "39", ",", "43", ",", "6", ",", "34", ",", "12", ",", "61", ",", "21", ",", "48", ",", "13", ",", "32", ",", "35", ",", "6", ",", "42", ",", "43", ",", "14", ",", "21", ",", "41", ",", "52", ",", "25", ",", "18", ",", "47", ",", "46", ",", "37", ",", "57", ",", "53", ",", "20", ",", "8", ",", "55", ",", "54", ",", "59", ",", "60", ",", "27", ",", "33", ",", "35", ",", "18", ",", "8", ",", "15", ",", "63", ",", "1", ",", "50", ",", "44", ",", "16", ",", "46", ",", "5", ",", "4", ",", "45", ",", "51", ",", "38", ",", "25", ",", "13", ",", "11", ",", "62", ",", "29", ",", "48", ",", "2", ",", "59", ",", "61", ",", "62", ",", "56", ",", "51", ",", "57", ",", "54", ",", "9", ",", "24", ",", "63", ",", "22", ",", "7", ",", "26", ",", "42", ",", "45", ",", "40", ",", "23", ",", "14", ",", "2", ",", "31", ",", "52", ",", "28", ",", "44", ",", "17", ",", "}", ";", "int", "i", ";", "dstkey", "[", "0", "]", "=", "0", ";", "dstkey", "[", "1", "]", "=", "0", ";", "dstkey", "[", "2", "]", "=", "0", ";", "dstkey", "[", "3", "]", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "96", ";", "++", "i", ")", "dstkey", "[", "i", "/", "24", "]", "|=", "BIT", "(", "srckey", "[", "bits", "[", "i", "]", "/", "32", "]", ",", "bits", "[", "i", "]", "%", "32", ")", "<<", "(", "i", "%", "24", ")", ";", "}" ]
srckey is the 64-bit master key (2x32 bits) dstkey will contain the 96-bit key for the 1st FN (4x24 bits)
[ "srckey", "is", "the", "64", "-", "bit", "master", "key", "(", "2x32", "bits", ")", "dstkey", "will", "contain", "the", "96", "-", "bit", "key", "for", "the", "1st", "FN", "(", "4x24", "bits", ")" ]
[]
[ { "param": "dstkey", "type": "UINT32" }, { "param": "srckey", "type": "UINT32" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dstkey", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "srckey", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba7ee6877b54e2849359c6b55c2b32ede852c314
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/cps2crpt.c
[ "Unlicense" ]
C
expand_2nd_key
void
static void expand_2nd_key(UINT32 *dstkey, const UINT32 *srckey) { static const int bits[96] = { 34, 9, 32, 24, 44, 54, 38, 61, 47, 13, 28, 7, 29, 58, 18, 1, 20, 60, 15, 6, 11, 43, 39, 19, 63, 23, 16, 62, 54, 40, 31, 3, 56, 61, 17, 25, 47, 38, 55, 57, 5, 4, 15, 42, 22, 7, 2, 19, 46, 37, 29, 39, 12, 30, 49, 57, 31, 41, 26, 27, 24, 36, 11, 63, 33, 16, 56, 62, 48, 60, 59, 32, 12, 30, 53, 48, 10, 0, 50, 35, 3, 59, 14, 49, 51, 45, 44, 2, 21, 33, 55, 52, 23, 28, 8, 26, }; int i; dstkey[0] = 0; dstkey[1] = 0; dstkey[2] = 0; dstkey[3] = 0; for (i = 0; i < 96; ++i) dstkey[i / 24] |= BIT(srckey[bits[i] / 32], bits[i] % 32) << (i % 24); }
// srckey is the 64-bit master key (2x32 bits) XORed with the subkey // dstkey will contain the 96-bit key for the 2nd FN (4x24 bits)
srckey is the 64-bit master key (2x32 bits) XORed with the subkey dstkey will contain the 96-bit key for the 2nd FN (4x24 bits)
[ "srckey", "is", "the", "64", "-", "bit", "master", "key", "(", "2x32", "bits", ")", "XORed", "with", "the", "subkey", "dstkey", "will", "contain", "the", "96", "-", "bit", "key", "for", "the", "2nd", "FN", "(", "4x24", "bits", ")" ]
static void expand_2nd_key(UINT32 *dstkey, const UINT32 *srckey) { static const int bits[96] = { 34, 9, 32, 24, 44, 54, 38, 61, 47, 13, 28, 7, 29, 58, 18, 1, 20, 60, 15, 6, 11, 43, 39, 19, 63, 23, 16, 62, 54, 40, 31, 3, 56, 61, 17, 25, 47, 38, 55, 57, 5, 4, 15, 42, 22, 7, 2, 19, 46, 37, 29, 39, 12, 30, 49, 57, 31, 41, 26, 27, 24, 36, 11, 63, 33, 16, 56, 62, 48, 60, 59, 32, 12, 30, 53, 48, 10, 0, 50, 35, 3, 59, 14, 49, 51, 45, 44, 2, 21, 33, 55, 52, 23, 28, 8, 26, }; int i; dstkey[0] = 0; dstkey[1] = 0; dstkey[2] = 0; dstkey[3] = 0; for (i = 0; i < 96; ++i) dstkey[i / 24] |= BIT(srckey[bits[i] / 32], bits[i] % 32) << (i % 24); }
[ "static", "void", "expand_2nd_key", "(", "UINT32", "*", "dstkey", ",", "const", "UINT32", "*", "srckey", ")", "{", "static", "const", "int", "bits", "[", "96", "]", "=", "{", "34", ",", "9", ",", "32", ",", "24", ",", "44", ",", "54", ",", "38", ",", "61", ",", "47", ",", "13", ",", "28", ",", "7", ",", "29", ",", "58", ",", "18", ",", "1", ",", "20", ",", "60", ",", "15", ",", "6", ",", "11", ",", "43", ",", "39", ",", "19", ",", "63", ",", "23", ",", "16", ",", "62", ",", "54", ",", "40", ",", "31", ",", "3", ",", "56", ",", "61", ",", "17", ",", "25", ",", "47", ",", "38", ",", "55", ",", "57", ",", "5", ",", "4", ",", "15", ",", "42", ",", "22", ",", "7", ",", "2", ",", "19", ",", "46", ",", "37", ",", "29", ",", "39", ",", "12", ",", "30", ",", "49", ",", "57", ",", "31", ",", "41", ",", "26", ",", "27", ",", "24", ",", "36", ",", "11", ",", "63", ",", "33", ",", "16", ",", "56", ",", "62", ",", "48", ",", "60", ",", "59", ",", "32", ",", "12", ",", "30", ",", "53", ",", "48", ",", "10", ",", "0", ",", "50", ",", "35", ",", "3", ",", "59", ",", "14", ",", "49", ",", "51", ",", "45", ",", "44", ",", "2", ",", "21", ",", "33", ",", "55", ",", "52", ",", "23", ",", "28", ",", "8", ",", "26", ",", "}", ";", "int", "i", ";", "dstkey", "[", "0", "]", "=", "0", ";", "dstkey", "[", "1", "]", "=", "0", ";", "dstkey", "[", "2", "]", "=", "0", ";", "dstkey", "[", "3", "]", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "96", ";", "++", "i", ")", "dstkey", "[", "i", "/", "24", "]", "|=", "BIT", "(", "srckey", "[", "bits", "[", "i", "]", "/", "32", "]", ",", "bits", "[", "i", "]", "%", "32", ")", "<<", "(", "i", "%", "24", ")", ";", "}" ]
srckey is the 64-bit master key (2x32 bits) XORed with the subkey dstkey will contain the 96-bit key for the 2nd FN (4x24 bits)
[ "srckey", "is", "the", "64", "-", "bit", "master", "key", "(", "2x32", "bits", ")", "XORed", "with", "the", "subkey", "dstkey", "will", "contain", "the", "96", "-", "bit", "key", "for", "the", "2nd", "FN", "(", "4x24", "bits", ")" ]
[]
[ { "param": "dstkey", "type": "UINT32" }, { "param": "srckey", "type": "UINT32" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dstkey", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "srckey", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba7ee6877b54e2849359c6b55c2b32ede852c314
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/cps2crpt.c
[ "Unlicense" ]
C
expand_subkey
void
static void expand_subkey(UINT32* subkey, UINT16 seed) { // Note that each row of the table is a permutation of the seed bits. static const int bits[64] = { 5, 10, 14, 9, 4, 0, 15, 6, 1, 8, 3, 2, 12, 7, 13, 11, 5, 12, 7, 2, 13, 11, 9, 14, 4, 1, 6, 10, 8, 0, 15, 3, 4, 10, 2, 0, 6, 9, 12, 1, 11, 7, 15, 8, 13, 5, 14, 3, 14, 11, 12, 7, 4, 5, 2, 10, 1, 15, 0, 9, 8, 6, 13, 3, }; int i; subkey[0] = 0; subkey[1] = 0; for (i = 0; i < 64; ++i) subkey[i / 32] |= BIT(seed, bits[i]) << (i % 32); }
// seed is the 16-bit seed generated by the first FN // subkey will contain the 64-bit key to be XORed with the master key // for the 2nd FN (2x32 bits)
seed is the 16-bit seed generated by the first FN subkey will contain the 64-bit key to be XORed with the master key for the 2nd FN (2x32 bits)
[ "seed", "is", "the", "16", "-", "bit", "seed", "generated", "by", "the", "first", "FN", "subkey", "will", "contain", "the", "64", "-", "bit", "key", "to", "be", "XORed", "with", "the", "master", "key", "for", "the", "2nd", "FN", "(", "2x32", "bits", ")" ]
static void expand_subkey(UINT32* subkey, UINT16 seed) { static const int bits[64] = { 5, 10, 14, 9, 4, 0, 15, 6, 1, 8, 3, 2, 12, 7, 13, 11, 5, 12, 7, 2, 13, 11, 9, 14, 4, 1, 6, 10, 8, 0, 15, 3, 4, 10, 2, 0, 6, 9, 12, 1, 11, 7, 15, 8, 13, 5, 14, 3, 14, 11, 12, 7, 4, 5, 2, 10, 1, 15, 0, 9, 8, 6, 13, 3, }; int i; subkey[0] = 0; subkey[1] = 0; for (i = 0; i < 64; ++i) subkey[i / 32] |= BIT(seed, bits[i]) << (i % 32); }
[ "static", "void", "expand_subkey", "(", "UINT32", "*", "subkey", ",", "UINT16", "seed", ")", "{", "static", "const", "int", "bits", "[", "64", "]", "=", "{", "5", ",", "10", ",", "14", ",", "9", ",", "4", ",", "0", ",", "15", ",", "6", ",", "1", ",", "8", ",", "3", ",", "2", ",", "12", ",", "7", ",", "13", ",", "11", ",", "5", ",", "12", ",", "7", ",", "2", ",", "13", ",", "11", ",", "9", ",", "14", ",", "4", ",", "1", ",", "6", ",", "10", ",", "8", ",", "0", ",", "15", ",", "3", ",", "4", ",", "10", ",", "2", ",", "0", ",", "6", ",", "9", ",", "12", ",", "1", ",", "11", ",", "7", ",", "15", ",", "8", ",", "13", ",", "5", ",", "14", ",", "3", ",", "14", ",", "11", ",", "12", ",", "7", ",", "4", ",", "5", ",", "2", ",", "10", ",", "1", ",", "15", ",", "0", ",", "9", ",", "8", ",", "6", ",", "13", ",", "3", ",", "}", ";", "int", "i", ";", "subkey", "[", "0", "]", "=", "0", ";", "subkey", "[", "1", "]", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "64", ";", "++", "i", ")", "subkey", "[", "i", "/", "32", "]", "|=", "BIT", "(", "seed", ",", "bits", "[", "i", "]", ")", "<<", "(", "i", "%", "32", ")", ";", "}" ]
seed is the 16-bit seed generated by the first FN subkey will contain the 64-bit key to be XORed with the master key for the 2nd FN (2x32 bits)
[ "seed", "is", "the", "16", "-", "bit", "seed", "generated", "by", "the", "first", "FN", "subkey", "will", "contain", "the", "64", "-", "bit", "key", "to", "be", "XORed", "with", "the", "master", "key", "for", "the", "2nd", "FN", "(", "2x32", "bits", ")" ]
[ "// Note that each row of the table is a permutation of the seed bits." ]
[ { "param": "subkey", "type": "UINT32" }, { "param": "seed", "type": "UINT16" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "subkey", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "seed", "type": "UINT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba923ea19cfb1caf82a22519420a572193a65ded
lofunz/mieme
Reloaded/trunk/src/mame/machine/seibuspi.c
[ "Unlicense" ]
C
partial_carry_sum
UINT32
static UINT32 partial_carry_sum(UINT32 add1,UINT32 add2,UINT32 carry_mask,int bits) { int i,res,carry; res = 0; carry = 0; for (i = 0;i < bits;i++) { int bit = BIT(add1,i) + BIT(add2,i) + carry; res += (bit & 1) << i; // generate carry only if the corresponding bit in carry_mask is 1 if (BIT(carry_mask,i)) carry = bit >> 1; else carry = 0; } // wrap around carry from top bit to bit 0 if (carry) res ^=1; return res; }
// add two numbers generating carry from one bit to the next only if // the corresponding bit in carry_mask is 1
add two numbers generating carry from one bit to the next only if the corresponding bit in carry_mask is 1
[ "add", "two", "numbers", "generating", "carry", "from", "one", "bit", "to", "the", "next", "only", "if", "the", "corresponding", "bit", "in", "carry_mask", "is", "1" ]
static UINT32 partial_carry_sum(UINT32 add1,UINT32 add2,UINT32 carry_mask,int bits) { int i,res,carry; res = 0; carry = 0; for (i = 0;i < bits;i++) { int bit = BIT(add1,i) + BIT(add2,i) + carry; res += (bit & 1) << i; if (BIT(carry_mask,i)) carry = bit >> 1; else carry = 0; } if (carry) res ^=1; return res; }
[ "static", "UINT32", "partial_carry_sum", "(", "UINT32", "add1", ",", "UINT32", "add2", ",", "UINT32", "carry_mask", ",", "int", "bits", ")", "{", "int", "i", ",", "res", ",", "carry", ";", "res", "=", "0", ";", "carry", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "bits", ";", "i", "++", ")", "{", "int", "bit", "=", "BIT", "(", "add1", ",", "i", ")", "+", "BIT", "(", "add2", ",", "i", ")", "+", "carry", ";", "res", "+=", "(", "bit", "&", "1", ")", "<<", "i", ";", "if", "(", "BIT", "(", "carry_mask", ",", "i", ")", ")", "carry", "=", "bit", ">>", "1", ";", "else", "carry", "=", "0", ";", "}", "if", "(", "carry", ")", "res", "^=", "1", ";", "return", "res", ";", "}" ]
add two numbers generating carry from one bit to the next only if the corresponding bit in carry_mask is 1
[ "add", "two", "numbers", "generating", "carry", "from", "one", "bit", "to", "the", "next", "only", "if", "the", "corresponding", "bit", "in", "carry_mask", "is", "1" ]
[ "// generate carry only if the corresponding bit in carry_mask is 1\r", "// wrap around carry from top bit to bit 0\r" ]
[ { "param": "add1", "type": "UINT32" }, { "param": "add2", "type": "UINT32" }, { "param": "carry_mask", "type": "UINT32" }, { "param": "bits", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "add1", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "add2", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "carry_mask", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bits", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ed2c81f5d008f3b7a3154f6dc0dbbc7551ca83c5
lofunz/mieme
Reloaded/trunk/src/emu/driver.c
[ "Unlicense" ]
C
driver_get_name
game_driver
const game_driver *driver_get_name(const char *name) { int lurnum, drvnum; /* scan the LRU list first */ for (lurnum = 0; lurnum < DRIVER_LRU_SIZE; lurnum++) if (mame_stricmp(drivers[driver_lru[lurnum]]->name, name) == 0) { /* if not first, swap with the head */ if (lurnum != 0) { int temp = driver_lru[0]; driver_lru[0] = driver_lru[lurnum]; driver_lru[lurnum] = temp; } return drivers[driver_lru[0]]; } /* scan for a match in the drivers -- slow! */ for (drvnum = 0; drivers[drvnum] != NULL; drvnum++) if (mame_stricmp(drivers[drvnum]->name, name) == 0) { memmove((void *)&driver_lru[1], (void *)&driver_lru[0], sizeof(driver_lru[0]) * (DRIVER_LRU_SIZE - 1)); driver_lru[0] = drvnum; return drivers[drvnum]; } return NULL; }
/*------------------------------------------------- driver_get_name - return a pointer to a driver given its name -------------------------------------------------*/
return a pointer to a driver given its name
[ "return", "a", "pointer", "to", "a", "driver", "given", "its", "name" ]
const game_driver *driver_get_name(const char *name) { int lurnum, drvnum; for (lurnum = 0; lurnum < DRIVER_LRU_SIZE; lurnum++) if (mame_stricmp(drivers[driver_lru[lurnum]]->name, name) == 0) { if (lurnum != 0) { int temp = driver_lru[0]; driver_lru[0] = driver_lru[lurnum]; driver_lru[lurnum] = temp; } return drivers[driver_lru[0]]; } for (drvnum = 0; drivers[drvnum] != NULL; drvnum++) if (mame_stricmp(drivers[drvnum]->name, name) == 0) { memmove((void *)&driver_lru[1], (void *)&driver_lru[0], sizeof(driver_lru[0]) * (DRIVER_LRU_SIZE - 1)); driver_lru[0] = drvnum; return drivers[drvnum]; } return NULL; }
[ "const", "game_driver", "*", "driver_get_name", "(", "const", "char", "*", "name", ")", "{", "int", "lurnum", ",", "drvnum", ";", "for", "(", "lurnum", "=", "0", ";", "lurnum", "<", "DRIVER_LRU_SIZE", ";", "lurnum", "++", ")", "if", "(", "mame_stricmp", "(", "drivers", "[", "driver_lru", "[", "lurnum", "]", "]", "->", "name", ",", "name", ")", "==", "0", ")", "{", "if", "(", "lurnum", "!=", "0", ")", "{", "int", "temp", "=", "driver_lru", "[", "0", "]", ";", "driver_lru", "[", "0", "]", "=", "driver_lru", "[", "lurnum", "]", ";", "driver_lru", "[", "lurnum", "]", "=", "temp", ";", "}", "return", "drivers", "[", "driver_lru", "[", "0", "]", "]", ";", "}", "for", "(", "drvnum", "=", "0", ";", "drivers", "[", "drvnum", "]", "!=", "NULL", ";", "drvnum", "++", ")", "if", "(", "mame_stricmp", "(", "drivers", "[", "drvnum", "]", "->", "name", ",", "name", ")", "==", "0", ")", "{", "memmove", "(", "(", "void", "*", ")", "&", "driver_lru", "[", "1", "]", ",", "(", "void", "*", ")", "&", "driver_lru", "[", "0", "]", ",", "sizeof", "(", "driver_lru", "[", "0", "]", ")", "*", "(", "DRIVER_LRU_SIZE", "-", "1", ")", ")", ";", "driver_lru", "[", "0", "]", "=", "drvnum", ";", "return", "drivers", "[", "drvnum", "]", ";", "}", "return", "NULL", ";", "}" ]
driver_get_name - return a pointer to a driver given its name
[ "driver_get_name", "-", "return", "a", "pointer", "to", "a", "driver", "given", "its", "name" ]
[ "/* scan the LRU list first */", "/* if not first, swap with the head */", "/* scan for a match in the drivers -- slow! */" ]
[ { "param": "name", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "name", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ed2c81f5d008f3b7a3154f6dc0dbbc7551ca83c5
lofunz/mieme
Reloaded/trunk/src/emu/driver.c
[ "Unlicense" ]
C
driver_get_clone
game_driver
const game_driver *driver_get_clone(const game_driver *driver) { /* if no clone, easy out */ if (driver->parent == NULL || (driver->parent[0] == '0' && driver->parent[1] == 0)) return NULL; /* convert the name to a game_driver */ return driver_get_name(driver->parent); }
/*------------------------------------------------- driver_get_clone - return a pointer to the clone of a game driver. -------------------------------------------------*/
return a pointer to the clone of a game driver.
[ "return", "a", "pointer", "to", "the", "clone", "of", "a", "game", "driver", "." ]
const game_driver *driver_get_clone(const game_driver *driver) { if (driver->parent == NULL || (driver->parent[0] == '0' && driver->parent[1] == 0)) return NULL; return driver_get_name(driver->parent); }
[ "const", "game_driver", "*", "driver_get_clone", "(", "const", "game_driver", "*", "driver", ")", "{", "if", "(", "driver", "->", "parent", "==", "NULL", "||", "(", "driver", "->", "parent", "[", "0", "]", "==", "'", "'", "&&", "driver", "->", "parent", "[", "1", "]", "==", "0", ")", ")", "return", "NULL", ";", "return", "driver_get_name", "(", "driver", "->", "parent", ")", ";", "}" ]
driver_get_clone - return a pointer to the clone of a game driver.
[ "driver_get_clone", "-", "return", "a", "pointer", "to", "the", "clone", "of", "a", "game", "driver", "." ]
[ "/* if no clone, easy out */", "/* convert the name to a game_driver */" ]
[ { "param": "driver", "type": "game_driver" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "driver", "type": "game_driver", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ed2c81f5d008f3b7a3154f6dc0dbbc7551ca83c5
lofunz/mieme
Reloaded/trunk/src/emu/driver.c
[ "Unlicense" ]
C
penalty_compare
int
static int penalty_compare(const char *source, const char *target) { int gaps = 1; int last = TRUE; /* scan the strings */ for ( ; *source && *target; target++) { /* do a case insensitive match */ int match = (tolower((UINT8)*source) == tolower((UINT8)*target)); /* if we matched, advance the source */ if (match) source++; /* if the match state changed, count gaps */ if (match != last) { last = match; if (!match) gaps++; } } /* penalty if short string does not completely fit in */ for ( ; *source; source++) gaps++; /* if we matched perfectly, gaps == 0 */ if (gaps == 1 && *source == 0 && *target == 0) gaps = 0; return gaps; }
/*------------------------------------------------- penalty_compare - compare two strings for closeness and assign a score. -------------------------------------------------*/
compare two strings for closeness and assign a score.
[ "compare", "two", "strings", "for", "closeness", "and", "assign", "a", "score", "." ]
static int penalty_compare(const char *source, const char *target) { int gaps = 1; int last = TRUE; for ( ; *source && *target; target++) { int match = (tolower((UINT8)*source) == tolower((UINT8)*target)); if (match) source++; if (match != last) { last = match; if (!match) gaps++; } } for ( ; *source; source++) gaps++; if (gaps == 1 && *source == 0 && *target == 0) gaps = 0; return gaps; }
[ "static", "int", "penalty_compare", "(", "const", "char", "*", "source", ",", "const", "char", "*", "target", ")", "{", "int", "gaps", "=", "1", ";", "int", "last", "=", "TRUE", ";", "for", "(", ";", "*", "source", "&&", "*", "target", ";", "target", "++", ")", "{", "int", "match", "=", "(", "tolower", "(", "(", "UINT8", ")", "*", "source", ")", "==", "tolower", "(", "(", "UINT8", ")", "*", "target", ")", ")", ";", "if", "(", "match", ")", "source", "++", ";", "if", "(", "match", "!=", "last", ")", "{", "last", "=", "match", ";", "if", "(", "!", "match", ")", "gaps", "++", ";", "}", "}", "for", "(", ";", "*", "source", ";", "source", "++", ")", "gaps", "++", ";", "if", "(", "gaps", "==", "1", "&&", "*", "source", "==", "0", "&&", "*", "target", "==", "0", ")", "gaps", "=", "0", ";", "return", "gaps", ";", "}" ]
penalty_compare - compare two strings for closeness and assign a score.
[ "penalty_compare", "-", "compare", "two", "strings", "for", "closeness", "and", "assign", "a", "score", "." ]
[ "/* scan the strings */", "/* do a case insensitive match */", "/* if we matched, advance the source */", "/* if the match state changed, count gaps */", "/* penalty if short string does not completely fit in */", "/* if we matched perfectly, gaps == 0 */" ]
[ { "param": "source", "type": "char" }, { "param": "target", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "source", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "target", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ed2c81f5d008f3b7a3154f6dc0dbbc7551ca83c5
lofunz/mieme
Reloaded/trunk/src/emu/driver.c
[ "Unlicense" ]
C
driver_get_compatible
game_driver
const game_driver *driver_get_compatible(const game_driver *drv) { if (driver_get_clone(drv)) drv = driver_get_clone(drv); else if (drv->compatible_with) drv = driver_get_name(drv->compatible_with); else drv = NULL; return drv; }
/*------------------------------------------------- driver_get_compatible - return a pointer to the compatible driver. -------------------------------------------------*/
return a pointer to the compatible driver.
[ "return", "a", "pointer", "to", "the", "compatible", "driver", "." ]
const game_driver *driver_get_compatible(const game_driver *drv) { if (driver_get_clone(drv)) drv = driver_get_clone(drv); else if (drv->compatible_with) drv = driver_get_name(drv->compatible_with); else drv = NULL; return drv; }
[ "const", "game_driver", "*", "driver_get_compatible", "(", "const", "game_driver", "*", "drv", ")", "{", "if", "(", "driver_get_clone", "(", "drv", ")", ")", "drv", "=", "driver_get_clone", "(", "drv", ")", ";", "else", "if", "(", "drv", "->", "compatible_with", ")", "drv", "=", "driver_get_name", "(", "drv", "->", "compatible_with", ")", ";", "else", "drv", "=", "NULL", ";", "return", "drv", ";", "}" ]
driver_get_compatible - return a pointer to the compatible driver.
[ "driver_get_compatible", "-", "return", "a", "pointer", "to", "the", "compatible", "driver", "." ]
[]
[ { "param": "drv", "type": "game_driver" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "drv", "type": "game_driver", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
816986152a835d29137b3ff290efe47048d3ffda
lofunz/mieme
Reloaded/trunk/src/emu/machine/ldcore.c
[ "Unlicense" ]
C
update_slider_pos
void
static void update_slider_pos(ldcore_data *ldcore, attotime curtime) { /* if not moving, update to now */ if (ldcore->attospertrack == 0) ldcore->sliderupdate = curtime; /* otherwise, compute the number of tracks covered */ else { attoseconds_t delta = attotime_to_attoseconds(attotime_sub(curtime, ldcore->sliderupdate)); INT32 tracks_covered; /* determine how many tracks we covered and advance */ if (ldcore->attospertrack >= 0) { tracks_covered = delta / ldcore->attospertrack; add_and_clamp_track(ldcore, tracks_covered); if (tracks_covered != 0) ldcore->sliderupdate = attotime_add_attoseconds(ldcore->sliderupdate, tracks_covered * ldcore->attospertrack); } else { tracks_covered = delta / -ldcore->attospertrack; add_and_clamp_track(ldcore, -tracks_covered); if (tracks_covered != 0) ldcore->sliderupdate = attotime_add_attoseconds(ldcore->sliderupdate, tracks_covered * -ldcore->attospertrack); } } }
/*------------------------------------------------- update_slider_pos - based on the current speed and elapsed time, update the current track position -------------------------------------------------*/
based on the current speed and elapsed time, update the current track position
[ "based", "on", "the", "current", "speed", "and", "elapsed", "time", "update", "the", "current", "track", "position" ]
static void update_slider_pos(ldcore_data *ldcore, attotime curtime) { if (ldcore->attospertrack == 0) ldcore->sliderupdate = curtime; else { attoseconds_t delta = attotime_to_attoseconds(attotime_sub(curtime, ldcore->sliderupdate)); INT32 tracks_covered; if (ldcore->attospertrack >= 0) { tracks_covered = delta / ldcore->attospertrack; add_and_clamp_track(ldcore, tracks_covered); if (tracks_covered != 0) ldcore->sliderupdate = attotime_add_attoseconds(ldcore->sliderupdate, tracks_covered * ldcore->attospertrack); } else { tracks_covered = delta / -ldcore->attospertrack; add_and_clamp_track(ldcore, -tracks_covered); if (tracks_covered != 0) ldcore->sliderupdate = attotime_add_attoseconds(ldcore->sliderupdate, tracks_covered * -ldcore->attospertrack); } } }
[ "static", "void", "update_slider_pos", "(", "ldcore_data", "*", "ldcore", ",", "attotime", "curtime", ")", "{", "if", "(", "ldcore", "->", "attospertrack", "==", "0", ")", "ldcore", "->", "sliderupdate", "=", "curtime", ";", "else", "{", "attoseconds_t", "delta", "=", "attotime_to_attoseconds", "(", "attotime_sub", "(", "curtime", ",", "ldcore", "->", "sliderupdate", ")", ")", ";", "INT32", "tracks_covered", ";", "if", "(", "ldcore", "->", "attospertrack", ">=", "0", ")", "{", "tracks_covered", "=", "delta", "/", "ldcore", "->", "attospertrack", ";", "add_and_clamp_track", "(", "ldcore", ",", "tracks_covered", ")", ";", "if", "(", "tracks_covered", "!=", "0", ")", "ldcore", "->", "sliderupdate", "=", "attotime_add_attoseconds", "(", "ldcore", "->", "sliderupdate", ",", "tracks_covered", "*", "ldcore", "->", "attospertrack", ")", ";", "}", "else", "{", "tracks_covered", "=", "delta", "/", "-", "ldcore", "->", "attospertrack", ";", "add_and_clamp_track", "(", "ldcore", ",", "-", "tracks_covered", ")", ";", "if", "(", "tracks_covered", "!=", "0", ")", "ldcore", "->", "sliderupdate", "=", "attotime_add_attoseconds", "(", "ldcore", "->", "sliderupdate", ",", "tracks_covered", "*", "-", "ldcore", "->", "attospertrack", ")", ";", "}", "}", "}" ]
update_slider_pos - based on the current speed and elapsed time, update the current track position
[ "update_slider_pos", "-", "based", "on", "the", "current", "speed", "and", "elapsed", "time", "update", "the", "current", "track", "position" ]
[ "/* if not moving, update to now */", "/* otherwise, compute the number of tracks covered */", "/* determine how many tracks we covered and advance */" ]
[ { "param": "ldcore", "type": "ldcore_data" }, { "param": "curtime", "type": "attotime" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ldcore", "type": "ldcore_data", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "curtime", "type": "attotime", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
816986152a835d29137b3ff290efe47048d3ffda
lofunz/mieme
Reloaded/trunk/src/emu/machine/ldcore.c
[ "Unlicense" ]
C
laserdisc_data_w
void
void laserdisc_data_w(running_device *device, UINT8 data) { laserdisc_state *ld = get_safe_token(device); ldcore_data *ldcore = ld->core; UINT8 prev = ldcore->datain; ldcore->datain = data; /* call through to the player-specific write handler */ if (ldcore->intf.writedata != NULL) (*ldcore->intf.writedata)(ld, prev, data); }
/*------------------------------------------------- laserdisc_data_w - write data to the given laserdisc player -------------------------------------------------*/
write data to the given laserdisc player
[ "write", "data", "to", "the", "given", "laserdisc", "player" ]
void laserdisc_data_w(running_device *device, UINT8 data) { laserdisc_state *ld = get_safe_token(device); ldcore_data *ldcore = ld->core; UINT8 prev = ldcore->datain; ldcore->datain = data; if (ldcore->intf.writedata != NULL) (*ldcore->intf.writedata)(ld, prev, data); }
[ "void", "laserdisc_data_w", "(", "running_device", "*", "device", ",", "UINT8", "data", ")", "{", "laserdisc_state", "*", "ld", "=", "get_safe_token", "(", "device", ")", ";", "ldcore_data", "*", "ldcore", "=", "ld", "->", "core", ";", "UINT8", "prev", "=", "ldcore", "->", "datain", ";", "ldcore", "->", "datain", "=", "data", ";", "if", "(", "ldcore", "->", "intf", ".", "writedata", "!=", "NULL", ")", "(", "*", "ldcore", "->", "intf", ".", "writedata", ")", "(", "ld", ",", "prev", ",", "data", ")", ";", "}" ]
laserdisc_data_w - write data to the given laserdisc player
[ "laserdisc_data_w", "-", "write", "data", "to", "the", "given", "laserdisc", "player" ]
[ "/* call through to the player-specific write handler */" ]
[ { "param": "device", "type": "running_device" }, { "param": "data", "type": "UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "device", "type": "running_device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
816986152a835d29137b3ff290efe47048d3ffda
lofunz/mieme
Reloaded/trunk/src/emu/machine/ldcore.c
[ "Unlicense" ]
C
laserdisc_line_r
UINT8
UINT8 laserdisc_line_r(running_device *device, UINT8 line) { laserdisc_state *ld = get_safe_token(device); ldcore_data *ldcore = ld->core; UINT8 result; assert(line < LASERDISC_OUTPUT_LINES); result = ldcore->lineout[line]; /* call through to the player-specific data handler */ if (ldcore->intf.readline[line] != NULL) result = (*ldcore->intf.readline[line])(ld); return result; }
/*------------------------------------------------- laserdisc_line_r - return the current state of an output line -------------------------------------------------*/
return the current state of an output line
[ "return", "the", "current", "state", "of", "an", "output", "line" ]
UINT8 laserdisc_line_r(running_device *device, UINT8 line) { laserdisc_state *ld = get_safe_token(device); ldcore_data *ldcore = ld->core; UINT8 result; assert(line < LASERDISC_OUTPUT_LINES); result = ldcore->lineout[line]; if (ldcore->intf.readline[line] != NULL) result = (*ldcore->intf.readline[line])(ld); return result; }
[ "UINT8", "laserdisc_line_r", "(", "running_device", "*", "device", ",", "UINT8", "line", ")", "{", "laserdisc_state", "*", "ld", "=", "get_safe_token", "(", "device", ")", ";", "ldcore_data", "*", "ldcore", "=", "ld", "->", "core", ";", "UINT8", "result", ";", "assert", "(", "line", "<", "LASERDISC_OUTPUT_LINES", ")", ";", "result", "=", "ldcore", "->", "lineout", "[", "line", "]", ";", "if", "(", "ldcore", "->", "intf", ".", "readline", "[", "line", "]", "!=", "NULL", ")", "result", "=", "(", "*", "ldcore", "->", "intf", ".", "readline", "[", "line", "]", ")", "(", "ld", ")", ";", "return", "result", ";", "}" ]
laserdisc_line_r - return the current state of an output line
[ "laserdisc_line_r", "-", "return", "the", "current", "state", "of", "an", "output", "line" ]
[ "/* call through to the player-specific data handler */" ]
[ { "param": "device", "type": "running_device" }, { "param": "line", "type": "UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "device", "type": "running_device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "line", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
816986152a835d29137b3ff290efe47048d3ffda
lofunz/mieme
Reloaded/trunk/src/emu/machine/ldcore.c
[ "Unlicense" ]
C
laserdisc_get_video
int
int laserdisc_get_video(running_device *device, bitmap_t **bitmap) { laserdisc_state *ld = get_safe_token(device); ldcore_data *ldcore = ld->core; frame_data *frame; /* determine the most recent live set of frames */ frame = &ldcore->frame[ldcore->videoindex]; if (frame->numfields < 2) frame = &ldcore->frame[(ldcore->videoindex + ARRAY_LENGTH(ldcore->frame) - 1) % ARRAY_LENGTH(ldcore->frame)]; /* if no video present, return the empty frame */ if (ldcore->videosquelch || frame->numfields < 2) { *bitmap = ldcore->emptyframe; return FALSE; } else { *bitmap = frame->visbitmap; return TRUE; } }
/*------------------------------------------------- laserdisc_get_video - return the current video frame; return TRUE if valid or FALSE if video off -------------------------------------------------*/
return the current video frame; return TRUE if valid or FALSE if video off
[ "return", "the", "current", "video", "frame", ";", "return", "TRUE", "if", "valid", "or", "FALSE", "if", "video", "off" ]
int laserdisc_get_video(running_device *device, bitmap_t **bitmap) { laserdisc_state *ld = get_safe_token(device); ldcore_data *ldcore = ld->core; frame_data *frame; frame = &ldcore->frame[ldcore->videoindex]; if (frame->numfields < 2) frame = &ldcore->frame[(ldcore->videoindex + ARRAY_LENGTH(ldcore->frame) - 1) % ARRAY_LENGTH(ldcore->frame)]; if (ldcore->videosquelch || frame->numfields < 2) { *bitmap = ldcore->emptyframe; return FALSE; } else { *bitmap = frame->visbitmap; return TRUE; } }
[ "int", "laserdisc_get_video", "(", "running_device", "*", "device", ",", "bitmap_t", "*", "*", "bitmap", ")", "{", "laserdisc_state", "*", "ld", "=", "get_safe_token", "(", "device", ")", ";", "ldcore_data", "*", "ldcore", "=", "ld", "->", "core", ";", "frame_data", "*", "frame", ";", "frame", "=", "&", "ldcore", "->", "frame", "[", "ldcore", "->", "videoindex", "]", ";", "if", "(", "frame", "->", "numfields", "<", "2", ")", "frame", "=", "&", "ldcore", "->", "frame", "[", "(", "ldcore", "->", "videoindex", "+", "ARRAY_LENGTH", "(", "ldcore", "->", "frame", ")", "-", "1", ")", "%", "ARRAY_LENGTH", "(", "ldcore", "->", "frame", ")", "]", ";", "if", "(", "ldcore", "->", "videosquelch", "||", "frame", "->", "numfields", "<", "2", ")", "{", "*", "bitmap", "=", "ldcore", "->", "emptyframe", ";", "return", "FALSE", ";", "}", "else", "{", "*", "bitmap", "=", "frame", "->", "visbitmap", ";", "return", "TRUE", ";", "}", "}" ]
laserdisc_get_video - return the current video frame; return TRUE if valid or FALSE if video off
[ "laserdisc_get_video", "-", "return", "the", "current", "video", "frame", ";", "return", "TRUE", "if", "valid", "or", "FALSE", "if", "video", "off" ]
[ "/* determine the most recent live set of frames */", "/* if no video present, return the empty frame */" ]
[ { "param": "device", "type": "running_device" }, { "param": "bitmap", "type": "bitmap_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "device", "type": "running_device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bitmap", "type": "bitmap_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
816986152a835d29137b3ff290efe47048d3ffda
lofunz/mieme
Reloaded/trunk/src/emu/machine/ldcore.c
[ "Unlicense" ]
C
laserdisc_get_field_code
UINT32
UINT32 laserdisc_get_field_code(running_device *device, UINT32 code, UINT8 zero_if_squelched) { laserdisc_state *ld = get_safe_token(device); ldcore_data *ldcore = ld->core; int field = ldcore->fieldnum; /* return nothing if the video is off (external devices can't sense) */ if (zero_if_squelched && ldcore->videosquelch) return 0; switch (code) { case LASERDISC_CODE_WHITE_FLAG: return ldcore->metadata[field].white; case LASERDISC_CODE_LINE16: return ldcore->metadata[field].line16; case LASERDISC_CODE_LINE17: return ldcore->metadata[field].line17; case LASERDISC_CODE_LINE18: return ldcore->metadata[field].line18; case LASERDISC_CODE_LINE1718: return ldcore->metadata[field].line1718; } return 0; }
/*------------------------------------------------- laserdisc_get_field_code - return raw field information read from the disc -------------------------------------------------*/
return raw field information read from the disc
[ "return", "raw", "field", "information", "read", "from", "the", "disc" ]
UINT32 laserdisc_get_field_code(running_device *device, UINT32 code, UINT8 zero_if_squelched) { laserdisc_state *ld = get_safe_token(device); ldcore_data *ldcore = ld->core; int field = ldcore->fieldnum; if (zero_if_squelched && ldcore->videosquelch) return 0; switch (code) { case LASERDISC_CODE_WHITE_FLAG: return ldcore->metadata[field].white; case LASERDISC_CODE_LINE16: return ldcore->metadata[field].line16; case LASERDISC_CODE_LINE17: return ldcore->metadata[field].line17; case LASERDISC_CODE_LINE18: return ldcore->metadata[field].line18; case LASERDISC_CODE_LINE1718: return ldcore->metadata[field].line1718; } return 0; }
[ "UINT32", "laserdisc_get_field_code", "(", "running_device", "*", "device", ",", "UINT32", "code", ",", "UINT8", "zero_if_squelched", ")", "{", "laserdisc_state", "*", "ld", "=", "get_safe_token", "(", "device", ")", ";", "ldcore_data", "*", "ldcore", "=", "ld", "->", "core", ";", "int", "field", "=", "ldcore", "->", "fieldnum", ";", "if", "(", "zero_if_squelched", "&&", "ldcore", "->", "videosquelch", ")", "return", "0", ";", "switch", "(", "code", ")", "{", "case", "LASERDISC_CODE_WHITE_FLAG", ":", "return", "ldcore", "->", "metadata", "[", "field", "]", ".", "white", ";", "case", "LASERDISC_CODE_LINE16", ":", "return", "ldcore", "->", "metadata", "[", "field", "]", ".", "line16", ";", "case", "LASERDISC_CODE_LINE17", ":", "return", "ldcore", "->", "metadata", "[", "field", "]", ".", "line17", ";", "case", "LASERDISC_CODE_LINE18", ":", "return", "ldcore", "->", "metadata", "[", "field", "]", ".", "line18", ";", "case", "LASERDISC_CODE_LINE1718", ":", "return", "ldcore", "->", "metadata", "[", "field", "]", ".", "line1718", ";", "}", "return", "0", ";", "}" ]
laserdisc_get_field_code - return raw field information read from the disc
[ "laserdisc_get_field_code", "-", "return", "raw", "field", "information", "read", "from", "the", "disc" ]
[ "/* return nothing if the video is off (external devices can't sense) */" ]
[ { "param": "device", "type": "running_device" }, { "param": "code", "type": "UINT32" }, { "param": "zero_if_squelched", "type": "UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "device", "type": "running_device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "code", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "zero_if_squelched", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
816986152a835d29137b3ff290efe47048d3ffda
lofunz/mieme
Reloaded/trunk/src/emu/machine/ldcore.c
[ "Unlicense" ]
C
ldcore_set_audio_squelch
void
void ldcore_set_audio_squelch(laserdisc_state *ld, UINT8 squelchleft, UINT8 squelchright) { update_audio(ld); ld->core->audiosquelch = (squelchleft ? 1 : 0) | (squelchright ? 2 : 0); }
/*------------------------------------------------- ldcore_set_audio_squelch - set the left/right audio squelch states -------------------------------------------------*/
set the left/right audio squelch states
[ "set", "the", "left", "/", "right", "audio", "squelch", "states" ]
void ldcore_set_audio_squelch(laserdisc_state *ld, UINT8 squelchleft, UINT8 squelchright) { update_audio(ld); ld->core->audiosquelch = (squelchleft ? 1 : 0) | (squelchright ? 2 : 0); }
[ "void", "ldcore_set_audio_squelch", "(", "laserdisc_state", "*", "ld", ",", "UINT8", "squelchleft", ",", "UINT8", "squelchright", ")", "{", "update_audio", "(", "ld", ")", ";", "ld", "->", "core", "->", "audiosquelch", "=", "(", "squelchleft", "?", "1", ":", "0", ")", "|", "(", "squelchright", "?", "2", ":", "0", ")", ";", "}" ]
ldcore_set_audio_squelch - set the left/right audio squelch states
[ "ldcore_set_audio_squelch", "-", "set", "the", "left", "/", "right", "audio", "squelch", "states" ]
[]
[ { "param": "ld", "type": "laserdisc_state" }, { "param": "squelchleft", "type": "UINT8" }, { "param": "squelchright", "type": "UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ld", "type": "laserdisc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "squelchleft", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "squelchright", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
816986152a835d29137b3ff290efe47048d3ffda
lofunz/mieme
Reloaded/trunk/src/emu/machine/ldcore.c
[ "Unlicense" ]
C
ldcore_advance_slider
void
void ldcore_advance_slider(laserdisc_state *ld, INT32 numtracks) { ldcore_data *ldcore = ld->core; update_slider_pos(ldcore, timer_get_time(ld->device->machine)); add_and_clamp_track(ldcore, numtracks); if (LOG_SLIDER) printf("Advance by %d\n", numtracks); }
/*------------------------------------------------- ldcore_advance_slider - advance the slider by a certain number of tracks -------------------------------------------------*/
advance the slider by a certain number of tracks
[ "advance", "the", "slider", "by", "a", "certain", "number", "of", "tracks" ]
void ldcore_advance_slider(laserdisc_state *ld, INT32 numtracks) { ldcore_data *ldcore = ld->core; update_slider_pos(ldcore, timer_get_time(ld->device->machine)); add_and_clamp_track(ldcore, numtracks); if (LOG_SLIDER) printf("Advance by %d\n", numtracks); }
[ "void", "ldcore_advance_slider", "(", "laserdisc_state", "*", "ld", ",", "INT32", "numtracks", ")", "{", "ldcore_data", "*", "ldcore", "=", "ld", "->", "core", ";", "update_slider_pos", "(", "ldcore", ",", "timer_get_time", "(", "ld", "->", "device", "->", "machine", ")", ")", ";", "add_and_clamp_track", "(", "ldcore", ",", "numtracks", ")", ";", "if", "(", "LOG_SLIDER", ")", "printf", "(", "\"", "\\n", "\"", ",", "numtracks", ")", ";", "}" ]
ldcore_advance_slider - advance the slider by a certain number of tracks
[ "ldcore_advance_slider", "-", "advance", "the", "slider", "by", "a", "certain", "number", "of", "tracks" ]
[]
[ { "param": "ld", "type": "laserdisc_state" }, { "param": "numtracks", "type": "INT32" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ld", "type": "laserdisc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "numtracks", "type": "INT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
816986152a835d29137b3ff290efe47048d3ffda
lofunz/mieme
Reloaded/trunk/src/emu/machine/ldcore.c
[ "Unlicense" ]
C
ldcore_generic_update
INT32
INT32 ldcore_generic_update(laserdisc_state *ld, const vbi_metadata *vbi, int fieldnum, attotime curtime, ldplayer_state *newstate) { INT32 advanceby = 0; int frame; /* start by assuming the state doesn't change */ *newstate = ld->state; /* handle things based on the state */ switch (ld->state.state) { case LDSTATE_EJECTING: /* when time expires, switch to the ejected state */ if (attotime_compare(curtime, ld->state.endtime) >= 0) newstate->state = LDSTATE_EJECTED; break; case LDSTATE_EJECTED: /* do nothing */ break; case LDSTATE_PARKED: /* do nothing */ break; case LDSTATE_LOADING: /* when time expires, switch to the spinup state */ if (attotime_compare(curtime, ld->state.endtime) >= 0) newstate->state = LDSTATE_SPINUP; advanceby = -GENERIC_SEARCH_SPEED; break; case LDSTATE_SPINUP: /* when time expires, switch to the playing state */ if (attotime_compare(curtime, ld->state.endtime) >= 0) newstate->state = LDSTATE_PLAYING; advanceby = -GENERIC_SEARCH_SPEED; break; case LDSTATE_PAUSING: /* if he hit the start of a frame, switch to paused state */ if (is_start_of_frame(vbi)) { newstate->state = LDSTATE_PAUSED; newstate->param = fieldnum; } /* else advance until we hit it */ else if (fieldnum == 1) advanceby = 1; break; case LDSTATE_PAUSED: /* if we paused on field 1, we must flip back and forth */ if (ld->state.param == 1) advanceby = (fieldnum == 1) ? 1 : -1; break; case LDSTATE_PLAYING: /* if we hit the target frame, switch to the paused state */ if (ld->state.param > 0 && is_start_of_frame(vbi) && frame_from_metadata(vbi) == ld->state.param) { newstate->state = LDSTATE_PAUSED; newstate->param = fieldnum; } /* otherwise after the second field of each frame */ else if (fieldnum == 1) advanceby = 1; break; case LDSTATE_PLAYING_SLOW_REVERSE: /* after the second field of each frame, see if we need to advance */ if (fieldnum == 1 && ++ld->state.substate > ld->state.param) { advanceby = -1; ld->state.substate = 0; } break; case LDSTATE_PLAYING_SLOW_FORWARD: /* after the second field of each frame, see if we need to advance */ if (fieldnum == 1 && ++ld->state.substate > ld->state.param) { advanceby = 1; ld->state.substate = 0; } break; case LDSTATE_PLAYING_FAST_REVERSE: /* advance after the second field of each frame */ if (fieldnum == 1) advanceby = -ld->state.param; break; case LDSTATE_PLAYING_FAST_FORWARD: /* advance after the second field of each frame */ if (fieldnum == 1) advanceby = ld->state.param; break; case LDSTATE_SCANNING: /* advance after the second field of each frame */ if (fieldnum == 1) advanceby = ld->state.param >> 8; /* after we run out of vsyncs, revert to the saved state */ if (++ld->state.substate >= (ld->state.param & 0xff)) *newstate = ld->savestate; break; case LDSTATE_STEPPING_REVERSE: /* wait for the first field of the frame and then leap backwards */ if (is_start_of_frame(vbi)) { advanceby = (fieldnum == 1) ? -1 : -2; newstate->state = LDSTATE_PAUSING; } break; case LDSTATE_STEPPING_FORWARD: /* wait for the first field of the frame and then switch to pausing state */ if (is_start_of_frame(vbi)) newstate->state = LDSTATE_PAUSING; break; case LDSTATE_SEEKING: /* if we're in the final state, look for a matching frame and pause there */ frame = frame_from_metadata(vbi); if (ld->state.substate == 1 && is_start_of_frame(vbi) && frame == ld->state.param) { newstate->state = LDSTATE_PAUSED; newstate->param = fieldnum; } /* otherwise, if we got frame data from the VBI, update our seeking logic */ else if (ld->state.substate == 0 && frame != FRAME_NOT_PRESENT) { INT32 delta = (ld->state.param - 2) - frame; /* if we're within a couple of frames, just play until we hit it */ if (delta >= 0 && delta <= 2) ld->state.substate++; /* otherwise, compute the delta assuming 1:1 track to frame; this will correct eventually */ else { if (delta < 0) delta--; advanceby = delta; advanceby = MIN(advanceby, GENERIC_SEARCH_SPEED); advanceby = MAX(advanceby, -GENERIC_SEARCH_SPEED); } } /* otherwise, keep advancing until we know what's up */ else { if (fieldnum == 1) advanceby = 1; } break; } return advanceby; }
/*------------------------------------------------- ldcore_generic_update - generically update in a way that works for most situations -------------------------------------------------*/
generically update in a way that works for most situations
[ "generically", "update", "in", "a", "way", "that", "works", "for", "most", "situations" ]
INT32 ldcore_generic_update(laserdisc_state *ld, const vbi_metadata *vbi, int fieldnum, attotime curtime, ldplayer_state *newstate) { INT32 advanceby = 0; int frame; *newstate = ld->state; switch (ld->state.state) { case LDSTATE_EJECTING: if (attotime_compare(curtime, ld->state.endtime) >= 0) newstate->state = LDSTATE_EJECTED; break; case LDSTATE_EJECTED: break; case LDSTATE_PARKED: break; case LDSTATE_LOADING: if (attotime_compare(curtime, ld->state.endtime) >= 0) newstate->state = LDSTATE_SPINUP; advanceby = -GENERIC_SEARCH_SPEED; break; case LDSTATE_SPINUP: if (attotime_compare(curtime, ld->state.endtime) >= 0) newstate->state = LDSTATE_PLAYING; advanceby = -GENERIC_SEARCH_SPEED; break; case LDSTATE_PAUSING: if (is_start_of_frame(vbi)) { newstate->state = LDSTATE_PAUSED; newstate->param = fieldnum; } else if (fieldnum == 1) advanceby = 1; break; case LDSTATE_PAUSED: if (ld->state.param == 1) advanceby = (fieldnum == 1) ? 1 : -1; break; case LDSTATE_PLAYING: if (ld->state.param > 0 && is_start_of_frame(vbi) && frame_from_metadata(vbi) == ld->state.param) { newstate->state = LDSTATE_PAUSED; newstate->param = fieldnum; } else if (fieldnum == 1) advanceby = 1; break; case LDSTATE_PLAYING_SLOW_REVERSE: if (fieldnum == 1 && ++ld->state.substate > ld->state.param) { advanceby = -1; ld->state.substate = 0; } break; case LDSTATE_PLAYING_SLOW_FORWARD: if (fieldnum == 1 && ++ld->state.substate > ld->state.param) { advanceby = 1; ld->state.substate = 0; } break; case LDSTATE_PLAYING_FAST_REVERSE: if (fieldnum == 1) advanceby = -ld->state.param; break; case LDSTATE_PLAYING_FAST_FORWARD: if (fieldnum == 1) advanceby = ld->state.param; break; case LDSTATE_SCANNING: if (fieldnum == 1) advanceby = ld->state.param >> 8; if (++ld->state.substate >= (ld->state.param & 0xff)) *newstate = ld->savestate; break; case LDSTATE_STEPPING_REVERSE: if (is_start_of_frame(vbi)) { advanceby = (fieldnum == 1) ? -1 : -2; newstate->state = LDSTATE_PAUSING; } break; case LDSTATE_STEPPING_FORWARD: if (is_start_of_frame(vbi)) newstate->state = LDSTATE_PAUSING; break; case LDSTATE_SEEKING: frame = frame_from_metadata(vbi); if (ld->state.substate == 1 && is_start_of_frame(vbi) && frame == ld->state.param) { newstate->state = LDSTATE_PAUSED; newstate->param = fieldnum; } else if (ld->state.substate == 0 && frame != FRAME_NOT_PRESENT) { INT32 delta = (ld->state.param - 2) - frame; if (delta >= 0 && delta <= 2) ld->state.substate++; else { if (delta < 0) delta--; advanceby = delta; advanceby = MIN(advanceby, GENERIC_SEARCH_SPEED); advanceby = MAX(advanceby, -GENERIC_SEARCH_SPEED); } } else { if (fieldnum == 1) advanceby = 1; } break; } return advanceby; }
[ "INT32", "ldcore_generic_update", "(", "laserdisc_state", "*", "ld", ",", "const", "vbi_metadata", "*", "vbi", ",", "int", "fieldnum", ",", "attotime", "curtime", ",", "ldplayer_state", "*", "newstate", ")", "{", "INT32", "advanceby", "=", "0", ";", "int", "frame", ";", "*", "newstate", "=", "ld", "->", "state", ";", "switch", "(", "ld", "->", "state", ".", "state", ")", "{", "case", "LDSTATE_EJECTING", ":", "if", "(", "attotime_compare", "(", "curtime", ",", "ld", "->", "state", ".", "endtime", ")", ">=", "0", ")", "newstate", "->", "state", "=", "LDSTATE_EJECTED", ";", "break", ";", "case", "LDSTATE_EJECTED", ":", "break", ";", "case", "LDSTATE_PARKED", ":", "break", ";", "case", "LDSTATE_LOADING", ":", "if", "(", "attotime_compare", "(", "curtime", ",", "ld", "->", "state", ".", "endtime", ")", ">=", "0", ")", "newstate", "->", "state", "=", "LDSTATE_SPINUP", ";", "advanceby", "=", "-", "GENERIC_SEARCH_SPEED", ";", "break", ";", "case", "LDSTATE_SPINUP", ":", "if", "(", "attotime_compare", "(", "curtime", ",", "ld", "->", "state", ".", "endtime", ")", ">=", "0", ")", "newstate", "->", "state", "=", "LDSTATE_PLAYING", ";", "advanceby", "=", "-", "GENERIC_SEARCH_SPEED", ";", "break", ";", "case", "LDSTATE_PAUSING", ":", "if", "(", "is_start_of_frame", "(", "vbi", ")", ")", "{", "newstate", "->", "state", "=", "LDSTATE_PAUSED", ";", "newstate", "->", "param", "=", "fieldnum", ";", "}", "else", "if", "(", "fieldnum", "==", "1", ")", "advanceby", "=", "1", ";", "break", ";", "case", "LDSTATE_PAUSED", ":", "if", "(", "ld", "->", "state", ".", "param", "==", "1", ")", "advanceby", "=", "(", "fieldnum", "==", "1", ")", "?", "1", ":", "-1", ";", "break", ";", "case", "LDSTATE_PLAYING", ":", "if", "(", "ld", "->", "state", ".", "param", ">", "0", "&&", "is_start_of_frame", "(", "vbi", ")", "&&", "frame_from_metadata", "(", "vbi", ")", "==", "ld", "->", "state", ".", "param", ")", "{", "newstate", "->", "state", "=", "LDSTATE_PAUSED", ";", "newstate", "->", "param", "=", "fieldnum", ";", "}", "else", "if", "(", "fieldnum", "==", "1", ")", "advanceby", "=", "1", ";", "break", ";", "case", "LDSTATE_PLAYING_SLOW_REVERSE", ":", "if", "(", "fieldnum", "==", "1", "&&", "++", "ld", "->", "state", ".", "substate", ">", "ld", "->", "state", ".", "param", ")", "{", "advanceby", "=", "-1", ";", "ld", "->", "state", ".", "substate", "=", "0", ";", "}", "break", ";", "case", "LDSTATE_PLAYING_SLOW_FORWARD", ":", "if", "(", "fieldnum", "==", "1", "&&", "++", "ld", "->", "state", ".", "substate", ">", "ld", "->", "state", ".", "param", ")", "{", "advanceby", "=", "1", ";", "ld", "->", "state", ".", "substate", "=", "0", ";", "}", "break", ";", "case", "LDSTATE_PLAYING_FAST_REVERSE", ":", "if", "(", "fieldnum", "==", "1", ")", "advanceby", "=", "-", "ld", "->", "state", ".", "param", ";", "break", ";", "case", "LDSTATE_PLAYING_FAST_FORWARD", ":", "if", "(", "fieldnum", "==", "1", ")", "advanceby", "=", "ld", "->", "state", ".", "param", ";", "break", ";", "case", "LDSTATE_SCANNING", ":", "if", "(", "fieldnum", "==", "1", ")", "advanceby", "=", "ld", "->", "state", ".", "param", ">>", "8", ";", "if", "(", "++", "ld", "->", "state", ".", "substate", ">=", "(", "ld", "->", "state", ".", "param", "&", "0xff", ")", ")", "*", "newstate", "=", "ld", "->", "savestate", ";", "break", ";", "case", "LDSTATE_STEPPING_REVERSE", ":", "if", "(", "is_start_of_frame", "(", "vbi", ")", ")", "{", "advanceby", "=", "(", "fieldnum", "==", "1", ")", "?", "-1", ":", "-2", ";", "newstate", "->", "state", "=", "LDSTATE_PAUSING", ";", "}", "break", ";", "case", "LDSTATE_STEPPING_FORWARD", ":", "if", "(", "is_start_of_frame", "(", "vbi", ")", ")", "newstate", "->", "state", "=", "LDSTATE_PAUSING", ";", "break", ";", "case", "LDSTATE_SEEKING", ":", "frame", "=", "frame_from_metadata", "(", "vbi", ")", ";", "if", "(", "ld", "->", "state", ".", "substate", "==", "1", "&&", "is_start_of_frame", "(", "vbi", ")", "&&", "frame", "==", "ld", "->", "state", ".", "param", ")", "{", "newstate", "->", "state", "=", "LDSTATE_PAUSED", ";", "newstate", "->", "param", "=", "fieldnum", ";", "}", "else", "if", "(", "ld", "->", "state", ".", "substate", "==", "0", "&&", "frame", "!=", "FRAME_NOT_PRESENT", ")", "{", "INT32", "delta", "=", "(", "ld", "->", "state", ".", "param", "-", "2", ")", "-", "frame", ";", "if", "(", "delta", ">=", "0", "&&", "delta", "<=", "2", ")", "ld", "->", "state", ".", "substate", "++", ";", "else", "{", "if", "(", "delta", "<", "0", ")", "delta", "--", ";", "advanceby", "=", "delta", ";", "advanceby", "=", "MIN", "(", "advanceby", ",", "GENERIC_SEARCH_SPEED", ")", ";", "advanceby", "=", "MAX", "(", "advanceby", ",", "-", "GENERIC_SEARCH_SPEED", ")", ";", "}", "}", "else", "{", "if", "(", "fieldnum", "==", "1", ")", "advanceby", "=", "1", ";", "}", "break", ";", "}", "return", "advanceby", ";", "}" ]
ldcore_generic_update - generically update in a way that works for most situations
[ "ldcore_generic_update", "-", "generically", "update", "in", "a", "way", "that", "works", "for", "most", "situations" ]
[ "/* start by assuming the state doesn't change */", "/* handle things based on the state */", "/* when time expires, switch to the ejected state */", "/* do nothing */", "/* do nothing */", "/* when time expires, switch to the spinup state */", "/* when time expires, switch to the playing state */", "/* if he hit the start of a frame, switch to paused state */", "/* else advance until we hit it */", "/* if we paused on field 1, we must flip back and forth */", "/* if we hit the target frame, switch to the paused state */", "/* otherwise after the second field of each frame */", "/* after the second field of each frame, see if we need to advance */", "/* after the second field of each frame, see if we need to advance */", "/* advance after the second field of each frame */", "/* advance after the second field of each frame */", "/* advance after the second field of each frame */", "/* after we run out of vsyncs, revert to the saved state */", "/* wait for the first field of the frame and then leap backwards */", "/* wait for the first field of the frame and then switch to pausing state */", "/* if we're in the final state, look for a matching frame and pause there */", "/* otherwise, if we got frame data from the VBI, update our seeking logic */", "/* if we're within a couple of frames, just play until we hit it */", "/* otherwise, compute the delta assuming 1:1 track to frame; this will correct eventually */", "/* otherwise, keep advancing until we know what's up */" ]
[ { "param": "ld", "type": "laserdisc_state" }, { "param": "vbi", "type": "vbi_metadata" }, { "param": "fieldnum", "type": "int" }, { "param": "curtime", "type": "attotime" }, { "param": "newstate", "type": "ldplayer_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ld", "type": "laserdisc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "vbi", "type": "vbi_metadata", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fieldnum", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "curtime", "type": "attotime", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "newstate", "type": "ldplayer_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
816986152a835d29137b3ff290efe47048d3ffda
lofunz/mieme
Reloaded/trunk/src/emu/machine/ldcore.c
[ "Unlicense" ]
C
read_track_data
void
static void read_track_data(laserdisc_state *ld) { ldcore_data *ldcore = ld->core; UINT32 tracknum = ldcore->curtrack; UINT32 fieldnum = ldcore->fieldnum; vbi_metadata vbidata = { 0 }; frame_data *frame; UINT32 vbiframe; UINT32 readhunk; INT32 chdtrack; /* compute the chdhunk number we are going to read */ chdtrack = tracknum - 1 - VIRTUAL_LEAD_IN_TRACKS; chdtrack = MAX(chdtrack, 0); chdtrack = MIN(chdtrack, ldcore->chdtracks - 1); readhunk = chdtrack * 2 + fieldnum; /* cheat and look up the metadata we are about to retrieve */ if (ldcore->vbidata != NULL) vbi_metadata_unpack(&vbidata, NULL, &ldcore->vbidata[readhunk * VBI_PACKED_BYTES]); /* if we're in the lead-in area, force the VBI data to be standard lead-in */ if (tracknum - 1 < VIRTUAL_LEAD_IN_TRACKS) { vbidata.line16 = 0; vbidata.line17 = vbidata.line18 = vbidata.line1718 = VBI_CODE_LEADIN; } //printf("track %5d.%d: %06X %06X %06X\n", tracknum, fieldnum, vbidata.line16, vbidata.line17, vbidata.line18); /* if we're about to read the first field in a frame, advance */ frame = &ldcore->frame[ldcore->videoindex]; if ((vbidata.line1718 & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE) { if (frame->numfields >= 2) ldcore->videoindex = (ldcore->videoindex + 1) % ARRAY_LENGTH(ldcore->frame); frame = &ldcore->frame[ldcore->videoindex]; frame->numfields = 0; } /* if we're squelched, reset the frame counter */ if (ldcore->videosquelch) frame->numfields = 0; /* remember the last field number */ frame->lastfield = tracknum * 2 + fieldnum; /* set the video target information */ ldcore->videotarget.alloc = NULL; ldcore->videotarget.base = BITMAP_ADDR16(frame->bitmap, fieldnum, 0); ldcore->videotarget.rowpixels = frame->bitmap->rowpixels * 2; ldcore->videotarget.width = frame->bitmap->width; ldcore->videotarget.height = frame->bitmap->height / 2; ldcore->videotarget.format = frame->bitmap->format; ldcore->videotarget.bpp = frame->bitmap->bpp; ldcore->videotarget.palette = frame->bitmap->palette; ldcore->videotarget.cliprect = frame->bitmap->cliprect; ldcore->avconfig.video = &ldcore->videotarget; /* set the audio target information */ if (ldcore->audiobufin + ldcore->audiomaxsamples <= ldcore->audiobufsize) { /* if we can fit without wrapping, just read the data directly */ ldcore->avconfig.audio[0] = &ldcore->audiobuffer[0][ldcore->audiobufin]; ldcore->avconfig.audio[1] = &ldcore->audiobuffer[1][ldcore->audiobufin]; } else { /* otherwise, read to the beginning of the buffer */ ldcore->avconfig.audio[0] = &ldcore->audiobuffer[0][0]; ldcore->avconfig.audio[1] = &ldcore->audiobuffer[1][0]; } /* override if we're not decoding */ ldcore->avconfig.maxsamples = ldcore->audiomaxsamples; ldcore->avconfig.actsamples = &ldcore->audiocursamples; ldcore->audiocursamples = 0; /* set the VBI data for the new field from our precomputed data */ if (ldcore->vbidata != NULL) vbi_metadata_unpack(&ldcore->metadata[fieldnum], &vbiframe, &ldcore->vbidata[readhunk * VBI_PACKED_BYTES]); /* if we're in the lead-in area, force the VBI data to be standard lead-in */ if (tracknum - 1 < VIRTUAL_LEAD_IN_TRACKS) { ldcore->metadata[fieldnum].line16 = 0; ldcore->metadata[fieldnum].line17 = ldcore->metadata[fieldnum].line18 = ldcore->metadata[fieldnum].line1718 = VBI_CODE_LEADIN; } /* configure the codec and then read */ ldcore->readresult = CHDERR_FILE_NOT_FOUND; if (ldcore->disc != NULL && !ldcore->videosquelch) { ldcore->readresult = chd_codec_config(ldcore->disc, AV_CODEC_DECOMPRESS_CONFIG, &ldcore->avconfig); if (ldcore->readresult == CHDERR_NONE) ldcore->readresult = chd_read_async(ldcore->disc, readhunk, NULL); } }
/*------------------------------------------------- read_track_data - read and process data for a particular video track -------------------------------------------------*/
read and process data for a particular video track
[ "read", "and", "process", "data", "for", "a", "particular", "video", "track" ]
static void read_track_data(laserdisc_state *ld) { ldcore_data *ldcore = ld->core; UINT32 tracknum = ldcore->curtrack; UINT32 fieldnum = ldcore->fieldnum; vbi_metadata vbidata = { 0 }; frame_data *frame; UINT32 vbiframe; UINT32 readhunk; INT32 chdtrack; chdtrack = tracknum - 1 - VIRTUAL_LEAD_IN_TRACKS; chdtrack = MAX(chdtrack, 0); chdtrack = MIN(chdtrack, ldcore->chdtracks - 1); readhunk = chdtrack * 2 + fieldnum; if (ldcore->vbidata != NULL) vbi_metadata_unpack(&vbidata, NULL, &ldcore->vbidata[readhunk * VBI_PACKED_BYTES]); if (tracknum - 1 < VIRTUAL_LEAD_IN_TRACKS) { vbidata.line16 = 0; vbidata.line17 = vbidata.line18 = vbidata.line1718 = VBI_CODE_LEADIN; } frame = &ldcore->frame[ldcore->videoindex]; if ((vbidata.line1718 & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE) { if (frame->numfields >= 2) ldcore->videoindex = (ldcore->videoindex + 1) % ARRAY_LENGTH(ldcore->frame); frame = &ldcore->frame[ldcore->videoindex]; frame->numfields = 0; } if (ldcore->videosquelch) frame->numfields = 0; frame->lastfield = tracknum * 2 + fieldnum; ldcore->videotarget.alloc = NULL; ldcore->videotarget.base = BITMAP_ADDR16(frame->bitmap, fieldnum, 0); ldcore->videotarget.rowpixels = frame->bitmap->rowpixels * 2; ldcore->videotarget.width = frame->bitmap->width; ldcore->videotarget.height = frame->bitmap->height / 2; ldcore->videotarget.format = frame->bitmap->format; ldcore->videotarget.bpp = frame->bitmap->bpp; ldcore->videotarget.palette = frame->bitmap->palette; ldcore->videotarget.cliprect = frame->bitmap->cliprect; ldcore->avconfig.video = &ldcore->videotarget; if (ldcore->audiobufin + ldcore->audiomaxsamples <= ldcore->audiobufsize) { ldcore->avconfig.audio[0] = &ldcore->audiobuffer[0][ldcore->audiobufin]; ldcore->avconfig.audio[1] = &ldcore->audiobuffer[1][ldcore->audiobufin]; } else { ldcore->avconfig.audio[0] = &ldcore->audiobuffer[0][0]; ldcore->avconfig.audio[1] = &ldcore->audiobuffer[1][0]; } ldcore->avconfig.maxsamples = ldcore->audiomaxsamples; ldcore->avconfig.actsamples = &ldcore->audiocursamples; ldcore->audiocursamples = 0; if (ldcore->vbidata != NULL) vbi_metadata_unpack(&ldcore->metadata[fieldnum], &vbiframe, &ldcore->vbidata[readhunk * VBI_PACKED_BYTES]); if (tracknum - 1 < VIRTUAL_LEAD_IN_TRACKS) { ldcore->metadata[fieldnum].line16 = 0; ldcore->metadata[fieldnum].line17 = ldcore->metadata[fieldnum].line18 = ldcore->metadata[fieldnum].line1718 = VBI_CODE_LEADIN; } ldcore->readresult = CHDERR_FILE_NOT_FOUND; if (ldcore->disc != NULL && !ldcore->videosquelch) { ldcore->readresult = chd_codec_config(ldcore->disc, AV_CODEC_DECOMPRESS_CONFIG, &ldcore->avconfig); if (ldcore->readresult == CHDERR_NONE) ldcore->readresult = chd_read_async(ldcore->disc, readhunk, NULL); } }
[ "static", "void", "read_track_data", "(", "laserdisc_state", "*", "ld", ")", "{", "ldcore_data", "*", "ldcore", "=", "ld", "->", "core", ";", "UINT32", "tracknum", "=", "ldcore", "->", "curtrack", ";", "UINT32", "fieldnum", "=", "ldcore", "->", "fieldnum", ";", "vbi_metadata", "vbidata", "=", "{", "0", "}", ";", "frame_data", "*", "frame", ";", "UINT32", "vbiframe", ";", "UINT32", "readhunk", ";", "INT32", "chdtrack", ";", "chdtrack", "=", "tracknum", "-", "1", "-", "VIRTUAL_LEAD_IN_TRACKS", ";", "chdtrack", "=", "MAX", "(", "chdtrack", ",", "0", ")", ";", "chdtrack", "=", "MIN", "(", "chdtrack", ",", "ldcore", "->", "chdtracks", "-", "1", ")", ";", "readhunk", "=", "chdtrack", "*", "2", "+", "fieldnum", ";", "if", "(", "ldcore", "->", "vbidata", "!=", "NULL", ")", "vbi_metadata_unpack", "(", "&", "vbidata", ",", "NULL", ",", "&", "ldcore", "->", "vbidata", "[", "readhunk", "*", "VBI_PACKED_BYTES", "]", ")", ";", "if", "(", "tracknum", "-", "1", "<", "VIRTUAL_LEAD_IN_TRACKS", ")", "{", "vbidata", ".", "line16", "=", "0", ";", "vbidata", ".", "line17", "=", "vbidata", ".", "line18", "=", "vbidata", ".", "line1718", "=", "VBI_CODE_LEADIN", ";", "}", "frame", "=", "&", "ldcore", "->", "frame", "[", "ldcore", "->", "videoindex", "]", ";", "if", "(", "(", "vbidata", ".", "line1718", "&", "VBI_MASK_CAV_PICTURE", ")", "==", "VBI_CODE_CAV_PICTURE", ")", "{", "if", "(", "frame", "->", "numfields", ">=", "2", ")", "ldcore", "->", "videoindex", "=", "(", "ldcore", "->", "videoindex", "+", "1", ")", "%", "ARRAY_LENGTH", "(", "ldcore", "->", "frame", ")", ";", "frame", "=", "&", "ldcore", "->", "frame", "[", "ldcore", "->", "videoindex", "]", ";", "frame", "->", "numfields", "=", "0", ";", "}", "if", "(", "ldcore", "->", "videosquelch", ")", "frame", "->", "numfields", "=", "0", ";", "frame", "->", "lastfield", "=", "tracknum", "*", "2", "+", "fieldnum", ";", "ldcore", "->", "videotarget", ".", "alloc", "=", "NULL", ";", "ldcore", "->", "videotarget", ".", "base", "=", "BITMAP_ADDR16", "(", "frame", "->", "bitmap", ",", "fieldnum", ",", "0", ")", ";", "ldcore", "->", "videotarget", ".", "rowpixels", "=", "frame", "->", "bitmap", "->", "rowpixels", "*", "2", ";", "ldcore", "->", "videotarget", ".", "width", "=", "frame", "->", "bitmap", "->", "width", ";", "ldcore", "->", "videotarget", ".", "height", "=", "frame", "->", "bitmap", "->", "height", "/", "2", ";", "ldcore", "->", "videotarget", ".", "format", "=", "frame", "->", "bitmap", "->", "format", ";", "ldcore", "->", "videotarget", ".", "bpp", "=", "frame", "->", "bitmap", "->", "bpp", ";", "ldcore", "->", "videotarget", ".", "palette", "=", "frame", "->", "bitmap", "->", "palette", ";", "ldcore", "->", "videotarget", ".", "cliprect", "=", "frame", "->", "bitmap", "->", "cliprect", ";", "ldcore", "->", "avconfig", ".", "video", "=", "&", "ldcore", "->", "videotarget", ";", "if", "(", "ldcore", "->", "audiobufin", "+", "ldcore", "->", "audiomaxsamples", "<=", "ldcore", "->", "audiobufsize", ")", "{", "ldcore", "->", "avconfig", ".", "audio", "[", "0", "]", "=", "&", "ldcore", "->", "audiobuffer", "[", "0", "]", "[", "ldcore", "->", "audiobufin", "]", ";", "ldcore", "->", "avconfig", ".", "audio", "[", "1", "]", "=", "&", "ldcore", "->", "audiobuffer", "[", "1", "]", "[", "ldcore", "->", "audiobufin", "]", ";", "}", "else", "{", "ldcore", "->", "avconfig", ".", "audio", "[", "0", "]", "=", "&", "ldcore", "->", "audiobuffer", "[", "0", "]", "[", "0", "]", ";", "ldcore", "->", "avconfig", ".", "audio", "[", "1", "]", "=", "&", "ldcore", "->", "audiobuffer", "[", "1", "]", "[", "0", "]", ";", "}", "ldcore", "->", "avconfig", ".", "maxsamples", "=", "ldcore", "->", "audiomaxsamples", ";", "ldcore", "->", "avconfig", ".", "actsamples", "=", "&", "ldcore", "->", "audiocursamples", ";", "ldcore", "->", "audiocursamples", "=", "0", ";", "if", "(", "ldcore", "->", "vbidata", "!=", "NULL", ")", "vbi_metadata_unpack", "(", "&", "ldcore", "->", "metadata", "[", "fieldnum", "]", ",", "&", "vbiframe", ",", "&", "ldcore", "->", "vbidata", "[", "readhunk", "*", "VBI_PACKED_BYTES", "]", ")", ";", "if", "(", "tracknum", "-", "1", "<", "VIRTUAL_LEAD_IN_TRACKS", ")", "{", "ldcore", "->", "metadata", "[", "fieldnum", "]", ".", "line16", "=", "0", ";", "ldcore", "->", "metadata", "[", "fieldnum", "]", ".", "line17", "=", "ldcore", "->", "metadata", "[", "fieldnum", "]", ".", "line18", "=", "ldcore", "->", "metadata", "[", "fieldnum", "]", ".", "line1718", "=", "VBI_CODE_LEADIN", ";", "}", "ldcore", "->", "readresult", "=", "CHDERR_FILE_NOT_FOUND", ";", "if", "(", "ldcore", "->", "disc", "!=", "NULL", "&&", "!", "ldcore", "->", "videosquelch", ")", "{", "ldcore", "->", "readresult", "=", "chd_codec_config", "(", "ldcore", "->", "disc", ",", "AV_CODEC_DECOMPRESS_CONFIG", ",", "&", "ldcore", "->", "avconfig", ")", ";", "if", "(", "ldcore", "->", "readresult", "==", "CHDERR_NONE", ")", "ldcore", "->", "readresult", "=", "chd_read_async", "(", "ldcore", "->", "disc", ",", "readhunk", ",", "NULL", ")", ";", "}", "}" ]
read_track_data - read and process data for a particular video track
[ "read_track_data", "-", "read", "and", "process", "data", "for", "a", "particular", "video", "track" ]
[ "/* compute the chdhunk number we are going to read */", "/* cheat and look up the metadata we are about to retrieve */", "/* if we're in the lead-in area, force the VBI data to be standard lead-in */", "//printf(\"track %5d.%d: %06X %06X %06X\\n\", tracknum, fieldnum, vbidata.line16, vbidata.line17, vbidata.line18);\r", "/* if we're about to read the first field in a frame, advance */", "/* if we're squelched, reset the frame counter */", "/* remember the last field number */", "/* set the video target information */", "/* set the audio target information */", "/* if we can fit without wrapping, just read the data directly */", "/* otherwise, read to the beginning of the buffer */", "/* override if we're not decoding */", "/* set the VBI data for the new field from our precomputed data */", "/* if we're in the lead-in area, force the VBI data to be standard lead-in */", "/* configure the codec and then read */" ]
[ { "param": "ld", "type": "laserdisc_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ld", "type": "laserdisc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
816986152a835d29137b3ff290efe47048d3ffda
lofunz/mieme
Reloaded/trunk/src/emu/machine/ldcore.c
[ "Unlicense" ]
C
process_track_data
void
static void process_track_data(running_device *device) { laserdisc_state *ld = get_safe_token(device); ldcore_data *ldcore = ld->core; /* wait for the async operation to complete */ if (ldcore->readresult == CHDERR_OPERATION_PENDING) ldcore->readresult = chd_async_complete(ldcore->disc); /* remove the video if we had an error */ if (ldcore->readresult != CHDERR_NONE) ldcore->avconfig.video = NULL; /* count the field as read if we are successful */ if (ldcore->avconfig.video != NULL) ldcore->frame[ldcore->videoindex].numfields++; /* render the display if present */ if (ldcore->avconfig.video != NULL && ldcore->intf.overlay != NULL) (*ldcore->intf.overlay)(ld, ldcore->avconfig.video); /* pass the audio to the callback */ if (ldcore->config.audio != NULL) (*ldcore->config.audio)(device, ldcore->samplerate, ldcore->audiocursamples, ldcore->avconfig.audio[0], ldcore->avconfig.audio[1]); /* shift audio data if we read it into the beginning of the buffer */ if (ldcore->audiocursamples != 0 && ldcore->audiobufin != 0) { int chnum; /* iterate over channels */ for (chnum = 0; chnum < 2; chnum++) if (ldcore->avconfig.audio[chnum] == &ldcore->audiobuffer[chnum][0]) { int samplesleft; /* move data to the end */ samplesleft = ldcore->audiobufsize - ldcore->audiobufin; samplesleft = MIN(samplesleft, ldcore->audiocursamples); memmove(&ldcore->audiobuffer[chnum][ldcore->audiobufin], &ldcore->audiobuffer[chnum][0], samplesleft * 2); /* shift data at the beginning */ if (samplesleft < ldcore->audiocursamples) memmove(&ldcore->audiobuffer[chnum][0], &ldcore->audiobuffer[chnum][samplesleft], (ldcore->audiocursamples - samplesleft) * 2); } } /* update the input buffer pointer */ ldcore->audiobufin = (ldcore->audiobufin + ldcore->audiocursamples) % ldcore->audiobufsize; }
/*------------------------------------------------- process_track_data - process data from a track after it has been read -------------------------------------------------*/
process data from a track after it has been read
[ "process", "data", "from", "a", "track", "after", "it", "has", "been", "read" ]
static void process_track_data(running_device *device) { laserdisc_state *ld = get_safe_token(device); ldcore_data *ldcore = ld->core; if (ldcore->readresult == CHDERR_OPERATION_PENDING) ldcore->readresult = chd_async_complete(ldcore->disc); if (ldcore->readresult != CHDERR_NONE) ldcore->avconfig.video = NULL; if (ldcore->avconfig.video != NULL) ldcore->frame[ldcore->videoindex].numfields++; if (ldcore->avconfig.video != NULL && ldcore->intf.overlay != NULL) (*ldcore->intf.overlay)(ld, ldcore->avconfig.video); if (ldcore->config.audio != NULL) (*ldcore->config.audio)(device, ldcore->samplerate, ldcore->audiocursamples, ldcore->avconfig.audio[0], ldcore->avconfig.audio[1]); if (ldcore->audiocursamples != 0 && ldcore->audiobufin != 0) { int chnum; for (chnum = 0; chnum < 2; chnum++) if (ldcore->avconfig.audio[chnum] == &ldcore->audiobuffer[chnum][0]) { int samplesleft; samplesleft = ldcore->audiobufsize - ldcore->audiobufin; samplesleft = MIN(samplesleft, ldcore->audiocursamples); memmove(&ldcore->audiobuffer[chnum][ldcore->audiobufin], &ldcore->audiobuffer[chnum][0], samplesleft * 2); if (samplesleft < ldcore->audiocursamples) memmove(&ldcore->audiobuffer[chnum][0], &ldcore->audiobuffer[chnum][samplesleft], (ldcore->audiocursamples - samplesleft) * 2); } } ldcore->audiobufin = (ldcore->audiobufin + ldcore->audiocursamples) % ldcore->audiobufsize; }
[ "static", "void", "process_track_data", "(", "running_device", "*", "device", ")", "{", "laserdisc_state", "*", "ld", "=", "get_safe_token", "(", "device", ")", ";", "ldcore_data", "*", "ldcore", "=", "ld", "->", "core", ";", "if", "(", "ldcore", "->", "readresult", "==", "CHDERR_OPERATION_PENDING", ")", "ldcore", "->", "readresult", "=", "chd_async_complete", "(", "ldcore", "->", "disc", ")", ";", "if", "(", "ldcore", "->", "readresult", "!=", "CHDERR_NONE", ")", "ldcore", "->", "avconfig", ".", "video", "=", "NULL", ";", "if", "(", "ldcore", "->", "avconfig", ".", "video", "!=", "NULL", ")", "ldcore", "->", "frame", "[", "ldcore", "->", "videoindex", "]", ".", "numfields", "++", ";", "if", "(", "ldcore", "->", "avconfig", ".", "video", "!=", "NULL", "&&", "ldcore", "->", "intf", ".", "overlay", "!=", "NULL", ")", "(", "*", "ldcore", "->", "intf", ".", "overlay", ")", "(", "ld", ",", "ldcore", "->", "avconfig", ".", "video", ")", ";", "if", "(", "ldcore", "->", "config", ".", "audio", "!=", "NULL", ")", "(", "*", "ldcore", "->", "config", ".", "audio", ")", "(", "device", ",", "ldcore", "->", "samplerate", ",", "ldcore", "->", "audiocursamples", ",", "ldcore", "->", "avconfig", ".", "audio", "[", "0", "]", ",", "ldcore", "->", "avconfig", ".", "audio", "[", "1", "]", ")", ";", "if", "(", "ldcore", "->", "audiocursamples", "!=", "0", "&&", "ldcore", "->", "audiobufin", "!=", "0", ")", "{", "int", "chnum", ";", "for", "(", "chnum", "=", "0", ";", "chnum", "<", "2", ";", "chnum", "++", ")", "if", "(", "ldcore", "->", "avconfig", ".", "audio", "[", "chnum", "]", "==", "&", "ldcore", "->", "audiobuffer", "[", "chnum", "]", "[", "0", "]", ")", "{", "int", "samplesleft", ";", "samplesleft", "=", "ldcore", "->", "audiobufsize", "-", "ldcore", "->", "audiobufin", ";", "samplesleft", "=", "MIN", "(", "samplesleft", ",", "ldcore", "->", "audiocursamples", ")", ";", "memmove", "(", "&", "ldcore", "->", "audiobuffer", "[", "chnum", "]", "[", "ldcore", "->", "audiobufin", "]", ",", "&", "ldcore", "->", "audiobuffer", "[", "chnum", "]", "[", "0", "]", ",", "samplesleft", "*", "2", ")", ";", "if", "(", "samplesleft", "<", "ldcore", "->", "audiocursamples", ")", "memmove", "(", "&", "ldcore", "->", "audiobuffer", "[", "chnum", "]", "[", "0", "]", ",", "&", "ldcore", "->", "audiobuffer", "[", "chnum", "]", "[", "samplesleft", "]", ",", "(", "ldcore", "->", "audiocursamples", "-", "samplesleft", ")", "*", "2", ")", ";", "}", "}", "ldcore", "->", "audiobufin", "=", "(", "ldcore", "->", "audiobufin", "+", "ldcore", "->", "audiocursamples", ")", "%", "ldcore", "->", "audiobufsize", ";", "}" ]
process_track_data - process data from a track after it has been read
[ "process_track_data", "-", "process", "data", "from", "a", "track", "after", "it", "has", "been", "read" ]
[ "/* wait for the async operation to complete */", "/* remove the video if we had an error */", "/* count the field as read if we are successful */", "/* render the display if present */", "/* pass the audio to the callback */", "/* shift audio data if we read it into the beginning of the buffer */", "/* iterate over channels */", "/* move data to the end */", "/* shift data at the beginning */", "/* update the input buffer pointer */" ]
[ { "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": [] }
816986152a835d29137b3ff290efe47048d3ffda
lofunz/mieme
Reloaded/trunk/src/emu/machine/ldcore.c
[ "Unlicense" ]
C
configuration_load
void
static void configuration_load(running_machine *machine, int config_type, xml_data_node *parentnode) { xml_data_node *overnode; xml_data_node *ldnode; /* we only care about game files */ if (config_type != CONFIG_TYPE_GAME) return; /* might not have any data */ if (parentnode == NULL) return; /* iterate over overlay nodes */ for (ldnode = xml_get_sibling(parentnode->child, "device"); ldnode != NULL; ldnode = xml_get_sibling(ldnode->next, "device")) { const char *devtag = xml_get_attribute_string(ldnode, "tag", ""); running_device *device = machine->device(devtag); if (device != NULL) { laserdisc_state *ld = get_safe_token(device); ldcore_data *ldcore = ld->core; /* handle the overlay node */ overnode = xml_get_sibling(ldnode->child, "overlay"); if (overnode != NULL) { /* fetch positioning controls */ ldcore->config.overposx = xml_get_attribute_float(overnode, "hoffset", ldcore->config.overposx); ldcore->config.overscalex = xml_get_attribute_float(overnode, "hstretch", ldcore->config.overscalex); ldcore->config.overposy = xml_get_attribute_float(overnode, "voffset", ldcore->config.overposy); ldcore->config.overscaley = xml_get_attribute_float(overnode, "vstretch", ldcore->config.overscaley); } } } }
/*------------------------------------------------- configuration_load - read and apply data from the configuration file -------------------------------------------------*/
read and apply data from the configuration file
[ "read", "and", "apply", "data", "from", "the", "configuration", "file" ]
static void configuration_load(running_machine *machine, int config_type, xml_data_node *parentnode) { xml_data_node *overnode; xml_data_node *ldnode; if (config_type != CONFIG_TYPE_GAME) return; if (parentnode == NULL) return; for (ldnode = xml_get_sibling(parentnode->child, "device"); ldnode != NULL; ldnode = xml_get_sibling(ldnode->next, "device")) { const char *devtag = xml_get_attribute_string(ldnode, "tag", ""); running_device *device = machine->device(devtag); if (device != NULL) { laserdisc_state *ld = get_safe_token(device); ldcore_data *ldcore = ld->core; overnode = xml_get_sibling(ldnode->child, "overlay"); if (overnode != NULL) { ldcore->config.overposx = xml_get_attribute_float(overnode, "hoffset", ldcore->config.overposx); ldcore->config.overscalex = xml_get_attribute_float(overnode, "hstretch", ldcore->config.overscalex); ldcore->config.overposy = xml_get_attribute_float(overnode, "voffset", ldcore->config.overposy); ldcore->config.overscaley = xml_get_attribute_float(overnode, "vstretch", ldcore->config.overscaley); } } } }
[ "static", "void", "configuration_load", "(", "running_machine", "*", "machine", ",", "int", "config_type", ",", "xml_data_node", "*", "parentnode", ")", "{", "xml_data_node", "*", "overnode", ";", "xml_data_node", "*", "ldnode", ";", "if", "(", "config_type", "!=", "CONFIG_TYPE_GAME", ")", "return", ";", "if", "(", "parentnode", "==", "NULL", ")", "return", ";", "for", "(", "ldnode", "=", "xml_get_sibling", "(", "parentnode", "->", "child", ",", "\"", "\"", ")", ";", "ldnode", "!=", "NULL", ";", "ldnode", "=", "xml_get_sibling", "(", "ldnode", "->", "next", ",", "\"", "\"", ")", ")", "{", "const", "char", "*", "devtag", "=", "xml_get_attribute_string", "(", "ldnode", ",", "\"", "\"", ",", "\"", "\"", ")", ";", "running_device", "*", "device", "=", "machine", "->", "device", "(", "devtag", ")", ";", "if", "(", "device", "!=", "NULL", ")", "{", "laserdisc_state", "*", "ld", "=", "get_safe_token", "(", "device", ")", ";", "ldcore_data", "*", "ldcore", "=", "ld", "->", "core", ";", "overnode", "=", "xml_get_sibling", "(", "ldnode", "->", "child", ",", "\"", "\"", ")", ";", "if", "(", "overnode", "!=", "NULL", ")", "{", "ldcore", "->", "config", ".", "overposx", "=", "xml_get_attribute_float", "(", "overnode", ",", "\"", "\"", ",", "ldcore", "->", "config", ".", "overposx", ")", ";", "ldcore", "->", "config", ".", "overscalex", "=", "xml_get_attribute_float", "(", "overnode", ",", "\"", "\"", ",", "ldcore", "->", "config", ".", "overscalex", ")", ";", "ldcore", "->", "config", ".", "overposy", "=", "xml_get_attribute_float", "(", "overnode", ",", "\"", "\"", ",", "ldcore", "->", "config", ".", "overposy", ")", ";", "ldcore", "->", "config", ".", "overscaley", "=", "xml_get_attribute_float", "(", "overnode", ",", "\"", "\"", ",", "ldcore", "->", "config", ".", "overscaley", ")", ";", "}", "}", "}", "}" ]
configuration_load - read and apply data from the configuration file
[ "configuration_load", "-", "read", "and", "apply", "data", "from", "the", "configuration", "file" ]
[ "/* we only care about game files */", "/* might not have any data */", "/* iterate over overlay nodes */", "/* handle the overlay node */", "/* fetch positioning controls */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "config_type", "type": "int" }, { "param": "parentnode", "type": "xml_data_node" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "config_type", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "parentnode", "type": "xml_data_node", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
816986152a835d29137b3ff290efe47048d3ffda
lofunz/mieme
Reloaded/trunk/src/emu/machine/ldcore.c
[ "Unlicense" ]
C
laserdisc_get_config
void
void laserdisc_get_config(running_device *device, laserdisc_config *config) { laserdisc_state *ld = get_safe_token(device); *config = ld->core->config; }
/*------------------------------------------------- laserdisc_get_config - return a copy of the current live configuration settings -------------------------------------------------*/
return a copy of the current live configuration settings
[ "return", "a", "copy", "of", "the", "current", "live", "configuration", "settings" ]
void laserdisc_get_config(running_device *device, laserdisc_config *config) { laserdisc_state *ld = get_safe_token(device); *config = ld->core->config; }
[ "void", "laserdisc_get_config", "(", "running_device", "*", "device", ",", "laserdisc_config", "*", "config", ")", "{", "laserdisc_state", "*", "ld", "=", "get_safe_token", "(", "device", ")", ";", "*", "config", "=", "ld", "->", "core", "->", "config", ";", "}" ]
laserdisc_get_config - return a copy of the current live configuration settings
[ "laserdisc_get_config", "-", "return", "a", "copy", "of", "the", "current", "live", "configuration", "settings" ]
[]
[ { "param": "device", "type": "running_device" }, { "param": "config", "type": "laserdisc_config" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "device", "type": "running_device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "config", "type": "laserdisc_config", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
816986152a835d29137b3ff290efe47048d3ffda
lofunz/mieme
Reloaded/trunk/src/emu/machine/ldcore.c
[ "Unlicense" ]
C
laserdisc_set_config
void
void laserdisc_set_config(running_device *device, const laserdisc_config *config) { laserdisc_state *ld = get_safe_token(device); ld->core->config = *config; }
/*------------------------------------------------- laserdisc_get_config - change the current live configuration settings -------------------------------------------------*/
change the current live configuration settings
[ "change", "the", "current", "live", "configuration", "settings" ]
void laserdisc_set_config(running_device *device, const laserdisc_config *config) { laserdisc_state *ld = get_safe_token(device); ld->core->config = *config; }
[ "void", "laserdisc_set_config", "(", "running_device", "*", "device", ",", "const", "laserdisc_config", "*", "config", ")", "{", "laserdisc_state", "*", "ld", "=", "get_safe_token", "(", "device", ")", ";", "ld", "->", "core", "->", "config", "=", "*", "config", ";", "}" ]
laserdisc_get_config - change the current live configuration settings
[ "laserdisc_get_config", "-", "change", "the", "current", "live", "configuration", "settings" ]
[]
[ { "param": "device", "type": "running_device" }, { "param": "config", "type": "laserdisc_config" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "device", "type": "running_device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "config", "type": "laserdisc_config", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
816986152a835d29137b3ff290efe47048d3ffda
lofunz/mieme
Reloaded/trunk/src/emu/machine/ldcore.c
[ "Unlicense" ]
C
init_video
void
static void init_video(running_device *device) { laserdisc_state *ld = get_safe_token(device); ldcore_data *ldcore = ld->core; int index; /* register for VBLANK callbacks */ ld->screen->register_vblank_callback(vblank_state_changed, (void *)device); /* allocate video frames */ for (index = 0; index < ARRAY_LENGTH(ldcore->frame); index++) { frame_data *frame = &ldcore->frame[index]; /* first allocate a YUY16 bitmap at 2x the height */ frame->bitmap = auto_alloc(device->machine, bitmap_t(ldcore->width, ldcore->height * 2, BITMAP_FORMAT_YUY16)); fillbitmap_yuy16(frame->bitmap, 40, 109, 240); /* make a copy of the bitmap that clips out the VBI and horizontal blanking areas */ frame->visbitmap = auto_alloc(device->machine, bitmap_t(BITMAP_ADDR16(frame->bitmap, 44, frame->bitmap->width * 8 / 720), frame->bitmap->width - 2 * frame->bitmap->width * 8 / 720, frame->bitmap->height - 44, frame->bitmap->rowpixels, frame->bitmap->format)); } /* allocate an empty frame of the same size */ ldcore->emptyframe = auto_bitmap_alloc(device->machine, ldcore->width, ldcore->height * 2, BITMAP_FORMAT_YUY16); fillbitmap_yuy16(ldcore->emptyframe, 0, 128, 128); /* allocate texture for rendering */ ldcore->videoenable = TRUE; ldcore->videotex = render_texture_alloc(NULL, NULL); if (ldcore->videotex == NULL) fatalerror("Out of memory allocating video texture"); /* allocate palette for applying brightness/contrast/gamma */ ldcore->videopalette = palette_alloc(256, 1); if (ldcore->videopalette == NULL) fatalerror("Out of memory allocating video palette"); for (index = 0; index < 256; index++) palette_entry_set_color(ldcore->videopalette, index, MAKE_RGB(index, index, index)); /* allocate overlay */ if (ldcore->config.overwidth > 0 && ldcore->config.overheight > 0 && ldcore->config.overupdate != NULL) { ldcore->overenable = TRUE; ldcore->overbitmap[0] = auto_bitmap_alloc(device->machine, ldcore->config.overwidth, ldcore->config.overheight, (bitmap_format)ldcore->config.overformat); ldcore->overbitmap[1] = auto_bitmap_alloc(device->machine, ldcore->config.overwidth, ldcore->config.overheight, (bitmap_format)ldcore->config.overformat); ldcore->overtex = render_texture_alloc(NULL, NULL); if (ldcore->overtex == NULL) fatalerror("Out of memory allocating overlay texture"); } }
/*------------------------------------------------- init_video - initialize the state of the video rendering -------------------------------------------------*/
initialize the state of the video rendering
[ "initialize", "the", "state", "of", "the", "video", "rendering" ]
static void init_video(running_device *device) { laserdisc_state *ld = get_safe_token(device); ldcore_data *ldcore = ld->core; int index; ld->screen->register_vblank_callback(vblank_state_changed, (void *)device); for (index = 0; index < ARRAY_LENGTH(ldcore->frame); index++) { frame_data *frame = &ldcore->frame[index]; frame->bitmap = auto_alloc(device->machine, bitmap_t(ldcore->width, ldcore->height * 2, BITMAP_FORMAT_YUY16)); fillbitmap_yuy16(frame->bitmap, 40, 109, 240); frame->visbitmap = auto_alloc(device->machine, bitmap_t(BITMAP_ADDR16(frame->bitmap, 44, frame->bitmap->width * 8 / 720), frame->bitmap->width - 2 * frame->bitmap->width * 8 / 720, frame->bitmap->height - 44, frame->bitmap->rowpixels, frame->bitmap->format)); } ldcore->emptyframe = auto_bitmap_alloc(device->machine, ldcore->width, ldcore->height * 2, BITMAP_FORMAT_YUY16); fillbitmap_yuy16(ldcore->emptyframe, 0, 128, 128); ldcore->videoenable = TRUE; ldcore->videotex = render_texture_alloc(NULL, NULL); if (ldcore->videotex == NULL) fatalerror("Out of memory allocating video texture"); ldcore->videopalette = palette_alloc(256, 1); if (ldcore->videopalette == NULL) fatalerror("Out of memory allocating video palette"); for (index = 0; index < 256; index++) palette_entry_set_color(ldcore->videopalette, index, MAKE_RGB(index, index, index)); if (ldcore->config.overwidth > 0 && ldcore->config.overheight > 0 && ldcore->config.overupdate != NULL) { ldcore->overenable = TRUE; ldcore->overbitmap[0] = auto_bitmap_alloc(device->machine, ldcore->config.overwidth, ldcore->config.overheight, (bitmap_format)ldcore->config.overformat); ldcore->overbitmap[1] = auto_bitmap_alloc(device->machine, ldcore->config.overwidth, ldcore->config.overheight, (bitmap_format)ldcore->config.overformat); ldcore->overtex = render_texture_alloc(NULL, NULL); if (ldcore->overtex == NULL) fatalerror("Out of memory allocating overlay texture"); } }
[ "static", "void", "init_video", "(", "running_device", "*", "device", ")", "{", "laserdisc_state", "*", "ld", "=", "get_safe_token", "(", "device", ")", ";", "ldcore_data", "*", "ldcore", "=", "ld", "->", "core", ";", "int", "index", ";", "ld", "->", "screen", "->", "register_vblank_callback", "(", "vblank_state_changed", ",", "(", "void", "*", ")", "device", ")", ";", "for", "(", "index", "=", "0", ";", "index", "<", "ARRAY_LENGTH", "(", "ldcore", "->", "frame", ")", ";", "index", "++", ")", "{", "frame_data", "*", "frame", "=", "&", "ldcore", "->", "frame", "[", "index", "]", ";", "frame", "->", "bitmap", "=", "auto_alloc", "(", "device", "->", "machine", ",", "bitmap_t", "(", "ldcore", "->", "width", ",", "ldcore", "->", "height", "*", "2", ",", "BITMAP_FORMAT_YUY16", ")", ")", ";", "fillbitmap_yuy16", "(", "frame", "->", "bitmap", ",", "40", ",", "109", ",", "240", ")", ";", "frame", "->", "visbitmap", "=", "auto_alloc", "(", "device", "->", "machine", ",", "bitmap_t", "(", "BITMAP_ADDR16", "(", "frame", "->", "bitmap", ",", "44", ",", "frame", "->", "bitmap", "->", "width", "*", "8", "/", "720", ")", ",", "frame", "->", "bitmap", "->", "width", "-", "2", "*", "frame", "->", "bitmap", "->", "width", "*", "8", "/", "720", ",", "frame", "->", "bitmap", "->", "height", "-", "44", ",", "frame", "->", "bitmap", "->", "rowpixels", ",", "frame", "->", "bitmap", "->", "format", ")", ")", ";", "}", "ldcore", "->", "emptyframe", "=", "auto_bitmap_alloc", "(", "device", "->", "machine", ",", "ldcore", "->", "width", ",", "ldcore", "->", "height", "*", "2", ",", "BITMAP_FORMAT_YUY16", ")", ";", "fillbitmap_yuy16", "(", "ldcore", "->", "emptyframe", ",", "0", ",", "128", ",", "128", ")", ";", "ldcore", "->", "videoenable", "=", "TRUE", ";", "ldcore", "->", "videotex", "=", "render_texture_alloc", "(", "NULL", ",", "NULL", ")", ";", "if", "(", "ldcore", "->", "videotex", "==", "NULL", ")", "fatalerror", "(", "\"", "\"", ")", ";", "ldcore", "->", "videopalette", "=", "palette_alloc", "(", "256", ",", "1", ")", ";", "if", "(", "ldcore", "->", "videopalette", "==", "NULL", ")", "fatalerror", "(", "\"", "\"", ")", ";", "for", "(", "index", "=", "0", ";", "index", "<", "256", ";", "index", "++", ")", "palette_entry_set_color", "(", "ldcore", "->", "videopalette", ",", "index", ",", "MAKE_RGB", "(", "index", ",", "index", ",", "index", ")", ")", ";", "if", "(", "ldcore", "->", "config", ".", "overwidth", ">", "0", "&&", "ldcore", "->", "config", ".", "overheight", ">", "0", "&&", "ldcore", "->", "config", ".", "overupdate", "!=", "NULL", ")", "{", "ldcore", "->", "overenable", "=", "TRUE", ";", "ldcore", "->", "overbitmap", "[", "0", "]", "=", "auto_bitmap_alloc", "(", "device", "->", "machine", ",", "ldcore", "->", "config", ".", "overwidth", ",", "ldcore", "->", "config", ".", "overheight", ",", "(", "bitmap_format", ")", "ldcore", "->", "config", ".", "overformat", ")", ";", "ldcore", "->", "overbitmap", "[", "1", "]", "=", "auto_bitmap_alloc", "(", "device", "->", "machine", ",", "ldcore", "->", "config", ".", "overwidth", ",", "ldcore", "->", "config", ".", "overheight", ",", "(", "bitmap_format", ")", "ldcore", "->", "config", ".", "overformat", ")", ";", "ldcore", "->", "overtex", "=", "render_texture_alloc", "(", "NULL", ",", "NULL", ")", ";", "if", "(", "ldcore", "->", "overtex", "==", "NULL", ")", "fatalerror", "(", "\"", "\"", ")", ";", "}", "}" ]
init_video - initialize the state of the video rendering
[ "init_video", "-", "initialize", "the", "state", "of", "the", "video", "rendering" ]
[ "/* register for VBLANK callbacks */", "/* allocate video frames */", "/* first allocate a YUY16 bitmap at 2x the height */", "/* make a copy of the bitmap that clips out the VBI and horizontal blanking areas */", "/* allocate an empty frame of the same size */", "/* allocate texture for rendering */", "/* allocate palette for applying brightness/contrast/gamma */", "/* allocate overlay */" ]
[ { "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": [] }
816986152a835d29137b3ff290efe47048d3ffda
lofunz/mieme
Reloaded/trunk/src/emu/machine/ldcore.c
[ "Unlicense" ]
C
init_audio
void
static void init_audio(running_device *device) { laserdisc_state *ld = get_safe_token(device); ldcore_data *ldcore = ld->core; /* find the custom audio */ ldcore->audiocustom = device->machine->device(ldcore->config.sound); /* allocate audio buffers */ ldcore->audiomaxsamples = ((UINT64)ldcore->samplerate * 1000000 + ldcore->fps_times_1million - 1) / ldcore->fps_times_1million; ldcore->audiobufsize = ldcore->audiomaxsamples * 4; ldcore->audiobuffer[0] = auto_alloc_array(device->machine, INT16, ldcore->audiobufsize); ldcore->audiobuffer[1] = auto_alloc_array(device->machine, INT16, ldcore->audiobufsize); }
/*------------------------------------------------- init_audio - initialize the state of the audio rendering -------------------------------------------------*/
initialize the state of the audio rendering
[ "initialize", "the", "state", "of", "the", "audio", "rendering" ]
static void init_audio(running_device *device) { laserdisc_state *ld = get_safe_token(device); ldcore_data *ldcore = ld->core; ldcore->audiocustom = device->machine->device(ldcore->config.sound); ldcore->audiomaxsamples = ((UINT64)ldcore->samplerate * 1000000 + ldcore->fps_times_1million - 1) / ldcore->fps_times_1million; ldcore->audiobufsize = ldcore->audiomaxsamples * 4; ldcore->audiobuffer[0] = auto_alloc_array(device->machine, INT16, ldcore->audiobufsize); ldcore->audiobuffer[1] = auto_alloc_array(device->machine, INT16, ldcore->audiobufsize); }
[ "static", "void", "init_audio", "(", "running_device", "*", "device", ")", "{", "laserdisc_state", "*", "ld", "=", "get_safe_token", "(", "device", ")", ";", "ldcore_data", "*", "ldcore", "=", "ld", "->", "core", ";", "ldcore", "->", "audiocustom", "=", "device", "->", "machine", "->", "device", "(", "ldcore", "->", "config", ".", "sound", ")", ";", "ldcore", "->", "audiomaxsamples", "=", "(", "(", "UINT64", ")", "ldcore", "->", "samplerate", "*", "1000000", "+", "ldcore", "->", "fps_times_1million", "-", "1", ")", "/", "ldcore", "->", "fps_times_1million", ";", "ldcore", "->", "audiobufsize", "=", "ldcore", "->", "audiomaxsamples", "*", "4", ";", "ldcore", "->", "audiobuffer", "[", "0", "]", "=", "auto_alloc_array", "(", "device", "->", "machine", ",", "INT16", ",", "ldcore", "->", "audiobufsize", ")", ";", "ldcore", "->", "audiobuffer", "[", "1", "]", "=", "auto_alloc_array", "(", "device", "->", "machine", ",", "INT16", ",", "ldcore", "->", "audiobufsize", ")", ";", "}" ]
init_audio - initialize the state of the audio rendering
[ "init_audio", "-", "initialize", "the", "state", "of", "the", "audio", "rendering" ]
[ "/* find the custom audio */", "/* allocate audio buffers */" ]
[ { "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": [] }
baf98cbcf613df84afe406d5f392ec194d4d652a
lofunz/mieme
Reloaded/trunk/src/emu/sound/disc_dev.c
[ "Unlicense" ]
C
range_to_bias
double
double range_to_bias(double range) { /* Quadratic2D_model */ double bias; // coefficients const double a = 2.3107142857142846E+00; const double b = -1.0714285714278806E-03; const double c = -1.7857142857144002E-03; bias = a; bias += b * range; bias += c * pow(range, 2.0); return bias; }
/* The range to bias and threshold routines were created from testing a real chip. * This data was entered into the function finder routine at www.zunzun.com * to create the following 2 routines */
The range to bias and threshold routines were created from testing a real chip.
[ "The", "range", "to", "bias", "and", "threshold", "routines", "were", "created", "from", "testing", "a", "real", "chip", "." ]
double range_to_bias(double range) { double bias; const double a = 2.3107142857142846E+00; const double b = -1.0714285714278806E-03; const double c = -1.7857142857144002E-03; bias = a; bias += b * range; bias += c * pow(range, 2.0); return bias; }
[ "double", "range_to_bias", "(", "double", "range", ")", "{", "double", "bias", ";", "const", "double", "a", "=", "2.3107142857142846E+00", ";", "const", "double", "b", "=", "-1.0714285714278806E-03", ";", "const", "double", "c", "=", "-1.7857142857144002E-03", ";", "bias", "=", "a", ";", "bias", "+=", "b", "*", "range", ";", "bias", "+=", "c", "*", "pow", "(", "range", ",", "2.0", ")", ";", "return", "bias", ";", "}" ]
The range to bias and threshold routines were created from testing a real chip.
[ "The", "range", "to", "bias", "and", "threshold", "routines", "were", "created", "from", "testing", "a", "real", "chip", "." ]
[ "/* Quadratic2D_model */", "// coefficients\r" ]
[ { "param": "range", "type": "double" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "range", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f795c0b45989dd1b161b64bc694fa0a5885ca701
lofunz/mieme
Reloaded/trunk/src/emu/cpu/rsp/rspdrc.c
[ "Unlicense" ]
C
rspdrc_flush_drc_cache
void
void rspdrc_flush_drc_cache(running_device *device) { rsp_state *rsp = get_safe_token(device); rsp->impstate->cache_dirty = TRUE; }
/*------------------------------------------------- rspdrc_flush_drc_cache - outward-facing accessor to code_flush_cache -------------------------------------------------*/
outward-facing accessor to code_flush_cache
[ "outward", "-", "facing", "accessor", "to", "code_flush_cache" ]
void rspdrc_flush_drc_cache(running_device *device) { rsp_state *rsp = get_safe_token(device); rsp->impstate->cache_dirty = TRUE; }
[ "void", "rspdrc_flush_drc_cache", "(", "running_device", "*", "device", ")", "{", "rsp_state", "*", "rsp", "=", "get_safe_token", "(", "device", ")", ";", "rsp", "->", "impstate", "->", "cache_dirty", "=", "TRUE", ";", "}" ]
rspdrc_flush_drc_cache - outward-facing accessor to code_flush_cache
[ "rspdrc_flush_drc_cache", "-", "outward", "-", "facing", "accessor", "to", "code_flush_cache" ]
[]
[ { "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": [] }
f795c0b45989dd1b161b64bc694fa0a5885ca701
lofunz/mieme
Reloaded/trunk/src/emu/cpu/rsp/rspdrc.c
[ "Unlicense" ]
C
code_flush_cache
void
static void code_flush_cache(rsp_state *rsp) { /* empty the transient cache contents */ drcuml_reset(rsp->impstate->drcuml); /* generate the entry point and out-of-cycles handlers */ static_generate_entry_point(rsp); static_generate_nocode_handler(rsp); static_generate_out_of_cycles(rsp); /* add subroutines for memory accesses */ static_generate_memory_accessor(rsp, 1, FALSE, "read8", &rsp->impstate->read8); static_generate_memory_accessor(rsp, 1, TRUE, "write8", &rsp->impstate->write8); static_generate_memory_accessor(rsp, 2, FALSE, "read16", &rsp->impstate->read16); static_generate_memory_accessor(rsp, 2, TRUE, "write16", &rsp->impstate->write16); static_generate_memory_accessor(rsp, 4, FALSE, "read32", &rsp->impstate->read32); static_generate_memory_accessor(rsp, 4, TRUE, "write32", &rsp->impstate->write32); }
/*------------------------------------------------- code_flush_cache - flush the cache and regenerate static code -------------------------------------------------*/
flush the cache and regenerate static code
[ "flush", "the", "cache", "and", "regenerate", "static", "code" ]
static void code_flush_cache(rsp_state *rsp) { drcuml_reset(rsp->impstate->drcuml); static_generate_entry_point(rsp); static_generate_nocode_handler(rsp); static_generate_out_of_cycles(rsp); static_generate_memory_accessor(rsp, 1, FALSE, "read8", &rsp->impstate->read8); static_generate_memory_accessor(rsp, 1, TRUE, "write8", &rsp->impstate->write8); static_generate_memory_accessor(rsp, 2, FALSE, "read16", &rsp->impstate->read16); static_generate_memory_accessor(rsp, 2, TRUE, "write16", &rsp->impstate->write16); static_generate_memory_accessor(rsp, 4, FALSE, "read32", &rsp->impstate->read32); static_generate_memory_accessor(rsp, 4, TRUE, "write32", &rsp->impstate->write32); }
[ "static", "void", "code_flush_cache", "(", "rsp_state", "*", "rsp", ")", "{", "drcuml_reset", "(", "rsp", "->", "impstate", "->", "drcuml", ")", ";", "static_generate_entry_point", "(", "rsp", ")", ";", "static_generate_nocode_handler", "(", "rsp", ")", ";", "static_generate_out_of_cycles", "(", "rsp", ")", ";", "static_generate_memory_accessor", "(", "rsp", ",", "1", ",", "FALSE", ",", "\"", "\"", ",", "&", "rsp", "->", "impstate", "->", "read8", ")", ";", "static_generate_memory_accessor", "(", "rsp", ",", "1", ",", "TRUE", ",", "\"", "\"", ",", "&", "rsp", "->", "impstate", "->", "write8", ")", ";", "static_generate_memory_accessor", "(", "rsp", ",", "2", ",", "FALSE", ",", "\"", "\"", ",", "&", "rsp", "->", "impstate", "->", "read16", ")", ";", "static_generate_memory_accessor", "(", "rsp", ",", "2", ",", "TRUE", ",", "\"", "\"", ",", "&", "rsp", "->", "impstate", "->", "write16", ")", ";", "static_generate_memory_accessor", "(", "rsp", ",", "4", ",", "FALSE", ",", "\"", "\"", ",", "&", "rsp", "->", "impstate", "->", "read32", ")", ";", "static_generate_memory_accessor", "(", "rsp", ",", "4", ",", "TRUE", ",", "\"", "\"", ",", "&", "rsp", "->", "impstate", "->", "write32", ")", ";", "}" ]
code_flush_cache - flush the cache and regenerate static code
[ "code_flush_cache", "-", "flush", "the", "cache", "and", "regenerate", "static", "code" ]
[ "/* empty the transient cache contents */", "/* generate the entry point and out-of-cycles handlers */", "/* add subroutines for memory accesses */" ]
[ { "param": "rsp", "type": "rsp_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rsp", "type": "rsp_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f795c0b45989dd1b161b64bc694fa0a5885ca701
lofunz/mieme
Reloaded/trunk/src/emu/cpu/rsp/rspdrc.c
[ "Unlicense" ]
C
code_compile_block
void
static void code_compile_block(rsp_state *rsp, offs_t pc) { drcuml_state *drcuml = rsp->impstate->drcuml; compiler_state compiler = { 0 }; const opcode_desc *seqhead, *seqlast; const opcode_desc *desclist; int override = FALSE; drcuml_block *block; jmp_buf errorbuf; profiler_mark_start(PROFILER_DRC_COMPILE); /* get a description of this sequence */ desclist = drcfe_describe_code(rsp->impstate->drcfe, pc); /* if we get an error back, flush the cache and try again */ if (setjmp(errorbuf) != 0) { code_flush_cache(rsp); } /* start the block */ block = drcuml_block_begin(drcuml, 8192, &errorbuf); /* loop until we get through all instruction sequences */ for (seqhead = desclist; seqhead != NULL; seqhead = seqlast->next) { const opcode_desc *curdesc; UINT32 nextpc; /* add a code log entry */ if (LOG_UML) UML_COMMENT(block, "-------------------------"); // comment /* determine the last instruction in this sequence */ for (seqlast = seqhead; seqlast != NULL; seqlast = seqlast->next) if (seqlast->flags & OPFLAG_END_SEQUENCE) break; assert(seqlast != NULL); /* if we don't have a hash for this mode/pc, or if we are overriding all, add one */ if (override || !drcuml_hash_exists(drcuml, 0, seqhead->pc)) UML_HASH(block, 0, seqhead->pc); // hash mode,pc /* if we already have a hash, and this is the first sequence, assume that we */ /* are recompiling due to being out of sync and allow future overrides */ else if (seqhead == desclist) { override = TRUE; UML_HASH(block, 0, seqhead->pc); // hash mode,pc } /* otherwise, redispatch to that fixed PC and skip the rest of the processing */ else { UML_LABEL(block, seqhead->pc | 0x80000000); // label seqhead->pc UML_HASHJMP(block, IMM(0), IMM(seqhead->pc), rsp->impstate->nocode); // hashjmp <0>,seqhead->pc,nocode continue; } /* validate this code block if we're not pointing into ROM */ if (memory_get_write_ptr(rsp->program, seqhead->physpc) != NULL) generate_checksum_block(rsp, block, &compiler, seqhead, seqlast); /* label this instruction, if it may be jumped to locally */ if (seqhead->flags & OPFLAG_IS_BRANCH_TARGET) UML_LABEL(block, seqhead->pc | 0x80000000); // label seqhead->pc /* iterate over instructions in the sequence and compile them */ for (curdesc = seqhead; curdesc != seqlast->next; curdesc = curdesc->next) generate_sequence_instruction(rsp, block, &compiler, curdesc); /* if we need to return to the start, do it */ if (seqlast->flags & OPFLAG_RETURN_TO_START) nextpc = pc; /* otherwise we just go to the next instruction */ else nextpc = seqlast->pc + (seqlast->skipslots + 1) * 4; /* count off cycles and go there */ generate_update_cycles(rsp, block, &compiler, IMM(nextpc), TRUE); // <subtract cycles> /* if the last instruction can change modes, use a variable mode; otherwise, assume the same mode */ if (seqlast->next == NULL || seqlast->next->pc != nextpc) UML_HASHJMP(block, IMM(0), IMM(nextpc), rsp->impstate->nocode); // hashjmp <mode>,nextpc,nocode } /* end the sequence */ drcuml_block_end(block); profiler_mark_end(); }
/*------------------------------------------------- code_compile_block - compile a block of the given mode at the specified pc -------------------------------------------------*/
compile a block of the given mode at the specified pc
[ "compile", "a", "block", "of", "the", "given", "mode", "at", "the", "specified", "pc" ]
static void code_compile_block(rsp_state *rsp, offs_t pc) { drcuml_state *drcuml = rsp->impstate->drcuml; compiler_state compiler = { 0 }; const opcode_desc *seqhead, *seqlast; const opcode_desc *desclist; int override = FALSE; drcuml_block *block; jmp_buf errorbuf; profiler_mark_start(PROFILER_DRC_COMPILE); desclist = drcfe_describe_code(rsp->impstate->drcfe, pc); if (setjmp(errorbuf) != 0) { code_flush_cache(rsp); } block = drcuml_block_begin(drcuml, 8192, &errorbuf); for (seqhead = desclist; seqhead != NULL; seqhead = seqlast->next) { const opcode_desc *curdesc; UINT32 nextpc; if (LOG_UML) UML_COMMENT(block, "-------------------------"); for (seqlast = seqhead; seqlast != NULL; seqlast = seqlast->next) if (seqlast->flags & OPFLAG_END_SEQUENCE) break; assert(seqlast != NULL); if (override || !drcuml_hash_exists(drcuml, 0, seqhead->pc)) UML_HASH(block, 0, seqhead->pc); else if (seqhead == desclist) { override = TRUE; UML_HASH(block, 0, seqhead->pc); } else { UML_LABEL(block, seqhead->pc | 0x80000000); UML_HASHJMP(block, IMM(0), IMM(seqhead->pc), rsp->impstate->nocode); continue; } if (memory_get_write_ptr(rsp->program, seqhead->physpc) != NULL) generate_checksum_block(rsp, block, &compiler, seqhead, seqlast); if (seqhead->flags & OPFLAG_IS_BRANCH_TARGET) UML_LABEL(block, seqhead->pc | 0x80000000); for (curdesc = seqhead; curdesc != seqlast->next; curdesc = curdesc->next) generate_sequence_instruction(rsp, block, &compiler, curdesc); if (seqlast->flags & OPFLAG_RETURN_TO_START) nextpc = pc; else nextpc = seqlast->pc + (seqlast->skipslots + 1) * 4; generate_update_cycles(rsp, block, &compiler, IMM(nextpc), TRUE); if (seqlast->next == NULL || seqlast->next->pc != nextpc) UML_HASHJMP(block, IMM(0), IMM(nextpc), rsp->impstate->nocode); } drcuml_block_end(block); profiler_mark_end(); }
[ "static", "void", "code_compile_block", "(", "rsp_state", "*", "rsp", ",", "offs_t", "pc", ")", "{", "drcuml_state", "*", "drcuml", "=", "rsp", "->", "impstate", "->", "drcuml", ";", "compiler_state", "compiler", "=", "{", "0", "}", ";", "const", "opcode_desc", "*", "seqhead", ",", "*", "seqlast", ";", "const", "opcode_desc", "*", "desclist", ";", "int", "override", "=", "FALSE", ";", "drcuml_block", "*", "block", ";", "jmp_buf", "errorbuf", ";", "profiler_mark_start", "(", "PROFILER_DRC_COMPILE", ")", ";", "desclist", "=", "drcfe_describe_code", "(", "rsp", "->", "impstate", "->", "drcfe", ",", "pc", ")", ";", "if", "(", "setjmp", "(", "errorbuf", ")", "!=", "0", ")", "{", "code_flush_cache", "(", "rsp", ")", ";", "}", "block", "=", "drcuml_block_begin", "(", "drcuml", ",", "8192", ",", "&", "errorbuf", ")", ";", "for", "(", "seqhead", "=", "desclist", ";", "seqhead", "!=", "NULL", ";", "seqhead", "=", "seqlast", "->", "next", ")", "{", "const", "opcode_desc", "*", "curdesc", ";", "UINT32", "nextpc", ";", "if", "(", "LOG_UML", ")", "UML_COMMENT", "(", "block", ",", "\"", "\"", ")", ";", "for", "(", "seqlast", "=", "seqhead", ";", "seqlast", "!=", "NULL", ";", "seqlast", "=", "seqlast", "->", "next", ")", "if", "(", "seqlast", "->", "flags", "&", "OPFLAG_END_SEQUENCE", ")", "break", ";", "assert", "(", "seqlast", "!=", "NULL", ")", ";", "if", "(", "override", "||", "!", "drcuml_hash_exists", "(", "drcuml", ",", "0", ",", "seqhead", "->", "pc", ")", ")", "UML_HASH", "(", "block", ",", "0", ",", "seqhead", "->", "pc", ")", ";", "else", "if", "(", "seqhead", "==", "desclist", ")", "{", "override", "=", "TRUE", ";", "UML_HASH", "(", "block", ",", "0", ",", "seqhead", "->", "pc", ")", ";", "}", "else", "{", "UML_LABEL", "(", "block", ",", "seqhead", "->", "pc", "|", "0x80000000", ")", ";", "UML_HASHJMP", "(", "block", ",", "IMM", "(", "0", ")", ",", "IMM", "(", "seqhead", "->", "pc", ")", ",", "rsp", "->", "impstate", "->", "nocode", ")", ";", "continue", ";", "}", "if", "(", "memory_get_write_ptr", "(", "rsp", "->", "program", ",", "seqhead", "->", "physpc", ")", "!=", "NULL", ")", "generate_checksum_block", "(", "rsp", ",", "block", ",", "&", "compiler", ",", "seqhead", ",", "seqlast", ")", ";", "if", "(", "seqhead", "->", "flags", "&", "OPFLAG_IS_BRANCH_TARGET", ")", "UML_LABEL", "(", "block", ",", "seqhead", "->", "pc", "|", "0x80000000", ")", ";", "for", "(", "curdesc", "=", "seqhead", ";", "curdesc", "!=", "seqlast", "->", "next", ";", "curdesc", "=", "curdesc", "->", "next", ")", "generate_sequence_instruction", "(", "rsp", ",", "block", ",", "&", "compiler", ",", "curdesc", ")", ";", "if", "(", "seqlast", "->", "flags", "&", "OPFLAG_RETURN_TO_START", ")", "nextpc", "=", "pc", ";", "else", "nextpc", "=", "seqlast", "->", "pc", "+", "(", "seqlast", "->", "skipslots", "+", "1", ")", "*", "4", ";", "generate_update_cycles", "(", "rsp", ",", "block", ",", "&", "compiler", ",", "IMM", "(", "nextpc", ")", ",", "TRUE", ")", ";", "if", "(", "seqlast", "->", "next", "==", "NULL", "||", "seqlast", "->", "next", "->", "pc", "!=", "nextpc", ")", "UML_HASHJMP", "(", "block", ",", "IMM", "(", "0", ")", ",", "IMM", "(", "nextpc", ")", ",", "rsp", "->", "impstate", "->", "nocode", ")", ";", "}", "drcuml_block_end", "(", "block", ")", ";", "profiler_mark_end", "(", ")", ";", "}" ]
code_compile_block - compile a block of the given mode at the specified pc
[ "code_compile_block", "-", "compile", "a", "block", "of", "the", "given", "mode", "at", "the", "specified", "pc" ]
[ "/* get a description of this sequence */", "/* if we get an error back, flush the cache and try again */", "/* start the block */", "/* loop until we get through all instruction sequences */", "/* add a code log entry */", "// comment\r", "/* determine the last instruction in this sequence */", "/* if we don't have a hash for this mode/pc, or if we are overriding all, add one */", "// hash mode,pc\r", "/* if we already have a hash, and this is the first sequence, assume that we */", "/* are recompiling due to being out of sync and allow future overrides */", "// hash mode,pc\r", "/* otherwise, redispatch to that fixed PC and skip the rest of the processing */", "// label seqhead->pc\r", "// hashjmp <0>,seqhead->pc,nocode\r", "/* validate this code block if we're not pointing into ROM */", "/* label this instruction, if it may be jumped to locally */", "// label seqhead->pc\r", "/* iterate over instructions in the sequence and compile them */", "/* if we need to return to the start, do it */", "/* otherwise we just go to the next instruction */", "/* count off cycles and go there */", "// <subtract cycles>\r", "/* if the last instruction can change modes, use a variable mode; otherwise, assume the same mode */", "// hashjmp <mode>,nextpc,nocode\r", "/* end the sequence */" ]
[ { "param": "rsp", "type": "rsp_state" }, { "param": "pc", "type": "offs_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rsp", "type": "rsp_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pc", "type": "offs_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f795c0b45989dd1b161b64bc694fa0a5885ca701
lofunz/mieme
Reloaded/trunk/src/emu/cpu/rsp/rspdrc.c
[ "Unlicense" ]
C
static_generate_nocode_handler
void
static void static_generate_nocode_handler(rsp_state *rsp) { drcuml_state *drcuml = rsp->impstate->drcuml; drcuml_block *block; jmp_buf errorbuf; /* if we get an error back, we're screwed */ if (setjmp(errorbuf) != 0) { fatalerror("Unrecoverable error in static_generate_nocode_handler"); } /* begin generating */ block = drcuml_block_begin(drcuml, 10, &errorbuf); /* generate a hash jump via the current mode and PC */ alloc_handle(drcuml, &rsp->impstate->nocode, "nocode"); UML_HANDLE(block, rsp->impstate->nocode); // handle nocode UML_GETEXP(block, IREG(0)); // getexp i0 UML_MOV(block, MEM(&rsp->pc), IREG(0)); // mov [pc],i0 save_fast_iregs(rsp, block); UML_EXIT(block, IMM(EXECUTE_MISSING_CODE)); // exit EXECUTE_MISSING_CODE drcuml_block_end(block); }
/*------------------------------------------------- static_generate_nocode_handler - generate an exception handler for "out of code" -------------------------------------------------*/
generate an exception handler for "out of code"
[ "generate", "an", "exception", "handler", "for", "\"", "out", "of", "code", "\"" ]
static void static_generate_nocode_handler(rsp_state *rsp) { drcuml_state *drcuml = rsp->impstate->drcuml; drcuml_block *block; jmp_buf errorbuf; if (setjmp(errorbuf) != 0) { fatalerror("Unrecoverable error in static_generate_nocode_handler"); } block = drcuml_block_begin(drcuml, 10, &errorbuf); alloc_handle(drcuml, &rsp->impstate->nocode, "nocode"); UML_HANDLE(block, rsp->impstate->nocode); UML_GETEXP(block, IREG(0)); UML_MOV(block, MEM(&rsp->pc), IREG(0)); save_fast_iregs(rsp, block); UML_EXIT(block, IMM(EXECUTE_MISSING_CODE)); drcuml_block_end(block); }
[ "static", "void", "static_generate_nocode_handler", "(", "rsp_state", "*", "rsp", ")", "{", "drcuml_state", "*", "drcuml", "=", "rsp", "->", "impstate", "->", "drcuml", ";", "drcuml_block", "*", "block", ";", "jmp_buf", "errorbuf", ";", "if", "(", "setjmp", "(", "errorbuf", ")", "!=", "0", ")", "{", "fatalerror", "(", "\"", "\"", ")", ";", "}", "block", "=", "drcuml_block_begin", "(", "drcuml", ",", "10", ",", "&", "errorbuf", ")", ";", "alloc_handle", "(", "drcuml", ",", "&", "rsp", "->", "impstate", "->", "nocode", ",", "\"", "\"", ")", ";", "UML_HANDLE", "(", "block", ",", "rsp", "->", "impstate", "->", "nocode", ")", ";", "UML_GETEXP", "(", "block", ",", "IREG", "(", "0", ")", ")", ";", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "rsp", "->", "pc", ")", ",", "IREG", "(", "0", ")", ")", ";", "save_fast_iregs", "(", "rsp", ",", "block", ")", ";", "UML_EXIT", "(", "block", ",", "IMM", "(", "EXECUTE_MISSING_CODE", ")", ")", ";", "drcuml_block_end", "(", "block", ")", ";", "}" ]
static_generate_nocode_handler - generate an exception handler for "out of code"
[ "static_generate_nocode_handler", "-", "generate", "an", "exception", "handler", "for", "\"", "out", "of", "code", "\"" ]
[ "/* if we get an error back, we're screwed */", "/* begin generating */", "/* generate a hash jump via the current mode and PC */", "// handle nocode\r", "// getexp i0\r", "// mov [pc],i0\r", "// exit EXECUTE_MISSING_CODE\r" ]
[ { "param": "rsp", "type": "rsp_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rsp", "type": "rsp_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f795c0b45989dd1b161b64bc694fa0a5885ca701
lofunz/mieme
Reloaded/trunk/src/emu/cpu/rsp/rspdrc.c
[ "Unlicense" ]
C
static_generate_out_of_cycles
void
static void static_generate_out_of_cycles(rsp_state *rsp) { drcuml_state *drcuml = rsp->impstate->drcuml; drcuml_block *block; jmp_buf errorbuf; /* if we get an error back, we're screwed */ if (setjmp(errorbuf) != 0) { fatalerror("Unrecoverable error in static_generate_out_of_cycles"); } /* begin generating */ block = drcuml_block_begin(drcuml, 10, &errorbuf); /* generate a hash jump via the current mode and PC */ alloc_handle(drcuml, &rsp->impstate->out_of_cycles, "out_of_cycles"); UML_HANDLE(block, rsp->impstate->out_of_cycles); // handle out_of_cycles UML_GETEXP(block, IREG(0)); // getexp i0 UML_MOV(block, MEM(&rsp->pc), IREG(0)); // mov <pc>,i0 save_fast_iregs(rsp, block); UML_EXIT(block, IMM(EXECUTE_OUT_OF_CYCLES)); // exit EXECUTE_OUT_OF_CYCLES drcuml_block_end(block); }
/*------------------------------------------------- static_generate_out_of_cycles - generate an out of cycles exception handler -------------------------------------------------*/
generate an out of cycles exception handler
[ "generate", "an", "out", "of", "cycles", "exception", "handler" ]
static void static_generate_out_of_cycles(rsp_state *rsp) { drcuml_state *drcuml = rsp->impstate->drcuml; drcuml_block *block; jmp_buf errorbuf; if (setjmp(errorbuf) != 0) { fatalerror("Unrecoverable error in static_generate_out_of_cycles"); } block = drcuml_block_begin(drcuml, 10, &errorbuf); alloc_handle(drcuml, &rsp->impstate->out_of_cycles, "out_of_cycles"); UML_HANDLE(block, rsp->impstate->out_of_cycles); UML_GETEXP(block, IREG(0)); UML_MOV(block, MEM(&rsp->pc), IREG(0)); save_fast_iregs(rsp, block); UML_EXIT(block, IMM(EXECUTE_OUT_OF_CYCLES)); drcuml_block_end(block); }
[ "static", "void", "static_generate_out_of_cycles", "(", "rsp_state", "*", "rsp", ")", "{", "drcuml_state", "*", "drcuml", "=", "rsp", "->", "impstate", "->", "drcuml", ";", "drcuml_block", "*", "block", ";", "jmp_buf", "errorbuf", ";", "if", "(", "setjmp", "(", "errorbuf", ")", "!=", "0", ")", "{", "fatalerror", "(", "\"", "\"", ")", ";", "}", "block", "=", "drcuml_block_begin", "(", "drcuml", ",", "10", ",", "&", "errorbuf", ")", ";", "alloc_handle", "(", "drcuml", ",", "&", "rsp", "->", "impstate", "->", "out_of_cycles", ",", "\"", "\"", ")", ";", "UML_HANDLE", "(", "block", ",", "rsp", "->", "impstate", "->", "out_of_cycles", ")", ";", "UML_GETEXP", "(", "block", ",", "IREG", "(", "0", ")", ")", ";", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "rsp", "->", "pc", ")", ",", "IREG", "(", "0", ")", ")", ";", "save_fast_iregs", "(", "rsp", ",", "block", ")", ";", "UML_EXIT", "(", "block", ",", "IMM", "(", "EXECUTE_OUT_OF_CYCLES", ")", ")", ";", "drcuml_block_end", "(", "block", ")", ";", "}" ]
static_generate_out_of_cycles - generate an out of cycles exception handler
[ "static_generate_out_of_cycles", "-", "generate", "an", "out", "of", "cycles", "exception", "handler" ]
[ "/* if we get an error back, we're screwed */", "/* begin generating */", "/* generate a hash jump via the current mode and PC */", "// handle out_of_cycles\r", "// getexp i0\r", "// mov <pc>,i0\r", "// exit EXECUTE_OUT_OF_CYCLES\r" ]
[ { "param": "rsp", "type": "rsp_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rsp", "type": "rsp_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f795c0b45989dd1b161b64bc694fa0a5885ca701
lofunz/mieme
Reloaded/trunk/src/emu/cpu/rsp/rspdrc.c
[ "Unlicense" ]
C
generate_update_cycles
void
static void generate_update_cycles(rsp_state *rsp, drcuml_block *block, compiler_state *compiler, drcuml_ptype ptype, UINT64 pvalue, int allow_exception) { /* account for cycles */ if (compiler->cycles > 0) { UML_SUB(block, MEM(&rsp->icount), MEM(&rsp->icount), MAPVAR_CYCLES); // sub icount,icount,cycles UML_MAPVAR(block, MAPVAR_CYCLES, 0); // mapvar cycles,0 UML_EXHc(block, IF_S, rsp->impstate->out_of_cycles, PARAM(ptype, pvalue)); } compiler->cycles = 0; }
/*------------------------------------------------- generate_update_cycles - generate code to subtract cycles from the icount and generate an exception if out -------------------------------------------------*/
generate code to subtract cycles from the icount and generate an exception if out
[ "generate", "code", "to", "subtract", "cycles", "from", "the", "icount", "and", "generate", "an", "exception", "if", "out" ]
static void generate_update_cycles(rsp_state *rsp, drcuml_block *block, compiler_state *compiler, drcuml_ptype ptype, UINT64 pvalue, int allow_exception) { if (compiler->cycles > 0) { UML_SUB(block, MEM(&rsp->icount), MEM(&rsp->icount), MAPVAR_CYCLES); UML_MAPVAR(block, MAPVAR_CYCLES, 0); UML_EXHc(block, IF_S, rsp->impstate->out_of_cycles, PARAM(ptype, pvalue)); } compiler->cycles = 0; }
[ "static", "void", "generate_update_cycles", "(", "rsp_state", "*", "rsp", ",", "drcuml_block", "*", "block", ",", "compiler_state", "*", "compiler", ",", "drcuml_ptype", "ptype", ",", "UINT64", "pvalue", ",", "int", "allow_exception", ")", "{", "if", "(", "compiler", "->", "cycles", ">", "0", ")", "{", "UML_SUB", "(", "block", ",", "MEM", "(", "&", "rsp", "->", "icount", ")", ",", "MEM", "(", "&", "rsp", "->", "icount", ")", ",", "MAPVAR_CYCLES", ")", ";", "UML_MAPVAR", "(", "block", ",", "MAPVAR_CYCLES", ",", "0", ")", ";", "UML_EXHc", "(", "block", ",", "IF_S", ",", "rsp", "->", "impstate", "->", "out_of_cycles", ",", "PARAM", "(", "ptype", ",", "pvalue", ")", ")", ";", "}", "compiler", "->", "cycles", "=", "0", ";", "}" ]
generate_update_cycles - generate code to subtract cycles from the icount and generate an exception if out
[ "generate_update_cycles", "-", "generate", "code", "to", "subtract", "cycles", "from", "the", "icount", "and", "generate", "an", "exception", "if", "out" ]
[ "/* account for cycles */", "// sub icount,icount,cycles\r", "// mapvar cycles,0\r" ]
[ { "param": "rsp", "type": "rsp_state" }, { "param": "block", "type": "drcuml_block" }, { "param": "compiler", "type": "compiler_state" }, { "param": "ptype", "type": "drcuml_ptype" }, { "param": "pvalue", "type": "UINT64" }, { "param": "allow_exception", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rsp", "type": "rsp_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "compiler", "type": "compiler_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ptype", "type": "drcuml_ptype", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pvalue", "type": "UINT64", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "allow_exception", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f795c0b45989dd1b161b64bc694fa0a5885ca701
lofunz/mieme
Reloaded/trunk/src/emu/cpu/rsp/rspdrc.c
[ "Unlicense" ]
C
generate_checksum_block
void
static void generate_checksum_block(rsp_state *rsp, drcuml_block *block, compiler_state *compiler, const opcode_desc *seqhead, const opcode_desc *seqlast) { const opcode_desc *curdesc; if (LOG_UML) { UML_COMMENT(block, "[Validation for %08X]", seqhead->pc | 0x1000); // comment } /* loose verify or single instruction: just compare and fail */ if (!(rsp->impstate->drcoptions & RSPDRC_STRICT_VERIFY) || seqhead->next == NULL) { if (!(seqhead->flags & OPFLAG_VIRTUAL_NOOP)) { void *base = memory_decrypted_read_ptr(rsp->program, seqhead->physpc | 0x1000); UML_LOAD(block, IREG(0), base, IMM(0), DWORD); // load i0,base,0,dword UML_CMP(block, IREG(0), IMM(seqhead->opptr.l[0])); // cmp i0,opptr[0] UML_EXHc(block, IF_NE, rsp->impstate->nocode, IMM(epc(seqhead))); // exne nocode,seqhead->pc } } /* full verification; sum up everything */ else { UINT32 sum = 0; void *base = memory_decrypted_read_ptr(rsp->program, seqhead->physpc | 0x1000); UML_LOAD(block, IREG(0), base, IMM(0), DWORD); // load i0,base,0,dword sum += seqhead->opptr.l[0]; for (curdesc = seqhead->next; curdesc != seqlast->next; curdesc = curdesc->next) if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP)) { base = memory_decrypted_read_ptr(rsp->program, curdesc->physpc | 0x1000); UML_LOAD(block, IREG(1), base, IMM(0), DWORD); // load i1,base,dword UML_ADD(block, IREG(0), IREG(0), IREG(1)); // add i0,i0,i1 sum += curdesc->opptr.l[0]; } UML_CMP(block, IREG(0), IMM(sum)); // cmp i0,sum UML_EXHc(block, IF_NE, rsp->impstate->nocode, IMM(epc(seqhead))); // exne nocode,seqhead->pc } }
/*------------------------------------------------- generate_checksum_block - generate code to validate a sequence of opcodes -------------------------------------------------*/
generate code to validate a sequence of opcodes
[ "generate", "code", "to", "validate", "a", "sequence", "of", "opcodes" ]
static void generate_checksum_block(rsp_state *rsp, drcuml_block *block, compiler_state *compiler, const opcode_desc *seqhead, const opcode_desc *seqlast) { const opcode_desc *curdesc; if (LOG_UML) { UML_COMMENT(block, "[Validation for %08X]", seqhead->pc | 0x1000); } if (!(rsp->impstate->drcoptions & RSPDRC_STRICT_VERIFY) || seqhead->next == NULL) { if (!(seqhead->flags & OPFLAG_VIRTUAL_NOOP)) { void *base = memory_decrypted_read_ptr(rsp->program, seqhead->physpc | 0x1000); UML_LOAD(block, IREG(0), base, IMM(0), DWORD); UML_CMP(block, IREG(0), IMM(seqhead->opptr.l[0])); UML_EXHc(block, IF_NE, rsp->impstate->nocode, IMM(epc(seqhead))); } } else { UINT32 sum = 0; void *base = memory_decrypted_read_ptr(rsp->program, seqhead->physpc | 0x1000); UML_LOAD(block, IREG(0), base, IMM(0), DWORD); sum += seqhead->opptr.l[0]; for (curdesc = seqhead->next; curdesc != seqlast->next; curdesc = curdesc->next) if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP)) { base = memory_decrypted_read_ptr(rsp->program, curdesc->physpc | 0x1000); UML_LOAD(block, IREG(1), base, IMM(0), DWORD); UML_ADD(block, IREG(0), IREG(0), IREG(1)); sum += curdesc->opptr.l[0]; } UML_CMP(block, IREG(0), IMM(sum)); UML_EXHc(block, IF_NE, rsp->impstate->nocode, IMM(epc(seqhead))); } }
[ "static", "void", "generate_checksum_block", "(", "rsp_state", "*", "rsp", ",", "drcuml_block", "*", "block", ",", "compiler_state", "*", "compiler", ",", "const", "opcode_desc", "*", "seqhead", ",", "const", "opcode_desc", "*", "seqlast", ")", "{", "const", "opcode_desc", "*", "curdesc", ";", "if", "(", "LOG_UML", ")", "{", "UML_COMMENT", "(", "block", ",", "\"", "\"", ",", "seqhead", "->", "pc", "|", "0x1000", ")", ";", "}", "if", "(", "!", "(", "rsp", "->", "impstate", "->", "drcoptions", "&", "RSPDRC_STRICT_VERIFY", ")", "||", "seqhead", "->", "next", "==", "NULL", ")", "{", "if", "(", "!", "(", "seqhead", "->", "flags", "&", "OPFLAG_VIRTUAL_NOOP", ")", ")", "{", "void", "*", "base", "=", "memory_decrypted_read_ptr", "(", "rsp", "->", "program", ",", "seqhead", "->", "physpc", "|", "0x1000", ")", ";", "UML_LOAD", "(", "block", ",", "IREG", "(", "0", ")", ",", "base", ",", "IMM", "(", "0", ")", ",", "DWORD", ")", ";", "UML_CMP", "(", "block", ",", "IREG", "(", "0", ")", ",", "IMM", "(", "seqhead", "->", "opptr", ".", "l", "[", "0", "]", ")", ")", ";", "UML_EXHc", "(", "block", ",", "IF_NE", ",", "rsp", "->", "impstate", "->", "nocode", ",", "IMM", "(", "epc", "(", "seqhead", ")", ")", ")", ";", "}", "}", "else", "{", "UINT32", "sum", "=", "0", ";", "void", "*", "base", "=", "memory_decrypted_read_ptr", "(", "rsp", "->", "program", ",", "seqhead", "->", "physpc", "|", "0x1000", ")", ";", "UML_LOAD", "(", "block", ",", "IREG", "(", "0", ")", ",", "base", ",", "IMM", "(", "0", ")", ",", "DWORD", ")", ";", "sum", "+=", "seqhead", "->", "opptr", ".", "l", "[", "0", "]", ";", "for", "(", "curdesc", "=", "seqhead", "->", "next", ";", "curdesc", "!=", "seqlast", "->", "next", ";", "curdesc", "=", "curdesc", "->", "next", ")", "if", "(", "!", "(", "curdesc", "->", "flags", "&", "OPFLAG_VIRTUAL_NOOP", ")", ")", "{", "base", "=", "memory_decrypted_read_ptr", "(", "rsp", "->", "program", ",", "curdesc", "->", "physpc", "|", "0x1000", ")", ";", "UML_LOAD", "(", "block", ",", "IREG", "(", "1", ")", ",", "base", ",", "IMM", "(", "0", ")", ",", "DWORD", ")", ";", "UML_ADD", "(", "block", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "1", ")", ")", ";", "sum", "+=", "curdesc", "->", "opptr", ".", "l", "[", "0", "]", ";", "}", "UML_CMP", "(", "block", ",", "IREG", "(", "0", ")", ",", "IMM", "(", "sum", ")", ")", ";", "UML_EXHc", "(", "block", ",", "IF_NE", ",", "rsp", "->", "impstate", "->", "nocode", ",", "IMM", "(", "epc", "(", "seqhead", ")", ")", ")", ";", "}", "}" ]
generate_checksum_block - generate code to validate a sequence of opcodes
[ "generate_checksum_block", "-", "generate", "code", "to", "validate", "a", "sequence", "of", "opcodes" ]
[ "// comment\r", "/* loose verify or single instruction: just compare and fail */", "// load i0,base,0,dword\r", "// cmp i0,opptr[0]\r", "// exne nocode,seqhead->pc\r", "/* full verification; sum up everything */", "// load i0,base,0,dword\r", "// load i1,base,dword\r", "// add i0,i0,i1\r", "// cmp i0,sum\r", "// exne nocode,seqhead->pc\r" ]
[ { "param": "rsp", "type": "rsp_state" }, { "param": "block", "type": "drcuml_block" }, { "param": "compiler", "type": "compiler_state" }, { "param": "seqhead", "type": "opcode_desc" }, { "param": "seqlast", "type": "opcode_desc" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rsp", "type": "rsp_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "compiler", "type": "compiler_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "seqhead", "type": "opcode_desc", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "seqlast", "type": "opcode_desc", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f795c0b45989dd1b161b64bc694fa0a5885ca701
lofunz/mieme
Reloaded/trunk/src/emu/cpu/rsp/rspdrc.c
[ "Unlicense" ]
C
generate_sequence_instruction
void
static void generate_sequence_instruction(rsp_state *rsp, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) { offs_t expc; /* add an entry for the log */ if (LOG_UML && !(desc->flags & OPFLAG_VIRTUAL_NOOP)) log_add_disasm_comment(rsp, block, desc->pc, desc->opptr.l[0]); /* set the PC map variable */ expc = (desc->flags & OPFLAG_IN_DELAY_SLOT) ? desc->pc - 3 : desc->pc; UML_MAPVAR(block, MAPVAR_PC, expc); // mapvar PC,expc /* accumulate total cycles */ compiler->cycles += desc->cycles; /* update the icount map variable */ UML_MAPVAR(block, MAPVAR_CYCLES, compiler->cycles); // mapvar CYCLES,compiler->cycles /* if we are debugging, call the debugger */ if ((rsp->device->machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) { UML_MOV(block, MEM(&rsp->pc), IMM(desc->pc)); // mov [pc],desc->pc save_fast_iregs(rsp, block); UML_DEBUG(block, IMM(desc->pc)); // debug desc->pc } /* if we hit an unmapped address, fatal error */ #if 0 if (desc->flags & OPFLAG_COMPILER_UNMAPPED) { UML_MOV(block, MEM(&rsp->pc), IMM(desc->pc)); // mov [pc],desc->pc save_fast_iregs(rsp, block); UML_EXIT(block, IMM(EXECUTE_UNMAPPED_CODE)); // exit EXECUTE_UNMAPPED_CODE } #endif /* otherwise, unless this is a virtual no-op, it's a regular instruction */ /*else*/ if (!(desc->flags & OPFLAG_VIRTUAL_NOOP)) { /* compile the instruction */ if (!generate_opcode(rsp, block, compiler, desc)) { UML_MOV(block, MEM(&rsp->pc), IMM(desc->pc)); // mov [pc],desc->pc UML_MOV(block, MEM(&rsp->impstate->arg0), IMM(desc->opptr.l[0])); // mov [arg0],desc->opptr.l UML_CALLC(block, cfunc_unimplemented, rsp); // callc cfunc_unimplemented } } }
/*------------------------------------------------- generate_sequence_instruction - generate code for a single instruction in a sequence -------------------------------------------------*/
generate code for a single instruction in a sequence
[ "generate", "code", "for", "a", "single", "instruction", "in", "a", "sequence" ]
static void generate_sequence_instruction(rsp_state *rsp, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) { offs_t expc; if (LOG_UML && !(desc->flags & OPFLAG_VIRTUAL_NOOP)) log_add_disasm_comment(rsp, block, desc->pc, desc->opptr.l[0]); expc = (desc->flags & OPFLAG_IN_DELAY_SLOT) ? desc->pc - 3 : desc->pc; UML_MAPVAR(block, MAPVAR_PC, expc); compiler->cycles += desc->cycles; UML_MAPVAR(block, MAPVAR_CYCLES, compiler->cycles); if ((rsp->device->machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) { UML_MOV(block, MEM(&rsp->pc), IMM(desc->pc)); save_fast_iregs(rsp, block); UML_DEBUG(block, IMM(desc->pc)); } #if 0 if (desc->flags & OPFLAG_COMPILER_UNMAPPED) { UML_MOV(block, MEM(&rsp->pc), IMM(desc->pc)); save_fast_iregs(rsp, block); UML_EXIT(block, IMM(EXECUTE_UNMAPPED_CODE)); } #endif if (!(desc->flags & OPFLAG_VIRTUAL_NOOP)) { if (!generate_opcode(rsp, block, compiler, desc)) { UML_MOV(block, MEM(&rsp->pc), IMM(desc->pc)); UML_MOV(block, MEM(&rsp->impstate->arg0), IMM(desc->opptr.l[0])); UML_CALLC(block, cfunc_unimplemented, rsp); } } }
[ "static", "void", "generate_sequence_instruction", "(", "rsp_state", "*", "rsp", ",", "drcuml_block", "*", "block", ",", "compiler_state", "*", "compiler", ",", "const", "opcode_desc", "*", "desc", ")", "{", "offs_t", "expc", ";", "if", "(", "LOG_UML", "&&", "!", "(", "desc", "->", "flags", "&", "OPFLAG_VIRTUAL_NOOP", ")", ")", "log_add_disasm_comment", "(", "rsp", ",", "block", ",", "desc", "->", "pc", ",", "desc", "->", "opptr", ".", "l", "[", "0", "]", ")", ";", "expc", "=", "(", "desc", "->", "flags", "&", "OPFLAG_IN_DELAY_SLOT", ")", "?", "desc", "->", "pc", "-", "3", ":", "desc", "->", "pc", ";", "UML_MAPVAR", "(", "block", ",", "MAPVAR_PC", ",", "expc", ")", ";", "compiler", "->", "cycles", "+=", "desc", "->", "cycles", ";", "UML_MAPVAR", "(", "block", ",", "MAPVAR_CYCLES", ",", "compiler", "->", "cycles", ")", ";", "if", "(", "(", "rsp", "->", "device", "->", "machine", "->", "debug_flags", "&", "DEBUG_FLAG_ENABLED", ")", "!=", "0", ")", "{", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "rsp", "->", "pc", ")", ",", "IMM", "(", "desc", "->", "pc", ")", ")", ";", "save_fast_iregs", "(", "rsp", ",", "block", ")", ";", "UML_DEBUG", "(", "block", ",", "IMM", "(", "desc", "->", "pc", ")", ")", ";", "}", "#if", "0", "\n", "if", "(", "desc", "->", "flags", "&", "OPFLAG_COMPILER_UNMAPPED", ")", "{", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "rsp", "->", "pc", ")", ",", "IMM", "(", "desc", "->", "pc", ")", ")", ";", "save_fast_iregs", "(", "rsp", ",", "block", ")", ";", "UML_EXIT", "(", "block", ",", "IMM", "(", "EXECUTE_UNMAPPED_CODE", ")", ")", ";", "}", "#endif", "if", "(", "!", "(", "desc", "->", "flags", "&", "OPFLAG_VIRTUAL_NOOP", ")", ")", "{", "if", "(", "!", "generate_opcode", "(", "rsp", ",", "block", ",", "compiler", ",", "desc", ")", ")", "{", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "rsp", "->", "pc", ")", ",", "IMM", "(", "desc", "->", "pc", ")", ")", ";", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "rsp", "->", "impstate", "->", "arg0", ")", ",", "IMM", "(", "desc", "->", "opptr", ".", "l", "[", "0", "]", ")", ")", ";", "UML_CALLC", "(", "block", ",", "cfunc_unimplemented", ",", "rsp", ")", ";", "}", "}", "}" ]
generate_sequence_instruction - generate code for a single instruction in a sequence
[ "generate_sequence_instruction", "-", "generate", "code", "for", "a", "single", "instruction", "in", "a", "sequence" ]
[ "/* add an entry for the log */", "/* set the PC map variable */", "// mapvar PC,expc\r", "/* accumulate total cycles */", "/* update the icount map variable */", "// mapvar CYCLES,compiler->cycles\r", "/* if we are debugging, call the debugger */", "// mov [pc],desc->pc\r", "// debug desc->pc\r", "/* if we hit an unmapped address, fatal error */", "// mov [pc],desc->pc\r", "// exit EXECUTE_UNMAPPED_CODE\r", "/* otherwise, unless this is a virtual no-op, it's a regular instruction */", "/*else*/", "/* compile the instruction */", "// mov [pc],desc->pc\r", "// mov [arg0],desc->opptr.l\r", "// callc cfunc_unimplemented\r" ]
[ { "param": "rsp", "type": "rsp_state" }, { "param": "block", "type": "drcuml_block" }, { "param": "compiler", "type": "compiler_state" }, { "param": "desc", "type": "opcode_desc" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rsp", "type": "rsp_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "compiler", "type": "compiler_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "desc", "type": "opcode_desc", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f795c0b45989dd1b161b64bc694fa0a5885ca701
lofunz/mieme
Reloaded/trunk/src/emu/cpu/rsp/rspdrc.c
[ "Unlicense" ]
C
generate_special
int
static int generate_special(rsp_state *rsp, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) { UINT32 op = desc->opptr.l[0]; UINT8 opswitch = op & 63; //drcuml_codelabel skip; switch (opswitch) { /* ----- shift instructions ----- */ case 0x00: /* SLL - MIPS I */ if (RDREG != 0) { UML_SHL(block, R32(RDREG), R32(RTREG), IMM(SHIFT)); } return TRUE; case 0x02: /* SRL - MIPS I */ if (RDREG != 0) { UML_SHR(block, R32(RDREG), R32(RTREG), IMM(SHIFT)); } return TRUE; case 0x03: /* SRA - MIPS I */ if (RDREG != 0) { UML_SAR(block, R32(RDREG), R32(RTREG), IMM(SHIFT)); } return TRUE; case 0x04: /* SLLV - MIPS I */ if (RDREG != 0) { UML_SHL(block, R32(RDREG), R32(RTREG), R32(RSREG)); } return TRUE; case 0x06: /* SRLV - MIPS I */ if (RDREG != 0) { UML_SHR(block, R32(RDREG), R32(RTREG), R32(RSREG)); } return TRUE; case 0x07: /* SRAV - MIPS I */ if (RDREG != 0) { UML_SAR(block, R32(RDREG), R32(RTREG), R32(RSREG)); } return TRUE; /* ----- basic arithmetic ----- */ case 0x20: /* ADD - MIPS I */ case 0x21: /* ADDU - MIPS I */ if (RDREG != 0) { UML_ADD(block, R32(RDREG), R32(RSREG), R32(RTREG)); } return TRUE; case 0x22: /* SUB - MIPS I */ case 0x23: /* SUBU - MIPS I */ if (RDREG != 0) { UML_SUB(block, R32(RDREG), R32(RSREG), R32(RTREG)); } return TRUE; /* ----- basic logical ops ----- */ case 0x24: /* AND - MIPS I */ if (RDREG != 0) { UML_AND(block, R32(RDREG), R32(RSREG), R32(RTREG)); // dand <rdreg>,<rsreg>,<rtreg> } return TRUE; case 0x25: /* OR - MIPS I */ if (RDREG != 0) { UML_OR(block, R32(RDREG), R32(RSREG), R32(RTREG)); // dor <rdreg>,<rsreg>,<rtreg> } return TRUE; case 0x26: /* XOR - MIPS I */ if (RDREG != 0) { UML_XOR(block, R32(RDREG), R32(RSREG), R32(RTREG)); // dxor <rdreg>,<rsreg>,<rtreg> } return TRUE; case 0x27: /* NOR - MIPS I */ if (RDREG != 0) { UML_OR(block, IREG(0), R32(RSREG), R32(RTREG)); // dor i0,<rsreg>,<rtreg> UML_XOR(block, R32(RDREG), IREG(0), IMM((UINT64)~0)); // dxor <rdreg>,i0,~0 } return TRUE; /* ----- basic comparisons ----- */ case 0x2a: /* SLT - MIPS I */ if (RDREG != 0) { UML_CMP(block, R32(RSREG), R32(RTREG)); // dcmp <rsreg>,<rtreg> UML_SETc(block, IF_L, R32(RDREG)); // dset <rdreg>,l } return TRUE; case 0x2b: /* SLTU - MIPS I */ if (RDREG != 0) { UML_CMP(block, R32(RSREG), R32(RTREG)); // dcmp <rsreg>,<rtreg> UML_SETc(block, IF_B, R32(RDREG)); // dset <rdreg>,b } return TRUE; /* ----- jumps and branches ----- */ case 0x08: /* JR - MIPS I */ generate_delay_slot_and_branch(rsp, block, compiler, desc, 0); // <next instruction + hashjmp> return TRUE; case 0x09: /* JALR - MIPS I */ generate_delay_slot_and_branch(rsp, block, compiler, desc, RDREG); // <next instruction + hashjmp> return TRUE; /* ----- system calls ----- */ case 0x0d: /* BREAK - MIPS I */ UML_MOV(block, MEM(&rsp->impstate->arg0), IMM(3)); // mov [arg0],3 UML_CALLC(block, cfunc_sp_set_status_cb, rsp); // callc cfunc_sp_set_status_cb UML_MOV(block, MEM(&rsp->icount), IMM(0)); // mov icount, #0 UML_EXIT(block, IMM(EXECUTE_OUT_OF_CYCLES)); return TRUE; } return FALSE; }
/*------------------------------------------------- generate_special - compile opcodes in the 'SPECIAL' group -------------------------------------------------*/
compile opcodes in the 'SPECIAL' group
[ "compile", "opcodes", "in", "the", "'", "SPECIAL", "'", "group" ]
static int generate_special(rsp_state *rsp, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) { UINT32 op = desc->opptr.l[0]; UINT8 opswitch = op & 63; switch (opswitch) { case 0x00: if (RDREG != 0) { UML_SHL(block, R32(RDREG), R32(RTREG), IMM(SHIFT)); } return TRUE; case 0x02: if (RDREG != 0) { UML_SHR(block, R32(RDREG), R32(RTREG), IMM(SHIFT)); } return TRUE; case 0x03: if (RDREG != 0) { UML_SAR(block, R32(RDREG), R32(RTREG), IMM(SHIFT)); } return TRUE; case 0x04: if (RDREG != 0) { UML_SHL(block, R32(RDREG), R32(RTREG), R32(RSREG)); } return TRUE; case 0x06: if (RDREG != 0) { UML_SHR(block, R32(RDREG), R32(RTREG), R32(RSREG)); } return TRUE; case 0x07: if (RDREG != 0) { UML_SAR(block, R32(RDREG), R32(RTREG), R32(RSREG)); } return TRUE; case 0x20: case 0x21: if (RDREG != 0) { UML_ADD(block, R32(RDREG), R32(RSREG), R32(RTREG)); } return TRUE; case 0x22: case 0x23: if (RDREG != 0) { UML_SUB(block, R32(RDREG), R32(RSREG), R32(RTREG)); } return TRUE; case 0x24: if (RDREG != 0) { UML_AND(block, R32(RDREG), R32(RSREG), R32(RTREG)); } return TRUE; case 0x25: if (RDREG != 0) { UML_OR(block, R32(RDREG), R32(RSREG), R32(RTREG)); } return TRUE; case 0x26: if (RDREG != 0) { UML_XOR(block, R32(RDREG), R32(RSREG), R32(RTREG)); } return TRUE; case 0x27: if (RDREG != 0) { UML_OR(block, IREG(0), R32(RSREG), R32(RTREG)); UML_XOR(block, R32(RDREG), IREG(0), IMM((UINT64)~0)); } return TRUE; case 0x2a: if (RDREG != 0) { UML_CMP(block, R32(RSREG), R32(RTREG)); UML_SETc(block, IF_L, R32(RDREG)); } return TRUE; case 0x2b: if (RDREG != 0) { UML_CMP(block, R32(RSREG), R32(RTREG)); UML_SETc(block, IF_B, R32(RDREG)); } return TRUE; case 0x08: generate_delay_slot_and_branch(rsp, block, compiler, desc, 0); return TRUE; case 0x09: generate_delay_slot_and_branch(rsp, block, compiler, desc, RDREG); return TRUE; case 0x0d: UML_MOV(block, MEM(&rsp->impstate->arg0), IMM(3)); UML_CALLC(block, cfunc_sp_set_status_cb, rsp); UML_MOV(block, MEM(&rsp->icount), IMM(0)); UML_EXIT(block, IMM(EXECUTE_OUT_OF_CYCLES)); return TRUE; } return FALSE; }
[ "static", "int", "generate_special", "(", "rsp_state", "*", "rsp", ",", "drcuml_block", "*", "block", ",", "compiler_state", "*", "compiler", ",", "const", "opcode_desc", "*", "desc", ")", "{", "UINT32", "op", "=", "desc", "->", "opptr", ".", "l", "[", "0", "]", ";", "UINT8", "opswitch", "=", "op", "&", "63", ";", "switch", "(", "opswitch", ")", "{", "case", "0x00", ":", "if", "(", "RDREG", "!=", "0", ")", "{", "UML_SHL", "(", "block", ",", "R32", "(", "RDREG", ")", ",", "R32", "(", "RTREG", ")", ",", "IMM", "(", "SHIFT", ")", ")", ";", "}", "return", "TRUE", ";", "case", "0x02", ":", "if", "(", "RDREG", "!=", "0", ")", "{", "UML_SHR", "(", "block", ",", "R32", "(", "RDREG", ")", ",", "R32", "(", "RTREG", ")", ",", "IMM", "(", "SHIFT", ")", ")", ";", "}", "return", "TRUE", ";", "case", "0x03", ":", "if", "(", "RDREG", "!=", "0", ")", "{", "UML_SAR", "(", "block", ",", "R32", "(", "RDREG", ")", ",", "R32", "(", "RTREG", ")", ",", "IMM", "(", "SHIFT", ")", ")", ";", "}", "return", "TRUE", ";", "case", "0x04", ":", "if", "(", "RDREG", "!=", "0", ")", "{", "UML_SHL", "(", "block", ",", "R32", "(", "RDREG", ")", ",", "R32", "(", "RTREG", ")", ",", "R32", "(", "RSREG", ")", ")", ";", "}", "return", "TRUE", ";", "case", "0x06", ":", "if", "(", "RDREG", "!=", "0", ")", "{", "UML_SHR", "(", "block", ",", "R32", "(", "RDREG", ")", ",", "R32", "(", "RTREG", ")", ",", "R32", "(", "RSREG", ")", ")", ";", "}", "return", "TRUE", ";", "case", "0x07", ":", "if", "(", "RDREG", "!=", "0", ")", "{", "UML_SAR", "(", "block", ",", "R32", "(", "RDREG", ")", ",", "R32", "(", "RTREG", ")", ",", "R32", "(", "RSREG", ")", ")", ";", "}", "return", "TRUE", ";", "case", "0x20", ":", "case", "0x21", ":", "if", "(", "RDREG", "!=", "0", ")", "{", "UML_ADD", "(", "block", ",", "R32", "(", "RDREG", ")", ",", "R32", "(", "RSREG", ")", ",", "R32", "(", "RTREG", ")", ")", ";", "}", "return", "TRUE", ";", "case", "0x22", ":", "case", "0x23", ":", "if", "(", "RDREG", "!=", "0", ")", "{", "UML_SUB", "(", "block", ",", "R32", "(", "RDREG", ")", ",", "R32", "(", "RSREG", ")", ",", "R32", "(", "RTREG", ")", ")", ";", "}", "return", "TRUE", ";", "case", "0x24", ":", "if", "(", "RDREG", "!=", "0", ")", "{", "UML_AND", "(", "block", ",", "R32", "(", "RDREG", ")", ",", "R32", "(", "RSREG", ")", ",", "R32", "(", "RTREG", ")", ")", ";", "}", "return", "TRUE", ";", "case", "0x25", ":", "if", "(", "RDREG", "!=", "0", ")", "{", "UML_OR", "(", "block", ",", "R32", "(", "RDREG", ")", ",", "R32", "(", "RSREG", ")", ",", "R32", "(", "RTREG", ")", ")", ";", "}", "return", "TRUE", ";", "case", "0x26", ":", "if", "(", "RDREG", "!=", "0", ")", "{", "UML_XOR", "(", "block", ",", "R32", "(", "RDREG", ")", ",", "R32", "(", "RSREG", ")", ",", "R32", "(", "RTREG", ")", ")", ";", "}", "return", "TRUE", ";", "case", "0x27", ":", "if", "(", "RDREG", "!=", "0", ")", "{", "UML_OR", "(", "block", ",", "IREG", "(", "0", ")", ",", "R32", "(", "RSREG", ")", ",", "R32", "(", "RTREG", ")", ")", ";", "UML_XOR", "(", "block", ",", "R32", "(", "RDREG", ")", ",", "IREG", "(", "0", ")", ",", "IMM", "(", "(", "UINT64", ")", "~", "0", ")", ")", ";", "}", "return", "TRUE", ";", "case", "0x2a", ":", "if", "(", "RDREG", "!=", "0", ")", "{", "UML_CMP", "(", "block", ",", "R32", "(", "RSREG", ")", ",", "R32", "(", "RTREG", ")", ")", ";", "UML_SETc", "(", "block", ",", "IF_L", ",", "R32", "(", "RDREG", ")", ")", ";", "}", "return", "TRUE", ";", "case", "0x2b", ":", "if", "(", "RDREG", "!=", "0", ")", "{", "UML_CMP", "(", "block", ",", "R32", "(", "RSREG", ")", ",", "R32", "(", "RTREG", ")", ")", ";", "UML_SETc", "(", "block", ",", "IF_B", ",", "R32", "(", "RDREG", ")", ")", ";", "}", "return", "TRUE", ";", "case", "0x08", ":", "generate_delay_slot_and_branch", "(", "rsp", ",", "block", ",", "compiler", ",", "desc", ",", "0", ")", ";", "return", "TRUE", ";", "case", "0x09", ":", "generate_delay_slot_and_branch", "(", "rsp", ",", "block", ",", "compiler", ",", "desc", ",", "RDREG", ")", ";", "return", "TRUE", ";", "case", "0x0d", ":", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "rsp", "->", "impstate", "->", "arg0", ")", ",", "IMM", "(", "3", ")", ")", ";", "UML_CALLC", "(", "block", ",", "cfunc_sp_set_status_cb", ",", "rsp", ")", ";", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "rsp", "->", "icount", ")", ",", "IMM", "(", "0", ")", ")", ";", "UML_EXIT", "(", "block", ",", "IMM", "(", "EXECUTE_OUT_OF_CYCLES", ")", ")", ";", "return", "TRUE", ";", "}", "return", "FALSE", ";", "}" ]
generate_special - compile opcodes in the 'SPECIAL' group
[ "generate_special", "-", "compile", "opcodes", "in", "the", "'", "SPECIAL", "'", "group" ]
[ "//drcuml_codelabel skip;\r", "/* ----- shift instructions ----- */", "/* SLL - MIPS I */", "/* SRL - MIPS I */", "/* SRA - MIPS I */", "/* SLLV - MIPS I */", "/* SRLV - MIPS I */", "/* SRAV - MIPS I */", "/* ----- basic arithmetic ----- */", "/* ADD - MIPS I */", "/* ADDU - MIPS I */", "/* SUB - MIPS I */", "/* SUBU - MIPS I */", "/* ----- basic logical ops ----- */", "/* AND - MIPS I */", "// dand <rdreg>,<rsreg>,<rtreg>\r", "/* OR - MIPS I */", "// dor <rdreg>,<rsreg>,<rtreg>\r", "/* XOR - MIPS I */", "// dxor <rdreg>,<rsreg>,<rtreg>\r", "/* NOR - MIPS I */", "// dor i0,<rsreg>,<rtreg>\r", "// dxor <rdreg>,i0,~0\r", "/* ----- basic comparisons ----- */", "/* SLT - MIPS I */", "// dcmp <rsreg>,<rtreg>\r", "// dset <rdreg>,l\r", "/* SLTU - MIPS I */", "// dcmp <rsreg>,<rtreg>\r", "// dset <rdreg>,b\r", "/* ----- jumps and branches ----- */", "/* JR - MIPS I */", "// <next instruction + hashjmp>\r", "/* JALR - MIPS I */", "// <next instruction + hashjmp>\r", "/* ----- system calls ----- */", "/* BREAK - MIPS I */", "// mov [arg0],3\r", "// callc cfunc_sp_set_status_cb\r", "// mov icount, #0\r" ]
[ { "param": "rsp", "type": "rsp_state" }, { "param": "block", "type": "drcuml_block" }, { "param": "compiler", "type": "compiler_state" }, { "param": "desc", "type": "opcode_desc" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rsp", "type": "rsp_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "compiler", "type": "compiler_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "desc", "type": "opcode_desc", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f795c0b45989dd1b161b64bc694fa0a5885ca701
lofunz/mieme
Reloaded/trunk/src/emu/cpu/rsp/rspdrc.c
[ "Unlicense" ]
C
generate_regimm
int
static int generate_regimm(rsp_state *rsp, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) { UINT32 op = desc->opptr.l[0]; UINT8 opswitch = RTREG; drcuml_codelabel skip; switch (opswitch) { case 0x00: /* BLTZ */ case 0x10: /* BLTZAL */ if (RSREG != 0) { UML_CMP(block, R32(RSREG), IMM(0)); // dcmp <rsreg>,0 UML_JMPc(block, IF_GE, skip = compiler->labelnum++); // jmp skip,GE generate_delay_slot_and_branch(rsp, block, compiler, desc, (opswitch & 0x10) ? 31 : 0); // <next instruction + hashjmp> UML_LABEL(block, skip); // skip: } return TRUE; case 0x01: /* BGEZ */ case 0x11: /* BGEZAL */ if (RSREG != 0) { UML_CMP(block, R32(RSREG), IMM(0)); // dcmp <rsreg>,0 UML_JMPc(block, IF_L, skip = compiler->labelnum++); // jmp skip,L generate_delay_slot_and_branch(rsp, block, compiler, desc, (opswitch & 0x10) ? 31 : 0); // <next instruction + hashjmp> UML_LABEL(block, skip); // skip: } else generate_delay_slot_and_branch(rsp, block, compiler, desc, (opswitch & 0x10) ? 31 : 0); // <next instruction + hashjmp> return TRUE; } return FALSE; }
/*------------------------------------------------- generate_regimm - compile opcodes in the 'REGIMM' group -------------------------------------------------*/
compile opcodes in the 'REGIMM' group
[ "compile", "opcodes", "in", "the", "'", "REGIMM", "'", "group" ]
static int generate_regimm(rsp_state *rsp, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) { UINT32 op = desc->opptr.l[0]; UINT8 opswitch = RTREG; drcuml_codelabel skip; switch (opswitch) { case 0x00: case 0x10: if (RSREG != 0) { UML_CMP(block, R32(RSREG), IMM(0)); UML_JMPc(block, IF_GE, skip = compiler->labelnum++); generate_delay_slot_and_branch(rsp, block, compiler, desc, (opswitch & 0x10) ? 31 : 0); UML_LABEL(block, skip); } return TRUE; case 0x01: case 0x11: if (RSREG != 0) { UML_CMP(block, R32(RSREG), IMM(0)); UML_JMPc(block, IF_L, skip = compiler->labelnum++); generate_delay_slot_and_branch(rsp, block, compiler, desc, (opswitch & 0x10) ? 31 : 0); UML_LABEL(block, skip); } else generate_delay_slot_and_branch(rsp, block, compiler, desc, (opswitch & 0x10) ? 31 : 0); return TRUE; } return FALSE; }
[ "static", "int", "generate_regimm", "(", "rsp_state", "*", "rsp", ",", "drcuml_block", "*", "block", ",", "compiler_state", "*", "compiler", ",", "const", "opcode_desc", "*", "desc", ")", "{", "UINT32", "op", "=", "desc", "->", "opptr", ".", "l", "[", "0", "]", ";", "UINT8", "opswitch", "=", "RTREG", ";", "drcuml_codelabel", "skip", ";", "switch", "(", "opswitch", ")", "{", "case", "0x00", ":", "case", "0x10", ":", "if", "(", "RSREG", "!=", "0", ")", "{", "UML_CMP", "(", "block", ",", "R32", "(", "RSREG", ")", ",", "IMM", "(", "0", ")", ")", ";", "UML_JMPc", "(", "block", ",", "IF_GE", ",", "skip", "=", "compiler", "->", "labelnum", "++", ")", ";", "generate_delay_slot_and_branch", "(", "rsp", ",", "block", ",", "compiler", ",", "desc", ",", "(", "opswitch", "&", "0x10", ")", "?", "31", ":", "0", ")", ";", "UML_LABEL", "(", "block", ",", "skip", ")", ";", "}", "return", "TRUE", ";", "case", "0x01", ":", "case", "0x11", ":", "if", "(", "RSREG", "!=", "0", ")", "{", "UML_CMP", "(", "block", ",", "R32", "(", "RSREG", ")", ",", "IMM", "(", "0", ")", ")", ";", "UML_JMPc", "(", "block", ",", "IF_L", ",", "skip", "=", "compiler", "->", "labelnum", "++", ")", ";", "generate_delay_slot_and_branch", "(", "rsp", ",", "block", ",", "compiler", ",", "desc", ",", "(", "opswitch", "&", "0x10", ")", "?", "31", ":", "0", ")", ";", "UML_LABEL", "(", "block", ",", "skip", ")", ";", "}", "else", "generate_delay_slot_and_branch", "(", "rsp", ",", "block", ",", "compiler", ",", "desc", ",", "(", "opswitch", "&", "0x10", ")", "?", "31", ":", "0", ")", ";", "return", "TRUE", ";", "}", "return", "FALSE", ";", "}" ]
generate_regimm - compile opcodes in the 'REGIMM' group
[ "generate_regimm", "-", "compile", "opcodes", "in", "the", "'", "REGIMM", "'", "group" ]
[ "/* BLTZ */", "/* BLTZAL */", "// dcmp <rsreg>,0\r", "// jmp skip,GE\r", "// <next instruction + hashjmp>\r", "// skip:\r", "/* BGEZ */", "/* BGEZAL */", "// dcmp <rsreg>,0\r", "// jmp skip,L\r", "// <next instruction + hashjmp>\r", "// skip:\r", "// <next instruction + hashjmp>\r" ]
[ { "param": "rsp", "type": "rsp_state" }, { "param": "block", "type": "drcuml_block" }, { "param": "compiler", "type": "compiler_state" }, { "param": "desc", "type": "opcode_desc" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rsp", "type": "rsp_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "compiler", "type": "compiler_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "desc", "type": "opcode_desc", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f795c0b45989dd1b161b64bc694fa0a5885ca701
lofunz/mieme
Reloaded/trunk/src/emu/cpu/rsp/rspdrc.c
[ "Unlicense" ]
C
log_add_disasm_comment
void
static void log_add_disasm_comment(rsp_state *rsp, drcuml_block *block, UINT32 pc, UINT32 op) { #if (LOG_UML) char buffer[100]; rsp_dasm_one(buffer, pc, op); UML_COMMENT(block, "%08X: %s", pc, buffer); // comment #endif }
/*------------------------------------------------- log_add_disasm_comment - add a comment including disassembly of a RSP instruction -------------------------------------------------*/
add a comment including disassembly of a RSP instruction
[ "add", "a", "comment", "including", "disassembly", "of", "a", "RSP", "instruction" ]
static void log_add_disasm_comment(rsp_state *rsp, drcuml_block *block, UINT32 pc, UINT32 op) { #if (LOG_UML) char buffer[100]; rsp_dasm_one(buffer, pc, op); UML_COMMENT(block, "%08X: %s", pc, buffer); #endif }
[ "static", "void", "log_add_disasm_comment", "(", "rsp_state", "*", "rsp", ",", "drcuml_block", "*", "block", ",", "UINT32", "pc", ",", "UINT32", "op", ")", "{", "#if", "(", "LOG_UML", ")", "\n", "char", "buffer", "[", "100", "]", ";", "rsp_dasm_one", "(", "buffer", ",", "pc", ",", "op", ")", ";", "UML_COMMENT", "(", "block", ",", "\"", "\"", ",", "pc", ",", "buffer", ")", ";", "#endif", "}" ]
log_add_disasm_comment - add a comment including disassembly of a RSP instruction
[ "log_add_disasm_comment", "-", "add", "a", "comment", "including", "disassembly", "of", "a", "RSP", "instruction" ]
[ "// comment\r" ]
[ { "param": "rsp", "type": "rsp_state" }, { "param": "block", "type": "drcuml_block" }, { "param": "pc", "type": "UINT32" }, { "param": "op", "type": "UINT32" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rsp", "type": "rsp_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pc", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "op", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
472e24b15be81715a2156a4ea06f556602da87b9
lofunz/mieme
Reloaded/trunk/src/emu/sound/okim6258.c
[ "Unlicense" ]
C
okim6258_set_divider
void
void okim6258_set_divider(running_device *device, int val) { okim6258_state *info = get_safe_token(device); int divider = dividers[val]; info->divider = dividers[val]; stream_set_sample_rate(info->stream, info->master_clock / divider); }
/********************************************************************************************** okim6258_set_divider -- set the master clock divider ***********************************************************************************************/
- set the master clock divider
[ "-", "set", "the", "master", "clock", "divider" ]
void okim6258_set_divider(running_device *device, int val) { okim6258_state *info = get_safe_token(device); int divider = dividers[val]; info->divider = dividers[val]; stream_set_sample_rate(info->stream, info->master_clock / divider); }
[ "void", "okim6258_set_divider", "(", "running_device", "*", "device", ",", "int", "val", ")", "{", "okim6258_state", "*", "info", "=", "get_safe_token", "(", "device", ")", ";", "int", "divider", "=", "dividers", "[", "val", "]", ";", "info", "->", "divider", "=", "dividers", "[", "val", "]", ";", "stream_set_sample_rate", "(", "info", "->", "stream", ",", "info", "->", "master_clock", "/", "divider", ")", ";", "}" ]
okim6258_set_divider -- set the master clock divider
[ "okim6258_set_divider", "--", "set", "the", "master", "clock", "divider" ]
[]
[ { "param": "device", "type": "running_device" }, { "param": "val", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "device", "type": "running_device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "val", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
472e24b15be81715a2156a4ea06f556602da87b9
lofunz/mieme
Reloaded/trunk/src/emu/sound/okim6258.c
[ "Unlicense" ]
C
okim6258_get_vclk
int
int okim6258_get_vclk(running_device *device) { okim6258_state *info = get_safe_token(device); return (info->master_clock / info->divider); }
/********************************************************************************************** okim6258_get_vclk -- get the VCLK/sampling frequency ***********************************************************************************************/
- get the VCLK/sampling frequency
[ "-", "get", "the", "VCLK", "/", "sampling", "frequency" ]
int okim6258_get_vclk(running_device *device) { okim6258_state *info = get_safe_token(device); return (info->master_clock / info->divider); }
[ "int", "okim6258_get_vclk", "(", "running_device", "*", "device", ")", "{", "okim6258_state", "*", "info", "=", "get_safe_token", "(", "device", ")", ";", "return", "(", "info", "->", "master_clock", "/", "info", "->", "divider", ")", ";", "}" ]
okim6258_get_vclk -- get the VCLK/sampling frequency
[ "okim6258_get_vclk", "--", "get", "the", "VCLK", "/", "sampling", "frequency" ]
[]
[ { "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": [] }
471cce9e03e61851c779490ac32bebbbfe9d2f0e
lofunz/mieme
Reloaded/trunk/src/emu/cpu/apexc/apexc.c
[ "Unlicense" ]
C
effective_address
int
static int effective_address(apexc_state *cpustate, int address) { if (address & 0x200) { address = (address & 0x1FF) | (cpustate->working_store) << 9; } return address; }
/* compute complete word address (i.e. translate a logical track address (expressed in current working store) to an absolute track address) */
compute complete word address to an absolute track address)
[ "compute", "complete", "word", "address", "to", "an", "absolute", "track", "address", ")" ]
static int effective_address(apexc_state *cpustate, int address) { if (address & 0x200) { address = (address & 0x1FF) | (cpustate->working_store) << 9; } return address; }
[ "static", "int", "effective_address", "(", "apexc_state", "*", "cpustate", ",", "int", "address", ")", "{", "if", "(", "address", "&", "0x200", ")", "{", "address", "=", "(", "address", "&", "0x1FF", ")", "|", "(", "cpustate", "->", "working_store", ")", "<<", "9", ";", "}", "return", "address", ";", "}" ]
compute complete word address (i.e.
[ "compute", "complete", "word", "address", "(", "i", ".", "e", "." ]
[]
[ { "param": "cpustate", "type": "apexc_state" }, { "param": "address", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cpustate", "type": "apexc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
471cce9e03e61851c779490ac32bebbbfe9d2f0e
lofunz/mieme
Reloaded/trunk/src/emu/cpu/apexc/apexc.c
[ "Unlicense" ]
C
word_write
void
static void word_write(apexc_state *cpustate, int address, UINT32 data, UINT32 mask) { /* compute absolute track address */ address = effective_address(cpustate, address); /* wait for requested word to appear under the heads */ DELAY(((address /*& 0x1f*/) - cpustate->current_word) & 0x1f); /* write 32 bits according to mask */ #if 0 /* note that the APEXC reads LSBits first */ for (i=0; i<31; i++) { if (mask & (1 << i)) bit_write((address << 5) | i, (data >> i) & 1); } #else apexc_writemem_masked(address, data, mask); #endif /* write takes one memory cycle (2, actually, but the 2nd cycle is taken into account in execute) */ DELAY(1); }
/* write word (or part of a word, according to mask) */
write word (or part of a word, according to mask)
[ "write", "word", "(", "or", "part", "of", "a", "word", "according", "to", "mask", ")" ]
static void word_write(apexc_state *cpustate, int address, UINT32 data, UINT32 mask) { address = effective_address(cpustate, address); DELAY(((address ) - cpustate->current_word) & 0x1f); #if 0 for (i=0; i<31; i++) { if (mask & (1 << i)) bit_write((address << 5) | i, (data >> i) & 1); } #else apexc_writemem_masked(address, data, mask); #endif DELAY(1); }
[ "static", "void", "word_write", "(", "apexc_state", "*", "cpustate", ",", "int", "address", ",", "UINT32", "data", ",", "UINT32", "mask", ")", "{", "address", "=", "effective_address", "(", "cpustate", ",", "address", ")", ";", "DELAY", "(", "(", "(", "address", ")", "-", "cpustate", "->", "current_word", ")", "&", "0x1f", ")", ";", "#if", "0", "\n", "for", "(", "i", "=", "0", ";", "i", "<", "31", ";", "i", "++", ")", "{", "if", "(", "mask", "&", "(", "1", "<<", "i", ")", ")", "bit_write", "(", "(", "address", "<<", "5", ")", "|", "i", ",", "(", "data", ">>", "i", ")", "&", "1", ")", ";", "}", "#else", "apexc_writemem_masked", "(", "address", ",", "data", ",", "mask", ")", ";", "#endif", "DELAY", "(", "1", ")", ";", "}" ]
write word (or part of a word, according to mask)
[ "write", "word", "(", "or", "part", "of", "a", "word", "according", "to", "mask", ")" ]
[ "/* compute absolute track address */", "/* wait for requested word to appear under the heads */", "/*& 0x1f*/", "/* write 32 bits according to mask */", "/* note that the APEXC reads LSBits first */", "/* write takes one memory cycle (2, actually, but the 2nd cycle is taken into\r\n account in execute) */" ]
[ { "param": "cpustate", "type": "apexc_state" }, { "param": "address", "type": "int" }, { "param": "data", "type": "UINT32" }, { "param": "mask", "type": "UINT32" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cpustate", "type": "apexc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mask", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
471cce9e03e61851c779490ac32bebbbfe9d2f0e
lofunz/mieme
Reloaded/trunk/src/emu/cpu/apexc/apexc.c
[ "Unlicense" ]
C
execute
void
static void execute(apexc_state *cpustate) { int x, y, function, c6, vector; /* instruction fields */ int i = 0; /* misc counter */ int has_operand; /* true if instruction is an AU operation with an X operand */ static const char has_operand_table[32] = /* table for has_operand - one entry for each function code */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0 }; int delay1; /* pre-operand-access delay */ int delay2; /* post-operation delay */ int delay3; /* pre-operand-fetch delay */ /* first isolate the instruction fields */ x = (cpustate->cr >> 22) & 0x3FF; y = (cpustate->cr >> 12) & 0x3FF; function = (cpustate->cr >> 7) & 0x1F; c6 = (cpustate->cr >> 1) & 0x3F; vector = cpustate->cr & 1; cpustate->pc = y<<2; function &= 0x1E; /* this is a mere guess - the LSBit is reserved for future additions */ /* determinates if we need to read an operand*/ has_operand = has_operand_table[function]; if (has_operand) { /* load ml with X */ delay1 = load_ml(cpustate, x, vector); /* burn pre-operand-access delay if needed */ if (delay1) { DELAY(delay1); } } delay2 = 0; /* default */ do { switch (function) { case 0: /* stop */ cpustate->running = FALSE; /* BTW, I don't know whether stop loads y into ml or not, and whether subsequent fetch is done */ break; case 2: /* I */ /* I do not know whether the CPU does an OR or whatever, but since docs say that the 5 bits must be cleared initially, an OR kind of makes sense */ cpustate->r |= papertape_read(cpustate) << 27; delay2 = 32; /* no idea whether this should be counted as an absolute delay or as a value in delay2 */ break; case 4: /* P */ papertape_punch(cpustate, (cpustate->r >> 27) & 0x1f); delay2 = 32; /* no idea whether this should be counted as an absolute delay or as a value in delay2 */ break; case 6: /* B<(x)>=(y) */ /* I have no idea what we should do if the vector bit is set */ if (cpustate->a & 0x80000000UL) { /* load ml with X */ delay1 = load_ml(cpustate, x, vector); cpustate->pc = x<<2; /* burn pre-fetch delay if needed */ if (delay1) { DELAY(delay1); } /* and do fetch at X */ goto special_fetch; } /* else, the instruction ends with a normal fetch */ break; case 8: /* l_n */ delay2 = (c6 & 0x20) ? 1 : 2; /* if more than 32 shifts, it takes more time */ /* Yes, this code is inefficient, but this must be the way the APEXC does it ;-) */ while (c6 != 0) { int shifted_bit = 0; /* shift and increment c6 */ shifted_bit = cpustate->r & 1; cpustate->r >>= 1; if (cpustate->a & 1) cpustate->r |= 0x80000000UL; cpustate->a >>= 1; if (shifted_bit) cpustate->a |= 0x80000000UL; c6 = (c6+1) & 0x3f; } break; case 10: /* r_n */ delay2 = (c6 & 0x20) ? 1 : 2; /* if more than 32 shifts, it takes more time */ /* Yes, this code is inefficient, but this must be the way the APEXC does it ;-) */ while (c6 != 0) { /* shift and increment c6 */ cpustate->r >>= 1; if (cpustate->a & 1) cpustate->r |= 0x80000000UL; cpustate->a = ((INT32) cpustate->a) >> 1; c6 = (c6+1) & 0x3f; } break; case 12: /* unused function code. I assume this results into a NOP, for lack of any specific info... */ break; case 14: /* X_n(x) */ /* Yes, this code is inefficient, but this must be the way the APEXC does it ;-) */ /* algorithm found in Booth&Booth, p. 45-48 */ { int shifted_bit; cpustate->a = 0; shifted_bit = 0; while (1) { /* note we read word at current word position */ if (shifted_bit && ! (cpustate->r & 1)) cpustate->a += word_read(cpustate, x, 1); else if ((! shifted_bit) && (cpustate->r & 1)) cpustate->a -= word_read(cpustate, x, 1); else /* Even if we do not read anything, the loop still takes 1 cycle of the memory word clock. */ /* Anyway, maybe we still read the data even if we do not use it. */ DELAY(1); /* exit if c6 reached 32 ("c6 & 0x20" is simpler to implement and essentially equivalent, so this is most likely the actual implementation) */ if (c6 & 0x20) break; /* else increment c6 and shift */ c6 = (c6+1) & 0x3f; /* shift */ shifted_bit = cpustate->r & 1; cpustate->r >>= 1; if (cpustate->a & 1) cpustate->r |= 0x80000000UL; cpustate->a = ((INT32) cpustate->a) >> 1; } } //DELAY(32); /* mmmh... we have already counted 32 wait states */ /* actually, if (n < 32) (which is an untypical case), we do not have 32 wait states. Question is: do we really have 32 wait states if (n < 32), or is the timing table incomplete? */ break; case 16: /* +c(x) */ cpustate->a = + word_read(cpustate, cpustate->ml, 0); break; case 18: /* -c(x) */ cpustate->a = - word_read(cpustate, cpustate->ml, 0); break; case 20: /* +(x) */ cpustate->a += word_read(cpustate, cpustate->ml, 0); break; case 22: /* -(x) */ cpustate->a -= word_read(cpustate, cpustate->ml, 0); break; case 24: /* T(x) */ cpustate->r = word_read(cpustate, cpustate->ml, 0); break; case 26: /* R_(1-n)(x) & R_(n-32)(x) */ { UINT32 mask; if (c6 & 0x20) mask = 0xFFFFFFFFUL << (64 - c6); else mask = 0xFFFFFFFFUL >> c6; word_write(cpustate, cpustate->ml, cpustate->r, mask); } cpustate->r = (cpustate->r & 0x80000000UL) ? 0xFFFFFFFFUL : 0; delay2 = 1; break; case 28: /* A_(1-n)(x) & A_(n-32)(x) */ { UINT32 mask; if (c6 & 0x20) mask = 0xFFFFFFFFUL << (64 - c6); else mask = 0xFFFFFFFFUL >> c6; word_write(cpustate, cpustate->ml, cpustate->a, mask); } delay2 = 1; break; case 30: /* S(x) */ cpustate->working_store = (x >> 5) & 0xf; /* or is it (x >> 6)? */ DELAY(32); /* no idea what the value is... All I know is that it takes much more time than track switching (which takes 6 cycles) */ break; } if (vector) /* increment word position in vector operations */ cpustate->ml = (cpustate->ml & 0x3E0) | ((cpustate->ml + 1) & 0x1F); } while (vector && has_operand && (++i < 32)); /* iterate 32 times if vector bit is set */ /* the has_operand is a mere guess */ /* load ml with Y */ delay3 = load_ml(cpustate, y, 0); /* compute max(delay2, delay3) */ if (delay2 > delay3) delay3 = delay2; /* burn pre-fetch delay if needed */ if (delay3) { DELAY(delay3); } /* entry point after a successful Branch (which alters the normal instruction sequence, in order not to load ml with Y) */ special_fetch: /* fetch current instruction into control register */ cpustate->cr = word_read(cpustate, cpustate->ml, 0); }
/* execute one instruction TODO: * test!!! NOTE: * I do not know whether we should fetch instructions at the beginning or the end of the instruction cycle. Either solution is roughly equivalent to the other, but changes the control panel operation (and I know virtually nothing on the control panel). Currently, I fetch each instruction right after executing the previous instruction, so that the user may enter an instruction into the control register with the control panel, then execute it. This solution makes timing simulation much simpler, too. */
execute one instruction TODO: test I do not know whether we should fetch instructions at the beginning or the end of the instruction cycle. Either solution is roughly equivalent to the other, but changes the control panel operation (and I know virtually nothing on the control panel). Currently, I fetch each instruction right after executing the previous instruction, so that the user may enter an instruction into the control register with the control panel, then execute it. This solution makes timing simulation much simpler, too.
[ "execute", "one", "instruction", "TODO", ":", "test", "I", "do", "not", "know", "whether", "we", "should", "fetch", "instructions", "at", "the", "beginning", "or", "the", "end", "of", "the", "instruction", "cycle", ".", "Either", "solution", "is", "roughly", "equivalent", "to", "the", "other", "but", "changes", "the", "control", "panel", "operation", "(", "and", "I", "know", "virtually", "nothing", "on", "the", "control", "panel", ")", ".", "Currently", "I", "fetch", "each", "instruction", "right", "after", "executing", "the", "previous", "instruction", "so", "that", "the", "user", "may", "enter", "an", "instruction", "into", "the", "control", "register", "with", "the", "control", "panel", "then", "execute", "it", ".", "This", "solution", "makes", "timing", "simulation", "much", "simpler", "too", "." ]
static void execute(apexc_state *cpustate) { int x, y, function, c6, vector; int i = 0; int has_operand; static const char has_operand_table[32] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0 }; int delay1; int delay2; int delay3; x = (cpustate->cr >> 22) & 0x3FF; y = (cpustate->cr >> 12) & 0x3FF; function = (cpustate->cr >> 7) & 0x1F; c6 = (cpustate->cr >> 1) & 0x3F; vector = cpustate->cr & 1; cpustate->pc = y<<2; function &= 0x1E; has_operand = has_operand_table[function]; if (has_operand) { delay1 = load_ml(cpustate, x, vector); if (delay1) { DELAY(delay1); } } delay2 = 0; do { switch (function) { case 0: cpustate->running = FALSE; break; case 2: cpustate->r |= papertape_read(cpustate) << 27; delay2 = 32; break; case 4: papertape_punch(cpustate, (cpustate->r >> 27) & 0x1f); delay2 = 32; break; case 6: if (cpustate->a & 0x80000000UL) { delay1 = load_ml(cpustate, x, vector); cpustate->pc = x<<2; if (delay1) { DELAY(delay1); } goto special_fetch; } break; case 8: delay2 = (c6 & 0x20) ? 1 : 2; while (c6 != 0) { int shifted_bit = 0; shifted_bit = cpustate->r & 1; cpustate->r >>= 1; if (cpustate->a & 1) cpustate->r |= 0x80000000UL; cpustate->a >>= 1; if (shifted_bit) cpustate->a |= 0x80000000UL; c6 = (c6+1) & 0x3f; } break; case 10: delay2 = (c6 & 0x20) ? 1 : 2; while (c6 != 0) { cpustate->r >>= 1; if (cpustate->a & 1) cpustate->r |= 0x80000000UL; cpustate->a = ((INT32) cpustate->a) >> 1; c6 = (c6+1) & 0x3f; } break; case 12: break; case 14: { int shifted_bit; cpustate->a = 0; shifted_bit = 0; while (1) { if (shifted_bit && ! (cpustate->r & 1)) cpustate->a += word_read(cpustate, x, 1); else if ((! shifted_bit) && (cpustate->r & 1)) cpustate->a -= word_read(cpustate, x, 1); else DELAY(1); if (c6 & 0x20) break; c6 = (c6+1) & 0x3f; shifted_bit = cpustate->r & 1; cpustate->r >>= 1; if (cpustate->a & 1) cpustate->r |= 0x80000000UL; cpustate->a = ((INT32) cpustate->a) >> 1; } } break; case 16: cpustate->a = + word_read(cpustate, cpustate->ml, 0); break; case 18: cpustate->a = - word_read(cpustate, cpustate->ml, 0); break; case 20: cpustate->a += word_read(cpustate, cpustate->ml, 0); break; case 22: cpustate->a -= word_read(cpustate, cpustate->ml, 0); break; case 24: cpustate->r = word_read(cpustate, cpustate->ml, 0); break; case 26: { UINT32 mask; if (c6 & 0x20) mask = 0xFFFFFFFFUL << (64 - c6); else mask = 0xFFFFFFFFUL >> c6; word_write(cpustate, cpustate->ml, cpustate->r, mask); } cpustate->r = (cpustate->r & 0x80000000UL) ? 0xFFFFFFFFUL : 0; delay2 = 1; break; case 28: { UINT32 mask; if (c6 & 0x20) mask = 0xFFFFFFFFUL << (64 - c6); else mask = 0xFFFFFFFFUL >> c6; word_write(cpustate, cpustate->ml, cpustate->a, mask); } delay2 = 1; break; case 30: cpustate->working_store = (x >> 5) & 0xf; DELAY(32); break; } if (vector) cpustate->ml = (cpustate->ml & 0x3E0) | ((cpustate->ml + 1) & 0x1F); } while (vector && has_operand && (++i < 32)); delay3 = load_ml(cpustate, y, 0); if (delay2 > delay3) delay3 = delay2; if (delay3) { DELAY(delay3); } special_fetch: cpustate->cr = word_read(cpustate, cpustate->ml, 0); }
[ "static", "void", "execute", "(", "apexc_state", "*", "cpustate", ")", "{", "int", "x", ",", "y", ",", "function", ",", "c6", ",", "vector", ";", "int", "i", "=", "0", ";", "int", "has_operand", ";", "static", "const", "char", "has_operand_table", "[", "32", "]", "=", "{", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "1", ",", "0", ",", "1", ",", "0", ",", "1", ",", "0", ",", "1", ",", "0", ",", "1", ",", "0", ",", "1", ",", "0", ",", "1", ",", "0", ",", "0", ",", "0", "}", ";", "int", "delay1", ";", "int", "delay2", ";", "int", "delay3", ";", "x", "=", "(", "cpustate", "->", "cr", ">>", "22", ")", "&", "0x3FF", ";", "y", "=", "(", "cpustate", "->", "cr", ">>", "12", ")", "&", "0x3FF", ";", "function", "=", "(", "cpustate", "->", "cr", ">>", "7", ")", "&", "0x1F", ";", "c6", "=", "(", "cpustate", "->", "cr", ">>", "1", ")", "&", "0x3F", ";", "vector", "=", "cpustate", "->", "cr", "&", "1", ";", "cpustate", "->", "pc", "=", "y", "<<", "2", ";", "function", "&=", "0x1E", ";", "has_operand", "=", "has_operand_table", "[", "function", "]", ";", "if", "(", "has_operand", ")", "{", "delay1", "=", "load_ml", "(", "cpustate", ",", "x", ",", "vector", ")", ";", "if", "(", "delay1", ")", "{", "DELAY", "(", "delay1", ")", ";", "}", "}", "delay2", "=", "0", ";", "do", "{", "switch", "(", "function", ")", "{", "case", "0", ":", "cpustate", "->", "running", "=", "FALSE", ";", "break", ";", "case", "2", ":", "cpustate", "->", "r", "|=", "papertape_read", "(", "cpustate", ")", "<<", "27", ";", "delay2", "=", "32", ";", "break", ";", "case", "4", ":", "papertape_punch", "(", "cpustate", ",", "(", "cpustate", "->", "r", ">>", "27", ")", "&", "0x1f", ")", ";", "delay2", "=", "32", ";", "break", ";", "case", "6", ":", "if", "(", "cpustate", "->", "a", "&", "0x80000000UL", ")", "{", "delay1", "=", "load_ml", "(", "cpustate", ",", "x", ",", "vector", ")", ";", "cpustate", "->", "pc", "=", "x", "<<", "2", ";", "if", "(", "delay1", ")", "{", "DELAY", "(", "delay1", ")", ";", "}", "goto", "special_fetch", ";", "}", "break", ";", "case", "8", ":", "delay2", "=", "(", "c6", "&", "0x20", ")", "?", "1", ":", "2", ";", "while", "(", "c6", "!=", "0", ")", "{", "int", "shifted_bit", "=", "0", ";", "shifted_bit", "=", "cpustate", "->", "r", "&", "1", ";", "cpustate", "->", "r", ">>=", "1", ";", "if", "(", "cpustate", "->", "a", "&", "1", ")", "cpustate", "->", "r", "|=", "0x80000000UL", ";", "cpustate", "->", "a", ">>=", "1", ";", "if", "(", "shifted_bit", ")", "cpustate", "->", "a", "|=", "0x80000000UL", ";", "c6", "=", "(", "c6", "+", "1", ")", "&", "0x3f", ";", "}", "break", ";", "case", "10", ":", "delay2", "=", "(", "c6", "&", "0x20", ")", "?", "1", ":", "2", ";", "while", "(", "c6", "!=", "0", ")", "{", "cpustate", "->", "r", ">>=", "1", ";", "if", "(", "cpustate", "->", "a", "&", "1", ")", "cpustate", "->", "r", "|=", "0x80000000UL", ";", "cpustate", "->", "a", "=", "(", "(", "INT32", ")", "cpustate", "->", "a", ")", ">>", "1", ";", "c6", "=", "(", "c6", "+", "1", ")", "&", "0x3f", ";", "}", "break", ";", "case", "12", ":", "break", ";", "case", "14", ":", "{", "int", "shifted_bit", ";", "cpustate", "->", "a", "=", "0", ";", "shifted_bit", "=", "0", ";", "while", "(", "1", ")", "{", "if", "(", "shifted_bit", "&&", "!", "(", "cpustate", "->", "r", "&", "1", ")", ")", "cpustate", "->", "a", "+=", "word_read", "(", "cpustate", ",", "x", ",", "1", ")", ";", "else", "if", "(", "(", "!", "shifted_bit", ")", "&&", "(", "cpustate", "->", "r", "&", "1", ")", ")", "cpustate", "->", "a", "-=", "word_read", "(", "cpustate", ",", "x", ",", "1", ")", ";", "else", "DELAY", "(", "1", ")", ";", "if", "(", "c6", "&", "0x20", ")", "break", ";", "c6", "=", "(", "c6", "+", "1", ")", "&", "0x3f", ";", "shifted_bit", "=", "cpustate", "->", "r", "&", "1", ";", "cpustate", "->", "r", ">>=", "1", ";", "if", "(", "cpustate", "->", "a", "&", "1", ")", "cpustate", "->", "r", "|=", "0x80000000UL", ";", "cpustate", "->", "a", "=", "(", "(", "INT32", ")", "cpustate", "->", "a", ")", ">>", "1", ";", "}", "}", "break", ";", "case", "16", ":", "cpustate", "->", "a", "=", "+", "word_read", "(", "cpustate", ",", "cpustate", "->", "ml", ",", "0", ")", ";", "break", ";", "case", "18", ":", "cpustate", "->", "a", "=", "-", "word_read", "(", "cpustate", ",", "cpustate", "->", "ml", ",", "0", ")", ";", "break", ";", "case", "20", ":", "cpustate", "->", "a", "+=", "word_read", "(", "cpustate", ",", "cpustate", "->", "ml", ",", "0", ")", ";", "break", ";", "case", "22", ":", "cpustate", "->", "a", "-=", "word_read", "(", "cpustate", ",", "cpustate", "->", "ml", ",", "0", ")", ";", "break", ";", "case", "24", ":", "cpustate", "->", "r", "=", "word_read", "(", "cpustate", ",", "cpustate", "->", "ml", ",", "0", ")", ";", "break", ";", "case", "26", ":", "{", "UINT32", "mask", ";", "if", "(", "c6", "&", "0x20", ")", "mask", "=", "0xFFFFFFFFUL", "<<", "(", "64", "-", "c6", ")", ";", "else", "mask", "=", "0xFFFFFFFFUL", ">>", "c6", ";", "word_write", "(", "cpustate", ",", "cpustate", "->", "ml", ",", "cpustate", "->", "r", ",", "mask", ")", ";", "}", "cpustate", "->", "r", "=", "(", "cpustate", "->", "r", "&", "0x80000000UL", ")", "?", "0xFFFFFFFFUL", ":", "0", ";", "delay2", "=", "1", ";", "break", ";", "case", "28", ":", "{", "UINT32", "mask", ";", "if", "(", "c6", "&", "0x20", ")", "mask", "=", "0xFFFFFFFFUL", "<<", "(", "64", "-", "c6", ")", ";", "else", "mask", "=", "0xFFFFFFFFUL", ">>", "c6", ";", "word_write", "(", "cpustate", ",", "cpustate", "->", "ml", ",", "cpustate", "->", "a", ",", "mask", ")", ";", "}", "delay2", "=", "1", ";", "break", ";", "case", "30", ":", "cpustate", "->", "working_store", "=", "(", "x", ">>", "5", ")", "&", "0xf", ";", "DELAY", "(", "32", ")", ";", "break", ";", "}", "if", "(", "vector", ")", "cpustate", "->", "ml", "=", "(", "cpustate", "->", "ml", "&", "0x3E0", ")", "|", "(", "(", "cpustate", "->", "ml", "+", "1", ")", "&", "0x1F", ")", ";", "}", "while", "(", "vector", "&&", "has_operand", "&&", "(", "++", "i", "<", "32", ")", ")", ";", "delay3", "=", "load_ml", "(", "cpustate", ",", "y", ",", "0", ")", ";", "if", "(", "delay2", ">", "delay3", ")", "delay3", "=", "delay2", ";", "if", "(", "delay3", ")", "{", "DELAY", "(", "delay3", ")", ";", "}", "special_fetch", ":", "cpustate", "->", "cr", "=", "word_read", "(", "cpustate", ",", "cpustate", "->", "ml", ",", "0", ")", ";", "}" ]
execute one instruction TODO: test!!
[ "execute", "one", "instruction", "TODO", ":", "test!!" ]
[ "/* instruction fields */", "/* misc counter */", "/* true if instruction is an AU operation with an X operand */", "/* table for has_operand - one entry for each function code */", "/* pre-operand-access delay */", "/* post-operation delay */", "/* pre-operand-fetch delay */", "/* first isolate the instruction fields */", "/* this is a mere guess - the LSBit is reserved for future additions */", "/* determinates if we need to read an operand*/", "/* load ml with X */", "/* burn pre-operand-access delay if needed */", "/* default */", "/* stop */", "/* BTW, I don't know whether stop loads y into ml or not, and whether\r\n subsequent fetch is done */", "/* I */", "/* I do not know whether the CPU does an OR or whatever, but since docs say that\r\n the 5 bits must be cleared initially, an OR kind of makes sense */", "/* no idea whether this should be counted as an absolute delay\r\n or as a value in delay2 */", "/* P */", "/* no idea whether this should be counted as an absolute delay\r\n or as a value in delay2 */", "/* B<(x)>=(y) */", "/* I have no idea what we should do if the vector bit is set */", "/* load ml with X */", "/* burn pre-fetch delay if needed */", "/* and do fetch at X */", "/* else, the instruction ends with a normal fetch */", "/* l_n */", "/* if more than 32 shifts, it takes more time */", "/* Yes, this code is inefficient, but this must be the way the APEXC does it ;-) */", "/* shift and increment c6 */", "/* r_n */", "/* if more than 32 shifts, it takes more time */", "/* Yes, this code is inefficient, but this must be the way the APEXC does it ;-) */", "/* shift and increment c6 */", "/* unused function code. I assume this results into a NOP, for lack of any\r\n specific info... */", "/* X_n(x) */", "/* Yes, this code is inefficient, but this must be the way the APEXC does it ;-) */", "/* algorithm found in Booth&Booth, p. 45-48 */", "/* note we read word at current word position */", "/* Even if we do not read anything, the loop still takes 1 cycle of\r\n the memory word clock. */", "/* Anyway, maybe we still read the data even if we do not use it. */", "/* exit if c6 reached 32 (\"c6 & 0x20\" is simpler to implement and\r\n essentially equivalent, so this is most likely the actual implementation) */", "/* else increment c6 and shift */", "/* shift */", "//DELAY(32); /* mmmh... we have already counted 32 wait states */\r", "/* actually, if (n < 32) (which is an untypical case), we do not have 32 wait\r\n states. Question is: do we really have 32 wait states if (n < 32), or is\r\n the timing table incomplete? */", "/* +c(x) */", "/* -c(x) */", "/* +(x) */", "/* -(x) */", "/* T(x) */", "/* R_(1-n)(x) & R_(n-32)(x) */", "/* A_(1-n)(x) & A_(n-32)(x) */", "/* S(x) */", "/* or is it (x >> 6)? */", "/* no idea what the value is... All I know is that it takes much\r\n more time than track switching (which takes 6 cycles) */", "/* increment word position in vector operations */", "/* iterate 32 times if vector bit is set */", "/* the has_operand is a mere guess */", "/* load ml with Y */", "/* compute max(delay2, delay3) */", "/* burn pre-fetch delay if needed */", "/* entry point after a successful Branch (which alters the normal instruction sequence,\r\n in order not to load ml with Y) */", "/* fetch current instruction into control register */" ]
[ { "param": "cpustate", "type": "apexc_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cpustate", "type": "apexc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba5e5d2677daeec6e843f4602fe2c3620f786438
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/drivers/namcoic.c
[ "Unlicense" ]
C
roz_get_info
void
static void roz_get_info( running_machine *machine, tile_data *tileinfo, int tile_index, int which) { UINT16 tile = rozvideoram16[tile_index]; int bank, mangle; switch( namcos2_gametype ) { case NAMCONB2_MACH_BREAKERS: bank = nth_byte16( &rozbank16[which*8/2], (tile>>11)&0x7 ); tile = (tile&0x7ff)|(bank*0x800); mangle = tile; break; case NAMCONB2_OUTFOXIES: bank = nth_byte16( &rozbank16[which*8/2], (tile>>11)&0x7 ); tile = (tile&0x7ff)|(bank*0x800); mangle = tile&~(0x50); if( tile&0x10 ) mangle |= 0x40; if( tile&0x40 ) mangle |= 0x10; break; case NAMCOS2_LUCKY_AND_WILD: mangle = tile&0x01ff; tile &= 0x3fff; switch( tile>>9 ) { case 0x00: mangle |= 0x1c00; break; case 0x01: mangle |= 0x0800; break; case 0x02: mangle |= 0x0000; break; case 0x08: mangle |= 0x1e00; break; case 0x09: mangle |= 0x0a00; break; case 0x0a: mangle |= 0x0200; break; case 0x10: mangle |= 0x2000; break; case 0x11: mangle |= 0x0c00; break; case 0x12: mangle |= 0x0400; break; case 0x18: mangle |= 0x2200; break; case 0x19: mangle |= 0x0e00; break; case 0x1a: mangle |= 0x0600; break; } break; case NAMCOS2_METAL_HAWK: mangle = tile&0x01ff; if( tile&0x1000 ) mangle |= 0x0200; if( tile&0x0200 ) mangle |= 0x0400; if( tile&0x0400 ) mangle |= 0x0800; if( tile&0x0800 ) mangle |= 0x1000; tile &= 0x3fff; /* cap mask offset */ break; default: case NAMCOFL_SPEED_RACER: case NAMCOFL_FINAL_LAP_R: mangle = tile; tile &= 0x3fff; /* cap mask offset */ break; } SET_TILE_INFO( mRozGfxBank,mangle,0/*color*/,0/*flag*/ ); tileinfo->mask_data = 32*tile + (UINT8 *)memory_region( machine, mRozMaskRegion ); }
/** * Graphics ROM addressing varies across games. */
Graphics ROM addressing varies across games.
[ "Graphics", "ROM", "addressing", "varies", "across", "games", "." ]
static void roz_get_info( running_machine *machine, tile_data *tileinfo, int tile_index, int which) { UINT16 tile = rozvideoram16[tile_index]; int bank, mangle; switch( namcos2_gametype ) { case NAMCONB2_MACH_BREAKERS: bank = nth_byte16( &rozbank16[which*8/2], (tile>>11)&0x7 ); tile = (tile&0x7ff)|(bank*0x800); mangle = tile; break; case NAMCONB2_OUTFOXIES: bank = nth_byte16( &rozbank16[which*8/2], (tile>>11)&0x7 ); tile = (tile&0x7ff)|(bank*0x800); mangle = tile&~(0x50); if( tile&0x10 ) mangle |= 0x40; if( tile&0x40 ) mangle |= 0x10; break; case NAMCOS2_LUCKY_AND_WILD: mangle = tile&0x01ff; tile &= 0x3fff; switch( tile>>9 ) { case 0x00: mangle |= 0x1c00; break; case 0x01: mangle |= 0x0800; break; case 0x02: mangle |= 0x0000; break; case 0x08: mangle |= 0x1e00; break; case 0x09: mangle |= 0x0a00; break; case 0x0a: mangle |= 0x0200; break; case 0x10: mangle |= 0x2000; break; case 0x11: mangle |= 0x0c00; break; case 0x12: mangle |= 0x0400; break; case 0x18: mangle |= 0x2200; break; case 0x19: mangle |= 0x0e00; break; case 0x1a: mangle |= 0x0600; break; } break; case NAMCOS2_METAL_HAWK: mangle = tile&0x01ff; if( tile&0x1000 ) mangle |= 0x0200; if( tile&0x0200 ) mangle |= 0x0400; if( tile&0x0400 ) mangle |= 0x0800; if( tile&0x0800 ) mangle |= 0x1000; tile &= 0x3fff; break; default: case NAMCOFL_SPEED_RACER: case NAMCOFL_FINAL_LAP_R: mangle = tile; tile &= 0x3fff; break; } SET_TILE_INFO( mRozGfxBank,mangle,0,0 ); tileinfo->mask_data = 32*tile + (UINT8 *)memory_region( machine, mRozMaskRegion ); }
[ "static", "void", "roz_get_info", "(", "running_machine", "*", "machine", ",", "tile_data", "*", "tileinfo", ",", "int", "tile_index", ",", "int", "which", ")", "{", "UINT16", "tile", "=", "rozvideoram16", "[", "tile_index", "]", ";", "int", "bank", ",", "mangle", ";", "switch", "(", "namcos2_gametype", ")", "{", "case", "NAMCONB2_MACH_BREAKERS", ":", "bank", "=", "nth_byte16", "(", "&", "rozbank16", "[", "which", "*", "8", "/", "2", "]", ",", "(", "tile", ">>", "11", ")", "&", "0x7", ")", ";", "tile", "=", "(", "tile", "&", "0x7ff", ")", "|", "(", "bank", "*", "0x800", ")", ";", "mangle", "=", "tile", ";", "break", ";", "case", "NAMCONB2_OUTFOXIES", ":", "bank", "=", "nth_byte16", "(", "&", "rozbank16", "[", "which", "*", "8", "/", "2", "]", ",", "(", "tile", ">>", "11", ")", "&", "0x7", ")", ";", "tile", "=", "(", "tile", "&", "0x7ff", ")", "|", "(", "bank", "*", "0x800", ")", ";", "mangle", "=", "tile", "&", "~", "(", "0x50", ")", ";", "if", "(", "tile", "&", "0x10", ")", "mangle", "|=", "0x40", ";", "if", "(", "tile", "&", "0x40", ")", "mangle", "|=", "0x10", ";", "break", ";", "case", "NAMCOS2_LUCKY_AND_WILD", ":", "mangle", "=", "tile", "&", "0x01ff", ";", "tile", "&=", "0x3fff", ";", "switch", "(", "tile", ">>", "9", ")", "{", "case", "0x00", ":", "mangle", "|=", "0x1c00", ";", "break", ";", "case", "0x01", ":", "mangle", "|=", "0x0800", ";", "break", ";", "case", "0x02", ":", "mangle", "|=", "0x0000", ";", "break", ";", "case", "0x08", ":", "mangle", "|=", "0x1e00", ";", "break", ";", "case", "0x09", ":", "mangle", "|=", "0x0a00", ";", "break", ";", "case", "0x0a", ":", "mangle", "|=", "0x0200", ";", "break", ";", "case", "0x10", ":", "mangle", "|=", "0x2000", ";", "break", ";", "case", "0x11", ":", "mangle", "|=", "0x0c00", ";", "break", ";", "case", "0x12", ":", "mangle", "|=", "0x0400", ";", "break", ";", "case", "0x18", ":", "mangle", "|=", "0x2200", ";", "break", ";", "case", "0x19", ":", "mangle", "|=", "0x0e00", ";", "break", ";", "case", "0x1a", ":", "mangle", "|=", "0x0600", ";", "break", ";", "}", "break", ";", "case", "NAMCOS2_METAL_HAWK", ":", "mangle", "=", "tile", "&", "0x01ff", ";", "if", "(", "tile", "&", "0x1000", ")", "mangle", "|=", "0x0200", ";", "if", "(", "tile", "&", "0x0200", ")", "mangle", "|=", "0x0400", ";", "if", "(", "tile", "&", "0x0400", ")", "mangle", "|=", "0x0800", ";", "if", "(", "tile", "&", "0x0800", ")", "mangle", "|=", "0x1000", ";", "tile", "&=", "0x3fff", ";", "break", ";", "default", ":", "case", "NAMCOFL_SPEED_RACER", ":", "case", "NAMCOFL_FINAL_LAP_R", ":", "mangle", "=", "tile", ";", "tile", "&=", "0x3fff", ";", "break", ";", "}", "SET_TILE_INFO", "(", "mRozGfxBank", ",", "mangle", ",", "0", ",", "0", ")", ";", "tileinfo", "->", "mask_data", "=", "32", "*", "tile", "+", "(", "UINT8", "*", ")", "memory_region", "(", "machine", ",", "mRozMaskRegion", ")", ";", "}" ]
Graphics ROM addressing varies across games.
[ "Graphics", "ROM", "addressing", "varies", "across", "games", "." ]
[ "/* cap mask offset */", "/* cap mask offset */", "/*color*/", "/*flag*/" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "tileinfo", "type": "tile_data" }, { "param": "tile_index", "type": "int" }, { "param": "which", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "tileinfo", "type": "tile_data", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "tile_index", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "which", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
511d22f2c7f0482031dffd7991a0bdba46ff5339
lofunz/mieme
Reloaded/trunk/src/emu/cpu/h83002/h8ops.h
[ "Unlicense" ]
C
h8_bor8
void
static void h8_bor8(h83xx_state *h8, UINT8 src, UINT8 dst) { // pass UINT8 res; res = dst & (1<<src); h8->h8cflag |= res ? 1 : 0; }
// does not affect result, res in C flag only
does not affect result, res in C flag only
[ "does", "not", "affect", "result", "res", "in", "C", "flag", "only" ]
static void h8_bor8(h83xx_state *h8, UINT8 src, UINT8 dst) { UINT8 res; res = dst & (1<<src); h8->h8cflag |= res ? 1 : 0; }
[ "static", "void", "h8_bor8", "(", "h83xx_state", "*", "h8", ",", "UINT8", "src", ",", "UINT8", "dst", ")", "{", "UINT8", "res", ";", "res", "=", "dst", "&", "(", "1", "<<", "src", ")", ";", "h8", "->", "h8cflag", "|=", "res", "?", "1", ":", "0", ";", "}" ]
does not affect result, res in C flag only
[ "does", "not", "affect", "result", "res", "in", "C", "flag", "only" ]
[ "// pass\r" ]
[ { "param": "h8", "type": "h83xx_state" }, { "param": "src", "type": "UINT8" }, { "param": "dst", "type": "UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "h8", "type": "h83xx_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "src", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dst", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
511d22f2c7f0482031dffd7991a0bdba46ff5339
lofunz/mieme
Reloaded/trunk/src/emu/cpu/h83002/h8ops.h
[ "Unlicense" ]
C
h8_branch
int
static int h8_branch(h83xx_state *h8, UINT8 condition) { int taken = 0; // a branch always eats 2 ifetch states, regardless of if it's taken H8_IFETCH_TIMING(2) switch(condition) { case 0: // bt taken = 1; break; case 1: // bf break; case 2: // bhi (C | Z) == 0) if((h8->h8cflag | h8->h8zflag) == 0)taken = 1; break; case 3: // bls if((h8->h8cflag | h8->h8zflag) == 1)taken = 1; break; case 4: // bcc C = 0 if(h8->h8cflag == 0)taken = 1; break; case 5: // bcs C = 1 if(h8->h8cflag == 1)taken = 1; break; case 6: // bne Z = 0 if(h8->h8zflag == 0)taken = 1; break; case 7: // beq Z = 1 if(h8->h8zflag == 1)taken = 1; break; case 8: // bvc V = 0 h8->h8err = 1; if(h8->h8vflag == 0)taken = 1; break; case 9: // bvs V = 1 h8->h8err = 1; if(h8->h8vflag == 1)taken = 1; break; case 0xa: // bpl N = 0 if(h8->h8nflag == 0)taken = 1; break; case 0xb: // bmi N = 1 if(h8->h8nflag == 1)taken = 1; break; case 0xc: // bge (N ^ V) = 0 if((h8->h8nflag ^ h8->h8vflag) == 0)taken = 1; break; case 0xd: // blt (N ^ V) = 1 if((h8->h8nflag ^ h8->h8vflag) == 1)taken = 1; break; case 0xe: // bgt (Z | (N ^ V)) = 0 if((h8->h8zflag | (h8->h8nflag ^ h8->h8vflag)) == 0)taken = 1; break; case 0xf: // ble (Z | (N ^ V)) = 1 if((h8->h8zflag | (h8->h8nflag ^ h8->h8vflag)) == 1)taken = 1; break; } return taken; }
// input: branch condition // output: 1 if condition met, 0 if not condition met
branch condition output: 1 if condition met, 0 if not condition met
[ "branch", "condition", "output", ":", "1", "if", "condition", "met", "0", "if", "not", "condition", "met" ]
static int h8_branch(h83xx_state *h8, UINT8 condition) { int taken = 0; H8_IFETCH_TIMING(2) switch(condition) { case 0: taken = 1; break; case 1: break; case 2: if((h8->h8cflag | h8->h8zflag) == 0)taken = 1; break; case 3: if((h8->h8cflag | h8->h8zflag) == 1)taken = 1; break; case 4: if(h8->h8cflag == 0)taken = 1; break; case 5: if(h8->h8cflag == 1)taken = 1; break; case 6: if(h8->h8zflag == 0)taken = 1; break; case 7: if(h8->h8zflag == 1)taken = 1; break; case 8: h8->h8err = 1; if(h8->h8vflag == 0)taken = 1; break; case 9: h8->h8err = 1; if(h8->h8vflag == 1)taken = 1; break; case 0xa: if(h8->h8nflag == 0)taken = 1; break; case 0xb: if(h8->h8nflag == 1)taken = 1; break; case 0xc: if((h8->h8nflag ^ h8->h8vflag) == 0)taken = 1; break; case 0xd: if((h8->h8nflag ^ h8->h8vflag) == 1)taken = 1; break; case 0xe: if((h8->h8zflag | (h8->h8nflag ^ h8->h8vflag)) == 0)taken = 1; break; case 0xf: if((h8->h8zflag | (h8->h8nflag ^ h8->h8vflag)) == 1)taken = 1; break; } return taken; }
[ "static", "int", "h8_branch", "(", "h83xx_state", "*", "h8", ",", "UINT8", "condition", ")", "{", "int", "taken", "=", "0", ";", "H8_IFETCH_TIMING", "(", "2", ")", "", "switch", "(", "condition", ")", "{", "case", "0", ":", "taken", "=", "1", ";", "break", ";", "case", "1", ":", "break", ";", "case", "2", ":", "if", "(", "(", "h8", "->", "h8cflag", "|", "h8", "->", "h8zflag", ")", "==", "0", ")", "taken", "=", "1", ";", "break", ";", "case", "3", ":", "if", "(", "(", "h8", "->", "h8cflag", "|", "h8", "->", "h8zflag", ")", "==", "1", ")", "taken", "=", "1", ";", "break", ";", "case", "4", ":", "if", "(", "h8", "->", "h8cflag", "==", "0", ")", "taken", "=", "1", ";", "break", ";", "case", "5", ":", "if", "(", "h8", "->", "h8cflag", "==", "1", ")", "taken", "=", "1", ";", "break", ";", "case", "6", ":", "if", "(", "h8", "->", "h8zflag", "==", "0", ")", "taken", "=", "1", ";", "break", ";", "case", "7", ":", "if", "(", "h8", "->", "h8zflag", "==", "1", ")", "taken", "=", "1", ";", "break", ";", "case", "8", ":", "h8", "->", "h8err", "=", "1", ";", "if", "(", "h8", "->", "h8vflag", "==", "0", ")", "taken", "=", "1", ";", "break", ";", "case", "9", ":", "h8", "->", "h8err", "=", "1", ";", "if", "(", "h8", "->", "h8vflag", "==", "1", ")", "taken", "=", "1", ";", "break", ";", "case", "0xa", ":", "if", "(", "h8", "->", "h8nflag", "==", "0", ")", "taken", "=", "1", ";", "break", ";", "case", "0xb", ":", "if", "(", "h8", "->", "h8nflag", "==", "1", ")", "taken", "=", "1", ";", "break", ";", "case", "0xc", ":", "if", "(", "(", "h8", "->", "h8nflag", "^", "h8", "->", "h8vflag", ")", "==", "0", ")", "taken", "=", "1", ";", "break", ";", "case", "0xd", ":", "if", "(", "(", "h8", "->", "h8nflag", "^", "h8", "->", "h8vflag", ")", "==", "1", ")", "taken", "=", "1", ";", "break", ";", "case", "0xe", ":", "if", "(", "(", "h8", "->", "h8zflag", "|", "(", "h8", "->", "h8nflag", "^", "h8", "->", "h8vflag", ")", ")", "==", "0", ")", "taken", "=", "1", ";", "break", ";", "case", "0xf", ":", "if", "(", "(", "h8", "->", "h8zflag", "|", "(", "h8", "->", "h8nflag", "^", "h8", "->", "h8vflag", ")", ")", "==", "1", ")", "taken", "=", "1", ";", "break", ";", "}", "return", "taken", ";", "}" ]
input: branch condition output: 1 if condition met, 0 if not condition met
[ "input", ":", "branch", "condition", "output", ":", "1", "if", "condition", "met", "0", "if", "not", "condition", "met" ]
[ "// a branch always eats 2 ifetch states, regardless of if it's taken\r", "// bt\r", "// bf\r", "// bhi (C | Z) == 0)\r", "// bls\r", "// bcc C = 0\r", "// bcs C = 1\r", "// bne Z = 0\r", "// beq Z = 1\r", "// bvc V = 0\r", "// bvs V = 1\r", "// bpl N = 0\r", "// bmi N = 1\r", "// bge (N ^ V) = 0\r", "// blt (N ^ V) = 1\r", "// bgt (Z | (N ^ V)) = 0\r", "// ble (Z | (N ^ V)) = 1\r" ]
[ { "param": "h8", "type": "h83xx_state" }, { "param": "condition", "type": "UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "h8", "type": "h83xx_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "condition", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d313f3c9f59e771573da8129ab540a1362cac850
lofunz/mieme
Reloaded/trunk/src/lib/util/zippath.c
[ "Unlicense" ]
C
create_core_file_from_zip
file_error
static file_error create_core_file_from_zip(zip_file *zip, const zip_file_header *header, core_file **file) { file_error filerr; zip_error ziperr; void *ptr; ptr = malloc(header->uncompressed_length); if (ptr == NULL) { filerr = FILERR_OUT_OF_MEMORY; goto done; } ziperr = zip_file_decompress(zip, ptr, header->uncompressed_length); if (ziperr != ZIPERR_NONE) { filerr = file_error_from_zip_error(ziperr); goto done; } filerr = core_fopen_ram_copy(ptr, header->uncompressed_length, OPEN_FLAG_READ, file); if (filerr != FILERR_NONE) goto done; done: if (ptr != NULL) free(ptr); return filerr; }
/*------------------------------------------------- create_core_file_from_zip - creates a core_file from a zip file entry -------------------------------------------------*/
creates a core_file from a zip file entry
[ "creates", "a", "core_file", "from", "a", "zip", "file", "entry" ]
static file_error create_core_file_from_zip(zip_file *zip, const zip_file_header *header, core_file **file) { file_error filerr; zip_error ziperr; void *ptr; ptr = malloc(header->uncompressed_length); if (ptr == NULL) { filerr = FILERR_OUT_OF_MEMORY; goto done; } ziperr = zip_file_decompress(zip, ptr, header->uncompressed_length); if (ziperr != ZIPERR_NONE) { filerr = file_error_from_zip_error(ziperr); goto done; } filerr = core_fopen_ram_copy(ptr, header->uncompressed_length, OPEN_FLAG_READ, file); if (filerr != FILERR_NONE) goto done; done: if (ptr != NULL) free(ptr); return filerr; }
[ "static", "file_error", "create_core_file_from_zip", "(", "zip_file", "*", "zip", ",", "const", "zip_file_header", "*", "header", ",", "core_file", "*", "*", "file", ")", "{", "file_error", "filerr", ";", "zip_error", "ziperr", ";", "void", "*", "ptr", ";", "ptr", "=", "malloc", "(", "header", "->", "uncompressed_length", ")", ";", "if", "(", "ptr", "==", "NULL", ")", "{", "filerr", "=", "FILERR_OUT_OF_MEMORY", ";", "goto", "done", ";", "}", "ziperr", "=", "zip_file_decompress", "(", "zip", ",", "ptr", ",", "header", "->", "uncompressed_length", ")", ";", "if", "(", "ziperr", "!=", "ZIPERR_NONE", ")", "{", "filerr", "=", "file_error_from_zip_error", "(", "ziperr", ")", ";", "goto", "done", ";", "}", "filerr", "=", "core_fopen_ram_copy", "(", "ptr", ",", "header", "->", "uncompressed_length", ",", "OPEN_FLAG_READ", ",", "file", ")", ";", "if", "(", "filerr", "!=", "FILERR_NONE", ")", "goto", "done", ";", "done", ":", "if", "(", "ptr", "!=", "NULL", ")", "free", "(", "ptr", ")", ";", "return", "filerr", ";", "}" ]
create_core_file_from_zip - creates a core_file from a zip file entry
[ "create_core_file_from_zip", "-", "creates", "a", "core_file", "from", "a", "zip", "file", "entry" ]
[]
[ { "param": "zip", "type": "zip_file" }, { "param": "header", "type": "zip_file_header" }, { "param": "file", "type": "core_file" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "zip", "type": "zip_file", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "header", "type": "zip_file_header", "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": [] }
d313f3c9f59e771573da8129ab540a1362cac850
lofunz/mieme
Reloaded/trunk/src/lib/util/zippath.c
[ "Unlicense" ]
C
is_root
int
static int is_root(const char *path) { int i = 0; /* skip drive letter */ if (isalpha(path[i]) && (path[i + 1] == ':')) i += 2; /* skip path separators */ while (is_path_separator(path[i])) i++; return path[i] == '\0'; }
/*------------------------------------------------- is_root - tests to see if this path is the root -------------------------------------------------*/
tests to see if this path is the root
[ "tests", "to", "see", "if", "this", "path", "is", "the", "root" ]
static int is_root(const char *path) { int i = 0; if (isalpha(path[i]) && (path[i + 1] == ':')) i += 2; while (is_path_separator(path[i])) i++; return path[i] == '\0'; }
[ "static", "int", "is_root", "(", "const", "char", "*", "path", ")", "{", "int", "i", "=", "0", ";", "if", "(", "isalpha", "(", "path", "[", "i", "]", ")", "&&", "(", "path", "[", "i", "+", "1", "]", "==", "'", "'", ")", ")", "i", "+=", "2", ";", "while", "(", "is_path_separator", "(", "path", "[", "i", "]", ")", ")", "i", "++", ";", "return", "path", "[", "i", "]", "==", "'", "\\0", "'", ";", "}" ]
is_root - tests to see if this path is the root
[ "is_root", "-", "tests", "to", "see", "if", "this", "path", "is", "the", "root" ]
[ "/* skip drive letter */", "/* skip path separators */" ]
[ { "param": "path", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "path", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d313f3c9f59e771573da8129ab540a1362cac850
lofunz/mieme
Reloaded/trunk/src/lib/util/zippath.c
[ "Unlicense" ]
C
is_zip_file
int
static int is_zip_file(const char *path) { const char *s = strrchr(path, '.'); return (s != NULL) && !core_stricmp(s, ".zip"); }
/*------------------------------------------------- is_zip_file - tests to see if this file is a ZIP file -------------------------------------------------*/
tests to see if this file is a ZIP file
[ "tests", "to", "see", "if", "this", "file", "is", "a", "ZIP", "file" ]
static int is_zip_file(const char *path) { const char *s = strrchr(path, '.'); return (s != NULL) && !core_stricmp(s, ".zip"); }
[ "static", "int", "is_zip_file", "(", "const", "char", "*", "path", ")", "{", "const", "char", "*", "s", "=", "strrchr", "(", "path", ",", "'", "'", ")", ";", "return", "(", "s", "!=", "NULL", ")", "&&", "!", "core_stricmp", "(", "s", ",", "\"", "\"", ")", ";", "}" ]
is_zip_file - tests to see if this file is a ZIP file
[ "is_zip_file", "-", "tests", "to", "see", "if", "this", "file", "is", "a", "ZIP", "file" ]
[]
[ { "param": "path", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "path", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d313f3c9f59e771573da8129ab540a1362cac850
lofunz/mieme
Reloaded/trunk/src/lib/util/zippath.c
[ "Unlicense" ]
C
next_path_char
char
static char next_path_char(const char *s, int *pos) { char result; /* skip over any initial separators */ if (*pos == 0) { while(is_zip_file_separator(s[*pos])) (*pos)++; } /* are we at a path separator? */ if (is_zip_file_separator(s[*pos])) { /* skip over path separators */ while(is_zip_file_separator(s[*pos])) (*pos)++; /* normalize as '/' */ result = '/'; } else if (s[*pos] != '\0') { /* return character */ result = tolower(s[(*pos)++]); } else { /* return NUL */ result = '\0'; } return result; }
/*------------------------------------------------- next_path_char - lexes out the next path character, normalizing separators as '/' -------------------------------------------------*/
lexes out the next path character, normalizing separators as '/'
[ "lexes", "out", "the", "next", "path", "character", "normalizing", "separators", "as", "'", "/", "'" ]
static char next_path_char(const char *s, int *pos) { char result; if (*pos == 0) { while(is_zip_file_separator(s[*pos])) (*pos)++; } if (is_zip_file_separator(s[*pos])) { while(is_zip_file_separator(s[*pos])) (*pos)++; result = '/'; } else if (s[*pos] != '\0') { result = tolower(s[(*pos)++]); } else { result = '\0'; } return result; }
[ "static", "char", "next_path_char", "(", "const", "char", "*", "s", ",", "int", "*", "pos", ")", "{", "char", "result", ";", "if", "(", "*", "pos", "==", "0", ")", "{", "while", "(", "is_zip_file_separator", "(", "s", "[", "*", "pos", "]", ")", ")", "(", "*", "pos", ")", "++", ";", "}", "if", "(", "is_zip_file_separator", "(", "s", "[", "*", "pos", "]", ")", ")", "{", "while", "(", "is_zip_file_separator", "(", "s", "[", "*", "pos", "]", ")", ")", "(", "*", "pos", ")", "++", ";", "result", "=", "'", "'", ";", "}", "else", "if", "(", "s", "[", "*", "pos", "]", "!=", "'", "\\0", "'", ")", "{", "result", "=", "tolower", "(", "s", "[", "(", "*", "pos", ")", "++", "]", ")", ";", "}", "else", "{", "result", "=", "'", "\\0", "'", ";", "}", "return", "result", ";", "}" ]
next_path_char - lexes out the next path character, normalizing separators as '/'
[ "next_path_char", "-", "lexes", "out", "the", "next", "path", "character", "normalizing", "separators", "as", "'", "/", "'" ]
[ "/* skip over any initial separators */", "/* are we at a path separator? */", "/* skip over path separators */", "/* normalize as '/' */", "/* return character */", "/* return NUL */" ]
[ { "param": "s", "type": "char" }, { "param": "pos", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "s", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pos", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d313f3c9f59e771573da8129ab540a1362cac850
lofunz/mieme
Reloaded/trunk/src/lib/util/zippath.c
[ "Unlicense" ]
C
zippath_find_sub_path
zip_file_header
static const zip_file_header *zippath_find_sub_path(zip_file *zipfile, const char *subpath, osd_dir_entry_type *type) { int i, j; char c1, c2, last_char; const zip_file_header *header; for (header = zip_file_first_file(zipfile); header != NULL; header = zip_file_next_file(zipfile)) { /* special case */ if (subpath == NULL) { if (type != NULL) *type = ENTTYPE_FILE; return header; } i = 0; j = 0; last_char = '/'; while(((c1 = next_path_char(header->filename, &i)) == (c2 = next_path_char(subpath, &j))) && ( c1 != '\0' && c2 != '\0' )) last_char = c2; if (c2 == '\0') { if (c1 == '\0') { if (type != NULL) *type = ENTTYPE_FILE; return header; } else if ((last_char == '/') || (c1 == '/')) { if (type != NULL) *type = ENTTYPE_DIR; return header; } } } if (type != NULL) *type = ENTTYPE_NONE; return NULL; }
/*------------------------------------------------- zippath_find_sub_path - attempts to identify the type of a sub path in a zip file -------------------------------------------------*/
attempts to identify the type of a sub path in a zip file
[ "attempts", "to", "identify", "the", "type", "of", "a", "sub", "path", "in", "a", "zip", "file" ]
static const zip_file_header *zippath_find_sub_path(zip_file *zipfile, const char *subpath, osd_dir_entry_type *type) { int i, j; char c1, c2, last_char; const zip_file_header *header; for (header = zip_file_first_file(zipfile); header != NULL; header = zip_file_next_file(zipfile)) { if (subpath == NULL) { if (type != NULL) *type = ENTTYPE_FILE; return header; } i = 0; j = 0; last_char = '/'; while(((c1 = next_path_char(header->filename, &i)) == (c2 = next_path_char(subpath, &j))) && ( c1 != '\0' && c2 != '\0' )) last_char = c2; if (c2 == '\0') { if (c1 == '\0') { if (type != NULL) *type = ENTTYPE_FILE; return header; } else if ((last_char == '/') || (c1 == '/')) { if (type != NULL) *type = ENTTYPE_DIR; return header; } } } if (type != NULL) *type = ENTTYPE_NONE; return NULL; }
[ "static", "const", "zip_file_header", "*", "zippath_find_sub_path", "(", "zip_file", "*", "zipfile", ",", "const", "char", "*", "subpath", ",", "osd_dir_entry_type", "*", "type", ")", "{", "int", "i", ",", "j", ";", "char", "c1", ",", "c2", ",", "last_char", ";", "const", "zip_file_header", "*", "header", ";", "for", "(", "header", "=", "zip_file_first_file", "(", "zipfile", ")", ";", "header", "!=", "NULL", ";", "header", "=", "zip_file_next_file", "(", "zipfile", ")", ")", "{", "if", "(", "subpath", "==", "NULL", ")", "{", "if", "(", "type", "!=", "NULL", ")", "*", "type", "=", "ENTTYPE_FILE", ";", "return", "header", ";", "}", "i", "=", "0", ";", "j", "=", "0", ";", "last_char", "=", "'", "'", ";", "while", "(", "(", "(", "c1", "=", "next_path_char", "(", "header", "->", "filename", ",", "&", "i", ")", ")", "==", "(", "c2", "=", "next_path_char", "(", "subpath", ",", "&", "j", ")", ")", ")", "&&", "(", "c1", "!=", "'", "\\0", "'", "&&", "c2", "!=", "'", "\\0", "'", ")", ")", "last_char", "=", "c2", ";", "if", "(", "c2", "==", "'", "\\0", "'", ")", "{", "if", "(", "c1", "==", "'", "\\0", "'", ")", "{", "if", "(", "type", "!=", "NULL", ")", "*", "type", "=", "ENTTYPE_FILE", ";", "return", "header", ";", "}", "else", "if", "(", "(", "last_char", "==", "'", "'", ")", "||", "(", "c1", "==", "'", "'", ")", ")", "{", "if", "(", "type", "!=", "NULL", ")", "*", "type", "=", "ENTTYPE_DIR", ";", "return", "header", ";", "}", "}", "}", "if", "(", "type", "!=", "NULL", ")", "*", "type", "=", "ENTTYPE_NONE", ";", "return", "NULL", ";", "}" ]
zippath_find_sub_path - attempts to identify the type of a sub path in a zip file
[ "zippath_find_sub_path", "-", "attempts", "to", "identify", "the", "type", "of", "a", "sub", "path", "in", "a", "zip", "file" ]
[ "/* special case */" ]
[ { "param": "zipfile", "type": "zip_file" }, { "param": "subpath", "type": "char" }, { "param": "type", "type": "osd_dir_entry_type" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "zipfile", "type": "zip_file", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "subpath", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "type", "type": "osd_dir_entry_type", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d313f3c9f59e771573da8129ab540a1362cac850
lofunz/mieme
Reloaded/trunk/src/lib/util/zippath.c
[ "Unlicense" ]
C
zippath_resolve
file_error
static file_error zippath_resolve(const char *path, osd_dir_entry_type *entry_type, zip_file **zipfile, astring *newpath) { file_error err; osd_directory_entry *current_entry = NULL; osd_dir_entry_type current_entry_type; astring *apath = astring_cpyc(astring_alloc(), path); astring *apath_trimmed = astring_alloc(); astring *parent = NULL; int went_up = FALSE; int i; /* be conservative */ *entry_type = ENTTYPE_NONE; *zipfile = NULL; do { /* trim the path of trailing path separators */ i = astring_len(apath); while((i > 1) && is_path_separator(astring_c(apath)[i - 1])) i--; apath_trimmed = astring_cpysubstr(apath_trimmed, apath, 0, i); /* stat the path */ current_entry = osd_stat(astring_c(apath_trimmed)); /* did we find anything? */ if (current_entry != NULL) { /* get the entry type and free the stat entry */ current_entry_type = current_entry->type; free(current_entry); current_entry = NULL; } else { /* if we have not found the file or directory, go up */ current_entry_type = ENTTYPE_NONE; went_up = TRUE; parent = zippath_parent(astring_alloc(), astring_c(apath)); astring_free(apath); apath = parent; } } while((current_entry_type == ENTTYPE_NONE) && (apath != NULL) && !is_root(astring_c(apath))); /* if we did not find anything, then error out */ if (current_entry_type == ENTTYPE_NONE) { err = FILERR_NOT_FOUND; goto done; } /* is this file a ZIP file? */ if ((current_entry_type == ENTTYPE_FILE) && is_zip_file(astring_c(apath_trimmed)) && (zip_file_open(astring_c(apath_trimmed), zipfile) == ZIPERR_NONE)) { i = strlen(path + astring_len(apath)); while((i > 0) && is_zip_path_separator(path[astring_len(apath) + i - 1])) i--; astring_cpych(newpath, path + astring_len(apath), i); /* this was a true ZIP path - attempt to identify the type of path */ zippath_find_sub_path(*zipfile, astring_c(newpath), &current_entry_type); if (current_entry_type == ENTTYPE_NONE) { err = FILERR_NOT_FOUND; goto done; } } else { /* this was a normal path */ if (went_up) { err = FILERR_NOT_FOUND; goto done; } astring_cpyc(newpath, path); } /* success! */ *entry_type = current_entry_type; err = FILERR_NONE; done: if (apath != NULL) astring_free(apath); if (apath_trimmed != NULL) astring_free(apath_trimmed); return err; }
/*------------------------------------------------- zippath_resolve - separates a ZIP path out into true path and ZIP entry components -------------------------------------------------*/
separates a ZIP path out into true path and ZIP entry components
[ "separates", "a", "ZIP", "path", "out", "into", "true", "path", "and", "ZIP", "entry", "components" ]
static file_error zippath_resolve(const char *path, osd_dir_entry_type *entry_type, zip_file **zipfile, astring *newpath) { file_error err; osd_directory_entry *current_entry = NULL; osd_dir_entry_type current_entry_type; astring *apath = astring_cpyc(astring_alloc(), path); astring *apath_trimmed = astring_alloc(); astring *parent = NULL; int went_up = FALSE; int i; *entry_type = ENTTYPE_NONE; *zipfile = NULL; do { i = astring_len(apath); while((i > 1) && is_path_separator(astring_c(apath)[i - 1])) i--; apath_trimmed = astring_cpysubstr(apath_trimmed, apath, 0, i); current_entry = osd_stat(astring_c(apath_trimmed)); if (current_entry != NULL) { current_entry_type = current_entry->type; free(current_entry); current_entry = NULL; } else { current_entry_type = ENTTYPE_NONE; went_up = TRUE; parent = zippath_parent(astring_alloc(), astring_c(apath)); astring_free(apath); apath = parent; } } while((current_entry_type == ENTTYPE_NONE) && (apath != NULL) && !is_root(astring_c(apath))); if (current_entry_type == ENTTYPE_NONE) { err = FILERR_NOT_FOUND; goto done; } if ((current_entry_type == ENTTYPE_FILE) && is_zip_file(astring_c(apath_trimmed)) && (zip_file_open(astring_c(apath_trimmed), zipfile) == ZIPERR_NONE)) { i = strlen(path + astring_len(apath)); while((i > 0) && is_zip_path_separator(path[astring_len(apath) + i - 1])) i--; astring_cpych(newpath, path + astring_len(apath), i); zippath_find_sub_path(*zipfile, astring_c(newpath), &current_entry_type); if (current_entry_type == ENTTYPE_NONE) { err = FILERR_NOT_FOUND; goto done; } } else { if (went_up) { err = FILERR_NOT_FOUND; goto done; } astring_cpyc(newpath, path); } *entry_type = current_entry_type; err = FILERR_NONE; done: if (apath != NULL) astring_free(apath); if (apath_trimmed != NULL) astring_free(apath_trimmed); return err; }
[ "static", "file_error", "zippath_resolve", "(", "const", "char", "*", "path", ",", "osd_dir_entry_type", "*", "entry_type", ",", "zip_file", "*", "*", "zipfile", ",", "astring", "*", "newpath", ")", "{", "file_error", "err", ";", "osd_directory_entry", "*", "current_entry", "=", "NULL", ";", "osd_dir_entry_type", "current_entry_type", ";", "astring", "*", "apath", "=", "astring_cpyc", "(", "astring_alloc", "(", ")", ",", "path", ")", ";", "astring", "*", "apath_trimmed", "=", "astring_alloc", "(", ")", ";", "astring", "*", "parent", "=", "NULL", ";", "int", "went_up", "=", "FALSE", ";", "int", "i", ";", "*", "entry_type", "=", "ENTTYPE_NONE", ";", "*", "zipfile", "=", "NULL", ";", "do", "{", "i", "=", "astring_len", "(", "apath", ")", ";", "while", "(", "(", "i", ">", "1", ")", "&&", "is_path_separator", "(", "astring_c", "(", "apath", ")", "[", "i", "-", "1", "]", ")", ")", "i", "--", ";", "apath_trimmed", "=", "astring_cpysubstr", "(", "apath_trimmed", ",", "apath", ",", "0", ",", "i", ")", ";", "current_entry", "=", "osd_stat", "(", "astring_c", "(", "apath_trimmed", ")", ")", ";", "if", "(", "current_entry", "!=", "NULL", ")", "{", "current_entry_type", "=", "current_entry", "->", "type", ";", "free", "(", "current_entry", ")", ";", "current_entry", "=", "NULL", ";", "}", "else", "{", "current_entry_type", "=", "ENTTYPE_NONE", ";", "went_up", "=", "TRUE", ";", "parent", "=", "zippath_parent", "(", "astring_alloc", "(", ")", ",", "astring_c", "(", "apath", ")", ")", ";", "astring_free", "(", "apath", ")", ";", "apath", "=", "parent", ";", "}", "}", "while", "(", "(", "current_entry_type", "==", "ENTTYPE_NONE", ")", "&&", "(", "apath", "!=", "NULL", ")", "&&", "!", "is_root", "(", "astring_c", "(", "apath", ")", ")", ")", ";", "if", "(", "current_entry_type", "==", "ENTTYPE_NONE", ")", "{", "err", "=", "FILERR_NOT_FOUND", ";", "goto", "done", ";", "}", "if", "(", "(", "current_entry_type", "==", "ENTTYPE_FILE", ")", "&&", "is_zip_file", "(", "astring_c", "(", "apath_trimmed", ")", ")", "&&", "(", "zip_file_open", "(", "astring_c", "(", "apath_trimmed", ")", ",", "zipfile", ")", "==", "ZIPERR_NONE", ")", ")", "{", "i", "=", "strlen", "(", "path", "+", "astring_len", "(", "apath", ")", ")", ";", "while", "(", "(", "i", ">", "0", ")", "&&", "is_zip_path_separator", "(", "path", "[", "astring_len", "(", "apath", ")", "+", "i", "-", "1", "]", ")", ")", "i", "--", ";", "astring_cpych", "(", "newpath", ",", "path", "+", "astring_len", "(", "apath", ")", ",", "i", ")", ";", "zippath_find_sub_path", "(", "*", "zipfile", ",", "astring_c", "(", "newpath", ")", ",", "&", "current_entry_type", ")", ";", "if", "(", "current_entry_type", "==", "ENTTYPE_NONE", ")", "{", "err", "=", "FILERR_NOT_FOUND", ";", "goto", "done", ";", "}", "}", "else", "{", "if", "(", "went_up", ")", "{", "err", "=", "FILERR_NOT_FOUND", ";", "goto", "done", ";", "}", "astring_cpyc", "(", "newpath", ",", "path", ")", ";", "}", "*", "entry_type", "=", "current_entry_type", ";", "err", "=", "FILERR_NONE", ";", "done", ":", "if", "(", "apath", "!=", "NULL", ")", "astring_free", "(", "apath", ")", ";", "if", "(", "apath_trimmed", "!=", "NULL", ")", "astring_free", "(", "apath_trimmed", ")", ";", "return", "err", ";", "}" ]
zippath_resolve - separates a ZIP path out into true path and ZIP entry components
[ "zippath_resolve", "-", "separates", "a", "ZIP", "path", "out", "into", "true", "path", "and", "ZIP", "entry", "components" ]
[ "/* be conservative */", "/* trim the path of trailing path separators */", "/* stat the path */", "/* did we find anything? */", "/* get the entry type and free the stat entry */", "/* if we have not found the file or directory, go up */", "/* if we did not find anything, then error out */", "/* is this file a ZIP file? */", "/* this was a true ZIP path - attempt to identify the type of path */", "/* this was a normal path */", "/* success! */" ]
[ { "param": "path", "type": "char" }, { "param": "entry_type", "type": "osd_dir_entry_type" }, { "param": "zipfile", "type": "zip_file" }, { "param": "newpath", "type": "astring" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "path", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "entry_type", "type": "osd_dir_entry_type", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "zipfile", "type": "zip_file", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "newpath", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
403b3f6812be5db6db8d34334f81b17233eb7d08
lofunz/mieme
Reloaded/trunk/src/mame/machine/midwayic.c
[ "Unlicense" ]
C
ioasic_fifo_r
UINT16
static UINT16 ioasic_fifo_r(running_device *device) { UINT16 result = 0; /* we can only read data if there's some to read! */ if (ioasic.fifo_bytes != 0) { /* fetch the data from the buffer and update the IOASIC state */ result = ioasic.fifo[ioasic.fifo_out++ % FIFO_SIZE]; ioasic.fifo_bytes--; update_ioasic_irq(device->machine); if (LOG_FIFO && (ioasic.fifo_bytes < 4 || ioasic.fifo_bytes >= FIFO_SIZE - 4)) logerror("fifo_r(%04X): FIFO bytes = %d!\n", result, ioasic.fifo_bytes); /* if we just cleared the buffer, this may generate an IRQ on the master CPU */ /* because of the way the streaming code works, we need to make sure that the */ /* next status read indicates an empty buffer, even if we've timesliced and the */ /* main CPU is handling the I/O ASIC interrupt */ if (ioasic.fifo_bytes == 0 && ioasic.has_dcs) { ioasic.fifo_force_buffer_empty_pc = cpu_get_pc(ioasic.dcs_cpu); if (LOG_FIFO) logerror("fifo_r(%04X): FIFO empty, PC = %04X\n", result, ioasic.fifo_force_buffer_empty_pc); } } else { if (LOG_FIFO) logerror("fifo_r(): nothing to read!\n"); } return result; }
/************************************* * * ASIC sound FIFO; used by CarnEvil * *************************************/
ASIC sound FIFO; used by CarnEvil
[ "ASIC", "sound", "FIFO", ";", "used", "by", "CarnEvil" ]
static UINT16 ioasic_fifo_r(running_device *device) { UINT16 result = 0; if (ioasic.fifo_bytes != 0) { result = ioasic.fifo[ioasic.fifo_out++ % FIFO_SIZE]; ioasic.fifo_bytes--; update_ioasic_irq(device->machine); if (LOG_FIFO && (ioasic.fifo_bytes < 4 || ioasic.fifo_bytes >= FIFO_SIZE - 4)) logerror("fifo_r(%04X): FIFO bytes = %d!\n", result, ioasic.fifo_bytes); if (ioasic.fifo_bytes == 0 && ioasic.has_dcs) { ioasic.fifo_force_buffer_empty_pc = cpu_get_pc(ioasic.dcs_cpu); if (LOG_FIFO) logerror("fifo_r(%04X): FIFO empty, PC = %04X\n", result, ioasic.fifo_force_buffer_empty_pc); } } else { if (LOG_FIFO) logerror("fifo_r(): nothing to read!\n"); } return result; }
[ "static", "UINT16", "ioasic_fifo_r", "(", "running_device", "*", "device", ")", "{", "UINT16", "result", "=", "0", ";", "if", "(", "ioasic", ".", "fifo_bytes", "!=", "0", ")", "{", "result", "=", "ioasic", ".", "fifo", "[", "ioasic", ".", "fifo_out", "++", "%", "FIFO_SIZE", "]", ";", "ioasic", ".", "fifo_bytes", "--", ";", "update_ioasic_irq", "(", "device", "->", "machine", ")", ";", "if", "(", "LOG_FIFO", "&&", "(", "ioasic", ".", "fifo_bytes", "<", "4", "||", "ioasic", ".", "fifo_bytes", ">=", "FIFO_SIZE", "-", "4", ")", ")", "logerror", "(", "\"", "\\n", "\"", ",", "result", ",", "ioasic", ".", "fifo_bytes", ")", ";", "if", "(", "ioasic", ".", "fifo_bytes", "==", "0", "&&", "ioasic", ".", "has_dcs", ")", "{", "ioasic", ".", "fifo_force_buffer_empty_pc", "=", "cpu_get_pc", "(", "ioasic", ".", "dcs_cpu", ")", ";", "if", "(", "LOG_FIFO", ")", "logerror", "(", "\"", "\\n", "\"", ",", "result", ",", "ioasic", ".", "fifo_force_buffer_empty_pc", ")", ";", "}", "}", "else", "{", "if", "(", "LOG_FIFO", ")", "logerror", "(", "\"", "\\n", "\"", ")", ";", "}", "return", "result", ";", "}" ]
ASIC sound FIFO; used by CarnEvil
[ "ASIC", "sound", "FIFO", ";", "used", "by", "CarnEvil" ]
[ "/* we can only read data if there's some to read! */", "/* fetch the data from the buffer and update the IOASIC state */", "/* if we just cleared the buffer, this may generate an IRQ on the master CPU */", "/* because of the way the streaming code works, we need to make sure that the */", "/* next status read indicates an empty buffer, even if we've timesliced and the */", "/* main CPU is handling the I/O ASIC interrupt */" ]
[ { "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": [] }
ba90f79cadaa1eb931a911efc6f06a616ce48a07
lofunz/mieme
Reloaded/trunk/src/lib/util/tagmap.c
[ "Unlicense" ]
C
tagmap_free
void
void tagmap_free(tagmap *map) { tagmap_reset(map); free(map); }
/*------------------------------------------------- tagmap_free - free a tagmap, and all entries within it -------------------------------------------------*/
free a tagmap, and all entries within it
[ "free", "a", "tagmap", "and", "all", "entries", "within", "it" ]
void tagmap_free(tagmap *map) { tagmap_reset(map); free(map); }
[ "void", "tagmap_free", "(", "tagmap", "*", "map", ")", "{", "tagmap_reset", "(", "map", ")", ";", "free", "(", "map", ")", ";", "}" ]
tagmap_free - free a tagmap, and all entries within it
[ "tagmap_free", "-", "free", "a", "tagmap", "and", "all", "entries", "within", "it" ]
[]
[ { "param": "map", "type": "tagmap" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "map", "type": "tagmap", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba90f79cadaa1eb931a911efc6f06a616ce48a07
lofunz/mieme
Reloaded/trunk/src/lib/util/tagmap.c
[ "Unlicense" ]
C
tagmap_reset
void
void tagmap_reset(tagmap *map) { UINT32 hashindex; for (hashindex = 0; hashindex < ARRAY_LENGTH(map->table); hashindex++) { tagmap_entry *entry, *next; for (entry = map->table[hashindex]; entry != NULL; entry = next) { next = entry->next; free(entry); } } }
/*------------------------------------------------- tagmap_reset - reset a tagmap by freeing all entries -------------------------------------------------*/
reset a tagmap by freeing all entries
[ "reset", "a", "tagmap", "by", "freeing", "all", "entries" ]
void tagmap_reset(tagmap *map) { UINT32 hashindex; for (hashindex = 0; hashindex < ARRAY_LENGTH(map->table); hashindex++) { tagmap_entry *entry, *next; for (entry = map->table[hashindex]; entry != NULL; entry = next) { next = entry->next; free(entry); } } }
[ "void", "tagmap_reset", "(", "tagmap", "*", "map", ")", "{", "UINT32", "hashindex", ";", "for", "(", "hashindex", "=", "0", ";", "hashindex", "<", "ARRAY_LENGTH", "(", "map", "->", "table", ")", ";", "hashindex", "++", ")", "{", "tagmap_entry", "*", "entry", ",", "*", "next", ";", "for", "(", "entry", "=", "map", "->", "table", "[", "hashindex", "]", ";", "entry", "!=", "NULL", ";", "entry", "=", "next", ")", "{", "next", "=", "entry", "->", "next", ";", "free", "(", "entry", ")", ";", "}", "}", "}" ]
tagmap_reset - reset a tagmap by freeing all entries
[ "tagmap_reset", "-", "reset", "a", "tagmap", "by", "freeing", "all", "entries" ]
[]
[ { "param": "map", "type": "tagmap" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "map", "type": "tagmap", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba90f79cadaa1eb931a911efc6f06a616ce48a07
lofunz/mieme
Reloaded/trunk/src/lib/util/tagmap.c
[ "Unlicense" ]
C
tagmap_remove
void
void tagmap_remove(tagmap *map, const char *tag) { UINT32 fullhash = tagmap_hash(tag); tagmap_entry **entryptr; for (entryptr = &map->table[fullhash % ARRAY_LENGTH(map->table)]; *entryptr != NULL; entryptr = &(*entryptr)->next) if ((*entryptr)->fullhash == fullhash && strcmp((*entryptr)->tag, tag) == 0) { tagmap_entry *entry = *entryptr; *entryptr = entry->next; free(entry); break; } }
/*------------------------------------------------- tagmap_remove - remove an entr from a tagmap -------------------------------------------------*/
remove an entr from a tagmap
[ "remove", "an", "entr", "from", "a", "tagmap" ]
void tagmap_remove(tagmap *map, const char *tag) { UINT32 fullhash = tagmap_hash(tag); tagmap_entry **entryptr; for (entryptr = &map->table[fullhash % ARRAY_LENGTH(map->table)]; *entryptr != NULL; entryptr = &(*entryptr)->next) if ((*entryptr)->fullhash == fullhash && strcmp((*entryptr)->tag, tag) == 0) { tagmap_entry *entry = *entryptr; *entryptr = entry->next; free(entry); break; } }
[ "void", "tagmap_remove", "(", "tagmap", "*", "map", ",", "const", "char", "*", "tag", ")", "{", "UINT32", "fullhash", "=", "tagmap_hash", "(", "tag", ")", ";", "tagmap_entry", "*", "*", "entryptr", ";", "for", "(", "entryptr", "=", "&", "map", "->", "table", "[", "fullhash", "%", "ARRAY_LENGTH", "(", "map", "->", "table", ")", "]", ";", "*", "entryptr", "!=", "NULL", ";", "entryptr", "=", "&", "(", "*", "entryptr", ")", "->", "next", ")", "if", "(", "(", "*", "entryptr", ")", "->", "fullhash", "==", "fullhash", "&&", "strcmp", "(", "(", "*", "entryptr", ")", "->", "tag", ",", "tag", ")", "==", "0", ")", "{", "tagmap_entry", "*", "entry", "=", "*", "entryptr", ";", "*", "entryptr", "=", "entry", "->", "next", ";", "free", "(", "entry", ")", ";", "break", ";", "}", "}" ]
tagmap_remove - remove an entr from a tagmap
[ "tagmap_remove", "-", "remove", "an", "entr", "from", "a", "tagmap" ]
[]
[ { "param": "map", "type": "tagmap" }, { "param": "tag", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "map", "type": "tagmap", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "tag", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba90f79cadaa1eb931a911efc6f06a616ce48a07
lofunz/mieme
Reloaded/trunk/src/lib/util/tagmap.c
[ "Unlicense" ]
C
tagmap_remove_object
void
void tagmap_remove_object(tagmap *map, void *object) { UINT32 hashindex; for (hashindex = 0; hashindex < ARRAY_LENGTH(map->table); hashindex++) { tagmap_entry **entryptr; for (entryptr = &map->table[hashindex]; *entryptr != NULL; entryptr = &(*entryptr)->next) if ((*entryptr)->object == object) { tagmap_entry *entry = *entryptr; *entryptr = entry->next; free(entry); return; } } }
/*------------------------------------------------- tagmap_remove_object - remove an entry from a tagmap by object pointer -------------------------------------------------*/
remove an entry from a tagmap by object pointer
[ "remove", "an", "entry", "from", "a", "tagmap", "by", "object", "pointer" ]
void tagmap_remove_object(tagmap *map, void *object) { UINT32 hashindex; for (hashindex = 0; hashindex < ARRAY_LENGTH(map->table); hashindex++) { tagmap_entry **entryptr; for (entryptr = &map->table[hashindex]; *entryptr != NULL; entryptr = &(*entryptr)->next) if ((*entryptr)->object == object) { tagmap_entry *entry = *entryptr; *entryptr = entry->next; free(entry); return; } } }
[ "void", "tagmap_remove_object", "(", "tagmap", "*", "map", ",", "void", "*", "object", ")", "{", "UINT32", "hashindex", ";", "for", "(", "hashindex", "=", "0", ";", "hashindex", "<", "ARRAY_LENGTH", "(", "map", "->", "table", ")", ";", "hashindex", "++", ")", "{", "tagmap_entry", "*", "*", "entryptr", ";", "for", "(", "entryptr", "=", "&", "map", "->", "table", "[", "hashindex", "]", ";", "*", "entryptr", "!=", "NULL", ";", "entryptr", "=", "&", "(", "*", "entryptr", ")", "->", "next", ")", "if", "(", "(", "*", "entryptr", ")", "->", "object", "==", "object", ")", "{", "tagmap_entry", "*", "entry", "=", "*", "entryptr", ";", "*", "entryptr", "=", "entry", "->", "next", ";", "free", "(", "entry", ")", ";", "return", ";", "}", "}", "}" ]
tagmap_remove_object - remove an entry from a tagmap by object pointer
[ "tagmap_remove_object", "-", "remove", "an", "entry", "from", "a", "tagmap", "by", "object", "pointer" ]
[]
[ { "param": "map", "type": "tagmap" }, { "param": "object", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "map", "type": "tagmap", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "object", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba90f79cadaa1eb931a911efc6f06a616ce48a07
lofunz/mieme
Reloaded/trunk/src/lib/util/tagmap.c
[ "Unlicense" ]
C
tagmap_add_common
tagmap_error
static tagmap_error tagmap_add_common(tagmap *map, const char *tag, void *object, UINT8 replace_if_duplicate, UINT8 unique_hash) { UINT32 fullhash = tagmap_hash(tag); UINT32 hashindex = fullhash % ARRAY_LENGTH(map->table); tagmap_entry *entry; /* first make sure we don't have a duplicate */ for (entry = map->table[hashindex]; entry != NULL; entry = entry->next) if (entry->fullhash == fullhash) if (unique_hash || strcmp(tag, entry->tag) == 0) { if (replace_if_duplicate) entry->object = object; return TMERR_DUPLICATE; } /* now allocate a new entry */ entry = (tagmap_entry *)malloc(sizeof(*entry) + strlen(tag)); if (entry == NULL) return TMERR_OUT_OF_MEMORY; /* fill in the entry */ entry->object = object; entry->fullhash = fullhash; strcpy(entry->tag, tag); /* add it to the head of the list */ entry->next = map->table[hashindex]; map->table[hashindex] = entry; return TMERR_NONE; }
/*------------------------------------------------- tagmap_add_common - core implementation of a tagmap addition -------------------------------------------------*/
core implementation of a tagmap addition
[ "core", "implementation", "of", "a", "tagmap", "addition" ]
static tagmap_error tagmap_add_common(tagmap *map, const char *tag, void *object, UINT8 replace_if_duplicate, UINT8 unique_hash) { UINT32 fullhash = tagmap_hash(tag); UINT32 hashindex = fullhash % ARRAY_LENGTH(map->table); tagmap_entry *entry; for (entry = map->table[hashindex]; entry != NULL; entry = entry->next) if (entry->fullhash == fullhash) if (unique_hash || strcmp(tag, entry->tag) == 0) { if (replace_if_duplicate) entry->object = object; return TMERR_DUPLICATE; } entry = (tagmap_entry *)malloc(sizeof(*entry) + strlen(tag)); if (entry == NULL) return TMERR_OUT_OF_MEMORY; entry->object = object; entry->fullhash = fullhash; strcpy(entry->tag, tag); entry->next = map->table[hashindex]; map->table[hashindex] = entry; return TMERR_NONE; }
[ "static", "tagmap_error", "tagmap_add_common", "(", "tagmap", "*", "map", ",", "const", "char", "*", "tag", ",", "void", "*", "object", ",", "UINT8", "replace_if_duplicate", ",", "UINT8", "unique_hash", ")", "{", "UINT32", "fullhash", "=", "tagmap_hash", "(", "tag", ")", ";", "UINT32", "hashindex", "=", "fullhash", "%", "ARRAY_LENGTH", "(", "map", "->", "table", ")", ";", "tagmap_entry", "*", "entry", ";", "for", "(", "entry", "=", "map", "->", "table", "[", "hashindex", "]", ";", "entry", "!=", "NULL", ";", "entry", "=", "entry", "->", "next", ")", "if", "(", "entry", "->", "fullhash", "==", "fullhash", ")", "if", "(", "unique_hash", "||", "strcmp", "(", "tag", ",", "entry", "->", "tag", ")", "==", "0", ")", "{", "if", "(", "replace_if_duplicate", ")", "entry", "->", "object", "=", "object", ";", "return", "TMERR_DUPLICATE", ";", "}", "entry", "=", "(", "tagmap_entry", "*", ")", "malloc", "(", "sizeof", "(", "*", "entry", ")", "+", "strlen", "(", "tag", ")", ")", ";", "if", "(", "entry", "==", "NULL", ")", "return", "TMERR_OUT_OF_MEMORY", ";", "entry", "->", "object", "=", "object", ";", "entry", "->", "fullhash", "=", "fullhash", ";", "strcpy", "(", "entry", "->", "tag", ",", "tag", ")", ";", "entry", "->", "next", "=", "map", "->", "table", "[", "hashindex", "]", ";", "map", "->", "table", "[", "hashindex", "]", "=", "entry", ";", "return", "TMERR_NONE", ";", "}" ]
tagmap_add_common - core implementation of a tagmap addition
[ "tagmap_add_common", "-", "core", "implementation", "of", "a", "tagmap", "addition" ]
[ "/* first make sure we don't have a duplicate */", "/* now allocate a new entry */", "/* fill in the entry */", "/* add it to the head of the list */" ]
[ { "param": "map", "type": "tagmap" }, { "param": "tag", "type": "char" }, { "param": "object", "type": "void" }, { "param": "replace_if_duplicate", "type": "UINT8" }, { "param": "unique_hash", "type": "UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "map", "type": "tagmap", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "tag", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "object", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "replace_if_duplicate", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "unique_hash", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bdbb080e6407da4d24f550db2dcab907e3cdb578
lofunz/mieme
Reloaded/trunk/src/mame/video/konicdev.c
[ "Unlicense" ]
C
konami_shuffle_16
void
static void konami_shuffle_16(UINT16 *buf,int len) { int i; UINT16 t; if (len == 2) return; if (len % 4) fatalerror("shuffle() - not modulo 4"); /* must not happen */ len /= 2; for (i = 0; i < len / 2; i++) { t = buf[len / 2 + i]; buf[len / 2 + i] = buf[len + i]; buf[len + i] = t; } konami_shuffle_16(buf,len); konami_shuffle_16(buf + len,len); }
/* This recursive function doesn't use additional memory (it could be easily converted into an iterative one). It's called shuffle because it mimics the shuffling of a deck of cards. */
This recursive function doesn't use additional memory (it could be easily converted into an iterative one). It's called shuffle because it mimics the shuffling of a deck of cards.
[ "This", "recursive", "function", "doesn", "'", "t", "use", "additional", "memory", "(", "it", "could", "be", "easily", "converted", "into", "an", "iterative", "one", ")", ".", "It", "'", "s", "called", "shuffle", "because", "it", "mimics", "the", "shuffling", "of", "a", "deck", "of", "cards", "." ]
static void konami_shuffle_16(UINT16 *buf,int len) { int i; UINT16 t; if (len == 2) return; if (len % 4) fatalerror("shuffle() - not modulo 4"); len /= 2; for (i = 0; i < len / 2; i++) { t = buf[len / 2 + i]; buf[len / 2 + i] = buf[len + i]; buf[len + i] = t; } konami_shuffle_16(buf,len); konami_shuffle_16(buf + len,len); }
[ "static", "void", "konami_shuffle_16", "(", "UINT16", "*", "buf", ",", "int", "len", ")", "{", "int", "i", ";", "UINT16", "t", ";", "if", "(", "len", "==", "2", ")", "return", ";", "if", "(", "len", "%", "4", ")", "fatalerror", "(", "\"", "\"", ")", ";", "len", "/=", "2", ";", "for", "(", "i", "=", "0", ";", "i", "<", "len", "/", "2", ";", "i", "++", ")", "{", "t", "=", "buf", "[", "len", "/", "2", "+", "i", "]", ";", "buf", "[", "len", "/", "2", "+", "i", "]", "=", "buf", "[", "len", "+", "i", "]", ";", "buf", "[", "len", "+", "i", "]", "=", "t", ";", "}", "konami_shuffle_16", "(", "buf", ",", "len", ")", ";", "konami_shuffle_16", "(", "buf", "+", "len", ",", "len", ")", ";", "}" ]
This recursive function doesn't use additional memory (it could be easily converted into an iterative one).
[ "This", "recursive", "function", "doesn", "'", "t", "use", "additional", "memory", "(", "it", "could", "be", "easily", "converted", "into", "an", "iterative", "one", ")", "." ]
[ "/* must not happen */" ]
[ { "param": "buf", "type": "UINT16" }, { "param": "len", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "buf", "type": "UINT16", "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": [] }
bdbb080e6407da4d24f550db2dcab907e3cdb578
lofunz/mieme
Reloaded/trunk/src/mame/video/konicdev.c
[ "Unlicense" ]
C
konamid_rom_deinterleave_2_half
void
void konamid_rom_deinterleave_2_half(running_machine *machine, const char *mem_region) { UINT8 *rgn = memory_region(machine, mem_region); konami_shuffle_16((UINT16 *)rgn,memory_region_length(machine, mem_region)/4); konami_shuffle_16((UINT16 *)(rgn+memory_region_length(machine, mem_region)/2),memory_region_length(machine, mem_region)/4); }
/* hacked version of rom_deinterleave_2_half for Lethal Enforcers */
hacked version of rom_deinterleave_2_half for Lethal Enforcers
[ "hacked", "version", "of", "rom_deinterleave_2_half", "for", "Lethal", "Enforcers" ]
void konamid_rom_deinterleave_2_half(running_machine *machine, const char *mem_region) { UINT8 *rgn = memory_region(machine, mem_region); konami_shuffle_16((UINT16 *)rgn,memory_region_length(machine, mem_region)/4); konami_shuffle_16((UINT16 *)(rgn+memory_region_length(machine, mem_region)/2),memory_region_length(machine, mem_region)/4); }
[ "void", "konamid_rom_deinterleave_2_half", "(", "running_machine", "*", "machine", ",", "const", "char", "*", "mem_region", ")", "{", "UINT8", "*", "rgn", "=", "memory_region", "(", "machine", ",", "mem_region", ")", ";", "konami_shuffle_16", "(", "(", "UINT16", "*", ")", "rgn", ",", "memory_region_length", "(", "machine", ",", "mem_region", ")", "/", "4", ")", ";", "konami_shuffle_16", "(", "(", "UINT16", "*", ")", "(", "rgn", "+", "memory_region_length", "(", "machine", ",", "mem_region", ")", "/", "2", ")", ",", "memory_region_length", "(", "machine", ",", "mem_region", ")", "/", "4", ")", ";", "}" ]
hacked version of rom_deinterleave_2_half for Lethal Enforcers
[ "hacked", "version", "of", "rom_deinterleave_2_half", "for", "Lethal", "Enforcers" ]
[]
[ { "param": "machine", "type": "running_machine" }, { "param": "mem_region", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mem_region", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bdbb080e6407da4d24f550db2dcab907e3cdb578
lofunz/mieme
Reloaded/trunk/src/mame/video/konicdev.c
[ "Unlicense" ]
C
konamid_rom_deinterleave_4
void
void konamid_rom_deinterleave_4(running_machine *machine, const char *mem_region) { konamid_rom_deinterleave_2(machine, mem_region); konamid_rom_deinterleave_2(machine, mem_region); }
/* helper function to join four 16-bit ROMs and form a 64-bit data stream */
helper function to join four 16-bit ROMs and form a 64-bit data stream
[ "helper", "function", "to", "join", "four", "16", "-", "bit", "ROMs", "and", "form", "a", "64", "-", "bit", "data", "stream" ]
void konamid_rom_deinterleave_4(running_machine *machine, const char *mem_region) { konamid_rom_deinterleave_2(machine, mem_region); konamid_rom_deinterleave_2(machine, mem_region); }
[ "void", "konamid_rom_deinterleave_4", "(", "running_machine", "*", "machine", ",", "const", "char", "*", "mem_region", ")", "{", "konamid_rom_deinterleave_2", "(", "machine", ",", "mem_region", ")", ";", "konamid_rom_deinterleave_2", "(", "machine", ",", "mem_region", ")", ";", "}" ]
helper function to join four 16-bit ROMs and form a 64-bit data stream
[ "helper", "function", "to", "join", "four", "16", "-", "bit", "ROMs", "and", "form", "a", "64", "-", "bit", "data", "stream" ]
[]
[ { "param": "machine", "type": "running_machine" }, { "param": "mem_region", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mem_region", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bdbb080e6407da4d24f550db2dcab907e3cdb578
lofunz/mieme
Reloaded/trunk/src/mame/video/konicdev.c
[ "Unlicense" ]
C
konami_sortlayers3
void
void konami_sortlayers3( int *layer, int *pri ) { #define SWAP(a,b) \ if (pri[a] < pri[b]) \ { \ int t; \ t = pri[a]; pri[a] = pri[b]; pri[b] = t; \ t = layer[a]; layer[a] = layer[b]; layer[b] = t; \ } SWAP(0,1) SWAP(0,2) SWAP(1,2) #undef SWAP }
/* useful function to sort three tile layers by priority order */
useful function to sort three tile layers by priority order
[ "useful", "function", "to", "sort", "three", "tile", "layers", "by", "priority", "order" ]
void konami_sortlayers3( int *layer, int *pri ) { #define SWAP(a,b) \ if (pri[a] < pri[b]) \ { \ int t; \ t = pri[a]; pri[a] = pri[b]; pri[b] = t; \ t = layer[a]; layer[a] = layer[b]; layer[b] = t; \ } SWAP(0,1) SWAP(0,2) SWAP(1,2) #undef SWAP }
[ "void", "konami_sortlayers3", "(", "int", "*", "layer", ",", "int", "*", "pri", ")", "{", "#define", "SWAP", "(", "a", ",", "b", ")", " \\\r\n\tif (pri[a] < pri[b]) \\\r\n\t{ \\\r\n\t\tint t; \\\r\n\t\tt = pri[a]; pri[a] = pri[b]; pri[b] = t; \\\r\n\t\tt = layer[a]; layer[a] = layer[b]; layer[b] = t; \\\r\n\t}\r", "\n", "SWAP", "(", "0", ",", "1", ")", "", "SWAP", "(", "0", ",", "2", ")", "", "SWAP", "(", "1", ",", "2", ")", "", "#undef", " SWAP\r", "\n", "}" ]
useful function to sort three tile layers by priority order
[ "useful", "function", "to", "sort", "three", "tile", "layers", "by", "priority", "order" ]
[]
[ { "param": "layer", "type": "int" }, { "param": "pri", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "layer", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pri", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bdbb080e6407da4d24f550db2dcab907e3cdb578
lofunz/mieme
Reloaded/trunk/src/mame/video/konicdev.c
[ "Unlicense" ]
C
konami_sortlayers4
void
void konami_sortlayers4( int *layer, int *pri ) { #define SWAP(a,b) \ if (pri[a] <= pri[b]) \ { \ int t; \ t = pri[a]; pri[a] = pri[b]; pri[b] = t; \ t = layer[a]; layer[a] = layer[b]; layer[b] = t; \ } SWAP(0, 1) SWAP(0, 2) SWAP(0, 3) SWAP(1, 2) SWAP(1, 3) SWAP(2, 3) #undef SWAP }
/* useful function to sort four tile layers by priority order */
useful function to sort four tile layers by priority order
[ "useful", "function", "to", "sort", "four", "tile", "layers", "by", "priority", "order" ]
void konami_sortlayers4( int *layer, int *pri ) { #define SWAP(a,b) \ if (pri[a] <= pri[b]) \ { \ int t; \ t = pri[a]; pri[a] = pri[b]; pri[b] = t; \ t = layer[a]; layer[a] = layer[b]; layer[b] = t; \ } SWAP(0, 1) SWAP(0, 2) SWAP(0, 3) SWAP(1, 2) SWAP(1, 3) SWAP(2, 3) #undef SWAP }
[ "void", "konami_sortlayers4", "(", "int", "*", "layer", ",", "int", "*", "pri", ")", "{", "#define", "SWAP", "(", "a", ",", "b", ")", " \\\r\n\tif (pri[a] <= pri[b]) \\\r\n\t{ \\\r\n\t\tint t; \\\r\n\t\tt = pri[a]; pri[a] = pri[b]; pri[b] = t; \\\r\n\t\tt = layer[a]; layer[a] = layer[b]; layer[b] = t; \\\r\n\t}\r", "\n", "SWAP", "(", "0", ",", "1", ")", "", "SWAP", "(", "0", ",", "2", ")", "", "SWAP", "(", "0", ",", "3", ")", "", "SWAP", "(", "1", ",", "2", ")", "", "SWAP", "(", "1", ",", "3", ")", "", "SWAP", "(", "2", ",", "3", ")", "", "#undef", " SWAP\r", "\n", "}" ]
useful function to sort four tile layers by priority order
[ "useful", "function", "to", "sort", "four", "tile", "layers", "by", "priority", "order" ]
[]
[ { "param": "layer", "type": "int" }, { "param": "pri", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "layer", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pri", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bdbb080e6407da4d24f550db2dcab907e3cdb578
lofunz/mieme
Reloaded/trunk/src/mame/video/konicdev.c
[ "Unlicense" ]
C
konami_sortlayers5
void
void konami_sortlayers5( int *layer, int *pri ) { #define SWAP(a,b) \ if (pri[a] <= pri[b]) \ { \ int t; \ t = pri[a]; pri[a] = pri[b]; pri[b] = t; \ t = layer[a]; layer[a] = layer[b]; layer[b] = t; \ } SWAP(0, 1) SWAP(0, 2) SWAP(0, 3) SWAP(0, 4) SWAP(1, 2) SWAP(1, 3) SWAP(1, 4) SWAP(2, 3) SWAP(2, 4) SWAP(3, 4) #undef SWAP }
/* useful function to sort five tile layers by priority order */
useful function to sort five tile layers by priority order
[ "useful", "function", "to", "sort", "five", "tile", "layers", "by", "priority", "order" ]
void konami_sortlayers5( int *layer, int *pri ) { #define SWAP(a,b) \ if (pri[a] <= pri[b]) \ { \ int t; \ t = pri[a]; pri[a] = pri[b]; pri[b] = t; \ t = layer[a]; layer[a] = layer[b]; layer[b] = t; \ } SWAP(0, 1) SWAP(0, 2) SWAP(0, 3) SWAP(0, 4) SWAP(1, 2) SWAP(1, 3) SWAP(1, 4) SWAP(2, 3) SWAP(2, 4) SWAP(3, 4) #undef SWAP }
[ "void", "konami_sortlayers5", "(", "int", "*", "layer", ",", "int", "*", "pri", ")", "{", "#define", "SWAP", "(", "a", ",", "b", ")", " \\\r\n\tif (pri[a] <= pri[b]) \\\r\n\t{ \\\r\n\t\tint t; \\\r\n\t\tt = pri[a]; pri[a] = pri[b]; pri[b] = t; \\\r\n\t\tt = layer[a]; layer[a] = layer[b]; layer[b] = t; \\\r\n\t}\r", "\n", "SWAP", "(", "0", ",", "1", ")", "", "SWAP", "(", "0", ",", "2", ")", "", "SWAP", "(", "0", ",", "3", ")", "", "SWAP", "(", "0", ",", "4", ")", "", "SWAP", "(", "1", ",", "2", ")", "", "SWAP", "(", "1", ",", "3", ")", "", "SWAP", "(", "1", ",", "4", ")", "", "SWAP", "(", "2", ",", "3", ")", "", "SWAP", "(", "2", ",", "4", ")", "", "SWAP", "(", "3", ",", "4", ")", "", "#undef", " SWAP\r", "\n", "}" ]
useful function to sort five tile layers by priority order
[ "useful", "function", "to", "sort", "five", "tile", "layers", "by", "priority", "order" ]
[]
[ { "param": "layer", "type": "int" }, { "param": "pri", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "layer", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pri", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bdbb080e6407da4d24f550db2dcab907e3cdb578
lofunz/mieme
Reloaded/trunk/src/mame/video/konicdev.c
[ "Unlicense" ]
C
k007121_sprites_draw
void
void k007121_sprites_draw( running_device *device, bitmap_t *bitmap, const rectangle *cliprect, gfx_element *gfx, colortable_t *ctable, const UINT8 *source, int base_color, int global_x_offset, int bank_base, UINT32 pri_mask ) { k007121_state *k007121 = k007121_get_safe_token(device); // const gfx_element *gfx = gfxs[chip]; bitmap_t *priority_bitmap = gfx->machine->priority_bitmap; int flipscreen = k007121->flipscreen; int i, num, inc, offs[5]; int is_flakatck = (ctable == NULL); if (is_flakatck) { num = 0x40; inc = -0x20; source += 0x3f * 0x20; offs[0] = 0x0e; offs[1] = 0x0f; offs[2] = 0x06; offs[3] = 0x04; offs[4] = 0x08; } else /* all others */ { //num = (k007121->ctrlram[0x03] & 0x40) ? 0x80 : 0x40; /* WRONG!!! (needed by combatsc) */ num = 0x40; // combatsc writes 70 sprites to VRAM at peak but the chip only processes the first 64. inc = 5; offs[0] = 0x00; offs[1] = 0x01; offs[2] = 0x02; offs[3] = 0x03; offs[4] = 0x04; /* when using priority buffer, draw front to back */ if (pri_mask != -1) { source += (num - 1)*inc; inc = -inc; } } for (i = 0; i < num; i++) { int number = source[offs[0]]; /* sprite number */ int sprite_bank = source[offs[1]] & 0x0f; /* sprite bank */ int sx = source[offs[3]]; /* vertical position */ int sy = source[offs[2]]; /* horizontal position */ int attr = source[offs[4]]; /* attributes */ int xflip = source[offs[4]] & 0x10; /* flip x */ int yflip = source[offs[4]] & 0x20; /* flip y */ int color = base_color + ((source[offs[1]] & 0xf0) >> 4); int width, height; int transparent_mask; static const int x_offset[4] = {0x0,0x1,0x4,0x5}; static const int y_offset[4] = {0x0,0x2,0x8,0xa}; int x,y, ex, ey, flipx, flipy, destx, desty; if (attr & 0x01) sx -= 256; if (sy >= 240) sy -= 256; number += ((sprite_bank & 0x3) << 8) + ((attr & 0xc0) << 4); number = number << 2; number += (sprite_bank >> 2) & 3; /* Flak Attack doesn't use a lookup PROM, it maps the color code directly */ /* to a palette entry */ if (is_flakatck) transparent_mask = 1 << 0; else transparent_mask = colortable_get_transpen_mask(ctable, gfx, color, 0); if (!is_flakatck || source[0x00]) /* Flak Attack needs this */ { number += bank_base; switch (attr & 0xe) { case 0x06: width = height = 1; break; case 0x04: width = 1; height = 2; number &= (~2); break; case 0x02: width = 2; height = 1; number &= (~1); break; case 0x00: width = height = 2; number &= (~3); break; case 0x08: width = height = 4; number &= (~3); break; default: width = 1; height = 1; // logerror("Unknown sprite size %02x\n", attr & 0xe); // popmessage("Unknown sprite size %02x\n", attr & 0xe); } for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { ex = xflip ? (width - 1 - x) : x; ey = yflip ? (height - 1 - y) : y; if (flipscreen) { flipx = !xflip; flipy = !yflip; destx = 248 - (sx + x * 8); desty = 248 - (sy + y * 8); } else { flipx = xflip; flipy = yflip; destx = global_x_offset + sx + x * 8; desty = sy + y * 8; } if (pri_mask != -1) pdrawgfx_transmask(bitmap,cliprect,gfx, number + x_offset[ex] + y_offset[ey], color, flipx,flipy, destx,desty, priority_bitmap,pri_mask, transparent_mask); else drawgfx_transmask(bitmap,cliprect,gfx, number + x_offset[ex] + y_offset[ey], color, flipx,flipy, destx,desty, transparent_mask); } } } source += inc; } }
/* * Sprite Format * ------------------ * * There are 0x40 sprites, each one using 5 bytes. However the number of * sprites can be increased to 0x80 with a control register (Combat School * sets it on and off during the game). * * Byte | Bit(s) | Use * -----+-76543210-+---------------- * 0 | xxxxxxxx | sprite code * 1 | xxxx---- | color * 1 | ----xx-- | sprite code low 2 bits for 16x8/8x8 sprites * 1 | ------xx | sprite code bank bits 1/0 * 2 | xxxxxxxx | y position * 3 | xxxxxxxx | x position (low 8 bits) * 4 | xx------ | sprite code bank bits 3/2 * 4 | --x----- | flip y * 4 | ---x---- | flip x * 4 | ----xxx- | sprite size 000=16x16 001=16x8 010=8x16 011=8x8 100=32x32 * 4 | -------x | x position (high bit) * * Flack Attack uses a different, "wider" layout with 32 bytes per sprite, * mapped as follows, and the priority order is reversed. Maybe it is a * compatibility mode with an older custom IC. It is not known how this * alternate layout is selected. * * 0 -> e * 1 -> f * 2 -> 6 * 3 -> 4 * 4 -> 8 * */
Sprite Format There are 0x40 sprites, each one using 5 bytes. However the number of sprites can be increased to 0x80 with a control register (Combat School sets it on and off during the game). Flack Attack uses a different, "wider" layout with 32 bytes per sprite, mapped as follows, and the priority order is reversed. Maybe it is a compatibility mode with an older custom IC. It is not known how this alternate layout is selected.
[ "Sprite", "Format", "There", "are", "0x40", "sprites", "each", "one", "using", "5", "bytes", ".", "However", "the", "number", "of", "sprites", "can", "be", "increased", "to", "0x80", "with", "a", "control", "register", "(", "Combat", "School", "sets", "it", "on", "and", "off", "during", "the", "game", ")", ".", "Flack", "Attack", "uses", "a", "different", "\"", "wider", "\"", "layout", "with", "32", "bytes", "per", "sprite", "mapped", "as", "follows", "and", "the", "priority", "order", "is", "reversed", ".", "Maybe", "it", "is", "a", "compatibility", "mode", "with", "an", "older", "custom", "IC", ".", "It", "is", "not", "known", "how", "this", "alternate", "layout", "is", "selected", "." ]
void k007121_sprites_draw( running_device *device, bitmap_t *bitmap, const rectangle *cliprect, gfx_element *gfx, colortable_t *ctable, const UINT8 *source, int base_color, int global_x_offset, int bank_base, UINT32 pri_mask ) { k007121_state *k007121 = k007121_get_safe_token(device); bitmap_t *priority_bitmap = gfx->machine->priority_bitmap; int flipscreen = k007121->flipscreen; int i, num, inc, offs[5]; int is_flakatck = (ctable == NULL); if (is_flakatck) { num = 0x40; inc = -0x20; source += 0x3f * 0x20; offs[0] = 0x0e; offs[1] = 0x0f; offs[2] = 0x06; offs[3] = 0x04; offs[4] = 0x08; } else { num = 0x40; inc = 5; offs[0] = 0x00; offs[1] = 0x01; offs[2] = 0x02; offs[3] = 0x03; offs[4] = 0x04; if (pri_mask != -1) { source += (num - 1)*inc; inc = -inc; } } for (i = 0; i < num; i++) { int number = source[offs[0]]; int sprite_bank = source[offs[1]] & 0x0f; int sx = source[offs[3]]; int sy = source[offs[2]]; int attr = source[offs[4]]; int xflip = source[offs[4]] & 0x10; int yflip = source[offs[4]] & 0x20; int color = base_color + ((source[offs[1]] & 0xf0) >> 4); int width, height; int transparent_mask; static const int x_offset[4] = {0x0,0x1,0x4,0x5}; static const int y_offset[4] = {0x0,0x2,0x8,0xa}; int x,y, ex, ey, flipx, flipy, destx, desty; if (attr & 0x01) sx -= 256; if (sy >= 240) sy -= 256; number += ((sprite_bank & 0x3) << 8) + ((attr & 0xc0) << 4); number = number << 2; number += (sprite_bank >> 2) & 3; if (is_flakatck) transparent_mask = 1 << 0; else transparent_mask = colortable_get_transpen_mask(ctable, gfx, color, 0); if (!is_flakatck || source[0x00]) { number += bank_base; switch (attr & 0xe) { case 0x06: width = height = 1; break; case 0x04: width = 1; height = 2; number &= (~2); break; case 0x02: width = 2; height = 1; number &= (~1); break; case 0x00: width = height = 2; number &= (~3); break; case 0x08: width = height = 4; number &= (~3); break; default: width = 1; height = 1; } for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { ex = xflip ? (width - 1 - x) : x; ey = yflip ? (height - 1 - y) : y; if (flipscreen) { flipx = !xflip; flipy = !yflip; destx = 248 - (sx + x * 8); desty = 248 - (sy + y * 8); } else { flipx = xflip; flipy = yflip; destx = global_x_offset + sx + x * 8; desty = sy + y * 8; } if (pri_mask != -1) pdrawgfx_transmask(bitmap,cliprect,gfx, number + x_offset[ex] + y_offset[ey], color, flipx,flipy, destx,desty, priority_bitmap,pri_mask, transparent_mask); else drawgfx_transmask(bitmap,cliprect,gfx, number + x_offset[ex] + y_offset[ey], color, flipx,flipy, destx,desty, transparent_mask); } } } source += inc; } }
[ "void", "k007121_sprites_draw", "(", "running_device", "*", "device", ",", "bitmap_t", "*", "bitmap", ",", "const", "rectangle", "*", "cliprect", ",", "gfx_element", "*", "gfx", ",", "colortable_t", "*", "ctable", ",", "const", "UINT8", "*", "source", ",", "int", "base_color", ",", "int", "global_x_offset", ",", "int", "bank_base", ",", "UINT32", "pri_mask", ")", "{", "k007121_state", "*", "k007121", "=", "k007121_get_safe_token", "(", "device", ")", ";", "bitmap_t", "*", "priority_bitmap", "=", "gfx", "->", "machine", "->", "priority_bitmap", ";", "int", "flipscreen", "=", "k007121", "->", "flipscreen", ";", "int", "i", ",", "num", ",", "inc", ",", "offs", "[", "5", "]", ";", "int", "is_flakatck", "=", "(", "ctable", "==", "NULL", ")", ";", "if", "(", "is_flakatck", ")", "{", "num", "=", "0x40", ";", "inc", "=", "-0x20", ";", "source", "+=", "0x3f", "*", "0x20", ";", "offs", "[", "0", "]", "=", "0x0e", ";", "offs", "[", "1", "]", "=", "0x0f", ";", "offs", "[", "2", "]", "=", "0x06", ";", "offs", "[", "3", "]", "=", "0x04", ";", "offs", "[", "4", "]", "=", "0x08", ";", "}", "else", "{", "num", "=", "0x40", ";", "inc", "=", "5", ";", "offs", "[", "0", "]", "=", "0x00", ";", "offs", "[", "1", "]", "=", "0x01", ";", "offs", "[", "2", "]", "=", "0x02", ";", "offs", "[", "3", "]", "=", "0x03", ";", "offs", "[", "4", "]", "=", "0x04", ";", "if", "(", "pri_mask", "!=", "-1", ")", "{", "source", "+=", "(", "num", "-", "1", ")", "*", "inc", ";", "inc", "=", "-", "inc", ";", "}", "}", "for", "(", "i", "=", "0", ";", "i", "<", "num", ";", "i", "++", ")", "{", "int", "number", "=", "source", "[", "offs", "[", "0", "]", "]", ";", "int", "sprite_bank", "=", "source", "[", "offs", "[", "1", "]", "]", "&", "0x0f", ";", "int", "sx", "=", "source", "[", "offs", "[", "3", "]", "]", ";", "int", "sy", "=", "source", "[", "offs", "[", "2", "]", "]", ";", "int", "attr", "=", "source", "[", "offs", "[", "4", "]", "]", ";", "int", "xflip", "=", "source", "[", "offs", "[", "4", "]", "]", "&", "0x10", ";", "int", "yflip", "=", "source", "[", "offs", "[", "4", "]", "]", "&", "0x20", ";", "int", "color", "=", "base_color", "+", "(", "(", "source", "[", "offs", "[", "1", "]", "]", "&", "0xf0", ")", ">>", "4", ")", ";", "int", "width", ",", "height", ";", "int", "transparent_mask", ";", "static", "const", "int", "x_offset", "[", "4", "]", "=", "{", "0x0", ",", "0x1", ",", "0x4", ",", "0x5", "}", ";", "static", "const", "int", "y_offset", "[", "4", "]", "=", "{", "0x0", ",", "0x2", ",", "0x8", ",", "0xa", "}", ";", "int", "x", ",", "y", ",", "ex", ",", "ey", ",", "flipx", ",", "flipy", ",", "destx", ",", "desty", ";", "if", "(", "attr", "&", "0x01", ")", "sx", "-=", "256", ";", "if", "(", "sy", ">=", "240", ")", "sy", "-=", "256", ";", "number", "+=", "(", "(", "sprite_bank", "&", "0x3", ")", "<<", "8", ")", "+", "(", "(", "attr", "&", "0xc0", ")", "<<", "4", ")", ";", "number", "=", "number", "<<", "2", ";", "number", "+=", "(", "sprite_bank", ">>", "2", ")", "&", "3", ";", "if", "(", "is_flakatck", ")", "transparent_mask", "=", "1", "<<", "0", ";", "else", "transparent_mask", "=", "colortable_get_transpen_mask", "(", "ctable", ",", "gfx", ",", "color", ",", "0", ")", ";", "if", "(", "!", "is_flakatck", "||", "source", "[", "0x00", "]", ")", "{", "number", "+=", "bank_base", ";", "switch", "(", "attr", "&", "0xe", ")", "{", "case", "0x06", ":", "width", "=", "height", "=", "1", ";", "break", ";", "case", "0x04", ":", "width", "=", "1", ";", "height", "=", "2", ";", "number", "&=", "(", "~", "2", ")", ";", "break", ";", "case", "0x02", ":", "width", "=", "2", ";", "height", "=", "1", ";", "number", "&=", "(", "~", "1", ")", ";", "break", ";", "case", "0x00", ":", "width", "=", "height", "=", "2", ";", "number", "&=", "(", "~", "3", ")", ";", "break", ";", "case", "0x08", ":", "width", "=", "height", "=", "4", ";", "number", "&=", "(", "~", "3", ")", ";", "break", ";", "default", ":", "width", "=", "1", ";", "height", "=", "1", ";", "}", "for", "(", "y", "=", "0", ";", "y", "<", "height", ";", "y", "++", ")", "{", "for", "(", "x", "=", "0", ";", "x", "<", "width", ";", "x", "++", ")", "{", "ex", "=", "xflip", "?", "(", "width", "-", "1", "-", "x", ")", ":", "x", ";", "ey", "=", "yflip", "?", "(", "height", "-", "1", "-", "y", ")", ":", "y", ";", "if", "(", "flipscreen", ")", "{", "flipx", "=", "!", "xflip", ";", "flipy", "=", "!", "yflip", ";", "destx", "=", "248", "-", "(", "sx", "+", "x", "*", "8", ")", ";", "desty", "=", "248", "-", "(", "sy", "+", "y", "*", "8", ")", ";", "}", "else", "{", "flipx", "=", "xflip", ";", "flipy", "=", "yflip", ";", "destx", "=", "global_x_offset", "+", "sx", "+", "x", "*", "8", ";", "desty", "=", "sy", "+", "y", "*", "8", ";", "}", "if", "(", "pri_mask", "!=", "-1", ")", "pdrawgfx_transmask", "(", "bitmap", ",", "cliprect", ",", "gfx", ",", "number", "+", "x_offset", "[", "ex", "]", "+", "y_offset", "[", "ey", "]", ",", "color", ",", "flipx", ",", "flipy", ",", "destx", ",", "desty", ",", "priority_bitmap", ",", "pri_mask", ",", "transparent_mask", ")", ";", "else", "drawgfx_transmask", "(", "bitmap", ",", "cliprect", ",", "gfx", ",", "number", "+", "x_offset", "[", "ex", "]", "+", "y_offset", "[", "ey", "]", ",", "color", ",", "flipx", ",", "flipy", ",", "destx", ",", "desty", ",", "transparent_mask", ")", ";", "}", "}", "}", "source", "+=", "inc", ";", "}", "}" ]
Sprite Format
[ "Sprite", "Format" ]
[ "// const gfx_element *gfx = gfxs[chip];\r", "/* all others */", "//num = (k007121->ctrlram[0x03] & 0x40) ? 0x80 : 0x40; /* WRONG!!! (needed by combatsc) */\r", "// combatsc writes 70 sprites to VRAM at peak but the chip only processes the first 64.\r", "/* when using priority buffer, draw front to back */", "/* sprite number */", "/* sprite bank */", "/* vertical position */", "/* horizontal position */", "/* attributes */", "/* flip x */", "/* flip y */", "/* Flak Attack doesn't use a lookup PROM, it maps the color code directly */", "/* to a palette entry */", "/* Flak Attack needs this */", "// logerror(\"Unknown sprite size %02x\\n\", attr & 0xe);\r", "// popmessage(\"Unknown sprite size %02x\\n\", attr & 0xe);\r" ]
[ { "param": "device", "type": "running_device" }, { "param": "bitmap", "type": "bitmap_t" }, { "param": "cliprect", "type": "rectangle" }, { "param": "gfx", "type": "gfx_element" }, { "param": "ctable", "type": "colortable_t" }, { "param": "source", "type": "UINT8" }, { "param": "base_color", "type": "int" }, { "param": "global_x_offset", "type": "int" }, { "param": "bank_base", "type": "int" }, { "param": "pri_mask", "type": "UINT32" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "device", "type": "running_device", "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 }, { "identifier": "gfx", "type": "gfx_element", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctable", "type": "colortable_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "source", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "base_color", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "global_x_offset", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bank_base", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pri_mask", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bdbb080e6407da4d24f550db2dcab907e3cdb578
lofunz/mieme
Reloaded/trunk/src/mame/video/konicdev.c
[ "Unlicense" ]
C
k05324x_set_z_rejection
void
void k05324x_set_z_rejection( running_device *device, int zcode ) { k05324x_state *k05324x = k05324x_get_safe_token(device); k05324x->z_rejection = zcode; }
/* In a K053247+K055555 setup objects with Z-code 0x00 should be ignored when PRFLIP is cleared, while objects with Z-code 0xff should be ignored when PRFLIP is set. These behaviors can also be seen in older K053245(6)+K053251 setups. Bucky'O Hare, The Simpsons and Sunset Riders rely on their implications to prepare and retire sprites. They probably apply to many other Konami games but it's hard to tell because most artifacts have been filtered by exclusion sort. A driver may call K05324x_set_z_rejection() to set which zcode to ignore. Parameter: -1 = accept all(default) 0x00-0xff = zcode to ignore */
In a K053247+K055555 setup objects with Z-code 0x00 should be ignored when PRFLIP is cleared, while objects with Z-code 0xff should be ignored when PRFLIP is set. These behaviors can also be seen in older K053245(6)+K053251 setups. Bucky'O Hare, The Simpsons and Sunset Riders rely on their implications to prepare and retire sprites. They probably apply to many other Konami games but it's hard to tell because most artifacts have been filtered by exclusion sort. A driver may call K05324x_set_z_rejection() to set which zcode to ignore. Parameter: 1 = accept all(default) 0x00-0xff = zcode to ignore
[ "In", "a", "K053247", "+", "K055555", "setup", "objects", "with", "Z", "-", "code", "0x00", "should", "be", "ignored", "when", "PRFLIP", "is", "cleared", "while", "objects", "with", "Z", "-", "code", "0xff", "should", "be", "ignored", "when", "PRFLIP", "is", "set", ".", "These", "behaviors", "can", "also", "be", "seen", "in", "older", "K053245", "(", "6", ")", "+", "K053251", "setups", ".", "Bucky", "'", "O", "Hare", "The", "Simpsons", "and", "Sunset", "Riders", "rely", "on", "their", "implications", "to", "prepare", "and", "retire", "sprites", ".", "They", "probably", "apply", "to", "many", "other", "Konami", "games", "but", "it", "'", "s", "hard", "to", "tell", "because", "most", "artifacts", "have", "been", "filtered", "by", "exclusion", "sort", ".", "A", "driver", "may", "call", "K05324x_set_z_rejection", "()", "to", "set", "which", "zcode", "to", "ignore", ".", "Parameter", ":", "1", "=", "accept", "all", "(", "default", ")", "0x00", "-", "0xff", "=", "zcode", "to", "ignore" ]
void k05324x_set_z_rejection( running_device *device, int zcode ) { k05324x_state *k05324x = k05324x_get_safe_token(device); k05324x->z_rejection = zcode; }
[ "void", "k05324x_set_z_rejection", "(", "running_device", "*", "device", ",", "int", "zcode", ")", "{", "k05324x_state", "*", "k05324x", "=", "k05324x_get_safe_token", "(", "device", ")", ";", "k05324x", "->", "z_rejection", "=", "zcode", ";", "}" ]
In a K053247+K055555 setup objects with Z-code 0x00 should be ignored when PRFLIP is cleared, while objects with Z-code 0xff should be ignored when PRFLIP is set.
[ "In", "a", "K053247", "+", "K055555", "setup", "objects", "with", "Z", "-", "code", "0x00", "should", "be", "ignored", "when", "PRFLIP", "is", "cleared", "while", "objects", "with", "Z", "-", "code", "0xff", "should", "be", "ignored", "when", "PRFLIP", "is", "set", "." ]
[]
[ { "param": "device", "type": "running_device" }, { "param": "zcode", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "device", "type": "running_device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "zcode", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bdbb080e6407da4d24f550db2dcab907e3cdb578
lofunz/mieme
Reloaded/trunk/src/mame/video/konicdev.c
[ "Unlicense" ]
C
k051316_wraparound_enable
void
void k051316_wraparound_enable( running_device *device, int status ) { k051316_state *k051316= k051316_get_safe_token(device); k051316->wraparound = status; }
// a few games (ajax, rollerg, ultraman, etc.) can enable and disable wraparound after start
a few games (ajax, rollerg, ultraman, etc.) can enable and disable wraparound after start
[ "a", "few", "games", "(", "ajax", "rollerg", "ultraman", "etc", ".", ")", "can", "enable", "and", "disable", "wraparound", "after", "start" ]
void k051316_wraparound_enable( running_device *device, int status ) { k051316_state *k051316= k051316_get_safe_token(device); k051316->wraparound = status; }
[ "void", "k051316_wraparound_enable", "(", "running_device", "*", "device", ",", "int", "status", ")", "{", "k051316_state", "*", "k051316", "=", "k051316_get_safe_token", "(", "device", ")", ";", "k051316", "->", "wraparound", "=", "status", ";", "}" ]
a few games (ajax, rollerg, ultraman, etc.)
[ "a", "few", "games", "(", "ajax", "rollerg", "ultraman", "etc", ".", ")" ]
[]
[ { "param": "device", "type": "running_device" }, { "param": "status", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "device", "type": "running_device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "status", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bdbb080e6407da4d24f550db2dcab907e3cdb578
lofunz/mieme
Reloaded/trunk/src/mame/video/konicdev.c
[ "Unlicense" ]
C
k056832_mark_all_tmaps_dirty
void
void k056832_mark_all_tmaps_dirty( running_device *device ) { k056832_state *k056832 = k056832_get_safe_token(device); k056832_mark_all_tilemaps_dirty(k056832); }
/* moo.c needs to call this in its VIDEO_UPDATE */
moo.c needs to call this in its VIDEO_UPDATE
[ "moo", ".", "c", "needs", "to", "call", "this", "in", "its", "VIDEO_UPDATE" ]
void k056832_mark_all_tmaps_dirty( running_device *device ) { k056832_state *k056832 = k056832_get_safe_token(device); k056832_mark_all_tilemaps_dirty(k056832); }
[ "void", "k056832_mark_all_tmaps_dirty", "(", "running_device", "*", "device", ")", "{", "k056832_state", "*", "k056832", "=", "k056832_get_safe_token", "(", "device", ")", ";", "k056832_mark_all_tilemaps_dirty", "(", "k056832", ")", ";", "}" ]
moo.c needs to call this in its VIDEO_UPDATE
[ "moo", ".", "c", "needs", "to", "call", "this", "in", "its", "VIDEO_UPDATE" ]
[]
[ { "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": [] }
bdbb080e6407da4d24f550db2dcab907e3cdb578
lofunz/mieme
Reloaded/trunk/src/mame/video/konicdev.c
[ "Unlicense" ]
C
k056832_SetExtLinescroll
void
void k056832_SetExtLinescroll( running_device *device ) { k056832_state *k056832 = k056832_get_safe_token(device); k056832->use_ext_linescroll = 1; }
/* call if a game uses external linescroll */
call if a game uses external linescroll
[ "call", "if", "a", "game", "uses", "external", "linescroll" ]
void k056832_SetExtLinescroll( running_device *device ) { k056832_state *k056832 = k056832_get_safe_token(device); k056832->use_ext_linescroll = 1; }
[ "void", "k056832_SetExtLinescroll", "(", "running_device", "*", "device", ")", "{", "k056832_state", "*", "k056832", "=", "k056832_get_safe_token", "(", "device", ")", ";", "k056832", "->", "use_ext_linescroll", "=", "1", ";", "}" ]
call if a game uses external linescroll
[ "call", "if", "a", "game", "uses", "external", "linescroll" ]
[]
[ { "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": [] }
bdbb080e6407da4d24f550db2dcab907e3cdb578
lofunz/mieme
Reloaded/trunk/src/mame/video/konicdev.c
[ "Unlicense" ]
C
k056832_rom_read_b
int
static int k056832_rom_read_b( running_device *device, int offset, int blksize, int blksize2, int zerosec ) { k056832_state *k056832 = k056832_get_safe_token(device); UINT8 *rombase; int base, ret; rombase = (UINT8 *)memory_region(device->machine, k056832->memory_region); if ((k056832->rom_half) && (zerosec)) { return 0; } // add in the bank offset offset += (k056832->cur_gfx_banks * 0x2000); // figure out the base of the ROM block base = (offset / blksize) * blksize2; // get the starting offset of the proper word inside the block base += (offset % blksize) * 2; if (k056832->rom_half) { ret = rombase[base + 1]; } else { ret = rombase[base]; k056832->rom_half = 1; } return ret; }
/* generic helper routine for ROM checksumming */
generic helper routine for ROM checksumming
[ "generic", "helper", "routine", "for", "ROM", "checksumming" ]
static int k056832_rom_read_b( running_device *device, int offset, int blksize, int blksize2, int zerosec ) { k056832_state *k056832 = k056832_get_safe_token(device); UINT8 *rombase; int base, ret; rombase = (UINT8 *)memory_region(device->machine, k056832->memory_region); if ((k056832->rom_half) && (zerosec)) { return 0; } offset += (k056832->cur_gfx_banks * 0x2000); base = (offset / blksize) * blksize2; base += (offset % blksize) * 2; if (k056832->rom_half) { ret = rombase[base + 1]; } else { ret = rombase[base]; k056832->rom_half = 1; } return ret; }
[ "static", "int", "k056832_rom_read_b", "(", "running_device", "*", "device", ",", "int", "offset", ",", "int", "blksize", ",", "int", "blksize2", ",", "int", "zerosec", ")", "{", "k056832_state", "*", "k056832", "=", "k056832_get_safe_token", "(", "device", ")", ";", "UINT8", "*", "rombase", ";", "int", "base", ",", "ret", ";", "rombase", "=", "(", "UINT8", "*", ")", "memory_region", "(", "device", "->", "machine", ",", "k056832", "->", "memory_region", ")", ";", "if", "(", "(", "k056832", "->", "rom_half", ")", "&&", "(", "zerosec", ")", ")", "{", "return", "0", ";", "}", "offset", "+=", "(", "k056832", "->", "cur_gfx_banks", "*", "0x2000", ")", ";", "base", "=", "(", "offset", "/", "blksize", ")", "*", "blksize2", ";", "base", "+=", "(", "offset", "%", "blksize", ")", "*", "2", ";", "if", "(", "k056832", "->", "rom_half", ")", "{", "ret", "=", "rombase", "[", "base", "+", "1", "]", ";", "}", "else", "{", "ret", "=", "rombase", "[", "base", "]", ";", "k056832", "->", "rom_half", "=", "1", ";", "}", "return", "ret", ";", "}" ]
generic helper routine for ROM checksumming
[ "generic", "helper", "routine", "for", "ROM", "checksumming" ]
[ "// add in the bank offset\r", "// figure out the base of the ROM block\r", "// get the starting offset of the proper word inside the block\r" ]
[ { "param": "device", "type": "running_device" }, { "param": "offset", "type": "int" }, { "param": "blksize", "type": "int" }, { "param": "blksize2", "type": "int" }, { "param": "zerosec", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "device", "type": "running_device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "offset", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "blksize", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "blksize2", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "zerosec", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bdbb080e6407da4d24f550db2dcab907e3cdb578
lofunz/mieme
Reloaded/trunk/src/mame/video/konicdev.c
[ "Unlicense" ]
C
k054338_register_r
int
int k054338_register_r( running_device *device, int reg ) { k054338_state *k054338 = k054338_get_safe_token(device); return k054338->regs[reg]; }
// returns a 16-bit '338 register
returns a 16-bit '338 register
[ "returns", "a", "16", "-", "bit", "'", "338", "register" ]
int k054338_register_r( running_device *device, int reg ) { k054338_state *k054338 = k054338_get_safe_token(device); return k054338->regs[reg]; }
[ "int", "k054338_register_r", "(", "running_device", "*", "device", ",", "int", "reg", ")", "{", "k054338_state", "*", "k054338", "=", "k054338_get_safe_token", "(", "device", ")", ";", "return", "k054338", "->", "regs", "[", "reg", "]", ";", "}" ]
returns a 16-bit '338 register
[ "returns", "a", "16", "-", "bit", "'", "338", "register" ]
[]
[ { "param": "device", "type": "running_device" }, { "param": "reg", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "device", "type": "running_device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reg", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bdbb080e6407da4d24f550db2dcab907e3cdb578
lofunz/mieme
Reloaded/trunk/src/mame/video/konicdev.c
[ "Unlicense" ]
C
k054338_set_alpha_level
int
int k054338_set_alpha_level( running_device *device, int pblend ) { k054338_state *k054338 = k054338_get_safe_token(device); UINT16 *regs; int ctrl, mixpri, mixset, mixlv; if (pblend <= 0 || pblend > 3) { return (255); } regs = k054338->regs; ctrl = k054338->regs[K338_REG_CONTROL]; mixpri = ctrl & K338_CTL_MIXPRI; mixset = regs[K338_REG_PBLEND + (pblend >> 1 & 1)] >> (~pblend << 3 & 8); mixlv = mixset & 0x1f; if (k054338->alphainverted) mixlv = 0x1f - mixlv; if (!(mixset & 0x20)) { mixlv = (mixlv << 3) | (mixlv >> 2); } else { if (!mixpri) { // source x alpha + target (clipped at 255) } else { // source + target x alpha (clipped at 255) } // DUMMY if (mixlv && mixlv < 0x1f) mixlv = 0x10; mixlv = (mixlv << 3) | (mixlv >> 2); if (VERBOSE) popmessage("MIXSET%1d %s addition mode: %02x", pblend, (mixpri) ? "dst" : "src", mixset & 0x1f); } return mixlv; }
// addition blending unimplemented (requires major changes to drawgfx and tilemap.c)
addition blending unimplemented (requires major changes to drawgfx and tilemap.c)
[ "addition", "blending", "unimplemented", "(", "requires", "major", "changes", "to", "drawgfx", "and", "tilemap", ".", "c", ")" ]
int k054338_set_alpha_level( running_device *device, int pblend ) { k054338_state *k054338 = k054338_get_safe_token(device); UINT16 *regs; int ctrl, mixpri, mixset, mixlv; if (pblend <= 0 || pblend > 3) { return (255); } regs = k054338->regs; ctrl = k054338->regs[K338_REG_CONTROL]; mixpri = ctrl & K338_CTL_MIXPRI; mixset = regs[K338_REG_PBLEND + (pblend >> 1 & 1)] >> (~pblend << 3 & 8); mixlv = mixset & 0x1f; if (k054338->alphainverted) mixlv = 0x1f - mixlv; if (!(mixset & 0x20)) { mixlv = (mixlv << 3) | (mixlv >> 2); } else { if (!mixpri) { } else { } if (mixlv && mixlv < 0x1f) mixlv = 0x10; mixlv = (mixlv << 3) | (mixlv >> 2); if (VERBOSE) popmessage("MIXSET%1d %s addition mode: %02x", pblend, (mixpri) ? "dst" : "src", mixset & 0x1f); } return mixlv; }
[ "int", "k054338_set_alpha_level", "(", "running_device", "*", "device", ",", "int", "pblend", ")", "{", "k054338_state", "*", "k054338", "=", "k054338_get_safe_token", "(", "device", ")", ";", "UINT16", "*", "regs", ";", "int", "ctrl", ",", "mixpri", ",", "mixset", ",", "mixlv", ";", "if", "(", "pblend", "<=", "0", "||", "pblend", ">", "3", ")", "{", "return", "(", "255", ")", ";", "}", "regs", "=", "k054338", "->", "regs", ";", "ctrl", "=", "k054338", "->", "regs", "[", "K338_REG_CONTROL", "]", ";", "mixpri", "=", "ctrl", "&", "K338_CTL_MIXPRI", ";", "mixset", "=", "regs", "[", "K338_REG_PBLEND", "+", "(", "pblend", ">>", "1", "&", "1", ")", "]", ">>", "(", "~", "pblend", "<<", "3", "&", "8", ")", ";", "mixlv", "=", "mixset", "&", "0x1f", ";", "if", "(", "k054338", "->", "alphainverted", ")", "mixlv", "=", "0x1f", "-", "mixlv", ";", "if", "(", "!", "(", "mixset", "&", "0x20", ")", ")", "{", "mixlv", "=", "(", "mixlv", "<<", "3", ")", "|", "(", "mixlv", ">>", "2", ")", ";", "}", "else", "{", "if", "(", "!", "mixpri", ")", "{", "}", "else", "{", "}", "if", "(", "mixlv", "&&", "mixlv", "<", "0x1f", ")", "mixlv", "=", "0x10", ";", "mixlv", "=", "(", "mixlv", "<<", "3", ")", "|", "(", "mixlv", ">>", "2", ")", ";", "if", "(", "VERBOSE", ")", "popmessage", "(", "\"", "\"", ",", "pblend", ",", "(", "mixpri", ")", "?", "\"", "\"", ":", "\"", "\"", ",", "mixset", "&", "0x1f", ")", ";", "}", "return", "mixlv", ";", "}" ]
addition blending unimplemented (requires major changes to drawgfx and tilemap.c)
[ "addition", "blending", "unimplemented", "(", "requires", "major", "changes", "to", "drawgfx", "and", "tilemap", ".", "c", ")" ]
[ "// source x alpha + target (clipped at 255)\r", "// source + target x alpha (clipped at 255)\r", "// DUMMY\r" ]
[ { "param": "device", "type": "running_device" }, { "param": "pblend", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "device", "type": "running_device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pblend", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bdbb080e6407da4d24f550db2dcab907e3cdb578
lofunz/mieme
Reloaded/trunk/src/mame/video/konicdev.c
[ "Unlicense" ]
C
k053250_dma
void
void k053250_dma( running_device *device, int limiter ) { k053250_state *k053250 = k053250_get_safe_token(device); int last_frame, current_frame; current_frame = k053250->screen->frame_number(); last_frame = k053250->frame; if (limiter && current_frame == last_frame) return; // make sure we only do DMA transfer once per frame k053250->frame = current_frame; memcpy(k053250->buffer[k053250->page], k053250->ram, 0x1000); k053250->page ^= 1; }
// The DMA process should be instantaneous but since rendering in MAME is performed at VIDEO_UPDATE() // the k053250 memory must be buffered to maintain visual integrity.
The DMA process should be instantaneous but since rendering in MAME is performed at VIDEO_UPDATE() the k053250 memory must be buffered to maintain visual integrity.
[ "The", "DMA", "process", "should", "be", "instantaneous", "but", "since", "rendering", "in", "MAME", "is", "performed", "at", "VIDEO_UPDATE", "()", "the", "k053250", "memory", "must", "be", "buffered", "to", "maintain", "visual", "integrity", "." ]
void k053250_dma( running_device *device, int limiter ) { k053250_state *k053250 = k053250_get_safe_token(device); int last_frame, current_frame; current_frame = k053250->screen->frame_number(); last_frame = k053250->frame; if (limiter && current_frame == last_frame) return; k053250->frame = current_frame; memcpy(k053250->buffer[k053250->page], k053250->ram, 0x1000); k053250->page ^= 1; }
[ "void", "k053250_dma", "(", "running_device", "*", "device", ",", "int", "limiter", ")", "{", "k053250_state", "*", "k053250", "=", "k053250_get_safe_token", "(", "device", ")", ";", "int", "last_frame", ",", "current_frame", ";", "current_frame", "=", "k053250", "->", "screen", "->", "frame_number", "(", ")", ";", "last_frame", "=", "k053250", "->", "frame", ";", "if", "(", "limiter", "&&", "current_frame", "==", "last_frame", ")", "return", ";", "k053250", "->", "frame", "=", "current_frame", ";", "memcpy", "(", "k053250", "->", "buffer", "[", "k053250", "->", "page", "]", ",", "k053250", "->", "ram", ",", "0x1000", ")", ";", "k053250", "->", "page", "^=", "1", ";", "}" ]
The DMA process should be instantaneous but since rendering in MAME is performed at VIDEO_UPDATE() the k053250 memory must be buffered to maintain visual integrity.
[ "The", "DMA", "process", "should", "be", "instantaneous", "but", "since", "rendering", "in", "MAME", "is", "performed", "at", "VIDEO_UPDATE", "()", "the", "k053250", "memory", "must", "be", "buffered", "to", "maintain", "visual", "integrity", "." ]
[ "// make sure we only do DMA transfer once per frame\r" ]
[ { "param": "device", "type": "running_device" }, { "param": "limiter", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "device", "type": "running_device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "limiter", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bdbb080e6407da4d24f550db2dcab907e3cdb578
lofunz/mieme
Reloaded/trunk/src/mame/video/konicdev.c
[ "Unlicense" ]
C
k053250_unpack_pixels
void
static void k053250_unpack_pixels(running_machine *machine, const char *region) { UINT8 *src_ptr, *dst_ptr; int hi_nibble, lo_nibble, offset; dst_ptr = src_ptr = memory_region(machine, region); offset = memory_region_length(machine, region) / 2 - 1; do { lo_nibble = hi_nibble = src_ptr[offset]; hi_nibble >>= 4; lo_nibble &= 0xf; dst_ptr[offset * 2 ] = hi_nibble; dst_ptr[offset * 2 + 1] = lo_nibble; } while ((--offset) >= 0); }
// Pixel data of the k053250 is nibble packed. It's preferable to be unpacked into byte format.
Pixel data of the k053250 is nibble packed. It's preferable to be unpacked into byte format.
[ "Pixel", "data", "of", "the", "k053250", "is", "nibble", "packed", ".", "It", "'", "s", "preferable", "to", "be", "unpacked", "into", "byte", "format", "." ]
static void k053250_unpack_pixels(running_machine *machine, const char *region) { UINT8 *src_ptr, *dst_ptr; int hi_nibble, lo_nibble, offset; dst_ptr = src_ptr = memory_region(machine, region); offset = memory_region_length(machine, region) / 2 - 1; do { lo_nibble = hi_nibble = src_ptr[offset]; hi_nibble >>= 4; lo_nibble &= 0xf; dst_ptr[offset * 2 ] = hi_nibble; dst_ptr[offset * 2 + 1] = lo_nibble; } while ((--offset) >= 0); }
[ "static", "void", "k053250_unpack_pixels", "(", "running_machine", "*", "machine", ",", "const", "char", "*", "region", ")", "{", "UINT8", "*", "src_ptr", ",", "*", "dst_ptr", ";", "int", "hi_nibble", ",", "lo_nibble", ",", "offset", ";", "dst_ptr", "=", "src_ptr", "=", "memory_region", "(", "machine", ",", "region", ")", ";", "offset", "=", "memory_region_length", "(", "machine", ",", "region", ")", "/", "2", "-", "1", ";", "do", "{", "lo_nibble", "=", "hi_nibble", "=", "src_ptr", "[", "offset", "]", ";", "hi_nibble", ">>=", "4", ";", "lo_nibble", "&=", "0xf", ";", "dst_ptr", "[", "offset", "*", "2", "]", "=", "hi_nibble", ";", "dst_ptr", "[", "offset", "*", "2", "+", "1", "]", "=", "lo_nibble", ";", "}", "while", "(", "(", "--", "offset", ")", ">=", "0", ")", ";", "}" ]
Pixel data of the k053250 is nibble packed.
[ "Pixel", "data", "of", "the", "k053250", "is", "nibble", "packed", "." ]
[]
[ { "param": "machine", "type": "running_machine" }, { "param": "region", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "region", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bdbb080e6407da4d24f550db2dcab907e3cdb578
lofunz/mieme
Reloaded/trunk/src/mame/video/konicdev.c
[ "Unlicense" ]
C
k001005_preprocess_texture_data
void
void k001005_preprocess_texture_data( UINT8 *rom, int length, int gticlub ) { int index; int i, x, y; UINT8 temp[0x40000]; const int *decode_x; const int *decode_y; if (gticlub) { decode_x = decode_x_gti; decode_y = decode_y_gti; } else { decode_x = decode_x_zr107; decode_y = decode_y_zr107; } for (index = 0; index < length; index += 0x40000) { int offset = index; memset(temp, 0, 0x40000); for (i = 0; i < 0x800; i++) { int tx = ((i & 0x400) >> 5) | ((i & 0x100) >> 4) | ((i & 0x40) >> 3) | ((i & 0x10) >> 2) | ((i & 0x4) >> 1) | (i & 0x1); int ty = ((i & 0x200) >> 5) | ((i & 0x80) >> 4) | ((i & 0x20) >> 3) | ((i & 0x8) >> 2) | ((i & 0x2) >> 1); tx <<= 3; ty <<= 4; for (y = 0; y < 16; y++) { for (x = 0; x < 8; x++) { UINT8 pixel = rom[offset + decode_y[y] + decode_x[x]]; temp[((ty + y) * 512) + (tx + x)] = pixel; } } offset += 128; } memcpy(&rom[index], temp, 0x40000); } }
// rearranges the texture data to a more practical order
rearranges the texture data to a more practical order
[ "rearranges", "the", "texture", "data", "to", "a", "more", "practical", "order" ]
void k001005_preprocess_texture_data( UINT8 *rom, int length, int gticlub ) { int index; int i, x, y; UINT8 temp[0x40000]; const int *decode_x; const int *decode_y; if (gticlub) { decode_x = decode_x_gti; decode_y = decode_y_gti; } else { decode_x = decode_x_zr107; decode_y = decode_y_zr107; } for (index = 0; index < length; index += 0x40000) { int offset = index; memset(temp, 0, 0x40000); for (i = 0; i < 0x800; i++) { int tx = ((i & 0x400) >> 5) | ((i & 0x100) >> 4) | ((i & 0x40) >> 3) | ((i & 0x10) >> 2) | ((i & 0x4) >> 1) | (i & 0x1); int ty = ((i & 0x200) >> 5) | ((i & 0x80) >> 4) | ((i & 0x20) >> 3) | ((i & 0x8) >> 2) | ((i & 0x2) >> 1); tx <<= 3; ty <<= 4; for (y = 0; y < 16; y++) { for (x = 0; x < 8; x++) { UINT8 pixel = rom[offset + decode_y[y] + decode_x[x]]; temp[((ty + y) * 512) + (tx + x)] = pixel; } } offset += 128; } memcpy(&rom[index], temp, 0x40000); } }
[ "void", "k001005_preprocess_texture_data", "(", "UINT8", "*", "rom", ",", "int", "length", ",", "int", "gticlub", ")", "{", "int", "index", ";", "int", "i", ",", "x", ",", "y", ";", "UINT8", "temp", "[", "0x40000", "]", ";", "const", "int", "*", "decode_x", ";", "const", "int", "*", "decode_y", ";", "if", "(", "gticlub", ")", "{", "decode_x", "=", "decode_x_gti", ";", "decode_y", "=", "decode_y_gti", ";", "}", "else", "{", "decode_x", "=", "decode_x_zr107", ";", "decode_y", "=", "decode_y_zr107", ";", "}", "for", "(", "index", "=", "0", ";", "index", "<", "length", ";", "index", "+=", "0x40000", ")", "{", "int", "offset", "=", "index", ";", "memset", "(", "temp", ",", "0", ",", "0x40000", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "0x800", ";", "i", "++", ")", "{", "int", "tx", "=", "(", "(", "i", "&", "0x400", ")", ">>", "5", ")", "|", "(", "(", "i", "&", "0x100", ")", ">>", "4", ")", "|", "(", "(", "i", "&", "0x40", ")", ">>", "3", ")", "|", "(", "(", "i", "&", "0x10", ")", ">>", "2", ")", "|", "(", "(", "i", "&", "0x4", ")", ">>", "1", ")", "|", "(", "i", "&", "0x1", ")", ";", "int", "ty", "=", "(", "(", "i", "&", "0x200", ")", ">>", "5", ")", "|", "(", "(", "i", "&", "0x80", ")", ">>", "4", ")", "|", "(", "(", "i", "&", "0x20", ")", ">>", "3", ")", "|", "(", "(", "i", "&", "0x8", ")", ">>", "2", ")", "|", "(", "(", "i", "&", "0x2", ")", ">>", "1", ")", ";", "tx", "<<=", "3", ";", "ty", "<<=", "4", ";", "for", "(", "y", "=", "0", ";", "y", "<", "16", ";", "y", "++", ")", "{", "for", "(", "x", "=", "0", ";", "x", "<", "8", ";", "x", "++", ")", "{", "UINT8", "pixel", "=", "rom", "[", "offset", "+", "decode_y", "[", "y", "]", "+", "decode_x", "[", "x", "]", "]", ";", "temp", "[", "(", "(", "ty", "+", "y", ")", "*", "512", ")", "+", "(", "tx", "+", "x", ")", "]", "=", "pixel", ";", "}", "}", "offset", "+=", "128", ";", "}", "memcpy", "(", "&", "rom", "[", "index", "]", ",", "temp", ",", "0x40000", ")", ";", "}", "}" ]
rearranges the texture data to a more practical order
[ "rearranges", "the", "texture", "data", "to", "a", "more", "practical", "order" ]
[]
[ { "param": "rom", "type": "UINT8" }, { "param": "length", "type": "int" }, { "param": "gticlub", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rom", "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": "gticlub", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
5aee04886236aa3ca5a5911c8ee530c9953fec26
lofunz/mieme
Reloaded/trunk/src/emu/info.c
[ "Unlicense" ]
C
print_game_bios
void
static void print_game_bios(FILE *out, const game_driver *game) { const rom_entry *rom; /* skip if no ROMs */ if (game->rom == NULL) return; /* iterate over ROM entries and look for BIOSes */ for (rom = game->rom; !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISSYSTEM_BIOS(rom)) { const char *name = ROM_GETNAME(rom); const char *description = ROM_GETHASHDATA(rom); /* output extracted name and descriptions */ fprintf(out, "\t\t<biosset"); fprintf(out, " name=\"%s\"", xml_normalize_string(name)); fprintf(out, " description=\"%s\"", xml_normalize_string(description)); if (ROM_GETBIOSFLAGS(rom) == 1) fprintf(out, " default=\"yes\""); fprintf(out, "/>\n"); } }
/*------------------------------------------------- print_game_bios - print the BIOS set for a game -------------------------------------------------*/
print the BIOS set for a game
[ "print", "the", "BIOS", "set", "for", "a", "game" ]
static void print_game_bios(FILE *out, const game_driver *game) { const rom_entry *rom; if (game->rom == NULL) return; for (rom = game->rom; !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISSYSTEM_BIOS(rom)) { const char *name = ROM_GETNAME(rom); const char *description = ROM_GETHASHDATA(rom); fprintf(out, "\t\t<biosset"); fprintf(out, " name=\"%s\"", xml_normalize_string(name)); fprintf(out, " description=\"%s\"", xml_normalize_string(description)); if (ROM_GETBIOSFLAGS(rom) == 1) fprintf(out, " default=\"yes\""); fprintf(out, "/>\n"); } }
[ "static", "void", "print_game_bios", "(", "FILE", "*", "out", ",", "const", "game_driver", "*", "game", ")", "{", "const", "rom_entry", "*", "rom", ";", "if", "(", "game", "->", "rom", "==", "NULL", ")", "return", ";", "for", "(", "rom", "=", "game", "->", "rom", ";", "!", "ROMENTRY_ISEND", "(", "rom", ")", ";", "rom", "++", ")", "if", "(", "ROMENTRY_ISSYSTEM_BIOS", "(", "rom", ")", ")", "{", "const", "char", "*", "name", "=", "ROM_GETNAME", "(", "rom", ")", ";", "const", "char", "*", "description", "=", "ROM_GETHASHDATA", "(", "rom", ")", ";", "fprintf", "(", "out", ",", "\"", "\\t", "\\t", "\"", ")", ";", "fprintf", "(", "out", ",", "\"", "\\\"", "\\\"", "\"", ",", "xml_normalize_string", "(", "name", ")", ")", ";", "fprintf", "(", "out", ",", "\"", "\\\"", "\\\"", "\"", ",", "xml_normalize_string", "(", "description", ")", ")", ";", "if", "(", "ROM_GETBIOSFLAGS", "(", "rom", ")", "==", "1", ")", "fprintf", "(", "out", ",", "\"", "\\\"", "\\\"", "\"", ")", ";", "fprintf", "(", "out", ",", "\"", "\\n", "\"", ")", ";", "}", "}" ]
print_game_bios - print the BIOS set for a game
[ "print_game_bios", "-", "print", "the", "BIOS", "set", "for", "a", "game" ]
[ "/* skip if no ROMs */", "/* iterate over ROM entries and look for BIOSes */", "/* output extracted name and descriptions */" ]
[ { "param": "out", "type": "FILE" }, { "param": "game", "type": "game_driver" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "out", "type": "FILE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "game", "type": "game_driver", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
5aee04886236aa3ca5a5911c8ee530c9953fec26
lofunz/mieme
Reloaded/trunk/src/emu/info.c
[ "Unlicense" ]
C
print_game_rom
void
static void print_game_rom(FILE *out, const game_driver *game, const machine_config *config) { const game_driver *clone_of = driver_get_clone(game); int rom_type; int parents = 0; const parent_info *pinfoarray[4]; for (; clone_of != NULL; clone_of = driver_get_clone(clone_of)) { assert_always(parents < ARRAY_LENGTH(pinfoarray), "too many parents"); pinfoarray[parents++] = global_alloc(parent_info(clone_of)); } /* iterate over 3 different ROM "types": BIOS, ROMs, DISKs */ for (rom_type = 0; rom_type < 3; rom_type++) { const rom_source *source; const rom_entry *region; /* iterate over ROM sources: first the game, then any devices */ for (source = rom_first_source(game, config); source != NULL; source = rom_next_source(game, config, source)) for (region = rom_first_region(game, source); region != NULL; region = rom_next_region(region)) { int is_disk = ROMREGION_ISDISKDATA(region); const rom_entry *rom; /* disk regions only work for disks */ if ((is_disk && rom_type != 2) || (!is_disk && rom_type == 2)) continue; /* iterate through ROM entries */ for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom)) { int is_bios = ROM_GETBIOSFLAGS(rom); const char *name = ROM_GETNAME(rom); int offset = ROM_GETOFFSET(rom); const char *merge_name = NULL; char bios_name[100]; /* BIOS ROMs only apply to bioses */ if ((is_bios && rom_type != 0) || (!is_bios && rom_type == 0)) continue; /* if we have a valid ROM and we are a clone, see if we can find the parent ROM */ if (!ROM_NOGOODDUMP(rom) && parents > 0) { merge_name = get_merge_name(rom, parents, pinfoarray); } /* scan for a BIOS name */ bios_name[0] = 0; if (!is_disk && is_bios) { const rom_entry *brom; /* scan backwards through the ROM entries */ for (brom = rom - 1; brom != game->rom; brom--) if (ROMENTRY_ISSYSTEM_BIOS(brom)) { strcpy(bios_name, ROM_GETNAME(brom)); break; } } /* opening tag */ if (!is_disk) fprintf(out, "\t\t<rom"); else fprintf(out, "\t\t<disk"); /* add name, merge, bios, and size tags */ if (name != NULL && name[0] != 0) fprintf(out, " name=\"%s\"", xml_normalize_string(name)); if (merge_name != NULL) fprintf(out, " merge=\"%s\"", xml_normalize_string(merge_name)); if (bios_name[0] != 0) fprintf(out, " bios=\"%s\"", xml_normalize_string(bios_name)); if (!is_disk) fprintf(out, " size=\"%d\"", rom_file_size(rom)); /* dump checksum information only if there is a known dump */ if (!hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_NO_DUMP)) { char checksum[HASH_BUF_SIZE]; int hashtype; /* iterate over hash function types and print out their values */ for (hashtype = 0; hashtype < HASH_NUM_FUNCTIONS; hashtype++) if (hash_data_extract_printable_checksum(ROM_GETHASHDATA(rom), 1 << hashtype, checksum)) fprintf(out, " %s=\"%s\"", hash_function_name(1 << hashtype), checksum); } /* append a region name */ fprintf(out, " region=\"%s\"", ROMREGION_GETTAG(region)); /* add nodump/baddump flags */ if (hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_NO_DUMP)) fprintf(out, " status=\"nodump\""); if (hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_BAD_DUMP)) fprintf(out, " status=\"baddump\""); /* for non-disk entries, print offset */ if (!is_disk) fprintf(out, " offset=\"%x\"", offset); /* for disk entries, add the disk index */ else fprintf(out, " index=\"%x\"", DISK_GETINDEX(rom)); /* add optional flag */ if ((!is_disk && ROM_ISOPTIONAL(rom)) || (is_disk && DISK_ISOPTIONAL(rom))) fprintf(out, " optional=\"yes\""); fprintf(out, "/>\n"); } } } for (; parents > 0; parents--) global_free(pinfoarray[parents - 1]); }
/*------------------------------------------------- print_game_rom - print the roms section of the XML output -------------------------------------------------*/
print the roms section of the XML output
[ "print", "the", "roms", "section", "of", "the", "XML", "output" ]
static void print_game_rom(FILE *out, const game_driver *game, const machine_config *config) { const game_driver *clone_of = driver_get_clone(game); int rom_type; int parents = 0; const parent_info *pinfoarray[4]; for (; clone_of != NULL; clone_of = driver_get_clone(clone_of)) { assert_always(parents < ARRAY_LENGTH(pinfoarray), "too many parents"); pinfoarray[parents++] = global_alloc(parent_info(clone_of)); } for (rom_type = 0; rom_type < 3; rom_type++) { const rom_source *source; const rom_entry *region; for (source = rom_first_source(game, config); source != NULL; source = rom_next_source(game, config, source)) for (region = rom_first_region(game, source); region != NULL; region = rom_next_region(region)) { int is_disk = ROMREGION_ISDISKDATA(region); const rom_entry *rom; if ((is_disk && rom_type != 2) || (!is_disk && rom_type == 2)) continue; for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom)) { int is_bios = ROM_GETBIOSFLAGS(rom); const char *name = ROM_GETNAME(rom); int offset = ROM_GETOFFSET(rom); const char *merge_name = NULL; char bios_name[100]; if ((is_bios && rom_type != 0) || (!is_bios && rom_type == 0)) continue; if (!ROM_NOGOODDUMP(rom) && parents > 0) { merge_name = get_merge_name(rom, parents, pinfoarray); } bios_name[0] = 0; if (!is_disk && is_bios) { const rom_entry *brom; for (brom = rom - 1; brom != game->rom; brom--) if (ROMENTRY_ISSYSTEM_BIOS(brom)) { strcpy(bios_name, ROM_GETNAME(brom)); break; } } if (!is_disk) fprintf(out, "\t\t<rom"); else fprintf(out, "\t\t<disk"); if (name != NULL && name[0] != 0) fprintf(out, " name=\"%s\"", xml_normalize_string(name)); if (merge_name != NULL) fprintf(out, " merge=\"%s\"", xml_normalize_string(merge_name)); if (bios_name[0] != 0) fprintf(out, " bios=\"%s\"", xml_normalize_string(bios_name)); if (!is_disk) fprintf(out, " size=\"%d\"", rom_file_size(rom)); if (!hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_NO_DUMP)) { char checksum[HASH_BUF_SIZE]; int hashtype; for (hashtype = 0; hashtype < HASH_NUM_FUNCTIONS; hashtype++) if (hash_data_extract_printable_checksum(ROM_GETHASHDATA(rom), 1 << hashtype, checksum)) fprintf(out, " %s=\"%s\"", hash_function_name(1 << hashtype), checksum); } fprintf(out, " region=\"%s\"", ROMREGION_GETTAG(region)); if (hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_NO_DUMP)) fprintf(out, " status=\"nodump\""); if (hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_BAD_DUMP)) fprintf(out, " status=\"baddump\""); if (!is_disk) fprintf(out, " offset=\"%x\"", offset); else fprintf(out, " index=\"%x\"", DISK_GETINDEX(rom)); if ((!is_disk && ROM_ISOPTIONAL(rom)) || (is_disk && DISK_ISOPTIONAL(rom))) fprintf(out, " optional=\"yes\""); fprintf(out, "/>\n"); } } } for (; parents > 0; parents--) global_free(pinfoarray[parents - 1]); }
[ "static", "void", "print_game_rom", "(", "FILE", "*", "out", ",", "const", "game_driver", "*", "game", ",", "const", "machine_config", "*", "config", ")", "{", "const", "game_driver", "*", "clone_of", "=", "driver_get_clone", "(", "game", ")", ";", "int", "rom_type", ";", "int", "parents", "=", "0", ";", "const", "parent_info", "*", "pinfoarray", "[", "4", "]", ";", "for", "(", ";", "clone_of", "!=", "NULL", ";", "clone_of", "=", "driver_get_clone", "(", "clone_of", ")", ")", "{", "assert_always", "(", "parents", "<", "ARRAY_LENGTH", "(", "pinfoarray", ")", ",", "\"", "\"", ")", ";", "pinfoarray", "[", "parents", "++", "]", "=", "global_alloc", "(", "parent_info", "(", "clone_of", ")", ")", ";", "}", "for", "(", "rom_type", "=", "0", ";", "rom_type", "<", "3", ";", "rom_type", "++", ")", "{", "const", "rom_source", "*", "source", ";", "const", "rom_entry", "*", "region", ";", "for", "(", "source", "=", "rom_first_source", "(", "game", ",", "config", ")", ";", "source", "!=", "NULL", ";", "source", "=", "rom_next_source", "(", "game", ",", "config", ",", "source", ")", ")", "for", "(", "region", "=", "rom_first_region", "(", "game", ",", "source", ")", ";", "region", "!=", "NULL", ";", "region", "=", "rom_next_region", "(", "region", ")", ")", "{", "int", "is_disk", "=", "ROMREGION_ISDISKDATA", "(", "region", ")", ";", "const", "rom_entry", "*", "rom", ";", "if", "(", "(", "is_disk", "&&", "rom_type", "!=", "2", ")", "||", "(", "!", "is_disk", "&&", "rom_type", "==", "2", ")", ")", "continue", ";", "for", "(", "rom", "=", "rom_first_file", "(", "region", ")", ";", "rom", "!=", "NULL", ";", "rom", "=", "rom_next_file", "(", "rom", ")", ")", "{", "int", "is_bios", "=", "ROM_GETBIOSFLAGS", "(", "rom", ")", ";", "const", "char", "*", "name", "=", "ROM_GETNAME", "(", "rom", ")", ";", "int", "offset", "=", "ROM_GETOFFSET", "(", "rom", ")", ";", "const", "char", "*", "merge_name", "=", "NULL", ";", "char", "bios_name", "[", "100", "]", ";", "if", "(", "(", "is_bios", "&&", "rom_type", "!=", "0", ")", "||", "(", "!", "is_bios", "&&", "rom_type", "==", "0", ")", ")", "continue", ";", "if", "(", "!", "ROM_NOGOODDUMP", "(", "rom", ")", "&&", "parents", ">", "0", ")", "{", "merge_name", "=", "get_merge_name", "(", "rom", ",", "parents", ",", "pinfoarray", ")", ";", "}", "bios_name", "[", "0", "]", "=", "0", ";", "if", "(", "!", "is_disk", "&&", "is_bios", ")", "{", "const", "rom_entry", "*", "brom", ";", "for", "(", "brom", "=", "rom", "-", "1", ";", "brom", "!=", "game", "->", "rom", ";", "brom", "--", ")", "if", "(", "ROMENTRY_ISSYSTEM_BIOS", "(", "brom", ")", ")", "{", "strcpy", "(", "bios_name", ",", "ROM_GETNAME", "(", "brom", ")", ")", ";", "break", ";", "}", "}", "if", "(", "!", "is_disk", ")", "fprintf", "(", "out", ",", "\"", "\\t", "\\t", "\"", ")", ";", "else", "fprintf", "(", "out", ",", "\"", "\\t", "\\t", "\"", ")", ";", "if", "(", "name", "!=", "NULL", "&&", "name", "[", "0", "]", "!=", "0", ")", "fprintf", "(", "out", ",", "\"", "\\\"", "\\\"", "\"", ",", "xml_normalize_string", "(", "name", ")", ")", ";", "if", "(", "merge_name", "!=", "NULL", ")", "fprintf", "(", "out", ",", "\"", "\\\"", "\\\"", "\"", ",", "xml_normalize_string", "(", "merge_name", ")", ")", ";", "if", "(", "bios_name", "[", "0", "]", "!=", "0", ")", "fprintf", "(", "out", ",", "\"", "\\\"", "\\\"", "\"", ",", "xml_normalize_string", "(", "bios_name", ")", ")", ";", "if", "(", "!", "is_disk", ")", "fprintf", "(", "out", ",", "\"", "\\\"", "\\\"", "\"", ",", "rom_file_size", "(", "rom", ")", ")", ";", "if", "(", "!", "hash_data_has_info", "(", "ROM_GETHASHDATA", "(", "rom", ")", ",", "HASH_INFO_NO_DUMP", ")", ")", "{", "char", "checksum", "[", "HASH_BUF_SIZE", "]", ";", "int", "hashtype", ";", "for", "(", "hashtype", "=", "0", ";", "hashtype", "<", "HASH_NUM_FUNCTIONS", ";", "hashtype", "++", ")", "if", "(", "hash_data_extract_printable_checksum", "(", "ROM_GETHASHDATA", "(", "rom", ")", ",", "1", "<<", "hashtype", ",", "checksum", ")", ")", "fprintf", "(", "out", ",", "\"", "\\\"", "\\\"", "\"", ",", "hash_function_name", "(", "1", "<<", "hashtype", ")", ",", "checksum", ")", ";", "}", "fprintf", "(", "out", ",", "\"", "\\\"", "\\\"", "\"", ",", "ROMREGION_GETTAG", "(", "region", ")", ")", ";", "if", "(", "hash_data_has_info", "(", "ROM_GETHASHDATA", "(", "rom", ")", ",", "HASH_INFO_NO_DUMP", ")", ")", "fprintf", "(", "out", ",", "\"", "\\\"", "\\\"", "\"", ")", ";", "if", "(", "hash_data_has_info", "(", "ROM_GETHASHDATA", "(", "rom", ")", ",", "HASH_INFO_BAD_DUMP", ")", ")", "fprintf", "(", "out", ",", "\"", "\\\"", "\\\"", "\"", ")", ";", "if", "(", "!", "is_disk", ")", "fprintf", "(", "out", ",", "\"", "\\\"", "\\\"", "\"", ",", "offset", ")", ";", "else", "fprintf", "(", "out", ",", "\"", "\\\"", "\\\"", "\"", ",", "DISK_GETINDEX", "(", "rom", ")", ")", ";", "if", "(", "(", "!", "is_disk", "&&", "ROM_ISOPTIONAL", "(", "rom", ")", ")", "||", "(", "is_disk", "&&", "DISK_ISOPTIONAL", "(", "rom", ")", ")", ")", "fprintf", "(", "out", ",", "\"", "\\\"", "\\\"", "\"", ")", ";", "fprintf", "(", "out", ",", "\"", "\\n", "\"", ")", ";", "}", "}", "}", "for", "(", ";", "parents", ">", "0", ";", "parents", "--", ")", "global_free", "(", "pinfoarray", "[", "parents", "-", "1", "]", ")", ";", "}" ]
print_game_rom - print the roms section of the XML output
[ "print_game_rom", "-", "print", "the", "roms", "section", "of", "the", "XML", "output" ]
[ "/* iterate over 3 different ROM \"types\": BIOS, ROMs, DISKs */", "/* iterate over ROM sources: first the game, then any devices */", "/* disk regions only work for disks */", "/* iterate through ROM entries */", "/* BIOS ROMs only apply to bioses */", "/* if we have a valid ROM and we are a clone, see if we can find the parent ROM */", "/* scan for a BIOS name */", "/* scan backwards through the ROM entries */", "/* opening tag */", "/* add name, merge, bios, and size tags */", "/* dump checksum information only if there is a known dump */", "/* iterate over hash function types and print out their values */", "/* append a region name */", "/* add nodump/baddump flags */", "/* for non-disk entries, print offset */", "/* for disk entries, add the disk index */", "/* add optional flag */" ]
[ { "param": "out", "type": "FILE" }, { "param": "game", "type": "game_driver" }, { "param": "config", "type": "machine_config" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "out", "type": "FILE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "game", "type": "game_driver", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "config", "type": "machine_config", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
5aee04886236aa3ca5a5911c8ee530c9953fec26
lofunz/mieme
Reloaded/trunk/src/emu/info.c
[ "Unlicense" ]
C
print_game_sampleof
void
static void print_game_sampleof(FILE *out, const game_driver *game, const machine_config *config) { const device_config_sound_interface *sound = NULL; for (bool gotone = config->m_devicelist.first(sound); gotone; gotone = sound->next(sound)) if (sound->devconfig().type() == SOUND_SAMPLES) { const char *const *samplenames = ((const samples_interface *)sound->devconfig().static_config())->samplenames; if (samplenames != NULL) { int sampnum; /* iterate over sample names */ for (sampnum = 0; samplenames[sampnum] != NULL; sampnum++) { const char *cursampname = samplenames[sampnum]; /* only output sampleof if different from the game name */ if (cursampname[0] == '*' && strcmp(cursampname + 1, game->name) != 0) fprintf(out, " sampleof=\"%s\"", xml_normalize_string(cursampname + 1)); } } } }
/*------------------------------------------------- print_game_sampleof - print the 'sampleof' attribute, if appropriate -------------------------------------------------*/
print the 'sampleof' attribute, if appropriate
[ "print", "the", "'", "sampleof", "'", "attribute", "if", "appropriate" ]
static void print_game_sampleof(FILE *out, const game_driver *game, const machine_config *config) { const device_config_sound_interface *sound = NULL; for (bool gotone = config->m_devicelist.first(sound); gotone; gotone = sound->next(sound)) if (sound->devconfig().type() == SOUND_SAMPLES) { const char *const *samplenames = ((const samples_interface *)sound->devconfig().static_config())->samplenames; if (samplenames != NULL) { int sampnum; for (sampnum = 0; samplenames[sampnum] != NULL; sampnum++) { const char *cursampname = samplenames[sampnum]; if (cursampname[0] == '*' && strcmp(cursampname + 1, game->name) != 0) fprintf(out, " sampleof=\"%s\"", xml_normalize_string(cursampname + 1)); } } } }
[ "static", "void", "print_game_sampleof", "(", "FILE", "*", "out", ",", "const", "game_driver", "*", "game", ",", "const", "machine_config", "*", "config", ")", "{", "const", "device_config_sound_interface", "*", "sound", "=", "NULL", ";", "for", "(", "bool", "gotone", "=", "config", "->", "m_devicelist", ".", "first", "(", "sound", ")", ";", "gotone", ";", "gotone", "=", "sound", "->", "next", "(", "sound", ")", ")", "if", "(", "sound", "->", "devconfig", "(", ")", ".", "type", "(", ")", "==", "SOUND_SAMPLES", ")", "{", "const", "char", "*", "const", "*", "samplenames", "=", "(", "(", "const", "samples_interface", "*", ")", "sound", "->", "devconfig", "(", ")", ".", "static_config", "(", ")", ")", "->", "samplenames", ";", "if", "(", "samplenames", "!=", "NULL", ")", "{", "int", "sampnum", ";", "for", "(", "sampnum", "=", "0", ";", "samplenames", "[", "sampnum", "]", "!=", "NULL", ";", "sampnum", "++", ")", "{", "const", "char", "*", "cursampname", "=", "samplenames", "[", "sampnum", "]", ";", "if", "(", "cursampname", "[", "0", "]", "==", "'", "'", "&&", "strcmp", "(", "cursampname", "+", "1", ",", "game", "->", "name", ")", "!=", "0", ")", "fprintf", "(", "out", ",", "\"", "\\\"", "\\\"", "\"", ",", "xml_normalize_string", "(", "cursampname", "+", "1", ")", ")", ";", "}", "}", "}", "}" ]
print_game_sampleof - print the 'sampleof' attribute, if appropriate
[ "print_game_sampleof", "-", "print", "the", "'", "sampleof", "'", "attribute", "if", "appropriate" ]
[ "/* iterate over sample names */", "/* only output sampleof if different from the game name */" ]
[ { "param": "out", "type": "FILE" }, { "param": "game", "type": "game_driver" }, { "param": "config", "type": "machine_config" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "out", "type": "FILE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "game", "type": "game_driver", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "config", "type": "machine_config", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }