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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
de69fd9779b3fbe92cd8cd8b99bcca0a6b744988 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/v60/am1.c | [
"Unlicense"
] | C | am1Register | UINT32 | static UINT32 am1Register(v60_state *cpustate)
{
switch (cpustate->moddim)
{
case 0:
cpustate->amout = (UINT8)cpustate->reg[cpustate->modval & 0x1F];
break;
case 1:
cpustate->amout = (UINT16)cpustate->reg[cpustate->modval & 0x1F];
break;
case 2:
cpustate->amout = cpustate->reg[cpustate->modval & 0x1F];
break;
}
return 1;
} | // AM1 Functions (for ReadAM)
// ************************** | AM1 Functions (for ReadAM) | [
"AM1",
"Functions",
"(",
"for",
"ReadAM",
")"
] | static UINT32 am1Register(v60_state *cpustate)
{
switch (cpustate->moddim)
{
case 0:
cpustate->amout = (UINT8)cpustate->reg[cpustate->modval & 0x1F];
break;
case 1:
cpustate->amout = (UINT16)cpustate->reg[cpustate->modval & 0x1F];
break;
case 2:
cpustate->amout = cpustate->reg[cpustate->modval & 0x1F];
break;
}
return 1;
} | [
"static",
"UINT32",
"am1Register",
"(",
"v60_state",
"*",
"cpustate",
")",
"{",
"switch",
"(",
"cpustate",
"->",
"moddim",
")",
"{",
"case",
"0",
":",
"cpustate",
"->",
"amout",
"=",
"(",
"UINT8",
")",
"cpustate",
"->",
"reg",
"[",
"cpustate",
"->",
"modval",
"&",
"0x1F",
"]",
";",
"break",
";",
"case",
"1",
":",
"cpustate",
"->",
"amout",
"=",
"(",
"UINT16",
")",
"cpustate",
"->",
"reg",
"[",
"cpustate",
"->",
"modval",
"&",
"0x1F",
"]",
";",
"break",
";",
"case",
"2",
":",
"cpustate",
"->",
"amout",
"=",
"cpustate",
"->",
"reg",
"[",
"cpustate",
"->",
"modval",
"&",
"0x1F",
"]",
";",
"break",
";",
"}",
"return",
"1",
";",
"}"
] | AM1 Functions (for ReadAM) | [
"AM1",
"Functions",
"(",
"for",
"ReadAM",
")"
] | [] | [
{
"param": "cpustate",
"type": "v60_state"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpustate",
"type": "v60_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a4520d0b849fced1efe34e5a922e794d2ea30b67 | lofunz/mieme | Reloaded/tags/MAME4droid1.1.2&MAME4iOS 1.1Reloaded/src/emu/cpu/mips/mips3fe.c | [
"Unlicense"
] | C | mips3fe_describe | int | int mips3fe_describe(void *param, opcode_desc *desc, const opcode_desc *prev)
{
mips3_state *mips = (mips3_state *)param;
UINT32 op, opswitch;
/* compute the physical PC */
if (!mips3com_translate_address(mips, ADDRESS_SPACE_PROGRAM, TRANSLATE_FETCH, &desc->physpc))
{
/* uh-oh: a page fault; leave the description empty and just if this is the first instruction, leave it empty and */
/* mark as needing to validate; otherwise, just end the sequence here */
desc->flags |= OPFLAG_VALIDATE_TLB | OPFLAG_CAN_CAUSE_EXCEPTION | OPFLAG_COMPILER_PAGE_FAULT | OPFLAG_VIRTUAL_NOOP | OPFLAG_END_SEQUENCE;
return TRUE;
}
/* fetch the opcode */
op = desc->opptr.l[0] = memory_decrypted_read_dword(mips->program, desc->physpc);
/* all instructions are 4 bytes and default to a single cycle each */
desc->length = 4;
desc->cycles = 1;
/* parse the instruction */
opswitch = op >> 26;
switch (opswitch)
{
case 0x00: /* SPECIAL */
return describe_instruction_special(mips, op, desc);
case 0x01: /* REGIMM */
return describe_instruction_regimm(mips, op, desc);
case 0x10: /* COP0 */
return describe_instruction_cop0(mips, op, desc);
case 0x11: /* COP1 */
return describe_instruction_cop1(mips, op, desc);
case 0x12: /* COP2 */
return describe_instruction_cop2(mips, op, desc);
case 0x13: /* COP1X - MIPS IV */
if (mips->flavor < MIPS3_TYPE_MIPS_IV)
return FALSE;
return describe_instruction_cop1x(mips, op, desc);
case 0x1c: /* IDT-specific opcodes: mad/madu/mul on R4640/4650, msub on RC32364 */
return describe_instruction_idt(mips, op, desc);
case 0x02: /* J */
desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
desc->targetpc = (desc->pc & 0xf0000000) | (LIMMVAL << 2);
desc->delayslots = 1;
return TRUE;
case 0x03: /* JAL */
desc->regout[0] |= REGFLAG_R(31);
desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
desc->targetpc = (desc->pc & 0xf0000000) | (LIMMVAL << 2);
desc->delayslots = 1;
return TRUE;
case 0x04: /* BEQ */
case 0x05: /* BNE */
case 0x14: /* BEQL */
case 0x15: /* BNEL */
if ((opswitch == 0x04 || opswitch == 0x14) && RSREG == RTREG)
desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
else
{
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
}
desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
desc->delayslots = 1;
desc->skipslots = (opswitch & 0x10) ? 1 : 0;
return TRUE;
case 0x06: /* BLEZ */
case 0x07: /* BGTZ */
case 0x16: /* BLEZL */
case 0x17: /* BGTZL */
if ((opswitch == 0x06 || opswitch == 0x16) && RSREG == 0)
desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
else
{
desc->regin[0] |= REGFLAG_R(RSREG);
desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
}
desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
desc->delayslots = 1;
desc->skipslots = (opswitch & 0x10) ? 1 : 0;
return TRUE;
case 0x08: /* ADDI */
case 0x18: /* DADDI */
desc->regin[0] |= REGFLAG_R(RSREG);
desc->regout[0] |= REGFLAG_R(RTREG);
desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x09: /* ADDIU */
case 0x0a: /* SLTI */
case 0x0b: /* SLTIU */
case 0x0c: /* ANDI */
case 0x0d: /* ORI */
case 0x0e: /* XORI */
case 0x19: /* DADDIU */
desc->regin[0] |= REGFLAG_R(RSREG);
desc->regout[0] |= REGFLAG_R(RTREG);
return TRUE;
case 0x0f: /* LUI */
desc->regout[0] |= REGFLAG_R(RTREG);
return TRUE;
case 0x1a: /* LDL */
case 0x1b: /* LDR */
case 0x22: /* LWL */
case 0x26: /* LWR */
desc->regin[0] |= REGFLAG_R(RTREG);
case 0x20: /* LB */
case 0x21: /* LH */
case 0x23: /* LW */
case 0x24: /* LBU */
case 0x25: /* LHU */
case 0x27: /* LWU */
case 0x30: /* LL */
case 0x34: /* LLD */
case 0x37: /* LD */
desc->regin[0] |= REGFLAG_R(RSREG);
desc->regout[0] |= REGFLAG_R(RTREG);
desc->flags |= OPFLAG_READS_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x28: /* SB */
case 0x29: /* SH */
case 0x2a: /* SWL */
case 0x2b: /* SW */
case 0x2c: /* SDL */
case 0x2d: /* SDR */
case 0x2e: /* SWR */
case 0x3f: /* SD */
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->flags |= OPFLAG_WRITES_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x38: /* SC */
case 0x3c: /* SCD */
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regout[0] |= REGFLAG_R(RTREG);
desc->flags |= OPFLAG_WRITES_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x31: /* LWC1 */
case 0x35: /* LDC1 */
desc->regin[0] |= REGFLAG_R(RSREG);
desc->regout[1] |= REGFLAG_CPR1(RTREG);
desc->flags |= OPFLAG_READS_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x39: /* SWC1 */
case 0x3d: /* SDC1 */
desc->regin[0] |= REGFLAG_R(RSREG);
desc->regin[1] |= REGFLAG_CPR1(RTREG);
desc->flags |= OPFLAG_WRITES_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x32: /* LWC2 */
case 0x36: /* LDC2 */
desc->regin[0] |= REGFLAG_R(RSREG);
desc->flags |= OPFLAG_READS_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x3a: /* SWC2 */
case 0x3e: /* SDC2 */
desc->regin[0] |= REGFLAG_R(RSREG);
desc->flags |= OPFLAG_WRITES_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x33: /* PREF */
if (mips->flavor < MIPS3_TYPE_MIPS_IV)
return FALSE;
case 0x2f: /* CACHE */
/* effective no-op */
return TRUE;
}
return FALSE;
} | /*-------------------------------------------------
describe_instruction - build a description
of a single instruction
-------------------------------------------------*/ | build a description
of a single instruction | [
"build",
"a",
"description",
"of",
"a",
"single",
"instruction"
] | int mips3fe_describe(void *param, opcode_desc *desc, const opcode_desc *prev)
{
mips3_state *mips = (mips3_state *)param;
UINT32 op, opswitch;
if (!mips3com_translate_address(mips, ADDRESS_SPACE_PROGRAM, TRANSLATE_FETCH, &desc->physpc))
{
desc->flags |= OPFLAG_VALIDATE_TLB | OPFLAG_CAN_CAUSE_EXCEPTION | OPFLAG_COMPILER_PAGE_FAULT | OPFLAG_VIRTUAL_NOOP | OPFLAG_END_SEQUENCE;
return TRUE;
}
op = desc->opptr.l[0] = memory_decrypted_read_dword(mips->program, desc->physpc);
desc->length = 4;
desc->cycles = 1;
opswitch = op >> 26;
switch (opswitch)
{
case 0x00:
return describe_instruction_special(mips, op, desc);
case 0x01:
return describe_instruction_regimm(mips, op, desc);
case 0x10:
return describe_instruction_cop0(mips, op, desc);
case 0x11:
return describe_instruction_cop1(mips, op, desc);
case 0x12:
return describe_instruction_cop2(mips, op, desc);
case 0x13:
if (mips->flavor < MIPS3_TYPE_MIPS_IV)
return FALSE;
return describe_instruction_cop1x(mips, op, desc);
case 0x1c:
return describe_instruction_idt(mips, op, desc);
case 0x02:
desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
desc->targetpc = (desc->pc & 0xf0000000) | (LIMMVAL << 2);
desc->delayslots = 1;
return TRUE;
case 0x03:
desc->regout[0] |= REGFLAG_R(31);
desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
desc->targetpc = (desc->pc & 0xf0000000) | (LIMMVAL << 2);
desc->delayslots = 1;
return TRUE;
case 0x04:
case 0x05:
case 0x14:
case 0x15:
if ((opswitch == 0x04 || opswitch == 0x14) && RSREG == RTREG)
desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
else
{
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
}
desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
desc->delayslots = 1;
desc->skipslots = (opswitch & 0x10) ? 1 : 0;
return TRUE;
case 0x06:
case 0x07:
case 0x16:
case 0x17:
if ((opswitch == 0x06 || opswitch == 0x16) && RSREG == 0)
desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
else
{
desc->regin[0] |= REGFLAG_R(RSREG);
desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
}
desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
desc->delayslots = 1;
desc->skipslots = (opswitch & 0x10) ? 1 : 0;
return TRUE;
case 0x08:
case 0x18:
desc->regin[0] |= REGFLAG_R(RSREG);
desc->regout[0] |= REGFLAG_R(RTREG);
desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x09:
case 0x0a:
case 0x0b:
case 0x0c:
case 0x0d:
case 0x0e:
case 0x19:
desc->regin[0] |= REGFLAG_R(RSREG);
desc->regout[0] |= REGFLAG_R(RTREG);
return TRUE;
case 0x0f:
desc->regout[0] |= REGFLAG_R(RTREG);
return TRUE;
case 0x1a:
case 0x1b:
case 0x22:
case 0x26:
desc->regin[0] |= REGFLAG_R(RTREG);
case 0x20:
case 0x21:
case 0x23:
case 0x24:
case 0x25:
case 0x27:
case 0x30:
case 0x34:
case 0x37:
desc->regin[0] |= REGFLAG_R(RSREG);
desc->regout[0] |= REGFLAG_R(RTREG);
desc->flags |= OPFLAG_READS_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x28:
case 0x29:
case 0x2a:
case 0x2b:
case 0x2c:
case 0x2d:
case 0x2e:
case 0x3f:
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->flags |= OPFLAG_WRITES_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x38:
case 0x3c:
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regout[0] |= REGFLAG_R(RTREG);
desc->flags |= OPFLAG_WRITES_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x31:
case 0x35:
desc->regin[0] |= REGFLAG_R(RSREG);
desc->regout[1] |= REGFLAG_CPR1(RTREG);
desc->flags |= OPFLAG_READS_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x39:
case 0x3d:
desc->regin[0] |= REGFLAG_R(RSREG);
desc->regin[1] |= REGFLAG_CPR1(RTREG);
desc->flags |= OPFLAG_WRITES_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x32:
case 0x36:
desc->regin[0] |= REGFLAG_R(RSREG);
desc->flags |= OPFLAG_READS_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x3a:
case 0x3e:
desc->regin[0] |= REGFLAG_R(RSREG);
desc->flags |= OPFLAG_WRITES_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x33:
if (mips->flavor < MIPS3_TYPE_MIPS_IV)
return FALSE;
case 0x2f:
return TRUE;
}
return FALSE;
} | [
"int",
"mips3fe_describe",
"(",
"void",
"*",
"param",
",",
"opcode_desc",
"*",
"desc",
",",
"const",
"opcode_desc",
"*",
"prev",
")",
"{",
"mips3_state",
"*",
"mips",
"=",
"(",
"mips3_state",
"*",
")",
"param",
";",
"UINT32",
"op",
",",
"opswitch",
";",
"if",
"(",
"!",
"mips3com_translate_address",
"(",
"mips",
",",
"ADDRESS_SPACE_PROGRAM",
",",
"TRANSLATE_FETCH",
",",
"&",
"desc",
"->",
"physpc",
")",
")",
"{",
"desc",
"->",
"flags",
"|=",
"OPFLAG_VALIDATE_TLB",
"|",
"OPFLAG_CAN_CAUSE_EXCEPTION",
"|",
"OPFLAG_COMPILER_PAGE_FAULT",
"|",
"OPFLAG_VIRTUAL_NOOP",
"|",
"OPFLAG_END_SEQUENCE",
";",
"return",
"TRUE",
";",
"}",
"op",
"=",
"desc",
"->",
"opptr",
".",
"l",
"[",
"0",
"]",
"=",
"memory_decrypted_read_dword",
"(",
"mips",
"->",
"program",
",",
"desc",
"->",
"physpc",
")",
";",
"desc",
"->",
"length",
"=",
"4",
";",
"desc",
"->",
"cycles",
"=",
"1",
";",
"opswitch",
"=",
"op",
">>",
"26",
";",
"switch",
"(",
"opswitch",
")",
"{",
"case",
"0x00",
":",
"return",
"describe_instruction_special",
"(",
"mips",
",",
"op",
",",
"desc",
")",
";",
"case",
"0x01",
":",
"return",
"describe_instruction_regimm",
"(",
"mips",
",",
"op",
",",
"desc",
")",
";",
"case",
"0x10",
":",
"return",
"describe_instruction_cop0",
"(",
"mips",
",",
"op",
",",
"desc",
")",
";",
"case",
"0x11",
":",
"return",
"describe_instruction_cop1",
"(",
"mips",
",",
"op",
",",
"desc",
")",
";",
"case",
"0x12",
":",
"return",
"describe_instruction_cop2",
"(",
"mips",
",",
"op",
",",
"desc",
")",
";",
"case",
"0x13",
":",
"if",
"(",
"mips",
"->",
"flavor",
"<",
"MIPS3_TYPE_MIPS_IV",
")",
"return",
"FALSE",
";",
"return",
"describe_instruction_cop1x",
"(",
"mips",
",",
"op",
",",
"desc",
")",
";",
"case",
"0x1c",
":",
"return",
"describe_instruction_idt",
"(",
"mips",
",",
"op",
",",
"desc",
")",
";",
"case",
"0x02",
":",
"desc",
"->",
"flags",
"|=",
"OPFLAG_IS_UNCONDITIONAL_BRANCH",
"|",
"OPFLAG_END_SEQUENCE",
";",
"desc",
"->",
"targetpc",
"=",
"(",
"desc",
"->",
"pc",
"&",
"0xf0000000",
")",
"|",
"(",
"LIMMVAL",
"<<",
"2",
")",
";",
"desc",
"->",
"delayslots",
"=",
"1",
";",
"return",
"TRUE",
";",
"case",
"0x03",
":",
"desc",
"->",
"regout",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"31",
")",
";",
"desc",
"->",
"flags",
"|=",
"OPFLAG_IS_UNCONDITIONAL_BRANCH",
"|",
"OPFLAG_END_SEQUENCE",
";",
"desc",
"->",
"targetpc",
"=",
"(",
"desc",
"->",
"pc",
"&",
"0xf0000000",
")",
"|",
"(",
"LIMMVAL",
"<<",
"2",
")",
";",
"desc",
"->",
"delayslots",
"=",
"1",
";",
"return",
"TRUE",
";",
"case",
"0x04",
":",
"case",
"0x05",
":",
"case",
"0x14",
":",
"case",
"0x15",
":",
"if",
"(",
"(",
"opswitch",
"==",
"0x04",
"||",
"opswitch",
"==",
"0x14",
")",
"&&",
"RSREG",
"==",
"RTREG",
")",
"desc",
"->",
"flags",
"|=",
"OPFLAG_IS_UNCONDITIONAL_BRANCH",
"|",
"OPFLAG_END_SEQUENCE",
";",
"else",
"{",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
"|",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"desc",
"->",
"flags",
"|=",
"OPFLAG_IS_CONDITIONAL_BRANCH",
";",
"}",
"desc",
"->",
"targetpc",
"=",
"desc",
"->",
"pc",
"+",
"4",
"+",
"(",
"SIMMVAL",
"<<",
"2",
")",
";",
"desc",
"->",
"delayslots",
"=",
"1",
";",
"desc",
"->",
"skipslots",
"=",
"(",
"opswitch",
"&",
"0x10",
")",
"?",
"1",
":",
"0",
";",
"return",
"TRUE",
";",
"case",
"0x06",
":",
"case",
"0x07",
":",
"case",
"0x16",
":",
"case",
"0x17",
":",
"if",
"(",
"(",
"opswitch",
"==",
"0x06",
"||",
"opswitch",
"==",
"0x16",
")",
"&&",
"RSREG",
"==",
"0",
")",
"desc",
"->",
"flags",
"|=",
"OPFLAG_IS_UNCONDITIONAL_BRANCH",
"|",
"OPFLAG_END_SEQUENCE",
";",
"else",
"{",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
";",
"desc",
"->",
"flags",
"|=",
"OPFLAG_IS_CONDITIONAL_BRANCH",
";",
"}",
"desc",
"->",
"targetpc",
"=",
"desc",
"->",
"pc",
"+",
"4",
"+",
"(",
"SIMMVAL",
"<<",
"2",
")",
";",
"desc",
"->",
"delayslots",
"=",
"1",
";",
"desc",
"->",
"skipslots",
"=",
"(",
"opswitch",
"&",
"0x10",
")",
"?",
"1",
":",
"0",
";",
"return",
"TRUE",
";",
"case",
"0x08",
":",
"case",
"0x18",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
";",
"desc",
"->",
"regout",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"desc",
"->",
"flags",
"|=",
"OPFLAG_CAN_CAUSE_EXCEPTION",
";",
"return",
"TRUE",
";",
"case",
"0x09",
":",
"case",
"0x0a",
":",
"case",
"0x0b",
":",
"case",
"0x0c",
":",
"case",
"0x0d",
":",
"case",
"0x0e",
":",
"case",
"0x19",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
";",
"desc",
"->",
"regout",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"return",
"TRUE",
";",
"case",
"0x0f",
":",
"desc",
"->",
"regout",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"return",
"TRUE",
";",
"case",
"0x1a",
":",
"case",
"0x1b",
":",
"case",
"0x22",
":",
"case",
"0x26",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"case",
"0x20",
":",
"case",
"0x21",
":",
"case",
"0x23",
":",
"case",
"0x24",
":",
"case",
"0x25",
":",
"case",
"0x27",
":",
"case",
"0x30",
":",
"case",
"0x34",
":",
"case",
"0x37",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
";",
"desc",
"->",
"regout",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"desc",
"->",
"flags",
"|=",
"OPFLAG_READS_MEMORY",
"|",
"OPFLAG_CAN_CAUSE_EXCEPTION",
";",
"return",
"TRUE",
";",
"case",
"0x28",
":",
"case",
"0x29",
":",
"case",
"0x2a",
":",
"case",
"0x2b",
":",
"case",
"0x2c",
":",
"case",
"0x2d",
":",
"case",
"0x2e",
":",
"case",
"0x3f",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
"|",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"desc",
"->",
"flags",
"|=",
"OPFLAG_WRITES_MEMORY",
"|",
"OPFLAG_CAN_CAUSE_EXCEPTION",
";",
"return",
"TRUE",
";",
"case",
"0x38",
":",
"case",
"0x3c",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
"|",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"desc",
"->",
"regout",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"desc",
"->",
"flags",
"|=",
"OPFLAG_WRITES_MEMORY",
"|",
"OPFLAG_CAN_CAUSE_EXCEPTION",
";",
"return",
"TRUE",
";",
"case",
"0x31",
":",
"case",
"0x35",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
";",
"desc",
"->",
"regout",
"[",
"1",
"]",
"|=",
"REGFLAG_CPR1",
"(",
"RTREG",
")",
";",
"desc",
"->",
"flags",
"|=",
"OPFLAG_READS_MEMORY",
"|",
"OPFLAG_CAN_CAUSE_EXCEPTION",
";",
"return",
"TRUE",
";",
"case",
"0x39",
":",
"case",
"0x3d",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
";",
"desc",
"->",
"regin",
"[",
"1",
"]",
"|=",
"REGFLAG_CPR1",
"(",
"RTREG",
")",
";",
"desc",
"->",
"flags",
"|=",
"OPFLAG_WRITES_MEMORY",
"|",
"OPFLAG_CAN_CAUSE_EXCEPTION",
";",
"return",
"TRUE",
";",
"case",
"0x32",
":",
"case",
"0x36",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
";",
"desc",
"->",
"flags",
"|=",
"OPFLAG_READS_MEMORY",
"|",
"OPFLAG_CAN_CAUSE_EXCEPTION",
";",
"return",
"TRUE",
";",
"case",
"0x3a",
":",
"case",
"0x3e",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
";",
"desc",
"->",
"flags",
"|=",
"OPFLAG_WRITES_MEMORY",
"|",
"OPFLAG_CAN_CAUSE_EXCEPTION",
";",
"return",
"TRUE",
";",
"case",
"0x33",
":",
"if",
"(",
"mips",
"->",
"flavor",
"<",
"MIPS3_TYPE_MIPS_IV",
")",
"return",
"FALSE",
";",
"case",
"0x2f",
":",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}"
] | describe_instruction - build a description
of a single instruction | [
"describe_instruction",
"-",
"build",
"a",
"description",
"of",
"a",
"single",
"instruction"
] | [
"/* compute the physical PC */",
"/* uh-oh: a page fault; leave the description empty and just if this is the first instruction, leave it empty and */",
"/* mark as needing to validate; otherwise, just end the sequence here */",
"/* fetch the opcode */",
"/* all instructions are 4 bytes and default to a single cycle each */",
"/* parse the instruction */",
"/* SPECIAL */",
"/* REGIMM */",
"/* COP0 */",
"/* COP1 */",
"/* COP2 */",
"/* COP1X - MIPS IV */",
"/* IDT-specific opcodes: mad/madu/mul on R4640/4650, msub on RC32364 */",
"/* J */",
"/* JAL */",
"/* BEQ */",
"/* BNE */",
"/* BEQL */",
"/* BNEL */",
"/* BLEZ */",
"/* BGTZ */",
"/* BLEZL */",
"/* BGTZL */",
"/* ADDI */",
"/* DADDI */",
"/* ADDIU */",
"/* SLTI */",
"/* SLTIU */",
"/* ANDI */",
"/* ORI */",
"/* XORI */",
"/* DADDIU */",
"/* LUI */",
"/* LDL */",
"/* LDR */",
"/* LWL */",
"/* LWR */",
"/* LB */",
"/* LH */",
"/* LW */",
"/* LBU */",
"/* LHU */",
"/* LWU */",
"/* LL */",
"/* LLD */",
"/* LD */",
"/* SB */",
"/* SH */",
"/* SWL */",
"/* SW */",
"/* SDL */",
"/* SDR */",
"/* SWR */",
"/* SD */",
"/* SC */",
"/* SCD */",
"/* LWC1 */",
"/* LDC1 */",
"/* SWC1 */",
"/* SDC1 */",
"/* LWC2 */",
"/* LDC2 */",
"/* SWC2 */",
"/* SDC2 */",
"/* PREF */",
"/* CACHE */",
"/* effective no-op */"
] | [
{
"param": "param",
"type": "void"
},
{
"param": "desc",
"type": "opcode_desc"
},
{
"param": "prev",
"type": "opcode_desc"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "param",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "desc",
"type": "opcode_desc",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "prev",
"type": "opcode_desc",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a4520d0b849fced1efe34e5a922e794d2ea30b67 | lofunz/mieme | Reloaded/tags/MAME4droid1.1.2&MAME4iOS 1.1Reloaded/src/emu/cpu/mips/mips3fe.c | [
"Unlicense"
] | C | describe_instruction_special | int | static int describe_instruction_special(mips3_state *mips, UINT32 op, opcode_desc *desc)
{
switch (op & 63)
{
case 0x00: /* SLL */
case 0x02: /* SRL */
case 0x03: /* SRA */
case 0x38: /* DSLL */
case 0x3a: /* DSRL */
case 0x3b: /* DSRA */
case 0x3c: /* DSLL32 */
case 0x3e: /* DSRL32 */
case 0x3f: /* DSRA32 */
desc->regin[0] |= REGFLAG_R(RTREG);
desc->regout[0] |= REGFLAG_R(RDREG);
return TRUE;
case 0x0a: /* MOVZ - MIPS IV */
case 0x0b: /* MOVN - MIPS IV */
if (mips->flavor < MIPS3_TYPE_MIPS_IV)
return FALSE;
desc->regin[0] |= REGFLAG_R(RDREG);
case 0x04: /* SLLV */
case 0x06: /* SRLV */
case 0x07: /* SRAV */
case 0x14: /* DSLLV */
case 0x16: /* DSRLV */
case 0x17: /* DSRAV */
case 0x21: /* ADDU */
case 0x23: /* SUBU */
case 0x24: /* AND */
case 0x25: /* OR */
case 0x26: /* XOR */
case 0x27: /* NOR */
case 0x2a: /* SLT */
case 0x2b: /* SLTU */
case 0x2d: /* DADDU */
case 0x2f: /* DSUBU */
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regout[0] |= REGFLAG_R(RDREG);
return TRUE;
case 0x20: /* ADD */
case 0x22: /* SUB */
case 0x2c: /* DADD */
case 0x2e: /* DSUB */
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regout[0] |= REGFLAG_R(RDREG);
desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x30: /* TGE */
case 0x31: /* TGEU */
case 0x32: /* TLT */
case 0x33: /* TLTU */
case 0x34: /* TEQ */
case 0x36: /* TNE */
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x01: /* MOVF - MIPS IV */
if (mips->flavor < MIPS3_TYPE_MIPS_IV)
return FALSE;
desc->regin[0] |= REGFLAG_R(RSREG);
desc->regin[2] |= REGFLAG_FCC;
desc->regout[0] |= REGFLAG_R(RDREG);
return TRUE;
case 0x08: /* JR */
desc->regin[0] |= REGFLAG_R(RSREG);
desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
desc->targetpc = BRANCH_TARGET_DYNAMIC;
desc->delayslots = 1;
return TRUE;
case 0x09: /* JALR */
desc->regin[0] |= REGFLAG_R(RSREG);
desc->regout[0] |= REGFLAG_R(RDREG);
desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
desc->targetpc = BRANCH_TARGET_DYNAMIC;
desc->delayslots = 1;
return TRUE;
case 0x10: /* MFHI */
desc->regin[0] |= REGFLAG_HI;
desc->regout[0] |= REGFLAG_R(RDREG);
return TRUE;
case 0x11: /* MTHI */
desc->regin[0] |= REGFLAG_R(RSREG);
desc->regout[0] |= REGFLAG_HI;
return TRUE;
case 0x12: /* MFLO */
desc->regin[2] |= REGFLAG_LO;
desc->regout[0] |= REGFLAG_R(RDREG);
return TRUE;
case 0x13: /* MTLO */
desc->regin[0] |= REGFLAG_R(RSREG);
desc->regout[2] |= REGFLAG_LO;
return TRUE;
case 0x18: /* MULT */
case 0x19: /* MULTU */
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regout[2] |= REGFLAG_LO | REGFLAG_HI;
desc->cycles = 3;
return TRUE;
case 0x1a: /* DIV */
case 0x1b: /* DIVU */
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regout[2] |= REGFLAG_LO | REGFLAG_HI;
desc->cycles = 35;
return TRUE;
case 0x1c: /* DMULT */
case 0x1d: /* DMULTU */
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regout[2] |= REGFLAG_LO | REGFLAG_HI;
desc->cycles = 7;
return TRUE;
case 0x1e: /* DDIV */
case 0x1f: /* DDIVU */
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regout[2] |= REGFLAG_LO | REGFLAG_HI;
desc->cycles = 67;
return TRUE;
case 0x0c: /* SYSCALL */
case 0x0d: /* BREAK */
desc->flags |= OPFLAG_WILL_CAUSE_EXCEPTION | OPFLAG_END_SEQUENCE;
return TRUE;
case 0x0f: /* SYNC */
/* effective no-op */
return TRUE;
}
return FALSE;
} | /*-------------------------------------------------
describe_instruction_special - build a
description of a single instruction in the
'special' group
-------------------------------------------------*/ | build a
description of a single instruction in the
'special' group | [
"build",
"a",
"description",
"of",
"a",
"single",
"instruction",
"in",
"the",
"'",
"special",
"'",
"group"
] | static int describe_instruction_special(mips3_state *mips, UINT32 op, opcode_desc *desc)
{
switch (op & 63)
{
case 0x00:
case 0x02:
case 0x03:
case 0x38:
case 0x3a:
case 0x3b:
case 0x3c:
case 0x3e:
case 0x3f:
desc->regin[0] |= REGFLAG_R(RTREG);
desc->regout[0] |= REGFLAG_R(RDREG);
return TRUE;
case 0x0a:
case 0x0b:
if (mips->flavor < MIPS3_TYPE_MIPS_IV)
return FALSE;
desc->regin[0] |= REGFLAG_R(RDREG);
case 0x04:
case 0x06:
case 0x07:
case 0x14:
case 0x16:
case 0x17:
case 0x21:
case 0x23:
case 0x24:
case 0x25:
case 0x26:
case 0x27:
case 0x2a:
case 0x2b:
case 0x2d:
case 0x2f:
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regout[0] |= REGFLAG_R(RDREG);
return TRUE;
case 0x20:
case 0x22:
case 0x2c:
case 0x2e:
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regout[0] |= REGFLAG_R(RDREG);
desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x30:
case 0x31:
case 0x32:
case 0x33:
case 0x34:
case 0x36:
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x01:
if (mips->flavor < MIPS3_TYPE_MIPS_IV)
return FALSE;
desc->regin[0] |= REGFLAG_R(RSREG);
desc->regin[2] |= REGFLAG_FCC;
desc->regout[0] |= REGFLAG_R(RDREG);
return TRUE;
case 0x08:
desc->regin[0] |= REGFLAG_R(RSREG);
desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
desc->targetpc = BRANCH_TARGET_DYNAMIC;
desc->delayslots = 1;
return TRUE;
case 0x09:
desc->regin[0] |= REGFLAG_R(RSREG);
desc->regout[0] |= REGFLAG_R(RDREG);
desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
desc->targetpc = BRANCH_TARGET_DYNAMIC;
desc->delayslots = 1;
return TRUE;
case 0x10:
desc->regin[0] |= REGFLAG_HI;
desc->regout[0] |= REGFLAG_R(RDREG);
return TRUE;
case 0x11:
desc->regin[0] |= REGFLAG_R(RSREG);
desc->regout[0] |= REGFLAG_HI;
return TRUE;
case 0x12:
desc->regin[2] |= REGFLAG_LO;
desc->regout[0] |= REGFLAG_R(RDREG);
return TRUE;
case 0x13:
desc->regin[0] |= REGFLAG_R(RSREG);
desc->regout[2] |= REGFLAG_LO;
return TRUE;
case 0x18:
case 0x19:
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regout[2] |= REGFLAG_LO | REGFLAG_HI;
desc->cycles = 3;
return TRUE;
case 0x1a:
case 0x1b:
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regout[2] |= REGFLAG_LO | REGFLAG_HI;
desc->cycles = 35;
return TRUE;
case 0x1c:
case 0x1d:
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regout[2] |= REGFLAG_LO | REGFLAG_HI;
desc->cycles = 7;
return TRUE;
case 0x1e:
case 0x1f:
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regout[2] |= REGFLAG_LO | REGFLAG_HI;
desc->cycles = 67;
return TRUE;
case 0x0c:
case 0x0d:
desc->flags |= OPFLAG_WILL_CAUSE_EXCEPTION | OPFLAG_END_SEQUENCE;
return TRUE;
case 0x0f:
return TRUE;
}
return FALSE;
} | [
"static",
"int",
"describe_instruction_special",
"(",
"mips3_state",
"*",
"mips",
",",
"UINT32",
"op",
",",
"opcode_desc",
"*",
"desc",
")",
"{",
"switch",
"(",
"op",
"&",
"63",
")",
"{",
"case",
"0x00",
":",
"case",
"0x02",
":",
"case",
"0x03",
":",
"case",
"0x38",
":",
"case",
"0x3a",
":",
"case",
"0x3b",
":",
"case",
"0x3c",
":",
"case",
"0x3e",
":",
"case",
"0x3f",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"desc",
"->",
"regout",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RDREG",
")",
";",
"return",
"TRUE",
";",
"case",
"0x0a",
":",
"case",
"0x0b",
":",
"if",
"(",
"mips",
"->",
"flavor",
"<",
"MIPS3_TYPE_MIPS_IV",
")",
"return",
"FALSE",
";",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RDREG",
")",
";",
"case",
"0x04",
":",
"case",
"0x06",
":",
"case",
"0x07",
":",
"case",
"0x14",
":",
"case",
"0x16",
":",
"case",
"0x17",
":",
"case",
"0x21",
":",
"case",
"0x23",
":",
"case",
"0x24",
":",
"case",
"0x25",
":",
"case",
"0x26",
":",
"case",
"0x27",
":",
"case",
"0x2a",
":",
"case",
"0x2b",
":",
"case",
"0x2d",
":",
"case",
"0x2f",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
"|",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"desc",
"->",
"regout",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RDREG",
")",
";",
"return",
"TRUE",
";",
"case",
"0x20",
":",
"case",
"0x22",
":",
"case",
"0x2c",
":",
"case",
"0x2e",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
"|",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"desc",
"->",
"regout",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RDREG",
")",
";",
"desc",
"->",
"flags",
"|=",
"OPFLAG_CAN_CAUSE_EXCEPTION",
";",
"return",
"TRUE",
";",
"case",
"0x30",
":",
"case",
"0x31",
":",
"case",
"0x32",
":",
"case",
"0x33",
":",
"case",
"0x34",
":",
"case",
"0x36",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
"|",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"desc",
"->",
"flags",
"|=",
"OPFLAG_CAN_CAUSE_EXCEPTION",
";",
"return",
"TRUE",
";",
"case",
"0x01",
":",
"if",
"(",
"mips",
"->",
"flavor",
"<",
"MIPS3_TYPE_MIPS_IV",
")",
"return",
"FALSE",
";",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
";",
"desc",
"->",
"regin",
"[",
"2",
"]",
"|=",
"REGFLAG_FCC",
";",
"desc",
"->",
"regout",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RDREG",
")",
";",
"return",
"TRUE",
";",
"case",
"0x08",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
";",
"desc",
"->",
"flags",
"|=",
"OPFLAG_IS_UNCONDITIONAL_BRANCH",
"|",
"OPFLAG_END_SEQUENCE",
";",
"desc",
"->",
"targetpc",
"=",
"BRANCH_TARGET_DYNAMIC",
";",
"desc",
"->",
"delayslots",
"=",
"1",
";",
"return",
"TRUE",
";",
"case",
"0x09",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
";",
"desc",
"->",
"regout",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RDREG",
")",
";",
"desc",
"->",
"flags",
"|=",
"OPFLAG_IS_UNCONDITIONAL_BRANCH",
"|",
"OPFLAG_END_SEQUENCE",
";",
"desc",
"->",
"targetpc",
"=",
"BRANCH_TARGET_DYNAMIC",
";",
"desc",
"->",
"delayslots",
"=",
"1",
";",
"return",
"TRUE",
";",
"case",
"0x10",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_HI",
";",
"desc",
"->",
"regout",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RDREG",
")",
";",
"return",
"TRUE",
";",
"case",
"0x11",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
";",
"desc",
"->",
"regout",
"[",
"0",
"]",
"|=",
"REGFLAG_HI",
";",
"return",
"TRUE",
";",
"case",
"0x12",
":",
"desc",
"->",
"regin",
"[",
"2",
"]",
"|=",
"REGFLAG_LO",
";",
"desc",
"->",
"regout",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RDREG",
")",
";",
"return",
"TRUE",
";",
"case",
"0x13",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
";",
"desc",
"->",
"regout",
"[",
"2",
"]",
"|=",
"REGFLAG_LO",
";",
"return",
"TRUE",
";",
"case",
"0x18",
":",
"case",
"0x19",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
"|",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"desc",
"->",
"regout",
"[",
"2",
"]",
"|=",
"REGFLAG_LO",
"|",
"REGFLAG_HI",
";",
"desc",
"->",
"cycles",
"=",
"3",
";",
"return",
"TRUE",
";",
"case",
"0x1a",
":",
"case",
"0x1b",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
"|",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"desc",
"->",
"regout",
"[",
"2",
"]",
"|=",
"REGFLAG_LO",
"|",
"REGFLAG_HI",
";",
"desc",
"->",
"cycles",
"=",
"35",
";",
"return",
"TRUE",
";",
"case",
"0x1c",
":",
"case",
"0x1d",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
"|",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"desc",
"->",
"regout",
"[",
"2",
"]",
"|=",
"REGFLAG_LO",
"|",
"REGFLAG_HI",
";",
"desc",
"->",
"cycles",
"=",
"7",
";",
"return",
"TRUE",
";",
"case",
"0x1e",
":",
"case",
"0x1f",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
"|",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"desc",
"->",
"regout",
"[",
"2",
"]",
"|=",
"REGFLAG_LO",
"|",
"REGFLAG_HI",
";",
"desc",
"->",
"cycles",
"=",
"67",
";",
"return",
"TRUE",
";",
"case",
"0x0c",
":",
"case",
"0x0d",
":",
"desc",
"->",
"flags",
"|=",
"OPFLAG_WILL_CAUSE_EXCEPTION",
"|",
"OPFLAG_END_SEQUENCE",
";",
"return",
"TRUE",
";",
"case",
"0x0f",
":",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}"
] | describe_instruction_special - build a
description of a single instruction in the
'special' group | [
"describe_instruction_special",
"-",
"build",
"a",
"description",
"of",
"a",
"single",
"instruction",
"in",
"the",
"'",
"special",
"'",
"group"
] | [
"/* SLL */",
"/* SRL */",
"/* SRA */",
"/* DSLL */",
"/* DSRL */",
"/* DSRA */",
"/* DSLL32 */",
"/* DSRL32 */",
"/* DSRA32 */",
"/* MOVZ - MIPS IV */",
"/* MOVN - MIPS IV */",
"/* SLLV */",
"/* SRLV */",
"/* SRAV */",
"/* DSLLV */",
"/* DSRLV */",
"/* DSRAV */",
"/* ADDU */",
"/* SUBU */",
"/* AND */",
"/* OR */",
"/* XOR */",
"/* NOR */",
"/* SLT */",
"/* SLTU */",
"/* DADDU */",
"/* DSUBU */",
"/* ADD */",
"/* SUB */",
"/* DADD */",
"/* DSUB */",
"/* TGE */",
"/* TGEU */",
"/* TLT */",
"/* TLTU */",
"/* TEQ */",
"/* TNE */",
"/* MOVF - MIPS IV */",
"/* JR */",
"/* JALR */",
"/* MFHI */",
"/* MTHI */",
"/* MFLO */",
"/* MTLO */",
"/* MULT */",
"/* MULTU */",
"/* DIV */",
"/* DIVU */",
"/* DMULT */",
"/* DMULTU */",
"/* DDIV */",
"/* DDIVU */",
"/* SYSCALL */",
"/* BREAK */",
"/* SYNC */",
"/* effective no-op */"
] | [
{
"param": "mips",
"type": "mips3_state"
},
{
"param": "op",
"type": "UINT32"
},
{
"param": "desc",
"type": "opcode_desc"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mips",
"type": "mips3_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "op",
"type": "UINT32",
"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": []
} |
a4520d0b849fced1efe34e5a922e794d2ea30b67 | lofunz/mieme | Reloaded/tags/MAME4droid1.1.2&MAME4iOS 1.1Reloaded/src/emu/cpu/mips/mips3fe.c | [
"Unlicense"
] | C | describe_instruction_regimm | int | static int describe_instruction_regimm(mips3_state *mips, UINT32 op, opcode_desc *desc)
{
switch (RTREG)
{
case 0x00: /* BLTZ */
case 0x01: /* BGEZ */
case 0x02: /* BLTZL */
case 0x03: /* BGEZL */
if (RTREG == 0x01 && RSREG == 0)
desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
else
{
desc->regin[0] |= REGFLAG_R(RSREG);
desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
}
desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
desc->delayslots = 1;
desc->skipslots = (RTREG & 0x02) ? 1 : 0;
return TRUE;
case 0x08: /* TGEI */
case 0x09: /* TGEIU */
case 0x0a: /* TLTI */
case 0x0b: /* TLTIU */
case 0x0c: /* TEQI */
case 0x0e: /* TNEI */
desc->regin[0] |= REGFLAG_R(RSREG);
desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x10: /* BLTZAL */
case 0x11: /* BGEZAL */
case 0x12: /* BLTZALL */
case 0x13: /* BGEZALL */
if (RTREG == 0x11 && RSREG == 0)
desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
else
{
desc->regin[0] |= REGFLAG_R(RSREG);
desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
}
desc->regout[0] |= REGFLAG_R(31);
desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
desc->delayslots = 1;
desc->skipslots = (RTREG & 0x02) ? 1 : 0;
return TRUE;
}
return FALSE;
} | /*-------------------------------------------------
describe_instruction_regimm - build a
description of a single instruction in the
'regimm' group
-------------------------------------------------*/ | build a
description of a single instruction in the
'regimm' group | [
"build",
"a",
"description",
"of",
"a",
"single",
"instruction",
"in",
"the",
"'",
"regimm",
"'",
"group"
] | static int describe_instruction_regimm(mips3_state *mips, UINT32 op, opcode_desc *desc)
{
switch (RTREG)
{
case 0x00:
case 0x01:
case 0x02:
case 0x03:
if (RTREG == 0x01 && RSREG == 0)
desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
else
{
desc->regin[0] |= REGFLAG_R(RSREG);
desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
}
desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
desc->delayslots = 1;
desc->skipslots = (RTREG & 0x02) ? 1 : 0;
return TRUE;
case 0x08:
case 0x09:
case 0x0a:
case 0x0b:
case 0x0c:
case 0x0e:
desc->regin[0] |= REGFLAG_R(RSREG);
desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
return TRUE;
case 0x10:
case 0x11:
case 0x12:
case 0x13:
if (RTREG == 0x11 && RSREG == 0)
desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
else
{
desc->regin[0] |= REGFLAG_R(RSREG);
desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
}
desc->regout[0] |= REGFLAG_R(31);
desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
desc->delayslots = 1;
desc->skipslots = (RTREG & 0x02) ? 1 : 0;
return TRUE;
}
return FALSE;
} | [
"static",
"int",
"describe_instruction_regimm",
"(",
"mips3_state",
"*",
"mips",
",",
"UINT32",
"op",
",",
"opcode_desc",
"*",
"desc",
")",
"{",
"switch",
"(",
"RTREG",
")",
"{",
"case",
"0x00",
":",
"case",
"0x01",
":",
"case",
"0x02",
":",
"case",
"0x03",
":",
"if",
"(",
"RTREG",
"==",
"0x01",
"&&",
"RSREG",
"==",
"0",
")",
"desc",
"->",
"flags",
"|=",
"OPFLAG_IS_UNCONDITIONAL_BRANCH",
"|",
"OPFLAG_END_SEQUENCE",
";",
"else",
"{",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
";",
"desc",
"->",
"flags",
"|=",
"OPFLAG_IS_CONDITIONAL_BRANCH",
";",
"}",
"desc",
"->",
"targetpc",
"=",
"desc",
"->",
"pc",
"+",
"4",
"+",
"(",
"SIMMVAL",
"<<",
"2",
")",
";",
"desc",
"->",
"delayslots",
"=",
"1",
";",
"desc",
"->",
"skipslots",
"=",
"(",
"RTREG",
"&",
"0x02",
")",
"?",
"1",
":",
"0",
";",
"return",
"TRUE",
";",
"case",
"0x08",
":",
"case",
"0x09",
":",
"case",
"0x0a",
":",
"case",
"0x0b",
":",
"case",
"0x0c",
":",
"case",
"0x0e",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
";",
"desc",
"->",
"flags",
"|=",
"OPFLAG_CAN_CAUSE_EXCEPTION",
";",
"return",
"TRUE",
";",
"case",
"0x10",
":",
"case",
"0x11",
":",
"case",
"0x12",
":",
"case",
"0x13",
":",
"if",
"(",
"RTREG",
"==",
"0x11",
"&&",
"RSREG",
"==",
"0",
")",
"desc",
"->",
"flags",
"|=",
"OPFLAG_IS_UNCONDITIONAL_BRANCH",
"|",
"OPFLAG_END_SEQUENCE",
";",
"else",
"{",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
";",
"desc",
"->",
"flags",
"|=",
"OPFLAG_IS_CONDITIONAL_BRANCH",
";",
"}",
"desc",
"->",
"regout",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"31",
")",
";",
"desc",
"->",
"targetpc",
"=",
"desc",
"->",
"pc",
"+",
"4",
"+",
"(",
"SIMMVAL",
"<<",
"2",
")",
";",
"desc",
"->",
"delayslots",
"=",
"1",
";",
"desc",
"->",
"skipslots",
"=",
"(",
"RTREG",
"&",
"0x02",
")",
"?",
"1",
":",
"0",
";",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}"
] | describe_instruction_regimm - build a
description of a single instruction in the
'regimm' group | [
"describe_instruction_regimm",
"-",
"build",
"a",
"description",
"of",
"a",
"single",
"instruction",
"in",
"the",
"'",
"regimm",
"'",
"group"
] | [
"/* BLTZ */",
"/* BGEZ */",
"/* BLTZL */",
"/* BGEZL */",
"/* TGEI */",
"/* TGEIU */",
"/* TLTI */",
"/* TLTIU */",
"/* TEQI */",
"/* TNEI */",
"/* BLTZAL */",
"/* BGEZAL */",
"/* BLTZALL */",
"/* BGEZALL */"
] | [
{
"param": "mips",
"type": "mips3_state"
},
{
"param": "op",
"type": "UINT32"
},
{
"param": "desc",
"type": "opcode_desc"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mips",
"type": "mips3_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "op",
"type": "UINT32",
"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": []
} |
a4520d0b849fced1efe34e5a922e794d2ea30b67 | lofunz/mieme | Reloaded/tags/MAME4droid1.1.2&MAME4iOS 1.1Reloaded/src/emu/cpu/mips/mips3fe.c | [
"Unlicense"
] | C | describe_instruction_idt | int | static int describe_instruction_idt(mips3_state *mips, UINT32 op, opcode_desc *desc)
{
/* only on the R4650 */
if (mips->flavor != MIPS3_TYPE_R4650)
return FALSE;
switch (op & 0x1f)
{
case 0: /* MAD */
case 1: /* MADU */
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regin[2] |= REGFLAG_LO | REGFLAG_HI;
desc->regout[2] |= REGFLAG_LO | REGFLAG_HI;
return TRUE;
case 2: /* MUL */
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regout[0] |= REGFLAG_R(RDREG);
desc->cycles = 3;
return TRUE;
}
return FALSE;
} | /*-------------------------------------------------
describe_instruction_idt - build a
description of a single instruction in the
IDT-specific group
-------------------------------------------------*/ | build a
description of a single instruction in the
IDT-specific group | [
"build",
"a",
"description",
"of",
"a",
"single",
"instruction",
"in",
"the",
"IDT",
"-",
"specific",
"group"
] | static int describe_instruction_idt(mips3_state *mips, UINT32 op, opcode_desc *desc)
{
if (mips->flavor != MIPS3_TYPE_R4650)
return FALSE;
switch (op & 0x1f)
{
case 0:
case 1:
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regin[2] |= REGFLAG_LO | REGFLAG_HI;
desc->regout[2] |= REGFLAG_LO | REGFLAG_HI;
return TRUE;
case 2:
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regout[0] |= REGFLAG_R(RDREG);
desc->cycles = 3;
return TRUE;
}
return FALSE;
} | [
"static",
"int",
"describe_instruction_idt",
"(",
"mips3_state",
"*",
"mips",
",",
"UINT32",
"op",
",",
"opcode_desc",
"*",
"desc",
")",
"{",
"if",
"(",
"mips",
"->",
"flavor",
"!=",
"MIPS3_TYPE_R4650",
")",
"return",
"FALSE",
";",
"switch",
"(",
"op",
"&",
"0x1f",
")",
"{",
"case",
"0",
":",
"case",
"1",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
"|",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"desc",
"->",
"regin",
"[",
"2",
"]",
"|=",
"REGFLAG_LO",
"|",
"REGFLAG_HI",
";",
"desc",
"->",
"regout",
"[",
"2",
"]",
"|=",
"REGFLAG_LO",
"|",
"REGFLAG_HI",
";",
"return",
"TRUE",
";",
"case",
"2",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
"|",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"desc",
"->",
"regout",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RDREG",
")",
";",
"desc",
"->",
"cycles",
"=",
"3",
";",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}"
] | describe_instruction_idt - build a
description of a single instruction in the
IDT-specific group | [
"describe_instruction_idt",
"-",
"build",
"a",
"description",
"of",
"a",
"single",
"instruction",
"in",
"the",
"IDT",
"-",
"specific",
"group"
] | [
"/* only on the R4650 */",
"/* MAD */",
"/* MADU */",
"/* MUL */"
] | [
{
"param": "mips",
"type": "mips3_state"
},
{
"param": "op",
"type": "UINT32"
},
{
"param": "desc",
"type": "opcode_desc"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mips",
"type": "mips3_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "op",
"type": "UINT32",
"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": []
} |
a4520d0b849fced1efe34e5a922e794d2ea30b67 | lofunz/mieme | Reloaded/tags/MAME4droid1.1.2&MAME4iOS 1.1Reloaded/src/emu/cpu/mips/mips3fe.c | [
"Unlicense"
] | C | describe_instruction_cop0 | int | static int describe_instruction_cop0(mips3_state *mips, UINT32 op, opcode_desc *desc)
{
/* any COP0 instruction can potentially cause an exception */
desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
switch (RSREG)
{
case 0x00: /* MFCz */
case 0x01: /* DMFCz */
if (RDREG == COP0_Count)
desc->cycles += MIPS3_COUNT_READ_CYCLES;
if (RDREG == COP0_Cause)
desc->cycles += MIPS3_CAUSE_READ_CYCLES;
desc->regout[0] |= REGFLAG_R(RTREG);
return TRUE;
case 0x02: /* CFCz */
desc->regout[0] |= REGFLAG_R(RTREG);
return TRUE;
case 0x04: /* MTCz */
case 0x05: /* DMTCz */
case 0x06: /* CTCz */
desc->regin[0] |= REGFLAG_R(RTREG);
if (RSREG == 0x04 || RSREG == 0x05)
{
if (RDREG == COP0_Cause)
desc->flags |= OPFLAG_CAN_TRIGGER_SW_INT;
if (RDREG == COP0_Status)
desc->flags |= OPFLAG_CAN_EXPOSE_EXTERNAL_INT | OPFLAG_CAN_CHANGE_MODES | OPFLAG_END_SEQUENCE;
}
return TRUE;
case 0x08: /* BC */
switch (RTREG)
{
case 0x00: /* BCzF */
case 0x01: /* BCzT */
desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
desc->delayslots = 1;
return TRUE;
}
return FALSE;
case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17:
case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f: /* COP */
switch (op & 0x01ffffff)
{
case 0x01: /* TLBR */
case 0x08: /* TLBP */
case 0x20: /* WAIT */
return TRUE;
case 0x02: /* TLBWI */
case 0x06: /* TLBWR */
desc->flags |= OPFLAG_MODIFIES_TRANSLATION;
return TRUE;
case 0x18: /* ERET */
desc->flags |= OPFLAG_CAN_CHANGE_MODES | OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
return TRUE;
}
return FALSE;
}
return FALSE;
} | /*-------------------------------------------------
describe_instruction_cop0 - build a
description of a single instruction in the
COP0 group
-------------------------------------------------*/ | build a
description of a single instruction in the
COP0 group | [
"build",
"a",
"description",
"of",
"a",
"single",
"instruction",
"in",
"the",
"COP0",
"group"
] | static int describe_instruction_cop0(mips3_state *mips, UINT32 op, opcode_desc *desc)
{
desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
switch (RSREG)
{
case 0x00:
case 0x01:
if (RDREG == COP0_Count)
desc->cycles += MIPS3_COUNT_READ_CYCLES;
if (RDREG == COP0_Cause)
desc->cycles += MIPS3_CAUSE_READ_CYCLES;
desc->regout[0] |= REGFLAG_R(RTREG);
return TRUE;
case 0x02:
desc->regout[0] |= REGFLAG_R(RTREG);
return TRUE;
case 0x04:
case 0x05:
case 0x06:
desc->regin[0] |= REGFLAG_R(RTREG);
if (RSREG == 0x04 || RSREG == 0x05)
{
if (RDREG == COP0_Cause)
desc->flags |= OPFLAG_CAN_TRIGGER_SW_INT;
if (RDREG == COP0_Status)
desc->flags |= OPFLAG_CAN_EXPOSE_EXTERNAL_INT | OPFLAG_CAN_CHANGE_MODES | OPFLAG_END_SEQUENCE;
}
return TRUE;
case 0x08:
switch (RTREG)
{
case 0x00:
case 0x01:
desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
desc->delayslots = 1;
return TRUE;
}
return FALSE;
case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17:
case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f:
switch (op & 0x01ffffff)
{
case 0x01:
case 0x08:
case 0x20:
return TRUE;
case 0x02:
case 0x06:
desc->flags |= OPFLAG_MODIFIES_TRANSLATION;
return TRUE;
case 0x18:
desc->flags |= OPFLAG_CAN_CHANGE_MODES | OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
return TRUE;
}
return FALSE;
}
return FALSE;
} | [
"static",
"int",
"describe_instruction_cop0",
"(",
"mips3_state",
"*",
"mips",
",",
"UINT32",
"op",
",",
"opcode_desc",
"*",
"desc",
")",
"{",
"desc",
"->",
"flags",
"|=",
"OPFLAG_CAN_CAUSE_EXCEPTION",
";",
"switch",
"(",
"RSREG",
")",
"{",
"case",
"0x00",
":",
"case",
"0x01",
":",
"if",
"(",
"RDREG",
"==",
"COP0_Count",
")",
"desc",
"->",
"cycles",
"+=",
"MIPS3_COUNT_READ_CYCLES",
";",
"if",
"(",
"RDREG",
"==",
"COP0_Cause",
")",
"desc",
"->",
"cycles",
"+=",
"MIPS3_CAUSE_READ_CYCLES",
";",
"desc",
"->",
"regout",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"return",
"TRUE",
";",
"case",
"0x02",
":",
"desc",
"->",
"regout",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"return",
"TRUE",
";",
"case",
"0x04",
":",
"case",
"0x05",
":",
"case",
"0x06",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"if",
"(",
"RSREG",
"==",
"0x04",
"||",
"RSREG",
"==",
"0x05",
")",
"{",
"if",
"(",
"RDREG",
"==",
"COP0_Cause",
")",
"desc",
"->",
"flags",
"|=",
"OPFLAG_CAN_TRIGGER_SW_INT",
";",
"if",
"(",
"RDREG",
"==",
"COP0_Status",
")",
"desc",
"->",
"flags",
"|=",
"OPFLAG_CAN_EXPOSE_EXTERNAL_INT",
"|",
"OPFLAG_CAN_CHANGE_MODES",
"|",
"OPFLAG_END_SEQUENCE",
";",
"}",
"return",
"TRUE",
";",
"case",
"0x08",
":",
"switch",
"(",
"RTREG",
")",
"{",
"case",
"0x00",
":",
"case",
"0x01",
":",
"desc",
"->",
"flags",
"|=",
"OPFLAG_IS_CONDITIONAL_BRANCH",
";",
"desc",
"->",
"targetpc",
"=",
"desc",
"->",
"pc",
"+",
"4",
"+",
"(",
"SIMMVAL",
"<<",
"2",
")",
";",
"desc",
"->",
"delayslots",
"=",
"1",
";",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"case",
"0x10",
":",
"case",
"0x11",
":",
"case",
"0x12",
":",
"case",
"0x13",
":",
"case",
"0x14",
":",
"case",
"0x15",
":",
"case",
"0x16",
":",
"case",
"0x17",
":",
"case",
"0x18",
":",
"case",
"0x19",
":",
"case",
"0x1a",
":",
"case",
"0x1b",
":",
"case",
"0x1c",
":",
"case",
"0x1d",
":",
"case",
"0x1e",
":",
"case",
"0x1f",
":",
"switch",
"(",
"op",
"&",
"0x01ffffff",
")",
"{",
"case",
"0x01",
":",
"case",
"0x08",
":",
"case",
"0x20",
":",
"return",
"TRUE",
";",
"case",
"0x02",
":",
"case",
"0x06",
":",
"desc",
"->",
"flags",
"|=",
"OPFLAG_MODIFIES_TRANSLATION",
";",
"return",
"TRUE",
";",
"case",
"0x18",
":",
"desc",
"->",
"flags",
"|=",
"OPFLAG_CAN_CHANGE_MODES",
"|",
"OPFLAG_IS_UNCONDITIONAL_BRANCH",
"|",
"OPFLAG_END_SEQUENCE",
";",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}",
"return",
"FALSE",
";",
"}"
] | describe_instruction_cop0 - build a
description of a single instruction in the
COP0 group | [
"describe_instruction_cop0",
"-",
"build",
"a",
"description",
"of",
"a",
"single",
"instruction",
"in",
"the",
"COP0",
"group"
] | [
"/* any COP0 instruction can potentially cause an exception */",
"/* MFCz */",
"/* DMFCz */",
"/* CFCz */",
"/* MTCz */",
"/* DMTCz */",
"/* CTCz */",
"/* BC */",
"/* BCzF */",
"/* BCzT */",
"/* COP */",
"/* TLBR */",
"/* TLBP */",
"/* WAIT */",
"/* TLBWI */",
"/* TLBWR */",
"/* ERET */"
] | [
{
"param": "mips",
"type": "mips3_state"
},
{
"param": "op",
"type": "UINT32"
},
{
"param": "desc",
"type": "opcode_desc"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mips",
"type": "mips3_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "op",
"type": "UINT32",
"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": []
} |
a4520d0b849fced1efe34e5a922e794d2ea30b67 | lofunz/mieme | Reloaded/tags/MAME4droid1.1.2&MAME4iOS 1.1Reloaded/src/emu/cpu/mips/mips3fe.c | [
"Unlicense"
] | C | describe_instruction_cop1 | int | static int describe_instruction_cop1(mips3_state *mips, UINT32 op, opcode_desc *desc)
{
/* any COP1 instruction can potentially cause an exception */
// desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
switch (RSREG)
{
case 0x00: /* MFCz */
case 0x01: /* DMFCz */
desc->regin[1] |= REGFLAG_CPR1(RDREG);
desc->regout[0] |= REGFLAG_R(RTREG);
return TRUE;
case 0x02: /* CFCz */
desc->regout[0] |= REGFLAG_R(RTREG);
return TRUE;
case 0x04: /* MTCz */
case 0x05: /* DMTCz */
desc->regin[0] |= REGFLAG_R(RTREG);
desc->regout[1] |= REGFLAG_CPR1(RDREG);
return TRUE;
case 0x06: /* CTCz */
desc->regin[0] |= REGFLAG_R(RTREG);
return TRUE;
case 0x08: /* BC */
switch (RTREG & 3)
{
case 0x00: /* BCzF */
case 0x01: /* BCzT */
case 0x02: /* BCzFL */
case 0x03: /* BCzTL */
desc->regin[2] |= REGFLAG_FCC;
desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
desc->delayslots = 1;
desc->skipslots = (RTREG & 0x02) ? 1 : 0;
return TRUE;
}
return FALSE;
case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17:
case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f: /* COP */
switch (op & 0x3f)
{
case 0x12: /* MOVZ - MIPS IV */
case 0x13: /* MOVN - MIPS IV */
if (mips->flavor < MIPS3_TYPE_MIPS_IV)
return FALSE;
case 0x00: /* ADD */
case 0x01: /* SUB */
case 0x02: /* MUL */
case 0x03: /* DIV */
desc->regin[1] |= REGFLAG_CPR1(FSREG) | REGFLAG_CPR1(FTREG);
desc->regout[1] |= REGFLAG_CPR1(FDREG);
return TRUE;
case 0x15: /* RECIP - MIPS IV */
case 0x16: /* RSQRT - MIPS IV */
if (mips->flavor < MIPS3_TYPE_MIPS_IV)
return FALSE;
case 0x04: /* SQRT */
case 0x05: /* ABS */
case 0x06: /* MOV */
case 0x07: /* NEG */
case 0x08: /* ROUND.L */
case 0x09: /* TRUNC.L */
case 0x0a: /* CEIL.L */
case 0x0b: /* FLOOR.L */
case 0x0c: /* ROUND.W */
case 0x0d: /* TRUNC.W */
case 0x0e: /* CEIL.W */
case 0x0f: /* FLOOR.W */
case 0x20: /* CVT.S */
case 0x21: /* CVT.D */
case 0x24: /* CVT.W */
case 0x25: /* CVT.L */
desc->regin[1] |= REGFLAG_CPR1(FSREG);
desc->regout[1] |= REGFLAG_CPR1(FDREG);
return TRUE;
case 0x11: /* MOVT/F - MIPS IV */
if (mips->flavor < MIPS3_TYPE_MIPS_IV)
return FALSE;
desc->regin[1] |= REGFLAG_CPR1(FSREG);
desc->regin[2] |= REGFLAG_FCC;
desc->regout[1] |= REGFLAG_CPR1(FDREG);
return TRUE;
case 0x30: case 0x38: /* C.F */
case 0x31: case 0x39: /* C.UN */
desc->regout[2] |= REGFLAG_FCC;
return TRUE;
case 0x32: case 0x3a: /* C.EQ */
case 0x33: case 0x3b: /* C.UEQ */
case 0x34: case 0x3c: /* C.OLT */
case 0x35: case 0x3d: /* C.ULT */
case 0x36: case 0x3e: /* C.OLE */
case 0x37: case 0x3f: /* C.ULE */
desc->regin[1] |= REGFLAG_CPR1(FSREG) | REGFLAG_CPR1(FTREG);
desc->regout[2] |= REGFLAG_FCC;
return TRUE;
}
return FALSE;
}
return FALSE;
} | /*-------------------------------------------------
describe_instruction_cop1 - build a
description of a single instruction in the
COP1 group
-------------------------------------------------*/ | build a
description of a single instruction in the
COP1 group | [
"build",
"a",
"description",
"of",
"a",
"single",
"instruction",
"in",
"the",
"COP1",
"group"
] | static int describe_instruction_cop1(mips3_state *mips, UINT32 op, opcode_desc *desc)
{
switch (RSREG)
{
case 0x00:
case 0x01:
desc->regin[1] |= REGFLAG_CPR1(RDREG);
desc->regout[0] |= REGFLAG_R(RTREG);
return TRUE;
case 0x02:
desc->regout[0] |= REGFLAG_R(RTREG);
return TRUE;
case 0x04:
case 0x05:
desc->regin[0] |= REGFLAG_R(RTREG);
desc->regout[1] |= REGFLAG_CPR1(RDREG);
return TRUE;
case 0x06:
desc->regin[0] |= REGFLAG_R(RTREG);
return TRUE;
case 0x08:
switch (RTREG & 3)
{
case 0x00:
case 0x01:
case 0x02:
case 0x03:
desc->regin[2] |= REGFLAG_FCC;
desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
desc->delayslots = 1;
desc->skipslots = (RTREG & 0x02) ? 1 : 0;
return TRUE;
}
return FALSE;
case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17:
case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f:
switch (op & 0x3f)
{
case 0x12:
case 0x13:
if (mips->flavor < MIPS3_TYPE_MIPS_IV)
return FALSE;
case 0x00:
case 0x01:
case 0x02:
case 0x03:
desc->regin[1] |= REGFLAG_CPR1(FSREG) | REGFLAG_CPR1(FTREG);
desc->regout[1] |= REGFLAG_CPR1(FDREG);
return TRUE;
case 0x15:
case 0x16:
if (mips->flavor < MIPS3_TYPE_MIPS_IV)
return FALSE;
case 0x04:
case 0x05:
case 0x06:
case 0x07:
case 0x08:
case 0x09:
case 0x0a:
case 0x0b:
case 0x0c:
case 0x0d:
case 0x0e:
case 0x0f:
case 0x20:
case 0x21:
case 0x24:
case 0x25:
desc->regin[1] |= REGFLAG_CPR1(FSREG);
desc->regout[1] |= REGFLAG_CPR1(FDREG);
return TRUE;
case 0x11:
if (mips->flavor < MIPS3_TYPE_MIPS_IV)
return FALSE;
desc->regin[1] |= REGFLAG_CPR1(FSREG);
desc->regin[2] |= REGFLAG_FCC;
desc->regout[1] |= REGFLAG_CPR1(FDREG);
return TRUE;
case 0x30: case 0x38:
case 0x31: case 0x39:
desc->regout[2] |= REGFLAG_FCC;
return TRUE;
case 0x32: case 0x3a:
case 0x33: case 0x3b:
case 0x34: case 0x3c:
case 0x35: case 0x3d:
case 0x36: case 0x3e:
case 0x37: case 0x3f:
desc->regin[1] |= REGFLAG_CPR1(FSREG) | REGFLAG_CPR1(FTREG);
desc->regout[2] |= REGFLAG_FCC;
return TRUE;
}
return FALSE;
}
return FALSE;
} | [
"static",
"int",
"describe_instruction_cop1",
"(",
"mips3_state",
"*",
"mips",
",",
"UINT32",
"op",
",",
"opcode_desc",
"*",
"desc",
")",
"{",
"switch",
"(",
"RSREG",
")",
"{",
"case",
"0x00",
":",
"case",
"0x01",
":",
"desc",
"->",
"regin",
"[",
"1",
"]",
"|=",
"REGFLAG_CPR1",
"(",
"RDREG",
")",
";",
"desc",
"->",
"regout",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"return",
"TRUE",
";",
"case",
"0x02",
":",
"desc",
"->",
"regout",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"return",
"TRUE",
";",
"case",
"0x04",
":",
"case",
"0x05",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"desc",
"->",
"regout",
"[",
"1",
"]",
"|=",
"REGFLAG_CPR1",
"(",
"RDREG",
")",
";",
"return",
"TRUE",
";",
"case",
"0x06",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"return",
"TRUE",
";",
"case",
"0x08",
":",
"switch",
"(",
"RTREG",
"&",
"3",
")",
"{",
"case",
"0x00",
":",
"case",
"0x01",
":",
"case",
"0x02",
":",
"case",
"0x03",
":",
"desc",
"->",
"regin",
"[",
"2",
"]",
"|=",
"REGFLAG_FCC",
";",
"desc",
"->",
"flags",
"|=",
"OPFLAG_IS_CONDITIONAL_BRANCH",
";",
"desc",
"->",
"targetpc",
"=",
"desc",
"->",
"pc",
"+",
"4",
"+",
"(",
"SIMMVAL",
"<<",
"2",
")",
";",
"desc",
"->",
"delayslots",
"=",
"1",
";",
"desc",
"->",
"skipslots",
"=",
"(",
"RTREG",
"&",
"0x02",
")",
"?",
"1",
":",
"0",
";",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"case",
"0x10",
":",
"case",
"0x11",
":",
"case",
"0x12",
":",
"case",
"0x13",
":",
"case",
"0x14",
":",
"case",
"0x15",
":",
"case",
"0x16",
":",
"case",
"0x17",
":",
"case",
"0x18",
":",
"case",
"0x19",
":",
"case",
"0x1a",
":",
"case",
"0x1b",
":",
"case",
"0x1c",
":",
"case",
"0x1d",
":",
"case",
"0x1e",
":",
"case",
"0x1f",
":",
"switch",
"(",
"op",
"&",
"0x3f",
")",
"{",
"case",
"0x12",
":",
"case",
"0x13",
":",
"if",
"(",
"mips",
"->",
"flavor",
"<",
"MIPS3_TYPE_MIPS_IV",
")",
"return",
"FALSE",
";",
"case",
"0x00",
":",
"case",
"0x01",
":",
"case",
"0x02",
":",
"case",
"0x03",
":",
"desc",
"->",
"regin",
"[",
"1",
"]",
"|=",
"REGFLAG_CPR1",
"(",
"FSREG",
")",
"|",
"REGFLAG_CPR1",
"(",
"FTREG",
")",
";",
"desc",
"->",
"regout",
"[",
"1",
"]",
"|=",
"REGFLAG_CPR1",
"(",
"FDREG",
")",
";",
"return",
"TRUE",
";",
"case",
"0x15",
":",
"case",
"0x16",
":",
"if",
"(",
"mips",
"->",
"flavor",
"<",
"MIPS3_TYPE_MIPS_IV",
")",
"return",
"FALSE",
";",
"case",
"0x04",
":",
"case",
"0x05",
":",
"case",
"0x06",
":",
"case",
"0x07",
":",
"case",
"0x08",
":",
"case",
"0x09",
":",
"case",
"0x0a",
":",
"case",
"0x0b",
":",
"case",
"0x0c",
":",
"case",
"0x0d",
":",
"case",
"0x0e",
":",
"case",
"0x0f",
":",
"case",
"0x20",
":",
"case",
"0x21",
":",
"case",
"0x24",
":",
"case",
"0x25",
":",
"desc",
"->",
"regin",
"[",
"1",
"]",
"|=",
"REGFLAG_CPR1",
"(",
"FSREG",
")",
";",
"desc",
"->",
"regout",
"[",
"1",
"]",
"|=",
"REGFLAG_CPR1",
"(",
"FDREG",
")",
";",
"return",
"TRUE",
";",
"case",
"0x11",
":",
"if",
"(",
"mips",
"->",
"flavor",
"<",
"MIPS3_TYPE_MIPS_IV",
")",
"return",
"FALSE",
";",
"desc",
"->",
"regin",
"[",
"1",
"]",
"|=",
"REGFLAG_CPR1",
"(",
"FSREG",
")",
";",
"desc",
"->",
"regin",
"[",
"2",
"]",
"|=",
"REGFLAG_FCC",
";",
"desc",
"->",
"regout",
"[",
"1",
"]",
"|=",
"REGFLAG_CPR1",
"(",
"FDREG",
")",
";",
"return",
"TRUE",
";",
"case",
"0x30",
":",
"case",
"0x38",
":",
"case",
"0x31",
":",
"case",
"0x39",
":",
"desc",
"->",
"regout",
"[",
"2",
"]",
"|=",
"REGFLAG_FCC",
";",
"return",
"TRUE",
";",
"case",
"0x32",
":",
"case",
"0x3a",
":",
"case",
"0x33",
":",
"case",
"0x3b",
":",
"case",
"0x34",
":",
"case",
"0x3c",
":",
"case",
"0x35",
":",
"case",
"0x3d",
":",
"case",
"0x36",
":",
"case",
"0x3e",
":",
"case",
"0x37",
":",
"case",
"0x3f",
":",
"desc",
"->",
"regin",
"[",
"1",
"]",
"|=",
"REGFLAG_CPR1",
"(",
"FSREG",
")",
"|",
"REGFLAG_CPR1",
"(",
"FTREG",
")",
";",
"desc",
"->",
"regout",
"[",
"2",
"]",
"|=",
"REGFLAG_FCC",
";",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}",
"return",
"FALSE",
";",
"}"
] | describe_instruction_cop1 - build a
description of a single instruction in the
COP1 group | [
"describe_instruction_cop1",
"-",
"build",
"a",
"description",
"of",
"a",
"single",
"instruction",
"in",
"the",
"COP1",
"group"
] | [
"/* any COP1 instruction can potentially cause an exception */",
"// desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;\r",
"/* MFCz */",
"/* DMFCz */",
"/* CFCz */",
"/* MTCz */",
"/* DMTCz */",
"/* CTCz */",
"/* BC */",
"/* BCzF */",
"/* BCzT */",
"/* BCzFL */",
"/* BCzTL */",
"/* COP */",
"/* MOVZ - MIPS IV */",
"/* MOVN - MIPS IV */",
"/* ADD */",
"/* SUB */",
"/* MUL */",
"/* DIV */",
"/* RECIP - MIPS IV */",
"/* RSQRT - MIPS IV */",
"/* SQRT */",
"/* ABS */",
"/* MOV */",
"/* NEG */",
"/* ROUND.L */",
"/* TRUNC.L */",
"/* CEIL.L */",
"/* FLOOR.L */",
"/* ROUND.W */",
"/* TRUNC.W */",
"/* CEIL.W */",
"/* FLOOR.W */",
"/* CVT.S */",
"/* CVT.D */",
"/* CVT.W */",
"/* CVT.L */",
"/* MOVT/F - MIPS IV */",
"/* C.F */",
"/* C.UN */",
"/* C.EQ */",
"/* C.UEQ */",
"/* C.OLT */",
"/* C.ULT */",
"/* C.OLE */",
"/* C.ULE */"
] | [
{
"param": "mips",
"type": "mips3_state"
},
{
"param": "op",
"type": "UINT32"
},
{
"param": "desc",
"type": "opcode_desc"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mips",
"type": "mips3_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "op",
"type": "UINT32",
"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": []
} |
a4520d0b849fced1efe34e5a922e794d2ea30b67 | lofunz/mieme | Reloaded/tags/MAME4droid1.1.2&MAME4iOS 1.1Reloaded/src/emu/cpu/mips/mips3fe.c | [
"Unlicense"
] | C | describe_instruction_cop1x | int | static int describe_instruction_cop1x(mips3_state *mips, UINT32 op, opcode_desc *desc)
{
/* any COP1 instruction can potentially cause an exception */
// desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
switch (op & 0x3f)
{
case 0x00: /* LWXC1 */
case 0x01: /* LDXC1 */
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regout[1] |= REGFLAG_CPR1(FDREG);
desc->flags |= OPFLAG_READS_MEMORY;
return TRUE;
case 0x08: /* SWXC1 */
case 0x09: /* SDXC1 */
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regin[1] |= REGFLAG_CPR1(FDREG);
desc->flags |= OPFLAG_WRITES_MEMORY;
return TRUE;
case 0x0f: /* PREFX */
/* effective no-op */
return TRUE;
case 0x20: case 0x21: /* MADD */
case 0x28: case 0x29: /* MSUB */
case 0x30: case 0x31: /* NMADD */
case 0x38: case 0x39: /* NMSUB */
desc->regin[1] |= REGFLAG_CPR1(FSREG) | REGFLAG_CPR1(FTREG) | REGFLAG_CPR1(FRREG);
desc->regout[1] |= REGFLAG_CPR1(FDREG);
return TRUE;
}
return FALSE;
} | /*-------------------------------------------------
describe_instruction_cop1x - build a
description of a single instruction in the
COP1X group
-------------------------------------------------*/ | build a
description of a single instruction in the
COP1X group | [
"build",
"a",
"description",
"of",
"a",
"single",
"instruction",
"in",
"the",
"COP1X",
"group"
] | static int describe_instruction_cop1x(mips3_state *mips, UINT32 op, opcode_desc *desc)
{
switch (op & 0x3f)
{
case 0x00:
case 0x01:
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regout[1] |= REGFLAG_CPR1(FDREG);
desc->flags |= OPFLAG_READS_MEMORY;
return TRUE;
case 0x08:
case 0x09:
desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
desc->regin[1] |= REGFLAG_CPR1(FDREG);
desc->flags |= OPFLAG_WRITES_MEMORY;
return TRUE;
case 0x0f:
return TRUE;
case 0x20: case 0x21:
case 0x28: case 0x29:
case 0x30: case 0x31:
case 0x38: case 0x39:
desc->regin[1] |= REGFLAG_CPR1(FSREG) | REGFLAG_CPR1(FTREG) | REGFLAG_CPR1(FRREG);
desc->regout[1] |= REGFLAG_CPR1(FDREG);
return TRUE;
}
return FALSE;
} | [
"static",
"int",
"describe_instruction_cop1x",
"(",
"mips3_state",
"*",
"mips",
",",
"UINT32",
"op",
",",
"opcode_desc",
"*",
"desc",
")",
"{",
"switch",
"(",
"op",
"&",
"0x3f",
")",
"{",
"case",
"0x00",
":",
"case",
"0x01",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
"|",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"desc",
"->",
"regout",
"[",
"1",
"]",
"|=",
"REGFLAG_CPR1",
"(",
"FDREG",
")",
";",
"desc",
"->",
"flags",
"|=",
"OPFLAG_READS_MEMORY",
";",
"return",
"TRUE",
";",
"case",
"0x08",
":",
"case",
"0x09",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RSREG",
")",
"|",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"desc",
"->",
"regin",
"[",
"1",
"]",
"|=",
"REGFLAG_CPR1",
"(",
"FDREG",
")",
";",
"desc",
"->",
"flags",
"|=",
"OPFLAG_WRITES_MEMORY",
";",
"return",
"TRUE",
";",
"case",
"0x0f",
":",
"return",
"TRUE",
";",
"case",
"0x20",
":",
"case",
"0x21",
":",
"case",
"0x28",
":",
"case",
"0x29",
":",
"case",
"0x30",
":",
"case",
"0x31",
":",
"case",
"0x38",
":",
"case",
"0x39",
":",
"desc",
"->",
"regin",
"[",
"1",
"]",
"|=",
"REGFLAG_CPR1",
"(",
"FSREG",
")",
"|",
"REGFLAG_CPR1",
"(",
"FTREG",
")",
"|",
"REGFLAG_CPR1",
"(",
"FRREG",
")",
";",
"desc",
"->",
"regout",
"[",
"1",
"]",
"|=",
"REGFLAG_CPR1",
"(",
"FDREG",
")",
";",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}"
] | describe_instruction_cop1x - build a
description of a single instruction in the
COP1X group | [
"describe_instruction_cop1x",
"-",
"build",
"a",
"description",
"of",
"a",
"single",
"instruction",
"in",
"the",
"COP1X",
"group"
] | [
"/* any COP1 instruction can potentially cause an exception */",
"// desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;\r",
"/* LWXC1 */",
"/* LDXC1 */",
"/* SWXC1 */",
"/* SDXC1 */",
"/* PREFX */",
"/* effective no-op */",
"/* MADD */",
"/* MSUB */",
"/* NMADD */",
"/* NMSUB */"
] | [
{
"param": "mips",
"type": "mips3_state"
},
{
"param": "op",
"type": "UINT32"
},
{
"param": "desc",
"type": "opcode_desc"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mips",
"type": "mips3_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "op",
"type": "UINT32",
"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": []
} |
a4520d0b849fced1efe34e5a922e794d2ea30b67 | lofunz/mieme | Reloaded/tags/MAME4droid1.1.2&MAME4iOS 1.1Reloaded/src/emu/cpu/mips/mips3fe.c | [
"Unlicense"
] | C | describe_instruction_cop2 | int | static int describe_instruction_cop2(mips3_state *mips, UINT32 op, opcode_desc *desc)
{
/* any COP2 instruction can potentially cause an exception */
desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
switch (RSREG)
{
case 0x00: /* MFCz */
case 0x01: /* DMFCz */
case 0x02: /* CFCz */
desc->regout[0] |= REGFLAG_R(RTREG);
return TRUE;
case 0x04: /* MTCz */
case 0x05: /* DMTCz */
case 0x06: /* CTCz */
desc->regin[0] |= REGFLAG_R(RTREG);
return TRUE;
case 0x08: /* BC */
switch (RTREG)
{
case 0x00: /* BCzF */
case 0x01: /* BCzT */
desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
desc->delayslots = 1;
return TRUE;
}
return FALSE;
}
return FALSE;
} | /*-------------------------------------------------
describe_instruction_cop2 - build a
description of a single instruction in the
COP2 group
-------------------------------------------------*/ | build a
description of a single instruction in the
COP2 group | [
"build",
"a",
"description",
"of",
"a",
"single",
"instruction",
"in",
"the",
"COP2",
"group"
] | static int describe_instruction_cop2(mips3_state *mips, UINT32 op, opcode_desc *desc)
{
desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
switch (RSREG)
{
case 0x00:
case 0x01:
case 0x02:
desc->regout[0] |= REGFLAG_R(RTREG);
return TRUE;
case 0x04:
case 0x05:
case 0x06:
desc->regin[0] |= REGFLAG_R(RTREG);
return TRUE;
case 0x08:
switch (RTREG)
{
case 0x00:
case 0x01:
desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
desc->delayslots = 1;
return TRUE;
}
return FALSE;
}
return FALSE;
} | [
"static",
"int",
"describe_instruction_cop2",
"(",
"mips3_state",
"*",
"mips",
",",
"UINT32",
"op",
",",
"opcode_desc",
"*",
"desc",
")",
"{",
"desc",
"->",
"flags",
"|=",
"OPFLAG_CAN_CAUSE_EXCEPTION",
";",
"switch",
"(",
"RSREG",
")",
"{",
"case",
"0x00",
":",
"case",
"0x01",
":",
"case",
"0x02",
":",
"desc",
"->",
"regout",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"return",
"TRUE",
";",
"case",
"0x04",
":",
"case",
"0x05",
":",
"case",
"0x06",
":",
"desc",
"->",
"regin",
"[",
"0",
"]",
"|=",
"REGFLAG_R",
"(",
"RTREG",
")",
";",
"return",
"TRUE",
";",
"case",
"0x08",
":",
"switch",
"(",
"RTREG",
")",
"{",
"case",
"0x00",
":",
"case",
"0x01",
":",
"desc",
"->",
"flags",
"|=",
"OPFLAG_IS_CONDITIONAL_BRANCH",
";",
"desc",
"->",
"targetpc",
"=",
"desc",
"->",
"pc",
"+",
"4",
"+",
"(",
"SIMMVAL",
"<<",
"2",
")",
";",
"desc",
"->",
"delayslots",
"=",
"1",
";",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}",
"return",
"FALSE",
";",
"}"
] | describe_instruction_cop2 - build a
description of a single instruction in the
COP2 group | [
"describe_instruction_cop2",
"-",
"build",
"a",
"description",
"of",
"a",
"single",
"instruction",
"in",
"the",
"COP2",
"group"
] | [
"/* any COP2 instruction can potentially cause an exception */",
"/* MFCz */",
"/* DMFCz */",
"/* CFCz */",
"/* MTCz */",
"/* DMTCz */",
"/* CTCz */",
"/* BC */",
"/* BCzF */",
"/* BCzT */"
] | [
{
"param": "mips",
"type": "mips3_state"
},
{
"param": "op",
"type": "UINT32"
},
{
"param": "desc",
"type": "opcode_desc"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mips",
"type": "mips3_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "op",
"type": "UINT32",
"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": []
} |
a460bd2445830158d2feca1fcf3c6320d7e6f1e0 | lofunz/mieme | Reloaded/trunk/src/emu/fileio.c | [
"Unlicense"
] | C | mame_fopen | file_error | file_error mame_fopen(const char *searchpath, const char *filename, UINT32 openflags, mame_file **file)
{
path_iterator iterator;
path_iterator_init(&iterator, mame_options(), searchpath);
return fopen_internal(mame_options(), &iterator, filename, 0, openflags, file);
} | /*-------------------------------------------------
mame_fopen - open a file for access and
return an error code
-------------------------------------------------*/ | open a file for access and
return an error code | [
"open",
"a",
"file",
"for",
"access",
"and",
"return",
"an",
"error",
"code"
] | file_error mame_fopen(const char *searchpath, const char *filename, UINT32 openflags, mame_file **file)
{
path_iterator iterator;
path_iterator_init(&iterator, mame_options(), searchpath);
return fopen_internal(mame_options(), &iterator, filename, 0, openflags, file);
} | [
"file_error",
"mame_fopen",
"(",
"const",
"char",
"*",
"searchpath",
",",
"const",
"char",
"*",
"filename",
",",
"UINT32",
"openflags",
",",
"mame_file",
"*",
"*",
"file",
")",
"{",
"path_iterator",
"iterator",
";",
"path_iterator_init",
"(",
"&",
"iterator",
",",
"mame_options",
"(",
")",
",",
"searchpath",
")",
";",
"return",
"fopen_internal",
"(",
"mame_options",
"(",
")",
",",
"&",
"iterator",
",",
"filename",
",",
"0",
",",
"openflags",
",",
"file",
")",
";",
"}"
] | mame_fopen - open a file for access and
return an error code | [
"mame_fopen",
"-",
"open",
"a",
"file",
"for",
"access",
"and",
"return",
"an",
"error",
"code"
] | [] | [
{
"param": "searchpath",
"type": "char"
},
{
"param": "filename",
"type": "char"
},
{
"param": "openflags",
"type": "UINT32"
},
{
"param": "file",
"type": "mame_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "searchpath",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "openflags",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type": "mame_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a460bd2445830158d2feca1fcf3c6320d7e6f1e0 | lofunz/mieme | Reloaded/trunk/src/emu/fileio.c | [
"Unlicense"
] | C | mame_fopen_crc | file_error | file_error mame_fopen_crc(const char *searchpath, const char *filename, UINT32 crc, UINT32 openflags, mame_file **file)
{
path_iterator iterator;
path_iterator_init(&iterator, mame_options(), searchpath);
return mame_fopen_crc_options(mame_options(), searchpath, filename, crc, openflags, file);
} | /*-------------------------------------------------
mame_fopen_crc - open a file by name or CRC
and return an error code
-------------------------------------------------*/ | open a file by name or CRC
and return an error code | [
"open",
"a",
"file",
"by",
"name",
"or",
"CRC",
"and",
"return",
"an",
"error",
"code"
] | file_error mame_fopen_crc(const char *searchpath, const char *filename, UINT32 crc, UINT32 openflags, mame_file **file)
{
path_iterator iterator;
path_iterator_init(&iterator, mame_options(), searchpath);
return mame_fopen_crc_options(mame_options(), searchpath, filename, crc, openflags, file);
} | [
"file_error",
"mame_fopen_crc",
"(",
"const",
"char",
"*",
"searchpath",
",",
"const",
"char",
"*",
"filename",
",",
"UINT32",
"crc",
",",
"UINT32",
"openflags",
",",
"mame_file",
"*",
"*",
"file",
")",
"{",
"path_iterator",
"iterator",
";",
"path_iterator_init",
"(",
"&",
"iterator",
",",
"mame_options",
"(",
")",
",",
"searchpath",
")",
";",
"return",
"mame_fopen_crc_options",
"(",
"mame_options",
"(",
")",
",",
"searchpath",
",",
"filename",
",",
"crc",
",",
"openflags",
",",
"file",
")",
";",
"}"
] | mame_fopen_crc - open a file by name or CRC
and return an error code | [
"mame_fopen_crc",
"-",
"open",
"a",
"file",
"by",
"name",
"or",
"CRC",
"and",
"return",
"an",
"error",
"code"
] | [] | [
{
"param": "searchpath",
"type": "char"
},
{
"param": "filename",
"type": "char"
},
{
"param": "crc",
"type": "UINT32"
},
{
"param": "openflags",
"type": "UINT32"
},
{
"param": "file",
"type": "mame_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "searchpath",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "crc",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "openflags",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type": "mame_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a460bd2445830158d2feca1fcf3c6320d7e6f1e0 | lofunz/mieme | Reloaded/trunk/src/emu/fileio.c | [
"Unlicense"
] | C | mame_fopen_options | file_error | file_error mame_fopen_options(core_options *opts, const char *searchpath, const char *filename, UINT32 openflags, mame_file **file)
{
path_iterator iterator;
path_iterator_init(&iterator, opts, searchpath);
return fopen_internal(opts, &iterator, filename, 0, openflags, file);
} | /*-------------------------------------------------
mame_fopen_options - open a file for access and
return an error code
-------------------------------------------------*/ | open a file for access and
return an error code | [
"open",
"a",
"file",
"for",
"access",
"and",
"return",
"an",
"error",
"code"
] | file_error mame_fopen_options(core_options *opts, const char *searchpath, const char *filename, UINT32 openflags, mame_file **file)
{
path_iterator iterator;
path_iterator_init(&iterator, opts, searchpath);
return fopen_internal(opts, &iterator, filename, 0, openflags, file);
} | [
"file_error",
"mame_fopen_options",
"(",
"core_options",
"*",
"opts",
",",
"const",
"char",
"*",
"searchpath",
",",
"const",
"char",
"*",
"filename",
",",
"UINT32",
"openflags",
",",
"mame_file",
"*",
"*",
"file",
")",
"{",
"path_iterator",
"iterator",
";",
"path_iterator_init",
"(",
"&",
"iterator",
",",
"opts",
",",
"searchpath",
")",
";",
"return",
"fopen_internal",
"(",
"opts",
",",
"&",
"iterator",
",",
"filename",
",",
"0",
",",
"openflags",
",",
"file",
")",
";",
"}"
] | mame_fopen_options - open a file for access and
return an error code | [
"mame_fopen_options",
"-",
"open",
"a",
"file",
"for",
"access",
"and",
"return",
"an",
"error",
"code"
] | [] | [
{
"param": "opts",
"type": "core_options"
},
{
"param": "searchpath",
"type": "char"
},
{
"param": "filename",
"type": "char"
},
{
"param": "openflags",
"type": "UINT32"
},
{
"param": "file",
"type": "mame_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "opts",
"type": "core_options",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "searchpath",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "openflags",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type": "mame_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a460bd2445830158d2feca1fcf3c6320d7e6f1e0 | lofunz/mieme | Reloaded/trunk/src/emu/fileio.c | [
"Unlicense"
] | C | mame_fopen_crc_options | file_error | file_error mame_fopen_crc_options(core_options *opts, const char *searchpath, const char *filename, UINT32 crc, UINT32 openflags, mame_file **file)
{
path_iterator iterator;
path_iterator_init(&iterator, opts, searchpath);
return fopen_internal(opts, &iterator, filename, crc, openflags | OPEN_FLAG_HAS_CRC, file);
} | /*-------------------------------------------------
mame_fopen_crc_options - open a file by name
or CRC and return an error code
-------------------------------------------------*/ | open a file by name
or CRC and return an error code | [
"open",
"a",
"file",
"by",
"name",
"or",
"CRC",
"and",
"return",
"an",
"error",
"code"
] | file_error mame_fopen_crc_options(core_options *opts, const char *searchpath, const char *filename, UINT32 crc, UINT32 openflags, mame_file **file)
{
path_iterator iterator;
path_iterator_init(&iterator, opts, searchpath);
return fopen_internal(opts, &iterator, filename, crc, openflags | OPEN_FLAG_HAS_CRC, file);
} | [
"file_error",
"mame_fopen_crc_options",
"(",
"core_options",
"*",
"opts",
",",
"const",
"char",
"*",
"searchpath",
",",
"const",
"char",
"*",
"filename",
",",
"UINT32",
"crc",
",",
"UINT32",
"openflags",
",",
"mame_file",
"*",
"*",
"file",
")",
"{",
"path_iterator",
"iterator",
";",
"path_iterator_init",
"(",
"&",
"iterator",
",",
"opts",
",",
"searchpath",
")",
";",
"return",
"fopen_internal",
"(",
"opts",
",",
"&",
"iterator",
",",
"filename",
",",
"crc",
",",
"openflags",
"|",
"OPEN_FLAG_HAS_CRC",
",",
"file",
")",
";",
"}"
] | mame_fopen_crc_options - open a file by name
or CRC and return an error code | [
"mame_fopen_crc_options",
"-",
"open",
"a",
"file",
"by",
"name",
"or",
"CRC",
"and",
"return",
"an",
"error",
"code"
] | [] | [
{
"param": "opts",
"type": "core_options"
},
{
"param": "searchpath",
"type": "char"
},
{
"param": "filename",
"type": "char"
},
{
"param": "crc",
"type": "UINT32"
},
{
"param": "openflags",
"type": "UINT32"
},
{
"param": "file",
"type": "mame_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "opts",
"type": "core_options",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "searchpath",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "crc",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "openflags",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type": "mame_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a460bd2445830158d2feca1fcf3c6320d7e6f1e0 | lofunz/mieme | Reloaded/trunk/src/emu/fileio.c | [
"Unlicense"
] | C | mame_fopen_ram | file_error | file_error mame_fopen_ram(const void *data, UINT32 length, UINT32 openflags, mame_file **file)
{
file_error filerr;
/* allocate the file itself */
*file = global_alloc_clear(mame_file);
/* reset the file handle */
(*file)->openflags = openflags;
#ifdef DEBUG_COOKIE
(*file)->debug_cookie = DEBUG_COOKIE;
#endif
/* attempt to open the file directly */
filerr = core_fopen_ram(data, length, openflags, &(*file)->file);
if (filerr == FILERR_NONE)
goto error;
/* handle errors and return */
error:
if (filerr != FILERR_NONE)
{
mame_fclose(*file);
*file = NULL;
}
return filerr;
} | /*-------------------------------------------------
mame_fopen_ram - open a "file" which is
actually just an array of data in RAM
-------------------------------------------------*/ | open a "file" which is
actually just an array of data in RAM | [
"open",
"a",
"\"",
"file",
"\"",
"which",
"is",
"actually",
"just",
"an",
"array",
"of",
"data",
"in",
"RAM"
] | file_error mame_fopen_ram(const void *data, UINT32 length, UINT32 openflags, mame_file **file)
{
file_error filerr;
*file = global_alloc_clear(mame_file);
(*file)->openflags = openflags;
#ifdef DEBUG_COOKIE
(*file)->debug_cookie = DEBUG_COOKIE;
#endif
filerr = core_fopen_ram(data, length, openflags, &(*file)->file);
if (filerr == FILERR_NONE)
goto error;
error:
if (filerr != FILERR_NONE)
{
mame_fclose(*file);
*file = NULL;
}
return filerr;
} | [
"file_error",
"mame_fopen_ram",
"(",
"const",
"void",
"*",
"data",
",",
"UINT32",
"length",
",",
"UINT32",
"openflags",
",",
"mame_file",
"*",
"*",
"file",
")",
"{",
"file_error",
"filerr",
";",
"*",
"file",
"=",
"global_alloc_clear",
"(",
"mame_file",
")",
";",
"(",
"*",
"file",
")",
"->",
"openflags",
"=",
"openflags",
";",
"#ifdef",
"DEBUG_COOKIE",
"(",
"*",
"file",
")",
"->",
"debug_cookie",
"=",
"DEBUG_COOKIE",
";",
"#endif",
"filerr",
"=",
"core_fopen_ram",
"(",
"data",
",",
"length",
",",
"openflags",
",",
"&",
"(",
"*",
"file",
")",
"->",
"file",
")",
";",
"if",
"(",
"filerr",
"==",
"FILERR_NONE",
")",
"goto",
"error",
";",
"error",
":",
"if",
"(",
"filerr",
"!=",
"FILERR_NONE",
")",
"{",
"mame_fclose",
"(",
"*",
"file",
")",
";",
"*",
"file",
"=",
"NULL",
";",
"}",
"return",
"filerr",
";",
"}"
] | mame_fopen_ram - open a "file" which is
actually just an array of data in RAM | [
"mame_fopen_ram",
"-",
"open",
"a",
"\"",
"file",
"\"",
"which",
"is",
"actually",
"just",
"an",
"array",
"of",
"data",
"in",
"RAM"
] | [
"/* allocate the file itself */",
"/* reset the file handle */",
"/* attempt to open the file directly */",
"/* handle errors and return */"
] | [
{
"param": "data",
"type": "void"
},
{
"param": "length",
"type": "UINT32"
},
{
"param": "openflags",
"type": "UINT32"
},
{
"param": "file",
"type": "mame_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "length",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "openflags",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type": "mame_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a460bd2445830158d2feca1fcf3c6320d7e6f1e0 | lofunz/mieme | Reloaded/trunk/src/emu/fileio.c | [
"Unlicense"
] | C | mame_fclose_and_open_next | file_error | file_error mame_fclose_and_open_next(mame_file **file, const char *filename, UINT32 openflags)
{
path_iterator iterator = (*file)->iterator;
mame_fclose(*file);
*file = NULL;
return fopen_internal(mame_options(), &iterator, filename, 0, openflags, file);
} | /*-------------------------------------------------
mame_fclose_and_open_next - close an open
file, and open the next entry in the original
searchpath
-------------------------------------------------*/ | close an open
file, and open the next entry in the original
searchpath | [
"close",
"an",
"open",
"file",
"and",
"open",
"the",
"next",
"entry",
"in",
"the",
"original",
"searchpath"
] | file_error mame_fclose_and_open_next(mame_file **file, const char *filename, UINT32 openflags)
{
path_iterator iterator = (*file)->iterator;
mame_fclose(*file);
*file = NULL;
return fopen_internal(mame_options(), &iterator, filename, 0, openflags, file);
} | [
"file_error",
"mame_fclose_and_open_next",
"(",
"mame_file",
"*",
"*",
"file",
",",
"const",
"char",
"*",
"filename",
",",
"UINT32",
"openflags",
")",
"{",
"path_iterator",
"iterator",
"=",
"(",
"*",
"file",
")",
"->",
"iterator",
";",
"mame_fclose",
"(",
"*",
"file",
")",
";",
"*",
"file",
"=",
"NULL",
";",
"return",
"fopen_internal",
"(",
"mame_options",
"(",
")",
",",
"&",
"iterator",
",",
"filename",
",",
"0",
",",
"openflags",
",",
"file",
")",
";",
"}"
] | mame_fclose_and_open_next - close an open
file, and open the next entry in the original
searchpath | [
"mame_fclose_and_open_next",
"-",
"close",
"an",
"open",
"file",
"and",
"open",
"the",
"next",
"entry",
"in",
"the",
"original",
"searchpath"
] | [] | [
{
"param": "file",
"type": "mame_file"
},
{
"param": "filename",
"type": "char"
},
{
"param": "openflags",
"type": "UINT32"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": "mame_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "openflags",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a460bd2445830158d2feca1fcf3c6320d7e6f1e0 | lofunz/mieme | Reloaded/trunk/src/emu/fileio.c | [
"Unlicense"
] | C | mame_feof | int | int mame_feof(mame_file *file)
{
/* load the ZIP file now if we haven't yet */
if (file->zipfile != NULL)
{
if (load_zipped_file(file) != FILERR_NONE)
return 0;
}
/* return EOF if we can */
if (file->file != NULL)
return core_feof(file->file);
return 0;
} | /*-------------------------------------------------
mame_feof - return 1 if we're at the end
of file
-------------------------------------------------*/ | return 1 if we're at the end
of file | [
"return",
"1",
"if",
"we",
"'",
"re",
"at",
"the",
"end",
"of",
"file"
] | int mame_feof(mame_file *file)
{
if (file->zipfile != NULL)
{
if (load_zipped_file(file) != FILERR_NONE)
return 0;
}
if (file->file != NULL)
return core_feof(file->file);
return 0;
} | [
"int",
"mame_feof",
"(",
"mame_file",
"*",
"file",
")",
"{",
"if",
"(",
"file",
"->",
"zipfile",
"!=",
"NULL",
")",
"{",
"if",
"(",
"load_zipped_file",
"(",
"file",
")",
"!=",
"FILERR_NONE",
")",
"return",
"0",
";",
"}",
"if",
"(",
"file",
"->",
"file",
"!=",
"NULL",
")",
"return",
"core_feof",
"(",
"file",
"->",
"file",
")",
";",
"return",
"0",
";",
"}"
] | mame_feof - return 1 if we're at the end
of file | [
"mame_feof",
"-",
"return",
"1",
"if",
"we",
"'",
"re",
"at",
"the",
"end",
"of",
"file"
] | [
"/* load the ZIP file now if we haven't yet */",
"/* return EOF if we can */"
] | [
{
"param": "file",
"type": "mame_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": "mame_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a460bd2445830158d2feca1fcf3c6320d7e6f1e0 | lofunz/mieme | Reloaded/trunk/src/emu/fileio.c | [
"Unlicense"
] | C | mame_fsize | UINT64 | UINT64 mame_fsize(mame_file *file)
{
/* use the ZIP length if present */
if (file->zipfile != NULL)
return file->ziplength;
/* return length if we can */
if (file->file != NULL)
return core_fsize(file->file);
return 0;
} | /*-------------------------------------------------
mame_fsize - returns the size of a file
-------------------------------------------------*/ | returns the size of a file | [
"returns",
"the",
"size",
"of",
"a",
"file"
] | UINT64 mame_fsize(mame_file *file)
{
if (file->zipfile != NULL)
return file->ziplength;
if (file->file != NULL)
return core_fsize(file->file);
return 0;
} | [
"UINT64",
"mame_fsize",
"(",
"mame_file",
"*",
"file",
")",
"{",
"if",
"(",
"file",
"->",
"zipfile",
"!=",
"NULL",
")",
"return",
"file",
"->",
"ziplength",
";",
"if",
"(",
"file",
"->",
"file",
"!=",
"NULL",
")",
"return",
"core_fsize",
"(",
"file",
"->",
"file",
")",
";",
"return",
"0",
";",
"}"
] | mame_fsize - returns the size of a file | [
"mame_fsize",
"-",
"returns",
"the",
"size",
"of",
"a",
"file"
] | [
"/* use the ZIP length if present */",
"/* return length if we can */"
] | [
{
"param": "file",
"type": "mame_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": "mame_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a460bd2445830158d2feca1fcf3c6320d7e6f1e0 | lofunz/mieme | Reloaded/trunk/src/emu/fileio.c | [
"Unlicense"
] | C | mame_fgetc | int | int mame_fgetc(mame_file *file)
{
/* load the ZIP file now if we haven't yet */
if (file->zipfile != NULL)
{
if (load_zipped_file(file) != FILERR_NONE)
return EOF;
}
/* read the data if we can */
if (file->file != NULL)
return core_fgetc(file->file);
return EOF;
} | /*-------------------------------------------------
mame_fgetc - read a character from a file
-------------------------------------------------*/ | read a character from a file | [
"read",
"a",
"character",
"from",
"a",
"file"
] | int mame_fgetc(mame_file *file)
{
if (file->zipfile != NULL)
{
if (load_zipped_file(file) != FILERR_NONE)
return EOF;
}
if (file->file != NULL)
return core_fgetc(file->file);
return EOF;
} | [
"int",
"mame_fgetc",
"(",
"mame_file",
"*",
"file",
")",
"{",
"if",
"(",
"file",
"->",
"zipfile",
"!=",
"NULL",
")",
"{",
"if",
"(",
"load_zipped_file",
"(",
"file",
")",
"!=",
"FILERR_NONE",
")",
"return",
"EOF",
";",
"}",
"if",
"(",
"file",
"->",
"file",
"!=",
"NULL",
")",
"return",
"core_fgetc",
"(",
"file",
"->",
"file",
")",
";",
"return",
"EOF",
";",
"}"
] | mame_fgetc - read a character from a file | [
"mame_fgetc",
"-",
"read",
"a",
"character",
"from",
"a",
"file"
] | [
"/* load the ZIP file now if we haven't yet */",
"/* read the data if we can */"
] | [
{
"param": "file",
"type": "mame_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": "mame_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a460bd2445830158d2feca1fcf3c6320d7e6f1e0 | lofunz/mieme | Reloaded/trunk/src/emu/fileio.c | [
"Unlicense"
] | C | mame_ungetc | int | int mame_ungetc(int c, mame_file *file)
{
/* load the ZIP file now if we haven't yet */
if (file->zipfile != NULL)
{
if (load_zipped_file(file) != FILERR_NONE)
return 1;
}
/* read the data if we can */
if (file->file != NULL)
return core_ungetc(c, file->file);
return 1;
} | /*-------------------------------------------------
mame_ungetc - put back a character read from
a file
-------------------------------------------------*/ | put back a character read from
a file | [
"put",
"back",
"a",
"character",
"read",
"from",
"a",
"file"
] | int mame_ungetc(int c, mame_file *file)
{
if (file->zipfile != NULL)
{
if (load_zipped_file(file) != FILERR_NONE)
return 1;
}
if (file->file != NULL)
return core_ungetc(c, file->file);
return 1;
} | [
"int",
"mame_ungetc",
"(",
"int",
"c",
",",
"mame_file",
"*",
"file",
")",
"{",
"if",
"(",
"file",
"->",
"zipfile",
"!=",
"NULL",
")",
"{",
"if",
"(",
"load_zipped_file",
"(",
"file",
")",
"!=",
"FILERR_NONE",
")",
"return",
"1",
";",
"}",
"if",
"(",
"file",
"->",
"file",
"!=",
"NULL",
")",
"return",
"core_ungetc",
"(",
"c",
",",
"file",
"->",
"file",
")",
";",
"return",
"1",
";",
"}"
] | mame_ungetc - put back a character read from
a file | [
"mame_ungetc",
"-",
"put",
"back",
"a",
"character",
"read",
"from",
"a",
"file"
] | [
"/* load the ZIP file now if we haven't yet */",
"/* read the data if we can */"
] | [
{
"param": "c",
"type": "int"
},
{
"param": "file",
"type": "mame_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "c",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type": "mame_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a460bd2445830158d2feca1fcf3c6320d7e6f1e0 | lofunz/mieme | Reloaded/trunk/src/emu/fileio.c | [
"Unlicense"
] | C | mame_fgets | char | char *mame_fgets(char *s, int n, mame_file *file)
{
/* load the ZIP file now if we haven't yet */
if (file->zipfile != NULL)
{
if (load_zipped_file(file) != FILERR_NONE)
return NULL;
}
/* read the data if we can */
if (file->file != NULL)
return core_fgets(s, n, file->file);
return NULL;
} | /*-------------------------------------------------
mame_fgets - read a line from a text file
-------------------------------------------------*/ | read a line from a text file | [
"read",
"a",
"line",
"from",
"a",
"text",
"file"
] | char *mame_fgets(char *s, int n, mame_file *file)
{
if (file->zipfile != NULL)
{
if (load_zipped_file(file) != FILERR_NONE)
return NULL;
}
if (file->file != NULL)
return core_fgets(s, n, file->file);
return NULL;
} | [
"char",
"*",
"mame_fgets",
"(",
"char",
"*",
"s",
",",
"int",
"n",
",",
"mame_file",
"*",
"file",
")",
"{",
"if",
"(",
"file",
"->",
"zipfile",
"!=",
"NULL",
")",
"{",
"if",
"(",
"load_zipped_file",
"(",
"file",
")",
"!=",
"FILERR_NONE",
")",
"return",
"NULL",
";",
"}",
"if",
"(",
"file",
"->",
"file",
"!=",
"NULL",
")",
"return",
"core_fgets",
"(",
"s",
",",
"n",
",",
"file",
"->",
"file",
")",
";",
"return",
"NULL",
";",
"}"
] | mame_fgets - read a line from a text file | [
"mame_fgets",
"-",
"read",
"a",
"line",
"from",
"a",
"text",
"file"
] | [
"/* load the ZIP file now if we haven't yet */",
"/* read the data if we can */"
] | [
{
"param": "s",
"type": "char"
},
{
"param": "n",
"type": "int"
},
{
"param": "file",
"type": "mame_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "s",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type": "mame_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a460bd2445830158d2feca1fcf3c6320d7e6f1e0 | lofunz/mieme | Reloaded/trunk/src/emu/fileio.c | [
"Unlicense"
] | C | mame_fputs | int | int mame_fputs(mame_file *file, const char *s)
{
/* write the data if we can */
if (file->file != NULL)
return core_fputs(file->file, s);
return 0;
} | /*-------------------------------------------------
mame_fputs - write a line to a text file
-------------------------------------------------*/ | write a line to a text file | [
"write",
"a",
"line",
"to",
"a",
"text",
"file"
] | int mame_fputs(mame_file *file, const char *s)
{
if (file->file != NULL)
return core_fputs(file->file, s);
return 0;
} | [
"int",
"mame_fputs",
"(",
"mame_file",
"*",
"file",
",",
"const",
"char",
"*",
"s",
")",
"{",
"if",
"(",
"file",
"->",
"file",
"!=",
"NULL",
")",
"return",
"core_fputs",
"(",
"file",
"->",
"file",
",",
"s",
")",
";",
"return",
"0",
";",
"}"
] | mame_fputs - write a line to a text file | [
"mame_fputs",
"-",
"write",
"a",
"line",
"to",
"a",
"text",
"file"
] | [
"/* write the data if we can */"
] | [
{
"param": "file",
"type": "mame_file"
},
{
"param": "s",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": "mame_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "s",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a460bd2445830158d2feca1fcf3c6320d7e6f1e0 | lofunz/mieme | Reloaded/trunk/src/emu/fileio.c | [
"Unlicense"
] | C | mame_openpath | mame_path | mame_path *mame_openpath(core_options *opts, const char *searchpath)
{
mame_path *path;
/* allocate a new mame_path */
path = global_alloc_clear(mame_path);
/* initialize the iterator */
path_iterator_init(&path->iterator, opts, searchpath);
return path;
} | /*-------------------------------------------------
mame_openpath - open a search path (multiple
directories) for iteration
-------------------------------------------------*/ | open a search path (multiple
directories) for iteration | [
"open",
"a",
"search",
"path",
"(",
"multiple",
"directories",
")",
"for",
"iteration"
] | mame_path *mame_openpath(core_options *opts, const char *searchpath)
{
mame_path *path;
path = global_alloc_clear(mame_path);
path_iterator_init(&path->iterator, opts, searchpath);
return path;
} | [
"mame_path",
"*",
"mame_openpath",
"(",
"core_options",
"*",
"opts",
",",
"const",
"char",
"*",
"searchpath",
")",
"{",
"mame_path",
"*",
"path",
";",
"path",
"=",
"global_alloc_clear",
"(",
"mame_path",
")",
";",
"path_iterator_init",
"(",
"&",
"path",
"->",
"iterator",
",",
"opts",
",",
"searchpath",
")",
";",
"return",
"path",
";",
"}"
] | mame_openpath - open a search path (multiple
directories) for iteration | [
"mame_openpath",
"-",
"open",
"a",
"search",
"path",
"(",
"multiple",
"directories",
")",
"for",
"iteration"
] | [
"/* allocate a new mame_path */",
"/* initialize the iterator */"
] | [
{
"param": "opts",
"type": "core_options"
},
{
"param": "searchpath",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "opts",
"type": "core_options",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "searchpath",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a460bd2445830158d2feca1fcf3c6320d7e6f1e0 | lofunz/mieme | Reloaded/trunk/src/emu/fileio.c | [
"Unlicense"
] | C | mame_readpath | osd_directory_entry | const osd_directory_entry *mame_readpath(mame_path *path)
{
const osd_directory_entry *result;
/* loop over potentially empty directories */
while (1)
{
/* if no open directory, get the next path */
while (path->curdir == NULL)
{
/* if we fail to get anything more, we're done */
if (!path_iterator_get_next(&path->iterator, path->pathbuffer))
return NULL;
/* open the path */
path->curdir = osd_opendir(path->pathbuffer);
}
/* get the next entry from the current directory */
result = osd_readdir(path->curdir);
if (result != NULL)
return result;
/* we're done; close this directory */
osd_closedir(path->curdir);
path->curdir = NULL;
}
} | /*-------------------------------------------------
mame_readpath - return information about the
next file in the search path
-------------------------------------------------*/ | return information about the
next file in the search path | [
"return",
"information",
"about",
"the",
"next",
"file",
"in",
"the",
"search",
"path"
] | const osd_directory_entry *mame_readpath(mame_path *path)
{
const osd_directory_entry *result;
while (1)
{
while (path->curdir == NULL)
{
if (!path_iterator_get_next(&path->iterator, path->pathbuffer))
return NULL;
path->curdir = osd_opendir(path->pathbuffer);
}
result = osd_readdir(path->curdir);
if (result != NULL)
return result;
osd_closedir(path->curdir);
path->curdir = NULL;
}
} | [
"const",
"osd_directory_entry",
"*",
"mame_readpath",
"(",
"mame_path",
"*",
"path",
")",
"{",
"const",
"osd_directory_entry",
"*",
"result",
";",
"while",
"(",
"1",
")",
"{",
"while",
"(",
"path",
"->",
"curdir",
"==",
"NULL",
")",
"{",
"if",
"(",
"!",
"path_iterator_get_next",
"(",
"&",
"path",
"->",
"iterator",
",",
"path",
"->",
"pathbuffer",
")",
")",
"return",
"NULL",
";",
"path",
"->",
"curdir",
"=",
"osd_opendir",
"(",
"path",
"->",
"pathbuffer",
")",
";",
"}",
"result",
"=",
"osd_readdir",
"(",
"path",
"->",
"curdir",
")",
";",
"if",
"(",
"result",
"!=",
"NULL",
")",
"return",
"result",
";",
"osd_closedir",
"(",
"path",
"->",
"curdir",
")",
";",
"path",
"->",
"curdir",
"=",
"NULL",
";",
"}",
"}"
] | mame_readpath - return information about the
next file in the search path | [
"mame_readpath",
"-",
"return",
"information",
"about",
"the",
"next",
"file",
"in",
"the",
"search",
"path"
] | [
"/* loop over potentially empty directories */",
"/* if no open directory, get the next path */",
"/* if we fail to get anything more, we're done */",
"/* open the path */",
"/* get the next entry from the current directory */",
"/* we're done; close this directory */"
] | [
{
"param": "path",
"type": "mame_path"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "path",
"type": "mame_path",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a460bd2445830158d2feca1fcf3c6320d7e6f1e0 | lofunz/mieme | Reloaded/trunk/src/emu/fileio.c | [
"Unlicense"
] | C | mame_fhash | char | const char *mame_fhash(mame_file *file, UINT32 functions)
{
const UINT8 *filedata;
UINT32 wehave;
/* if we already have the functions we need, just return */
wehave = hash_data_used_functions(file->hash);
if ((wehave & functions) == functions)
return file->hash;
/* load the ZIP file now if we haven't yet */
if (file->zipfile != NULL)
{
if (load_zipped_file(file) != FILERR_NONE)
return file->hash;
}
if (file->file == NULL)
return file->hash;
/* read the data if we can */
filedata = (const UINT8 *)core_fbuffer(file->file);
if (filedata == NULL)
return file->hash;
/* compute the hash */
hash_compute(file->hash, filedata, core_fsize(file->file), wehave | functions);
return file->hash;
} | /*-------------------------------------------------
mame_fhash - returns the hash for a file
-------------------------------------------------*/ | returns the hash for a file | [
"returns",
"the",
"hash",
"for",
"a",
"file"
] | const char *mame_fhash(mame_file *file, UINT32 functions)
{
const UINT8 *filedata;
UINT32 wehave;
wehave = hash_data_used_functions(file->hash);
if ((wehave & functions) == functions)
return file->hash;
if (file->zipfile != NULL)
{
if (load_zipped_file(file) != FILERR_NONE)
return file->hash;
}
if (file->file == NULL)
return file->hash;
filedata = (const UINT8 *)core_fbuffer(file->file);
if (filedata == NULL)
return file->hash;
hash_compute(file->hash, filedata, core_fsize(file->file), wehave | functions);
return file->hash;
} | [
"const",
"char",
"*",
"mame_fhash",
"(",
"mame_file",
"*",
"file",
",",
"UINT32",
"functions",
")",
"{",
"const",
"UINT8",
"*",
"filedata",
";",
"UINT32",
"wehave",
";",
"wehave",
"=",
"hash_data_used_functions",
"(",
"file",
"->",
"hash",
")",
";",
"if",
"(",
"(",
"wehave",
"&",
"functions",
")",
"==",
"functions",
")",
"return",
"file",
"->",
"hash",
";",
"if",
"(",
"file",
"->",
"zipfile",
"!=",
"NULL",
")",
"{",
"if",
"(",
"load_zipped_file",
"(",
"file",
")",
"!=",
"FILERR_NONE",
")",
"return",
"file",
"->",
"hash",
";",
"}",
"if",
"(",
"file",
"->",
"file",
"==",
"NULL",
")",
"return",
"file",
"->",
"hash",
";",
"filedata",
"=",
"(",
"const",
"UINT8",
"*",
")",
"core_fbuffer",
"(",
"file",
"->",
"file",
")",
";",
"if",
"(",
"filedata",
"==",
"NULL",
")",
"return",
"file",
"->",
"hash",
";",
"hash_compute",
"(",
"file",
"->",
"hash",
",",
"filedata",
",",
"core_fsize",
"(",
"file",
"->",
"file",
")",
",",
"wehave",
"|",
"functions",
")",
";",
"return",
"file",
"->",
"hash",
";",
"}"
] | mame_fhash - returns the hash for a file | [
"mame_fhash",
"-",
"returns",
"the",
"hash",
"for",
"a",
"file"
] | [
"/* if we already have the functions we need, just return */",
"/* load the ZIP file now if we haven't yet */",
"/* read the data if we can */",
"/* compute the hash */"
] | [
{
"param": "file",
"type": "mame_file"
},
{
"param": "functions",
"type": "UINT32"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": "mame_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "functions",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a460bd2445830158d2feca1fcf3c6320d7e6f1e0 | lofunz/mieme | Reloaded/trunk/src/emu/fileio.c | [
"Unlicense"
] | C | path_iterator_init | void | static void path_iterator_init(path_iterator *iterator, core_options *opts, const char *searchpath)
{
/* reset the structure */
iterator->base = (searchpath != NULL && !osd_is_absolute_path(searchpath)) ? options_get_string(opts, searchpath) : "";
iterator->cur = iterator->base;
iterator->index = 0;
} | /*-------------------------------------------------
path_iterator_init - prepare to iterate over
a given path type
-------------------------------------------------*/ | prepare to iterate over
a given path type | [
"prepare",
"to",
"iterate",
"over",
"a",
"given",
"path",
"type"
] | static void path_iterator_init(path_iterator *iterator, core_options *opts, const char *searchpath)
{
iterator->base = (searchpath != NULL && !osd_is_absolute_path(searchpath)) ? options_get_string(opts, searchpath) : "";
iterator->cur = iterator->base;
iterator->index = 0;
} | [
"static",
"void",
"path_iterator_init",
"(",
"path_iterator",
"*",
"iterator",
",",
"core_options",
"*",
"opts",
",",
"const",
"char",
"*",
"searchpath",
")",
"{",
"iterator",
"->",
"base",
"=",
"(",
"searchpath",
"!=",
"NULL",
"&&",
"!",
"osd_is_absolute_path",
"(",
"searchpath",
")",
")",
"?",
"options_get_string",
"(",
"opts",
",",
"searchpath",
")",
":",
"\"",
"\"",
";",
"iterator",
"->",
"cur",
"=",
"iterator",
"->",
"base",
";",
"iterator",
"->",
"index",
"=",
"0",
";",
"}"
] | path_iterator_init - prepare to iterate over
a given path type | [
"path_iterator_init",
"-",
"prepare",
"to",
"iterate",
"over",
"a",
"given",
"path",
"type"
] | [
"/* reset the structure */"
] | [
{
"param": "iterator",
"type": "path_iterator"
},
{
"param": "opts",
"type": "core_options"
},
{
"param": "searchpath",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "iterator",
"type": "path_iterator",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "opts",
"type": "core_options",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "searchpath",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a460bd2445830158d2feca1fcf3c6320d7e6f1e0 | lofunz/mieme | Reloaded/trunk/src/emu/fileio.c | [
"Unlicense"
] | C | zip_header_is_path | int | static int zip_header_is_path(const zip_file_header *header)
{
const char *zipfile = header->filename + header->filename_length - 1;
return (zipfile >= header->filename && zipfile[0] == '/');
} | /*-------------------------------------------------
zip_header_is_path - check whether filename
in header is a path
-------------------------------------------------*/ | check whether filename
in header is a path | [
"check",
"whether",
"filename",
"in",
"header",
"is",
"a",
"path"
] | static int zip_header_is_path(const zip_file_header *header)
{
const char *zipfile = header->filename + header->filename_length - 1;
return (zipfile >= header->filename && zipfile[0] == '/');
} | [
"static",
"int",
"zip_header_is_path",
"(",
"const",
"zip_file_header",
"*",
"header",
")",
"{",
"const",
"char",
"*",
"zipfile",
"=",
"header",
"->",
"filename",
"+",
"header",
"->",
"filename_length",
"-",
"1",
";",
"return",
"(",
"zipfile",
">=",
"header",
"->",
"filename",
"&&",
"zipfile",
"[",
"0",
"]",
"==",
"'",
"'",
")",
";",
"}"
] | zip_header_is_path - check whether filename
in header is a path | [
"zip_header_is_path",
"-",
"check",
"whether",
"filename",
"in",
"header",
"is",
"a",
"path"
] | [] | [
{
"param": "header",
"type": "zip_file_header"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "header",
"type": "zip_file_header",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d28abcb4873735de606609ca20806168fad378b2 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/nitedrvr.c | [
"Unlicense"
] | C | nitedrvr_steering | int | static int nitedrvr_steering(running_machine *machine)
{
int this_val;
int delta;
this_val = input_port_read(machine, "STEER");
delta=this_val-last_steering_val;
last_steering_val=this_val;
if (delta>128) delta-=256;
else if (delta<-128) delta+=256;
/* Divide by four to make our steering less sensitive */
nitedrvr_steering_buf+=(delta/4);
if (nitedrvr_steering_buf>0)
{
nitedrvr_steering_buf--;
nitedrvr_steering_val=0xC0;
}
else if (nitedrvr_steering_buf<0)
{
nitedrvr_steering_buf++;
nitedrvr_steering_val=0x80;
}
else
{
nitedrvr_steering_val=0x00;
}
return nitedrvr_steering_val;
} | /***************************************************************************
Steering
When D7 is high, the steering wheel has moved.
If D6 is low, it moved left. If D6 is high, it moved right.
Be sure to keep returning a direction until steering_reset is called,
because D6 and D7 are apparently checked at different times, and a
change in-between can affect the direction you move.
***************************************************************************/ | Steering
When D7 is high, the steering wheel has moved.
If D6 is low, it moved left. If D6 is high, it moved right.
Be sure to keep returning a direction until steering_reset is called,
because D6 and D7 are apparently checked at different times, and a
change in-between can affect the direction you move. | [
"Steering",
"When",
"D7",
"is",
"high",
"the",
"steering",
"wheel",
"has",
"moved",
".",
"If",
"D6",
"is",
"low",
"it",
"moved",
"left",
".",
"If",
"D6",
"is",
"high",
"it",
"moved",
"right",
".",
"Be",
"sure",
"to",
"keep",
"returning",
"a",
"direction",
"until",
"steering_reset",
"is",
"called",
"because",
"D6",
"and",
"D7",
"are",
"apparently",
"checked",
"at",
"different",
"times",
"and",
"a",
"change",
"in",
"-",
"between",
"can",
"affect",
"the",
"direction",
"you",
"move",
"."
] | static int nitedrvr_steering(running_machine *machine)
{
int this_val;
int delta;
this_val = input_port_read(machine, "STEER");
delta=this_val-last_steering_val;
last_steering_val=this_val;
if (delta>128) delta-=256;
else if (delta<-128) delta+=256;
nitedrvr_steering_buf+=(delta/4);
if (nitedrvr_steering_buf>0)
{
nitedrvr_steering_buf--;
nitedrvr_steering_val=0xC0;
}
else if (nitedrvr_steering_buf<0)
{
nitedrvr_steering_buf++;
nitedrvr_steering_val=0x80;
}
else
{
nitedrvr_steering_val=0x00;
}
return nitedrvr_steering_val;
} | [
"static",
"int",
"nitedrvr_steering",
"(",
"running_machine",
"*",
"machine",
")",
"{",
"int",
"this_val",
";",
"int",
"delta",
";",
"this_val",
"=",
"input_port_read",
"(",
"machine",
",",
"\"",
"\"",
")",
";",
"delta",
"=",
"this_val",
"-",
"last_steering_val",
";",
"last_steering_val",
"=",
"this_val",
";",
"if",
"(",
"delta",
">",
"128",
")",
"delta",
"-=",
"256",
";",
"else",
"if",
"(",
"delta",
"<",
"-128",
")",
"delta",
"+=",
"256",
";",
"nitedrvr_steering_buf",
"+=",
"(",
"delta",
"/",
"4",
")",
";",
"if",
"(",
"nitedrvr_steering_buf",
">",
"0",
")",
"{",
"nitedrvr_steering_buf",
"--",
";",
"nitedrvr_steering_val",
"=",
"0xC0",
";",
"}",
"else",
"if",
"(",
"nitedrvr_steering_buf",
"<",
"0",
")",
"{",
"nitedrvr_steering_buf",
"++",
";",
"nitedrvr_steering_val",
"=",
"0x80",
";",
"}",
"else",
"{",
"nitedrvr_steering_val",
"=",
"0x00",
";",
"}",
"return",
"nitedrvr_steering_val",
";",
"}"
] | Steering
When D7 is high, the steering wheel has moved. | [
"Steering",
"When",
"D7",
"is",
"high",
"the",
"steering",
"wheel",
"has",
"moved",
"."
] | [
"/* Divide by four to make our steering less sensitive */"
] | [
{
"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": []
} |
8763e287951c407860681796b2c2d5fc8159f258 | lofunz/mieme | Reloaded/trunk/src/emu/cpu/dsp56k/dsp56ops.c | [
"Unlicense"
] | C | execute_dual_x_memory_data_read | void | static void execute_dual_x_memory_data_read(dsp56k_core* cpustate, const UINT16 op, typed_pointer* d_register)
{
typed_pointer tempV;
UINT16 srcVal1 = 0x0000;
UINT16 srcVal2 = 0x0000;
typed_pointer R = {NULL, DT_BYTE};
typed_pointer D1 = {NULL, DT_BYTE};
typed_pointer D2 = {NULL, DT_BYTE};
decode_RR_table(cpustate, BITS(op,0x0060), &R);
decode_KKK_table(cpustate, BITS(op,0x0700), &D1, &D2, d_register->addr);
/* Can't do an R3 for S1 */
if (R.addr == &R3)
fatalerror("Dsp56k: Error. Dual x memory data read specified R3 as its first source!");
/* The note on A-142 is very interesting.
You can effectively access external memory in the last 64 bytes of X data memory! */
if (*((UINT16*)D2.addr) >= 0xffc0)
fatalerror("Dsp56k: Unimplemented access to external X Data Memory >= 0xffc0 in Dual X Memory Data Read.");
/* First memmove */
srcVal1 = memory_read_word_16le(cpustate->data, ADDRESS(*((UINT16*)R.addr)));
tempV.addr = &srcVal1;
tempV.data_type = DT_WORD;
SetDestinationValue(tempV, D1);
/* Second memmove */
srcVal2 = memory_read_word_16le(cpustate->data, ADDRESS(R3));
tempV.addr = &srcVal2;
tempV.data_type = DT_WORD;
SetDestinationValue(tempV, D2);
/* Touch up the R regs after all the moves */
execute_mm_table(cpustate, BITS(op,0x0060), BITS(op,0x1800));
} | /* Dual X Memory Data Read : 011m mKKK .rr. .... : A-142*/ | Dual X Memory Data Read : 011m mKKK .rr. | [
"Dual",
"X",
"Memory",
"Data",
"Read",
":",
"011m",
"mKKK",
".",
"rr",
"."
] | static void execute_dual_x_memory_data_read(dsp56k_core* cpustate, const UINT16 op, typed_pointer* d_register)
{
typed_pointer tempV;
UINT16 srcVal1 = 0x0000;
UINT16 srcVal2 = 0x0000;
typed_pointer R = {NULL, DT_BYTE};
typed_pointer D1 = {NULL, DT_BYTE};
typed_pointer D2 = {NULL, DT_BYTE};
decode_RR_table(cpustate, BITS(op,0x0060), &R);
decode_KKK_table(cpustate, BITS(op,0x0700), &D1, &D2, d_register->addr);
if (R.addr == &R3)
fatalerror("Dsp56k: Error. Dual x memory data read specified R3 as its first source!");
if (*((UINT16*)D2.addr) >= 0xffc0)
fatalerror("Dsp56k: Unimplemented access to external X Data Memory >= 0xffc0 in Dual X Memory Data Read.");
srcVal1 = memory_read_word_16le(cpustate->data, ADDRESS(*((UINT16*)R.addr)));
tempV.addr = &srcVal1;
tempV.data_type = DT_WORD;
SetDestinationValue(tempV, D1);
srcVal2 = memory_read_word_16le(cpustate->data, ADDRESS(R3));
tempV.addr = &srcVal2;
tempV.data_type = DT_WORD;
SetDestinationValue(tempV, D2);
execute_mm_table(cpustate, BITS(op,0x0060), BITS(op,0x1800));
} | [
"static",
"void",
"execute_dual_x_memory_data_read",
"(",
"dsp56k_core",
"*",
"cpustate",
",",
"const",
"UINT16",
"op",
",",
"typed_pointer",
"*",
"d_register",
")",
"{",
"typed_pointer",
"tempV",
";",
"UINT16",
"srcVal1",
"=",
"0x0000",
";",
"UINT16",
"srcVal2",
"=",
"0x0000",
";",
"typed_pointer",
"R",
"=",
"{",
"NULL",
",",
"DT_BYTE",
"}",
";",
"typed_pointer",
"D1",
"=",
"{",
"NULL",
",",
"DT_BYTE",
"}",
";",
"typed_pointer",
"D2",
"=",
"{",
"NULL",
",",
"DT_BYTE",
"}",
";",
"decode_RR_table",
"(",
"cpustate",
",",
"BITS",
"(",
"op",
",",
"0x0060",
")",
",",
"&",
"R",
")",
";",
"decode_KKK_table",
"(",
"cpustate",
",",
"BITS",
"(",
"op",
",",
"0x0700",
")",
",",
"&",
"D1",
",",
"&",
"D2",
",",
"d_register",
"->",
"addr",
")",
";",
"if",
"(",
"R",
".",
"addr",
"==",
"&",
"R3",
")",
"fatalerror",
"(",
"\"",
"\"",
")",
";",
"if",
"(",
"*",
"(",
"(",
"UINT16",
"*",
")",
"D2",
".",
"addr",
")",
">=",
"0xffc0",
")",
"fatalerror",
"(",
"\"",
"\"",
")",
";",
"srcVal1",
"=",
"memory_read_word_16le",
"(",
"cpustate",
"->",
"data",
",",
"ADDRESS",
"(",
"*",
"(",
"(",
"UINT16",
"*",
")",
"R",
".",
"addr",
")",
")",
")",
";",
"tempV",
".",
"addr",
"=",
"&",
"srcVal1",
";",
"tempV",
".",
"data_type",
"=",
"DT_WORD",
";",
"SetDestinationValue",
"(",
"tempV",
",",
"D1",
")",
";",
"srcVal2",
"=",
"memory_read_word_16le",
"(",
"cpustate",
"->",
"data",
",",
"ADDRESS",
"(",
"R3",
")",
")",
";",
"tempV",
".",
"addr",
"=",
"&",
"srcVal2",
";",
"tempV",
".",
"data_type",
"=",
"DT_WORD",
";",
"SetDestinationValue",
"(",
"tempV",
",",
"D2",
")",
";",
"execute_mm_table",
"(",
"cpustate",
",",
"BITS",
"(",
"op",
",",
"0x0060",
")",
",",
"BITS",
"(",
"op",
",",
"0x1800",
")",
")",
";",
"}"
] | Dual X Memory Data Read : 011m mKKK .rr. | [
"Dual",
"X",
"Memory",
"Data",
"Read",
":",
"011m",
"mKKK",
".",
"rr",
"."
] | [
"/* Can't do an R3 for S1 */",
"/* The note on A-142 is very interesting.\r\n You can effectively access external memory in the last 64 bytes of X data memory! */",
"/* First memmove */",
"/* Second memmove */",
"/* Touch up the R regs after all the moves */"
] | [
{
"param": "cpustate",
"type": "dsp56k_core"
},
{
"param": "op",
"type": "UINT16"
},
{
"param": "d_register",
"type": "typed_pointer"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpustate",
"type": "dsp56k_core",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "op",
"type": "UINT16",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "d_register",
"type": "typed_pointer",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | chd_open_file | chd_error | chd_error chd_open_file(core_file *file, int mode, chd_file *parent, chd_file **chd)
{
chd_file *newchd = NULL;
chd_error err;
int intfnum;
/* verify parameters */
if (file == NULL)
EARLY_EXIT(err = CHDERR_INVALID_PARAMETER);
/* punt if invalid parent */
if (parent != NULL && parent->cookie != COOKIE_VALUE)
EARLY_EXIT(err = CHDERR_INVALID_PARAMETER);
/* allocate memory for the final result */
newchd = (chd_file *)malloc(sizeof(**chd));
if (newchd == NULL)
EARLY_EXIT(err = CHDERR_OUT_OF_MEMORY);
memset(newchd, 0, sizeof(*newchd));
newchd->cookie = COOKIE_VALUE;
newchd->parent = parent;
newchd->file = file;
/* now attempt to read the header */
err = header_read(newchd->file, &newchd->header);
if (err != CHDERR_NONE)
EARLY_EXIT(err);
/* validate the header */
err = header_validate(&newchd->header);
if (err != CHDERR_NONE)
EARLY_EXIT(err);
/* make sure we don't open a read-only file writeable */
if (mode == CHD_OPEN_READWRITE && !(newchd->header.flags & CHDFLAGS_IS_WRITEABLE))
EARLY_EXIT(err = CHDERR_FILE_NOT_WRITEABLE);
/* also, never open an older version writeable */
if (mode == CHD_OPEN_READWRITE && newchd->header.version < CHD_HEADER_VERSION)
EARLY_EXIT(err = CHDERR_UNSUPPORTED_VERSION);
/* if we need a parent, make sure we have one */
if (parent == NULL && (newchd->header.flags & CHDFLAGS_HAS_PARENT))
EARLY_EXIT(err = CHDERR_REQUIRES_PARENT);
/* make sure we have a valid parent */
if (parent != NULL)
{
/* check MD5 if it isn't empty */
if (memcmp(nullmd5, newchd->header.parentmd5, sizeof(newchd->header.parentmd5)) != 0 &&
memcmp(nullmd5, newchd->parent->header.md5, sizeof(newchd->parent->header.md5)) != 0 &&
memcmp(newchd->parent->header.md5, newchd->header.parentmd5, sizeof(newchd->header.parentmd5)) != 0)
EARLY_EXIT(err = CHDERR_INVALID_PARENT);
/* check SHA1 if it isn't empty */
if (memcmp(nullsha1, newchd->header.parentsha1, sizeof(newchd->header.parentsha1)) != 0 &&
memcmp(nullsha1, newchd->parent->header.sha1, sizeof(newchd->parent->header.sha1)) != 0 &&
memcmp(newchd->parent->header.sha1, newchd->header.parentsha1, sizeof(newchd->header.parentsha1)) != 0)
EARLY_EXIT(err = CHDERR_INVALID_PARENT);
}
/* now read the hunk map */
err = map_read(newchd);
if (err != CHDERR_NONE)
EARLY_EXIT(err);
/* allocate and init the hunk cache */
newchd->cache = (UINT8 *)malloc(newchd->header.hunkbytes);
newchd->compare = (UINT8 *)malloc(newchd->header.hunkbytes);
if (newchd->cache == NULL || newchd->compare == NULL)
EARLY_EXIT(err = CHDERR_OUT_OF_MEMORY);
newchd->cachehunk = ~0;
newchd->comparehunk = ~0;
/* allocate the temporary compressed buffer */
newchd->compressed = (UINT8 *)malloc(newchd->header.hunkbytes);
if (newchd->compressed == NULL)
EARLY_EXIT(err = CHDERR_OUT_OF_MEMORY);
/* find the codec interface */
for (intfnum = 0; intfnum < ARRAY_LENGTH(codec_interfaces); intfnum++)
if (codec_interfaces[intfnum].compression == newchd->header.compression)
{
newchd->codecintf = &codec_interfaces[intfnum];
break;
}
if (intfnum == ARRAY_LENGTH(codec_interfaces))
EARLY_EXIT(err = CHDERR_UNSUPPORTED_FORMAT);
/* initialize the codec */
if (newchd->codecintf->init != NULL)
err = (*newchd->codecintf->init)(newchd);
if (err != CHDERR_NONE)
EARLY_EXIT(err);
/* all done */
*chd = newchd;
return CHDERR_NONE;
cleanup:
if (newchd != NULL)
chd_close(newchd);
return err;
} | /*-------------------------------------------------
chd_open_file - open a CHD file for access
-------------------------------------------------*/ | open a CHD file for access | [
"open",
"a",
"CHD",
"file",
"for",
"access"
] | chd_error chd_open_file(core_file *file, int mode, chd_file *parent, chd_file **chd)
{
chd_file *newchd = NULL;
chd_error err;
int intfnum;
if (file == NULL)
EARLY_EXIT(err = CHDERR_INVALID_PARAMETER);
if (parent != NULL && parent->cookie != COOKIE_VALUE)
EARLY_EXIT(err = CHDERR_INVALID_PARAMETER);
newchd = (chd_file *)malloc(sizeof(**chd));
if (newchd == NULL)
EARLY_EXIT(err = CHDERR_OUT_OF_MEMORY);
memset(newchd, 0, sizeof(*newchd));
newchd->cookie = COOKIE_VALUE;
newchd->parent = parent;
newchd->file = file;
err = header_read(newchd->file, &newchd->header);
if (err != CHDERR_NONE)
EARLY_EXIT(err);
err = header_validate(&newchd->header);
if (err != CHDERR_NONE)
EARLY_EXIT(err);
if (mode == CHD_OPEN_READWRITE && !(newchd->header.flags & CHDFLAGS_IS_WRITEABLE))
EARLY_EXIT(err = CHDERR_FILE_NOT_WRITEABLE);
if (mode == CHD_OPEN_READWRITE && newchd->header.version < CHD_HEADER_VERSION)
EARLY_EXIT(err = CHDERR_UNSUPPORTED_VERSION);
if (parent == NULL && (newchd->header.flags & CHDFLAGS_HAS_PARENT))
EARLY_EXIT(err = CHDERR_REQUIRES_PARENT);
if (parent != NULL)
{
if (memcmp(nullmd5, newchd->header.parentmd5, sizeof(newchd->header.parentmd5)) != 0 &&
memcmp(nullmd5, newchd->parent->header.md5, sizeof(newchd->parent->header.md5)) != 0 &&
memcmp(newchd->parent->header.md5, newchd->header.parentmd5, sizeof(newchd->header.parentmd5)) != 0)
EARLY_EXIT(err = CHDERR_INVALID_PARENT);
if (memcmp(nullsha1, newchd->header.parentsha1, sizeof(newchd->header.parentsha1)) != 0 &&
memcmp(nullsha1, newchd->parent->header.sha1, sizeof(newchd->parent->header.sha1)) != 0 &&
memcmp(newchd->parent->header.sha1, newchd->header.parentsha1, sizeof(newchd->header.parentsha1)) != 0)
EARLY_EXIT(err = CHDERR_INVALID_PARENT);
}
err = map_read(newchd);
if (err != CHDERR_NONE)
EARLY_EXIT(err);
newchd->cache = (UINT8 *)malloc(newchd->header.hunkbytes);
newchd->compare = (UINT8 *)malloc(newchd->header.hunkbytes);
if (newchd->cache == NULL || newchd->compare == NULL)
EARLY_EXIT(err = CHDERR_OUT_OF_MEMORY);
newchd->cachehunk = ~0;
newchd->comparehunk = ~0;
newchd->compressed = (UINT8 *)malloc(newchd->header.hunkbytes);
if (newchd->compressed == NULL)
EARLY_EXIT(err = CHDERR_OUT_OF_MEMORY);
for (intfnum = 0; intfnum < ARRAY_LENGTH(codec_interfaces); intfnum++)
if (codec_interfaces[intfnum].compression == newchd->header.compression)
{
newchd->codecintf = &codec_interfaces[intfnum];
break;
}
if (intfnum == ARRAY_LENGTH(codec_interfaces))
EARLY_EXIT(err = CHDERR_UNSUPPORTED_FORMAT);
if (newchd->codecintf->init != NULL)
err = (*newchd->codecintf->init)(newchd);
if (err != CHDERR_NONE)
EARLY_EXIT(err);
*chd = newchd;
return CHDERR_NONE;
cleanup:
if (newchd != NULL)
chd_close(newchd);
return err;
} | [
"chd_error",
"chd_open_file",
"(",
"core_file",
"*",
"file",
",",
"int",
"mode",
",",
"chd_file",
"*",
"parent",
",",
"chd_file",
"*",
"*",
"chd",
")",
"{",
"chd_file",
"*",
"newchd",
"=",
"NULL",
";",
"chd_error",
"err",
";",
"int",
"intfnum",
";",
"if",
"(",
"file",
"==",
"NULL",
")",
"EARLY_EXIT",
"(",
"err",
"=",
"CHDERR_INVALID_PARAMETER",
")",
";",
"if",
"(",
"parent",
"!=",
"NULL",
"&&",
"parent",
"->",
"cookie",
"!=",
"COOKIE_VALUE",
")",
"EARLY_EXIT",
"(",
"err",
"=",
"CHDERR_INVALID_PARAMETER",
")",
";",
"newchd",
"=",
"(",
"chd_file",
"*",
")",
"malloc",
"(",
"sizeof",
"(",
"*",
"*",
"chd",
")",
")",
";",
"if",
"(",
"newchd",
"==",
"NULL",
")",
"EARLY_EXIT",
"(",
"err",
"=",
"CHDERR_OUT_OF_MEMORY",
")",
";",
"memset",
"(",
"newchd",
",",
"0",
",",
"sizeof",
"(",
"*",
"newchd",
")",
")",
";",
"newchd",
"->",
"cookie",
"=",
"COOKIE_VALUE",
";",
"newchd",
"->",
"parent",
"=",
"parent",
";",
"newchd",
"->",
"file",
"=",
"file",
";",
"err",
"=",
"header_read",
"(",
"newchd",
"->",
"file",
",",
"&",
"newchd",
"->",
"header",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"EARLY_EXIT",
"(",
"err",
")",
";",
"err",
"=",
"header_validate",
"(",
"&",
"newchd",
"->",
"header",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"EARLY_EXIT",
"(",
"err",
")",
";",
"if",
"(",
"mode",
"==",
"CHD_OPEN_READWRITE",
"&&",
"!",
"(",
"newchd",
"->",
"header",
".",
"flags",
"&",
"CHDFLAGS_IS_WRITEABLE",
")",
")",
"EARLY_EXIT",
"(",
"err",
"=",
"CHDERR_FILE_NOT_WRITEABLE",
")",
";",
"if",
"(",
"mode",
"==",
"CHD_OPEN_READWRITE",
"&&",
"newchd",
"->",
"header",
".",
"version",
"<",
"CHD_HEADER_VERSION",
")",
"EARLY_EXIT",
"(",
"err",
"=",
"CHDERR_UNSUPPORTED_VERSION",
")",
";",
"if",
"(",
"parent",
"==",
"NULL",
"&&",
"(",
"newchd",
"->",
"header",
".",
"flags",
"&",
"CHDFLAGS_HAS_PARENT",
")",
")",
"EARLY_EXIT",
"(",
"err",
"=",
"CHDERR_REQUIRES_PARENT",
")",
";",
"if",
"(",
"parent",
"!=",
"NULL",
")",
"{",
"if",
"(",
"memcmp",
"(",
"nullmd5",
",",
"newchd",
"->",
"header",
".",
"parentmd5",
",",
"sizeof",
"(",
"newchd",
"->",
"header",
".",
"parentmd5",
")",
")",
"!=",
"0",
"&&",
"memcmp",
"(",
"nullmd5",
",",
"newchd",
"->",
"parent",
"->",
"header",
".",
"md5",
",",
"sizeof",
"(",
"newchd",
"->",
"parent",
"->",
"header",
".",
"md5",
")",
")",
"!=",
"0",
"&&",
"memcmp",
"(",
"newchd",
"->",
"parent",
"->",
"header",
".",
"md5",
",",
"newchd",
"->",
"header",
".",
"parentmd5",
",",
"sizeof",
"(",
"newchd",
"->",
"header",
".",
"parentmd5",
")",
")",
"!=",
"0",
")",
"EARLY_EXIT",
"(",
"err",
"=",
"CHDERR_INVALID_PARENT",
")",
";",
"if",
"(",
"memcmp",
"(",
"nullsha1",
",",
"newchd",
"->",
"header",
".",
"parentsha1",
",",
"sizeof",
"(",
"newchd",
"->",
"header",
".",
"parentsha1",
")",
")",
"!=",
"0",
"&&",
"memcmp",
"(",
"nullsha1",
",",
"newchd",
"->",
"parent",
"->",
"header",
".",
"sha1",
",",
"sizeof",
"(",
"newchd",
"->",
"parent",
"->",
"header",
".",
"sha1",
")",
")",
"!=",
"0",
"&&",
"memcmp",
"(",
"newchd",
"->",
"parent",
"->",
"header",
".",
"sha1",
",",
"newchd",
"->",
"header",
".",
"parentsha1",
",",
"sizeof",
"(",
"newchd",
"->",
"header",
".",
"parentsha1",
")",
")",
"!=",
"0",
")",
"EARLY_EXIT",
"(",
"err",
"=",
"CHDERR_INVALID_PARENT",
")",
";",
"}",
"err",
"=",
"map_read",
"(",
"newchd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"EARLY_EXIT",
"(",
"err",
")",
";",
"newchd",
"->",
"cache",
"=",
"(",
"UINT8",
"*",
")",
"malloc",
"(",
"newchd",
"->",
"header",
".",
"hunkbytes",
")",
";",
"newchd",
"->",
"compare",
"=",
"(",
"UINT8",
"*",
")",
"malloc",
"(",
"newchd",
"->",
"header",
".",
"hunkbytes",
")",
";",
"if",
"(",
"newchd",
"->",
"cache",
"==",
"NULL",
"||",
"newchd",
"->",
"compare",
"==",
"NULL",
")",
"EARLY_EXIT",
"(",
"err",
"=",
"CHDERR_OUT_OF_MEMORY",
")",
";",
"newchd",
"->",
"cachehunk",
"=",
"~",
"0",
";",
"newchd",
"->",
"comparehunk",
"=",
"~",
"0",
";",
"newchd",
"->",
"compressed",
"=",
"(",
"UINT8",
"*",
")",
"malloc",
"(",
"newchd",
"->",
"header",
".",
"hunkbytes",
")",
";",
"if",
"(",
"newchd",
"->",
"compressed",
"==",
"NULL",
")",
"EARLY_EXIT",
"(",
"err",
"=",
"CHDERR_OUT_OF_MEMORY",
")",
";",
"for",
"(",
"intfnum",
"=",
"0",
";",
"intfnum",
"<",
"ARRAY_LENGTH",
"(",
"codec_interfaces",
")",
";",
"intfnum",
"++",
")",
"if",
"(",
"codec_interfaces",
"[",
"intfnum",
"]",
".",
"compression",
"==",
"newchd",
"->",
"header",
".",
"compression",
")",
"{",
"newchd",
"->",
"codecintf",
"=",
"&",
"codec_interfaces",
"[",
"intfnum",
"]",
";",
"break",
";",
"}",
"if",
"(",
"intfnum",
"==",
"ARRAY_LENGTH",
"(",
"codec_interfaces",
")",
")",
"EARLY_EXIT",
"(",
"err",
"=",
"CHDERR_UNSUPPORTED_FORMAT",
")",
";",
"if",
"(",
"newchd",
"->",
"codecintf",
"->",
"init",
"!=",
"NULL",
")",
"err",
"=",
"(",
"*",
"newchd",
"->",
"codecintf",
"->",
"init",
")",
"(",
"newchd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"EARLY_EXIT",
"(",
"err",
")",
";",
"*",
"chd",
"=",
"newchd",
";",
"return",
"CHDERR_NONE",
";",
"cleanup",
":",
"if",
"(",
"newchd",
"!=",
"NULL",
")",
"chd_close",
"(",
"newchd",
")",
";",
"return",
"err",
";",
"}"
] | chd_open_file - open a CHD file for access | [
"chd_open_file",
"-",
"open",
"a",
"CHD",
"file",
"for",
"access"
] | [
"/* verify parameters */",
"/* punt if invalid parent */",
"/* allocate memory for the final result */",
"/* now attempt to read the header */",
"/* validate the header */",
"/* make sure we don't open a read-only file writeable */",
"/* also, never open an older version writeable */",
"/* if we need a parent, make sure we have one */",
"/* make sure we have a valid parent */",
"/* check MD5 if it isn't empty */",
"/* check SHA1 if it isn't empty */",
"/* now read the hunk map */",
"/* allocate and init the hunk cache */",
"/* allocate the temporary compressed buffer */",
"/* find the codec interface */",
"/* initialize the codec */",
"/* all done */"
] | [
{
"param": "file",
"type": "core_file"
},
{
"param": "mode",
"type": "int"
},
{
"param": "parent",
"type": "chd_file"
},
{
"param": "chd",
"type": "chd_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": "core_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mode",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "parent",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | chd_create | chd_error | chd_error chd_create(const char *filename, UINT64 logicalbytes, UINT32 hunkbytes, UINT32 compression, chd_file *parent)
{
core_file *file = NULL;
file_error filerr;
chd_error chderr;
filerr = core_fopen(filename, OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &file);
if (filerr != FILERR_NONE)
{
chderr = CHDERR_FILE_NOT_FOUND;
goto cleanup;
}
chderr = chd_create_file(file, logicalbytes, hunkbytes, compression, parent);
if (chderr != CHDERR_NONE)
goto cleanup;
cleanup:
if (file != NULL)
core_fclose(file);
return chderr;
} | /*-------------------------------------------------
chd_create - create a CHD file by
filename
-------------------------------------------------*/ | create a CHD file by
filename | [
"create",
"a",
"CHD",
"file",
"by",
"filename"
] | chd_error chd_create(const char *filename, UINT64 logicalbytes, UINT32 hunkbytes, UINT32 compression, chd_file *parent)
{
core_file *file = NULL;
file_error filerr;
chd_error chderr;
filerr = core_fopen(filename, OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &file);
if (filerr != FILERR_NONE)
{
chderr = CHDERR_FILE_NOT_FOUND;
goto cleanup;
}
chderr = chd_create_file(file, logicalbytes, hunkbytes, compression, parent);
if (chderr != CHDERR_NONE)
goto cleanup;
cleanup:
if (file != NULL)
core_fclose(file);
return chderr;
} | [
"chd_error",
"chd_create",
"(",
"const",
"char",
"*",
"filename",
",",
"UINT64",
"logicalbytes",
",",
"UINT32",
"hunkbytes",
",",
"UINT32",
"compression",
",",
"chd_file",
"*",
"parent",
")",
"{",
"core_file",
"*",
"file",
"=",
"NULL",
";",
"file_error",
"filerr",
";",
"chd_error",
"chderr",
";",
"filerr",
"=",
"core_fopen",
"(",
"filename",
",",
"OPEN_FLAG_READ",
"|",
"OPEN_FLAG_WRITE",
"|",
"OPEN_FLAG_CREATE",
",",
"&",
"file",
")",
";",
"if",
"(",
"filerr",
"!=",
"FILERR_NONE",
")",
"{",
"chderr",
"=",
"CHDERR_FILE_NOT_FOUND",
";",
"goto",
"cleanup",
";",
"}",
"chderr",
"=",
"chd_create_file",
"(",
"file",
",",
"logicalbytes",
",",
"hunkbytes",
",",
"compression",
",",
"parent",
")",
";",
"if",
"(",
"chderr",
"!=",
"CHDERR_NONE",
")",
"goto",
"cleanup",
";",
"cleanup",
":",
"if",
"(",
"file",
"!=",
"NULL",
")",
"core_fclose",
"(",
"file",
")",
";",
"return",
"chderr",
";",
"}"
] | chd_create - create a CHD file by
filename | [
"chd_create",
"-",
"create",
"a",
"CHD",
"file",
"by",
"filename"
] | [] | [
{
"param": "filename",
"type": "char"
},
{
"param": "logicalbytes",
"type": "UINT64"
},
{
"param": "hunkbytes",
"type": "UINT32"
},
{
"param": "compression",
"type": "UINT32"
},
{
"param": "parent",
"type": "chd_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "logicalbytes",
"type": "UINT64",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "hunkbytes",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "compression",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "parent",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | chd_open | chd_error | chd_error chd_open(const char *filename, int mode, chd_file *parent, chd_file **chd)
{
chd_error err;
file_error filerr;
core_file *file = NULL;
UINT32 openflags;
/* choose the proper mode */
switch(mode)
{
case CHD_OPEN_READ:
openflags = OPEN_FLAG_READ;
break;
case CHD_OPEN_READWRITE:
openflags = OPEN_FLAG_READ | OPEN_FLAG_WRITE;
break;
default:
err = CHDERR_INVALID_PARAMETER;
goto cleanup;
}
/* open the file */
filerr = core_fopen(filename, openflags, &file);
if (filerr != FILERR_NONE)
{
err = CHDERR_FILE_NOT_FOUND;
goto cleanup;
}
/* now open the CHD */
err = chd_open_file(file, mode, parent, chd);
if (err != CHDERR_NONE)
goto cleanup;
/* we now own this file */
(*chd)->owns_file = TRUE;
cleanup:
if ((err != CHDERR_NONE) && (file != NULL))
core_fclose(file);
return err;
} | /*-------------------------------------------------
chd_open - open a CHD file by
filename
-------------------------------------------------*/ | open a CHD file by
filename | [
"open",
"a",
"CHD",
"file",
"by",
"filename"
] | chd_error chd_open(const char *filename, int mode, chd_file *parent, chd_file **chd)
{
chd_error err;
file_error filerr;
core_file *file = NULL;
UINT32 openflags;
switch(mode)
{
case CHD_OPEN_READ:
openflags = OPEN_FLAG_READ;
break;
case CHD_OPEN_READWRITE:
openflags = OPEN_FLAG_READ | OPEN_FLAG_WRITE;
break;
default:
err = CHDERR_INVALID_PARAMETER;
goto cleanup;
}
filerr = core_fopen(filename, openflags, &file);
if (filerr != FILERR_NONE)
{
err = CHDERR_FILE_NOT_FOUND;
goto cleanup;
}
err = chd_open_file(file, mode, parent, chd);
if (err != CHDERR_NONE)
goto cleanup;
(*chd)->owns_file = TRUE;
cleanup:
if ((err != CHDERR_NONE) && (file != NULL))
core_fclose(file);
return err;
} | [
"chd_error",
"chd_open",
"(",
"const",
"char",
"*",
"filename",
",",
"int",
"mode",
",",
"chd_file",
"*",
"parent",
",",
"chd_file",
"*",
"*",
"chd",
")",
"{",
"chd_error",
"err",
";",
"file_error",
"filerr",
";",
"core_file",
"*",
"file",
"=",
"NULL",
";",
"UINT32",
"openflags",
";",
"switch",
"(",
"mode",
")",
"{",
"case",
"CHD_OPEN_READ",
":",
"openflags",
"=",
"OPEN_FLAG_READ",
";",
"break",
";",
"case",
"CHD_OPEN_READWRITE",
":",
"openflags",
"=",
"OPEN_FLAG_READ",
"|",
"OPEN_FLAG_WRITE",
";",
"break",
";",
"default",
":",
"err",
"=",
"CHDERR_INVALID_PARAMETER",
";",
"goto",
"cleanup",
";",
"}",
"filerr",
"=",
"core_fopen",
"(",
"filename",
",",
"openflags",
",",
"&",
"file",
")",
";",
"if",
"(",
"filerr",
"!=",
"FILERR_NONE",
")",
"{",
"err",
"=",
"CHDERR_FILE_NOT_FOUND",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"chd_open_file",
"(",
"file",
",",
"mode",
",",
"parent",
",",
"chd",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"goto",
"cleanup",
";",
"(",
"*",
"chd",
")",
"->",
"owns_file",
"=",
"TRUE",
";",
"cleanup",
":",
"if",
"(",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"&&",
"(",
"file",
"!=",
"NULL",
")",
")",
"core_fclose",
"(",
"file",
")",
";",
"return",
"err",
";",
"}"
] | chd_open - open a CHD file by
filename | [
"chd_open",
"-",
"open",
"a",
"CHD",
"file",
"by",
"filename"
] | [
"/* choose the proper mode */",
"/* open the file */",
"/* now open the CHD */",
"/* we now own this file */"
] | [
{
"param": "filename",
"type": "char"
},
{
"param": "mode",
"type": "int"
},
{
"param": "parent",
"type": "chd_file"
},
{
"param": "chd",
"type": "chd_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mode",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "parent",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | chd_close | void | void chd_close(chd_file *chd)
{
/* punt if NULL or invalid */
if (chd == NULL || chd->cookie != COOKIE_VALUE)
return;
/* wait for any pending async operations */
wait_for_pending_async(chd);
/* kill the work queue and any work item */
if (chd->workitem != NULL)
osd_work_item_release(chd->workitem);
if (chd->workqueue != NULL)
osd_work_queue_free(chd->workqueue);
/* deinit the codec */
if (chd->codecintf != NULL && chd->codecintf->free != NULL)
(*chd->codecintf->free)(chd);
/* free the compressed data buffer */
if (chd->compressed != NULL)
free(chd->compressed);
/* free the hunk cache and compare data */
if (chd->compare != NULL)
free(chd->compare);
if (chd->cache != NULL)
free(chd->cache);
/* free the hunk map */
if (chd->map != NULL)
free(chd->map);
/* free the CRC table */
if (chd->crctable != NULL)
free(chd->crctable);
/* free the CRC map */
if (chd->crcmap != NULL)
free(chd->crcmap);
/* close the file */
if (chd->owns_file && chd->file != NULL)
core_fclose(chd->file);
if (PRINTF_MAX_HUNK) printf("Max hunk = %d/%d\n", chd->maxhunk, chd->header.totalhunks);
/* free our memory */
free(chd);
} | /*-------------------------------------------------
chd_close - close a CHD file for access
-------------------------------------------------*/ | close a CHD file for access | [
"close",
"a",
"CHD",
"file",
"for",
"access"
] | void chd_close(chd_file *chd)
{
if (chd == NULL || chd->cookie != COOKIE_VALUE)
return;
wait_for_pending_async(chd);
if (chd->workitem != NULL)
osd_work_item_release(chd->workitem);
if (chd->workqueue != NULL)
osd_work_queue_free(chd->workqueue);
if (chd->codecintf != NULL && chd->codecintf->free != NULL)
(*chd->codecintf->free)(chd);
if (chd->compressed != NULL)
free(chd->compressed);
if (chd->compare != NULL)
free(chd->compare);
if (chd->cache != NULL)
free(chd->cache);
if (chd->map != NULL)
free(chd->map);
if (chd->crctable != NULL)
free(chd->crctable);
if (chd->crcmap != NULL)
free(chd->crcmap);
if (chd->owns_file && chd->file != NULL)
core_fclose(chd->file);
if (PRINTF_MAX_HUNK) printf("Max hunk = %d/%d\n", chd->maxhunk, chd->header.totalhunks);
free(chd);
} | [
"void",
"chd_close",
"(",
"chd_file",
"*",
"chd",
")",
"{",
"if",
"(",
"chd",
"==",
"NULL",
"||",
"chd",
"->",
"cookie",
"!=",
"COOKIE_VALUE",
")",
"return",
";",
"wait_for_pending_async",
"(",
"chd",
")",
";",
"if",
"(",
"chd",
"->",
"workitem",
"!=",
"NULL",
")",
"osd_work_item_release",
"(",
"chd",
"->",
"workitem",
")",
";",
"if",
"(",
"chd",
"->",
"workqueue",
"!=",
"NULL",
")",
"osd_work_queue_free",
"(",
"chd",
"->",
"workqueue",
")",
";",
"if",
"(",
"chd",
"->",
"codecintf",
"!=",
"NULL",
"&&",
"chd",
"->",
"codecintf",
"->",
"free",
"!=",
"NULL",
")",
"(",
"*",
"chd",
"->",
"codecintf",
"->",
"free",
")",
"(",
"chd",
")",
";",
"if",
"(",
"chd",
"->",
"compressed",
"!=",
"NULL",
")",
"free",
"(",
"chd",
"->",
"compressed",
")",
";",
"if",
"(",
"chd",
"->",
"compare",
"!=",
"NULL",
")",
"free",
"(",
"chd",
"->",
"compare",
")",
";",
"if",
"(",
"chd",
"->",
"cache",
"!=",
"NULL",
")",
"free",
"(",
"chd",
"->",
"cache",
")",
";",
"if",
"(",
"chd",
"->",
"map",
"!=",
"NULL",
")",
"free",
"(",
"chd",
"->",
"map",
")",
";",
"if",
"(",
"chd",
"->",
"crctable",
"!=",
"NULL",
")",
"free",
"(",
"chd",
"->",
"crctable",
")",
";",
"if",
"(",
"chd",
"->",
"crcmap",
"!=",
"NULL",
")",
"free",
"(",
"chd",
"->",
"crcmap",
")",
";",
"if",
"(",
"chd",
"->",
"owns_file",
"&&",
"chd",
"->",
"file",
"!=",
"NULL",
")",
"core_fclose",
"(",
"chd",
"->",
"file",
")",
";",
"if",
"(",
"PRINTF_MAX_HUNK",
")",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"chd",
"->",
"maxhunk",
",",
"chd",
"->",
"header",
".",
"totalhunks",
")",
";",
"free",
"(",
"chd",
")",
";",
"}"
] | chd_close - close a CHD file for access | [
"chd_close",
"-",
"close",
"a",
"CHD",
"file",
"for",
"access"
] | [
"/* punt if NULL or invalid */",
"/* wait for any pending async operations */",
"/* kill the work queue and any work item */",
"/* deinit the codec */",
"/* free the compressed data buffer */",
"/* free the hunk cache and compare data */",
"/* free the hunk map */",
"/* free the CRC table */",
"/* free the CRC map */",
"/* close the file */",
"/* free our memory */"
] | [
{
"param": "chd",
"type": "chd_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | chd_error_string | char | const char *chd_error_string(chd_error err)
{
switch (err)
{
case CHDERR_NONE: return "no error";
case CHDERR_NO_INTERFACE: return "no drive interface";
case CHDERR_OUT_OF_MEMORY: return "out of memory";
case CHDERR_INVALID_FILE: return "invalid file";
case CHDERR_INVALID_PARAMETER: return "invalid parameter";
case CHDERR_INVALID_DATA: return "invalid data";
case CHDERR_FILE_NOT_FOUND: return "file not found";
case CHDERR_REQUIRES_PARENT: return "requires parent";
case CHDERR_FILE_NOT_WRITEABLE: return "file not writeable";
case CHDERR_READ_ERROR: return "read error";
case CHDERR_WRITE_ERROR: return "write error";
case CHDERR_CODEC_ERROR: return "codec error";
case CHDERR_INVALID_PARENT: return "invalid parent";
case CHDERR_HUNK_OUT_OF_RANGE: return "hunk out of range";
case CHDERR_DECOMPRESSION_ERROR: return "decompression error";
case CHDERR_COMPRESSION_ERROR: return "compression error";
case CHDERR_CANT_CREATE_FILE: return "can't create file";
case CHDERR_CANT_VERIFY: return "can't verify file";
case CHDERR_NOT_SUPPORTED: return "operation not supported";
case CHDERR_METADATA_NOT_FOUND: return "can't find metadata";
case CHDERR_INVALID_METADATA_SIZE: return "invalid metadata size";
case CHDERR_UNSUPPORTED_VERSION: return "unsupported CHD version";
case CHDERR_VERIFY_INCOMPLETE: return "incomplete verify";
case CHDERR_INVALID_METADATA: return "invalid metadata";
case CHDERR_INVALID_STATE: return "invalid state";
case CHDERR_OPERATION_PENDING: return "operation pending";
case CHDERR_NO_ASYNC_OPERATION: return "no async operation in progress";
case CHDERR_UNSUPPORTED_FORMAT: return "unsupported format";
default: return "undocumented error";
}
} | /*-------------------------------------------------
chd_error_string - return an error string for
the given CHD error
-------------------------------------------------*/ | return an error string for
the given CHD error | [
"return",
"an",
"error",
"string",
"for",
"the",
"given",
"CHD",
"error"
] | const char *chd_error_string(chd_error err)
{
switch (err)
{
case CHDERR_NONE: return "no error";
case CHDERR_NO_INTERFACE: return "no drive interface";
case CHDERR_OUT_OF_MEMORY: return "out of memory";
case CHDERR_INVALID_FILE: return "invalid file";
case CHDERR_INVALID_PARAMETER: return "invalid parameter";
case CHDERR_INVALID_DATA: return "invalid data";
case CHDERR_FILE_NOT_FOUND: return "file not found";
case CHDERR_REQUIRES_PARENT: return "requires parent";
case CHDERR_FILE_NOT_WRITEABLE: return "file not writeable";
case CHDERR_READ_ERROR: return "read error";
case CHDERR_WRITE_ERROR: return "write error";
case CHDERR_CODEC_ERROR: return "codec error";
case CHDERR_INVALID_PARENT: return "invalid parent";
case CHDERR_HUNK_OUT_OF_RANGE: return "hunk out of range";
case CHDERR_DECOMPRESSION_ERROR: return "decompression error";
case CHDERR_COMPRESSION_ERROR: return "compression error";
case CHDERR_CANT_CREATE_FILE: return "can't create file";
case CHDERR_CANT_VERIFY: return "can't verify file";
case CHDERR_NOT_SUPPORTED: return "operation not supported";
case CHDERR_METADATA_NOT_FOUND: return "can't find metadata";
case CHDERR_INVALID_METADATA_SIZE: return "invalid metadata size";
case CHDERR_UNSUPPORTED_VERSION: return "unsupported CHD version";
case CHDERR_VERIFY_INCOMPLETE: return "incomplete verify";
case CHDERR_INVALID_METADATA: return "invalid metadata";
case CHDERR_INVALID_STATE: return "invalid state";
case CHDERR_OPERATION_PENDING: return "operation pending";
case CHDERR_NO_ASYNC_OPERATION: return "no async operation in progress";
case CHDERR_UNSUPPORTED_FORMAT: return "unsupported format";
default: return "undocumented error";
}
} | [
"const",
"char",
"*",
"chd_error_string",
"(",
"chd_error",
"err",
")",
"{",
"switch",
"(",
"err",
")",
"{",
"case",
"CHDERR_NONE",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_NO_INTERFACE",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_OUT_OF_MEMORY",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_INVALID_FILE",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_INVALID_PARAMETER",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_INVALID_DATA",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_FILE_NOT_FOUND",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_REQUIRES_PARENT",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_FILE_NOT_WRITEABLE",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_READ_ERROR",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_WRITE_ERROR",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_CODEC_ERROR",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_INVALID_PARENT",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_HUNK_OUT_OF_RANGE",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_DECOMPRESSION_ERROR",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_COMPRESSION_ERROR",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_CANT_CREATE_FILE",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_CANT_VERIFY",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_NOT_SUPPORTED",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_METADATA_NOT_FOUND",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_INVALID_METADATA_SIZE",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_UNSUPPORTED_VERSION",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_VERIFY_INCOMPLETE",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_INVALID_METADATA",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_INVALID_STATE",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_OPERATION_PENDING",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_NO_ASYNC_OPERATION",
":",
"return",
"\"",
"\"",
";",
"case",
"CHDERR_UNSUPPORTED_FORMAT",
":",
"return",
"\"",
"\"",
";",
"default",
":",
"return",
"\"",
"\"",
";",
"}",
"}"
] | chd_error_string - return an error string for
the given CHD error | [
"chd_error_string",
"-",
"return",
"an",
"error",
"string",
"for",
"the",
"given",
"CHD",
"error"
] | [] | [
{
"param": "err",
"type": "chd_error"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "err",
"type": "chd_error",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | chd_get_header | chd_header | const chd_header *chd_get_header(chd_file *chd)
{
/* punt if NULL or invalid */
if (chd == NULL || chd->cookie != COOKIE_VALUE)
return NULL;
return &chd->header;
} | /*-------------------------------------------------
chd_get_header - return a pointer to the
extracted header data
-------------------------------------------------*/ | return a pointer to the
extracted header data | [
"return",
"a",
"pointer",
"to",
"the",
"extracted",
"header",
"data"
] | const chd_header *chd_get_header(chd_file *chd)
{
if (chd == NULL || chd->cookie != COOKIE_VALUE)
return NULL;
return &chd->header;
} | [
"const",
"chd_header",
"*",
"chd_get_header",
"(",
"chd_file",
"*",
"chd",
")",
"{",
"if",
"(",
"chd",
"==",
"NULL",
"||",
"chd",
"->",
"cookie",
"!=",
"COOKIE_VALUE",
")",
"return",
"NULL",
";",
"return",
"&",
"chd",
"->",
"header",
";",
"}"
] | chd_get_header - return a pointer to the
extracted header data | [
"chd_get_header",
"-",
"return",
"a",
"pointer",
"to",
"the",
"extracted",
"header",
"data"
] | [
"/* punt if NULL or invalid */"
] | [
{
"param": "chd",
"type": "chd_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | chd_set_header_file | chd_error | chd_error chd_set_header_file(core_file *file, const chd_header *header)
{
chd_header oldheader;
chd_error err;
/* validate the header */
err = header_validate(header);
if (err != CHDERR_NONE)
EARLY_EXIT(err);
/* read the old header */
err = header_read(file, &oldheader);
if (err != CHDERR_NONE)
EARLY_EXIT(err);
/* make sure we're only making valid changes */
if (header->length != oldheader.length)
EARLY_EXIT(err = CHDERR_INVALID_PARAMETER);
if (header->version != oldheader.version)
EARLY_EXIT(err = CHDERR_INVALID_PARAMETER);
if (header->compression != oldheader.compression)
EARLY_EXIT(err = CHDERR_INVALID_PARAMETER);
if (header->hunkbytes != oldheader.hunkbytes)
EARLY_EXIT(err = CHDERR_INVALID_PARAMETER);
if (header->totalhunks != oldheader.totalhunks)
EARLY_EXIT(err = CHDERR_INVALID_PARAMETER);
if (header->metaoffset != oldheader.metaoffset)
EARLY_EXIT(err = CHDERR_INVALID_PARAMETER);
if (header->obsolete_hunksize != oldheader.obsolete_hunksize)
EARLY_EXIT(err = CHDERR_INVALID_PARAMETER);
/* write the new header */
err = header_write(file, header);
if (err != CHDERR_NONE)
EARLY_EXIT(err);
return CHDERR_NONE;
cleanup:
return err;
} | /*-------------------------------------------------
chd_set_header_file - write the current header to
the file
-------------------------------------------------*/ | write the current header to
the file | [
"write",
"the",
"current",
"header",
"to",
"the",
"file"
] | chd_error chd_set_header_file(core_file *file, const chd_header *header)
{
chd_header oldheader;
chd_error err;
err = header_validate(header);
if (err != CHDERR_NONE)
EARLY_EXIT(err);
err = header_read(file, &oldheader);
if (err != CHDERR_NONE)
EARLY_EXIT(err);
if (header->length != oldheader.length)
EARLY_EXIT(err = CHDERR_INVALID_PARAMETER);
if (header->version != oldheader.version)
EARLY_EXIT(err = CHDERR_INVALID_PARAMETER);
if (header->compression != oldheader.compression)
EARLY_EXIT(err = CHDERR_INVALID_PARAMETER);
if (header->hunkbytes != oldheader.hunkbytes)
EARLY_EXIT(err = CHDERR_INVALID_PARAMETER);
if (header->totalhunks != oldheader.totalhunks)
EARLY_EXIT(err = CHDERR_INVALID_PARAMETER);
if (header->metaoffset != oldheader.metaoffset)
EARLY_EXIT(err = CHDERR_INVALID_PARAMETER);
if (header->obsolete_hunksize != oldheader.obsolete_hunksize)
EARLY_EXIT(err = CHDERR_INVALID_PARAMETER);
err = header_write(file, header);
if (err != CHDERR_NONE)
EARLY_EXIT(err);
return CHDERR_NONE;
cleanup:
return err;
} | [
"chd_error",
"chd_set_header_file",
"(",
"core_file",
"*",
"file",
",",
"const",
"chd_header",
"*",
"header",
")",
"{",
"chd_header",
"oldheader",
";",
"chd_error",
"err",
";",
"err",
"=",
"header_validate",
"(",
"header",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"EARLY_EXIT",
"(",
"err",
")",
";",
"err",
"=",
"header_read",
"(",
"file",
",",
"&",
"oldheader",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"EARLY_EXIT",
"(",
"err",
")",
";",
"if",
"(",
"header",
"->",
"length",
"!=",
"oldheader",
".",
"length",
")",
"EARLY_EXIT",
"(",
"err",
"=",
"CHDERR_INVALID_PARAMETER",
")",
";",
"if",
"(",
"header",
"->",
"version",
"!=",
"oldheader",
".",
"version",
")",
"EARLY_EXIT",
"(",
"err",
"=",
"CHDERR_INVALID_PARAMETER",
")",
";",
"if",
"(",
"header",
"->",
"compression",
"!=",
"oldheader",
".",
"compression",
")",
"EARLY_EXIT",
"(",
"err",
"=",
"CHDERR_INVALID_PARAMETER",
")",
";",
"if",
"(",
"header",
"->",
"hunkbytes",
"!=",
"oldheader",
".",
"hunkbytes",
")",
"EARLY_EXIT",
"(",
"err",
"=",
"CHDERR_INVALID_PARAMETER",
")",
";",
"if",
"(",
"header",
"->",
"totalhunks",
"!=",
"oldheader",
".",
"totalhunks",
")",
"EARLY_EXIT",
"(",
"err",
"=",
"CHDERR_INVALID_PARAMETER",
")",
";",
"if",
"(",
"header",
"->",
"metaoffset",
"!=",
"oldheader",
".",
"metaoffset",
")",
"EARLY_EXIT",
"(",
"err",
"=",
"CHDERR_INVALID_PARAMETER",
")",
";",
"if",
"(",
"header",
"->",
"obsolete_hunksize",
"!=",
"oldheader",
".",
"obsolete_hunksize",
")",
"EARLY_EXIT",
"(",
"err",
"=",
"CHDERR_INVALID_PARAMETER",
")",
";",
"err",
"=",
"header_write",
"(",
"file",
",",
"header",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"EARLY_EXIT",
"(",
"err",
")",
";",
"return",
"CHDERR_NONE",
";",
"cleanup",
":",
"return",
"err",
";",
"}"
] | chd_set_header_file - write the current header to
the file | [
"chd_set_header_file",
"-",
"write",
"the",
"current",
"header",
"to",
"the",
"file"
] | [
"/* validate the header */",
"/* read the old header */",
"/* make sure we're only making valid changes */",
"/* write the new header */"
] | [
{
"param": "file",
"type": "core_file"
},
{
"param": "header",
"type": "chd_header"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": "core_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "header",
"type": "chd_header",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | chd_set_header | chd_error | chd_error chd_set_header(const char *filename, const chd_header *header)
{
core_file *file = NULL;
file_error filerr;
chd_error err;
filerr = core_fopen(filename, OPEN_FLAG_READ | OPEN_FLAG_WRITE, &file);
if (filerr != FILERR_NONE)
{
err = CHDERR_FILE_NOT_FOUND;
goto cleanup;
}
err = chd_set_header_file(file, header);
if (err != CHDERR_NONE)
goto cleanup;
cleanup:
if (file != NULL)
core_fclose(file);
return err;
} | /*-------------------------------------------------
chd_set_header - write the current
header to the file
-------------------------------------------------*/ | write the current
header to the file | [
"write",
"the",
"current",
"header",
"to",
"the",
"file"
] | chd_error chd_set_header(const char *filename, const chd_header *header)
{
core_file *file = NULL;
file_error filerr;
chd_error err;
filerr = core_fopen(filename, OPEN_FLAG_READ | OPEN_FLAG_WRITE, &file);
if (filerr != FILERR_NONE)
{
err = CHDERR_FILE_NOT_FOUND;
goto cleanup;
}
err = chd_set_header_file(file, header);
if (err != CHDERR_NONE)
goto cleanup;
cleanup:
if (file != NULL)
core_fclose(file);
return err;
} | [
"chd_error",
"chd_set_header",
"(",
"const",
"char",
"*",
"filename",
",",
"const",
"chd_header",
"*",
"header",
")",
"{",
"core_file",
"*",
"file",
"=",
"NULL",
";",
"file_error",
"filerr",
";",
"chd_error",
"err",
";",
"filerr",
"=",
"core_fopen",
"(",
"filename",
",",
"OPEN_FLAG_READ",
"|",
"OPEN_FLAG_WRITE",
",",
"&",
"file",
")",
";",
"if",
"(",
"filerr",
"!=",
"FILERR_NONE",
")",
"{",
"err",
"=",
"CHDERR_FILE_NOT_FOUND",
";",
"goto",
"cleanup",
";",
"}",
"err",
"=",
"chd_set_header_file",
"(",
"file",
",",
"header",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"goto",
"cleanup",
";",
"cleanup",
":",
"if",
"(",
"file",
"!=",
"NULL",
")",
"core_fclose",
"(",
"file",
")",
";",
"return",
"err",
";",
"}"
] | chd_set_header - write the current
header to the file | [
"chd_set_header",
"-",
"write",
"the",
"current",
"header",
"to",
"the",
"file"
] | [] | [
{
"param": "filename",
"type": "char"
},
{
"param": "header",
"type": "chd_header"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "header",
"type": "chd_header",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | chd_read | chd_error | chd_error chd_read(chd_file *chd, UINT32 hunknum, void *buffer)
{
/* punt if NULL or invalid */
if (chd == NULL || chd->cookie != COOKIE_VALUE)
return CHDERR_INVALID_PARAMETER;
/* if we're past the end, fail */
if (hunknum >= chd->header.totalhunks)
return CHDERR_HUNK_OUT_OF_RANGE;
/* wait for any pending async operations */
wait_for_pending_async(chd);
/* perform the read */
return hunk_read_into_memory(chd, hunknum, (UINT8 *)buffer);
} | /*-------------------------------------------------
chd_read - read a single hunk from the CHD
file
-------------------------------------------------*/ | read a single hunk from the CHD
file | [
"read",
"a",
"single",
"hunk",
"from",
"the",
"CHD",
"file"
] | chd_error chd_read(chd_file *chd, UINT32 hunknum, void *buffer)
{
if (chd == NULL || chd->cookie != COOKIE_VALUE)
return CHDERR_INVALID_PARAMETER;
if (hunknum >= chd->header.totalhunks)
return CHDERR_HUNK_OUT_OF_RANGE;
wait_for_pending_async(chd);
return hunk_read_into_memory(chd, hunknum, (UINT8 *)buffer);
} | [
"chd_error",
"chd_read",
"(",
"chd_file",
"*",
"chd",
",",
"UINT32",
"hunknum",
",",
"void",
"*",
"buffer",
")",
"{",
"if",
"(",
"chd",
"==",
"NULL",
"||",
"chd",
"->",
"cookie",
"!=",
"COOKIE_VALUE",
")",
"return",
"CHDERR_INVALID_PARAMETER",
";",
"if",
"(",
"hunknum",
">=",
"chd",
"->",
"header",
".",
"totalhunks",
")",
"return",
"CHDERR_HUNK_OUT_OF_RANGE",
";",
"wait_for_pending_async",
"(",
"chd",
")",
";",
"return",
"hunk_read_into_memory",
"(",
"chd",
",",
"hunknum",
",",
"(",
"UINT8",
"*",
")",
"buffer",
")",
";",
"}"
] | chd_read - read a single hunk from the CHD
file | [
"chd_read",
"-",
"read",
"a",
"single",
"hunk",
"from",
"the",
"CHD",
"file"
] | [
"/* punt if NULL or invalid */",
"/* if we're past the end, fail */",
"/* wait for any pending async operations */",
"/* perform the read */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "hunknum",
"type": "UINT32"
},
{
"param": "buffer",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "hunknum",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "buffer",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | chd_read_async | chd_error | chd_error chd_read_async(chd_file *chd, UINT32 hunknum, void *buffer)
{
/* punt if NULL or invalid */
if (chd == NULL || chd->cookie != COOKIE_VALUE)
return CHDERR_INVALID_PARAMETER;
/* if we're past the end, fail */
if (hunknum >= chd->header.totalhunks)
return CHDERR_HUNK_OUT_OF_RANGE;
/* wait for any pending async operations */
wait_for_pending_async(chd);
/* set the async parameters */
chd->async_hunknum = hunknum;
chd->async_buffer = buffer;
/* queue the work item */
if (queue_async_operation(chd, async_read_callback))
return CHDERR_OPERATION_PENDING;
/* if we fail, fall back on the sync version */
return chd_read(chd, hunknum, buffer);
} | /*-------------------------------------------------
chd_read_async - read a single hunk from the
CHD file asynchronously
-------------------------------------------------*/ | read a single hunk from the
CHD file asynchronously | [
"read",
"a",
"single",
"hunk",
"from",
"the",
"CHD",
"file",
"asynchronously"
] | chd_error chd_read_async(chd_file *chd, UINT32 hunknum, void *buffer)
{
if (chd == NULL || chd->cookie != COOKIE_VALUE)
return CHDERR_INVALID_PARAMETER;
if (hunknum >= chd->header.totalhunks)
return CHDERR_HUNK_OUT_OF_RANGE;
wait_for_pending_async(chd);
chd->async_hunknum = hunknum;
chd->async_buffer = buffer;
if (queue_async_operation(chd, async_read_callback))
return CHDERR_OPERATION_PENDING;
return chd_read(chd, hunknum, buffer);
} | [
"chd_error",
"chd_read_async",
"(",
"chd_file",
"*",
"chd",
",",
"UINT32",
"hunknum",
",",
"void",
"*",
"buffer",
")",
"{",
"if",
"(",
"chd",
"==",
"NULL",
"||",
"chd",
"->",
"cookie",
"!=",
"COOKIE_VALUE",
")",
"return",
"CHDERR_INVALID_PARAMETER",
";",
"if",
"(",
"hunknum",
">=",
"chd",
"->",
"header",
".",
"totalhunks",
")",
"return",
"CHDERR_HUNK_OUT_OF_RANGE",
";",
"wait_for_pending_async",
"(",
"chd",
")",
";",
"chd",
"->",
"async_hunknum",
"=",
"hunknum",
";",
"chd",
"->",
"async_buffer",
"=",
"buffer",
";",
"if",
"(",
"queue_async_operation",
"(",
"chd",
",",
"async_read_callback",
")",
")",
"return",
"CHDERR_OPERATION_PENDING",
";",
"return",
"chd_read",
"(",
"chd",
",",
"hunknum",
",",
"buffer",
")",
";",
"}"
] | chd_read_async - read a single hunk from the
CHD file asynchronously | [
"chd_read_async",
"-",
"read",
"a",
"single",
"hunk",
"from",
"the",
"CHD",
"file",
"asynchronously"
] | [
"/* punt if NULL or invalid */",
"/* if we're past the end, fail */",
"/* wait for any pending async operations */",
"/* set the async parameters */",
"/* queue the work item */",
"/* if we fail, fall back on the sync version */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "hunknum",
"type": "UINT32"
},
{
"param": "buffer",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "hunknum",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "buffer",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | chd_write | chd_error | chd_error chd_write(chd_file *chd, UINT32 hunknum, const void *buffer)
{
/* punt if NULL or invalid */
if (chd == NULL || chd->cookie != COOKIE_VALUE)
return CHDERR_INVALID_PARAMETER;
/* if we're past the end, fail */
if (hunknum >= chd->header.totalhunks)
return CHDERR_HUNK_OUT_OF_RANGE;
/* wait for any pending async operations */
wait_for_pending_async(chd);
/* then write out the hunk */
return hunk_write_from_memory(chd, hunknum, (const UINT8 *)buffer);
} | /*-------------------------------------------------
chd_write - write a single hunk to the CHD
file
-------------------------------------------------*/ | write a single hunk to the CHD
file | [
"write",
"a",
"single",
"hunk",
"to",
"the",
"CHD",
"file"
] | chd_error chd_write(chd_file *chd, UINT32 hunknum, const void *buffer)
{
if (chd == NULL || chd->cookie != COOKIE_VALUE)
return CHDERR_INVALID_PARAMETER;
if (hunknum >= chd->header.totalhunks)
return CHDERR_HUNK_OUT_OF_RANGE;
wait_for_pending_async(chd);
return hunk_write_from_memory(chd, hunknum, (const UINT8 *)buffer);
} | [
"chd_error",
"chd_write",
"(",
"chd_file",
"*",
"chd",
",",
"UINT32",
"hunknum",
",",
"const",
"void",
"*",
"buffer",
")",
"{",
"if",
"(",
"chd",
"==",
"NULL",
"||",
"chd",
"->",
"cookie",
"!=",
"COOKIE_VALUE",
")",
"return",
"CHDERR_INVALID_PARAMETER",
";",
"if",
"(",
"hunknum",
">=",
"chd",
"->",
"header",
".",
"totalhunks",
")",
"return",
"CHDERR_HUNK_OUT_OF_RANGE",
";",
"wait_for_pending_async",
"(",
"chd",
")",
";",
"return",
"hunk_write_from_memory",
"(",
"chd",
",",
"hunknum",
",",
"(",
"const",
"UINT8",
"*",
")",
"buffer",
")",
";",
"}"
] | chd_write - write a single hunk to the CHD
file | [
"chd_write",
"-",
"write",
"a",
"single",
"hunk",
"to",
"the",
"CHD",
"file"
] | [
"/* punt if NULL or invalid */",
"/* if we're past the end, fail */",
"/* wait for any pending async operations */",
"/* then write out the hunk */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "hunknum",
"type": "UINT32"
},
{
"param": "buffer",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "hunknum",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "buffer",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | chd_write_async | chd_error | chd_error chd_write_async(chd_file *chd, UINT32 hunknum, const void *buffer)
{
/* punt if NULL or invalid */
if (chd == NULL || chd->cookie != COOKIE_VALUE)
return CHDERR_INVALID_PARAMETER;
/* if we're past the end, fail */
if (hunknum >= chd->header.totalhunks)
return CHDERR_HUNK_OUT_OF_RANGE;
/* wait for any pending async operations */
wait_for_pending_async(chd);
/* set the async parameters */
chd->async_hunknum = hunknum;
chd->async_buffer = (void *)buffer;
/* queue the work item */
if (queue_async_operation(chd, async_write_callback))
return CHDERR_OPERATION_PENDING;
/* if we fail, fall back on the sync version */
return chd_write(chd, hunknum, buffer);
} | /*-------------------------------------------------
chd_write_async - write a single hunk to the
CHD file asynchronously
-------------------------------------------------*/ | write a single hunk to the
CHD file asynchronously | [
"write",
"a",
"single",
"hunk",
"to",
"the",
"CHD",
"file",
"asynchronously"
] | chd_error chd_write_async(chd_file *chd, UINT32 hunknum, const void *buffer)
{
if (chd == NULL || chd->cookie != COOKIE_VALUE)
return CHDERR_INVALID_PARAMETER;
if (hunknum >= chd->header.totalhunks)
return CHDERR_HUNK_OUT_OF_RANGE;
wait_for_pending_async(chd);
chd->async_hunknum = hunknum;
chd->async_buffer = (void *)buffer;
if (queue_async_operation(chd, async_write_callback))
return CHDERR_OPERATION_PENDING;
return chd_write(chd, hunknum, buffer);
} | [
"chd_error",
"chd_write_async",
"(",
"chd_file",
"*",
"chd",
",",
"UINT32",
"hunknum",
",",
"const",
"void",
"*",
"buffer",
")",
"{",
"if",
"(",
"chd",
"==",
"NULL",
"||",
"chd",
"->",
"cookie",
"!=",
"COOKIE_VALUE",
")",
"return",
"CHDERR_INVALID_PARAMETER",
";",
"if",
"(",
"hunknum",
">=",
"chd",
"->",
"header",
".",
"totalhunks",
")",
"return",
"CHDERR_HUNK_OUT_OF_RANGE",
";",
"wait_for_pending_async",
"(",
"chd",
")",
";",
"chd",
"->",
"async_hunknum",
"=",
"hunknum",
";",
"chd",
"->",
"async_buffer",
"=",
"(",
"void",
"*",
")",
"buffer",
";",
"if",
"(",
"queue_async_operation",
"(",
"chd",
",",
"async_write_callback",
")",
")",
"return",
"CHDERR_OPERATION_PENDING",
";",
"return",
"chd_write",
"(",
"chd",
",",
"hunknum",
",",
"buffer",
")",
";",
"}"
] | chd_write_async - write a single hunk to the
CHD file asynchronously | [
"chd_write_async",
"-",
"write",
"a",
"single",
"hunk",
"to",
"the",
"CHD",
"file",
"asynchronously"
] | [
"/* punt if NULL or invalid */",
"/* if we're past the end, fail */",
"/* wait for any pending async operations */",
"/* set the async parameters */",
"/* queue the work item */",
"/* if we fail, fall back on the sync version */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "hunknum",
"type": "UINT32"
},
{
"param": "buffer",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "hunknum",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "buffer",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | chd_async_complete | chd_error | chd_error chd_async_complete(chd_file *chd)
{
void *result;
/* if nothing present, return an error */
if (chd->workitem == NULL)
return CHDERR_NO_ASYNC_OPERATION;
/* wait for the work to complete */
wait_for_pending_async(chd);
/* get the result and free the work item */
result = osd_work_item_result(chd->workitem);
osd_work_item_release(chd->workitem);
chd->workitem = NULL;
return (chd_error)(ptrdiff_t)result;
} | /*-------------------------------------------------
chd_async_complete - get the result of a
completed work item and clear it out of the
system
-------------------------------------------------*/ | get the result of a
completed work item and clear it out of the
system | [
"get",
"the",
"result",
"of",
"a",
"completed",
"work",
"item",
"and",
"clear",
"it",
"out",
"of",
"the",
"system"
] | chd_error chd_async_complete(chd_file *chd)
{
void *result;
if (chd->workitem == NULL)
return CHDERR_NO_ASYNC_OPERATION;
wait_for_pending_async(chd);
result = osd_work_item_result(chd->workitem);
osd_work_item_release(chd->workitem);
chd->workitem = NULL;
return (chd_error)(ptrdiff_t)result;
} | [
"chd_error",
"chd_async_complete",
"(",
"chd_file",
"*",
"chd",
")",
"{",
"void",
"*",
"result",
";",
"if",
"(",
"chd",
"->",
"workitem",
"==",
"NULL",
")",
"return",
"CHDERR_NO_ASYNC_OPERATION",
";",
"wait_for_pending_async",
"(",
"chd",
")",
";",
"result",
"=",
"osd_work_item_result",
"(",
"chd",
"->",
"workitem",
")",
";",
"osd_work_item_release",
"(",
"chd",
"->",
"workitem",
")",
";",
"chd",
"->",
"workitem",
"=",
"NULL",
";",
"return",
"(",
"chd_error",
")",
"(",
"ptrdiff_t",
")",
"result",
";",
"}"
] | chd_async_complete - get the result of a
completed work item and clear it out of the
system | [
"chd_async_complete",
"-",
"get",
"the",
"result",
"of",
"a",
"completed",
"work",
"item",
"and",
"clear",
"it",
"out",
"of",
"the",
"system"
] | [
"/* if nothing present, return an error */",
"/* wait for the work to complete */",
"/* get the result and free the work item */"
] | [
{
"param": "chd",
"type": "chd_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | chd_get_metadata | chd_error | chd_error chd_get_metadata(chd_file *chd, UINT32 searchtag, UINT32 searchindex, void *output, UINT32 outputlen, UINT32 *resultlen, UINT32 *resulttag, UINT8 *resultflags)
{
metadata_entry metaentry;
chd_error err;
UINT32 count;
/* wait for any pending async operations */
wait_for_pending_async(chd);
/* if we didn't find it, just return */
err = metadata_find_entry(chd, searchtag, searchindex, &metaentry);
if (err != CHDERR_NONE)
{
/* unless we're an old version and they are requesting hard disk metadata */
if (chd->header.version < 3 && (searchtag == HARD_DISK_METADATA_TAG || searchtag == CHDMETATAG_WILDCARD) && searchindex == 0)
{
char faux_metadata[256];
UINT32 faux_length;
/* fill in the faux metadata */
sprintf(faux_metadata, HARD_DISK_METADATA_FORMAT, chd->header.obsolete_cylinders, chd->header.obsolete_heads, chd->header.obsolete_sectors, chd->header.hunkbytes / chd->header.obsolete_hunksize);
faux_length = (UINT32)strlen(faux_metadata) + 1;
/* copy the metadata itself */
memcpy(output, faux_metadata, MIN(outputlen, faux_length));
/* return the length of the data and the tag */
if (resultlen != NULL)
*resultlen = faux_length;
if (resulttag != NULL)
*resulttag = HARD_DISK_METADATA_TAG;
return CHDERR_NONE;
}
return err;
}
/* read the metadata */
outputlen = MIN(outputlen, metaentry.length);
core_fseek(chd->file, metaentry.offset + METADATA_HEADER_SIZE, SEEK_SET);
count = core_fread(chd->file, output, outputlen);
if (count != outputlen)
return CHDERR_READ_ERROR;
/* return the length of the data and the tag */
if (resultlen != NULL)
*resultlen = metaentry.length;
if (resulttag != NULL)
*resulttag = metaentry.metatag;
if (resultflags != NULL)
*resultflags = metaentry.flags;
return CHDERR_NONE;
} | /*-------------------------------------------------
chd_get_metadata - get the indexed metadata
of the given type
-------------------------------------------------*/ | get the indexed metadata
of the given type | [
"get",
"the",
"indexed",
"metadata",
"of",
"the",
"given",
"type"
] | chd_error chd_get_metadata(chd_file *chd, UINT32 searchtag, UINT32 searchindex, void *output, UINT32 outputlen, UINT32 *resultlen, UINT32 *resulttag, UINT8 *resultflags)
{
metadata_entry metaentry;
chd_error err;
UINT32 count;
wait_for_pending_async(chd);
err = metadata_find_entry(chd, searchtag, searchindex, &metaentry);
if (err != CHDERR_NONE)
{
if (chd->header.version < 3 && (searchtag == HARD_DISK_METADATA_TAG || searchtag == CHDMETATAG_WILDCARD) && searchindex == 0)
{
char faux_metadata[256];
UINT32 faux_length;
sprintf(faux_metadata, HARD_DISK_METADATA_FORMAT, chd->header.obsolete_cylinders, chd->header.obsolete_heads, chd->header.obsolete_sectors, chd->header.hunkbytes / chd->header.obsolete_hunksize);
faux_length = (UINT32)strlen(faux_metadata) + 1;
memcpy(output, faux_metadata, MIN(outputlen, faux_length));
if (resultlen != NULL)
*resultlen = faux_length;
if (resulttag != NULL)
*resulttag = HARD_DISK_METADATA_TAG;
return CHDERR_NONE;
}
return err;
}
outputlen = MIN(outputlen, metaentry.length);
core_fseek(chd->file, metaentry.offset + METADATA_HEADER_SIZE, SEEK_SET);
count = core_fread(chd->file, output, outputlen);
if (count != outputlen)
return CHDERR_READ_ERROR;
if (resultlen != NULL)
*resultlen = metaentry.length;
if (resulttag != NULL)
*resulttag = metaentry.metatag;
if (resultflags != NULL)
*resultflags = metaentry.flags;
return CHDERR_NONE;
} | [
"chd_error",
"chd_get_metadata",
"(",
"chd_file",
"*",
"chd",
",",
"UINT32",
"searchtag",
",",
"UINT32",
"searchindex",
",",
"void",
"*",
"output",
",",
"UINT32",
"outputlen",
",",
"UINT32",
"*",
"resultlen",
",",
"UINT32",
"*",
"resulttag",
",",
"UINT8",
"*",
"resultflags",
")",
"{",
"metadata_entry",
"metaentry",
";",
"chd_error",
"err",
";",
"UINT32",
"count",
";",
"wait_for_pending_async",
"(",
"chd",
")",
";",
"err",
"=",
"metadata_find_entry",
"(",
"chd",
",",
"searchtag",
",",
"searchindex",
",",
"&",
"metaentry",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"if",
"(",
"chd",
"->",
"header",
".",
"version",
"<",
"3",
"&&",
"(",
"searchtag",
"==",
"HARD_DISK_METADATA_TAG",
"||",
"searchtag",
"==",
"CHDMETATAG_WILDCARD",
")",
"&&",
"searchindex",
"==",
"0",
")",
"{",
"char",
"faux_metadata",
"[",
"256",
"]",
";",
"UINT32",
"faux_length",
";",
"sprintf",
"(",
"faux_metadata",
",",
"HARD_DISK_METADATA_FORMAT",
",",
"chd",
"->",
"header",
".",
"obsolete_cylinders",
",",
"chd",
"->",
"header",
".",
"obsolete_heads",
",",
"chd",
"->",
"header",
".",
"obsolete_sectors",
",",
"chd",
"->",
"header",
".",
"hunkbytes",
"/",
"chd",
"->",
"header",
".",
"obsolete_hunksize",
")",
";",
"faux_length",
"=",
"(",
"UINT32",
")",
"strlen",
"(",
"faux_metadata",
")",
"+",
"1",
";",
"memcpy",
"(",
"output",
",",
"faux_metadata",
",",
"MIN",
"(",
"outputlen",
",",
"faux_length",
")",
")",
";",
"if",
"(",
"resultlen",
"!=",
"NULL",
")",
"*",
"resultlen",
"=",
"faux_length",
";",
"if",
"(",
"resulttag",
"!=",
"NULL",
")",
"*",
"resulttag",
"=",
"HARD_DISK_METADATA_TAG",
";",
"return",
"CHDERR_NONE",
";",
"}",
"return",
"err",
";",
"}",
"outputlen",
"=",
"MIN",
"(",
"outputlen",
",",
"metaentry",
".",
"length",
")",
";",
"core_fseek",
"(",
"chd",
"->",
"file",
",",
"metaentry",
".",
"offset",
"+",
"METADATA_HEADER_SIZE",
",",
"SEEK_SET",
")",
";",
"count",
"=",
"core_fread",
"(",
"chd",
"->",
"file",
",",
"output",
",",
"outputlen",
")",
";",
"if",
"(",
"count",
"!=",
"outputlen",
")",
"return",
"CHDERR_READ_ERROR",
";",
"if",
"(",
"resultlen",
"!=",
"NULL",
")",
"*",
"resultlen",
"=",
"metaentry",
".",
"length",
";",
"if",
"(",
"resulttag",
"!=",
"NULL",
")",
"*",
"resulttag",
"=",
"metaentry",
".",
"metatag",
";",
"if",
"(",
"resultflags",
"!=",
"NULL",
")",
"*",
"resultflags",
"=",
"metaentry",
".",
"flags",
";",
"return",
"CHDERR_NONE",
";",
"}"
] | chd_get_metadata - get the indexed metadata
of the given type | [
"chd_get_metadata",
"-",
"get",
"the",
"indexed",
"metadata",
"of",
"the",
"given",
"type"
] | [
"/* wait for any pending async operations */",
"/* if we didn't find it, just return */",
"/* unless we're an old version and they are requesting hard disk metadata */",
"/* fill in the faux metadata */",
"/* copy the metadata itself */",
"/* return the length of the data and the tag */",
"/* read the metadata */",
"/* return the length of the data and the tag */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "searchtag",
"type": "UINT32"
},
{
"param": "searchindex",
"type": "UINT32"
},
{
"param": "output",
"type": "void"
},
{
"param": "outputlen",
"type": "UINT32"
},
{
"param": "resultlen",
"type": "UINT32"
},
{
"param": "resulttag",
"type": "UINT32"
},
{
"param": "resultflags",
"type": "UINT8"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "searchtag",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "searchindex",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "output",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "outputlen",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "resultlen",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "resulttag",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "resultflags",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | chd_set_metadata | chd_error | chd_error chd_set_metadata(chd_file *chd, UINT32 metatag, UINT32 metaindex, const void *inputbuf, UINT32 inputlen, UINT8 flags)
{
UINT8 raw_meta_header[METADATA_HEADER_SIZE];
metadata_entry metaentry;
chd_error err;
UINT64 offset;
UINT32 count;
/* if the disk is an old version, punt */
if (chd->header.version < 3)
return CHDERR_NOT_SUPPORTED;
/* if the disk isn't writeable, punt */
if (!(chd->header.flags & CHDFLAGS_IS_WRITEABLE))
return CHDERR_FILE_NOT_WRITEABLE;
/* must write at least 1 byte */
if (inputlen < 1)
return CHDERR_INVALID_PARAMETER;
/* no more than 16MB */
if (inputlen >= 16 * 1024 * 1024)
return CHDERR_INVALID_PARAMETER;
/* wait for any pending async operations */
wait_for_pending_async(chd);
/* find the entry if it already exists */
err = metadata_find_entry(chd, metatag, metaindex, &metaentry);
/* if it's there and it fits, just overwrite */
if (err == CHDERR_NONE && inputlen <= metaentry.length)
{
/* overwrite the original data with our new input data */
core_fseek(chd->file, metaentry.offset + METADATA_HEADER_SIZE, SEEK_SET);
count = core_fwrite(chd->file, inputbuf, inputlen);
if (count != inputlen)
{
err = CHDERR_WRITE_ERROR;
goto update;
}
/* if the lengths don't match, we need to update the length in our header */
if (inputlen != metaentry.length)
err = metadata_set_length(chd, metaentry.offset, inputlen);
goto update;
}
/* if we already have an entry, unlink it */
if (err == CHDERR_NONE)
{
err = metadata_set_previous_next(chd, metaentry.prev, metaentry.next);
if (err != CHDERR_NONE)
goto update;
}
/* now build us a new entry */
put_bigendian_uint32(&raw_meta_header[0], metatag);
put_bigendian_uint32(&raw_meta_header[4], (inputlen & 0x00ffffff) | (flags << 24));
put_bigendian_uint64(&raw_meta_header[8], (err == CHDERR_NONE) ? metaentry.next : 0);
/* write out the new header */
offset = core_fsize(chd->file);
core_fseek(chd->file, offset, SEEK_SET);
count = core_fwrite(chd->file, raw_meta_header, sizeof(raw_meta_header));
if (count != sizeof(raw_meta_header))
{
err = CHDERR_WRITE_ERROR;
goto update;
}
/* follow that with the data */
core_fseek(chd->file, offset + METADATA_HEADER_SIZE, SEEK_SET);
count = core_fwrite(chd->file, inputbuf, inputlen);
if (count != inputlen)
{
err = CHDERR_WRITE_ERROR;
goto update;
}
/* set the previous entry to point to us */
err = metadata_set_previous_next(chd, metaentry.prev, offset);
update:
/* update the hash */
if (metadata_compute_hash(chd, chd->header.rawsha1, chd->header.sha1) == CHDERR_NONE)
err = header_write(chd->file, &chd->header);
return err;
} | /*-------------------------------------------------
chd_set_metadata - write the indexed metadata
of the given type
-------------------------------------------------*/ | write the indexed metadata
of the given type | [
"write",
"the",
"indexed",
"metadata",
"of",
"the",
"given",
"type"
] | chd_error chd_set_metadata(chd_file *chd, UINT32 metatag, UINT32 metaindex, const void *inputbuf, UINT32 inputlen, UINT8 flags)
{
UINT8 raw_meta_header[METADATA_HEADER_SIZE];
metadata_entry metaentry;
chd_error err;
UINT64 offset;
UINT32 count;
if (chd->header.version < 3)
return CHDERR_NOT_SUPPORTED;
if (!(chd->header.flags & CHDFLAGS_IS_WRITEABLE))
return CHDERR_FILE_NOT_WRITEABLE;
if (inputlen < 1)
return CHDERR_INVALID_PARAMETER;
if (inputlen >= 16 * 1024 * 1024)
return CHDERR_INVALID_PARAMETER;
wait_for_pending_async(chd);
err = metadata_find_entry(chd, metatag, metaindex, &metaentry);
if (err == CHDERR_NONE && inputlen <= metaentry.length)
{
core_fseek(chd->file, metaentry.offset + METADATA_HEADER_SIZE, SEEK_SET);
count = core_fwrite(chd->file, inputbuf, inputlen);
if (count != inputlen)
{
err = CHDERR_WRITE_ERROR;
goto update;
}
if (inputlen != metaentry.length)
err = metadata_set_length(chd, metaentry.offset, inputlen);
goto update;
}
if (err == CHDERR_NONE)
{
err = metadata_set_previous_next(chd, metaentry.prev, metaentry.next);
if (err != CHDERR_NONE)
goto update;
}
put_bigendian_uint32(&raw_meta_header[0], metatag);
put_bigendian_uint32(&raw_meta_header[4], (inputlen & 0x00ffffff) | (flags << 24));
put_bigendian_uint64(&raw_meta_header[8], (err == CHDERR_NONE) ? metaentry.next : 0);
offset = core_fsize(chd->file);
core_fseek(chd->file, offset, SEEK_SET);
count = core_fwrite(chd->file, raw_meta_header, sizeof(raw_meta_header));
if (count != sizeof(raw_meta_header))
{
err = CHDERR_WRITE_ERROR;
goto update;
}
core_fseek(chd->file, offset + METADATA_HEADER_SIZE, SEEK_SET);
count = core_fwrite(chd->file, inputbuf, inputlen);
if (count != inputlen)
{
err = CHDERR_WRITE_ERROR;
goto update;
}
err = metadata_set_previous_next(chd, metaentry.prev, offset);
update:
if (metadata_compute_hash(chd, chd->header.rawsha1, chd->header.sha1) == CHDERR_NONE)
err = header_write(chd->file, &chd->header);
return err;
} | [
"chd_error",
"chd_set_metadata",
"(",
"chd_file",
"*",
"chd",
",",
"UINT32",
"metatag",
",",
"UINT32",
"metaindex",
",",
"const",
"void",
"*",
"inputbuf",
",",
"UINT32",
"inputlen",
",",
"UINT8",
"flags",
")",
"{",
"UINT8",
"raw_meta_header",
"[",
"METADATA_HEADER_SIZE",
"]",
";",
"metadata_entry",
"metaentry",
";",
"chd_error",
"err",
";",
"UINT64",
"offset",
";",
"UINT32",
"count",
";",
"if",
"(",
"chd",
"->",
"header",
".",
"version",
"<",
"3",
")",
"return",
"CHDERR_NOT_SUPPORTED",
";",
"if",
"(",
"!",
"(",
"chd",
"->",
"header",
".",
"flags",
"&",
"CHDFLAGS_IS_WRITEABLE",
")",
")",
"return",
"CHDERR_FILE_NOT_WRITEABLE",
";",
"if",
"(",
"inputlen",
"<",
"1",
")",
"return",
"CHDERR_INVALID_PARAMETER",
";",
"if",
"(",
"inputlen",
">=",
"16",
"*",
"1024",
"*",
"1024",
")",
"return",
"CHDERR_INVALID_PARAMETER",
";",
"wait_for_pending_async",
"(",
"chd",
")",
";",
"err",
"=",
"metadata_find_entry",
"(",
"chd",
",",
"metatag",
",",
"metaindex",
",",
"&",
"metaentry",
")",
";",
"if",
"(",
"err",
"==",
"CHDERR_NONE",
"&&",
"inputlen",
"<=",
"metaentry",
".",
"length",
")",
"{",
"core_fseek",
"(",
"chd",
"->",
"file",
",",
"metaentry",
".",
"offset",
"+",
"METADATA_HEADER_SIZE",
",",
"SEEK_SET",
")",
";",
"count",
"=",
"core_fwrite",
"(",
"chd",
"->",
"file",
",",
"inputbuf",
",",
"inputlen",
")",
";",
"if",
"(",
"count",
"!=",
"inputlen",
")",
"{",
"err",
"=",
"CHDERR_WRITE_ERROR",
";",
"goto",
"update",
";",
"}",
"if",
"(",
"inputlen",
"!=",
"metaentry",
".",
"length",
")",
"err",
"=",
"metadata_set_length",
"(",
"chd",
",",
"metaentry",
".",
"offset",
",",
"inputlen",
")",
";",
"goto",
"update",
";",
"}",
"if",
"(",
"err",
"==",
"CHDERR_NONE",
")",
"{",
"err",
"=",
"metadata_set_previous_next",
"(",
"chd",
",",
"metaentry",
".",
"prev",
",",
"metaentry",
".",
"next",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"goto",
"update",
";",
"}",
"put_bigendian_uint32",
"(",
"&",
"raw_meta_header",
"[",
"0",
"]",
",",
"metatag",
")",
";",
"put_bigendian_uint32",
"(",
"&",
"raw_meta_header",
"[",
"4",
"]",
",",
"(",
"inputlen",
"&",
"0x00ffffff",
")",
"|",
"(",
"flags",
"<<",
"24",
")",
")",
";",
"put_bigendian_uint64",
"(",
"&",
"raw_meta_header",
"[",
"8",
"]",
",",
"(",
"err",
"==",
"CHDERR_NONE",
")",
"?",
"metaentry",
".",
"next",
":",
"0",
")",
";",
"offset",
"=",
"core_fsize",
"(",
"chd",
"->",
"file",
")",
";",
"core_fseek",
"(",
"chd",
"->",
"file",
",",
"offset",
",",
"SEEK_SET",
")",
";",
"count",
"=",
"core_fwrite",
"(",
"chd",
"->",
"file",
",",
"raw_meta_header",
",",
"sizeof",
"(",
"raw_meta_header",
")",
")",
";",
"if",
"(",
"count",
"!=",
"sizeof",
"(",
"raw_meta_header",
")",
")",
"{",
"err",
"=",
"CHDERR_WRITE_ERROR",
";",
"goto",
"update",
";",
"}",
"core_fseek",
"(",
"chd",
"->",
"file",
",",
"offset",
"+",
"METADATA_HEADER_SIZE",
",",
"SEEK_SET",
")",
";",
"count",
"=",
"core_fwrite",
"(",
"chd",
"->",
"file",
",",
"inputbuf",
",",
"inputlen",
")",
";",
"if",
"(",
"count",
"!=",
"inputlen",
")",
"{",
"err",
"=",
"CHDERR_WRITE_ERROR",
";",
"goto",
"update",
";",
"}",
"err",
"=",
"metadata_set_previous_next",
"(",
"chd",
",",
"metaentry",
".",
"prev",
",",
"offset",
")",
";",
"update",
":",
"if",
"(",
"metadata_compute_hash",
"(",
"chd",
",",
"chd",
"->",
"header",
".",
"rawsha1",
",",
"chd",
"->",
"header",
".",
"sha1",
")",
"==",
"CHDERR_NONE",
")",
"err",
"=",
"header_write",
"(",
"chd",
"->",
"file",
",",
"&",
"chd",
"->",
"header",
")",
";",
"return",
"err",
";",
"}"
] | chd_set_metadata - write the indexed metadata
of the given type | [
"chd_set_metadata",
"-",
"write",
"the",
"indexed",
"metadata",
"of",
"the",
"given",
"type"
] | [
"/* if the disk is an old version, punt */",
"/* if the disk isn't writeable, punt */",
"/* must write at least 1 byte */",
"/* no more than 16MB */",
"/* wait for any pending async operations */",
"/* find the entry if it already exists */",
"/* if it's there and it fits, just overwrite */",
"/* overwrite the original data with our new input data */",
"/* if the lengths don't match, we need to update the length in our header */",
"/* if we already have an entry, unlink it */",
"/* now build us a new entry */",
"/* write out the new header */",
"/* follow that with the data */",
"/* set the previous entry to point to us */",
"/* update the hash */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "metatag",
"type": "UINT32"
},
{
"param": "metaindex",
"type": "UINT32"
},
{
"param": "inputbuf",
"type": "void"
},
{
"param": "inputlen",
"type": "UINT32"
},
{
"param": "flags",
"type": "UINT8"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "metatag",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "metaindex",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "inputbuf",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "inputlen",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "flags",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | chd_clone_metadata | chd_error | chd_error chd_clone_metadata(chd_file *source, chd_file *dest)
{
UINT32 metatag, metasize, metaindex;
UINT8 metabuffer[1024];
UINT8 metaflags;
chd_error err;
/* clone the metadata */
for (metaindex = 0; ; metaindex++)
{
/* fetch the next piece of metadata */
err = chd_get_metadata(source, CHDMETATAG_WILDCARD, metaindex, metabuffer, sizeof(metabuffer), &metasize, &metatag, &metaflags);
if (err != CHDERR_NONE)
{
if (err == CHDERR_METADATA_NOT_FOUND)
err = CHDERR_NONE;
break;
}
/* if that fit, just write it back from the temporary buffer */
if (metasize <= sizeof(metabuffer))
{
/* write it to the target */
err = chd_set_metadata(dest, metatag, CHD_METAINDEX_APPEND, metabuffer, metasize, metaflags);
if (err != CHDERR_NONE)
break;
}
/* otherwise, allocate a bigger temporary buffer */
else
{
UINT8 *allocbuffer = (UINT8 *)malloc(metasize);
if (allocbuffer == NULL)
{
err = CHDERR_OUT_OF_MEMORY;
break;
}
/* re-read the whole thing */
err = chd_get_metadata(source, CHDMETATAG_WILDCARD, metaindex, allocbuffer, metasize, &metasize, &metatag, &metaflags);
if (err != CHDERR_NONE)
{
free(allocbuffer);
break;
}
/* write it to the target */
err = chd_set_metadata(dest, metatag, CHD_METAINDEX_APPEND, allocbuffer, metasize, metaflags);
free(allocbuffer);
if (err != CHDERR_NONE)
break;
}
}
return err;
} | /*-------------------------------------------------
chd_clone_metadata - clone the metadata from
one CHD to a second
-------------------------------------------------*/ | clone the metadata from
one CHD to a second | [
"clone",
"the",
"metadata",
"from",
"one",
"CHD",
"to",
"a",
"second"
] | chd_error chd_clone_metadata(chd_file *source, chd_file *dest)
{
UINT32 metatag, metasize, metaindex;
UINT8 metabuffer[1024];
UINT8 metaflags;
chd_error err;
for (metaindex = 0; ; metaindex++)
{
err = chd_get_metadata(source, CHDMETATAG_WILDCARD, metaindex, metabuffer, sizeof(metabuffer), &metasize, &metatag, &metaflags);
if (err != CHDERR_NONE)
{
if (err == CHDERR_METADATA_NOT_FOUND)
err = CHDERR_NONE;
break;
}
if (metasize <= sizeof(metabuffer))
{
err = chd_set_metadata(dest, metatag, CHD_METAINDEX_APPEND, metabuffer, metasize, metaflags);
if (err != CHDERR_NONE)
break;
}
else
{
UINT8 *allocbuffer = (UINT8 *)malloc(metasize);
if (allocbuffer == NULL)
{
err = CHDERR_OUT_OF_MEMORY;
break;
}
err = chd_get_metadata(source, CHDMETATAG_WILDCARD, metaindex, allocbuffer, metasize, &metasize, &metatag, &metaflags);
if (err != CHDERR_NONE)
{
free(allocbuffer);
break;
}
err = chd_set_metadata(dest, metatag, CHD_METAINDEX_APPEND, allocbuffer, metasize, metaflags);
free(allocbuffer);
if (err != CHDERR_NONE)
break;
}
}
return err;
} | [
"chd_error",
"chd_clone_metadata",
"(",
"chd_file",
"*",
"source",
",",
"chd_file",
"*",
"dest",
")",
"{",
"UINT32",
"metatag",
",",
"metasize",
",",
"metaindex",
";",
"UINT8",
"metabuffer",
"[",
"1024",
"]",
";",
"UINT8",
"metaflags",
";",
"chd_error",
"err",
";",
"for",
"(",
"metaindex",
"=",
"0",
";",
";",
"metaindex",
"++",
")",
"{",
"err",
"=",
"chd_get_metadata",
"(",
"source",
",",
"CHDMETATAG_WILDCARD",
",",
"metaindex",
",",
"metabuffer",
",",
"sizeof",
"(",
"metabuffer",
")",
",",
"&",
"metasize",
",",
"&",
"metatag",
",",
"&",
"metaflags",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"if",
"(",
"err",
"==",
"CHDERR_METADATA_NOT_FOUND",
")",
"err",
"=",
"CHDERR_NONE",
";",
"break",
";",
"}",
"if",
"(",
"metasize",
"<=",
"sizeof",
"(",
"metabuffer",
")",
")",
"{",
"err",
"=",
"chd_set_metadata",
"(",
"dest",
",",
"metatag",
",",
"CHD_METAINDEX_APPEND",
",",
"metabuffer",
",",
"metasize",
",",
"metaflags",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"break",
";",
"}",
"else",
"{",
"UINT8",
"*",
"allocbuffer",
"=",
"(",
"UINT8",
"*",
")",
"malloc",
"(",
"metasize",
")",
";",
"if",
"(",
"allocbuffer",
"==",
"NULL",
")",
"{",
"err",
"=",
"CHDERR_OUT_OF_MEMORY",
";",
"break",
";",
"}",
"err",
"=",
"chd_get_metadata",
"(",
"source",
",",
"CHDMETATAG_WILDCARD",
",",
"metaindex",
",",
"allocbuffer",
",",
"metasize",
",",
"&",
"metasize",
",",
"&",
"metatag",
",",
"&",
"metaflags",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"{",
"free",
"(",
"allocbuffer",
")",
";",
"break",
";",
"}",
"err",
"=",
"chd_set_metadata",
"(",
"dest",
",",
"metatag",
",",
"CHD_METAINDEX_APPEND",
",",
"allocbuffer",
",",
"metasize",
",",
"metaflags",
")",
";",
"free",
"(",
"allocbuffer",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"break",
";",
"}",
"}",
"return",
"err",
";",
"}"
] | chd_clone_metadata - clone the metadata from
one CHD to a second | [
"chd_clone_metadata",
"-",
"clone",
"the",
"metadata",
"from",
"one",
"CHD",
"to",
"a",
"second"
] | [
"/* clone the metadata */",
"/* fetch the next piece of metadata */",
"/* if that fit, just write it back from the temporary buffer */",
"/* write it to the target */",
"/* otherwise, allocate a bigger temporary buffer */",
"/* re-read the whole thing */",
"/* write it to the target */"
] | [
{
"param": "source",
"type": "chd_file"
},
{
"param": "dest",
"type": "chd_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "source",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dest",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | chd_compress_begin | chd_error | chd_error chd_compress_begin(chd_file *chd)
{
chd_error err;
/* verify parameters */
if (chd == NULL)
return CHDERR_INVALID_PARAMETER;
/* wait for any pending async operations */
wait_for_pending_async(chd);
/* mark the CHD writeable and write the updated header */
chd->header.flags |= CHDFLAGS_IS_WRITEABLE;
err = header_write(chd->file, &chd->header);
if (err != CHDERR_NONE)
return err;
/* create CRC maps for the new CHD and the parent */
crcmap_init(chd, FALSE);
if (chd->parent != NULL)
crcmap_init(chd->parent, TRUE);
/* init the MD5/SHA1 computations */
MD5Init(&chd->compmd5);
sha1_init(&chd->compsha1);
chd->compressing = TRUE;
chd->comphunk = 0;
return CHDERR_NONE;
} | /*-------------------------------------------------
chd_compress_begin - begin compressing data
into a CHD
-------------------------------------------------*/ | begin compressing data
into a CHD | [
"begin",
"compressing",
"data",
"into",
"a",
"CHD"
] | chd_error chd_compress_begin(chd_file *chd)
{
chd_error err;
if (chd == NULL)
return CHDERR_INVALID_PARAMETER;
wait_for_pending_async(chd);
chd->header.flags |= CHDFLAGS_IS_WRITEABLE;
err = header_write(chd->file, &chd->header);
if (err != CHDERR_NONE)
return err;
crcmap_init(chd, FALSE);
if (chd->parent != NULL)
crcmap_init(chd->parent, TRUE);
MD5Init(&chd->compmd5);
sha1_init(&chd->compsha1);
chd->compressing = TRUE;
chd->comphunk = 0;
return CHDERR_NONE;
} | [
"chd_error",
"chd_compress_begin",
"(",
"chd_file",
"*",
"chd",
")",
"{",
"chd_error",
"err",
";",
"if",
"(",
"chd",
"==",
"NULL",
")",
"return",
"CHDERR_INVALID_PARAMETER",
";",
"wait_for_pending_async",
"(",
"chd",
")",
";",
"chd",
"->",
"header",
".",
"flags",
"|=",
"CHDFLAGS_IS_WRITEABLE",
";",
"err",
"=",
"header_write",
"(",
"chd",
"->",
"file",
",",
"&",
"chd",
"->",
"header",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"return",
"err",
";",
"crcmap_init",
"(",
"chd",
",",
"FALSE",
")",
";",
"if",
"(",
"chd",
"->",
"parent",
"!=",
"NULL",
")",
"crcmap_init",
"(",
"chd",
"->",
"parent",
",",
"TRUE",
")",
";",
"MD5Init",
"(",
"&",
"chd",
"->",
"compmd5",
")",
";",
"sha1_init",
"(",
"&",
"chd",
"->",
"compsha1",
")",
";",
"chd",
"->",
"compressing",
"=",
"TRUE",
";",
"chd",
"->",
"comphunk",
"=",
"0",
";",
"return",
"CHDERR_NONE",
";",
"}"
] | chd_compress_begin - begin compressing data
into a CHD | [
"chd_compress_begin",
"-",
"begin",
"compressing",
"data",
"into",
"a",
"CHD"
] | [
"/* verify parameters */",
"/* wait for any pending async operations */",
"/* mark the CHD writeable and write the updated header */",
"/* create CRC maps for the new CHD and the parent */",
"/* init the MD5/SHA1 computations */"
] | [
{
"param": "chd",
"type": "chd_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | chd_compress_hunk | chd_error | chd_error chd_compress_hunk(chd_file *chd, const void *data, double *curratio)
{
UINT32 thishunk = chd->comphunk++;
UINT64 sourceoffset = (UINT64)thishunk * (UINT64)chd->header.hunkbytes;
UINT32 bytestochecksum;
const void *crcdata;
chd_error err;
/* error if in the wrong state */
if (!chd->compressing)
return CHDERR_INVALID_STATE;
/* write out the hunk */
err = hunk_write_from_memory(chd, thishunk, (const UINT8 *)data);
if (err != CHDERR_NONE)
return err;
/* if we are lossy, then we need to use the decompressed version in */
/* the cache as our MD5/SHA1 source */
crcdata = (chd->codecintf->lossy || data == NULL) ? chd->cache : data;
/* update the MD5/SHA1 */
bytestochecksum = chd->header.hunkbytes;
if (sourceoffset + chd->header.hunkbytes > chd->header.logicalbytes)
{
if (sourceoffset >= chd->header.logicalbytes)
bytestochecksum = 0;
else
bytestochecksum = chd->header.logicalbytes - sourceoffset;
}
if (bytestochecksum > 0)
{
MD5Update(&chd->compmd5, (const unsigned char *)crcdata, bytestochecksum);
sha1_update(&chd->compsha1, bytestochecksum, (const UINT8 *)crcdata);
}
/* update our CRC map */
if ((chd->map[thishunk].flags & MAP_ENTRY_FLAG_TYPE_MASK) != MAP_ENTRY_TYPE_SELF_HUNK &&
(chd->map[thishunk].flags & MAP_ENTRY_FLAG_TYPE_MASK) != MAP_ENTRY_TYPE_PARENT_HUNK)
crcmap_add_entry(chd, thishunk);
/* update the ratio */
if (curratio != NULL)
{
UINT64 curlength = core_fsize(chd->file);
*curratio = 1.0 - (double)curlength / (double)((UINT64)chd->comphunk * (UINT64)chd->header.hunkbytes);
}
return CHDERR_NONE;
} | /*-------------------------------------------------
chd_compress_hunk - append data to a CHD
that is being compressed
-------------------------------------------------*/ | append data to a CHD
that is being compressed | [
"append",
"data",
"to",
"a",
"CHD",
"that",
"is",
"being",
"compressed"
] | chd_error chd_compress_hunk(chd_file *chd, const void *data, double *curratio)
{
UINT32 thishunk = chd->comphunk++;
UINT64 sourceoffset = (UINT64)thishunk * (UINT64)chd->header.hunkbytes;
UINT32 bytestochecksum;
const void *crcdata;
chd_error err;
if (!chd->compressing)
return CHDERR_INVALID_STATE;
err = hunk_write_from_memory(chd, thishunk, (const UINT8 *)data);
if (err != CHDERR_NONE)
return err;
crcdata = (chd->codecintf->lossy || data == NULL) ? chd->cache : data;
bytestochecksum = chd->header.hunkbytes;
if (sourceoffset + chd->header.hunkbytes > chd->header.logicalbytes)
{
if (sourceoffset >= chd->header.logicalbytes)
bytestochecksum = 0;
else
bytestochecksum = chd->header.logicalbytes - sourceoffset;
}
if (bytestochecksum > 0)
{
MD5Update(&chd->compmd5, (const unsigned char *)crcdata, bytestochecksum);
sha1_update(&chd->compsha1, bytestochecksum, (const UINT8 *)crcdata);
}
if ((chd->map[thishunk].flags & MAP_ENTRY_FLAG_TYPE_MASK) != MAP_ENTRY_TYPE_SELF_HUNK &&
(chd->map[thishunk].flags & MAP_ENTRY_FLAG_TYPE_MASK) != MAP_ENTRY_TYPE_PARENT_HUNK)
crcmap_add_entry(chd, thishunk);
if (curratio != NULL)
{
UINT64 curlength = core_fsize(chd->file);
*curratio = 1.0 - (double)curlength / (double)((UINT64)chd->comphunk * (UINT64)chd->header.hunkbytes);
}
return CHDERR_NONE;
} | [
"chd_error",
"chd_compress_hunk",
"(",
"chd_file",
"*",
"chd",
",",
"const",
"void",
"*",
"data",
",",
"double",
"*",
"curratio",
")",
"{",
"UINT32",
"thishunk",
"=",
"chd",
"->",
"comphunk",
"++",
";",
"UINT64",
"sourceoffset",
"=",
"(",
"UINT64",
")",
"thishunk",
"*",
"(",
"UINT64",
")",
"chd",
"->",
"header",
".",
"hunkbytes",
";",
"UINT32",
"bytestochecksum",
";",
"const",
"void",
"*",
"crcdata",
";",
"chd_error",
"err",
";",
"if",
"(",
"!",
"chd",
"->",
"compressing",
")",
"return",
"CHDERR_INVALID_STATE",
";",
"err",
"=",
"hunk_write_from_memory",
"(",
"chd",
",",
"thishunk",
",",
"(",
"const",
"UINT8",
"*",
")",
"data",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"return",
"err",
";",
"crcdata",
"=",
"(",
"chd",
"->",
"codecintf",
"->",
"lossy",
"||",
"data",
"==",
"NULL",
")",
"?",
"chd",
"->",
"cache",
":",
"data",
";",
"bytestochecksum",
"=",
"chd",
"->",
"header",
".",
"hunkbytes",
";",
"if",
"(",
"sourceoffset",
"+",
"chd",
"->",
"header",
".",
"hunkbytes",
">",
"chd",
"->",
"header",
".",
"logicalbytes",
")",
"{",
"if",
"(",
"sourceoffset",
">=",
"chd",
"->",
"header",
".",
"logicalbytes",
")",
"bytestochecksum",
"=",
"0",
";",
"else",
"bytestochecksum",
"=",
"chd",
"->",
"header",
".",
"logicalbytes",
"-",
"sourceoffset",
";",
"}",
"if",
"(",
"bytestochecksum",
">",
"0",
")",
"{",
"MD5Update",
"(",
"&",
"chd",
"->",
"compmd5",
",",
"(",
"const",
"unsigned",
"char",
"*",
")",
"crcdata",
",",
"bytestochecksum",
")",
";",
"sha1_update",
"(",
"&",
"chd",
"->",
"compsha1",
",",
"bytestochecksum",
",",
"(",
"const",
"UINT8",
"*",
")",
"crcdata",
")",
";",
"}",
"if",
"(",
"(",
"chd",
"->",
"map",
"[",
"thishunk",
"]",
".",
"flags",
"&",
"MAP_ENTRY_FLAG_TYPE_MASK",
")",
"!=",
"MAP_ENTRY_TYPE_SELF_HUNK",
"&&",
"(",
"chd",
"->",
"map",
"[",
"thishunk",
"]",
".",
"flags",
"&",
"MAP_ENTRY_FLAG_TYPE_MASK",
")",
"!=",
"MAP_ENTRY_TYPE_PARENT_HUNK",
")",
"crcmap_add_entry",
"(",
"chd",
",",
"thishunk",
")",
";",
"if",
"(",
"curratio",
"!=",
"NULL",
")",
"{",
"UINT64",
"curlength",
"=",
"core_fsize",
"(",
"chd",
"->",
"file",
")",
";",
"*",
"curratio",
"=",
"1.0",
"-",
"(",
"double",
")",
"curlength",
"/",
"(",
"double",
")",
"(",
"(",
"UINT64",
")",
"chd",
"->",
"comphunk",
"*",
"(",
"UINT64",
")",
"chd",
"->",
"header",
".",
"hunkbytes",
")",
";",
"}",
"return",
"CHDERR_NONE",
";",
"}"
] | chd_compress_hunk - append data to a CHD
that is being compressed | [
"chd_compress_hunk",
"-",
"append",
"data",
"to",
"a",
"CHD",
"that",
"is",
"being",
"compressed"
] | [
"/* error if in the wrong state */",
"/* write out the hunk */",
"/* if we are lossy, then we need to use the decompressed version in */",
"/* the cache as our MD5/SHA1 source */",
"/* update the MD5/SHA1 */",
"/* update our CRC map */",
"/* update the ratio */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "data",
"type": "void"
},
{
"param": "curratio",
"type": "double"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "curratio",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | chd_verify_begin | chd_error | chd_error chd_verify_begin(chd_file *chd)
{
/* verify parameters */
if (chd == NULL)
return CHDERR_INVALID_PARAMETER;
/* if this is a writeable file image, we can't verify */
if (chd->header.flags & CHDFLAGS_IS_WRITEABLE)
return CHDERR_CANT_VERIFY;
/* wait for any pending async operations */
wait_for_pending_async(chd);
/* init the MD5/SHA1 computations */
MD5Init(&chd->vermd5);
sha1_init(&chd->versha1);
chd->verifying = TRUE;
chd->verhunk = 0;
return CHDERR_NONE;
} | /*-------------------------------------------------
chd_verify_begin - begin compressing data
into a CHD
-------------------------------------------------*/ | begin compressing data
into a CHD | [
"begin",
"compressing",
"data",
"into",
"a",
"CHD"
] | chd_error chd_verify_begin(chd_file *chd)
{
if (chd == NULL)
return CHDERR_INVALID_PARAMETER;
if (chd->header.flags & CHDFLAGS_IS_WRITEABLE)
return CHDERR_CANT_VERIFY;
wait_for_pending_async(chd);
MD5Init(&chd->vermd5);
sha1_init(&chd->versha1);
chd->verifying = TRUE;
chd->verhunk = 0;
return CHDERR_NONE;
} | [
"chd_error",
"chd_verify_begin",
"(",
"chd_file",
"*",
"chd",
")",
"{",
"if",
"(",
"chd",
"==",
"NULL",
")",
"return",
"CHDERR_INVALID_PARAMETER",
";",
"if",
"(",
"chd",
"->",
"header",
".",
"flags",
"&",
"CHDFLAGS_IS_WRITEABLE",
")",
"return",
"CHDERR_CANT_VERIFY",
";",
"wait_for_pending_async",
"(",
"chd",
")",
";",
"MD5Init",
"(",
"&",
"chd",
"->",
"vermd5",
")",
";",
"sha1_init",
"(",
"&",
"chd",
"->",
"versha1",
")",
";",
"chd",
"->",
"verifying",
"=",
"TRUE",
";",
"chd",
"->",
"verhunk",
"=",
"0",
";",
"return",
"CHDERR_NONE",
";",
"}"
] | chd_verify_begin - begin compressing data
into a CHD | [
"chd_verify_begin",
"-",
"begin",
"compressing",
"data",
"into",
"a",
"CHD"
] | [
"/* verify parameters */",
"/* if this is a writeable file image, we can't verify */",
"/* wait for any pending async operations */",
"/* init the MD5/SHA1 computations */"
] | [
{
"param": "chd",
"type": "chd_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | chd_verify_hunk | chd_error | chd_error chd_verify_hunk(chd_file *chd)
{
UINT32 thishunk = chd->verhunk++;
UINT64 hunkoffset = (UINT64)thishunk * (UINT64)chd->header.hunkbytes;
map_entry *entry;
chd_error err;
/* error if in the wrong state */
if (!chd->verifying)
return CHDERR_INVALID_STATE;
/* read the hunk into the cache */
err = hunk_read_into_cache(chd, thishunk);
if (err != CHDERR_NONE)
return err;
/* update the MD5/SHA1 */
if (hunkoffset < chd->header.logicalbytes)
{
UINT64 bytestochecksum = MIN(chd->header.hunkbytes, chd->header.logicalbytes - hunkoffset);
if (bytestochecksum > 0)
{
MD5Update(&chd->vermd5, chd->cache, bytestochecksum);
sha1_update(&chd->versha1, bytestochecksum, chd->cache);
}
}
/* validate the CRC if we have one */
entry = &chd->map[thishunk];
if (!(entry->flags & MAP_ENTRY_FLAG_NO_CRC) && entry->crc != crc32(0, chd->cache, chd->header.hunkbytes))
return CHDERR_DECOMPRESSION_ERROR;
return CHDERR_NONE;
} | /*-------------------------------------------------
chd_verify_hunk - verify the next hunk in
the CHD
-------------------------------------------------*/ | verify the next hunk in
the CHD | [
"verify",
"the",
"next",
"hunk",
"in",
"the",
"CHD"
] | chd_error chd_verify_hunk(chd_file *chd)
{
UINT32 thishunk = chd->verhunk++;
UINT64 hunkoffset = (UINT64)thishunk * (UINT64)chd->header.hunkbytes;
map_entry *entry;
chd_error err;
if (!chd->verifying)
return CHDERR_INVALID_STATE;
err = hunk_read_into_cache(chd, thishunk);
if (err != CHDERR_NONE)
return err;
if (hunkoffset < chd->header.logicalbytes)
{
UINT64 bytestochecksum = MIN(chd->header.hunkbytes, chd->header.logicalbytes - hunkoffset);
if (bytestochecksum > 0)
{
MD5Update(&chd->vermd5, chd->cache, bytestochecksum);
sha1_update(&chd->versha1, bytestochecksum, chd->cache);
}
}
entry = &chd->map[thishunk];
if (!(entry->flags & MAP_ENTRY_FLAG_NO_CRC) && entry->crc != crc32(0, chd->cache, chd->header.hunkbytes))
return CHDERR_DECOMPRESSION_ERROR;
return CHDERR_NONE;
} | [
"chd_error",
"chd_verify_hunk",
"(",
"chd_file",
"*",
"chd",
")",
"{",
"UINT32",
"thishunk",
"=",
"chd",
"->",
"verhunk",
"++",
";",
"UINT64",
"hunkoffset",
"=",
"(",
"UINT64",
")",
"thishunk",
"*",
"(",
"UINT64",
")",
"chd",
"->",
"header",
".",
"hunkbytes",
";",
"map_entry",
"*",
"entry",
";",
"chd_error",
"err",
";",
"if",
"(",
"!",
"chd",
"->",
"verifying",
")",
"return",
"CHDERR_INVALID_STATE",
";",
"err",
"=",
"hunk_read_into_cache",
"(",
"chd",
",",
"thishunk",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"return",
"err",
";",
"if",
"(",
"hunkoffset",
"<",
"chd",
"->",
"header",
".",
"logicalbytes",
")",
"{",
"UINT64",
"bytestochecksum",
"=",
"MIN",
"(",
"chd",
"->",
"header",
".",
"hunkbytes",
",",
"chd",
"->",
"header",
".",
"logicalbytes",
"-",
"hunkoffset",
")",
";",
"if",
"(",
"bytestochecksum",
">",
"0",
")",
"{",
"MD5Update",
"(",
"&",
"chd",
"->",
"vermd5",
",",
"chd",
"->",
"cache",
",",
"bytestochecksum",
")",
";",
"sha1_update",
"(",
"&",
"chd",
"->",
"versha1",
",",
"bytestochecksum",
",",
"chd",
"->",
"cache",
")",
";",
"}",
"}",
"entry",
"=",
"&",
"chd",
"->",
"map",
"[",
"thishunk",
"]",
";",
"if",
"(",
"!",
"(",
"entry",
"->",
"flags",
"&",
"MAP_ENTRY_FLAG_NO_CRC",
")",
"&&",
"entry",
"->",
"crc",
"!=",
"crc32",
"(",
"0",
",",
"chd",
"->",
"cache",
",",
"chd",
"->",
"header",
".",
"hunkbytes",
")",
")",
"return",
"CHDERR_DECOMPRESSION_ERROR",
";",
"return",
"CHDERR_NONE",
";",
"}"
] | chd_verify_hunk - verify the next hunk in
the CHD | [
"chd_verify_hunk",
"-",
"verify",
"the",
"next",
"hunk",
"in",
"the",
"CHD"
] | [
"/* error if in the wrong state */",
"/* read the hunk into the cache */",
"/* update the MD5/SHA1 */",
"/* validate the CRC if we have one */"
] | [
{
"param": "chd",
"type": "chd_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | chd_get_codec_name | char | const char *chd_get_codec_name(UINT32 codec)
{
int intfnum;
/* look for a matching codec and return its string */
for (intfnum = 0; intfnum < ARRAY_LENGTH(codec_interfaces); intfnum++)
if (codec_interfaces[intfnum].compression == codec)
return codec_interfaces[intfnum].compname;
return "Unknown";
} | /*-------------------------------------------------
chd_get_codec_name - get the name of a
particular codec
-------------------------------------------------*/ | get the name of a
particular codec | [
"get",
"the",
"name",
"of",
"a",
"particular",
"codec"
] | const char *chd_get_codec_name(UINT32 codec)
{
int intfnum;
for (intfnum = 0; intfnum < ARRAY_LENGTH(codec_interfaces); intfnum++)
if (codec_interfaces[intfnum].compression == codec)
return codec_interfaces[intfnum].compname;
return "Unknown";
} | [
"const",
"char",
"*",
"chd_get_codec_name",
"(",
"UINT32",
"codec",
")",
"{",
"int",
"intfnum",
";",
"for",
"(",
"intfnum",
"=",
"0",
";",
"intfnum",
"<",
"ARRAY_LENGTH",
"(",
"codec_interfaces",
")",
";",
"intfnum",
"++",
")",
"if",
"(",
"codec_interfaces",
"[",
"intfnum",
"]",
".",
"compression",
"==",
"codec",
")",
"return",
"codec_interfaces",
"[",
"intfnum",
"]",
".",
"compname",
";",
"return",
"\"",
"\"",
";",
"}"
] | chd_get_codec_name - get the name of a
particular codec | [
"chd_get_codec_name",
"-",
"get",
"the",
"name",
"of",
"a",
"particular",
"codec"
] | [
"/* look for a matching codec and return its string */"
] | [
{
"param": "codec",
"type": "UINT32"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "codec",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | header_validate | chd_error | static chd_error header_validate(const chd_header *header)
{
int intfnum;
/* require a valid version */
if (header->version == 0 || header->version > CHD_HEADER_VERSION)
return CHDERR_UNSUPPORTED_VERSION;
/* require a valid length */
if ((header->version == 1 && header->length != CHD_V1_HEADER_SIZE) ||
(header->version == 2 && header->length != CHD_V2_HEADER_SIZE) ||
(header->version == 3 && header->length != CHD_V3_HEADER_SIZE) ||
(header->version == 4 && header->length != CHD_V4_HEADER_SIZE))
return CHDERR_INVALID_PARAMETER;
/* require valid flags */
if (header->flags & CHDFLAGS_UNDEFINED)
return CHDERR_INVALID_PARAMETER;
/* require a supported compression mechanism */
for (intfnum = 0; intfnum < ARRAY_LENGTH(codec_interfaces); intfnum++)
if (codec_interfaces[intfnum].compression == header->compression)
break;
if (intfnum == ARRAY_LENGTH(codec_interfaces))
return CHDERR_INVALID_PARAMETER;
/* require a valid hunksize */
if (header->hunkbytes == 0 || header->hunkbytes >= 65536 * 256)
return CHDERR_INVALID_PARAMETER;
/* require a valid hunk count */
if (header->totalhunks == 0)
return CHDERR_INVALID_PARAMETER;
/* require a valid MD5 and/or SHA1 if we're using a parent */
if ((header->flags & CHDFLAGS_HAS_PARENT) && memcmp(header->parentmd5, nullmd5, sizeof(nullmd5)) == 0 && memcmp(header->parentsha1, nullsha1, sizeof(nullsha1)) == 0)
return CHDERR_INVALID_PARAMETER;
/* if we're V3 or later, the obsolete fields must be 0 */
if (header->version >= 3 &&
(header->obsolete_cylinders != 0 || header->obsolete_sectors != 0 ||
header->obsolete_heads != 0 || header->obsolete_hunksize != 0))
return CHDERR_INVALID_PARAMETER;
/* if we're pre-V3, the obsolete fields must NOT be 0 */
if (header->version < 3 &&
(header->obsolete_cylinders == 0 || header->obsolete_sectors == 0 ||
header->obsolete_heads == 0 || header->obsolete_hunksize == 0))
return CHDERR_INVALID_PARAMETER;
return CHDERR_NONE;
} | /*-------------------------------------------------
header_validate - check the validity of a
CHD header
-------------------------------------------------*/ | check the validity of a
CHD header | [
"check",
"the",
"validity",
"of",
"a",
"CHD",
"header"
] | static chd_error header_validate(const chd_header *header)
{
int intfnum;
if (header->version == 0 || header->version > CHD_HEADER_VERSION)
return CHDERR_UNSUPPORTED_VERSION;
if ((header->version == 1 && header->length != CHD_V1_HEADER_SIZE) ||
(header->version == 2 && header->length != CHD_V2_HEADER_SIZE) ||
(header->version == 3 && header->length != CHD_V3_HEADER_SIZE) ||
(header->version == 4 && header->length != CHD_V4_HEADER_SIZE))
return CHDERR_INVALID_PARAMETER;
if (header->flags & CHDFLAGS_UNDEFINED)
return CHDERR_INVALID_PARAMETER;
for (intfnum = 0; intfnum < ARRAY_LENGTH(codec_interfaces); intfnum++)
if (codec_interfaces[intfnum].compression == header->compression)
break;
if (intfnum == ARRAY_LENGTH(codec_interfaces))
return CHDERR_INVALID_PARAMETER;
if (header->hunkbytes == 0 || header->hunkbytes >= 65536 * 256)
return CHDERR_INVALID_PARAMETER;
if (header->totalhunks == 0)
return CHDERR_INVALID_PARAMETER;
if ((header->flags & CHDFLAGS_HAS_PARENT) && memcmp(header->parentmd5, nullmd5, sizeof(nullmd5)) == 0 && memcmp(header->parentsha1, nullsha1, sizeof(nullsha1)) == 0)
return CHDERR_INVALID_PARAMETER;
if (header->version >= 3 &&
(header->obsolete_cylinders != 0 || header->obsolete_sectors != 0 ||
header->obsolete_heads != 0 || header->obsolete_hunksize != 0))
return CHDERR_INVALID_PARAMETER;
if (header->version < 3 &&
(header->obsolete_cylinders == 0 || header->obsolete_sectors == 0 ||
header->obsolete_heads == 0 || header->obsolete_hunksize == 0))
return CHDERR_INVALID_PARAMETER;
return CHDERR_NONE;
} | [
"static",
"chd_error",
"header_validate",
"(",
"const",
"chd_header",
"*",
"header",
")",
"{",
"int",
"intfnum",
";",
"if",
"(",
"header",
"->",
"version",
"==",
"0",
"||",
"header",
"->",
"version",
">",
"CHD_HEADER_VERSION",
")",
"return",
"CHDERR_UNSUPPORTED_VERSION",
";",
"if",
"(",
"(",
"header",
"->",
"version",
"==",
"1",
"&&",
"header",
"->",
"length",
"!=",
"CHD_V1_HEADER_SIZE",
")",
"||",
"(",
"header",
"->",
"version",
"==",
"2",
"&&",
"header",
"->",
"length",
"!=",
"CHD_V2_HEADER_SIZE",
")",
"||",
"(",
"header",
"->",
"version",
"==",
"3",
"&&",
"header",
"->",
"length",
"!=",
"CHD_V3_HEADER_SIZE",
")",
"||",
"(",
"header",
"->",
"version",
"==",
"4",
"&&",
"header",
"->",
"length",
"!=",
"CHD_V4_HEADER_SIZE",
")",
")",
"return",
"CHDERR_INVALID_PARAMETER",
";",
"if",
"(",
"header",
"->",
"flags",
"&",
"CHDFLAGS_UNDEFINED",
")",
"return",
"CHDERR_INVALID_PARAMETER",
";",
"for",
"(",
"intfnum",
"=",
"0",
";",
"intfnum",
"<",
"ARRAY_LENGTH",
"(",
"codec_interfaces",
")",
";",
"intfnum",
"++",
")",
"if",
"(",
"codec_interfaces",
"[",
"intfnum",
"]",
".",
"compression",
"==",
"header",
"->",
"compression",
")",
"break",
";",
"if",
"(",
"intfnum",
"==",
"ARRAY_LENGTH",
"(",
"codec_interfaces",
")",
")",
"return",
"CHDERR_INVALID_PARAMETER",
";",
"if",
"(",
"header",
"->",
"hunkbytes",
"==",
"0",
"||",
"header",
"->",
"hunkbytes",
">=",
"65536",
"*",
"256",
")",
"return",
"CHDERR_INVALID_PARAMETER",
";",
"if",
"(",
"header",
"->",
"totalhunks",
"==",
"0",
")",
"return",
"CHDERR_INVALID_PARAMETER",
";",
"if",
"(",
"(",
"header",
"->",
"flags",
"&",
"CHDFLAGS_HAS_PARENT",
")",
"&&",
"memcmp",
"(",
"header",
"->",
"parentmd5",
",",
"nullmd5",
",",
"sizeof",
"(",
"nullmd5",
")",
")",
"==",
"0",
"&&",
"memcmp",
"(",
"header",
"->",
"parentsha1",
",",
"nullsha1",
",",
"sizeof",
"(",
"nullsha1",
")",
")",
"==",
"0",
")",
"return",
"CHDERR_INVALID_PARAMETER",
";",
"if",
"(",
"header",
"->",
"version",
">=",
"3",
"&&",
"(",
"header",
"->",
"obsolete_cylinders",
"!=",
"0",
"||",
"header",
"->",
"obsolete_sectors",
"!=",
"0",
"||",
"header",
"->",
"obsolete_heads",
"!=",
"0",
"||",
"header",
"->",
"obsolete_hunksize",
"!=",
"0",
")",
")",
"return",
"CHDERR_INVALID_PARAMETER",
";",
"if",
"(",
"header",
"->",
"version",
"<",
"3",
"&&",
"(",
"header",
"->",
"obsolete_cylinders",
"==",
"0",
"||",
"header",
"->",
"obsolete_sectors",
"==",
"0",
"||",
"header",
"->",
"obsolete_heads",
"==",
"0",
"||",
"header",
"->",
"obsolete_hunksize",
"==",
"0",
")",
")",
"return",
"CHDERR_INVALID_PARAMETER",
";",
"return",
"CHDERR_NONE",
";",
"}"
] | header_validate - check the validity of a
CHD header | [
"header_validate",
"-",
"check",
"the",
"validity",
"of",
"a",
"CHD",
"header"
] | [
"/* require a valid version */",
"/* require a valid length */",
"/* require valid flags */",
"/* require a supported compression mechanism */",
"/* require a valid hunksize */",
"/* require a valid hunk count */",
"/* require a valid MD5 and/or SHA1 if we're using a parent */",
"/* if we're V3 or later, the obsolete fields must be 0 */",
"/* if we're pre-V3, the obsolete fields must NOT be 0 */"
] | [
{
"param": "header",
"type": "chd_header"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "header",
"type": "chd_header",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | header_read | chd_error | static chd_error header_read(core_file *file, chd_header *header)
{
UINT8 rawheader[CHD_MAX_HEADER_SIZE];
UINT32 count;
/* punt if NULL */
if (header == NULL)
return CHDERR_INVALID_PARAMETER;
/* punt if invalid file */
if (file == NULL)
return CHDERR_INVALID_FILE;
/* seek and read */
core_fseek(file, 0, SEEK_SET);
count = core_fread(file, rawheader, sizeof(rawheader));
if (count != sizeof(rawheader))
return CHDERR_READ_ERROR;
/* verify the tag */
if (strncmp((char *)rawheader, "MComprHD", 8) != 0)
return CHDERR_INVALID_DATA;
/* extract the direct data */
memset(header, 0, sizeof(*header));
header->length = get_bigendian_uint32(&rawheader[8]);
header->version = get_bigendian_uint32(&rawheader[12]);
/* make sure it's a version we understand */
if (header->version == 0 || header->version > CHD_HEADER_VERSION)
return CHDERR_UNSUPPORTED_VERSION;
/* make sure the length is expected */
if ((header->version == 1 && header->length != CHD_V1_HEADER_SIZE) ||
(header->version == 2 && header->length != CHD_V2_HEADER_SIZE) ||
(header->version == 3 && header->length != CHD_V3_HEADER_SIZE) ||
(header->version == 4 && header->length != CHD_V4_HEADER_SIZE))
return CHDERR_INVALID_DATA;
/* extract the common data */
header->flags = get_bigendian_uint32(&rawheader[16]);
header->compression = get_bigendian_uint32(&rawheader[20]);
/* extract the V1/V2-specific data */
if (header->version < 3)
{
int seclen = (header->version == 1) ? CHD_V1_SECTOR_SIZE : get_bigendian_uint32(&rawheader[76]);
header->obsolete_hunksize = get_bigendian_uint32(&rawheader[24]);
header->totalhunks = get_bigendian_uint32(&rawheader[28]);
header->obsolete_cylinders = get_bigendian_uint32(&rawheader[32]);
header->obsolete_heads = get_bigendian_uint32(&rawheader[36]);
header->obsolete_sectors = get_bigendian_uint32(&rawheader[40]);
memcpy(header->md5, &rawheader[44], CHD_MD5_BYTES);
memcpy(header->parentmd5, &rawheader[60], CHD_MD5_BYTES);
header->logicalbytes = (UINT64)header->obsolete_cylinders * (UINT64)header->obsolete_heads * (UINT64)header->obsolete_sectors * (UINT64)seclen;
header->hunkbytes = seclen * header->obsolete_hunksize;
header->metaoffset = 0;
}
/* extract the V3-specific data */
else if (header->version == 3)
{
header->totalhunks = get_bigendian_uint32(&rawheader[24]);
header->logicalbytes = get_bigendian_uint64(&rawheader[28]);
header->metaoffset = get_bigendian_uint64(&rawheader[36]);
memcpy(header->md5, &rawheader[44], CHD_MD5_BYTES);
memcpy(header->parentmd5, &rawheader[60], CHD_MD5_BYTES);
header->hunkbytes = get_bigendian_uint32(&rawheader[76]);
memcpy(header->sha1, &rawheader[80], CHD_SHA1_BYTES);
memcpy(header->parentsha1, &rawheader[100], CHD_SHA1_BYTES);
}
/* extract the V4-specific data */
else
{
header->totalhunks = get_bigendian_uint32(&rawheader[24]);
header->logicalbytes = get_bigendian_uint64(&rawheader[28]);
header->metaoffset = get_bigendian_uint64(&rawheader[36]);
header->hunkbytes = get_bigendian_uint32(&rawheader[44]);
memcpy(header->sha1, &rawheader[48], CHD_SHA1_BYTES);
memcpy(header->parentsha1, &rawheader[68], CHD_SHA1_BYTES);
memcpy(header->rawsha1, &rawheader[88], CHD_SHA1_BYTES);
}
/* guess it worked */
return CHDERR_NONE;
} | /*-------------------------------------------------
header_read - read a CHD header into the
internal data structure
-------------------------------------------------*/ | read a CHD header into the
internal data structure | [
"read",
"a",
"CHD",
"header",
"into",
"the",
"internal",
"data",
"structure"
] | static chd_error header_read(core_file *file, chd_header *header)
{
UINT8 rawheader[CHD_MAX_HEADER_SIZE];
UINT32 count;
if (header == NULL)
return CHDERR_INVALID_PARAMETER;
if (file == NULL)
return CHDERR_INVALID_FILE;
core_fseek(file, 0, SEEK_SET);
count = core_fread(file, rawheader, sizeof(rawheader));
if (count != sizeof(rawheader))
return CHDERR_READ_ERROR;
if (strncmp((char *)rawheader, "MComprHD", 8) != 0)
return CHDERR_INVALID_DATA;
memset(header, 0, sizeof(*header));
header->length = get_bigendian_uint32(&rawheader[8]);
header->version = get_bigendian_uint32(&rawheader[12]);
if (header->version == 0 || header->version > CHD_HEADER_VERSION)
return CHDERR_UNSUPPORTED_VERSION;
if ((header->version == 1 && header->length != CHD_V1_HEADER_SIZE) ||
(header->version == 2 && header->length != CHD_V2_HEADER_SIZE) ||
(header->version == 3 && header->length != CHD_V3_HEADER_SIZE) ||
(header->version == 4 && header->length != CHD_V4_HEADER_SIZE))
return CHDERR_INVALID_DATA;
header->flags = get_bigendian_uint32(&rawheader[16]);
header->compression = get_bigendian_uint32(&rawheader[20]);
if (header->version < 3)
{
int seclen = (header->version == 1) ? CHD_V1_SECTOR_SIZE : get_bigendian_uint32(&rawheader[76]);
header->obsolete_hunksize = get_bigendian_uint32(&rawheader[24]);
header->totalhunks = get_bigendian_uint32(&rawheader[28]);
header->obsolete_cylinders = get_bigendian_uint32(&rawheader[32]);
header->obsolete_heads = get_bigendian_uint32(&rawheader[36]);
header->obsolete_sectors = get_bigendian_uint32(&rawheader[40]);
memcpy(header->md5, &rawheader[44], CHD_MD5_BYTES);
memcpy(header->parentmd5, &rawheader[60], CHD_MD5_BYTES);
header->logicalbytes = (UINT64)header->obsolete_cylinders * (UINT64)header->obsolete_heads * (UINT64)header->obsolete_sectors * (UINT64)seclen;
header->hunkbytes = seclen * header->obsolete_hunksize;
header->metaoffset = 0;
}
else if (header->version == 3)
{
header->totalhunks = get_bigendian_uint32(&rawheader[24]);
header->logicalbytes = get_bigendian_uint64(&rawheader[28]);
header->metaoffset = get_bigendian_uint64(&rawheader[36]);
memcpy(header->md5, &rawheader[44], CHD_MD5_BYTES);
memcpy(header->parentmd5, &rawheader[60], CHD_MD5_BYTES);
header->hunkbytes = get_bigendian_uint32(&rawheader[76]);
memcpy(header->sha1, &rawheader[80], CHD_SHA1_BYTES);
memcpy(header->parentsha1, &rawheader[100], CHD_SHA1_BYTES);
}
else
{
header->totalhunks = get_bigendian_uint32(&rawheader[24]);
header->logicalbytes = get_bigendian_uint64(&rawheader[28]);
header->metaoffset = get_bigendian_uint64(&rawheader[36]);
header->hunkbytes = get_bigendian_uint32(&rawheader[44]);
memcpy(header->sha1, &rawheader[48], CHD_SHA1_BYTES);
memcpy(header->parentsha1, &rawheader[68], CHD_SHA1_BYTES);
memcpy(header->rawsha1, &rawheader[88], CHD_SHA1_BYTES);
}
return CHDERR_NONE;
} | [
"static",
"chd_error",
"header_read",
"(",
"core_file",
"*",
"file",
",",
"chd_header",
"*",
"header",
")",
"{",
"UINT8",
"rawheader",
"[",
"CHD_MAX_HEADER_SIZE",
"]",
";",
"UINT32",
"count",
";",
"if",
"(",
"header",
"==",
"NULL",
")",
"return",
"CHDERR_INVALID_PARAMETER",
";",
"if",
"(",
"file",
"==",
"NULL",
")",
"return",
"CHDERR_INVALID_FILE",
";",
"core_fseek",
"(",
"file",
",",
"0",
",",
"SEEK_SET",
")",
";",
"count",
"=",
"core_fread",
"(",
"file",
",",
"rawheader",
",",
"sizeof",
"(",
"rawheader",
")",
")",
";",
"if",
"(",
"count",
"!=",
"sizeof",
"(",
"rawheader",
")",
")",
"return",
"CHDERR_READ_ERROR",
";",
"if",
"(",
"strncmp",
"(",
"(",
"char",
"*",
")",
"rawheader",
",",
"\"",
"\"",
",",
"8",
")",
"!=",
"0",
")",
"return",
"CHDERR_INVALID_DATA",
";",
"memset",
"(",
"header",
",",
"0",
",",
"sizeof",
"(",
"*",
"header",
")",
")",
";",
"header",
"->",
"length",
"=",
"get_bigendian_uint32",
"(",
"&",
"rawheader",
"[",
"8",
"]",
")",
";",
"header",
"->",
"version",
"=",
"get_bigendian_uint32",
"(",
"&",
"rawheader",
"[",
"12",
"]",
")",
";",
"if",
"(",
"header",
"->",
"version",
"==",
"0",
"||",
"header",
"->",
"version",
">",
"CHD_HEADER_VERSION",
")",
"return",
"CHDERR_UNSUPPORTED_VERSION",
";",
"if",
"(",
"(",
"header",
"->",
"version",
"==",
"1",
"&&",
"header",
"->",
"length",
"!=",
"CHD_V1_HEADER_SIZE",
")",
"||",
"(",
"header",
"->",
"version",
"==",
"2",
"&&",
"header",
"->",
"length",
"!=",
"CHD_V2_HEADER_SIZE",
")",
"||",
"(",
"header",
"->",
"version",
"==",
"3",
"&&",
"header",
"->",
"length",
"!=",
"CHD_V3_HEADER_SIZE",
")",
"||",
"(",
"header",
"->",
"version",
"==",
"4",
"&&",
"header",
"->",
"length",
"!=",
"CHD_V4_HEADER_SIZE",
")",
")",
"return",
"CHDERR_INVALID_DATA",
";",
"header",
"->",
"flags",
"=",
"get_bigendian_uint32",
"(",
"&",
"rawheader",
"[",
"16",
"]",
")",
";",
"header",
"->",
"compression",
"=",
"get_bigendian_uint32",
"(",
"&",
"rawheader",
"[",
"20",
"]",
")",
";",
"if",
"(",
"header",
"->",
"version",
"<",
"3",
")",
"{",
"int",
"seclen",
"=",
"(",
"header",
"->",
"version",
"==",
"1",
")",
"?",
"CHD_V1_SECTOR_SIZE",
":",
"get_bigendian_uint32",
"(",
"&",
"rawheader",
"[",
"76",
"]",
")",
";",
"header",
"->",
"obsolete_hunksize",
"=",
"get_bigendian_uint32",
"(",
"&",
"rawheader",
"[",
"24",
"]",
")",
";",
"header",
"->",
"totalhunks",
"=",
"get_bigendian_uint32",
"(",
"&",
"rawheader",
"[",
"28",
"]",
")",
";",
"header",
"->",
"obsolete_cylinders",
"=",
"get_bigendian_uint32",
"(",
"&",
"rawheader",
"[",
"32",
"]",
")",
";",
"header",
"->",
"obsolete_heads",
"=",
"get_bigendian_uint32",
"(",
"&",
"rawheader",
"[",
"36",
"]",
")",
";",
"header",
"->",
"obsolete_sectors",
"=",
"get_bigendian_uint32",
"(",
"&",
"rawheader",
"[",
"40",
"]",
")",
";",
"memcpy",
"(",
"header",
"->",
"md5",
",",
"&",
"rawheader",
"[",
"44",
"]",
",",
"CHD_MD5_BYTES",
")",
";",
"memcpy",
"(",
"header",
"->",
"parentmd5",
",",
"&",
"rawheader",
"[",
"60",
"]",
",",
"CHD_MD5_BYTES",
")",
";",
"header",
"->",
"logicalbytes",
"=",
"(",
"UINT64",
")",
"header",
"->",
"obsolete_cylinders",
"*",
"(",
"UINT64",
")",
"header",
"->",
"obsolete_heads",
"*",
"(",
"UINT64",
")",
"header",
"->",
"obsolete_sectors",
"*",
"(",
"UINT64",
")",
"seclen",
";",
"header",
"->",
"hunkbytes",
"=",
"seclen",
"*",
"header",
"->",
"obsolete_hunksize",
";",
"header",
"->",
"metaoffset",
"=",
"0",
";",
"}",
"else",
"if",
"(",
"header",
"->",
"version",
"==",
"3",
")",
"{",
"header",
"->",
"totalhunks",
"=",
"get_bigendian_uint32",
"(",
"&",
"rawheader",
"[",
"24",
"]",
")",
";",
"header",
"->",
"logicalbytes",
"=",
"get_bigendian_uint64",
"(",
"&",
"rawheader",
"[",
"28",
"]",
")",
";",
"header",
"->",
"metaoffset",
"=",
"get_bigendian_uint64",
"(",
"&",
"rawheader",
"[",
"36",
"]",
")",
";",
"memcpy",
"(",
"header",
"->",
"md5",
",",
"&",
"rawheader",
"[",
"44",
"]",
",",
"CHD_MD5_BYTES",
")",
";",
"memcpy",
"(",
"header",
"->",
"parentmd5",
",",
"&",
"rawheader",
"[",
"60",
"]",
",",
"CHD_MD5_BYTES",
")",
";",
"header",
"->",
"hunkbytes",
"=",
"get_bigendian_uint32",
"(",
"&",
"rawheader",
"[",
"76",
"]",
")",
";",
"memcpy",
"(",
"header",
"->",
"sha1",
",",
"&",
"rawheader",
"[",
"80",
"]",
",",
"CHD_SHA1_BYTES",
")",
";",
"memcpy",
"(",
"header",
"->",
"parentsha1",
",",
"&",
"rawheader",
"[",
"100",
"]",
",",
"CHD_SHA1_BYTES",
")",
";",
"}",
"else",
"{",
"header",
"->",
"totalhunks",
"=",
"get_bigendian_uint32",
"(",
"&",
"rawheader",
"[",
"24",
"]",
")",
";",
"header",
"->",
"logicalbytes",
"=",
"get_bigendian_uint64",
"(",
"&",
"rawheader",
"[",
"28",
"]",
")",
";",
"header",
"->",
"metaoffset",
"=",
"get_bigendian_uint64",
"(",
"&",
"rawheader",
"[",
"36",
"]",
")",
";",
"header",
"->",
"hunkbytes",
"=",
"get_bigendian_uint32",
"(",
"&",
"rawheader",
"[",
"44",
"]",
")",
";",
"memcpy",
"(",
"header",
"->",
"sha1",
",",
"&",
"rawheader",
"[",
"48",
"]",
",",
"CHD_SHA1_BYTES",
")",
";",
"memcpy",
"(",
"header",
"->",
"parentsha1",
",",
"&",
"rawheader",
"[",
"68",
"]",
",",
"CHD_SHA1_BYTES",
")",
";",
"memcpy",
"(",
"header",
"->",
"rawsha1",
",",
"&",
"rawheader",
"[",
"88",
"]",
",",
"CHD_SHA1_BYTES",
")",
";",
"}",
"return",
"CHDERR_NONE",
";",
"}"
] | header_read - read a CHD header into the
internal data structure | [
"header_read",
"-",
"read",
"a",
"CHD",
"header",
"into",
"the",
"internal",
"data",
"structure"
] | [
"/* punt if NULL */",
"/* punt if invalid file */",
"/* seek and read */",
"/* verify the tag */",
"/* extract the direct data */",
"/* make sure it's a version we understand */",
"/* make sure the length is expected */",
"/* extract the common data */",
"/* extract the V1/V2-specific data */",
"/* extract the V3-specific data */",
"/* extract the V4-specific data */",
"/* guess it worked */"
] | [
{
"param": "file",
"type": "core_file"
},
{
"param": "header",
"type": "chd_header"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": "core_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "header",
"type": "chd_header",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | header_write | chd_error | static chd_error header_write(core_file *file, const chd_header *header)
{
UINT8 rawheader[CHD_MAX_HEADER_SIZE];
UINT32 count;
/* punt if NULL */
if (header == NULL)
return CHDERR_INVALID_PARAMETER;
/* punt if invalid file */
if (file == NULL)
return CHDERR_INVALID_FILE;
/* only support writing modern headers */
if (header->version != 4)
return CHDERR_INVALID_PARAMETER;
/* assemble the data */
memset(rawheader, 0, sizeof(rawheader));
memcpy(rawheader, "MComprHD", 8);
put_bigendian_uint32(&rawheader[8], CHD_V4_HEADER_SIZE);
put_bigendian_uint32(&rawheader[12], header->version);
put_bigendian_uint32(&rawheader[16], header->flags);
put_bigendian_uint32(&rawheader[20], header->compression);
put_bigendian_uint32(&rawheader[24], header->totalhunks);
put_bigendian_uint64(&rawheader[28], header->logicalbytes);
put_bigendian_uint64(&rawheader[36], header->metaoffset);
put_bigendian_uint32(&rawheader[44], header->hunkbytes);
memcpy(&rawheader[48], header->sha1, CHD_SHA1_BYTES);
memcpy(&rawheader[68], header->parentsha1, CHD_SHA1_BYTES);
memcpy(&rawheader[88], header->rawsha1, CHD_SHA1_BYTES);
/* seek and write */
core_fseek(file, 0, SEEK_SET);
count = core_fwrite(file, rawheader, CHD_V4_HEADER_SIZE);
if (count != CHD_V4_HEADER_SIZE)
return CHDERR_WRITE_ERROR;
return CHDERR_NONE;
} | /*-------------------------------------------------
header_write - write a CHD header from the
internal data structure
-------------------------------------------------*/ | write a CHD header from the
internal data structure | [
"write",
"a",
"CHD",
"header",
"from",
"the",
"internal",
"data",
"structure"
] | static chd_error header_write(core_file *file, const chd_header *header)
{
UINT8 rawheader[CHD_MAX_HEADER_SIZE];
UINT32 count;
if (header == NULL)
return CHDERR_INVALID_PARAMETER;
if (file == NULL)
return CHDERR_INVALID_FILE;
if (header->version != 4)
return CHDERR_INVALID_PARAMETER;
memset(rawheader, 0, sizeof(rawheader));
memcpy(rawheader, "MComprHD", 8);
put_bigendian_uint32(&rawheader[8], CHD_V4_HEADER_SIZE);
put_bigendian_uint32(&rawheader[12], header->version);
put_bigendian_uint32(&rawheader[16], header->flags);
put_bigendian_uint32(&rawheader[20], header->compression);
put_bigendian_uint32(&rawheader[24], header->totalhunks);
put_bigendian_uint64(&rawheader[28], header->logicalbytes);
put_bigendian_uint64(&rawheader[36], header->metaoffset);
put_bigendian_uint32(&rawheader[44], header->hunkbytes);
memcpy(&rawheader[48], header->sha1, CHD_SHA1_BYTES);
memcpy(&rawheader[68], header->parentsha1, CHD_SHA1_BYTES);
memcpy(&rawheader[88], header->rawsha1, CHD_SHA1_BYTES);
core_fseek(file, 0, SEEK_SET);
count = core_fwrite(file, rawheader, CHD_V4_HEADER_SIZE);
if (count != CHD_V4_HEADER_SIZE)
return CHDERR_WRITE_ERROR;
return CHDERR_NONE;
} | [
"static",
"chd_error",
"header_write",
"(",
"core_file",
"*",
"file",
",",
"const",
"chd_header",
"*",
"header",
")",
"{",
"UINT8",
"rawheader",
"[",
"CHD_MAX_HEADER_SIZE",
"]",
";",
"UINT32",
"count",
";",
"if",
"(",
"header",
"==",
"NULL",
")",
"return",
"CHDERR_INVALID_PARAMETER",
";",
"if",
"(",
"file",
"==",
"NULL",
")",
"return",
"CHDERR_INVALID_FILE",
";",
"if",
"(",
"header",
"->",
"version",
"!=",
"4",
")",
"return",
"CHDERR_INVALID_PARAMETER",
";",
"memset",
"(",
"rawheader",
",",
"0",
",",
"sizeof",
"(",
"rawheader",
")",
")",
";",
"memcpy",
"(",
"rawheader",
",",
"\"",
"\"",
",",
"8",
")",
";",
"put_bigendian_uint32",
"(",
"&",
"rawheader",
"[",
"8",
"]",
",",
"CHD_V4_HEADER_SIZE",
")",
";",
"put_bigendian_uint32",
"(",
"&",
"rawheader",
"[",
"12",
"]",
",",
"header",
"->",
"version",
")",
";",
"put_bigendian_uint32",
"(",
"&",
"rawheader",
"[",
"16",
"]",
",",
"header",
"->",
"flags",
")",
";",
"put_bigendian_uint32",
"(",
"&",
"rawheader",
"[",
"20",
"]",
",",
"header",
"->",
"compression",
")",
";",
"put_bigendian_uint32",
"(",
"&",
"rawheader",
"[",
"24",
"]",
",",
"header",
"->",
"totalhunks",
")",
";",
"put_bigendian_uint64",
"(",
"&",
"rawheader",
"[",
"28",
"]",
",",
"header",
"->",
"logicalbytes",
")",
";",
"put_bigendian_uint64",
"(",
"&",
"rawheader",
"[",
"36",
"]",
",",
"header",
"->",
"metaoffset",
")",
";",
"put_bigendian_uint32",
"(",
"&",
"rawheader",
"[",
"44",
"]",
",",
"header",
"->",
"hunkbytes",
")",
";",
"memcpy",
"(",
"&",
"rawheader",
"[",
"48",
"]",
",",
"header",
"->",
"sha1",
",",
"CHD_SHA1_BYTES",
")",
";",
"memcpy",
"(",
"&",
"rawheader",
"[",
"68",
"]",
",",
"header",
"->",
"parentsha1",
",",
"CHD_SHA1_BYTES",
")",
";",
"memcpy",
"(",
"&",
"rawheader",
"[",
"88",
"]",
",",
"header",
"->",
"rawsha1",
",",
"CHD_SHA1_BYTES",
")",
";",
"core_fseek",
"(",
"file",
",",
"0",
",",
"SEEK_SET",
")",
";",
"count",
"=",
"core_fwrite",
"(",
"file",
",",
"rawheader",
",",
"CHD_V4_HEADER_SIZE",
")",
";",
"if",
"(",
"count",
"!=",
"CHD_V4_HEADER_SIZE",
")",
"return",
"CHDERR_WRITE_ERROR",
";",
"return",
"CHDERR_NONE",
";",
"}"
] | header_write - write a CHD header from the
internal data structure | [
"header_write",
"-",
"write",
"a",
"CHD",
"header",
"from",
"the",
"internal",
"data",
"structure"
] | [
"/* punt if NULL */",
"/* punt if invalid file */",
"/* only support writing modern headers */",
"/* assemble the data */",
"/* seek and write */"
] | [
{
"param": "file",
"type": "core_file"
},
{
"param": "header",
"type": "chd_header"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": "core_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "header",
"type": "chd_header",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | hunk_read_into_cache | chd_error | static chd_error hunk_read_into_cache(chd_file *chd, UINT32 hunknum)
{
chd_error err;
/* track the max */
if (hunknum > chd->maxhunk)
chd->maxhunk = hunknum;
/* if we're already in the cache, we're done */
if (chd->cachehunk == hunknum)
return CHDERR_NONE;
chd->cachehunk = ~0;
/* otherwise, read the data */
err = hunk_read_into_memory(chd, hunknum, chd->cache);
if (err != CHDERR_NONE)
return err;
/* mark the hunk successfully cached in */
chd->cachehunk = hunknum;
return CHDERR_NONE;
} | /*-------------------------------------------------
hunk_read_into_cache - read a hunk into
the CHD's hunk cache
-------------------------------------------------*/ | read a hunk into
the CHD's hunk cache | [
"read",
"a",
"hunk",
"into",
"the",
"CHD",
"'",
"s",
"hunk",
"cache"
] | static chd_error hunk_read_into_cache(chd_file *chd, UINT32 hunknum)
{
chd_error err;
if (hunknum > chd->maxhunk)
chd->maxhunk = hunknum;
if (chd->cachehunk == hunknum)
return CHDERR_NONE;
chd->cachehunk = ~0;
err = hunk_read_into_memory(chd, hunknum, chd->cache);
if (err != CHDERR_NONE)
return err;
chd->cachehunk = hunknum;
return CHDERR_NONE;
} | [
"static",
"chd_error",
"hunk_read_into_cache",
"(",
"chd_file",
"*",
"chd",
",",
"UINT32",
"hunknum",
")",
"{",
"chd_error",
"err",
";",
"if",
"(",
"hunknum",
">",
"chd",
"->",
"maxhunk",
")",
"chd",
"->",
"maxhunk",
"=",
"hunknum",
";",
"if",
"(",
"chd",
"->",
"cachehunk",
"==",
"hunknum",
")",
"return",
"CHDERR_NONE",
";",
"chd",
"->",
"cachehunk",
"=",
"~",
"0",
";",
"err",
"=",
"hunk_read_into_memory",
"(",
"chd",
",",
"hunknum",
",",
"chd",
"->",
"cache",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"return",
"err",
";",
"chd",
"->",
"cachehunk",
"=",
"hunknum",
";",
"return",
"CHDERR_NONE",
";",
"}"
] | hunk_read_into_cache - read a hunk into
the CHD's hunk cache | [
"hunk_read_into_cache",
"-",
"read",
"a",
"hunk",
"into",
"the",
"CHD",
"'",
"s",
"hunk",
"cache"
] | [
"/* track the max */",
"/* if we're already in the cache, we're done */",
"/* otherwise, read the data */",
"/* mark the hunk successfully cached in */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "hunknum",
"type": "UINT32"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "hunknum",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | hunk_read_into_memory | chd_error | static chd_error hunk_read_into_memory(chd_file *chd, UINT32 hunknum, UINT8 *dest)
{
map_entry *entry = &chd->map[hunknum];
chd_error err;
UINT32 bytes;
/* return an error if out of range */
if (hunknum >= chd->header.totalhunks)
return CHDERR_HUNK_OUT_OF_RANGE;
/* switch off the entry type */
switch (entry->flags & MAP_ENTRY_FLAG_TYPE_MASK)
{
/* compressed data */
case MAP_ENTRY_TYPE_COMPRESSED:
/* read it into the decompression buffer */
core_fseek(chd->file, entry->offset, SEEK_SET);
bytes = core_fread(chd->file, chd->compressed, entry->length);
if (bytes != entry->length)
return CHDERR_READ_ERROR;
/* now decompress using the codec */
err = CHDERR_NONE;
if (chd->codecintf->decompress != NULL)
err = (*chd->codecintf->decompress)(chd, entry->length, dest);
if (err != CHDERR_NONE)
return err;
break;
/* uncompressed data */
case MAP_ENTRY_TYPE_UNCOMPRESSED:
core_fseek(chd->file, entry->offset, SEEK_SET);
bytes = core_fread(chd->file, dest, chd->header.hunkbytes);
if (bytes != chd->header.hunkbytes)
return CHDERR_READ_ERROR;
break;
/* mini-compressed data */
case MAP_ENTRY_TYPE_MINI:
put_bigendian_uint64(&dest[0], entry->offset);
for (bytes = 8; bytes < chd->header.hunkbytes; bytes++)
dest[bytes] = dest[bytes - 8];
break;
/* self-referenced data */
case MAP_ENTRY_TYPE_SELF_HUNK:
if (chd->cachehunk == entry->offset && dest == chd->cache)
break;
return hunk_read_into_memory(chd, entry->offset, dest);
/* parent-referenced data */
case MAP_ENTRY_TYPE_PARENT_HUNK:
err = hunk_read_into_memory(chd->parent, entry->offset, dest);
if (err != CHDERR_NONE)
return err;
break;
}
return CHDERR_NONE;
} | /*-------------------------------------------------
hunk_read_into_memory - read a hunk into
memory at the given location
-------------------------------------------------*/ | read a hunk into
memory at the given location | [
"read",
"a",
"hunk",
"into",
"memory",
"at",
"the",
"given",
"location"
] | static chd_error hunk_read_into_memory(chd_file *chd, UINT32 hunknum, UINT8 *dest)
{
map_entry *entry = &chd->map[hunknum];
chd_error err;
UINT32 bytes;
if (hunknum >= chd->header.totalhunks)
return CHDERR_HUNK_OUT_OF_RANGE;
switch (entry->flags & MAP_ENTRY_FLAG_TYPE_MASK)
{
case MAP_ENTRY_TYPE_COMPRESSED:
core_fseek(chd->file, entry->offset, SEEK_SET);
bytes = core_fread(chd->file, chd->compressed, entry->length);
if (bytes != entry->length)
return CHDERR_READ_ERROR;
err = CHDERR_NONE;
if (chd->codecintf->decompress != NULL)
err = (*chd->codecintf->decompress)(chd, entry->length, dest);
if (err != CHDERR_NONE)
return err;
break;
case MAP_ENTRY_TYPE_UNCOMPRESSED:
core_fseek(chd->file, entry->offset, SEEK_SET);
bytes = core_fread(chd->file, dest, chd->header.hunkbytes);
if (bytes != chd->header.hunkbytes)
return CHDERR_READ_ERROR;
break;
case MAP_ENTRY_TYPE_MINI:
put_bigendian_uint64(&dest[0], entry->offset);
for (bytes = 8; bytes < chd->header.hunkbytes; bytes++)
dest[bytes] = dest[bytes - 8];
break;
case MAP_ENTRY_TYPE_SELF_HUNK:
if (chd->cachehunk == entry->offset && dest == chd->cache)
break;
return hunk_read_into_memory(chd, entry->offset, dest);
case MAP_ENTRY_TYPE_PARENT_HUNK:
err = hunk_read_into_memory(chd->parent, entry->offset, dest);
if (err != CHDERR_NONE)
return err;
break;
}
return CHDERR_NONE;
} | [
"static",
"chd_error",
"hunk_read_into_memory",
"(",
"chd_file",
"*",
"chd",
",",
"UINT32",
"hunknum",
",",
"UINT8",
"*",
"dest",
")",
"{",
"map_entry",
"*",
"entry",
"=",
"&",
"chd",
"->",
"map",
"[",
"hunknum",
"]",
";",
"chd_error",
"err",
";",
"UINT32",
"bytes",
";",
"if",
"(",
"hunknum",
">=",
"chd",
"->",
"header",
".",
"totalhunks",
")",
"return",
"CHDERR_HUNK_OUT_OF_RANGE",
";",
"switch",
"(",
"entry",
"->",
"flags",
"&",
"MAP_ENTRY_FLAG_TYPE_MASK",
")",
"{",
"case",
"MAP_ENTRY_TYPE_COMPRESSED",
":",
"core_fseek",
"(",
"chd",
"->",
"file",
",",
"entry",
"->",
"offset",
",",
"SEEK_SET",
")",
";",
"bytes",
"=",
"core_fread",
"(",
"chd",
"->",
"file",
",",
"chd",
"->",
"compressed",
",",
"entry",
"->",
"length",
")",
";",
"if",
"(",
"bytes",
"!=",
"entry",
"->",
"length",
")",
"return",
"CHDERR_READ_ERROR",
";",
"err",
"=",
"CHDERR_NONE",
";",
"if",
"(",
"chd",
"->",
"codecintf",
"->",
"decompress",
"!=",
"NULL",
")",
"err",
"=",
"(",
"*",
"chd",
"->",
"codecintf",
"->",
"decompress",
")",
"(",
"chd",
",",
"entry",
"->",
"length",
",",
"dest",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"return",
"err",
";",
"break",
";",
"case",
"MAP_ENTRY_TYPE_UNCOMPRESSED",
":",
"core_fseek",
"(",
"chd",
"->",
"file",
",",
"entry",
"->",
"offset",
",",
"SEEK_SET",
")",
";",
"bytes",
"=",
"core_fread",
"(",
"chd",
"->",
"file",
",",
"dest",
",",
"chd",
"->",
"header",
".",
"hunkbytes",
")",
";",
"if",
"(",
"bytes",
"!=",
"chd",
"->",
"header",
".",
"hunkbytes",
")",
"return",
"CHDERR_READ_ERROR",
";",
"break",
";",
"case",
"MAP_ENTRY_TYPE_MINI",
":",
"put_bigendian_uint64",
"(",
"&",
"dest",
"[",
"0",
"]",
",",
"entry",
"->",
"offset",
")",
";",
"for",
"(",
"bytes",
"=",
"8",
";",
"bytes",
"<",
"chd",
"->",
"header",
".",
"hunkbytes",
";",
"bytes",
"++",
")",
"dest",
"[",
"bytes",
"]",
"=",
"dest",
"[",
"bytes",
"-",
"8",
"]",
";",
"break",
";",
"case",
"MAP_ENTRY_TYPE_SELF_HUNK",
":",
"if",
"(",
"chd",
"->",
"cachehunk",
"==",
"entry",
"->",
"offset",
"&&",
"dest",
"==",
"chd",
"->",
"cache",
")",
"break",
";",
"return",
"hunk_read_into_memory",
"(",
"chd",
",",
"entry",
"->",
"offset",
",",
"dest",
")",
";",
"case",
"MAP_ENTRY_TYPE_PARENT_HUNK",
":",
"err",
"=",
"hunk_read_into_memory",
"(",
"chd",
"->",
"parent",
",",
"entry",
"->",
"offset",
",",
"dest",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"return",
"err",
";",
"break",
";",
"}",
"return",
"CHDERR_NONE",
";",
"}"
] | hunk_read_into_memory - read a hunk into
memory at the given location | [
"hunk_read_into_memory",
"-",
"read",
"a",
"hunk",
"into",
"memory",
"at",
"the",
"given",
"location"
] | [
"/* return an error if out of range */",
"/* switch off the entry type */",
"/* compressed data */",
"/* read it into the decompression buffer */",
"/* now decompress using the codec */",
"/* uncompressed data */",
"/* mini-compressed data */",
"/* self-referenced data */",
"/* parent-referenced data */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "hunknum",
"type": "UINT32"
},
{
"param": "dest",
"type": "UINT8"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "hunknum",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dest",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | hunk_write_from_memory | chd_error | static chd_error hunk_write_from_memory(chd_file *chd, UINT32 hunknum, const UINT8 *src)
{
map_entry *entry = &chd->map[hunknum];
map_entry newentry;
UINT8 fileentry[MAP_ENTRY_SIZE];
const void *data = src;
UINT32 bytes = 0, match;
chd_error err;
/* track the max */
if (hunknum > chd->maxhunk)
chd->maxhunk = hunknum;
/* first compute the CRC of the original data */
newentry.crc = 0;
if (src != NULL)
newentry.crc = crc32(0, &src[0], chd->header.hunkbytes);
/* if we're not a lossy codec, compute the CRC and look for matches */
if (!chd->codecintf->lossy && src != NULL)
{
/* some extra stuff for zlib+ compression */
if (chd->header.compression >= CHDCOMPRESSION_ZLIB_PLUS)
{
/* see if we can mini-compress first */
for (bytes = 8; bytes < chd->header.hunkbytes; bytes++)
if (src[bytes] != src[bytes - 8])
break;
/* if so, we don't need to write any data */
if (bytes == chd->header.hunkbytes)
{
newentry.offset = get_bigendian_uint64(&src[0]);
newentry.length = 0;
newentry.flags = MAP_ENTRY_TYPE_MINI;
goto write_entry;
}
/* otherwise, see if we can find a match in the current file */
match = crcmap_find_hunk(chd, hunknum, newentry.crc, &src[0]);
if (match != NO_MATCH)
{
newentry.offset = match;
newentry.length = 0;
newentry.flags = MAP_ENTRY_TYPE_SELF_HUNK;
goto write_entry;
}
/* if we have a parent, see if we can find a match in there */
if (chd->header.flags & CHDFLAGS_HAS_PARENT)
{
match = crcmap_find_hunk(chd->parent, ~0, newentry.crc, &src[0]);
if (match != NO_MATCH)
{
newentry.offset = match;
newentry.length = 0;
newentry.flags = MAP_ENTRY_TYPE_PARENT_HUNK;
goto write_entry;
}
}
}
}
/* now try compressing the data */
err = CHDERR_COMPRESSION_ERROR;
if (chd->codecintf->compress != NULL)
err = (*chd->codecintf->compress)(chd, src, &bytes);
/* if that worked, and we're lossy, decompress and CRC the result */
if (err == CHDERR_NONE && (chd->codecintf->lossy || src == NULL))
{
err = (*chd->codecintf->decompress)(chd, bytes, chd->cache);
if (err == CHDERR_NONE)
newentry.crc = crc32(0, chd->cache, chd->header.hunkbytes);
}
/* if we succeeded in compressing the data, replace our data pointer and mark it so */
if (err == CHDERR_NONE)
{
data = chd->compressed;
newentry.length = bytes;
newentry.flags = MAP_ENTRY_TYPE_COMPRESSED;
}
/* otherwise, mark it uncompressed and use the original data */
else
{
newentry.length = chd->header.hunkbytes;
newentry.flags = MAP_ENTRY_TYPE_UNCOMPRESSED;
}
/* if the data doesn't fit into the previous entry, make a new one at the eof */
newentry.offset = entry->offset;
if (newentry.offset == 0 || newentry.length > entry->length)
newentry.offset = core_fsize(chd->file);
/* write the data */
core_fseek(chd->file, newentry.offset, SEEK_SET);
bytes = core_fwrite(chd->file, data, newentry.length);
if (bytes != newentry.length)
return CHDERR_WRITE_ERROR;
/* update the entry in memory */
write_entry:
*entry = newentry;
/* update the map on file */
map_assemble(&fileentry[0], &chd->map[hunknum]);
core_fseek(chd->file, chd->header.length + hunknum * sizeof(fileentry), SEEK_SET);
bytes = core_fwrite(chd->file, &fileentry[0], sizeof(fileentry));
if (bytes != sizeof(fileentry))
return CHDERR_WRITE_ERROR;
return CHDERR_NONE;
} | /*-------------------------------------------------
hunk_write_from_memory - write a hunk from
memory into a CHD
-------------------------------------------------*/ | write a hunk from
memory into a CHD | [
"write",
"a",
"hunk",
"from",
"memory",
"into",
"a",
"CHD"
] | static chd_error hunk_write_from_memory(chd_file *chd, UINT32 hunknum, const UINT8 *src)
{
map_entry *entry = &chd->map[hunknum];
map_entry newentry;
UINT8 fileentry[MAP_ENTRY_SIZE];
const void *data = src;
UINT32 bytes = 0, match;
chd_error err;
if (hunknum > chd->maxhunk)
chd->maxhunk = hunknum;
newentry.crc = 0;
if (src != NULL)
newentry.crc = crc32(0, &src[0], chd->header.hunkbytes);
if (!chd->codecintf->lossy && src != NULL)
{
if (chd->header.compression >= CHDCOMPRESSION_ZLIB_PLUS)
{
for (bytes = 8; bytes < chd->header.hunkbytes; bytes++)
if (src[bytes] != src[bytes - 8])
break;
if (bytes == chd->header.hunkbytes)
{
newentry.offset = get_bigendian_uint64(&src[0]);
newentry.length = 0;
newentry.flags = MAP_ENTRY_TYPE_MINI;
goto write_entry;
}
match = crcmap_find_hunk(chd, hunknum, newentry.crc, &src[0]);
if (match != NO_MATCH)
{
newentry.offset = match;
newentry.length = 0;
newentry.flags = MAP_ENTRY_TYPE_SELF_HUNK;
goto write_entry;
}
if (chd->header.flags & CHDFLAGS_HAS_PARENT)
{
match = crcmap_find_hunk(chd->parent, ~0, newentry.crc, &src[0]);
if (match != NO_MATCH)
{
newentry.offset = match;
newentry.length = 0;
newentry.flags = MAP_ENTRY_TYPE_PARENT_HUNK;
goto write_entry;
}
}
}
}
err = CHDERR_COMPRESSION_ERROR;
if (chd->codecintf->compress != NULL)
err = (*chd->codecintf->compress)(chd, src, &bytes);
if (err == CHDERR_NONE && (chd->codecintf->lossy || src == NULL))
{
err = (*chd->codecintf->decompress)(chd, bytes, chd->cache);
if (err == CHDERR_NONE)
newentry.crc = crc32(0, chd->cache, chd->header.hunkbytes);
}
if (err == CHDERR_NONE)
{
data = chd->compressed;
newentry.length = bytes;
newentry.flags = MAP_ENTRY_TYPE_COMPRESSED;
}
else
{
newentry.length = chd->header.hunkbytes;
newentry.flags = MAP_ENTRY_TYPE_UNCOMPRESSED;
}
newentry.offset = entry->offset;
if (newentry.offset == 0 || newentry.length > entry->length)
newentry.offset = core_fsize(chd->file);
core_fseek(chd->file, newentry.offset, SEEK_SET);
bytes = core_fwrite(chd->file, data, newentry.length);
if (bytes != newentry.length)
return CHDERR_WRITE_ERROR;
write_entry:
*entry = newentry;
map_assemble(&fileentry[0], &chd->map[hunknum]);
core_fseek(chd->file, chd->header.length + hunknum * sizeof(fileentry), SEEK_SET);
bytes = core_fwrite(chd->file, &fileentry[0], sizeof(fileentry));
if (bytes != sizeof(fileentry))
return CHDERR_WRITE_ERROR;
return CHDERR_NONE;
} | [
"static",
"chd_error",
"hunk_write_from_memory",
"(",
"chd_file",
"*",
"chd",
",",
"UINT32",
"hunknum",
",",
"const",
"UINT8",
"*",
"src",
")",
"{",
"map_entry",
"*",
"entry",
"=",
"&",
"chd",
"->",
"map",
"[",
"hunknum",
"]",
";",
"map_entry",
"newentry",
";",
"UINT8",
"fileentry",
"[",
"MAP_ENTRY_SIZE",
"]",
";",
"const",
"void",
"*",
"data",
"=",
"src",
";",
"UINT32",
"bytes",
"=",
"0",
",",
"match",
";",
"chd_error",
"err",
";",
"if",
"(",
"hunknum",
">",
"chd",
"->",
"maxhunk",
")",
"chd",
"->",
"maxhunk",
"=",
"hunknum",
";",
"newentry",
".",
"crc",
"=",
"0",
";",
"if",
"(",
"src",
"!=",
"NULL",
")",
"newentry",
".",
"crc",
"=",
"crc32",
"(",
"0",
",",
"&",
"src",
"[",
"0",
"]",
",",
"chd",
"->",
"header",
".",
"hunkbytes",
")",
";",
"if",
"(",
"!",
"chd",
"->",
"codecintf",
"->",
"lossy",
"&&",
"src",
"!=",
"NULL",
")",
"{",
"if",
"(",
"chd",
"->",
"header",
".",
"compression",
">=",
"CHDCOMPRESSION_ZLIB_PLUS",
")",
"{",
"for",
"(",
"bytes",
"=",
"8",
";",
"bytes",
"<",
"chd",
"->",
"header",
".",
"hunkbytes",
";",
"bytes",
"++",
")",
"if",
"(",
"src",
"[",
"bytes",
"]",
"!=",
"src",
"[",
"bytes",
"-",
"8",
"]",
")",
"break",
";",
"if",
"(",
"bytes",
"==",
"chd",
"->",
"header",
".",
"hunkbytes",
")",
"{",
"newentry",
".",
"offset",
"=",
"get_bigendian_uint64",
"(",
"&",
"src",
"[",
"0",
"]",
")",
";",
"newentry",
".",
"length",
"=",
"0",
";",
"newentry",
".",
"flags",
"=",
"MAP_ENTRY_TYPE_MINI",
";",
"goto",
"write_entry",
";",
"}",
"match",
"=",
"crcmap_find_hunk",
"(",
"chd",
",",
"hunknum",
",",
"newentry",
".",
"crc",
",",
"&",
"src",
"[",
"0",
"]",
")",
";",
"if",
"(",
"match",
"!=",
"NO_MATCH",
")",
"{",
"newentry",
".",
"offset",
"=",
"match",
";",
"newentry",
".",
"length",
"=",
"0",
";",
"newentry",
".",
"flags",
"=",
"MAP_ENTRY_TYPE_SELF_HUNK",
";",
"goto",
"write_entry",
";",
"}",
"if",
"(",
"chd",
"->",
"header",
".",
"flags",
"&",
"CHDFLAGS_HAS_PARENT",
")",
"{",
"match",
"=",
"crcmap_find_hunk",
"(",
"chd",
"->",
"parent",
",",
"~",
"0",
",",
"newentry",
".",
"crc",
",",
"&",
"src",
"[",
"0",
"]",
")",
";",
"if",
"(",
"match",
"!=",
"NO_MATCH",
")",
"{",
"newentry",
".",
"offset",
"=",
"match",
";",
"newentry",
".",
"length",
"=",
"0",
";",
"newentry",
".",
"flags",
"=",
"MAP_ENTRY_TYPE_PARENT_HUNK",
";",
"goto",
"write_entry",
";",
"}",
"}",
"}",
"}",
"err",
"=",
"CHDERR_COMPRESSION_ERROR",
";",
"if",
"(",
"chd",
"->",
"codecintf",
"->",
"compress",
"!=",
"NULL",
")",
"err",
"=",
"(",
"*",
"chd",
"->",
"codecintf",
"->",
"compress",
")",
"(",
"chd",
",",
"src",
",",
"&",
"bytes",
")",
";",
"if",
"(",
"err",
"==",
"CHDERR_NONE",
"&&",
"(",
"chd",
"->",
"codecintf",
"->",
"lossy",
"||",
"src",
"==",
"NULL",
")",
")",
"{",
"err",
"=",
"(",
"*",
"chd",
"->",
"codecintf",
"->",
"decompress",
")",
"(",
"chd",
",",
"bytes",
",",
"chd",
"->",
"cache",
")",
";",
"if",
"(",
"err",
"==",
"CHDERR_NONE",
")",
"newentry",
".",
"crc",
"=",
"crc32",
"(",
"0",
",",
"chd",
"->",
"cache",
",",
"chd",
"->",
"header",
".",
"hunkbytes",
")",
";",
"}",
"if",
"(",
"err",
"==",
"CHDERR_NONE",
")",
"{",
"data",
"=",
"chd",
"->",
"compressed",
";",
"newentry",
".",
"length",
"=",
"bytes",
";",
"newentry",
".",
"flags",
"=",
"MAP_ENTRY_TYPE_COMPRESSED",
";",
"}",
"else",
"{",
"newentry",
".",
"length",
"=",
"chd",
"->",
"header",
".",
"hunkbytes",
";",
"newentry",
".",
"flags",
"=",
"MAP_ENTRY_TYPE_UNCOMPRESSED",
";",
"}",
"newentry",
".",
"offset",
"=",
"entry",
"->",
"offset",
";",
"if",
"(",
"newentry",
".",
"offset",
"==",
"0",
"||",
"newentry",
".",
"length",
">",
"entry",
"->",
"length",
")",
"newentry",
".",
"offset",
"=",
"core_fsize",
"(",
"chd",
"->",
"file",
")",
";",
"core_fseek",
"(",
"chd",
"->",
"file",
",",
"newentry",
".",
"offset",
",",
"SEEK_SET",
")",
";",
"bytes",
"=",
"core_fwrite",
"(",
"chd",
"->",
"file",
",",
"data",
",",
"newentry",
".",
"length",
")",
";",
"if",
"(",
"bytes",
"!=",
"newentry",
".",
"length",
")",
"return",
"CHDERR_WRITE_ERROR",
";",
"write_entry",
":",
"*",
"entry",
"=",
"newentry",
";",
"map_assemble",
"(",
"&",
"fileentry",
"[",
"0",
"]",
",",
"&",
"chd",
"->",
"map",
"[",
"hunknum",
"]",
")",
";",
"core_fseek",
"(",
"chd",
"->",
"file",
",",
"chd",
"->",
"header",
".",
"length",
"+",
"hunknum",
"*",
"sizeof",
"(",
"fileentry",
")",
",",
"SEEK_SET",
")",
";",
"bytes",
"=",
"core_fwrite",
"(",
"chd",
"->",
"file",
",",
"&",
"fileentry",
"[",
"0",
"]",
",",
"sizeof",
"(",
"fileentry",
")",
")",
";",
"if",
"(",
"bytes",
"!=",
"sizeof",
"(",
"fileentry",
")",
")",
"return",
"CHDERR_WRITE_ERROR",
";",
"return",
"CHDERR_NONE",
";",
"}"
] | hunk_write_from_memory - write a hunk from
memory into a CHD | [
"hunk_write_from_memory",
"-",
"write",
"a",
"hunk",
"from",
"memory",
"into",
"a",
"CHD"
] | [
"/* track the max */",
"/* first compute the CRC of the original data */",
"/* if we're not a lossy codec, compute the CRC and look for matches */",
"/* some extra stuff for zlib+ compression */",
"/* see if we can mini-compress first */",
"/* if so, we don't need to write any data */",
"/* otherwise, see if we can find a match in the current file */",
"/* if we have a parent, see if we can find a match in there */",
"/* now try compressing the data */",
"/* if that worked, and we're lossy, decompress and CRC the result */",
"/* if we succeeded in compressing the data, replace our data pointer and mark it so */",
"/* otherwise, mark it uncompressed and use the original data */",
"/* if the data doesn't fit into the previous entry, make a new one at the eof */",
"/* write the data */",
"/* update the entry in memory */",
"/* update the map on file */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "hunknum",
"type": "UINT32"
},
{
"param": "src",
"type": "UINT8"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "hunknum",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "src",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | map_write_initial | chd_error | static chd_error map_write_initial(core_file *file, chd_file *parent, const chd_header *header)
{
UINT8 blank_map_entries[MAP_STACK_ENTRIES * MAP_ENTRY_SIZE];
int fullchunks, remainder, count, i, j;
map_entry mapentry;
UINT64 fileoffset;
/* create a mini hunk of 0's */
mapentry.offset = 0;
mapentry.crc = 0;
mapentry.length = 0;
mapentry.flags = MAP_ENTRY_TYPE_MINI | MAP_ENTRY_FLAG_NO_CRC;
for (i = 0; i < MAP_STACK_ENTRIES; i++)
map_assemble(&blank_map_entries[i * MAP_ENTRY_SIZE], &mapentry);
/* prepare to write a blank hunk map immediately following */
fileoffset = header->length;
fullchunks = header->totalhunks / MAP_STACK_ENTRIES;
remainder = header->totalhunks % MAP_STACK_ENTRIES;
/* first write full chunks of blank entries */
for (i = 0; i < fullchunks; i++)
{
/* parent drives need to be mapped through */
if (parent != NULL)
for (j = 0; j < MAP_STACK_ENTRIES; j++)
{
mapentry.offset = i * MAP_STACK_ENTRIES + j;
mapentry.crc = parent->map[i * MAP_STACK_ENTRIES + j].crc;
mapentry.flags = MAP_ENTRY_TYPE_PARENT_HUNK;
map_assemble(&blank_map_entries[j * MAP_ENTRY_SIZE], &mapentry);
}
/* write the chunks */
core_fseek(file, fileoffset, SEEK_SET);
count = core_fwrite(file, blank_map_entries, sizeof(blank_map_entries));
if (count != sizeof(blank_map_entries))
return CHDERR_WRITE_ERROR;
fileoffset += sizeof(blank_map_entries);
}
/* then write the remainder */
if (remainder > 0)
{
/* parent drives need to be mapped through */
if (parent != NULL)
for (j = 0; j < remainder; j++)
{
mapentry.offset = i * MAP_STACK_ENTRIES + j;
mapentry.crc = parent->map[i * MAP_STACK_ENTRIES + j].crc;
mapentry.flags = MAP_ENTRY_TYPE_PARENT_HUNK;
map_assemble(&blank_map_entries[j * MAP_ENTRY_SIZE], &mapentry);
}
/* write the chunks */
core_fseek(file, fileoffset, SEEK_SET);
count = core_fwrite(file, blank_map_entries, remainder * MAP_ENTRY_SIZE);
if (count != remainder * MAP_ENTRY_SIZE)
return CHDERR_WRITE_ERROR;
fileoffset += remainder * MAP_ENTRY_SIZE;
}
/* then write a special end-of-list cookie */
memcpy(&blank_map_entries[0], END_OF_LIST_COOKIE, MAP_ENTRY_SIZE);
core_fseek(file, fileoffset, SEEK_SET);
count = core_fwrite(file, blank_map_entries, MAP_ENTRY_SIZE);
if (count != MAP_ENTRY_SIZE)
return CHDERR_WRITE_ERROR;
return CHDERR_NONE;
} | /*-------------------------------------------------
map_write_initial - write an initial map to
a new CHD file
-------------------------------------------------*/ | write an initial map to
a new CHD file | [
"write",
"an",
"initial",
"map",
"to",
"a",
"new",
"CHD",
"file"
] | static chd_error map_write_initial(core_file *file, chd_file *parent, const chd_header *header)
{
UINT8 blank_map_entries[MAP_STACK_ENTRIES * MAP_ENTRY_SIZE];
int fullchunks, remainder, count, i, j;
map_entry mapentry;
UINT64 fileoffset;
mapentry.offset = 0;
mapentry.crc = 0;
mapentry.length = 0;
mapentry.flags = MAP_ENTRY_TYPE_MINI | MAP_ENTRY_FLAG_NO_CRC;
for (i = 0; i < MAP_STACK_ENTRIES; i++)
map_assemble(&blank_map_entries[i * MAP_ENTRY_SIZE], &mapentry);
fileoffset = header->length;
fullchunks = header->totalhunks / MAP_STACK_ENTRIES;
remainder = header->totalhunks % MAP_STACK_ENTRIES;
for (i = 0; i < fullchunks; i++)
{
if (parent != NULL)
for (j = 0; j < MAP_STACK_ENTRIES; j++)
{
mapentry.offset = i * MAP_STACK_ENTRIES + j;
mapentry.crc = parent->map[i * MAP_STACK_ENTRIES + j].crc;
mapentry.flags = MAP_ENTRY_TYPE_PARENT_HUNK;
map_assemble(&blank_map_entries[j * MAP_ENTRY_SIZE], &mapentry);
}
core_fseek(file, fileoffset, SEEK_SET);
count = core_fwrite(file, blank_map_entries, sizeof(blank_map_entries));
if (count != sizeof(blank_map_entries))
return CHDERR_WRITE_ERROR;
fileoffset += sizeof(blank_map_entries);
}
if (remainder > 0)
{
if (parent != NULL)
for (j = 0; j < remainder; j++)
{
mapentry.offset = i * MAP_STACK_ENTRIES + j;
mapentry.crc = parent->map[i * MAP_STACK_ENTRIES + j].crc;
mapentry.flags = MAP_ENTRY_TYPE_PARENT_HUNK;
map_assemble(&blank_map_entries[j * MAP_ENTRY_SIZE], &mapentry);
}
core_fseek(file, fileoffset, SEEK_SET);
count = core_fwrite(file, blank_map_entries, remainder * MAP_ENTRY_SIZE);
if (count != remainder * MAP_ENTRY_SIZE)
return CHDERR_WRITE_ERROR;
fileoffset += remainder * MAP_ENTRY_SIZE;
}
memcpy(&blank_map_entries[0], END_OF_LIST_COOKIE, MAP_ENTRY_SIZE);
core_fseek(file, fileoffset, SEEK_SET);
count = core_fwrite(file, blank_map_entries, MAP_ENTRY_SIZE);
if (count != MAP_ENTRY_SIZE)
return CHDERR_WRITE_ERROR;
return CHDERR_NONE;
} | [
"static",
"chd_error",
"map_write_initial",
"(",
"core_file",
"*",
"file",
",",
"chd_file",
"*",
"parent",
",",
"const",
"chd_header",
"*",
"header",
")",
"{",
"UINT8",
"blank_map_entries",
"[",
"MAP_STACK_ENTRIES",
"*",
"MAP_ENTRY_SIZE",
"]",
";",
"int",
"fullchunks",
",",
"remainder",
",",
"count",
",",
"i",
",",
"j",
";",
"map_entry",
"mapentry",
";",
"UINT64",
"fileoffset",
";",
"mapentry",
".",
"offset",
"=",
"0",
";",
"mapentry",
".",
"crc",
"=",
"0",
";",
"mapentry",
".",
"length",
"=",
"0",
";",
"mapentry",
".",
"flags",
"=",
"MAP_ENTRY_TYPE_MINI",
"|",
"MAP_ENTRY_FLAG_NO_CRC",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"MAP_STACK_ENTRIES",
";",
"i",
"++",
")",
"map_assemble",
"(",
"&",
"blank_map_entries",
"[",
"i",
"*",
"MAP_ENTRY_SIZE",
"]",
",",
"&",
"mapentry",
")",
";",
"fileoffset",
"=",
"header",
"->",
"length",
";",
"fullchunks",
"=",
"header",
"->",
"totalhunks",
"/",
"MAP_STACK_ENTRIES",
";",
"remainder",
"=",
"header",
"->",
"totalhunks",
"%",
"MAP_STACK_ENTRIES",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"fullchunks",
";",
"i",
"++",
")",
"{",
"if",
"(",
"parent",
"!=",
"NULL",
")",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"MAP_STACK_ENTRIES",
";",
"j",
"++",
")",
"{",
"mapentry",
".",
"offset",
"=",
"i",
"*",
"MAP_STACK_ENTRIES",
"+",
"j",
";",
"mapentry",
".",
"crc",
"=",
"parent",
"->",
"map",
"[",
"i",
"*",
"MAP_STACK_ENTRIES",
"+",
"j",
"]",
".",
"crc",
";",
"mapentry",
".",
"flags",
"=",
"MAP_ENTRY_TYPE_PARENT_HUNK",
";",
"map_assemble",
"(",
"&",
"blank_map_entries",
"[",
"j",
"*",
"MAP_ENTRY_SIZE",
"]",
",",
"&",
"mapentry",
")",
";",
"}",
"core_fseek",
"(",
"file",
",",
"fileoffset",
",",
"SEEK_SET",
")",
";",
"count",
"=",
"core_fwrite",
"(",
"file",
",",
"blank_map_entries",
",",
"sizeof",
"(",
"blank_map_entries",
")",
")",
";",
"if",
"(",
"count",
"!=",
"sizeof",
"(",
"blank_map_entries",
")",
")",
"return",
"CHDERR_WRITE_ERROR",
";",
"fileoffset",
"+=",
"sizeof",
"(",
"blank_map_entries",
")",
";",
"}",
"if",
"(",
"remainder",
">",
"0",
")",
"{",
"if",
"(",
"parent",
"!=",
"NULL",
")",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"remainder",
";",
"j",
"++",
")",
"{",
"mapentry",
".",
"offset",
"=",
"i",
"*",
"MAP_STACK_ENTRIES",
"+",
"j",
";",
"mapentry",
".",
"crc",
"=",
"parent",
"->",
"map",
"[",
"i",
"*",
"MAP_STACK_ENTRIES",
"+",
"j",
"]",
".",
"crc",
";",
"mapentry",
".",
"flags",
"=",
"MAP_ENTRY_TYPE_PARENT_HUNK",
";",
"map_assemble",
"(",
"&",
"blank_map_entries",
"[",
"j",
"*",
"MAP_ENTRY_SIZE",
"]",
",",
"&",
"mapentry",
")",
";",
"}",
"core_fseek",
"(",
"file",
",",
"fileoffset",
",",
"SEEK_SET",
")",
";",
"count",
"=",
"core_fwrite",
"(",
"file",
",",
"blank_map_entries",
",",
"remainder",
"*",
"MAP_ENTRY_SIZE",
")",
";",
"if",
"(",
"count",
"!=",
"remainder",
"*",
"MAP_ENTRY_SIZE",
")",
"return",
"CHDERR_WRITE_ERROR",
";",
"fileoffset",
"+=",
"remainder",
"*",
"MAP_ENTRY_SIZE",
";",
"}",
"memcpy",
"(",
"&",
"blank_map_entries",
"[",
"0",
"]",
",",
"END_OF_LIST_COOKIE",
",",
"MAP_ENTRY_SIZE",
")",
";",
"core_fseek",
"(",
"file",
",",
"fileoffset",
",",
"SEEK_SET",
")",
";",
"count",
"=",
"core_fwrite",
"(",
"file",
",",
"blank_map_entries",
",",
"MAP_ENTRY_SIZE",
")",
";",
"if",
"(",
"count",
"!=",
"MAP_ENTRY_SIZE",
")",
"return",
"CHDERR_WRITE_ERROR",
";",
"return",
"CHDERR_NONE",
";",
"}"
] | map_write_initial - write an initial map to
a new CHD file | [
"map_write_initial",
"-",
"write",
"an",
"initial",
"map",
"to",
"a",
"new",
"CHD",
"file"
] | [
"/* create a mini hunk of 0's */",
"/* prepare to write a blank hunk map immediately following */",
"/* first write full chunks of blank entries */",
"/* parent drives need to be mapped through */",
"/* write the chunks */",
"/* then write the remainder */",
"/* parent drives need to be mapped through */",
"/* write the chunks */",
"/* then write a special end-of-list cookie */"
] | [
{
"param": "file",
"type": "core_file"
},
{
"param": "parent",
"type": "chd_file"
},
{
"param": "header",
"type": "chd_header"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": "core_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "parent",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "header",
"type": "chd_header",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | crcmap_verify_hunk_match | int | static int crcmap_verify_hunk_match(chd_file *chd, UINT32 hunknum, const UINT8 *rawdata)
{
/* we have a potential match -- better be sure */
/* read the hunk from disk and compare byte-for-byte */
if (hunknum != chd->comparehunk)
{
chd->comparehunk = ~0;
if (hunk_read_into_memory(chd, hunknum, chd->compare) == CHDERR_NONE)
chd->comparehunk = hunknum;
}
return (hunknum == chd->comparehunk && memcmp(rawdata, chd->compare, chd->header.hunkbytes) == 0);
} | /*-------------------------------------------------
crcmap_verify_hunk_match - verify that a
hunk really matches by doing a byte-for-byte
compare
-------------------------------------------------*/ | verify that a
hunk really matches by doing a byte-for-byte
compare | [
"verify",
"that",
"a",
"hunk",
"really",
"matches",
"by",
"doing",
"a",
"byte",
"-",
"for",
"-",
"byte",
"compare"
] | static int crcmap_verify_hunk_match(chd_file *chd, UINT32 hunknum, const UINT8 *rawdata)
{
if (hunknum != chd->comparehunk)
{
chd->comparehunk = ~0;
if (hunk_read_into_memory(chd, hunknum, chd->compare) == CHDERR_NONE)
chd->comparehunk = hunknum;
}
return (hunknum == chd->comparehunk && memcmp(rawdata, chd->compare, chd->header.hunkbytes) == 0);
} | [
"static",
"int",
"crcmap_verify_hunk_match",
"(",
"chd_file",
"*",
"chd",
",",
"UINT32",
"hunknum",
",",
"const",
"UINT8",
"*",
"rawdata",
")",
"{",
"if",
"(",
"hunknum",
"!=",
"chd",
"->",
"comparehunk",
")",
"{",
"chd",
"->",
"comparehunk",
"=",
"~",
"0",
";",
"if",
"(",
"hunk_read_into_memory",
"(",
"chd",
",",
"hunknum",
",",
"chd",
"->",
"compare",
")",
"==",
"CHDERR_NONE",
")",
"chd",
"->",
"comparehunk",
"=",
"hunknum",
";",
"}",
"return",
"(",
"hunknum",
"==",
"chd",
"->",
"comparehunk",
"&&",
"memcmp",
"(",
"rawdata",
",",
"chd",
"->",
"compare",
",",
"chd",
"->",
"header",
".",
"hunkbytes",
")",
"==",
"0",
")",
";",
"}"
] | crcmap_verify_hunk_match - verify that a
hunk really matches by doing a byte-for-byte
compare | [
"crcmap_verify_hunk_match",
"-",
"verify",
"that",
"a",
"hunk",
"really",
"matches",
"by",
"doing",
"a",
"byte",
"-",
"for",
"-",
"byte",
"compare"
] | [
"/* we have a potential match -- better be sure */",
"/* read the hunk from disk and compare byte-for-byte */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "hunknum",
"type": "UINT32"
},
{
"param": "rawdata",
"type": "UINT8"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "hunknum",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rawdata",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | crcmap_find_hunk | UINT32 | static UINT32 crcmap_find_hunk(chd_file *chd, UINT32 hunknum, UINT32 crc, const UINT8 *rawdata)
{
UINT32 lasthunk = (hunknum < chd->header.totalhunks) ? hunknum : chd->header.totalhunks;
int curhunk;
/* if we have a CRC map, use that */
if (chd->crctable)
{
crcmap_entry *curentry;
for (curentry = chd->crctable[crc % CRCMAP_HASH_SIZE]; curentry; curentry = curentry->next)
{
curhunk = curentry->hunknum;
if (chd->map[curhunk].crc == crc && !(chd->map[curhunk].flags & MAP_ENTRY_FLAG_NO_CRC) && crcmap_verify_hunk_match(chd, curhunk, rawdata))
return curhunk;
}
return NO_MATCH;
}
/* first see if the last match is a valid one */
if (chd->comparehunk < chd->header.totalhunks && chd->map[chd->comparehunk].crc == crc && !(chd->map[chd->comparehunk].flags & MAP_ENTRY_FLAG_NO_CRC) &&
memcmp(rawdata, chd->compare, chd->header.hunkbytes) == 0)
return chd->comparehunk;
/* scan through the CHD's hunk map looking for a match */
for (curhunk = 0; curhunk < lasthunk; curhunk++)
if (chd->map[curhunk].crc == crc && !(chd->map[curhunk].flags & MAP_ENTRY_FLAG_NO_CRC) && crcmap_verify_hunk_match(chd, curhunk, rawdata))
return curhunk;
return NO_MATCH;
} | /*-------------------------------------------------
crcmap_find_hunk - find a hunk with a matching
CRC in the map
-------------------------------------------------*/ | find a hunk with a matching
CRC in the map | [
"find",
"a",
"hunk",
"with",
"a",
"matching",
"CRC",
"in",
"the",
"map"
] | static UINT32 crcmap_find_hunk(chd_file *chd, UINT32 hunknum, UINT32 crc, const UINT8 *rawdata)
{
UINT32 lasthunk = (hunknum < chd->header.totalhunks) ? hunknum : chd->header.totalhunks;
int curhunk;
if (chd->crctable)
{
crcmap_entry *curentry;
for (curentry = chd->crctable[crc % CRCMAP_HASH_SIZE]; curentry; curentry = curentry->next)
{
curhunk = curentry->hunknum;
if (chd->map[curhunk].crc == crc && !(chd->map[curhunk].flags & MAP_ENTRY_FLAG_NO_CRC) && crcmap_verify_hunk_match(chd, curhunk, rawdata))
return curhunk;
}
return NO_MATCH;
}
if (chd->comparehunk < chd->header.totalhunks && chd->map[chd->comparehunk].crc == crc && !(chd->map[chd->comparehunk].flags & MAP_ENTRY_FLAG_NO_CRC) &&
memcmp(rawdata, chd->compare, chd->header.hunkbytes) == 0)
return chd->comparehunk;
for (curhunk = 0; curhunk < lasthunk; curhunk++)
if (chd->map[curhunk].crc == crc && !(chd->map[curhunk].flags & MAP_ENTRY_FLAG_NO_CRC) && crcmap_verify_hunk_match(chd, curhunk, rawdata))
return curhunk;
return NO_MATCH;
} | [
"static",
"UINT32",
"crcmap_find_hunk",
"(",
"chd_file",
"*",
"chd",
",",
"UINT32",
"hunknum",
",",
"UINT32",
"crc",
",",
"const",
"UINT8",
"*",
"rawdata",
")",
"{",
"UINT32",
"lasthunk",
"=",
"(",
"hunknum",
"<",
"chd",
"->",
"header",
".",
"totalhunks",
")",
"?",
"hunknum",
":",
"chd",
"->",
"header",
".",
"totalhunks",
";",
"int",
"curhunk",
";",
"if",
"(",
"chd",
"->",
"crctable",
")",
"{",
"crcmap_entry",
"*",
"curentry",
";",
"for",
"(",
"curentry",
"=",
"chd",
"->",
"crctable",
"[",
"crc",
"%",
"CRCMAP_HASH_SIZE",
"]",
";",
"curentry",
";",
"curentry",
"=",
"curentry",
"->",
"next",
")",
"{",
"curhunk",
"=",
"curentry",
"->",
"hunknum",
";",
"if",
"(",
"chd",
"->",
"map",
"[",
"curhunk",
"]",
".",
"crc",
"==",
"crc",
"&&",
"!",
"(",
"chd",
"->",
"map",
"[",
"curhunk",
"]",
".",
"flags",
"&",
"MAP_ENTRY_FLAG_NO_CRC",
")",
"&&",
"crcmap_verify_hunk_match",
"(",
"chd",
",",
"curhunk",
",",
"rawdata",
")",
")",
"return",
"curhunk",
";",
"}",
"return",
"NO_MATCH",
";",
"}",
"if",
"(",
"chd",
"->",
"comparehunk",
"<",
"chd",
"->",
"header",
".",
"totalhunks",
"&&",
"chd",
"->",
"map",
"[",
"chd",
"->",
"comparehunk",
"]",
".",
"crc",
"==",
"crc",
"&&",
"!",
"(",
"chd",
"->",
"map",
"[",
"chd",
"->",
"comparehunk",
"]",
".",
"flags",
"&",
"MAP_ENTRY_FLAG_NO_CRC",
")",
"&&",
"memcmp",
"(",
"rawdata",
",",
"chd",
"->",
"compare",
",",
"chd",
"->",
"header",
".",
"hunkbytes",
")",
"==",
"0",
")",
"return",
"chd",
"->",
"comparehunk",
";",
"for",
"(",
"curhunk",
"=",
"0",
";",
"curhunk",
"<",
"lasthunk",
";",
"curhunk",
"++",
")",
"if",
"(",
"chd",
"->",
"map",
"[",
"curhunk",
"]",
".",
"crc",
"==",
"crc",
"&&",
"!",
"(",
"chd",
"->",
"map",
"[",
"curhunk",
"]",
".",
"flags",
"&",
"MAP_ENTRY_FLAG_NO_CRC",
")",
"&&",
"crcmap_verify_hunk_match",
"(",
"chd",
",",
"curhunk",
",",
"rawdata",
")",
")",
"return",
"curhunk",
";",
"return",
"NO_MATCH",
";",
"}"
] | crcmap_find_hunk - find a hunk with a matching
CRC in the map | [
"crcmap_find_hunk",
"-",
"find",
"a",
"hunk",
"with",
"a",
"matching",
"CRC",
"in",
"the",
"map"
] | [
"/* if we have a CRC map, use that */",
"/* first see if the last match is a valid one */",
"/* scan through the CHD's hunk map looking for a match */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "hunknum",
"type": "UINT32"
},
{
"param": "crc",
"type": "UINT32"
},
{
"param": "rawdata",
"type": "UINT8"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "hunknum",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "crc",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rawdata",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | metadata_set_previous_next | chd_error | static chd_error metadata_set_previous_next(chd_file *chd, UINT64 prevoffset, UINT64 nextoffset)
{
UINT8 raw_meta_header[METADATA_HEADER_SIZE];
chd_error err;
UINT32 count;
/* if we were the first entry, make the next entry the first */
if (prevoffset == 0)
{
chd->header.metaoffset = nextoffset;
err = header_write(chd->file, &chd->header);
if (err != CHDERR_NONE)
return err;
}
/* otherwise, update the link in the previous pointer */
else
{
/* read the previous raw header */
core_fseek(chd->file, prevoffset, SEEK_SET);
count = core_fread(chd->file, raw_meta_header, sizeof(raw_meta_header));
if (count != sizeof(raw_meta_header))
return CHDERR_READ_ERROR;
/* copy our next pointer into the previous->next offset */
put_bigendian_uint64(&raw_meta_header[8], nextoffset);
/* write the previous raw header */
core_fseek(chd->file, prevoffset, SEEK_SET);
count = core_fwrite(chd->file, raw_meta_header, sizeof(raw_meta_header));
if (count != sizeof(raw_meta_header))
return CHDERR_WRITE_ERROR;
}
return CHDERR_NONE;
} | /*-------------------------------------------------
metadata_set_previous_next - set the 'next'
offset of a piece of metadata
-------------------------------------------------*/ | set the 'next'
offset of a piece of metadata | [
"set",
"the",
"'",
"next",
"'",
"offset",
"of",
"a",
"piece",
"of",
"metadata"
] | static chd_error metadata_set_previous_next(chd_file *chd, UINT64 prevoffset, UINT64 nextoffset)
{
UINT8 raw_meta_header[METADATA_HEADER_SIZE];
chd_error err;
UINT32 count;
if (prevoffset == 0)
{
chd->header.metaoffset = nextoffset;
err = header_write(chd->file, &chd->header);
if (err != CHDERR_NONE)
return err;
}
else
{
core_fseek(chd->file, prevoffset, SEEK_SET);
count = core_fread(chd->file, raw_meta_header, sizeof(raw_meta_header));
if (count != sizeof(raw_meta_header))
return CHDERR_READ_ERROR;
put_bigendian_uint64(&raw_meta_header[8], nextoffset);
core_fseek(chd->file, prevoffset, SEEK_SET);
count = core_fwrite(chd->file, raw_meta_header, sizeof(raw_meta_header));
if (count != sizeof(raw_meta_header))
return CHDERR_WRITE_ERROR;
}
return CHDERR_NONE;
} | [
"static",
"chd_error",
"metadata_set_previous_next",
"(",
"chd_file",
"*",
"chd",
",",
"UINT64",
"prevoffset",
",",
"UINT64",
"nextoffset",
")",
"{",
"UINT8",
"raw_meta_header",
"[",
"METADATA_HEADER_SIZE",
"]",
";",
"chd_error",
"err",
";",
"UINT32",
"count",
";",
"if",
"(",
"prevoffset",
"==",
"0",
")",
"{",
"chd",
"->",
"header",
".",
"metaoffset",
"=",
"nextoffset",
";",
"err",
"=",
"header_write",
"(",
"chd",
"->",
"file",
",",
"&",
"chd",
"->",
"header",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"return",
"err",
";",
"}",
"else",
"{",
"core_fseek",
"(",
"chd",
"->",
"file",
",",
"prevoffset",
",",
"SEEK_SET",
")",
";",
"count",
"=",
"core_fread",
"(",
"chd",
"->",
"file",
",",
"raw_meta_header",
",",
"sizeof",
"(",
"raw_meta_header",
")",
")",
";",
"if",
"(",
"count",
"!=",
"sizeof",
"(",
"raw_meta_header",
")",
")",
"return",
"CHDERR_READ_ERROR",
";",
"put_bigendian_uint64",
"(",
"&",
"raw_meta_header",
"[",
"8",
"]",
",",
"nextoffset",
")",
";",
"core_fseek",
"(",
"chd",
"->",
"file",
",",
"prevoffset",
",",
"SEEK_SET",
")",
";",
"count",
"=",
"core_fwrite",
"(",
"chd",
"->",
"file",
",",
"raw_meta_header",
",",
"sizeof",
"(",
"raw_meta_header",
")",
")",
";",
"if",
"(",
"count",
"!=",
"sizeof",
"(",
"raw_meta_header",
")",
")",
"return",
"CHDERR_WRITE_ERROR",
";",
"}",
"return",
"CHDERR_NONE",
";",
"}"
] | metadata_set_previous_next - set the 'next'
offset of a piece of metadata | [
"metadata_set_previous_next",
"-",
"set",
"the",
"'",
"next",
"'",
"offset",
"of",
"a",
"piece",
"of",
"metadata"
] | [
"/* if we were the first entry, make the next entry the first */",
"/* otherwise, update the link in the previous pointer */",
"/* read the previous raw header */",
"/* copy our next pointer into the previous->next offset */",
"/* write the previous raw header */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "prevoffset",
"type": "UINT64"
},
{
"param": "nextoffset",
"type": "UINT64"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "prevoffset",
"type": "UINT64",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "nextoffset",
"type": "UINT64",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | metadata_set_length | chd_error | static chd_error metadata_set_length(chd_file *chd, UINT64 offset, UINT32 length)
{
UINT8 raw_meta_header[METADATA_HEADER_SIZE];
UINT32 oldlength;
UINT32 count;
/* read the raw header */
core_fseek(chd->file, offset, SEEK_SET);
count = core_fread(chd->file, raw_meta_header, sizeof(raw_meta_header));
if (count != sizeof(raw_meta_header))
return CHDERR_READ_ERROR;
/* update the length at offset 4, preserving the flags in the upper byte */
oldlength = get_bigendian_uint32(&raw_meta_header[4]);
length = (length & 0x00ffffff) | (oldlength & 0xff000000);
put_bigendian_uint32(&raw_meta_header[4], length);
/* write the raw header */
core_fseek(chd->file, offset, SEEK_SET);
count = core_fwrite(chd->file, raw_meta_header, sizeof(raw_meta_header));
if (count != sizeof(raw_meta_header))
return CHDERR_WRITE_ERROR;
return CHDERR_NONE;
} | /*-------------------------------------------------
metadata_set_length - set the length field of
a piece of metadata
-------------------------------------------------*/ | set the length field of
a piece of metadata | [
"set",
"the",
"length",
"field",
"of",
"a",
"piece",
"of",
"metadata"
] | static chd_error metadata_set_length(chd_file *chd, UINT64 offset, UINT32 length)
{
UINT8 raw_meta_header[METADATA_HEADER_SIZE];
UINT32 oldlength;
UINT32 count;
core_fseek(chd->file, offset, SEEK_SET);
count = core_fread(chd->file, raw_meta_header, sizeof(raw_meta_header));
if (count != sizeof(raw_meta_header))
return CHDERR_READ_ERROR;
oldlength = get_bigendian_uint32(&raw_meta_header[4]);
length = (length & 0x00ffffff) | (oldlength & 0xff000000);
put_bigendian_uint32(&raw_meta_header[4], length);
core_fseek(chd->file, offset, SEEK_SET);
count = core_fwrite(chd->file, raw_meta_header, sizeof(raw_meta_header));
if (count != sizeof(raw_meta_header))
return CHDERR_WRITE_ERROR;
return CHDERR_NONE;
} | [
"static",
"chd_error",
"metadata_set_length",
"(",
"chd_file",
"*",
"chd",
",",
"UINT64",
"offset",
",",
"UINT32",
"length",
")",
"{",
"UINT8",
"raw_meta_header",
"[",
"METADATA_HEADER_SIZE",
"]",
";",
"UINT32",
"oldlength",
";",
"UINT32",
"count",
";",
"core_fseek",
"(",
"chd",
"->",
"file",
",",
"offset",
",",
"SEEK_SET",
")",
";",
"count",
"=",
"core_fread",
"(",
"chd",
"->",
"file",
",",
"raw_meta_header",
",",
"sizeof",
"(",
"raw_meta_header",
")",
")",
";",
"if",
"(",
"count",
"!=",
"sizeof",
"(",
"raw_meta_header",
")",
")",
"return",
"CHDERR_READ_ERROR",
";",
"oldlength",
"=",
"get_bigendian_uint32",
"(",
"&",
"raw_meta_header",
"[",
"4",
"]",
")",
";",
"length",
"=",
"(",
"length",
"&",
"0x00ffffff",
")",
"|",
"(",
"oldlength",
"&",
"0xff000000",
")",
";",
"put_bigendian_uint32",
"(",
"&",
"raw_meta_header",
"[",
"4",
"]",
",",
"length",
")",
";",
"core_fseek",
"(",
"chd",
"->",
"file",
",",
"offset",
",",
"SEEK_SET",
")",
";",
"count",
"=",
"core_fwrite",
"(",
"chd",
"->",
"file",
",",
"raw_meta_header",
",",
"sizeof",
"(",
"raw_meta_header",
")",
")",
";",
"if",
"(",
"count",
"!=",
"sizeof",
"(",
"raw_meta_header",
")",
")",
"return",
"CHDERR_WRITE_ERROR",
";",
"return",
"CHDERR_NONE",
";",
"}"
] | metadata_set_length - set the length field of
a piece of metadata | [
"metadata_set_length",
"-",
"set",
"the",
"length",
"field",
"of",
"a",
"piece",
"of",
"metadata"
] | [
"/* read the raw header */",
"/* update the length at offset 4, preserving the flags in the upper byte */",
"/* write the raw header */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "offset",
"type": "UINT64"
},
{
"param": "length",
"type": "UINT32"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offset",
"type": "UINT64",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "length",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | metadata_compute_hash | chd_error | static chd_error metadata_compute_hash(chd_file *chd, const UINT8 *rawsha1, UINT8 *finalsha1)
{
metadata_hash *hasharray = NULL;
chd_error err = CHDERR_NONE;
struct sha1_ctx sha1;
UINT32 hashindex = 0;
UINT32 hashalloc = 0;
UINT64 offset, next;
/* only works for V4 and above */
if (chd->header.version < 4)
{
memcpy(finalsha1, rawsha1, SHA1_DIGEST_SIZE);
return CHDERR_NONE;
}
/* loop until we run out of data */
for (offset = chd->header.metaoffset; offset != 0; offset = next)
{
UINT8 raw_meta_header[METADATA_HEADER_SIZE];
UINT32 count, metalength, metatag;
UINT8 *tempbuffer;
UINT8 metaflags;
/* read the raw header */
core_fseek(chd->file, offset, SEEK_SET);
count = core_fread(chd->file, raw_meta_header, sizeof(raw_meta_header));
if (count != sizeof(raw_meta_header))
break;
/* extract the data */
metatag = get_bigendian_uint32(&raw_meta_header[0]);
metalength = get_bigendian_uint32(&raw_meta_header[4]);
next = get_bigendian_uint64(&raw_meta_header[8]);
/* flags are encoded in the high byte of length */
metaflags = metalength >> 24;
metalength &= 0x00ffffff;
/* if not checksumming, continue */
if (!(metaflags & CHD_MDFLAGS_CHECKSUM))
continue;
/* allocate memory */
tempbuffer = (UINT8 *)malloc(metalength);
if (tempbuffer == NULL)
{
err = CHDERR_OUT_OF_MEMORY;
goto cleanup;
}
/* seek and read the metadata */
core_fseek(chd->file, offset + METADATA_HEADER_SIZE, SEEK_SET);
count = core_fread(chd->file, tempbuffer, metalength);
if (count != metalength)
{
free(tempbuffer);
err = CHDERR_READ_ERROR;
goto cleanup;
}
/* compute this entry's hash */
sha1_init(&sha1);
sha1_update(&sha1, metalength, tempbuffer);
sha1_final(&sha1);
free(tempbuffer);
/* expand the hasharray if necessary */
if (hashindex >= hashalloc)
{
hashalloc += 256;
hasharray = (metadata_hash *)realloc(hasharray, hashalloc * sizeof(hasharray[0]));
if (hasharray == NULL)
{
err = CHDERR_OUT_OF_MEMORY;
goto cleanup;
}
}
/* fill in the entry */
put_bigendian_uint32(hasharray[hashindex].tag, metatag);
sha1_digest(&sha1, SHA1_DIGEST_SIZE, hasharray[hashindex].sha1);
hashindex++;
}
/* sort the array */
qsort(hasharray, hashindex, sizeof(hasharray[0]), metadata_hash_compare);
/* compute the SHA1 of the raw plus the various metadata */
sha1_init(&sha1);
sha1_update(&sha1, CHD_SHA1_BYTES, rawsha1);
sha1_update(&sha1, hashindex * sizeof(hasharray[0]), (const UINT8 *)hasharray);
sha1_final(&sha1);
sha1_digest(&sha1, SHA1_DIGEST_SIZE, finalsha1);
cleanup:
if (hasharray != NULL)
free(hasharray);
return err;
} | /*-------------------------------------------------
metadata_compute_hash - compute the SHA1
hash of all metadata that requests it
-------------------------------------------------*/ | compute the SHA1
hash of all metadata that requests it | [
"compute",
"the",
"SHA1",
"hash",
"of",
"all",
"metadata",
"that",
"requests",
"it"
] | static chd_error metadata_compute_hash(chd_file *chd, const UINT8 *rawsha1, UINT8 *finalsha1)
{
metadata_hash *hasharray = NULL;
chd_error err = CHDERR_NONE;
struct sha1_ctx sha1;
UINT32 hashindex = 0;
UINT32 hashalloc = 0;
UINT64 offset, next;
if (chd->header.version < 4)
{
memcpy(finalsha1, rawsha1, SHA1_DIGEST_SIZE);
return CHDERR_NONE;
}
for (offset = chd->header.metaoffset; offset != 0; offset = next)
{
UINT8 raw_meta_header[METADATA_HEADER_SIZE];
UINT32 count, metalength, metatag;
UINT8 *tempbuffer;
UINT8 metaflags;
core_fseek(chd->file, offset, SEEK_SET);
count = core_fread(chd->file, raw_meta_header, sizeof(raw_meta_header));
if (count != sizeof(raw_meta_header))
break;
metatag = get_bigendian_uint32(&raw_meta_header[0]);
metalength = get_bigendian_uint32(&raw_meta_header[4]);
next = get_bigendian_uint64(&raw_meta_header[8]);
metaflags = metalength >> 24;
metalength &= 0x00ffffff;
if (!(metaflags & CHD_MDFLAGS_CHECKSUM))
continue;
tempbuffer = (UINT8 *)malloc(metalength);
if (tempbuffer == NULL)
{
err = CHDERR_OUT_OF_MEMORY;
goto cleanup;
}
core_fseek(chd->file, offset + METADATA_HEADER_SIZE, SEEK_SET);
count = core_fread(chd->file, tempbuffer, metalength);
if (count != metalength)
{
free(tempbuffer);
err = CHDERR_READ_ERROR;
goto cleanup;
}
sha1_init(&sha1);
sha1_update(&sha1, metalength, tempbuffer);
sha1_final(&sha1);
free(tempbuffer);
if (hashindex >= hashalloc)
{
hashalloc += 256;
hasharray = (metadata_hash *)realloc(hasharray, hashalloc * sizeof(hasharray[0]));
if (hasharray == NULL)
{
err = CHDERR_OUT_OF_MEMORY;
goto cleanup;
}
}
put_bigendian_uint32(hasharray[hashindex].tag, metatag);
sha1_digest(&sha1, SHA1_DIGEST_SIZE, hasharray[hashindex].sha1);
hashindex++;
}
qsort(hasharray, hashindex, sizeof(hasharray[0]), metadata_hash_compare);
sha1_init(&sha1);
sha1_update(&sha1, CHD_SHA1_BYTES, rawsha1);
sha1_update(&sha1, hashindex * sizeof(hasharray[0]), (const UINT8 *)hasharray);
sha1_final(&sha1);
sha1_digest(&sha1, SHA1_DIGEST_SIZE, finalsha1);
cleanup:
if (hasharray != NULL)
free(hasharray);
return err;
} | [
"static",
"chd_error",
"metadata_compute_hash",
"(",
"chd_file",
"*",
"chd",
",",
"const",
"UINT8",
"*",
"rawsha1",
",",
"UINT8",
"*",
"finalsha1",
")",
"{",
"metadata_hash",
"*",
"hasharray",
"=",
"NULL",
";",
"chd_error",
"err",
"=",
"CHDERR_NONE",
";",
"struct",
"sha1_ctx",
"sha1",
";",
"UINT32",
"hashindex",
"=",
"0",
";",
"UINT32",
"hashalloc",
"=",
"0",
";",
"UINT64",
"offset",
",",
"next",
";",
"if",
"(",
"chd",
"->",
"header",
".",
"version",
"<",
"4",
")",
"{",
"memcpy",
"(",
"finalsha1",
",",
"rawsha1",
",",
"SHA1_DIGEST_SIZE",
")",
";",
"return",
"CHDERR_NONE",
";",
"}",
"for",
"(",
"offset",
"=",
"chd",
"->",
"header",
".",
"metaoffset",
";",
"offset",
"!=",
"0",
";",
"offset",
"=",
"next",
")",
"{",
"UINT8",
"raw_meta_header",
"[",
"METADATA_HEADER_SIZE",
"]",
";",
"UINT32",
"count",
",",
"metalength",
",",
"metatag",
";",
"UINT8",
"*",
"tempbuffer",
";",
"UINT8",
"metaflags",
";",
"core_fseek",
"(",
"chd",
"->",
"file",
",",
"offset",
",",
"SEEK_SET",
")",
";",
"count",
"=",
"core_fread",
"(",
"chd",
"->",
"file",
",",
"raw_meta_header",
",",
"sizeof",
"(",
"raw_meta_header",
")",
")",
";",
"if",
"(",
"count",
"!=",
"sizeof",
"(",
"raw_meta_header",
")",
")",
"break",
";",
"metatag",
"=",
"get_bigendian_uint32",
"(",
"&",
"raw_meta_header",
"[",
"0",
"]",
")",
";",
"metalength",
"=",
"get_bigendian_uint32",
"(",
"&",
"raw_meta_header",
"[",
"4",
"]",
")",
";",
"next",
"=",
"get_bigendian_uint64",
"(",
"&",
"raw_meta_header",
"[",
"8",
"]",
")",
";",
"metaflags",
"=",
"metalength",
">>",
"24",
";",
"metalength",
"&=",
"0x00ffffff",
";",
"if",
"(",
"!",
"(",
"metaflags",
"&",
"CHD_MDFLAGS_CHECKSUM",
")",
")",
"continue",
";",
"tempbuffer",
"=",
"(",
"UINT8",
"*",
")",
"malloc",
"(",
"metalength",
")",
";",
"if",
"(",
"tempbuffer",
"==",
"NULL",
")",
"{",
"err",
"=",
"CHDERR_OUT_OF_MEMORY",
";",
"goto",
"cleanup",
";",
"}",
"core_fseek",
"(",
"chd",
"->",
"file",
",",
"offset",
"+",
"METADATA_HEADER_SIZE",
",",
"SEEK_SET",
")",
";",
"count",
"=",
"core_fread",
"(",
"chd",
"->",
"file",
",",
"tempbuffer",
",",
"metalength",
")",
";",
"if",
"(",
"count",
"!=",
"metalength",
")",
"{",
"free",
"(",
"tempbuffer",
")",
";",
"err",
"=",
"CHDERR_READ_ERROR",
";",
"goto",
"cleanup",
";",
"}",
"sha1_init",
"(",
"&",
"sha1",
")",
";",
"sha1_update",
"(",
"&",
"sha1",
",",
"metalength",
",",
"tempbuffer",
")",
";",
"sha1_final",
"(",
"&",
"sha1",
")",
";",
"free",
"(",
"tempbuffer",
")",
";",
"if",
"(",
"hashindex",
">=",
"hashalloc",
")",
"{",
"hashalloc",
"+=",
"256",
";",
"hasharray",
"=",
"(",
"metadata_hash",
"*",
")",
"realloc",
"(",
"hasharray",
",",
"hashalloc",
"*",
"sizeof",
"(",
"hasharray",
"[",
"0",
"]",
")",
")",
";",
"if",
"(",
"hasharray",
"==",
"NULL",
")",
"{",
"err",
"=",
"CHDERR_OUT_OF_MEMORY",
";",
"goto",
"cleanup",
";",
"}",
"}",
"put_bigendian_uint32",
"(",
"hasharray",
"[",
"hashindex",
"]",
".",
"tag",
",",
"metatag",
")",
";",
"sha1_digest",
"(",
"&",
"sha1",
",",
"SHA1_DIGEST_SIZE",
",",
"hasharray",
"[",
"hashindex",
"]",
".",
"sha1",
")",
";",
"hashindex",
"++",
";",
"}",
"qsort",
"(",
"hasharray",
",",
"hashindex",
",",
"sizeof",
"(",
"hasharray",
"[",
"0",
"]",
")",
",",
"metadata_hash_compare",
")",
";",
"sha1_init",
"(",
"&",
"sha1",
")",
";",
"sha1_update",
"(",
"&",
"sha1",
",",
"CHD_SHA1_BYTES",
",",
"rawsha1",
")",
";",
"sha1_update",
"(",
"&",
"sha1",
",",
"hashindex",
"*",
"sizeof",
"(",
"hasharray",
"[",
"0",
"]",
")",
",",
"(",
"const",
"UINT8",
"*",
")",
"hasharray",
")",
";",
"sha1_final",
"(",
"&",
"sha1",
")",
";",
"sha1_digest",
"(",
"&",
"sha1",
",",
"SHA1_DIGEST_SIZE",
",",
"finalsha1",
")",
";",
"cleanup",
":",
"if",
"(",
"hasharray",
"!=",
"NULL",
")",
"free",
"(",
"hasharray",
")",
";",
"return",
"err",
";",
"}"
] | metadata_compute_hash - compute the SHA1
hash of all metadata that requests it | [
"metadata_compute_hash",
"-",
"compute",
"the",
"SHA1",
"hash",
"of",
"all",
"metadata",
"that",
"requests",
"it"
] | [
"/* only works for V4 and above */",
"/* loop until we run out of data */",
"/* read the raw header */",
"/* extract the data */",
"/* flags are encoded in the high byte of length */",
"/* if not checksumming, continue */",
"/* allocate memory */",
"/* seek and read the metadata */",
"/* compute this entry's hash */",
"/* expand the hasharray if necessary */",
"/* fill in the entry */",
"/* sort the array */",
"/* compute the SHA1 of the raw plus the various metadata */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "rawsha1",
"type": "UINT8"
},
{
"param": "finalsha1",
"type": "UINT8"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rawsha1",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "finalsha1",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | zlib_codec_free | void | static void zlib_codec_free(chd_file *chd)
{
zlib_codec_data *data = (zlib_codec_data *)chd->codecdata;
/* deinit the streams */
if (data != NULL)
{
int i;
inflateEnd(&data->inflater);
deflateEnd(&data->deflater);
/* free our fast memory */
for (i = 0; i < MAX_ZLIB_ALLOCS; i++)
if (data->allocptr[i])
free(data->allocptr[i]);
free(data);
}
} | /*-------------------------------------------------
zlib_codec_free - free data for the ZLIB
codec
-------------------------------------------------*/ | free data for the ZLIB
codec | [
"free",
"data",
"for",
"the",
"ZLIB",
"codec"
] | static void zlib_codec_free(chd_file *chd)
{
zlib_codec_data *data = (zlib_codec_data *)chd->codecdata;
if (data != NULL)
{
int i;
inflateEnd(&data->inflater);
deflateEnd(&data->deflater);
for (i = 0; i < MAX_ZLIB_ALLOCS; i++)
if (data->allocptr[i])
free(data->allocptr[i]);
free(data);
}
} | [
"static",
"void",
"zlib_codec_free",
"(",
"chd_file",
"*",
"chd",
")",
"{",
"zlib_codec_data",
"*",
"data",
"=",
"(",
"zlib_codec_data",
"*",
")",
"chd",
"->",
"codecdata",
";",
"if",
"(",
"data",
"!=",
"NULL",
")",
"{",
"int",
"i",
";",
"inflateEnd",
"(",
"&",
"data",
"->",
"inflater",
")",
";",
"deflateEnd",
"(",
"&",
"data",
"->",
"deflater",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"MAX_ZLIB_ALLOCS",
";",
"i",
"++",
")",
"if",
"(",
"data",
"->",
"allocptr",
"[",
"i",
"]",
")",
"free",
"(",
"data",
"->",
"allocptr",
"[",
"i",
"]",
")",
";",
"free",
"(",
"data",
")",
";",
"}",
"}"
] | zlib_codec_free - free data for the ZLIB
codec | [
"zlib_codec_free",
"-",
"free",
"data",
"for",
"the",
"ZLIB",
"codec"
] | [
"/* deinit the streams */",
"/* free our fast memory */"
] | [
{
"param": "chd",
"type": "chd_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | zlib_codec_compress | chd_error | static chd_error zlib_codec_compress(chd_file *chd, const void *src, UINT32 *length)
{
zlib_codec_data *data = (zlib_codec_data *)chd->codecdata;
int zerr;
/* reset the decompressor */
data->deflater.next_in = (Bytef *)src;
data->deflater.avail_in = chd->header.hunkbytes;
data->deflater.total_in = 0;
data->deflater.next_out = chd->compressed;
data->deflater.avail_out = chd->header.hunkbytes;
data->deflater.total_out = 0;
zerr = deflateReset(&data->deflater);
if (zerr != Z_OK)
return CHDERR_COMPRESSION_ERROR;
/* do it */
zerr = deflate(&data->deflater, Z_FINISH);
/* if we ended up with more data than we started with, return an error */
if (zerr != Z_STREAM_END || data->deflater.total_out >= chd->header.hunkbytes)
return CHDERR_COMPRESSION_ERROR;
/* otherwise, fill in the length and return success */
*length = data->deflater.total_out;
return CHDERR_NONE;
} | /*-------------------------------------------------
zlib_codec_compress - compress data using the
ZLIB codec
-------------------------------------------------*/ | compress data using the
ZLIB codec | [
"compress",
"data",
"using",
"the",
"ZLIB",
"codec"
] | static chd_error zlib_codec_compress(chd_file *chd, const void *src, UINT32 *length)
{
zlib_codec_data *data = (zlib_codec_data *)chd->codecdata;
int zerr;
data->deflater.next_in = (Bytef *)src;
data->deflater.avail_in = chd->header.hunkbytes;
data->deflater.total_in = 0;
data->deflater.next_out = chd->compressed;
data->deflater.avail_out = chd->header.hunkbytes;
data->deflater.total_out = 0;
zerr = deflateReset(&data->deflater);
if (zerr != Z_OK)
return CHDERR_COMPRESSION_ERROR;
zerr = deflate(&data->deflater, Z_FINISH);
if (zerr != Z_STREAM_END || data->deflater.total_out >= chd->header.hunkbytes)
return CHDERR_COMPRESSION_ERROR;
*length = data->deflater.total_out;
return CHDERR_NONE;
} | [
"static",
"chd_error",
"zlib_codec_compress",
"(",
"chd_file",
"*",
"chd",
",",
"const",
"void",
"*",
"src",
",",
"UINT32",
"*",
"length",
")",
"{",
"zlib_codec_data",
"*",
"data",
"=",
"(",
"zlib_codec_data",
"*",
")",
"chd",
"->",
"codecdata",
";",
"int",
"zerr",
";",
"data",
"->",
"deflater",
".",
"next_in",
"=",
"(",
"Bytef",
"*",
")",
"src",
";",
"data",
"->",
"deflater",
".",
"avail_in",
"=",
"chd",
"->",
"header",
".",
"hunkbytes",
";",
"data",
"->",
"deflater",
".",
"total_in",
"=",
"0",
";",
"data",
"->",
"deflater",
".",
"next_out",
"=",
"chd",
"->",
"compressed",
";",
"data",
"->",
"deflater",
".",
"avail_out",
"=",
"chd",
"->",
"header",
".",
"hunkbytes",
";",
"data",
"->",
"deflater",
".",
"total_out",
"=",
"0",
";",
"zerr",
"=",
"deflateReset",
"(",
"&",
"data",
"->",
"deflater",
")",
";",
"if",
"(",
"zerr",
"!=",
"Z_OK",
")",
"return",
"CHDERR_COMPRESSION_ERROR",
";",
"zerr",
"=",
"deflate",
"(",
"&",
"data",
"->",
"deflater",
",",
"Z_FINISH",
")",
";",
"if",
"(",
"zerr",
"!=",
"Z_STREAM_END",
"||",
"data",
"->",
"deflater",
".",
"total_out",
">=",
"chd",
"->",
"header",
".",
"hunkbytes",
")",
"return",
"CHDERR_COMPRESSION_ERROR",
";",
"*",
"length",
"=",
"data",
"->",
"deflater",
".",
"total_out",
";",
"return",
"CHDERR_NONE",
";",
"}"
] | zlib_codec_compress - compress data using the
ZLIB codec | [
"zlib_codec_compress",
"-",
"compress",
"data",
"using",
"the",
"ZLIB",
"codec"
] | [
"/* reset the decompressor */",
"/* do it */",
"/* if we ended up with more data than we started with, return an error */",
"/* otherwise, fill in the length and return success */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "src",
"type": "void"
},
{
"param": "length",
"type": "UINT32"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "src",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "length",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | zlib_codec_decompress | chd_error | static chd_error zlib_codec_decompress(chd_file *chd, UINT32 srclength, void *dest)
{
zlib_codec_data *data = (zlib_codec_data *)chd->codecdata;
int zerr;
/* reset the decompressor */
data->inflater.next_in = chd->compressed;
data->inflater.avail_in = srclength;
data->inflater.total_in = 0;
data->inflater.next_out = (Bytef *)dest;
data->inflater.avail_out = chd->header.hunkbytes;
data->inflater.total_out = 0;
zerr = inflateReset(&data->inflater);
if (zerr != Z_OK)
return CHDERR_DECOMPRESSION_ERROR;
/* do it */
zerr = inflate(&data->inflater, Z_FINISH);
if (data->inflater.total_out != chd->header.hunkbytes)
return CHDERR_DECOMPRESSION_ERROR;
return CHDERR_NONE;
} | /*-------------------------------------------------
zlib_codec_decompress - decomrpess data using
the ZLIB codec
-------------------------------------------------*/ | decomrpess data using
the ZLIB codec | [
"decomrpess",
"data",
"using",
"the",
"ZLIB",
"codec"
] | static chd_error zlib_codec_decompress(chd_file *chd, UINT32 srclength, void *dest)
{
zlib_codec_data *data = (zlib_codec_data *)chd->codecdata;
int zerr;
data->inflater.next_in = chd->compressed;
data->inflater.avail_in = srclength;
data->inflater.total_in = 0;
data->inflater.next_out = (Bytef *)dest;
data->inflater.avail_out = chd->header.hunkbytes;
data->inflater.total_out = 0;
zerr = inflateReset(&data->inflater);
if (zerr != Z_OK)
return CHDERR_DECOMPRESSION_ERROR;
zerr = inflate(&data->inflater, Z_FINISH);
if (data->inflater.total_out != chd->header.hunkbytes)
return CHDERR_DECOMPRESSION_ERROR;
return CHDERR_NONE;
} | [
"static",
"chd_error",
"zlib_codec_decompress",
"(",
"chd_file",
"*",
"chd",
",",
"UINT32",
"srclength",
",",
"void",
"*",
"dest",
")",
"{",
"zlib_codec_data",
"*",
"data",
"=",
"(",
"zlib_codec_data",
"*",
")",
"chd",
"->",
"codecdata",
";",
"int",
"zerr",
";",
"data",
"->",
"inflater",
".",
"next_in",
"=",
"chd",
"->",
"compressed",
";",
"data",
"->",
"inflater",
".",
"avail_in",
"=",
"srclength",
";",
"data",
"->",
"inflater",
".",
"total_in",
"=",
"0",
";",
"data",
"->",
"inflater",
".",
"next_out",
"=",
"(",
"Bytef",
"*",
")",
"dest",
";",
"data",
"->",
"inflater",
".",
"avail_out",
"=",
"chd",
"->",
"header",
".",
"hunkbytes",
";",
"data",
"->",
"inflater",
".",
"total_out",
"=",
"0",
";",
"zerr",
"=",
"inflateReset",
"(",
"&",
"data",
"->",
"inflater",
")",
";",
"if",
"(",
"zerr",
"!=",
"Z_OK",
")",
"return",
"CHDERR_DECOMPRESSION_ERROR",
";",
"zerr",
"=",
"inflate",
"(",
"&",
"data",
"->",
"inflater",
",",
"Z_FINISH",
")",
";",
"if",
"(",
"data",
"->",
"inflater",
".",
"total_out",
"!=",
"chd",
"->",
"header",
".",
"hunkbytes",
")",
"return",
"CHDERR_DECOMPRESSION_ERROR",
";",
"return",
"CHDERR_NONE",
";",
"}"
] | zlib_codec_decompress - decomrpess data using
the ZLIB codec | [
"zlib_codec_decompress",
"-",
"decomrpess",
"data",
"using",
"the",
"ZLIB",
"codec"
] | [
"/* reset the decompressor */",
"/* do it */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "srclength",
"type": "UINT32"
},
{
"param": "dest",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "srclength",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dest",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | zlib_fast_alloc | voidpf | static voidpf zlib_fast_alloc(voidpf opaque, uInt items, uInt size)
{
zlib_codec_data *data = (zlib_codec_data *)opaque;
UINT32 *ptr;
int i;
/* compute the size, rounding to the nearest 1k */
size = (size * items + 0x3ff) & ~0x3ff;
/* reuse a hunk if we can */
for (i = 0; i < MAX_ZLIB_ALLOCS; i++)
{
ptr = data->allocptr[i];
if (ptr && size == *ptr)
{
/* set the low bit of the size so we don't match next time */
*ptr |= 1;
return ptr + 1;
}
}
/* alloc a new one */
ptr = (UINT32 *)malloc(size + sizeof(UINT32));
if (!ptr)
return NULL;
/* put it into the list */
for (i = 0; i < MAX_ZLIB_ALLOCS; i++)
if (!data->allocptr[i])
{
data->allocptr[i] = ptr;
break;
}
/* set the low bit of the size so we don't match next time */
*ptr = size | 1;
return ptr + 1;
} | /*-------------------------------------------------
zlib_fast_alloc - fast malloc for ZLIB, which
allocates and frees memory frequently
-------------------------------------------------*/ | fast malloc for ZLIB, which
allocates and frees memory frequently | [
"fast",
"malloc",
"for",
"ZLIB",
"which",
"allocates",
"and",
"frees",
"memory",
"frequently"
] | static voidpf zlib_fast_alloc(voidpf opaque, uInt items, uInt size)
{
zlib_codec_data *data = (zlib_codec_data *)opaque;
UINT32 *ptr;
int i;
size = (size * items + 0x3ff) & ~0x3ff;
for (i = 0; i < MAX_ZLIB_ALLOCS; i++)
{
ptr = data->allocptr[i];
if (ptr && size == *ptr)
{
*ptr |= 1;
return ptr + 1;
}
}
ptr = (UINT32 *)malloc(size + sizeof(UINT32));
if (!ptr)
return NULL;
for (i = 0; i < MAX_ZLIB_ALLOCS; i++)
if (!data->allocptr[i])
{
data->allocptr[i] = ptr;
break;
}
*ptr = size | 1;
return ptr + 1;
} | [
"static",
"voidpf",
"zlib_fast_alloc",
"(",
"voidpf",
"opaque",
",",
"uInt",
"items",
",",
"uInt",
"size",
")",
"{",
"zlib_codec_data",
"*",
"data",
"=",
"(",
"zlib_codec_data",
"*",
")",
"opaque",
";",
"UINT32",
"*",
"ptr",
";",
"int",
"i",
";",
"size",
"=",
"(",
"size",
"*",
"items",
"+",
"0x3ff",
")",
"&",
"~",
"0x3ff",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"MAX_ZLIB_ALLOCS",
";",
"i",
"++",
")",
"{",
"ptr",
"=",
"data",
"->",
"allocptr",
"[",
"i",
"]",
";",
"if",
"(",
"ptr",
"&&",
"size",
"==",
"*",
"ptr",
")",
"{",
"*",
"ptr",
"|=",
"1",
";",
"return",
"ptr",
"+",
"1",
";",
"}",
"}",
"ptr",
"=",
"(",
"UINT32",
"*",
")",
"malloc",
"(",
"size",
"+",
"sizeof",
"(",
"UINT32",
")",
")",
";",
"if",
"(",
"!",
"ptr",
")",
"return",
"NULL",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"MAX_ZLIB_ALLOCS",
";",
"i",
"++",
")",
"if",
"(",
"!",
"data",
"->",
"allocptr",
"[",
"i",
"]",
")",
"{",
"data",
"->",
"allocptr",
"[",
"i",
"]",
"=",
"ptr",
";",
"break",
";",
"}",
"*",
"ptr",
"=",
"size",
"|",
"1",
";",
"return",
"ptr",
"+",
"1",
";",
"}"
] | zlib_fast_alloc - fast malloc for ZLIB, which
allocates and frees memory frequently | [
"zlib_fast_alloc",
"-",
"fast",
"malloc",
"for",
"ZLIB",
"which",
"allocates",
"and",
"frees",
"memory",
"frequently"
] | [
"/* compute the size, rounding to the nearest 1k */",
"/* reuse a hunk if we can */",
"/* set the low bit of the size so we don't match next time */",
"/* alloc a new one */",
"/* put it into the list */",
"/* set the low bit of the size so we don't match next time */"
] | [
{
"param": "opaque",
"type": "voidpf"
},
{
"param": "items",
"type": "uInt"
},
{
"param": "size",
"type": "uInt"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "opaque",
"type": "voidpf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "items",
"type": "uInt",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "size",
"type": "uInt",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | zlib_fast_free | void | static void zlib_fast_free(voidpf opaque, voidpf address)
{
zlib_codec_data *data = (zlib_codec_data *)opaque;
UINT32 *ptr = (UINT32 *)address - 1;
int i;
/* find the hunk */
for (i = 0; i < MAX_ZLIB_ALLOCS; i++)
if (ptr == data->allocptr[i])
{
/* clear the low bit of the size to allow matches */
*ptr &= ~1;
return;
}
} | /*-------------------------------------------------
zlib_fast_free - fast free for ZLIB, which
allocates and frees memory frequently
-------------------------------------------------*/ | fast free for ZLIB, which
allocates and frees memory frequently | [
"fast",
"free",
"for",
"ZLIB",
"which",
"allocates",
"and",
"frees",
"memory",
"frequently"
] | static void zlib_fast_free(voidpf opaque, voidpf address)
{
zlib_codec_data *data = (zlib_codec_data *)opaque;
UINT32 *ptr = (UINT32 *)address - 1;
int i;
for (i = 0; i < MAX_ZLIB_ALLOCS; i++)
if (ptr == data->allocptr[i])
{
*ptr &= ~1;
return;
}
} | [
"static",
"void",
"zlib_fast_free",
"(",
"voidpf",
"opaque",
",",
"voidpf",
"address",
")",
"{",
"zlib_codec_data",
"*",
"data",
"=",
"(",
"zlib_codec_data",
"*",
")",
"opaque",
";",
"UINT32",
"*",
"ptr",
"=",
"(",
"UINT32",
"*",
")",
"address",
"-",
"1",
";",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"MAX_ZLIB_ALLOCS",
";",
"i",
"++",
")",
"if",
"(",
"ptr",
"==",
"data",
"->",
"allocptr",
"[",
"i",
"]",
")",
"{",
"*",
"ptr",
"&=",
"~",
"1",
";",
"return",
";",
"}",
"}"
] | zlib_fast_free - fast free for ZLIB, which
allocates and frees memory frequently | [
"zlib_fast_free",
"-",
"fast",
"free",
"for",
"ZLIB",
"which",
"allocates",
"and",
"frees",
"memory",
"frequently"
] | [
"/* find the hunk */",
"/* clear the low bit of the size to allow matches */"
] | [
{
"param": "opaque",
"type": "voidpf"
},
{
"param": "address",
"type": "voidpf"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "opaque",
"type": "voidpf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "address",
"type": "voidpf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | av_codec_init | chd_error | static chd_error av_codec_init(chd_file *chd)
{
av_codec_data *data;
/* allocate memory for the 2 stream buffers */
data = (av_codec_data *)malloc(sizeof(*data));
if (data == NULL)
return CHDERR_OUT_OF_MEMORY;
/* clear the buffers */
memset(data, 0, sizeof(*data));
chd->codecdata = data;
/* attempt to do a post-init now; if we're creating a new CHD, this won't work */
/* but that's ok */
av_codec_postinit(chd);
return CHDERR_NONE;
} | /*-------------------------------------------------
av_codec_init - initialize the A/V codec
-------------------------------------------------*/ | initialize the A/V codec | [
"initialize",
"the",
"A",
"/",
"V",
"codec"
] | static chd_error av_codec_init(chd_file *chd)
{
av_codec_data *data;
data = (av_codec_data *)malloc(sizeof(*data));
if (data == NULL)
return CHDERR_OUT_OF_MEMORY;
memset(data, 0, sizeof(*data));
chd->codecdata = data;
av_codec_postinit(chd);
return CHDERR_NONE;
} | [
"static",
"chd_error",
"av_codec_init",
"(",
"chd_file",
"*",
"chd",
")",
"{",
"av_codec_data",
"*",
"data",
";",
"data",
"=",
"(",
"av_codec_data",
"*",
")",
"malloc",
"(",
"sizeof",
"(",
"*",
"data",
")",
")",
";",
"if",
"(",
"data",
"==",
"NULL",
")",
"return",
"CHDERR_OUT_OF_MEMORY",
";",
"memset",
"(",
"data",
",",
"0",
",",
"sizeof",
"(",
"*",
"data",
")",
")",
";",
"chd",
"->",
"codecdata",
"=",
"data",
";",
"av_codec_postinit",
"(",
"chd",
")",
";",
"return",
"CHDERR_NONE",
";",
"}"
] | av_codec_init - initialize the A/V codec | [
"av_codec_init",
"-",
"initialize",
"the",
"A",
"/",
"V",
"codec"
] | [
"/* allocate memory for the 2 stream buffers */",
"/* clear the buffers */",
"/* attempt to do a post-init now; if we're creating a new CHD, this won't work */",
"/* but that's ok */"
] | [
{
"param": "chd",
"type": "chd_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | av_codec_free | void | static void av_codec_free(chd_file *chd)
{
av_codec_data *data = (av_codec_data *)chd->codecdata;
/* deinit avcomp */
if (data != NULL)
{
if (data->compstate != NULL)
avcomp_free(data->compstate);
free(data);
}
} | /*-------------------------------------------------
av_codec_free - free data for the A/V
codec
-------------------------------------------------*/ | free data for the A/V
codec | [
"free",
"data",
"for",
"the",
"A",
"/",
"V",
"codec"
] | static void av_codec_free(chd_file *chd)
{
av_codec_data *data = (av_codec_data *)chd->codecdata;
if (data != NULL)
{
if (data->compstate != NULL)
avcomp_free(data->compstate);
free(data);
}
} | [
"static",
"void",
"av_codec_free",
"(",
"chd_file",
"*",
"chd",
")",
"{",
"av_codec_data",
"*",
"data",
"=",
"(",
"av_codec_data",
"*",
")",
"chd",
"->",
"codecdata",
";",
"if",
"(",
"data",
"!=",
"NULL",
")",
"{",
"if",
"(",
"data",
"->",
"compstate",
"!=",
"NULL",
")",
"avcomp_free",
"(",
"data",
"->",
"compstate",
")",
";",
"free",
"(",
"data",
")",
";",
"}",
"}"
] | av_codec_free - free data for the A/V
codec | [
"av_codec_free",
"-",
"free",
"data",
"for",
"the",
"A",
"/",
"V",
"codec"
] | [
"/* deinit avcomp */"
] | [
{
"param": "chd",
"type": "chd_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | av_codec_compress | chd_error | static chd_error av_codec_compress(chd_file *chd, const void *src, UINT32 *length)
{
av_codec_data *data = (av_codec_data *)chd->codecdata;
int averr;
int size;
/* if we haven't yet set up the avcomp code, do it now */
if (data->compstate == NULL)
{
chd_error chderr = av_codec_postinit(chd);
if (chderr != CHDERR_NONE)
return chderr;
}
/* make sure short frames are padded with 0 */
if (src != NULL)
{
size = av_raw_data_size((const UINT8 *)src);
while (size < chd->header.hunkbytes)
if (((const UINT8 *)src)[size++] != 0)
return CHDERR_INVALID_DATA;
}
/* encode the audio and video */
averr = avcomp_encode_data(data->compstate, (const UINT8 *)src, chd->compressed, length);
if (averr != AVCERR_NONE || *length > chd->header.hunkbytes)
return CHDERR_COMPRESSION_ERROR;
return CHDERR_NONE;
} | /*-------------------------------------------------
av_codec_compress - compress data using the
A/V codec
-------------------------------------------------*/ | compress data using the
A/V codec | [
"compress",
"data",
"using",
"the",
"A",
"/",
"V",
"codec"
] | static chd_error av_codec_compress(chd_file *chd, const void *src, UINT32 *length)
{
av_codec_data *data = (av_codec_data *)chd->codecdata;
int averr;
int size;
if (data->compstate == NULL)
{
chd_error chderr = av_codec_postinit(chd);
if (chderr != CHDERR_NONE)
return chderr;
}
if (src != NULL)
{
size = av_raw_data_size((const UINT8 *)src);
while (size < chd->header.hunkbytes)
if (((const UINT8 *)src)[size++] != 0)
return CHDERR_INVALID_DATA;
}
averr = avcomp_encode_data(data->compstate, (const UINT8 *)src, chd->compressed, length);
if (averr != AVCERR_NONE || *length > chd->header.hunkbytes)
return CHDERR_COMPRESSION_ERROR;
return CHDERR_NONE;
} | [
"static",
"chd_error",
"av_codec_compress",
"(",
"chd_file",
"*",
"chd",
",",
"const",
"void",
"*",
"src",
",",
"UINT32",
"*",
"length",
")",
"{",
"av_codec_data",
"*",
"data",
"=",
"(",
"av_codec_data",
"*",
")",
"chd",
"->",
"codecdata",
";",
"int",
"averr",
";",
"int",
"size",
";",
"if",
"(",
"data",
"->",
"compstate",
"==",
"NULL",
")",
"{",
"chd_error",
"chderr",
"=",
"av_codec_postinit",
"(",
"chd",
")",
";",
"if",
"(",
"chderr",
"!=",
"CHDERR_NONE",
")",
"return",
"chderr",
";",
"}",
"if",
"(",
"src",
"!=",
"NULL",
")",
"{",
"size",
"=",
"av_raw_data_size",
"(",
"(",
"const",
"UINT8",
"*",
")",
"src",
")",
";",
"while",
"(",
"size",
"<",
"chd",
"->",
"header",
".",
"hunkbytes",
")",
"if",
"(",
"(",
"(",
"const",
"UINT8",
"*",
")",
"src",
")",
"[",
"size",
"++",
"]",
"!=",
"0",
")",
"return",
"CHDERR_INVALID_DATA",
";",
"}",
"averr",
"=",
"avcomp_encode_data",
"(",
"data",
"->",
"compstate",
",",
"(",
"const",
"UINT8",
"*",
")",
"src",
",",
"chd",
"->",
"compressed",
",",
"length",
")",
";",
"if",
"(",
"averr",
"!=",
"AVCERR_NONE",
"||",
"*",
"length",
">",
"chd",
"->",
"header",
".",
"hunkbytes",
")",
"return",
"CHDERR_COMPRESSION_ERROR",
";",
"return",
"CHDERR_NONE",
";",
"}"
] | av_codec_compress - compress data using the
A/V codec | [
"av_codec_compress",
"-",
"compress",
"data",
"using",
"the",
"A",
"/",
"V",
"codec"
] | [
"/* if we haven't yet set up the avcomp code, do it now */",
"/* make sure short frames are padded with 0 */",
"/* encode the audio and video */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "src",
"type": "void"
},
{
"param": "length",
"type": "UINT32"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "src",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "length",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | av_codec_decompress | chd_error | static chd_error av_codec_decompress(chd_file *chd, UINT32 srclength, void *dest)
{
av_codec_data *data = (av_codec_data *)chd->codecdata;
const UINT8 *source;
avcomp_error averr;
int size;
/* if we haven't yet set up the avcomp code, do it now */
if (data->compstate == NULL)
{
chd_error chderr = av_codec_postinit(chd);
if (chderr != CHDERR_NONE)
return chderr;
}
/* decode the audio and video */
source = chd->compressed;
averr = avcomp_decode_data(data->compstate, source, srclength, (UINT8 *)dest);
if (averr != AVCERR_NONE)
return CHDERR_DECOMPRESSION_ERROR;
/* pad short frames with 0 */
if (dest != NULL)
{
size = av_raw_data_size((const UINT8 *)dest);
while (size < chd->header.hunkbytes)
((UINT8 *)dest)[size++] = 0;
}
return CHDERR_NONE;
} | /*-------------------------------------------------
av_codec_decompress - decomrpess data using
the A/V codec
-------------------------------------------------*/ | decomrpess data using
the A/V codec | [
"decomrpess",
"data",
"using",
"the",
"A",
"/",
"V",
"codec"
] | static chd_error av_codec_decompress(chd_file *chd, UINT32 srclength, void *dest)
{
av_codec_data *data = (av_codec_data *)chd->codecdata;
const UINT8 *source;
avcomp_error averr;
int size;
if (data->compstate == NULL)
{
chd_error chderr = av_codec_postinit(chd);
if (chderr != CHDERR_NONE)
return chderr;
}
source = chd->compressed;
averr = avcomp_decode_data(data->compstate, source, srclength, (UINT8 *)dest);
if (averr != AVCERR_NONE)
return CHDERR_DECOMPRESSION_ERROR;
if (dest != NULL)
{
size = av_raw_data_size((const UINT8 *)dest);
while (size < chd->header.hunkbytes)
((UINT8 *)dest)[size++] = 0;
}
return CHDERR_NONE;
} | [
"static",
"chd_error",
"av_codec_decompress",
"(",
"chd_file",
"*",
"chd",
",",
"UINT32",
"srclength",
",",
"void",
"*",
"dest",
")",
"{",
"av_codec_data",
"*",
"data",
"=",
"(",
"av_codec_data",
"*",
")",
"chd",
"->",
"codecdata",
";",
"const",
"UINT8",
"*",
"source",
";",
"avcomp_error",
"averr",
";",
"int",
"size",
";",
"if",
"(",
"data",
"->",
"compstate",
"==",
"NULL",
")",
"{",
"chd_error",
"chderr",
"=",
"av_codec_postinit",
"(",
"chd",
")",
";",
"if",
"(",
"chderr",
"!=",
"CHDERR_NONE",
")",
"return",
"chderr",
";",
"}",
"source",
"=",
"chd",
"->",
"compressed",
";",
"averr",
"=",
"avcomp_decode_data",
"(",
"data",
"->",
"compstate",
",",
"source",
",",
"srclength",
",",
"(",
"UINT8",
"*",
")",
"dest",
")",
";",
"if",
"(",
"averr",
"!=",
"AVCERR_NONE",
")",
"return",
"CHDERR_DECOMPRESSION_ERROR",
";",
"if",
"(",
"dest",
"!=",
"NULL",
")",
"{",
"size",
"=",
"av_raw_data_size",
"(",
"(",
"const",
"UINT8",
"*",
")",
"dest",
")",
";",
"while",
"(",
"size",
"<",
"chd",
"->",
"header",
".",
"hunkbytes",
")",
"(",
"(",
"UINT8",
"*",
")",
"dest",
")",
"[",
"size",
"++",
"]",
"=",
"0",
";",
"}",
"return",
"CHDERR_NONE",
";",
"}"
] | av_codec_decompress - decomrpess data using
the A/V codec | [
"av_codec_decompress",
"-",
"decomrpess",
"data",
"using",
"the",
"A",
"/",
"V",
"codec"
] | [
"/* if we haven't yet set up the avcomp code, do it now */",
"/* decode the audio and video */",
"/* pad short frames with 0 */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "srclength",
"type": "UINT32"
},
{
"param": "dest",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "srclength",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dest",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | av_codec_config | chd_error | static chd_error av_codec_config(chd_file *chd, int param, void *config)
{
av_codec_data *data = (av_codec_data *)chd->codecdata;
/* if we're getting the compression configuration, apply it now */
if (param == AV_CODEC_COMPRESS_CONFIG)
{
data->compress = *(av_codec_compress_config *)config;
if (data->compstate != NULL)
avcomp_config_compress(data->compstate, &data->compress);
return CHDERR_NONE;
}
/* if we're getting the decompression configuration, apply it now */
else if (param == AV_CODEC_DECOMPRESS_CONFIG)
{
data->decompress = *(av_codec_decompress_config *)config;
if (data->compstate != NULL)
avcomp_config_decompress(data->compstate, &data->decompress);
return CHDERR_NONE;
}
/* anything else is invalid */
return CHDERR_INVALID_PARAMETER;
} | /*-------------------------------------------------
av_codec_config - codec-specific configuration
for the A/V codec
-------------------------------------------------*/ | codec-specific configuration
for the A/V codec | [
"codec",
"-",
"specific",
"configuration",
"for",
"the",
"A",
"/",
"V",
"codec"
] | static chd_error av_codec_config(chd_file *chd, int param, void *config)
{
av_codec_data *data = (av_codec_data *)chd->codecdata;
if (param == AV_CODEC_COMPRESS_CONFIG)
{
data->compress = *(av_codec_compress_config *)config;
if (data->compstate != NULL)
avcomp_config_compress(data->compstate, &data->compress);
return CHDERR_NONE;
}
else if (param == AV_CODEC_DECOMPRESS_CONFIG)
{
data->decompress = *(av_codec_decompress_config *)config;
if (data->compstate != NULL)
avcomp_config_decompress(data->compstate, &data->decompress);
return CHDERR_NONE;
}
return CHDERR_INVALID_PARAMETER;
} | [
"static",
"chd_error",
"av_codec_config",
"(",
"chd_file",
"*",
"chd",
",",
"int",
"param",
",",
"void",
"*",
"config",
")",
"{",
"av_codec_data",
"*",
"data",
"=",
"(",
"av_codec_data",
"*",
")",
"chd",
"->",
"codecdata",
";",
"if",
"(",
"param",
"==",
"AV_CODEC_COMPRESS_CONFIG",
")",
"{",
"data",
"->",
"compress",
"=",
"*",
"(",
"av_codec_compress_config",
"*",
")",
"config",
";",
"if",
"(",
"data",
"->",
"compstate",
"!=",
"NULL",
")",
"avcomp_config_compress",
"(",
"data",
"->",
"compstate",
",",
"&",
"data",
"->",
"compress",
")",
";",
"return",
"CHDERR_NONE",
";",
"}",
"else",
"if",
"(",
"param",
"==",
"AV_CODEC_DECOMPRESS_CONFIG",
")",
"{",
"data",
"->",
"decompress",
"=",
"*",
"(",
"av_codec_decompress_config",
"*",
")",
"config",
";",
"if",
"(",
"data",
"->",
"compstate",
"!=",
"NULL",
")",
"avcomp_config_decompress",
"(",
"data",
"->",
"compstate",
",",
"&",
"data",
"->",
"decompress",
")",
";",
"return",
"CHDERR_NONE",
";",
"}",
"return",
"CHDERR_INVALID_PARAMETER",
";",
"}"
] | av_codec_config - codec-specific configuration
for the A/V codec | [
"av_codec_config",
"-",
"codec",
"-",
"specific",
"configuration",
"for",
"the",
"A",
"/",
"V",
"codec"
] | [
"/* if we're getting the compression configuration, apply it now */",
"/* if we're getting the decompression configuration, apply it now */",
"/* anything else is invalid */"
] | [
{
"param": "chd",
"type": "chd_file"
},
{
"param": "param",
"type": "int"
},
{
"param": "config",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "param",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "config",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
de1516c83d91cc3a04aa5401f52c2a975d90a0d4 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/lib/util/chd.c | [
"Unlicense"
] | C | av_codec_postinit | chd_error | static chd_error av_codec_postinit(chd_file *chd)
{
int fps, fpsfrac, width, height, interlaced, channels, rate;
UINT32 fps_times_1million, max_samples_per_frame, bytes_per_frame;
av_codec_data *data = (av_codec_data *)chd->codecdata;
char metadata[256];
chd_error err;
/* the code below won't work asynchronously */
if (chd->workitem != NULL)
return CHDERR_OPERATION_PENDING;
/* get the metadata */
err = chd_get_metadata(chd, AV_METADATA_TAG, 0, metadata, sizeof(metadata), NULL, NULL, NULL);
if (err != CHDERR_NONE)
return err;
/* extract the info */
if (sscanf(metadata, AV_METADATA_FORMAT, &fps, &fpsfrac, &width, &height, &interlaced, &channels, &rate) != 7)
return CHDERR_INVALID_METADATA;
/* compute the bytes per frame */
fps_times_1million = fps * 1000000 + fpsfrac;
max_samples_per_frame = ((UINT64)rate * 1000000 + fps_times_1million - 1) / fps_times_1million;
bytes_per_frame = 12 + channels * max_samples_per_frame * 2 + width * height * 2;
if (bytes_per_frame > chd->header.hunkbytes)
return CHDERR_INVALID_METADATA;
/* create the avcomp state */
data->compstate = avcomp_init(width, height, channels);
/* configure the codec */
avcomp_config_compress(data->compstate, &data->compress);
avcomp_config_decompress(data->compstate, &data->decompress);
return CHDERR_NONE;
} | /*-------------------------------------------------
av_codec_postinit - actual initialization of
avcomp happens here, on the first attempt
to compress or decompress data
-------------------------------------------------*/ | actual initialization of
avcomp happens here, on the first attempt
to compress or decompress data | [
"actual",
"initialization",
"of",
"avcomp",
"happens",
"here",
"on",
"the",
"first",
"attempt",
"to",
"compress",
"or",
"decompress",
"data"
] | static chd_error av_codec_postinit(chd_file *chd)
{
int fps, fpsfrac, width, height, interlaced, channels, rate;
UINT32 fps_times_1million, max_samples_per_frame, bytes_per_frame;
av_codec_data *data = (av_codec_data *)chd->codecdata;
char metadata[256];
chd_error err;
if (chd->workitem != NULL)
return CHDERR_OPERATION_PENDING;
err = chd_get_metadata(chd, AV_METADATA_TAG, 0, metadata, sizeof(metadata), NULL, NULL, NULL);
if (err != CHDERR_NONE)
return err;
if (sscanf(metadata, AV_METADATA_FORMAT, &fps, &fpsfrac, &width, &height, &interlaced, &channels, &rate) != 7)
return CHDERR_INVALID_METADATA;
fps_times_1million = fps * 1000000 + fpsfrac;
max_samples_per_frame = ((UINT64)rate * 1000000 + fps_times_1million - 1) / fps_times_1million;
bytes_per_frame = 12 + channels * max_samples_per_frame * 2 + width * height * 2;
if (bytes_per_frame > chd->header.hunkbytes)
return CHDERR_INVALID_METADATA;
data->compstate = avcomp_init(width, height, channels);
avcomp_config_compress(data->compstate, &data->compress);
avcomp_config_decompress(data->compstate, &data->decompress);
return CHDERR_NONE;
} | [
"static",
"chd_error",
"av_codec_postinit",
"(",
"chd_file",
"*",
"chd",
")",
"{",
"int",
"fps",
",",
"fpsfrac",
",",
"width",
",",
"height",
",",
"interlaced",
",",
"channels",
",",
"rate",
";",
"UINT32",
"fps_times_1million",
",",
"max_samples_per_frame",
",",
"bytes_per_frame",
";",
"av_codec_data",
"*",
"data",
"=",
"(",
"av_codec_data",
"*",
")",
"chd",
"->",
"codecdata",
";",
"char",
"metadata",
"[",
"256",
"]",
";",
"chd_error",
"err",
";",
"if",
"(",
"chd",
"->",
"workitem",
"!=",
"NULL",
")",
"return",
"CHDERR_OPERATION_PENDING",
";",
"err",
"=",
"chd_get_metadata",
"(",
"chd",
",",
"AV_METADATA_TAG",
",",
"0",
",",
"metadata",
",",
"sizeof",
"(",
"metadata",
")",
",",
"NULL",
",",
"NULL",
",",
"NULL",
")",
";",
"if",
"(",
"err",
"!=",
"CHDERR_NONE",
")",
"return",
"err",
";",
"if",
"(",
"sscanf",
"(",
"metadata",
",",
"AV_METADATA_FORMAT",
",",
"&",
"fps",
",",
"&",
"fpsfrac",
",",
"&",
"width",
",",
"&",
"height",
",",
"&",
"interlaced",
",",
"&",
"channels",
",",
"&",
"rate",
")",
"!=",
"7",
")",
"return",
"CHDERR_INVALID_METADATA",
";",
"fps_times_1million",
"=",
"fps",
"*",
"1000000",
"+",
"fpsfrac",
";",
"max_samples_per_frame",
"=",
"(",
"(",
"UINT64",
")",
"rate",
"*",
"1000000",
"+",
"fps_times_1million",
"-",
"1",
")",
"/",
"fps_times_1million",
";",
"bytes_per_frame",
"=",
"12",
"+",
"channels",
"*",
"max_samples_per_frame",
"*",
"2",
"+",
"width",
"*",
"height",
"*",
"2",
";",
"if",
"(",
"bytes_per_frame",
">",
"chd",
"->",
"header",
".",
"hunkbytes",
")",
"return",
"CHDERR_INVALID_METADATA",
";",
"data",
"->",
"compstate",
"=",
"avcomp_init",
"(",
"width",
",",
"height",
",",
"channels",
")",
";",
"avcomp_config_compress",
"(",
"data",
"->",
"compstate",
",",
"&",
"data",
"->",
"compress",
")",
";",
"avcomp_config_decompress",
"(",
"data",
"->",
"compstate",
",",
"&",
"data",
"->",
"decompress",
")",
";",
"return",
"CHDERR_NONE",
";",
"}"
] | av_codec_postinit - actual initialization of
avcomp happens here, on the first attempt
to compress or decompress data | [
"av_codec_postinit",
"-",
"actual",
"initialization",
"of",
"avcomp",
"happens",
"here",
"on",
"the",
"first",
"attempt",
"to",
"compress",
"or",
"decompress",
"data"
] | [
"/* the code below won't work asynchronously */",
"/* get the metadata */",
"/* extract the info */",
"/* compute the bytes per frame */",
"/* create the avcomp state */",
"/* configure the codec */"
] | [
{
"param": "chd",
"type": "chd_file"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chd",
"type": "chd_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3bc7f26268b7d70ff012b9cf13433d9edc1fec78 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/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)
{
UINT16 layers_pri = metro_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 = metro_scroll[layer * 2 + 0]; UINT16 sx = metro_scroll[layer * 2 + 1];
UINT16 wy = metro_window[layer * 2 + 0]; UINT16 wx = metro_window[layer * 2 + 1];
if (layers_ctrl & (1<<layer)) // for debug
{
/* Only *one* of tilemap_16x16 & tilemap is enabled at any given time! */
draw_tilemap(machine, bitmap,cliprect,bg_tilemap[layer], 0, 1<<(3-pri), sx, sy, wx, wy);
if (tilemap_16x16[layer]) draw_tilemap(machine, bitmap,cliprect,tilemap_16x16[layer], 0, 1<<(3-pri), sx, sy, wx, wy);
}
}
}
} | /* 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)
{
UINT16 layers_pri = metro_videoregs[0x10/2];
int layer;
for (layer = 2; layer >= 0; layer--)
{
if ( pri == ((layers_pri >> (layer*2)) & 3) )
{
UINT16 sy = metro_scroll[layer * 2 + 0]; UINT16 sx = metro_scroll[layer * 2 + 1];
UINT16 wy = metro_window[layer * 2 + 0]; UINT16 wx = metro_window[layer * 2 + 1];
if (layers_ctrl & (1<<layer))
{
draw_tilemap(machine, bitmap,cliprect,bg_tilemap[layer], 0, 1<<(3-pri), sx, sy, wx, wy);
if (tilemap_16x16[layer]) draw_tilemap(machine, bitmap,cliprect,tilemap_16x16[layer], 0, 1<<(3-pri), sx, sy, wx, wy);
}
}
}
} | [
"static",
"void",
"draw_layers",
"(",
"running_machine",
"*",
"machine",
",",
"bitmap_t",
"*",
"bitmap",
",",
"const",
"rectangle",
"*",
"cliprect",
",",
"int",
"pri",
",",
"int",
"layers_ctrl",
")",
"{",
"UINT16",
"layers_pri",
"=",
"metro_videoregs",
"[",
"0x10",
"/",
"2",
"]",
";",
"int",
"layer",
";",
"for",
"(",
"layer",
"=",
"2",
";",
"layer",
">=",
"0",
";",
"layer",
"--",
")",
"{",
"if",
"(",
"pri",
"==",
"(",
"(",
"layers_pri",
">>",
"(",
"layer",
"*",
"2",
")",
")",
"&",
"3",
")",
")",
"{",
"UINT16",
"sy",
"=",
"metro_scroll",
"[",
"layer",
"*",
"2",
"+",
"0",
"]",
";",
"UINT16",
"sx",
"=",
"metro_scroll",
"[",
"layer",
"*",
"2",
"+",
"1",
"]",
";",
"UINT16",
"wy",
"=",
"metro_window",
"[",
"layer",
"*",
"2",
"+",
"0",
"]",
";",
"UINT16",
"wx",
"=",
"metro_window",
"[",
"layer",
"*",
"2",
"+",
"1",
"]",
";",
"if",
"(",
"layers_ctrl",
"&",
"(",
"1",
"<<",
"layer",
")",
")",
"{",
"draw_tilemap",
"(",
"machine",
",",
"bitmap",
",",
"cliprect",
",",
"bg_tilemap",
"[",
"layer",
"]",
",",
"0",
",",
"1",
"<<",
"(",
"3",
"-",
"pri",
")",
",",
"sx",
",",
"sy",
",",
"wx",
",",
"wy",
")",
";",
"if",
"(",
"tilemap_16x16",
"[",
"layer",
"]",
")",
"draw_tilemap",
"(",
"machine",
",",
"bitmap",
",",
"cliprect",
",",
"tilemap_16x16",
"[",
"layer",
"]",
",",
"0",
",",
"1",
"<<",
"(",
"3",
"-",
"pri",
")",
",",
"sx",
",",
"sy",
",",
"wx",
",",
"wy",
")",
";",
"}",
"}",
"}",
"}"
] | 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?",
"/* Scroll and Window values */",
"// for debug",
"/* Only *one* of tilemap_16x16 & tilemap is enabled at any given time! */"
] | [
{
"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": []
} |
3bc7f26268b7d70ff012b9cf13433d9edc1fec78 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/video/metro.c | [
"Unlicense"
] | C | dirty_tiles | void | static void dirty_tiles(int layer,UINT16 *vram)
{
int col,row;
for (row = 0;row < WIN_NY;row++)
{
for (col = 0;col < WIN_NX;col++)
{
int offset = (col + metro_window[layer * 2 + 1] / 8) % BIG_NX +
((row + metro_window[layer * 2 + 0] / 8) % BIG_NY) * BIG_NX;
UINT16 code = vram[offset];
if (!(code & 0x8000) && dirtyindex[(code & 0x1ff0) >> 4])
{
tilemap_mark_tile_dirty(bg_tilemap[layer], row * WIN_NX + col );
if (tilemap_16x16[layer])
tilemap_mark_tile_dirty(tilemap_16x16[layer], row * WIN_NX + col );
}
}
}
} | /* Dirty tilemaps when the tiles set changes */ | Dirty tilemaps when the tiles set changes | [
"Dirty",
"tilemaps",
"when",
"the",
"tiles",
"set",
"changes"
] | static void dirty_tiles(int layer,UINT16 *vram)
{
int col,row;
for (row = 0;row < WIN_NY;row++)
{
for (col = 0;col < WIN_NX;col++)
{
int offset = (col + metro_window[layer * 2 + 1] / 8) % BIG_NX +
((row + metro_window[layer * 2 + 0] / 8) % BIG_NY) * BIG_NX;
UINT16 code = vram[offset];
if (!(code & 0x8000) && dirtyindex[(code & 0x1ff0) >> 4])
{
tilemap_mark_tile_dirty(bg_tilemap[layer], row * WIN_NX + col );
if (tilemap_16x16[layer])
tilemap_mark_tile_dirty(tilemap_16x16[layer], row * WIN_NX + col );
}
}
}
} | [
"static",
"void",
"dirty_tiles",
"(",
"int",
"layer",
",",
"UINT16",
"*",
"vram",
")",
"{",
"int",
"col",
",",
"row",
";",
"for",
"(",
"row",
"=",
"0",
";",
"row",
"<",
"WIN_NY",
";",
"row",
"++",
")",
"{",
"for",
"(",
"col",
"=",
"0",
";",
"col",
"<",
"WIN_NX",
";",
"col",
"++",
")",
"{",
"int",
"offset",
"=",
"(",
"col",
"+",
"metro_window",
"[",
"layer",
"*",
"2",
"+",
"1",
"]",
"/",
"8",
")",
"%",
"BIG_NX",
"+",
"(",
"(",
"row",
"+",
"metro_window",
"[",
"layer",
"*",
"2",
"+",
"0",
"]",
"/",
"8",
")",
"%",
"BIG_NY",
")",
"*",
"BIG_NX",
";",
"UINT16",
"code",
"=",
"vram",
"[",
"offset",
"]",
";",
"if",
"(",
"!",
"(",
"code",
"&",
"0x8000",
")",
"&&",
"dirtyindex",
"[",
"(",
"code",
"&",
"0x1ff0",
")",
">>",
"4",
"]",
")",
"{",
"tilemap_mark_tile_dirty",
"(",
"bg_tilemap",
"[",
"layer",
"]",
",",
"row",
"*",
"WIN_NX",
"+",
"col",
")",
";",
"if",
"(",
"tilemap_16x16",
"[",
"layer",
"]",
")",
"tilemap_mark_tile_dirty",
"(",
"tilemap_16x16",
"[",
"layer",
"]",
",",
"row",
"*",
"WIN_NX",
"+",
"col",
")",
";",
"}",
"}",
"}",
"}"
] | Dirty tilemaps when the tiles set changes | [
"Dirty",
"tilemaps",
"when",
"the",
"tiles",
"set",
"changes"
] | [] | [
{
"param": "layer",
"type": "int"
},
{
"param": "vram",
"type": "UINT16"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "layer",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vram",
"type": "UINT16",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a3fb952528ffa0b1a426b1ea471308311a631f41 | lofunz/mieme | Reloaded/trunk/src/emu/sound/mos6560.c | [
"Unlicense"
] | C | mos6560_drawlines | void | static void mos6560_drawlines( running_device *device, int first, int last )
{
mos6560_state *mos6560 = get_safe_token(device);
int line, vline;
int offs, yoff, xoff, ybegin, yend, i, j;
int attr, ch;
mos6560->lastline = last;
if (first >= last)
return;
for (line = first; (line < mos6560->ypos) && (line < last); line++)
{
for (j = 0; j < mos6560->total_xsize; j++)
*BITMAP_ADDR16(mos6560->bitmap, line, j) = mos6560->framecolor;
}
for (vline = line - mos6560->ypos; (line < last) && (line < mos6560->ypos + mos6560->ysize);)
{
if (mos6560->matrix8x16)
{
offs = (vline >> 4) * mos6560->chars_x;
yoff = (vline & ~0xf) + mos6560->ypos;
ybegin = vline & 0xf;
yend = (vline + 0xf < last - mos6560->ypos) ? 0xf : ((last - line) & 0xf) + ybegin;
}
else
{
offs = (vline >> 3) * mos6560->chars_x;
yoff = (vline & ~7) + mos6560->ypos;
ybegin = vline & 7;
yend = (vline + 7 < last - mos6560->ypos) ? 7 : ((last - line) & 7) + ybegin;
}
if (mos6560->xpos > 0)
{
for (i = ybegin; i <= yend; i++)
for (j = 0; j < mos6560->xpos; j++)
*BITMAP_ADDR16(mos6560->bitmap, yoff + i, j) = mos6560->framecolor;
}
for (xoff = mos6560->xpos; (xoff < mos6560->xpos + mos6560->xsize) && (xoff < mos6560->total_xsize); xoff += 8, offs++)
{
ch = mos6560->dma_read(device->machine, (mos6560->videoaddr + offs) & 0x3fff);
attr = (mos6560->dma_read_color(device->machine, (mos6560->videoaddr + offs) & 0x3fff)) & 0xf;
if (mos6560->type == MOS6560_ATTACKUFO)
{
/* the mos6560 variant used in attckufo only has only one draw mode */
mos6560->mono[1] = attr;
mos6560_draw_character(device, ybegin, yend, ch, yoff, xoff, mos6560->mono);
}
else if (mos6560->inverted)
{
if (attr & 8)
{
mos6560->multiinverted[0] = attr & 7;
mos6560_draw_character_multi(device, ybegin, yend, ch, yoff, xoff, mos6560->multiinverted);
}
else
{
mos6560->monoinverted[0] = attr;
mos6560_draw_character(device, ybegin, yend, ch, yoff, xoff, mos6560->monoinverted);
}
}
else
{
if (attr & 8)
{
mos6560->multi[2] = attr & 7;
mos6560_draw_character_multi(device, ybegin, yend, ch, yoff, xoff, mos6560->multi);
}
else
{
mos6560->mono[1] = attr;
mos6560_draw_character(device, ybegin, yend, ch, yoff, xoff, mos6560->mono);
}
}
}
if (xoff < mos6560->total_xsize)
{
for (i = ybegin; i <= yend; i++)
for (j = xoff; j < mos6560->total_xsize; j++)
*BITMAP_ADDR16(mos6560->bitmap, yoff + i, j) = mos6560->framecolor;
}
if (mos6560->matrix8x16)
{
vline = (vline + 16) & ~0xf;
line = vline + mos6560->ypos;
}
else
{
vline = (vline + 8) & ~7;
line = vline + mos6560->ypos;
}
}
for (; line < last; line++)
for (j = 0; j < mos6560->total_xsize; j++)
*BITMAP_ADDR16(mos6560->bitmap, line, j) = mos6560->framecolor;
} | /*-------------------------------------------------
mos6560_drawlines - draw a certain numer of lines
-------------------------------------------------*/ | draw a certain numer of lines | [
"draw",
"a",
"certain",
"numer",
"of",
"lines"
] | static void mos6560_drawlines( running_device *device, int first, int last )
{
mos6560_state *mos6560 = get_safe_token(device);
int line, vline;
int offs, yoff, xoff, ybegin, yend, i, j;
int attr, ch;
mos6560->lastline = last;
if (first >= last)
return;
for (line = first; (line < mos6560->ypos) && (line < last); line++)
{
for (j = 0; j < mos6560->total_xsize; j++)
*BITMAP_ADDR16(mos6560->bitmap, line, j) = mos6560->framecolor;
}
for (vline = line - mos6560->ypos; (line < last) && (line < mos6560->ypos + mos6560->ysize);)
{
if (mos6560->matrix8x16)
{
offs = (vline >> 4) * mos6560->chars_x;
yoff = (vline & ~0xf) + mos6560->ypos;
ybegin = vline & 0xf;
yend = (vline + 0xf < last - mos6560->ypos) ? 0xf : ((last - line) & 0xf) + ybegin;
}
else
{
offs = (vline >> 3) * mos6560->chars_x;
yoff = (vline & ~7) + mos6560->ypos;
ybegin = vline & 7;
yend = (vline + 7 < last - mos6560->ypos) ? 7 : ((last - line) & 7) + ybegin;
}
if (mos6560->xpos > 0)
{
for (i = ybegin; i <= yend; i++)
for (j = 0; j < mos6560->xpos; j++)
*BITMAP_ADDR16(mos6560->bitmap, yoff + i, j) = mos6560->framecolor;
}
for (xoff = mos6560->xpos; (xoff < mos6560->xpos + mos6560->xsize) && (xoff < mos6560->total_xsize); xoff += 8, offs++)
{
ch = mos6560->dma_read(device->machine, (mos6560->videoaddr + offs) & 0x3fff);
attr = (mos6560->dma_read_color(device->machine, (mos6560->videoaddr + offs) & 0x3fff)) & 0xf;
if (mos6560->type == MOS6560_ATTACKUFO)
{
mos6560->mono[1] = attr;
mos6560_draw_character(device, ybegin, yend, ch, yoff, xoff, mos6560->mono);
}
else if (mos6560->inverted)
{
if (attr & 8)
{
mos6560->multiinverted[0] = attr & 7;
mos6560_draw_character_multi(device, ybegin, yend, ch, yoff, xoff, mos6560->multiinverted);
}
else
{
mos6560->monoinverted[0] = attr;
mos6560_draw_character(device, ybegin, yend, ch, yoff, xoff, mos6560->monoinverted);
}
}
else
{
if (attr & 8)
{
mos6560->multi[2] = attr & 7;
mos6560_draw_character_multi(device, ybegin, yend, ch, yoff, xoff, mos6560->multi);
}
else
{
mos6560->mono[1] = attr;
mos6560_draw_character(device, ybegin, yend, ch, yoff, xoff, mos6560->mono);
}
}
}
if (xoff < mos6560->total_xsize)
{
for (i = ybegin; i <= yend; i++)
for (j = xoff; j < mos6560->total_xsize; j++)
*BITMAP_ADDR16(mos6560->bitmap, yoff + i, j) = mos6560->framecolor;
}
if (mos6560->matrix8x16)
{
vline = (vline + 16) & ~0xf;
line = vline + mos6560->ypos;
}
else
{
vline = (vline + 8) & ~7;
line = vline + mos6560->ypos;
}
}
for (; line < last; line++)
for (j = 0; j < mos6560->total_xsize; j++)
*BITMAP_ADDR16(mos6560->bitmap, line, j) = mos6560->framecolor;
} | [
"static",
"void",
"mos6560_drawlines",
"(",
"running_device",
"*",
"device",
",",
"int",
"first",
",",
"int",
"last",
")",
"{",
"mos6560_state",
"*",
"mos6560",
"=",
"get_safe_token",
"(",
"device",
")",
";",
"int",
"line",
",",
"vline",
";",
"int",
"offs",
",",
"yoff",
",",
"xoff",
",",
"ybegin",
",",
"yend",
",",
"i",
",",
"j",
";",
"int",
"attr",
",",
"ch",
";",
"mos6560",
"->",
"lastline",
"=",
"last",
";",
"if",
"(",
"first",
">=",
"last",
")",
"return",
";",
"for",
"(",
"line",
"=",
"first",
";",
"(",
"line",
"<",
"mos6560",
"->",
"ypos",
")",
"&&",
"(",
"line",
"<",
"last",
")",
";",
"line",
"++",
")",
"{",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"mos6560",
"->",
"total_xsize",
";",
"j",
"++",
")",
"*",
"BITMAP_ADDR16",
"(",
"mos6560",
"->",
"bitmap",
",",
"line",
",",
"j",
")",
"=",
"mos6560",
"->",
"framecolor",
";",
"}",
"for",
"(",
"vline",
"=",
"line",
"-",
"mos6560",
"->",
"ypos",
";",
"(",
"line",
"<",
"last",
")",
"&&",
"(",
"line",
"<",
"mos6560",
"->",
"ypos",
"+",
"mos6560",
"->",
"ysize",
")",
";",
")",
"{",
"if",
"(",
"mos6560",
"->",
"matrix8x16",
")",
"{",
"offs",
"=",
"(",
"vline",
">>",
"4",
")",
"*",
"mos6560",
"->",
"chars_x",
";",
"yoff",
"=",
"(",
"vline",
"&",
"~",
"0xf",
")",
"+",
"mos6560",
"->",
"ypos",
";",
"ybegin",
"=",
"vline",
"&",
"0xf",
";",
"yend",
"=",
"(",
"vline",
"+",
"0xf",
"<",
"last",
"-",
"mos6560",
"->",
"ypos",
")",
"?",
"0xf",
":",
"(",
"(",
"last",
"-",
"line",
")",
"&",
"0xf",
")",
"+",
"ybegin",
";",
"}",
"else",
"{",
"offs",
"=",
"(",
"vline",
">>",
"3",
")",
"*",
"mos6560",
"->",
"chars_x",
";",
"yoff",
"=",
"(",
"vline",
"&",
"~",
"7",
")",
"+",
"mos6560",
"->",
"ypos",
";",
"ybegin",
"=",
"vline",
"&",
"7",
";",
"yend",
"=",
"(",
"vline",
"+",
"7",
"<",
"last",
"-",
"mos6560",
"->",
"ypos",
")",
"?",
"7",
":",
"(",
"(",
"last",
"-",
"line",
")",
"&",
"7",
")",
"+",
"ybegin",
";",
"}",
"if",
"(",
"mos6560",
"->",
"xpos",
">",
"0",
")",
"{",
"for",
"(",
"i",
"=",
"ybegin",
";",
"i",
"<=",
"yend",
";",
"i",
"++",
")",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"mos6560",
"->",
"xpos",
";",
"j",
"++",
")",
"*",
"BITMAP_ADDR16",
"(",
"mos6560",
"->",
"bitmap",
",",
"yoff",
"+",
"i",
",",
"j",
")",
"=",
"mos6560",
"->",
"framecolor",
";",
"}",
"for",
"(",
"xoff",
"=",
"mos6560",
"->",
"xpos",
";",
"(",
"xoff",
"<",
"mos6560",
"->",
"xpos",
"+",
"mos6560",
"->",
"xsize",
")",
"&&",
"(",
"xoff",
"<",
"mos6560",
"->",
"total_xsize",
")",
";",
"xoff",
"+=",
"8",
",",
"offs",
"++",
")",
"{",
"ch",
"=",
"mos6560",
"->",
"dma_read",
"(",
"device",
"->",
"machine",
",",
"(",
"mos6560",
"->",
"videoaddr",
"+",
"offs",
")",
"&",
"0x3fff",
")",
";",
"attr",
"=",
"(",
"mos6560",
"->",
"dma_read_color",
"(",
"device",
"->",
"machine",
",",
"(",
"mos6560",
"->",
"videoaddr",
"+",
"offs",
")",
"&",
"0x3fff",
")",
")",
"&",
"0xf",
";",
"if",
"(",
"mos6560",
"->",
"type",
"==",
"MOS6560_ATTACKUFO",
")",
"{",
"mos6560",
"->",
"mono",
"[",
"1",
"]",
"=",
"attr",
";",
"mos6560_draw_character",
"(",
"device",
",",
"ybegin",
",",
"yend",
",",
"ch",
",",
"yoff",
",",
"xoff",
",",
"mos6560",
"->",
"mono",
")",
";",
"}",
"else",
"if",
"(",
"mos6560",
"->",
"inverted",
")",
"{",
"if",
"(",
"attr",
"&",
"8",
")",
"{",
"mos6560",
"->",
"multiinverted",
"[",
"0",
"]",
"=",
"attr",
"&",
"7",
";",
"mos6560_draw_character_multi",
"(",
"device",
",",
"ybegin",
",",
"yend",
",",
"ch",
",",
"yoff",
",",
"xoff",
",",
"mos6560",
"->",
"multiinverted",
")",
";",
"}",
"else",
"{",
"mos6560",
"->",
"monoinverted",
"[",
"0",
"]",
"=",
"attr",
";",
"mos6560_draw_character",
"(",
"device",
",",
"ybegin",
",",
"yend",
",",
"ch",
",",
"yoff",
",",
"xoff",
",",
"mos6560",
"->",
"monoinverted",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"attr",
"&",
"8",
")",
"{",
"mos6560",
"->",
"multi",
"[",
"2",
"]",
"=",
"attr",
"&",
"7",
";",
"mos6560_draw_character_multi",
"(",
"device",
",",
"ybegin",
",",
"yend",
",",
"ch",
",",
"yoff",
",",
"xoff",
",",
"mos6560",
"->",
"multi",
")",
";",
"}",
"else",
"{",
"mos6560",
"->",
"mono",
"[",
"1",
"]",
"=",
"attr",
";",
"mos6560_draw_character",
"(",
"device",
",",
"ybegin",
",",
"yend",
",",
"ch",
",",
"yoff",
",",
"xoff",
",",
"mos6560",
"->",
"mono",
")",
";",
"}",
"}",
"}",
"if",
"(",
"xoff",
"<",
"mos6560",
"->",
"total_xsize",
")",
"{",
"for",
"(",
"i",
"=",
"ybegin",
";",
"i",
"<=",
"yend",
";",
"i",
"++",
")",
"for",
"(",
"j",
"=",
"xoff",
";",
"j",
"<",
"mos6560",
"->",
"total_xsize",
";",
"j",
"++",
")",
"*",
"BITMAP_ADDR16",
"(",
"mos6560",
"->",
"bitmap",
",",
"yoff",
"+",
"i",
",",
"j",
")",
"=",
"mos6560",
"->",
"framecolor",
";",
"}",
"if",
"(",
"mos6560",
"->",
"matrix8x16",
")",
"{",
"vline",
"=",
"(",
"vline",
"+",
"16",
")",
"&",
"~",
"0xf",
";",
"line",
"=",
"vline",
"+",
"mos6560",
"->",
"ypos",
";",
"}",
"else",
"{",
"vline",
"=",
"(",
"vline",
"+",
"8",
")",
"&",
"~",
"7",
";",
"line",
"=",
"vline",
"+",
"mos6560",
"->",
"ypos",
";",
"}",
"}",
"for",
"(",
";",
"line",
"<",
"last",
";",
"line",
"++",
")",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"mos6560",
"->",
"total_xsize",
";",
"j",
"++",
")",
"*",
"BITMAP_ADDR16",
"(",
"mos6560",
"->",
"bitmap",
",",
"line",
",",
"j",
")",
"=",
"mos6560",
"->",
"framecolor",
";",
"}"
] | mos6560_drawlines - draw a certain numer of lines | [
"mos6560_drawlines",
"-",
"draw",
"a",
"certain",
"numer",
"of",
"lines"
] | [
"/* the mos6560 variant used in attckufo only has only one draw mode */"
] | [
{
"param": "device",
"type": "running_device"
},
{
"param": "first",
"type": "int"
},
{
"param": "last",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "device",
"type": "running_device",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "first",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "last",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a3fb952528ffa0b1a426b1ea471308311a631f41 | lofunz/mieme | Reloaded/trunk/src/emu/sound/mos6560.c | [
"Unlicense"
] | C | mos6560_video_update | UINT32 | UINT32 mos6560_video_update( running_device *device, bitmap_t *bitmap, const rectangle *cliprect )
{
mos6560_state *mos6560 = get_safe_token(device);
copybitmap(bitmap, mos6560->bitmap, 0, 0, 0, 0, cliprect);
return 0;
} | /*-------------------------------------------------
mos6560_video_update - copy the VIC bitmap to
main screen bitmap
-------------------------------------------------*/ | copy the VIC bitmap to
main screen bitmap | [
"copy",
"the",
"VIC",
"bitmap",
"to",
"main",
"screen",
"bitmap"
] | UINT32 mos6560_video_update( running_device *device, bitmap_t *bitmap, const rectangle *cliprect )
{
mos6560_state *mos6560 = get_safe_token(device);
copybitmap(bitmap, mos6560->bitmap, 0, 0, 0, 0, cliprect);
return 0;
} | [
"UINT32",
"mos6560_video_update",
"(",
"running_device",
"*",
"device",
",",
"bitmap_t",
"*",
"bitmap",
",",
"const",
"rectangle",
"*",
"cliprect",
")",
"{",
"mos6560_state",
"*",
"mos6560",
"=",
"get_safe_token",
"(",
"device",
")",
";",
"copybitmap",
"(",
"bitmap",
",",
"mos6560",
"->",
"bitmap",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"cliprect",
")",
";",
"return",
"0",
";",
"}"
] | mos6560_video_update - copy the VIC bitmap to
main screen bitmap | [
"mos6560_video_update",
"-",
"copy",
"the",
"VIC",
"bitmap",
"to",
"main",
"screen",
"bitmap"
] | [] | [
{
"param": "device",
"type": "running_device"
},
{
"param": "bitmap",
"type": "bitmap_t"
},
{
"param": "cliprect",
"type": "rectangle"
}
] | {
"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
}
],
"outlier_params": [],
"others": []
} |
a3fb952528ffa0b1a426b1ea471308311a631f41 | lofunz/mieme | Reloaded/trunk/src/emu/sound/mos6560.c | [
"Unlicense"
] | C | mos6560_sound_start | void | static void mos6560_sound_start( running_device *device )
{
mos6560_state *mos6560 = get_safe_token(device);
int i;
mos6560->channel = stream_create(device, 0, 1, device->machine->sample_rate, 0, mos6560_update);
/* buffer for fastest played sample for 5 second so we have enough data for min 5 second */
mos6560->noisesize = NOISE_FREQUENCY_MAX * NOISE_BUFFER_SIZE_SEC;
mos6560->noise = auto_alloc_array(device->machine, INT8, mos6560->noisesize);
{
int noiseshift = 0x7ffff8;
char data;
for (i = 0; i < mos6560->noisesize; i++)
{
data = 0;
if (noiseshift & 0x400000)
data |= 0x80;
if (noiseshift & 0x100000)
data |= 0x40;
if (noiseshift & 0x010000)
data |= 0x20;
if (noiseshift & 0x002000)
data |= 0x10;
if (noiseshift & 0x000800)
data |= 0x08;
if (noiseshift & 0x000080)
data |= 0x04;
if (noiseshift & 0x000010)
data |= 0x02;
if (noiseshift & 0x000004)
data |= 0x01;
mos6560->noise[i] = data;
if (((noiseshift & 0x400000) == 0) != ((noiseshift & 0x002000) == 0))
noiseshift = (noiseshift << 1) | 1;
else
noiseshift <<= 1;
}
}
mos6560->tonesize = device->machine->sample_rate / TONE_FREQUENCY_MIN;
if (mos6560->tonesize > 0)
{
mos6560->tone = auto_alloc_array(device->machine, INT16, mos6560->tonesize);
for (i = 0; i < mos6560->tonesize; i++)
{
mos6560->tone[i] = (INT16)(sin (2 * M_PI * i / mos6560->tonesize) * 127 + 0.5);
}
}
else
{
mos6560->tone = NULL;
}
} | /*-------------------------------------------------
mos6560_sound_start - start audio emulation
(to be called at device start)
-------------------------------------------------*/ | start audio emulation
(to be called at device start) | [
"start",
"audio",
"emulation",
"(",
"to",
"be",
"called",
"at",
"device",
"start",
")"
] | static void mos6560_sound_start( running_device *device )
{
mos6560_state *mos6560 = get_safe_token(device);
int i;
mos6560->channel = stream_create(device, 0, 1, device->machine->sample_rate, 0, mos6560_update);
mos6560->noisesize = NOISE_FREQUENCY_MAX * NOISE_BUFFER_SIZE_SEC;
mos6560->noise = auto_alloc_array(device->machine, INT8, mos6560->noisesize);
{
int noiseshift = 0x7ffff8;
char data;
for (i = 0; i < mos6560->noisesize; i++)
{
data = 0;
if (noiseshift & 0x400000)
data |= 0x80;
if (noiseshift & 0x100000)
data |= 0x40;
if (noiseshift & 0x010000)
data |= 0x20;
if (noiseshift & 0x002000)
data |= 0x10;
if (noiseshift & 0x000800)
data |= 0x08;
if (noiseshift & 0x000080)
data |= 0x04;
if (noiseshift & 0x000010)
data |= 0x02;
if (noiseshift & 0x000004)
data |= 0x01;
mos6560->noise[i] = data;
if (((noiseshift & 0x400000) == 0) != ((noiseshift & 0x002000) == 0))
noiseshift = (noiseshift << 1) | 1;
else
noiseshift <<= 1;
}
}
mos6560->tonesize = device->machine->sample_rate / TONE_FREQUENCY_MIN;
if (mos6560->tonesize > 0)
{
mos6560->tone = auto_alloc_array(device->machine, INT16, mos6560->tonesize);
for (i = 0; i < mos6560->tonesize; i++)
{
mos6560->tone[i] = (INT16)(sin (2 * M_PI * i / mos6560->tonesize) * 127 + 0.5);
}
}
else
{
mos6560->tone = NULL;
}
} | [
"static",
"void",
"mos6560_sound_start",
"(",
"running_device",
"*",
"device",
")",
"{",
"mos6560_state",
"*",
"mos6560",
"=",
"get_safe_token",
"(",
"device",
")",
";",
"int",
"i",
";",
"mos6560",
"->",
"channel",
"=",
"stream_create",
"(",
"device",
",",
"0",
",",
"1",
",",
"device",
"->",
"machine",
"->",
"sample_rate",
",",
"0",
",",
"mos6560_update",
")",
";",
"mos6560",
"->",
"noisesize",
"=",
"NOISE_FREQUENCY_MAX",
"*",
"NOISE_BUFFER_SIZE_SEC",
";",
"mos6560",
"->",
"noise",
"=",
"auto_alloc_array",
"(",
"device",
"->",
"machine",
",",
"INT8",
",",
"mos6560",
"->",
"noisesize",
")",
";",
"{",
"int",
"noiseshift",
"=",
"0x7ffff8",
";",
"char",
"data",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"mos6560",
"->",
"noisesize",
";",
"i",
"++",
")",
"{",
"data",
"=",
"0",
";",
"if",
"(",
"noiseshift",
"&",
"0x400000",
")",
"data",
"|=",
"0x80",
";",
"if",
"(",
"noiseshift",
"&",
"0x100000",
")",
"data",
"|=",
"0x40",
";",
"if",
"(",
"noiseshift",
"&",
"0x010000",
")",
"data",
"|=",
"0x20",
";",
"if",
"(",
"noiseshift",
"&",
"0x002000",
")",
"data",
"|=",
"0x10",
";",
"if",
"(",
"noiseshift",
"&",
"0x000800",
")",
"data",
"|=",
"0x08",
";",
"if",
"(",
"noiseshift",
"&",
"0x000080",
")",
"data",
"|=",
"0x04",
";",
"if",
"(",
"noiseshift",
"&",
"0x000010",
")",
"data",
"|=",
"0x02",
";",
"if",
"(",
"noiseshift",
"&",
"0x000004",
")",
"data",
"|=",
"0x01",
";",
"mos6560",
"->",
"noise",
"[",
"i",
"]",
"=",
"data",
";",
"if",
"(",
"(",
"(",
"noiseshift",
"&",
"0x400000",
")",
"==",
"0",
")",
"!=",
"(",
"(",
"noiseshift",
"&",
"0x002000",
")",
"==",
"0",
")",
")",
"noiseshift",
"=",
"(",
"noiseshift",
"<<",
"1",
")",
"|",
"1",
";",
"else",
"noiseshift",
"<<=",
"1",
";",
"}",
"}",
"mos6560",
"->",
"tonesize",
"=",
"device",
"->",
"machine",
"->",
"sample_rate",
"/",
"TONE_FREQUENCY_MIN",
";",
"if",
"(",
"mos6560",
"->",
"tonesize",
">",
"0",
")",
"{",
"mos6560",
"->",
"tone",
"=",
"auto_alloc_array",
"(",
"device",
"->",
"machine",
",",
"INT16",
",",
"mos6560",
"->",
"tonesize",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"mos6560",
"->",
"tonesize",
";",
"i",
"++",
")",
"{",
"mos6560",
"->",
"tone",
"[",
"i",
"]",
"=",
"(",
"INT16",
")",
"(",
"sin",
"(",
"2",
"*",
"M_PI",
"*",
"i",
"/",
"mos6560",
"->",
"tonesize",
")",
"*",
"127",
"+",
"0.5",
")",
";",
"}",
"}",
"else",
"{",
"mos6560",
"->",
"tone",
"=",
"NULL",
";",
"}",
"}"
] | mos6560_sound_start - start audio emulation
(to be called at device start) | [
"mos6560_sound_start",
"-",
"start",
"audio",
"emulation",
"(",
"to",
"be",
"called",
"at",
"device",
"start",
")"
] | [
"/* buffer for fastest played sample for 5 second so we have enough data for min 5 second */"
] | [
{
"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": []
} |
6bc278f7c04d8bb711021d60c335024d3fe28fcd | lofunz/mieme | Reloaded/tags/MAME4iOS 1.3.1Reloaded/src/mame/video/segaic16.c | [
"Unlicense"
] | C | segaic16_palette_init | void | void segaic16_palette_init(int entries)
{
static const int resistances_normal[6] = { 3900, 2000, 1000, 1000/2, 1000/4, 0 };
static const int resistances_sh[6] = { 3900, 2000, 1000, 1000/2, 1000/4, 470 };
double weights[2][6];
int i;
struct palette_info *info = &segaic16_palette;
/* compute the number of palette entries */
info->entries = entries;
/* compute weight table for regular palette entries */
compute_resistor_weights(0, 255, -1.0,
6, resistances_normal, weights[0], 0, 0,
0, NULL, NULL, 0, 0,
0, NULL, NULL, 0, 0);
/* compute weight table for shadow/hilight palette entries */
compute_resistor_weights(0, 255, -1.0,
6, resistances_sh, weights[1], 0, 0,
0, NULL, NULL, 0, 0,
0, NULL, NULL, 0, 0);
/* compute R, G, B for each weight */
for (i = 0; i < 32; i++)
{
int i4 = (i >> 4) & 1;
int i3 = (i >> 3) & 1;
int i2 = (i >> 2) & 1;
int i1 = (i >> 1) & 1;
int i0 = (i >> 0) & 1;
info->normal[i] = combine_6_weights(weights[0], i0, i1, i2, i3, i4, 0);
info->shadow[i] = combine_6_weights(weights[1], i0, i1, i2, i3, i4, 0);
info->hilight[i] = combine_6_weights(weights[1], i0, i1, i2, i3, i4, 1);
}
} | /*
Color generation details
Each color is made up of 5 bits, connected through one or more resistors like so:
Bit 0 = 1 x 3.9K ohm
Bit 1 = 1 x 2.0K ohm
Bit 2 = 1 x 1.0K ohm
Bit 3 = 2 x 1.0K ohm
Bit 4 = 4 x 1.0K ohm
Another data bit is connected by a tristate buffer to the color output through a
470 ohm resistor. The buffer allows the resistor to have no effect (tristate),
halve brightness (pull-down) or double brightness (pull-up). The data bit source
is bit 15 of each color RAM entry.
*/ | Color generation details
Each color is made up of 5 bits, connected through one or more resistors like so.
Another data bit is connected by a tristate buffer to the color output through a
470 ohm resistor. The buffer allows the resistor to have no effect (tristate),
halve brightness (pull-down) or double brightness (pull-up). The data bit source
is bit 15 of each color RAM entry. | [
"Color",
"generation",
"details",
"Each",
"color",
"is",
"made",
"up",
"of",
"5",
"bits",
"connected",
"through",
"one",
"or",
"more",
"resistors",
"like",
"so",
".",
"Another",
"data",
"bit",
"is",
"connected",
"by",
"a",
"tristate",
"buffer",
"to",
"the",
"color",
"output",
"through",
"a",
"470",
"ohm",
"resistor",
".",
"The",
"buffer",
"allows",
"the",
"resistor",
"to",
"have",
"no",
"effect",
"(",
"tristate",
")",
"halve",
"brightness",
"(",
"pull",
"-",
"down",
")",
"or",
"double",
"brightness",
"(",
"pull",
"-",
"up",
")",
".",
"The",
"data",
"bit",
"source",
"is",
"bit",
"15",
"of",
"each",
"color",
"RAM",
"entry",
"."
] | void segaic16_palette_init(int entries)
{
static const int resistances_normal[6] = { 3900, 2000, 1000, 1000/2, 1000/4, 0 };
static const int resistances_sh[6] = { 3900, 2000, 1000, 1000/2, 1000/4, 470 };
double weights[2][6];
int i;
struct palette_info *info = &segaic16_palette;
info->entries = entries;
compute_resistor_weights(0, 255, -1.0,
6, resistances_normal, weights[0], 0, 0,
0, NULL, NULL, 0, 0,
0, NULL, NULL, 0, 0);
compute_resistor_weights(0, 255, -1.0,
6, resistances_sh, weights[1], 0, 0,
0, NULL, NULL, 0, 0,
0, NULL, NULL, 0, 0);
for (i = 0; i < 32; i++)
{
int i4 = (i >> 4) & 1;
int i3 = (i >> 3) & 1;
int i2 = (i >> 2) & 1;
int i1 = (i >> 1) & 1;
int i0 = (i >> 0) & 1;
info->normal[i] = combine_6_weights(weights[0], i0, i1, i2, i3, i4, 0);
info->shadow[i] = combine_6_weights(weights[1], i0, i1, i2, i3, i4, 0);
info->hilight[i] = combine_6_weights(weights[1], i0, i1, i2, i3, i4, 1);
}
} | [
"void",
"segaic16_palette_init",
"(",
"int",
"entries",
")",
"{",
"static",
"const",
"int",
"resistances_normal",
"[",
"6",
"]",
"=",
"{",
"3900",
",",
"2000",
",",
"1000",
",",
"1000",
"/",
"2",
",",
"1000",
"/",
"4",
",",
"0",
"}",
";",
"static",
"const",
"int",
"resistances_sh",
"[",
"6",
"]",
"=",
"{",
"3900",
",",
"2000",
",",
"1000",
",",
"1000",
"/",
"2",
",",
"1000",
"/",
"4",
",",
"470",
"}",
";",
"double",
"weights",
"[",
"2",
"]",
"[",
"6",
"]",
";",
"int",
"i",
";",
"struct",
"palette_info",
"*",
"info",
"=",
"&",
"segaic16_palette",
";",
"info",
"->",
"entries",
"=",
"entries",
";",
"compute_resistor_weights",
"(",
"0",
",",
"255",
",",
"-1.0",
",",
"6",
",",
"resistances_normal",
",",
"weights",
"[",
"0",
"]",
",",
"0",
",",
"0",
",",
"0",
",",
"NULL",
",",
"NULL",
",",
"0",
",",
"0",
",",
"0",
",",
"NULL",
",",
"NULL",
",",
"0",
",",
"0",
")",
";",
"compute_resistor_weights",
"(",
"0",
",",
"255",
",",
"-1.0",
",",
"6",
",",
"resistances_sh",
",",
"weights",
"[",
"1",
"]",
",",
"0",
",",
"0",
",",
"0",
",",
"NULL",
",",
"NULL",
",",
"0",
",",
"0",
",",
"0",
",",
"NULL",
",",
"NULL",
",",
"0",
",",
"0",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"32",
";",
"i",
"++",
")",
"{",
"int",
"i4",
"=",
"(",
"i",
">>",
"4",
")",
"&",
"1",
";",
"int",
"i3",
"=",
"(",
"i",
">>",
"3",
")",
"&",
"1",
";",
"int",
"i2",
"=",
"(",
"i",
">>",
"2",
")",
"&",
"1",
";",
"int",
"i1",
"=",
"(",
"i",
">>",
"1",
")",
"&",
"1",
";",
"int",
"i0",
"=",
"(",
"i",
">>",
"0",
")",
"&",
"1",
";",
"info",
"->",
"normal",
"[",
"i",
"]",
"=",
"combine_6_weights",
"(",
"weights",
"[",
"0",
"]",
",",
"i0",
",",
"i1",
",",
"i2",
",",
"i3",
",",
"i4",
",",
"0",
")",
";",
"info",
"->",
"shadow",
"[",
"i",
"]",
"=",
"combine_6_weights",
"(",
"weights",
"[",
"1",
"]",
",",
"i0",
",",
"i1",
",",
"i2",
",",
"i3",
",",
"i4",
",",
"0",
")",
";",
"info",
"->",
"hilight",
"[",
"i",
"]",
"=",
"combine_6_weights",
"(",
"weights",
"[",
"1",
"]",
",",
"i0",
",",
"i1",
",",
"i2",
",",
"i3",
",",
"i4",
",",
"1",
")",
";",
"}",
"}"
] | Color generation details
Each color is made up of 5 bits, connected through one or more resistors like so: | [
"Color",
"generation",
"details",
"Each",
"color",
"is",
"made",
"up",
"of",
"5",
"bits",
"connected",
"through",
"one",
"or",
"more",
"resistors",
"like",
"so",
":"
] | [
"/* compute the number of palette entries */",
"/* compute weight table for regular palette entries */",
"/* compute weight table for shadow/hilight palette entries */",
"/* compute R, G, B for each weight */"
] | [
{
"param": "entries",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "entries",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6bc278f7c04d8bb711021d60c335024d3fe28fcd | lofunz/mieme | Reloaded/tags/MAME4iOS 1.3.1Reloaded/src/mame/video/segaic16.c | [
"Unlicense"
] | C | segaic16_road_hangon_decode | void | static void segaic16_road_hangon_decode(running_machine *machine, struct road_info *info)
{
int x, y;
const UINT8 *gfx = memory_region(machine, "gfx3");
int len = memory_region_length(machine, "gfx3");
/* allocate memory for the unpacked road data */
info->gfx = auto_alloc_array(machine, UINT8, 256 * 512);
/* loop over rows */
for (y = 0; y < 256; y++)
{
const UINT8 *src = gfx + ((y & 0xff) * 0x40) % len;
UINT8 *dst = info->gfx + y * 512;
/* loop over columns */
for (x = 0; x < 512; x++)
dst[x] = (((src[x/8] >> (~x & 7)) & 1) << 0) | (((src[x/8 + 0x4000] >> (~x & 7)) & 1) << 1);
}
} | /*******************************************************************************************
*
* Hang On/Space Harrier-style road chip
*
* Road RAM:
* Offset Bits Usage
* 000-1FF ----pp-- -------- road priority versus tilemaps and sprites
* ------s- -------- (Hang On only) Stripe coloring enable (1=enable)
* ------s- -------- (Space Harrier only) Solid color fill (1=solid, 0=from ROM)
* -------m -------- mirror enable (1=enable)
* -------- iiiiiiii index for other tables
* -------- rrrrrrrr road ROM line select
* 200-3FF ----hhhh hhhhhhhh horizontal scroll
* 400-5FF --bbbbbb -------- background color (colorset 0)
* -------- --bbbbbb background color (colorset 1)
* 600-7FF -------- s------- stripe color index (colorset 1)
* -------- -s------ stripe color index (colorset 0)
* -------- --a----- pixel value 2 color index (colorset 1)
* -------- ---a---- pixel value 2 color index (colorset 0)
* -------- ----b--- pixel value 1 color index (colorset 1)
* -------- -----b-- pixel value 1 color index (colorset 0)
* -------- ------c- pixel value 0 color index (colorset 1)
* -------- -------c pixel value 0 color index (colorset 0)
*
* Logic:
* First, the scanline is used to index into the table at 000-1FF
*
* The index is taken from the low 8 bits of the table value from 000-1FF
*
* The horizontal scroll value is looked up using the index in the table at
* 200-3FF
*
* The background color information is looked up using the index in the table at 400-5FF.
*
* The pixel color information is looked up using the index in the table at 600-7FF.
*
*******************************************************************************************/ | Hang On/Space Harrier-style road chip
First, the scanline is used to index into the table at 000-1FF
The index is taken from the low 8 bits of the table value from 000-1FF
The horizontal scroll value is looked up using the index in the table at
200-3FF
The background color information is looked up using the index in the table at 400-5FF.
The pixel color information is looked up using the index in the table at 600-7FF. | [
"Hang",
"On",
"/",
"Space",
"Harrier",
"-",
"style",
"road",
"chip",
"First",
"the",
"scanline",
"is",
"used",
"to",
"index",
"into",
"the",
"table",
"at",
"000",
"-",
"1FF",
"The",
"index",
"is",
"taken",
"from",
"the",
"low",
"8",
"bits",
"of",
"the",
"table",
"value",
"from",
"000",
"-",
"1FF",
"The",
"horizontal",
"scroll",
"value",
"is",
"looked",
"up",
"using",
"the",
"index",
"in",
"the",
"table",
"at",
"200",
"-",
"3FF",
"The",
"background",
"color",
"information",
"is",
"looked",
"up",
"using",
"the",
"index",
"in",
"the",
"table",
"at",
"400",
"-",
"5FF",
".",
"The",
"pixel",
"color",
"information",
"is",
"looked",
"up",
"using",
"the",
"index",
"in",
"the",
"table",
"at",
"600",
"-",
"7FF",
"."
] | static void segaic16_road_hangon_decode(running_machine *machine, struct road_info *info)
{
int x, y;
const UINT8 *gfx = memory_region(machine, "gfx3");
int len = memory_region_length(machine, "gfx3");
info->gfx = auto_alloc_array(machine, UINT8, 256 * 512);
for (y = 0; y < 256; y++)
{
const UINT8 *src = gfx + ((y & 0xff) * 0x40) % len;
UINT8 *dst = info->gfx + y * 512;
for (x = 0; x < 512; x++)
dst[x] = (((src[x/8] >> (~x & 7)) & 1) << 0) | (((src[x/8 + 0x4000] >> (~x & 7)) & 1) << 1);
}
} | [
"static",
"void",
"segaic16_road_hangon_decode",
"(",
"running_machine",
"*",
"machine",
",",
"struct",
"road_info",
"*",
"info",
")",
"{",
"int",
"x",
",",
"y",
";",
"const",
"UINT8",
"*",
"gfx",
"=",
"memory_region",
"(",
"machine",
",",
"\"",
"\"",
")",
";",
"int",
"len",
"=",
"memory_region_length",
"(",
"machine",
",",
"\"",
"\"",
")",
";",
"info",
"->",
"gfx",
"=",
"auto_alloc_array",
"(",
"machine",
",",
"UINT8",
",",
"256",
"*",
"512",
")",
";",
"for",
"(",
"y",
"=",
"0",
";",
"y",
"<",
"256",
";",
"y",
"++",
")",
"{",
"const",
"UINT8",
"*",
"src",
"=",
"gfx",
"+",
"(",
"(",
"y",
"&",
"0xff",
")",
"*",
"0x40",
")",
"%",
"len",
";",
"UINT8",
"*",
"dst",
"=",
"info",
"->",
"gfx",
"+",
"y",
"*",
"512",
";",
"for",
"(",
"x",
"=",
"0",
";",
"x",
"<",
"512",
";",
"x",
"++",
")",
"dst",
"[",
"x",
"]",
"=",
"(",
"(",
"(",
"src",
"[",
"x",
"/",
"8",
"]",
">>",
"(",
"~",
"x",
"&",
"7",
")",
")",
"&",
"1",
")",
"<<",
"0",
")",
"|",
"(",
"(",
"(",
"src",
"[",
"x",
"/",
"8",
"+",
"0x4000",
"]",
">>",
"(",
"~",
"x",
"&",
"7",
")",
")",
"&",
"1",
")",
"<<",
"1",
")",
";",
"}",
"}"
] | Hang On/Space Harrier-style road chip | [
"Hang",
"On",
"/",
"Space",
"Harrier",
"-",
"style",
"road",
"chip"
] | [
"/* allocate memory for the unpacked road data */",
"/* loop over rows */",
"/* loop over columns */"
] | [
{
"param": "machine",
"type": "running_machine"
},
{
"param": "info",
"type": "struct road_info"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "machine",
"type": "running_machine",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "info",
"type": "struct road_info",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6bc278f7c04d8bb711021d60c335024d3fe28fcd | lofunz/mieme | Reloaded/tags/MAME4iOS 1.3.1Reloaded/src/mame/video/segaic16.c | [
"Unlicense"
] | C | segaic16_road_outrun_decode | void | static void segaic16_road_outrun_decode(running_machine *machine, struct road_info *info)
{
int x, y;
const UINT8 *gfx = memory_region(machine, "gfx3");
int len = memory_region_length(machine, "gfx3");
/* allocate memory for the unpacked road data */
info->gfx = auto_alloc_array(machine, UINT8, (256 * 2 + 1) * 512);
/* loop over rows */
for (y = 0; y < 256 * 2; y++)
{
const UINT8 *src = gfx + ((y & 0xff) * 0x40 + (y >> 8) * 0x8000) % len;
UINT8 *dst = info->gfx + y * 512;
/* loop over columns */
for (x = 0; x < 512; x++)
{
dst[x] = (((src[x/8] >> (~x & 7)) & 1) << 0) | (((src[x/8 + 0x4000] >> (~x & 7)) & 1) << 1);
/* pre-mark road data in the "stripe" area with a high bit */
if (x >= 256-8 && x < 256 && dst[x] == 3)
dst[x] |= 4;
}
}
/* set up a dummy road in the last entry */
memset(info->gfx + 256 * 2 * 512, 3, 512);
} | /*******************************************************************************************
*
* Out Run/X-Board-style road chip
*
* Road control register:
* Bits Usage
* -------- -----d-- (X-board only) Direct scanline mode (1) or indirect mode (0)
* -------- ------pp Road enable/priorities:
* 0 = road 0 only visible
* 1 = both roads visible, road 0 has priority
* 2 = both roads visible, road 1 has priority
* 3 = road 1 only visible
*
* Road RAM:
* Offset Bits Usage
* 000-1FF ----s--- -------- Road 0: Solid fill (1) or ROM fill
* -------- -ccccccc Road 0: Solid color (if solid fill)
* -------i iiiiiiii Road 0: Index for other tables (if in indirect mode)
* -------r rrrrrrr- Road 0: Road ROM line select
* 200-3FF ----s--- -------- Road 1: Solid fill (1) or ROM fill
* -------- -ccccccc Road 1: Solid color (if solid fill)
* -------i iiiiiiii Road 1: Index for other tables (if in indirect mode)
* -------r rrrrrrr- Road 1: Road ROM line select
* 400-7FF ----hhhh hhhhhhhh Road 0: horizontal scroll
* 800-BFF ----hhhh hhhhhhhh Road 1: horizontal scroll
* C00-FFF ----bbbb -------- Background color index
* -------- s------- Road 1: stripe color index
* -------- -a------ Road 1: pixel value 2 color index
* -------- --b----- Road 1: pixel value 1 color index
* -------- ---c---- Road 1: pixel value 0 color index
* -------- ----s--- Road 0: stripe color index
* -------- -----a-- Road 0: pixel value 2 color index
* -------- ------b- Road 0: pixel value 1 color index
* -------- -------c Road 0: pixel value 0 color index
*
* Logic:
* First, the scanline is used to index into the tables at 000-1FF/200-3FF
* - if solid fill, the background is filled with the specified color index
* - otherwise, the remaining tables are used
*
* If indirect mode is selected, the index is taken from the low 9 bits of the
* table value from 000-1FF/200-3FF
* If direct scanline mode is selected, the index is set equal to the scanline
* for road 0, or the scanline + 256 for road 1
*
* The horizontal scroll value is looked up using the index in the tables at
* 400-7FF/800-BFF
*
* The color information is looked up using the index in the table at C00-FFF. Note
* that the same table is used for both roads.
*
*
* Out Run road priorities are controlled by a PAL that maps as indicated below.
* This was used to generate the priority_map. It is assumed that X-board is the
* same, though this logic is locked inside a Sega custom.
*
* RRC0 = CENTA & (RDA == 3) & !RRC2
* | CENTB & (RDB == 3) & RRC2
* | (RDA == 1) & !RRC2
* | (RDB == 1) & RRC2
*
* RRC1 = CENTA & (RDA == 3) & !RRC2
* | CENTB & (RDB == 3) & RRC2
* | (RDA == 2) & !RRC2
* | (RDB == 2) & RRC2
*
* RRC2 = !/HSYNC & IIQ
* | (CTRL == 3)
* | !CENTA & (RDA == 3) & !CENTB & (RDB == 3) & (CTRL == 2)
* | CENTB & (RDB == 3) & (CTRL == 2)
* | !CENTA & (RDA == 3) & !M2 & (CTRL == 2)
* | !CENTA & (RDA == 3) & !M3 & (CTRL == 2)
* | !M0 & (RDB == 0) & (CTRL == 2)
* | !M1 & (RDB == 0) & (CTRL == 2)
* | !CENTA & (RDA == 3) & CENTB & (RDB == 3) & (CTRL == 1)
* | !M0 & CENTB & (RDB == 3) & (CTRL == 1)
* | !M1 & CENTB & (RDB == 3) & (CTRL == 1)
* | !CENTA & M0 & (RDB == 0) & (CTRL == 1)
* | !CENTA & M1 & (RDB == 0) & (CTRL == 1)
* | !CENTA & (RDA == 3) & (RDB == 1) & (CTRL == 1)
* | !CENTA & (RDA == 3) & (RDB == 2) & (CTRL == 1)
*
* RRC3 = VA11 & VB11
* | VA11 & (CTRL == 0)
* | (CTRL == 3) & VB11
*
* RRC4 = !CENTA & (RDA == 3) & !CENTB & (RDB == 3)
* | VA11 & VB11
* | VA11 & (CTRL == 0)
* | (CTRL == 3) & VB11
* | !CENTB & (RDB == 3) & (CTRL == 3)
* | !CENTA & (RDA == 3) & (CTRL == 0)
*
*******************************************************************************************/ | Out Run/X-Board-style road chip
Road control register:
Bits Usage
d-- (X-board only) Direct scanline mode (1) or indirect mode (0)
pp Road enable/priorities:
0 = road 0 only visible
1 = both roads visible, road 0 has priority
2 = both roads visible, road 1 has priority
3 = road 1 only visible
First, the scanline is used to index into the tables at 000-1FF/200-3FF
- if solid fill, the background is filled with the specified color index
- otherwise, the remaining tables are used
If indirect mode is selected, the index is taken from the low 9 bits of the
table value from 000-1FF/200-3FF
If direct scanline mode is selected, the index is set equal to the scanline
for road 0, or the scanline + 256 for road 1
The horizontal scroll value is looked up using the index in the tables at
400-7FF/800-BFF
The color information is looked up using the index in the table at C00-FFF. Note
that the same table is used for both roads.
Out Run road priorities are controlled by a PAL that maps as indicated below.
This was used to generate the priority_map. It is assumed that X-board is the
same, though this logic is locked inside a Sega custom.
| [
"Out",
"Run",
"/",
"X",
"-",
"Board",
"-",
"style",
"road",
"chip",
"Road",
"control",
"register",
":",
"Bits",
"Usage",
"d",
"--",
"(",
"X",
"-",
"board",
"only",
")",
"Direct",
"scanline",
"mode",
"(",
"1",
")",
"or",
"indirect",
"mode",
"(",
"0",
")",
"pp",
"Road",
"enable",
"/",
"priorities",
":",
"0",
"=",
"road",
"0",
"only",
"visible",
"1",
"=",
"both",
"roads",
"visible",
"road",
"0",
"has",
"priority",
"2",
"=",
"both",
"roads",
"visible",
"road",
"1",
"has",
"priority",
"3",
"=",
"road",
"1",
"only",
"visible",
"First",
"the",
"scanline",
"is",
"used",
"to",
"index",
"into",
"the",
"tables",
"at",
"000",
"-",
"1FF",
"/",
"200",
"-",
"3FF",
"-",
"if",
"solid",
"fill",
"the",
"background",
"is",
"filled",
"with",
"the",
"specified",
"color",
"index",
"-",
"otherwise",
"the",
"remaining",
"tables",
"are",
"used",
"If",
"indirect",
"mode",
"is",
"selected",
"the",
"index",
"is",
"taken",
"from",
"the",
"low",
"9",
"bits",
"of",
"the",
"table",
"value",
"from",
"000",
"-",
"1FF",
"/",
"200",
"-",
"3FF",
"If",
"direct",
"scanline",
"mode",
"is",
"selected",
"the",
"index",
"is",
"set",
"equal",
"to",
"the",
"scanline",
"for",
"road",
"0",
"or",
"the",
"scanline",
"+",
"256",
"for",
"road",
"1",
"The",
"horizontal",
"scroll",
"value",
"is",
"looked",
"up",
"using",
"the",
"index",
"in",
"the",
"tables",
"at",
"400",
"-",
"7FF",
"/",
"800",
"-",
"BFF",
"The",
"color",
"information",
"is",
"looked",
"up",
"using",
"the",
"index",
"in",
"the",
"table",
"at",
"C00",
"-",
"FFF",
".",
"Note",
"that",
"the",
"same",
"table",
"is",
"used",
"for",
"both",
"roads",
".",
"Out",
"Run",
"road",
"priorities",
"are",
"controlled",
"by",
"a",
"PAL",
"that",
"maps",
"as",
"indicated",
"below",
".",
"This",
"was",
"used",
"to",
"generate",
"the",
"priority_map",
".",
"It",
"is",
"assumed",
"that",
"X",
"-",
"board",
"is",
"the",
"same",
"though",
"this",
"logic",
"is",
"locked",
"inside",
"a",
"Sega",
"custom",
"."
] | static void segaic16_road_outrun_decode(running_machine *machine, struct road_info *info)
{
int x, y;
const UINT8 *gfx = memory_region(machine, "gfx3");
int len = memory_region_length(machine, "gfx3");
info->gfx = auto_alloc_array(machine, UINT8, (256 * 2 + 1) * 512);
for (y = 0; y < 256 * 2; y++)
{
const UINT8 *src = gfx + ((y & 0xff) * 0x40 + (y >> 8) * 0x8000) % len;
UINT8 *dst = info->gfx + y * 512;
for (x = 0; x < 512; x++)
{
dst[x] = (((src[x/8] >> (~x & 7)) & 1) << 0) | (((src[x/8 + 0x4000] >> (~x & 7)) & 1) << 1);
if (x >= 256-8 && x < 256 && dst[x] == 3)
dst[x] |= 4;
}
}
memset(info->gfx + 256 * 2 * 512, 3, 512);
} | [
"static",
"void",
"segaic16_road_outrun_decode",
"(",
"running_machine",
"*",
"machine",
",",
"struct",
"road_info",
"*",
"info",
")",
"{",
"int",
"x",
",",
"y",
";",
"const",
"UINT8",
"*",
"gfx",
"=",
"memory_region",
"(",
"machine",
",",
"\"",
"\"",
")",
";",
"int",
"len",
"=",
"memory_region_length",
"(",
"machine",
",",
"\"",
"\"",
")",
";",
"info",
"->",
"gfx",
"=",
"auto_alloc_array",
"(",
"machine",
",",
"UINT8",
",",
"(",
"256",
"*",
"2",
"+",
"1",
")",
"*",
"512",
")",
";",
"for",
"(",
"y",
"=",
"0",
";",
"y",
"<",
"256",
"*",
"2",
";",
"y",
"++",
")",
"{",
"const",
"UINT8",
"*",
"src",
"=",
"gfx",
"+",
"(",
"(",
"y",
"&",
"0xff",
")",
"*",
"0x40",
"+",
"(",
"y",
">>",
"8",
")",
"*",
"0x8000",
")",
"%",
"len",
";",
"UINT8",
"*",
"dst",
"=",
"info",
"->",
"gfx",
"+",
"y",
"*",
"512",
";",
"for",
"(",
"x",
"=",
"0",
";",
"x",
"<",
"512",
";",
"x",
"++",
")",
"{",
"dst",
"[",
"x",
"]",
"=",
"(",
"(",
"(",
"src",
"[",
"x",
"/",
"8",
"]",
">>",
"(",
"~",
"x",
"&",
"7",
")",
")",
"&",
"1",
")",
"<<",
"0",
")",
"|",
"(",
"(",
"(",
"src",
"[",
"x",
"/",
"8",
"+",
"0x4000",
"]",
">>",
"(",
"~",
"x",
"&",
"7",
")",
")",
"&",
"1",
")",
"<<",
"1",
")",
";",
"if",
"(",
"x",
">=",
"256",
"-",
"8",
"&&",
"x",
"<",
"256",
"&&",
"dst",
"[",
"x",
"]",
"==",
"3",
")",
"dst",
"[",
"x",
"]",
"|=",
"4",
";",
"}",
"}",
"memset",
"(",
"info",
"->",
"gfx",
"+",
"256",
"*",
"2",
"*",
"512",
",",
"3",
",",
"512",
")",
";",
"}"
] | Out Run/X-Board-style road chip | [
"Out",
"Run",
"/",
"X",
"-",
"Board",
"-",
"style",
"road",
"chip"
] | [
"/* allocate memory for the unpacked road data */",
"/* loop over rows */",
"/* loop over columns */",
"/* pre-mark road data in the \"stripe\" area with a high bit */",
"/* set up a dummy road in the last entry */"
] | [
{
"param": "machine",
"type": "running_machine"
},
{
"param": "info",
"type": "struct road_info"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "machine",
"type": "running_machine",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "info",
"type": "struct road_info",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
908ba337e95781df892f5f60b9b28b6f64a544d5 | lofunz/mieme | Reloaded/trunk/src/emu/cpu/sh2/sh2drc.c | [
"Unlicense"
] | C | cfunc_printf_probe | void | static void cfunc_printf_probe(void *param)
{
sh2_state *sh2 = (sh2_state *)param;
UINT32 pc = sh2->pc;
printf(" PC=%08X r0=%08X r1=%08X r2=%08X\n",
pc,
(UINT32)sh2->r[0],
(UINT32)sh2->r[1],
(UINT32)sh2->r[2]);
printf(" r3=%08X r4=%08X r5=%08X r6=%08X\n",
(UINT32)sh2->r[3],
(UINT32)sh2->r[4],
(UINT32)sh2->r[5],
(UINT32)sh2->r[6]);
printf(" r7=%08X r8=%08X r9=%08X r10=%08X\n",
(UINT32)sh2->r[7],
(UINT32)sh2->r[8],
(UINT32)sh2->r[9],
(UINT32)sh2->r[10]);
printf(" r11=%08X r12=%08X r13=%08X r14=%08X\n",
(UINT32)sh2->r[11],
(UINT32)sh2->r[12],
(UINT32)sh2->r[13],
(UINT32)sh2->r[14]);
printf(" r15=%08X macl=%08X mach=%08X gbr=%08X\n",
(UINT32)sh2->r[15],
(UINT32)sh2->macl,
(UINT32)sh2->mach,
(UINT32)sh2->gbr);
printf(" evec %x irqsr %x pc=%08x\n",
(UINT32)sh2->evec,
(UINT32)sh2->irqsr, (UINT32)sh2->pc);
} | /*-------------------------------------------------
cfunc_printf_probe - print the current CPU
state and return
-------------------------------------------------*/ | print the current CPU
state and return | [
"print",
"the",
"current",
"CPU",
"state",
"and",
"return"
] | static void cfunc_printf_probe(void *param)
{
sh2_state *sh2 = (sh2_state *)param;
UINT32 pc = sh2->pc;
printf(" PC=%08X r0=%08X r1=%08X r2=%08X\n",
pc,
(UINT32)sh2->r[0],
(UINT32)sh2->r[1],
(UINT32)sh2->r[2]);
printf(" r3=%08X r4=%08X r5=%08X r6=%08X\n",
(UINT32)sh2->r[3],
(UINT32)sh2->r[4],
(UINT32)sh2->r[5],
(UINT32)sh2->r[6]);
printf(" r7=%08X r8=%08X r9=%08X r10=%08X\n",
(UINT32)sh2->r[7],
(UINT32)sh2->r[8],
(UINT32)sh2->r[9],
(UINT32)sh2->r[10]);
printf(" r11=%08X r12=%08X r13=%08X r14=%08X\n",
(UINT32)sh2->r[11],
(UINT32)sh2->r[12],
(UINT32)sh2->r[13],
(UINT32)sh2->r[14]);
printf(" r15=%08X macl=%08X mach=%08X gbr=%08X\n",
(UINT32)sh2->r[15],
(UINT32)sh2->macl,
(UINT32)sh2->mach,
(UINT32)sh2->gbr);
printf(" evec %x irqsr %x pc=%08x\n",
(UINT32)sh2->evec,
(UINT32)sh2->irqsr, (UINT32)sh2->pc);
} | [
"static",
"void",
"cfunc_printf_probe",
"(",
"void",
"*",
"param",
")",
"{",
"sh2_state",
"*",
"sh2",
"=",
"(",
"sh2_state",
"*",
")",
"param",
";",
"UINT32",
"pc",
"=",
"sh2",
"->",
"pc",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"pc",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"r",
"[",
"0",
"]",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"r",
"[",
"1",
"]",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"r",
"[",
"2",
"]",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"r",
"[",
"3",
"]",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"r",
"[",
"4",
"]",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"r",
"[",
"5",
"]",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"r",
"[",
"6",
"]",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"r",
"[",
"7",
"]",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"r",
"[",
"8",
"]",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"r",
"[",
"9",
"]",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"r",
"[",
"10",
"]",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"r",
"[",
"11",
"]",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"r",
"[",
"12",
"]",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"r",
"[",
"13",
"]",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"r",
"[",
"14",
"]",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"r",
"[",
"15",
"]",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"macl",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"mach",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"gbr",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"evec",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"irqsr",
",",
"(",
"UINT32",
")",
"sh2",
"->",
"pc",
")",
";",
"}"
] | cfunc_printf_probe - print the current CPU
state and return | [
"cfunc_printf_probe",
"-",
"print",
"the",
"current",
"CPU",
"state",
"and",
"return"
] | [] | [
{
"param": "param",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "param",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
908ba337e95781df892f5f60b9b28b6f64a544d5 | lofunz/mieme | Reloaded/trunk/src/emu/cpu/sh2/sh2drc.c | [
"Unlicense"
] | C | code_flush_cache | void | static void code_flush_cache(sh2_state *sh2)
{
drcuml_state *drcuml = sh2->drcuml;
/* empty the transient cache contents */
drcuml_reset(drcuml);
/* generate the entry point and out-of-cycles handlers */
static_generate_nocode_handler(sh2);
static_generate_out_of_cycles(sh2);
static_generate_entry_point(sh2);
/* add subroutines for memory accesses */
static_generate_memory_accessor(sh2, 1, FALSE, "read8", &sh2->read8);
static_generate_memory_accessor(sh2, 1, TRUE, "write8", &sh2->write8);
static_generate_memory_accessor(sh2, 2, FALSE, "read16", &sh2->read16);
static_generate_memory_accessor(sh2, 2, TRUE, "write16", &sh2->write16);
static_generate_memory_accessor(sh2, 4, FALSE, "read32", &sh2->read32);
static_generate_memory_accessor(sh2, 4, TRUE, "write32", &sh2->write32);
sh2->cache_dirty = FALSE;
} | /*-------------------------------------------------
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(sh2_state *sh2)
{
drcuml_state *drcuml = sh2->drcuml;
drcuml_reset(drcuml);
static_generate_nocode_handler(sh2);
static_generate_out_of_cycles(sh2);
static_generate_entry_point(sh2);
static_generate_memory_accessor(sh2, 1, FALSE, "read8", &sh2->read8);
static_generate_memory_accessor(sh2, 1, TRUE, "write8", &sh2->write8);
static_generate_memory_accessor(sh2, 2, FALSE, "read16", &sh2->read16);
static_generate_memory_accessor(sh2, 2, TRUE, "write16", &sh2->write16);
static_generate_memory_accessor(sh2, 4, FALSE, "read32", &sh2->read32);
static_generate_memory_accessor(sh2, 4, TRUE, "write32", &sh2->write32);
sh2->cache_dirty = FALSE;
} | [
"static",
"void",
"code_flush_cache",
"(",
"sh2_state",
"*",
"sh2",
")",
"{",
"drcuml_state",
"*",
"drcuml",
"=",
"sh2",
"->",
"drcuml",
";",
"drcuml_reset",
"(",
"drcuml",
")",
";",
"static_generate_nocode_handler",
"(",
"sh2",
")",
";",
"static_generate_out_of_cycles",
"(",
"sh2",
")",
";",
"static_generate_entry_point",
"(",
"sh2",
")",
";",
"static_generate_memory_accessor",
"(",
"sh2",
",",
"1",
",",
"FALSE",
",",
"\"",
"\"",
",",
"&",
"sh2",
"->",
"read8",
")",
";",
"static_generate_memory_accessor",
"(",
"sh2",
",",
"1",
",",
"TRUE",
",",
"\"",
"\"",
",",
"&",
"sh2",
"->",
"write8",
")",
";",
"static_generate_memory_accessor",
"(",
"sh2",
",",
"2",
",",
"FALSE",
",",
"\"",
"\"",
",",
"&",
"sh2",
"->",
"read16",
")",
";",
"static_generate_memory_accessor",
"(",
"sh2",
",",
"2",
",",
"TRUE",
",",
"\"",
"\"",
",",
"&",
"sh2",
"->",
"write16",
")",
";",
"static_generate_memory_accessor",
"(",
"sh2",
",",
"4",
",",
"FALSE",
",",
"\"",
"\"",
",",
"&",
"sh2",
"->",
"read32",
")",
";",
"static_generate_memory_accessor",
"(",
"sh2",
",",
"4",
",",
"TRUE",
",",
"\"",
"\"",
",",
"&",
"sh2",
"->",
"write32",
")",
";",
"sh2",
"->",
"cache_dirty",
"=",
"FALSE",
";",
"}"
] | 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": "sh2",
"type": "sh2_state"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sh2",
"type": "sh2_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
908ba337e95781df892f5f60b9b28b6f64a544d5 | lofunz/mieme | Reloaded/trunk/src/emu/cpu/sh2/sh2drc.c | [
"Unlicense"
] | C | code_compile_block | void | static void code_compile_block(sh2_state *sh2, UINT8 mode, offs_t pc)
{
drcuml_state *drcuml = sh2->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(sh2->drcfe, pc);
if (LOG_UML || LOG_NATIVE)
log_opcode_desc(drcuml, desclist, 0);
/* if we get an error back, flush the cache and try again */
if (setjmp(errorbuf) != 0)
code_flush_cache(sh2);
/* start the block */
block = drcuml_block_begin(drcuml, 4096, &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, mode, seqhead->pc))
UML_HASH(block, mode, 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, mode, 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 | 0x80000000
UML_HASHJMP(block, IMM(0), IMM(seqhead->pc), sh2->nocode);
// hashjmp <mode>,seqhead->pc,nocode
continue;
}
/* validate this code block if we're not pointing into ROM */
if (memory_get_write_ptr(sh2->program, seqhead->physpc) != NULL)
generate_checksum_block(sh2, 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 | 0x80000000
}
/* iterate over instructions in the sequence and compile them */
for (curdesc = seqhead; curdesc != seqlast->next; curdesc = curdesc->next)
{
generate_sequence_instruction(sh2, 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) * 2;
}
/* count off cycles and go there */
generate_update_cycles(sh2, block, &compiler, IMM(nextpc), TRUE); // <subtract cycles>
/* SH2 has no modes */
if (seqlast->next == NULL || seqlast->next->pc != nextpc)
{
UML_HASHJMP(block, IMM(0), IMM(nextpc), sh2->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(sh2_state *sh2, UINT8 mode, offs_t pc)
{
drcuml_state *drcuml = sh2->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(sh2->drcfe, pc);
if (LOG_UML || LOG_NATIVE)
log_opcode_desc(drcuml, desclist, 0);
if (setjmp(errorbuf) != 0)
code_flush_cache(sh2);
block = drcuml_block_begin(drcuml, 4096, &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, mode, seqhead->pc))
UML_HASH(block, mode, seqhead->pc);
else if (seqhead == desclist)
{
override = TRUE;
UML_HASH(block, mode, seqhead->pc);
}
else
{
UML_LABEL(block, seqhead->pc | 0x80000000);
UML_HASHJMP(block, IMM(0), IMM(seqhead->pc), sh2->nocode);
continue;
}
if (memory_get_write_ptr(sh2->program, seqhead->physpc) != NULL)
generate_checksum_block(sh2, 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(sh2, block, &compiler, curdesc);
}
if (seqlast->flags & OPFLAG_RETURN_TO_START)
{
nextpc = pc;
}
else
{
nextpc = seqlast->pc + (seqlast->skipslots + 1) * 2;
}
generate_update_cycles(sh2, block, &compiler, IMM(nextpc), TRUE);
if (seqlast->next == NULL || seqlast->next->pc != nextpc)
{
UML_HASHJMP(block, IMM(0), IMM(nextpc), sh2->nocode);
}
}
drcuml_block_end(block);
profiler_mark_end();
} | [
"static",
"void",
"code_compile_block",
"(",
"sh2_state",
"*",
"sh2",
",",
"UINT8",
"mode",
",",
"offs_t",
"pc",
")",
"{",
"drcuml_state",
"*",
"drcuml",
"=",
"sh2",
"->",
"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",
"(",
"sh2",
"->",
"drcfe",
",",
"pc",
")",
";",
"if",
"(",
"LOG_UML",
"||",
"LOG_NATIVE",
")",
"log_opcode_desc",
"(",
"drcuml",
",",
"desclist",
",",
"0",
")",
";",
"if",
"(",
"setjmp",
"(",
"errorbuf",
")",
"!=",
"0",
")",
"code_flush_cache",
"(",
"sh2",
")",
";",
"block",
"=",
"drcuml_block_begin",
"(",
"drcuml",
",",
"4096",
",",
"&",
"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",
",",
"mode",
",",
"seqhead",
"->",
"pc",
")",
")",
"UML_HASH",
"(",
"block",
",",
"mode",
",",
"seqhead",
"->",
"pc",
")",
";",
"else",
"if",
"(",
"seqhead",
"==",
"desclist",
")",
"{",
"override",
"=",
"TRUE",
";",
"UML_HASH",
"(",
"block",
",",
"mode",
",",
"seqhead",
"->",
"pc",
")",
";",
"}",
"else",
"{",
"UML_LABEL",
"(",
"block",
",",
"seqhead",
"->",
"pc",
"|",
"0x80000000",
")",
";",
"UML_HASHJMP",
"(",
"block",
",",
"IMM",
"(",
"0",
")",
",",
"IMM",
"(",
"seqhead",
"->",
"pc",
")",
",",
"sh2",
"->",
"nocode",
")",
";",
"continue",
";",
"}",
"if",
"(",
"memory_get_write_ptr",
"(",
"sh2",
"->",
"program",
",",
"seqhead",
"->",
"physpc",
")",
"!=",
"NULL",
")",
"generate_checksum_block",
"(",
"sh2",
",",
"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",
"(",
"sh2",
",",
"block",
",",
"&",
"compiler",
",",
"curdesc",
")",
";",
"}",
"if",
"(",
"seqlast",
"->",
"flags",
"&",
"OPFLAG_RETURN_TO_START",
")",
"{",
"nextpc",
"=",
"pc",
";",
"}",
"else",
"{",
"nextpc",
"=",
"seqlast",
"->",
"pc",
"+",
"(",
"seqlast",
"->",
"skipslots",
"+",
"1",
")",
"*",
"2",
";",
"}",
"generate_update_cycles",
"(",
"sh2",
",",
"block",
",",
"&",
"compiler",
",",
"IMM",
"(",
"nextpc",
")",
",",
"TRUE",
")",
";",
"if",
"(",
"seqlast",
"->",
"next",
"==",
"NULL",
"||",
"seqlast",
"->",
"next",
"->",
"pc",
"!=",
"nextpc",
")",
"{",
"UML_HASHJMP",
"(",
"block",
",",
"IMM",
"(",
"0",
")",
",",
"IMM",
"(",
"nextpc",
")",
",",
"sh2",
"->",
"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 | 0x80000000\r",
"// hashjmp <mode>,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 | 0x80000000\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",
"/* SH2 has no modes */",
"// hashjmp <mode>,nextpc,nocode\r",
"/* end the sequence */"
] | [
{
"param": "sh2",
"type": "sh2_state"
},
{
"param": "mode",
"type": "UINT8"
},
{
"param": "pc",
"type": "offs_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sh2",
"type": "sh2_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mode",
"type": "UINT8",
"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": []
} |
908ba337e95781df892f5f60b9b28b6f64a544d5 | lofunz/mieme | Reloaded/trunk/src/emu/cpu/sh2/sh2drc.c | [
"Unlicense"
] | C | static_generate_nocode_handler | void | static void static_generate_nocode_handler(sh2_state *sh2)
{
drcuml_state *drcuml = sh2->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, &sh2->nocode, "nocode");
UML_HANDLE(block, sh2->nocode); // handle nocode
UML_GETEXP(block, IREG(0)); // getexp i0
UML_MOV(block, MEM(&sh2->pc), IREG(0)); // mov [pc],i0
save_fast_iregs(sh2, 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(sh2_state *sh2)
{
drcuml_state *drcuml = sh2->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, &sh2->nocode, "nocode");
UML_HANDLE(block, sh2->nocode);
UML_GETEXP(block, IREG(0));
UML_MOV(block, MEM(&sh2->pc), IREG(0));
save_fast_iregs(sh2, block);
UML_EXIT(block, IMM(EXECUTE_MISSING_CODE));
drcuml_block_end(block);
} | [
"static",
"void",
"static_generate_nocode_handler",
"(",
"sh2_state",
"*",
"sh2",
")",
"{",
"drcuml_state",
"*",
"drcuml",
"=",
"sh2",
"->",
"drcuml",
";",
"drcuml_block",
"*",
"block",
";",
"jmp_buf",
"errorbuf",
";",
"if",
"(",
"setjmp",
"(",
"errorbuf",
")",
"!=",
"0",
")",
"fatalerror",
"(",
"\"",
"\"",
")",
";",
"block",
"=",
"drcuml_block_begin",
"(",
"drcuml",
",",
"10",
",",
"&",
"errorbuf",
")",
";",
"alloc_handle",
"(",
"drcuml",
",",
"&",
"sh2",
"->",
"nocode",
",",
"\"",
"\"",
")",
";",
"UML_HANDLE",
"(",
"block",
",",
"sh2",
"->",
"nocode",
")",
";",
"UML_GETEXP",
"(",
"block",
",",
"IREG",
"(",
"0",
")",
")",
";",
"UML_MOV",
"(",
"block",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"pc",
")",
",",
"IREG",
"(",
"0",
")",
")",
";",
"save_fast_iregs",
"(",
"sh2",
",",
"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": "sh2",
"type": "sh2_state"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sh2",
"type": "sh2_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
908ba337e95781df892f5f60b9b28b6f64a544d5 | lofunz/mieme | Reloaded/trunk/src/emu/cpu/sh2/sh2drc.c | [
"Unlicense"
] | C | static_generate_out_of_cycles | void | static void static_generate_out_of_cycles(sh2_state *sh2)
{
drcuml_state *drcuml = sh2->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, &sh2->out_of_cycles, "out_of_cycles");
UML_HANDLE(block, sh2->out_of_cycles); // handle out_of_cycles
UML_GETEXP(block, IREG(0)); // getexp i0
UML_MOV(block, MEM(&sh2->pc), IREG(0)); // mov <pc>,i0
save_fast_iregs(sh2,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(sh2_state *sh2)
{
drcuml_state *drcuml = sh2->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, &sh2->out_of_cycles, "out_of_cycles");
UML_HANDLE(block, sh2->out_of_cycles);
UML_GETEXP(block, IREG(0));
UML_MOV(block, MEM(&sh2->pc), IREG(0));
save_fast_iregs(sh2,block);
UML_EXIT(block, IMM(EXECUTE_OUT_OF_CYCLES));
drcuml_block_end(block);
} | [
"static",
"void",
"static_generate_out_of_cycles",
"(",
"sh2_state",
"*",
"sh2",
")",
"{",
"drcuml_state",
"*",
"drcuml",
"=",
"sh2",
"->",
"drcuml",
";",
"drcuml_block",
"*",
"block",
";",
"jmp_buf",
"errorbuf",
";",
"if",
"(",
"setjmp",
"(",
"errorbuf",
")",
"!=",
"0",
")",
"fatalerror",
"(",
"\"",
"\"",
")",
";",
"block",
"=",
"drcuml_block_begin",
"(",
"drcuml",
",",
"10",
",",
"&",
"errorbuf",
")",
";",
"alloc_handle",
"(",
"drcuml",
",",
"&",
"sh2",
"->",
"out_of_cycles",
",",
"\"",
"\"",
")",
";",
"UML_HANDLE",
"(",
"block",
",",
"sh2",
"->",
"out_of_cycles",
")",
";",
"UML_GETEXP",
"(",
"block",
",",
"IREG",
"(",
"0",
")",
")",
";",
"UML_MOV",
"(",
"block",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"pc",
")",
",",
"IREG",
"(",
"0",
")",
")",
";",
"save_fast_iregs",
"(",
"sh2",
",",
"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": "sh2",
"type": "sh2_state"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sh2",
"type": "sh2_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
908ba337e95781df892f5f60b9b28b6f64a544d5 | lofunz/mieme | Reloaded/trunk/src/emu/cpu/sh2/sh2drc.c | [
"Unlicense"
] | C | log_desc_flags_to_string | char | static const char *log_desc_flags_to_string(UINT32 flags)
{
static char tempbuf[30];
char *dest = tempbuf;
/* branches */
if (flags & OPFLAG_IS_UNCONDITIONAL_BRANCH)
*dest++ = 'U';
else if (flags & OPFLAG_IS_CONDITIONAL_BRANCH)
*dest++ = 'C';
else
*dest++ = '.';
/* intrablock branches */
*dest++ = (flags & OPFLAG_INTRABLOCK_BRANCH) ? 'i' : '.';
/* branch targets */
*dest++ = (flags & OPFLAG_IS_BRANCH_TARGET) ? 'B' : '.';
/* delay slots */
*dest++ = (flags & OPFLAG_IN_DELAY_SLOT) ? 'D' : '.';
/* exceptions */
if (flags & OPFLAG_WILL_CAUSE_EXCEPTION)
*dest++ = 'E';
else if (flags & OPFLAG_CAN_CAUSE_EXCEPTION)
*dest++ = 'e';
else
*dest++ = '.';
/* read/write */
if (flags & OPFLAG_READS_MEMORY)
*dest++ = 'R';
else if (flags & OPFLAG_WRITES_MEMORY)
*dest++ = 'W';
else
*dest++ = '.';
/* TLB validation */
*dest++ = (flags & OPFLAG_VALIDATE_TLB) ? 'V' : '.';
/* TLB modification */
*dest++ = (flags & OPFLAG_MODIFIES_TRANSLATION) ? 'T' : '.';
/* redispatch */
*dest++ = (flags & OPFLAG_REDISPATCH) ? 'R' : '.';
return tempbuf;
} | /*-------------------------------------------------
log_desc_flags_to_string - generate a string
representing the instruction description
flags
-------------------------------------------------*/ | generate a string
representing the instruction description
flags | [
"generate",
"a",
"string",
"representing",
"the",
"instruction",
"description",
"flags"
] | static const char *log_desc_flags_to_string(UINT32 flags)
{
static char tempbuf[30];
char *dest = tempbuf;
if (flags & OPFLAG_IS_UNCONDITIONAL_BRANCH)
*dest++ = 'U';
else if (flags & OPFLAG_IS_CONDITIONAL_BRANCH)
*dest++ = 'C';
else
*dest++ = '.';
*dest++ = (flags & OPFLAG_INTRABLOCK_BRANCH) ? 'i' : '.';
*dest++ = (flags & OPFLAG_IS_BRANCH_TARGET) ? 'B' : '.';
*dest++ = (flags & OPFLAG_IN_DELAY_SLOT) ? 'D' : '.';
if (flags & OPFLAG_WILL_CAUSE_EXCEPTION)
*dest++ = 'E';
else if (flags & OPFLAG_CAN_CAUSE_EXCEPTION)
*dest++ = 'e';
else
*dest++ = '.';
if (flags & OPFLAG_READS_MEMORY)
*dest++ = 'R';
else if (flags & OPFLAG_WRITES_MEMORY)
*dest++ = 'W';
else
*dest++ = '.';
*dest++ = (flags & OPFLAG_VALIDATE_TLB) ? 'V' : '.';
*dest++ = (flags & OPFLAG_MODIFIES_TRANSLATION) ? 'T' : '.';
*dest++ = (flags & OPFLAG_REDISPATCH) ? 'R' : '.';
return tempbuf;
} | [
"static",
"const",
"char",
"*",
"log_desc_flags_to_string",
"(",
"UINT32",
"flags",
")",
"{",
"static",
"char",
"tempbuf",
"[",
"30",
"]",
";",
"char",
"*",
"dest",
"=",
"tempbuf",
";",
"if",
"(",
"flags",
"&",
"OPFLAG_IS_UNCONDITIONAL_BRANCH",
")",
"*",
"dest",
"++",
"=",
"'",
"'",
";",
"else",
"if",
"(",
"flags",
"&",
"OPFLAG_IS_CONDITIONAL_BRANCH",
")",
"*",
"dest",
"++",
"=",
"'",
"'",
";",
"else",
"*",
"dest",
"++",
"=",
"'",
"'",
";",
"*",
"dest",
"++",
"=",
"(",
"flags",
"&",
"OPFLAG_INTRABLOCK_BRANCH",
")",
"?",
"'",
"'",
":",
"'",
"'",
";",
"*",
"dest",
"++",
"=",
"(",
"flags",
"&",
"OPFLAG_IS_BRANCH_TARGET",
")",
"?",
"'",
"'",
":",
"'",
"'",
";",
"*",
"dest",
"++",
"=",
"(",
"flags",
"&",
"OPFLAG_IN_DELAY_SLOT",
")",
"?",
"'",
"'",
":",
"'",
"'",
";",
"if",
"(",
"flags",
"&",
"OPFLAG_WILL_CAUSE_EXCEPTION",
")",
"*",
"dest",
"++",
"=",
"'",
"'",
";",
"else",
"if",
"(",
"flags",
"&",
"OPFLAG_CAN_CAUSE_EXCEPTION",
")",
"*",
"dest",
"++",
"=",
"'",
"'",
";",
"else",
"*",
"dest",
"++",
"=",
"'",
"'",
";",
"if",
"(",
"flags",
"&",
"OPFLAG_READS_MEMORY",
")",
"*",
"dest",
"++",
"=",
"'",
"'",
";",
"else",
"if",
"(",
"flags",
"&",
"OPFLAG_WRITES_MEMORY",
")",
"*",
"dest",
"++",
"=",
"'",
"'",
";",
"else",
"*",
"dest",
"++",
"=",
"'",
"'",
";",
"*",
"dest",
"++",
"=",
"(",
"flags",
"&",
"OPFLAG_VALIDATE_TLB",
")",
"?",
"'",
"'",
":",
"'",
"'",
";",
"*",
"dest",
"++",
"=",
"(",
"flags",
"&",
"OPFLAG_MODIFIES_TRANSLATION",
")",
"?",
"'",
"'",
":",
"'",
"'",
";",
"*",
"dest",
"++",
"=",
"(",
"flags",
"&",
"OPFLAG_REDISPATCH",
")",
"?",
"'",
"'",
":",
"'",
"'",
";",
"return",
"tempbuf",
";",
"}"
] | log_desc_flags_to_string - generate a string
representing the instruction description
flags | [
"log_desc_flags_to_string",
"-",
"generate",
"a",
"string",
"representing",
"the",
"instruction",
"description",
"flags"
] | [
"/* branches */",
"/* intrablock branches */",
"/* branch targets */",
"/* delay slots */",
"/* exceptions */",
"/* read/write */",
"/* TLB validation */",
"/* TLB modification */",
"/* redispatch */"
] | [
{
"param": "flags",
"type": "UINT32"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "flags",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
908ba337e95781df892f5f60b9b28b6f64a544d5 | lofunz/mieme | Reloaded/trunk/src/emu/cpu/sh2/sh2drc.c | [
"Unlicense"
] | C | log_register_list | void | static void log_register_list(drcuml_state *drcuml, const char *string, const UINT32 *reglist, const UINT32 *regnostarlist)
{
int count = 0;
int regnum;
/* skip if nothing */
if (reglist[0] == 0 && reglist[1] == 0 && reglist[2] == 0)
return;
drcuml_log_printf(drcuml, "[%s:", string);
for (regnum = 0; regnum < 16; regnum++)
{
if (reglist[0] & REGFLAG_R(regnum))
{
drcuml_log_printf(drcuml, "%sr%d", (count++ == 0) ? "" : ",", regnum);
if (regnostarlist != NULL && !(regnostarlist[0] & REGFLAG_R(regnum)))
drcuml_log_printf(drcuml, "*");
}
}
if (reglist[1] & REGFLAG_PR)
{
drcuml_log_printf(drcuml, "%spr", (count++ == 0) ? "" : ",");
if (regnostarlist != NULL && !(regnostarlist[1] & REGFLAG_PR))
drcuml_log_printf(drcuml, "*");
}
if (reglist[1] & REGFLAG_SR)
{
drcuml_log_printf(drcuml, "%ssr", (count++ == 0) ? "" : ",");
if (regnostarlist != NULL && !(regnostarlist[1] & REGFLAG_SR))
drcuml_log_printf(drcuml, "*");
}
if (reglist[1] & REGFLAG_MACL)
{
drcuml_log_printf(drcuml, "%smacl", (count++ == 0) ? "" : ",");
if (regnostarlist != NULL && !(regnostarlist[1] & REGFLAG_MACL))
drcuml_log_printf(drcuml, "*");
}
if (reglist[1] & REGFLAG_MACH)
{
drcuml_log_printf(drcuml, "%smach", (count++ == 0) ? "" : ",");
if (regnostarlist != NULL && !(regnostarlist[1] & REGFLAG_MACH))
drcuml_log_printf(drcuml, "*");
}
if (reglist[1] & REGFLAG_GBR)
{
drcuml_log_printf(drcuml, "%sgbr", (count++ == 0) ? "" : ",");
if (regnostarlist != NULL && !(regnostarlist[1] & REGFLAG_GBR))
drcuml_log_printf(drcuml, "*");
}
if (reglist[1] & REGFLAG_VBR)
{
drcuml_log_printf(drcuml, "%svbr", (count++ == 0) ? "" : ",");
if (regnostarlist != NULL && !(regnostarlist[1] & REGFLAG_VBR))
drcuml_log_printf(drcuml, "*");
}
drcuml_log_printf(drcuml, "] ");
} | /*-------------------------------------------------
log_register_list - log a list of GPR registers
-------------------------------------------------*/ | log a list of GPR registers | [
"log",
"a",
"list",
"of",
"GPR",
"registers"
] | static void log_register_list(drcuml_state *drcuml, const char *string, const UINT32 *reglist, const UINT32 *regnostarlist)
{
int count = 0;
int regnum;
if (reglist[0] == 0 && reglist[1] == 0 && reglist[2] == 0)
return;
drcuml_log_printf(drcuml, "[%s:", string);
for (regnum = 0; regnum < 16; regnum++)
{
if (reglist[0] & REGFLAG_R(regnum))
{
drcuml_log_printf(drcuml, "%sr%d", (count++ == 0) ? "" : ",", regnum);
if (regnostarlist != NULL && !(regnostarlist[0] & REGFLAG_R(regnum)))
drcuml_log_printf(drcuml, "*");
}
}
if (reglist[1] & REGFLAG_PR)
{
drcuml_log_printf(drcuml, "%spr", (count++ == 0) ? "" : ",");
if (regnostarlist != NULL && !(regnostarlist[1] & REGFLAG_PR))
drcuml_log_printf(drcuml, "*");
}
if (reglist[1] & REGFLAG_SR)
{
drcuml_log_printf(drcuml, "%ssr", (count++ == 0) ? "" : ",");
if (regnostarlist != NULL && !(regnostarlist[1] & REGFLAG_SR))
drcuml_log_printf(drcuml, "*");
}
if (reglist[1] & REGFLAG_MACL)
{
drcuml_log_printf(drcuml, "%smacl", (count++ == 0) ? "" : ",");
if (regnostarlist != NULL && !(regnostarlist[1] & REGFLAG_MACL))
drcuml_log_printf(drcuml, "*");
}
if (reglist[1] & REGFLAG_MACH)
{
drcuml_log_printf(drcuml, "%smach", (count++ == 0) ? "" : ",");
if (regnostarlist != NULL && !(regnostarlist[1] & REGFLAG_MACH))
drcuml_log_printf(drcuml, "*");
}
if (reglist[1] & REGFLAG_GBR)
{
drcuml_log_printf(drcuml, "%sgbr", (count++ == 0) ? "" : ",");
if (regnostarlist != NULL && !(regnostarlist[1] & REGFLAG_GBR))
drcuml_log_printf(drcuml, "*");
}
if (reglist[1] & REGFLAG_VBR)
{
drcuml_log_printf(drcuml, "%svbr", (count++ == 0) ? "" : ",");
if (regnostarlist != NULL && !(regnostarlist[1] & REGFLAG_VBR))
drcuml_log_printf(drcuml, "*");
}
drcuml_log_printf(drcuml, "] ");
} | [
"static",
"void",
"log_register_list",
"(",
"drcuml_state",
"*",
"drcuml",
",",
"const",
"char",
"*",
"string",
",",
"const",
"UINT32",
"*",
"reglist",
",",
"const",
"UINT32",
"*",
"regnostarlist",
")",
"{",
"int",
"count",
"=",
"0",
";",
"int",
"regnum",
";",
"if",
"(",
"reglist",
"[",
"0",
"]",
"==",
"0",
"&&",
"reglist",
"[",
"1",
"]",
"==",
"0",
"&&",
"reglist",
"[",
"2",
"]",
"==",
"0",
")",
"return",
";",
"drcuml_log_printf",
"(",
"drcuml",
",",
"\"",
"\"",
",",
"string",
")",
";",
"for",
"(",
"regnum",
"=",
"0",
";",
"regnum",
"<",
"16",
";",
"regnum",
"++",
")",
"{",
"if",
"(",
"reglist",
"[",
"0",
"]",
"&",
"REGFLAG_R",
"(",
"regnum",
")",
")",
"{",
"drcuml_log_printf",
"(",
"drcuml",
",",
"\"",
"\"",
",",
"(",
"count",
"++",
"==",
"0",
")",
"?",
"\"",
"\"",
":",
"\"",
"\"",
",",
"regnum",
")",
";",
"if",
"(",
"regnostarlist",
"!=",
"NULL",
"&&",
"!",
"(",
"regnostarlist",
"[",
"0",
"]",
"&",
"REGFLAG_R",
"(",
"regnum",
")",
")",
")",
"drcuml_log_printf",
"(",
"drcuml",
",",
"\"",
"\"",
")",
";",
"}",
"}",
"if",
"(",
"reglist",
"[",
"1",
"]",
"&",
"REGFLAG_PR",
")",
"{",
"drcuml_log_printf",
"(",
"drcuml",
",",
"\"",
"\"",
",",
"(",
"count",
"++",
"==",
"0",
")",
"?",
"\"",
"\"",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"regnostarlist",
"!=",
"NULL",
"&&",
"!",
"(",
"regnostarlist",
"[",
"1",
"]",
"&",
"REGFLAG_PR",
")",
")",
"drcuml_log_printf",
"(",
"drcuml",
",",
"\"",
"\"",
")",
";",
"}",
"if",
"(",
"reglist",
"[",
"1",
"]",
"&",
"REGFLAG_SR",
")",
"{",
"drcuml_log_printf",
"(",
"drcuml",
",",
"\"",
"\"",
",",
"(",
"count",
"++",
"==",
"0",
")",
"?",
"\"",
"\"",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"regnostarlist",
"!=",
"NULL",
"&&",
"!",
"(",
"regnostarlist",
"[",
"1",
"]",
"&",
"REGFLAG_SR",
")",
")",
"drcuml_log_printf",
"(",
"drcuml",
",",
"\"",
"\"",
")",
";",
"}",
"if",
"(",
"reglist",
"[",
"1",
"]",
"&",
"REGFLAG_MACL",
")",
"{",
"drcuml_log_printf",
"(",
"drcuml",
",",
"\"",
"\"",
",",
"(",
"count",
"++",
"==",
"0",
")",
"?",
"\"",
"\"",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"regnostarlist",
"!=",
"NULL",
"&&",
"!",
"(",
"regnostarlist",
"[",
"1",
"]",
"&",
"REGFLAG_MACL",
")",
")",
"drcuml_log_printf",
"(",
"drcuml",
",",
"\"",
"\"",
")",
";",
"}",
"if",
"(",
"reglist",
"[",
"1",
"]",
"&",
"REGFLAG_MACH",
")",
"{",
"drcuml_log_printf",
"(",
"drcuml",
",",
"\"",
"\"",
",",
"(",
"count",
"++",
"==",
"0",
")",
"?",
"\"",
"\"",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"regnostarlist",
"!=",
"NULL",
"&&",
"!",
"(",
"regnostarlist",
"[",
"1",
"]",
"&",
"REGFLAG_MACH",
")",
")",
"drcuml_log_printf",
"(",
"drcuml",
",",
"\"",
"\"",
")",
";",
"}",
"if",
"(",
"reglist",
"[",
"1",
"]",
"&",
"REGFLAG_GBR",
")",
"{",
"drcuml_log_printf",
"(",
"drcuml",
",",
"\"",
"\"",
",",
"(",
"count",
"++",
"==",
"0",
")",
"?",
"\"",
"\"",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"regnostarlist",
"!=",
"NULL",
"&&",
"!",
"(",
"regnostarlist",
"[",
"1",
"]",
"&",
"REGFLAG_GBR",
")",
")",
"drcuml_log_printf",
"(",
"drcuml",
",",
"\"",
"\"",
")",
";",
"}",
"if",
"(",
"reglist",
"[",
"1",
"]",
"&",
"REGFLAG_VBR",
")",
"{",
"drcuml_log_printf",
"(",
"drcuml",
",",
"\"",
"\"",
",",
"(",
"count",
"++",
"==",
"0",
")",
"?",
"\"",
"\"",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"regnostarlist",
"!=",
"NULL",
"&&",
"!",
"(",
"regnostarlist",
"[",
"1",
"]",
"&",
"REGFLAG_VBR",
")",
")",
"drcuml_log_printf",
"(",
"drcuml",
",",
"\"",
"\"",
")",
";",
"}",
"drcuml_log_printf",
"(",
"drcuml",
",",
"\"",
"\"",
")",
";",
"}"
] | log_register_list - log a list of GPR registers | [
"log_register_list",
"-",
"log",
"a",
"list",
"of",
"GPR",
"registers"
] | [
"/* skip if nothing */"
] | [
{
"param": "drcuml",
"type": "drcuml_state"
},
{
"param": "string",
"type": "char"
},
{
"param": "reglist",
"type": "UINT32"
},
{
"param": "regnostarlist",
"type": "UINT32"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "drcuml",
"type": "drcuml_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "string",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reglist",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "regnostarlist",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
908ba337e95781df892f5f60b9b28b6f64a544d5 | lofunz/mieme | Reloaded/trunk/src/emu/cpu/sh2/sh2drc.c | [
"Unlicense"
] | C | log_add_disasm_comment | void | static void log_add_disasm_comment(drcuml_block *block, UINT32 pc, UINT32 op)
{
#if (LOG_UML)
char buffer[100];
DasmSH2(buffer, pc, op);
UML_COMMENT(block, "%08X: %s", pc, buffer); // comment
#endif
} | /*-------------------------------------------------
log_add_disasm_comment - add a comment
including disassembly of a MIPS instruction
-------------------------------------------------*/ | add a comment
including disassembly of a MIPS instruction | [
"add",
"a",
"comment",
"including",
"disassembly",
"of",
"a",
"MIPS",
"instruction"
] | static void log_add_disasm_comment(drcuml_block *block, UINT32 pc, UINT32 op)
{
#if (LOG_UML)
char buffer[100];
DasmSH2(buffer, pc, op);
UML_COMMENT(block, "%08X: %s", pc, buffer);
#endif
} | [
"static",
"void",
"log_add_disasm_comment",
"(",
"drcuml_block",
"*",
"block",
",",
"UINT32",
"pc",
",",
"UINT32",
"op",
")",
"{",
"#if",
"(",
"LOG_UML",
")",
"\n",
"char",
"buffer",
"[",
"100",
"]",
";",
"DasmSH2",
"(",
"buffer",
",",
"pc",
",",
"op",
")",
";",
"UML_COMMENT",
"(",
"block",
",",
"\"",
"\"",
",",
"pc",
",",
"buffer",
")",
";",
"#endif",
"}"
] | log_add_disasm_comment - add a comment
including disassembly of a MIPS instruction | [
"log_add_disasm_comment",
"-",
"add",
"a",
"comment",
"including",
"disassembly",
"of",
"a",
"MIPS",
"instruction"
] | [
"// comment\r"
] | [
{
"param": "block",
"type": "drcuml_block"
},
{
"param": "pc",
"type": "UINT32"
},
{
"param": "op",
"type": "UINT32"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"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": []
} |
908ba337e95781df892f5f60b9b28b6f64a544d5 | lofunz/mieme | Reloaded/trunk/src/emu/cpu/sh2/sh2drc.c | [
"Unlicense"
] | C | generate_update_cycles | void | static void generate_update_cycles(sh2_state *sh2, drcuml_block *block, compiler_state *compiler, drcuml_ptype ptype, UINT64 pvalue, int allow_exception)
{
/* check full interrupts if pending */
if (compiler->checkints)
{
drcuml_codelabel skip = compiler->labelnum++;
compiler->checkints = FALSE;
compiler->labelnum += 4;
/* check for interrupts */
UML_MOV(block, MEM(&sh2->irqline), IMM(0xffffffff)); // mov irqline, #-1
UML_CMP(block, MEM(&sh2->pending_nmi), IMM(0)); // cmp pending_nmi, #0
UML_JMPc(block, IF_Z, skip+2); // jz skip+2
UML_MOV(block, MEM(&sh2->pending_nmi), IMM(0)); // zap pending_nmi
UML_JMP(block, skip+1); // and then go take it (evec is already set)
UML_LABEL(block, skip+2); // skip+2:
UML_MOV(block, MEM(&sh2->evec), IMM(0xffffffff)); // mov evec, -1
UML_MOV(block, IREG(0), IMM(0xffffffff)); // mov r0, -1 (r0 = irq)
UML_AND(block, IREG(1), IREG(0), IMM(0xffff)); // and r1, r0, 0xffff
UML_LZCNT(block, IREG(1), MEM(&sh2->pending_irq)); // lzcnt r1, pending_irq
UML_CMP(block, IREG(1), IMM(32)); // cmp r1, #32
UML_JMPc(block, IF_Z, skip+4); // jz skip+4
UML_SUB(block, MEM(&sh2->irqline), IMM(31), IREG(1)); // sub irqline, #31, r1
UML_LABEL(block, skip+4); // skip+4:
UML_CMP(block, MEM(&sh2->internal_irq_level), IMM(0xffffffff)); // cmp internal_irq_level, #-1
UML_JMPc(block, IF_Z, skip+3); // jz skip+3
UML_CMP(block, MEM(&sh2->internal_irq_level), MEM(&sh2->irqline)); // cmp internal_irq_level, irqline
UML_JMPc(block, IF_LE, skip+3); // jle skip+3
UML_MOV(block, MEM(&sh2->irqline), MEM(&sh2->internal_irq_level)); // mov r0, internal_irq_level
UML_LABEL(block, skip+3); // skip+3:
UML_CMP(block, MEM(&sh2->irqline), IMM(0xffffffff)); // cmp irqline, #-1
UML_JMPc(block, IF_Z, skip+1); // jz skip+1
UML_CALLC(block, cfunc_fastirq, sh2); // callc fastirq
UML_LABEL(block, skip+1); // skip+1:
UML_CMP(block, MEM(&sh2->evec), IMM(0xffffffff)); // cmp evec, 0xffffffff
UML_JMPc(block, IF_Z, skip); // jz skip
UML_SUB(block, R32(15), R32(15), IMM(4)); // sub R15, R15, #4
UML_MOV(block, IREG(0), R32(15)); // mov r0, R15
UML_MOV(block, IREG(1), MEM(&sh2->irqsr)); // mov r1, irqsr
UML_CALLH(block, sh2->write32); // call write32
UML_SUB(block, R32(15), R32(15), IMM(4)); // sub R15, R15, #4
UML_MOV(block, IREG(0), R32(15)); // mov r0, R15
UML_MOV(block, IREG(1), PARAM(ptype, pvalue)); // mov r1, nextpc
UML_CALLH(block, sh2->write32); // call write32
UML_HASHJMP(block, IMM(0), MEM(&sh2->evec), sh2->nocode); // hashjmp sh2->evec
UML_LABEL(block, skip); // skip:
}
/* account for cycles */
if (compiler->cycles > 0)
{
UML_SUB(block, MEM(&sh2->icount), MEM(&sh2->icount), MAPVAR_CYCLES); // sub icount,icount,cycles
UML_MAPVAR(block, MAPVAR_CYCLES, 0); // mapvar cycles,0
if (allow_exception)
UML_EXHc(block, IF_S, sh2->out_of_cycles, PARAM(ptype, pvalue));
// exh out_of_cycles,nextpc
}
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(sh2_state *sh2, drcuml_block *block, compiler_state *compiler, drcuml_ptype ptype, UINT64 pvalue, int allow_exception)
{
if (compiler->checkints)
{
drcuml_codelabel skip = compiler->labelnum++;
compiler->checkints = FALSE;
compiler->labelnum += 4;
UML_MOV(block, MEM(&sh2->irqline), IMM(0xffffffff));
UML_CMP(block, MEM(&sh2->pending_nmi), IMM(0));
UML_JMPc(block, IF_Z, skip+2);
UML_MOV(block, MEM(&sh2->pending_nmi), IMM(0));
UML_JMP(block, skip+1);
UML_LABEL(block, skip+2);
UML_MOV(block, MEM(&sh2->evec), IMM(0xffffffff));
UML_MOV(block, IREG(0), IMM(0xffffffff));
UML_AND(block, IREG(1), IREG(0), IMM(0xffff));
UML_LZCNT(block, IREG(1), MEM(&sh2->pending_irq));
UML_CMP(block, IREG(1), IMM(32));
UML_JMPc(block, IF_Z, skip+4);
UML_SUB(block, MEM(&sh2->irqline), IMM(31), IREG(1));
UML_LABEL(block, skip+4);
UML_CMP(block, MEM(&sh2->internal_irq_level), IMM(0xffffffff));
UML_JMPc(block, IF_Z, skip+3);
UML_CMP(block, MEM(&sh2->internal_irq_level), MEM(&sh2->irqline));
UML_JMPc(block, IF_LE, skip+3);
UML_MOV(block, MEM(&sh2->irqline), MEM(&sh2->internal_irq_level));
UML_LABEL(block, skip+3);
UML_CMP(block, MEM(&sh2->irqline), IMM(0xffffffff));
UML_JMPc(block, IF_Z, skip+1);
UML_CALLC(block, cfunc_fastirq, sh2);
UML_LABEL(block, skip+1);
UML_CMP(block, MEM(&sh2->evec), IMM(0xffffffff));
UML_JMPc(block, IF_Z, skip);
UML_SUB(block, R32(15), R32(15), IMM(4));
UML_MOV(block, IREG(0), R32(15));
UML_MOV(block, IREG(1), MEM(&sh2->irqsr));
UML_CALLH(block, sh2->write32);
UML_SUB(block, R32(15), R32(15), IMM(4));
UML_MOV(block, IREG(0), R32(15));
UML_MOV(block, IREG(1), PARAM(ptype, pvalue));
UML_CALLH(block, sh2->write32);
UML_HASHJMP(block, IMM(0), MEM(&sh2->evec), sh2->nocode);
UML_LABEL(block, skip);
}
if (compiler->cycles > 0)
{
UML_SUB(block, MEM(&sh2->icount), MEM(&sh2->icount), MAPVAR_CYCLES);
UML_MAPVAR(block, MAPVAR_CYCLES, 0);
if (allow_exception)
UML_EXHc(block, IF_S, sh2->out_of_cycles, PARAM(ptype, pvalue));
}
compiler->cycles = 0;
} | [
"static",
"void",
"generate_update_cycles",
"(",
"sh2_state",
"*",
"sh2",
",",
"drcuml_block",
"*",
"block",
",",
"compiler_state",
"*",
"compiler",
",",
"drcuml_ptype",
"ptype",
",",
"UINT64",
"pvalue",
",",
"int",
"allow_exception",
")",
"{",
"if",
"(",
"compiler",
"->",
"checkints",
")",
"{",
"drcuml_codelabel",
"skip",
"=",
"compiler",
"->",
"labelnum",
"++",
";",
"compiler",
"->",
"checkints",
"=",
"FALSE",
";",
"compiler",
"->",
"labelnum",
"+=",
"4",
";",
"UML_MOV",
"(",
"block",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"irqline",
")",
",",
"IMM",
"(",
"0xffffffff",
")",
")",
";",
"UML_CMP",
"(",
"block",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"pending_nmi",
")",
",",
"IMM",
"(",
"0",
")",
")",
";",
"UML_JMPc",
"(",
"block",
",",
"IF_Z",
",",
"skip",
"+",
"2",
")",
";",
"UML_MOV",
"(",
"block",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"pending_nmi",
")",
",",
"IMM",
"(",
"0",
")",
")",
";",
"UML_JMP",
"(",
"block",
",",
"skip",
"+",
"1",
")",
";",
"UML_LABEL",
"(",
"block",
",",
"skip",
"+",
"2",
")",
";",
"UML_MOV",
"(",
"block",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"evec",
")",
",",
"IMM",
"(",
"0xffffffff",
")",
")",
";",
"UML_MOV",
"(",
"block",
",",
"IREG",
"(",
"0",
")",
",",
"IMM",
"(",
"0xffffffff",
")",
")",
";",
"UML_AND",
"(",
"block",
",",
"IREG",
"(",
"1",
")",
",",
"IREG",
"(",
"0",
")",
",",
"IMM",
"(",
"0xffff",
")",
")",
";",
"UML_LZCNT",
"(",
"block",
",",
"IREG",
"(",
"1",
")",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"pending_irq",
")",
")",
";",
"UML_CMP",
"(",
"block",
",",
"IREG",
"(",
"1",
")",
",",
"IMM",
"(",
"32",
")",
")",
";",
"UML_JMPc",
"(",
"block",
",",
"IF_Z",
",",
"skip",
"+",
"4",
")",
";",
"UML_SUB",
"(",
"block",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"irqline",
")",
",",
"IMM",
"(",
"31",
")",
",",
"IREG",
"(",
"1",
")",
")",
";",
"UML_LABEL",
"(",
"block",
",",
"skip",
"+",
"4",
")",
";",
"UML_CMP",
"(",
"block",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"internal_irq_level",
")",
",",
"IMM",
"(",
"0xffffffff",
")",
")",
";",
"UML_JMPc",
"(",
"block",
",",
"IF_Z",
",",
"skip",
"+",
"3",
")",
";",
"UML_CMP",
"(",
"block",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"internal_irq_level",
")",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"irqline",
")",
")",
";",
"UML_JMPc",
"(",
"block",
",",
"IF_LE",
",",
"skip",
"+",
"3",
")",
";",
"UML_MOV",
"(",
"block",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"irqline",
")",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"internal_irq_level",
")",
")",
";",
"UML_LABEL",
"(",
"block",
",",
"skip",
"+",
"3",
")",
";",
"UML_CMP",
"(",
"block",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"irqline",
")",
",",
"IMM",
"(",
"0xffffffff",
")",
")",
";",
"UML_JMPc",
"(",
"block",
",",
"IF_Z",
",",
"skip",
"+",
"1",
")",
";",
"UML_CALLC",
"(",
"block",
",",
"cfunc_fastirq",
",",
"sh2",
")",
";",
"UML_LABEL",
"(",
"block",
",",
"skip",
"+",
"1",
")",
";",
"UML_CMP",
"(",
"block",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"evec",
")",
",",
"IMM",
"(",
"0xffffffff",
")",
")",
";",
"UML_JMPc",
"(",
"block",
",",
"IF_Z",
",",
"skip",
")",
";",
"UML_SUB",
"(",
"block",
",",
"R32",
"(",
"15",
")",
",",
"R32",
"(",
"15",
")",
",",
"IMM",
"(",
"4",
")",
")",
";",
"UML_MOV",
"(",
"block",
",",
"IREG",
"(",
"0",
")",
",",
"R32",
"(",
"15",
")",
")",
";",
"UML_MOV",
"(",
"block",
",",
"IREG",
"(",
"1",
")",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"irqsr",
")",
")",
";",
"UML_CALLH",
"(",
"block",
",",
"sh2",
"->",
"write32",
")",
";",
"UML_SUB",
"(",
"block",
",",
"R32",
"(",
"15",
")",
",",
"R32",
"(",
"15",
")",
",",
"IMM",
"(",
"4",
")",
")",
";",
"UML_MOV",
"(",
"block",
",",
"IREG",
"(",
"0",
")",
",",
"R32",
"(",
"15",
")",
")",
";",
"UML_MOV",
"(",
"block",
",",
"IREG",
"(",
"1",
")",
",",
"PARAM",
"(",
"ptype",
",",
"pvalue",
")",
")",
";",
"UML_CALLH",
"(",
"block",
",",
"sh2",
"->",
"write32",
")",
";",
"UML_HASHJMP",
"(",
"block",
",",
"IMM",
"(",
"0",
")",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"evec",
")",
",",
"sh2",
"->",
"nocode",
")",
";",
"UML_LABEL",
"(",
"block",
",",
"skip",
")",
";",
"}",
"if",
"(",
"compiler",
"->",
"cycles",
">",
"0",
")",
"{",
"UML_SUB",
"(",
"block",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"icount",
")",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"icount",
")",
",",
"MAPVAR_CYCLES",
")",
";",
"UML_MAPVAR",
"(",
"block",
",",
"MAPVAR_CYCLES",
",",
"0",
")",
";",
"if",
"(",
"allow_exception",
")",
"UML_EXHc",
"(",
"block",
",",
"IF_S",
",",
"sh2",
"->",
"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"
] | [
"/* check full interrupts if pending */",
"/* check for interrupts */",
"// mov irqline, #-1\r",
"// cmp pending_nmi, #0\r",
"// jz skip+2\r",
"// zap pending_nmi\r",
"// and then go take it (evec is already set)\r",
"// skip+2:\r",
"// mov evec, -1\r",
"// mov r0, -1 (r0 = irq)\r",
"// and r1, r0, 0xffff\r",
"// lzcnt r1, pending_irq\r",
"// cmp r1, #32\r",
"// jz skip+4\r",
"// sub irqline, #31, r1\r",
"// skip+4:\r",
"// cmp internal_irq_level, #-1\r",
"// jz skip+3\r",
"// cmp internal_irq_level, irqline\r",
"// jle skip+3\r",
"// mov r0, internal_irq_level\r",
"// skip+3:\r",
"// cmp irqline, #-1\r",
"// jz skip+1\r",
"// callc fastirq\r",
"// skip+1:\r",
"// cmp evec, 0xffffffff\r",
"// jz skip\r",
"// sub R15, R15, #4\r",
"// mov r0, R15\r",
"// mov r1, irqsr\r",
"// call write32\r",
"// sub R15, R15, #4\r",
"// mov r0, R15\r",
"// mov r1, nextpc\r",
"// call write32\r",
"// hashjmp sh2->evec\r",
"// skip:\r",
"/* account for cycles */",
"// sub icount,icount,cycles\r",
"// mapvar cycles,0\r",
"// exh out_of_cycles,nextpc\r"
] | [
{
"param": "sh2",
"type": "sh2_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": "sh2",
"type": "sh2_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": []
} |
908ba337e95781df892f5f60b9b28b6f64a544d5 | lofunz/mieme | Reloaded/trunk/src/emu/cpu/sh2/sh2drc.c | [
"Unlicense"
] | C | generate_checksum_block | void | static void generate_checksum_block(sh2_state *sh2, 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); // comment
/* loose verify or single instruction: just compare and fail */
if (!(sh2->drcoptions & SH2DRC_STRICT_VERIFY) || seqhead->next == NULL)
{
if (!(seqhead->flags & OPFLAG_VIRTUAL_NOOP))
{
void *base = memory_decrypted_read_ptr(sh2->program, SH2_CODE_XOR(seqhead->physpc));
UML_LOAD(block, IREG(0), base, IMM(0), WORD); // load i0,base,word
UML_CMP(block, IREG(0), IMM(seqhead->opptr.w[0])); // cmp i0,*opptr
UML_EXHc(block, IF_NE, sh2->nocode, IMM(epc(seqhead))); // exne nocode,seqhead->pc
}
}
/* full verification; sum up everything */
else
{
#if 0
for (curdesc = seqhead->next; curdesc != seqlast->next; curdesc = curdesc->next)
if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP))
{
base = memory_decrypted_read_ptr(sh2->program, SH2_CODE_XOR(curdesc->physpc));
UML_LOAD(block, IREG(0), curdesc->opptr.w, IMM(0), WORD); // load i0,*opptr,0,word
UML_CMP(block, IREG(0), IMM(curdesc->opptr.w[0])); // cmp i0,*opptr
UML_EXHc(block, IF_NE, sh2->nocode, IMM(epc(seqhead))); // exne nocode,seqhead->pc
}
#else
UINT32 sum = 0;
void *base = memory_decrypted_read_ptr(sh2->program, SH2_CODE_XOR(seqhead->physpc));
UML_LOAD(block, IREG(0), base, IMM(0), WORD); // load i0,base,word
sum += seqhead->opptr.w[0];
for (curdesc = seqhead->next; curdesc != seqlast->next; curdesc = curdesc->next)
if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP))
{
base = memory_decrypted_read_ptr(sh2->program, SH2_CODE_XOR(curdesc->physpc));
UML_LOAD(block, IREG(1), base, IMM(0), WORD); // load i1,*opptr,word
UML_ADD(block, IREG(0), IREG(0), IREG(1)); // add i0,i0,i1
sum += curdesc->opptr.w[0];
}
UML_CMP(block, IREG(0), IMM(sum)); // cmp i0,sum
UML_EXHc(block, IF_NE, sh2->nocode, IMM(epc(seqhead))); // exne nocode,seqhead->pc
#endif
}
} | /*-------------------------------------------------
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(sh2_state *sh2, 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);
if (!(sh2->drcoptions & SH2DRC_STRICT_VERIFY) || seqhead->next == NULL)
{
if (!(seqhead->flags & OPFLAG_VIRTUAL_NOOP))
{
void *base = memory_decrypted_read_ptr(sh2->program, SH2_CODE_XOR(seqhead->physpc));
UML_LOAD(block, IREG(0), base, IMM(0), WORD);
UML_CMP(block, IREG(0), IMM(seqhead->opptr.w[0]));
UML_EXHc(block, IF_NE, sh2->nocode, IMM(epc(seqhead)));
}
}
else
{
#if 0
for (curdesc = seqhead->next; curdesc != seqlast->next; curdesc = curdesc->next)
if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP))
{
base = memory_decrypted_read_ptr(sh2->program, SH2_CODE_XOR(curdesc->physpc));
UML_LOAD(block, IREG(0), curdesc->opptr.w, IMM(0), WORD);
UML_CMP(block, IREG(0), IMM(curdesc->opptr.w[0]));
UML_EXHc(block, IF_NE, sh2->nocode, IMM(epc(seqhead)));
}
#else
UINT32 sum = 0;
void *base = memory_decrypted_read_ptr(sh2->program, SH2_CODE_XOR(seqhead->physpc));
UML_LOAD(block, IREG(0), base, IMM(0), WORD);
sum += seqhead->opptr.w[0];
for (curdesc = seqhead->next; curdesc != seqlast->next; curdesc = curdesc->next)
if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP))
{
base = memory_decrypted_read_ptr(sh2->program, SH2_CODE_XOR(curdesc->physpc));
UML_LOAD(block, IREG(1), base, IMM(0), WORD);
UML_ADD(block, IREG(0), IREG(0), IREG(1));
sum += curdesc->opptr.w[0];
}
UML_CMP(block, IREG(0), IMM(sum));
UML_EXHc(block, IF_NE, sh2->nocode, IMM(epc(seqhead)));
#endif
}
} | [
"static",
"void",
"generate_checksum_block",
"(",
"sh2_state",
"*",
"sh2",
",",
"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",
")",
";",
"if",
"(",
"!",
"(",
"sh2",
"->",
"drcoptions",
"&",
"SH2DRC_STRICT_VERIFY",
")",
"||",
"seqhead",
"->",
"next",
"==",
"NULL",
")",
"{",
"if",
"(",
"!",
"(",
"seqhead",
"->",
"flags",
"&",
"OPFLAG_VIRTUAL_NOOP",
")",
")",
"{",
"void",
"*",
"base",
"=",
"memory_decrypted_read_ptr",
"(",
"sh2",
"->",
"program",
",",
"SH2_CODE_XOR",
"(",
"seqhead",
"->",
"physpc",
")",
")",
";",
"UML_LOAD",
"(",
"block",
",",
"IREG",
"(",
"0",
")",
",",
"base",
",",
"IMM",
"(",
"0",
")",
",",
"WORD",
")",
";",
"UML_CMP",
"(",
"block",
",",
"IREG",
"(",
"0",
")",
",",
"IMM",
"(",
"seqhead",
"->",
"opptr",
".",
"w",
"[",
"0",
"]",
")",
")",
";",
"UML_EXHc",
"(",
"block",
",",
"IF_NE",
",",
"sh2",
"->",
"nocode",
",",
"IMM",
"(",
"epc",
"(",
"seqhead",
")",
")",
")",
";",
"}",
"}",
"else",
"{",
"#if",
"0",
"\n",
"for",
"(",
"curdesc",
"=",
"seqhead",
"->",
"next",
";",
"curdesc",
"!=",
"seqlast",
"->",
"next",
";",
"curdesc",
"=",
"curdesc",
"->",
"next",
")",
"if",
"(",
"!",
"(",
"curdesc",
"->",
"flags",
"&",
"OPFLAG_VIRTUAL_NOOP",
")",
")",
"{",
"base",
"=",
"memory_decrypted_read_ptr",
"(",
"sh2",
"->",
"program",
",",
"SH2_CODE_XOR",
"(",
"curdesc",
"->",
"physpc",
")",
")",
";",
"UML_LOAD",
"(",
"block",
",",
"IREG",
"(",
"0",
")",
",",
"curdesc",
"->",
"opptr",
".",
"w",
",",
"IMM",
"(",
"0",
")",
",",
"WORD",
")",
";",
"UML_CMP",
"(",
"block",
",",
"IREG",
"(",
"0",
")",
",",
"IMM",
"(",
"curdesc",
"->",
"opptr",
".",
"w",
"[",
"0",
"]",
")",
")",
";",
"UML_EXHc",
"(",
"block",
",",
"IF_NE",
",",
"sh2",
"->",
"nocode",
",",
"IMM",
"(",
"epc",
"(",
"seqhead",
")",
")",
")",
";",
"}",
"#else",
"UINT32",
"sum",
"=",
"0",
";",
"void",
"*",
"base",
"=",
"memory_decrypted_read_ptr",
"(",
"sh2",
"->",
"program",
",",
"SH2_CODE_XOR",
"(",
"seqhead",
"->",
"physpc",
")",
")",
";",
"UML_LOAD",
"(",
"block",
",",
"IREG",
"(",
"0",
")",
",",
"base",
",",
"IMM",
"(",
"0",
")",
",",
"WORD",
")",
";",
"sum",
"+=",
"seqhead",
"->",
"opptr",
".",
"w",
"[",
"0",
"]",
";",
"for",
"(",
"curdesc",
"=",
"seqhead",
"->",
"next",
";",
"curdesc",
"!=",
"seqlast",
"->",
"next",
";",
"curdesc",
"=",
"curdesc",
"->",
"next",
")",
"if",
"(",
"!",
"(",
"curdesc",
"->",
"flags",
"&",
"OPFLAG_VIRTUAL_NOOP",
")",
")",
"{",
"base",
"=",
"memory_decrypted_read_ptr",
"(",
"sh2",
"->",
"program",
",",
"SH2_CODE_XOR",
"(",
"curdesc",
"->",
"physpc",
")",
")",
";",
"UML_LOAD",
"(",
"block",
",",
"IREG",
"(",
"1",
")",
",",
"base",
",",
"IMM",
"(",
"0",
")",
",",
"WORD",
")",
";",
"UML_ADD",
"(",
"block",
",",
"IREG",
"(",
"0",
")",
",",
"IREG",
"(",
"0",
")",
",",
"IREG",
"(",
"1",
")",
")",
";",
"sum",
"+=",
"curdesc",
"->",
"opptr",
".",
"w",
"[",
"0",
"]",
";",
"}",
"UML_CMP",
"(",
"block",
",",
"IREG",
"(",
"0",
")",
",",
"IMM",
"(",
"sum",
")",
")",
";",
"UML_EXHc",
"(",
"block",
",",
"IF_NE",
",",
"sh2",
"->",
"nocode",
",",
"IMM",
"(",
"epc",
"(",
"seqhead",
")",
")",
")",
";",
"#endif",
"}",
"}"
] | 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,word\r",
"// cmp i0,*opptr\r",
"// exne nocode,seqhead->pc\r",
"/* full verification; sum up everything */",
"// load i0,*opptr,0,word\r",
"// cmp i0,*opptr\r",
"// exne nocode,seqhead->pc\r",
"// load i0,base,word\r",
"// load i1,*opptr,word\r",
"// add i0,i0,i1\r",
"// cmp i0,sum\r",
"// exne nocode,seqhead->pc\r"
] | [
{
"param": "sh2",
"type": "sh2_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": "sh2",
"type": "sh2_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": []
} |
908ba337e95781df892f5f60b9b28b6f64a544d5 | lofunz/mieme | Reloaded/trunk/src/emu/cpu/sh2/sh2drc.c | [
"Unlicense"
] | C | generate_sequence_instruction | void | static void generate_sequence_instruction(sh2_state *sh2, 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(block, desc->pc, desc->opptr.w[0]);
/* set the PC map variable */
expc = (desc->flags & OPFLAG_IN_DELAY_SLOT) ? desc->pc - 1 : 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 want a probe, add it here */
if (desc->pc == PROBE_ADDRESS)
{
UML_MOV(block, MEM(&sh2->pc), IMM(desc->pc)); // mov [pc],desc->pc
UML_CALLC(block, cfunc_printf_probe, sh2); // callc cfunc_printf_probe,sh2
}
/* if we are debugging, call the debugger */
if ((sh2->device->machine->debug_flags & DEBUG_FLAG_ENABLED) != 0)
{
UML_MOV(block, MEM(&sh2->pc), IMM(desc->pc)); // mov [pc],desc->pc
save_fast_iregs(sh2, block);
UML_DEBUG(block, IMM(desc->pc)); // debug desc->pc
}
else // not debug, see what other reasons there are for flushing the PC
{
if (sh2->drcoptions & SH2DRC_FLUSH_PC) // always flush?
{
UML_MOV(block, MEM(&sh2->pc), IMM(desc->pc)); // mov sh2->pc, desc->pc
}
else // check for driver-selected flushes
{
int pcflush;
for (pcflush = 0; pcflush < sh2->pcfsel; pcflush++)
{
if (desc->pc == sh2->pcflushes[pcflush])
{
UML_MOV(block, MEM(&sh2->pc), IMM(desc->pc)); // mov sh2->pc, desc->pc
}
}
}
}
/* if we hit an unmapped address, fatal error */
if (desc->flags & OPFLAG_COMPILER_UNMAPPED)
{
UML_MOV(block, MEM(&sh2->pc), IMM(desc->pc)); // mov [pc],desc->pc
save_fast_iregs(sh2, block);
UML_EXIT(block, IMM(EXECUTE_UNMAPPED_CODE)); // exit EXECUTE_UNMAPPED_CODE
}
/* if this is an invalid opcode, die */
if (desc->flags & OPFLAG_INVALID_OPCODE)
{
fatalerror("SH2DRC: invalid opcode!\n");
}
/* 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(sh2, block, compiler, desc))
{
UML_MOV(block, MEM(&sh2->pc), IMM(desc->pc)); // mov [pc],desc->pc
UML_MOV(block, MEM(&sh2->arg0), IMM(desc->opptr.w[0])); // mov [arg0],opcode
UML_CALLC(block, cfunc_unimplemented, sh2); // 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(sh2_state *sh2, 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(block, desc->pc, desc->opptr.w[0]);
expc = (desc->flags & OPFLAG_IN_DELAY_SLOT) ? desc->pc - 1 : desc->pc;
UML_MAPVAR(block, MAPVAR_PC, expc);
compiler->cycles += desc->cycles;
UML_MAPVAR(block, MAPVAR_CYCLES, compiler->cycles);
if (desc->pc == PROBE_ADDRESS)
{
UML_MOV(block, MEM(&sh2->pc), IMM(desc->pc));
UML_CALLC(block, cfunc_printf_probe, sh2);
}
if ((sh2->device->machine->debug_flags & DEBUG_FLAG_ENABLED) != 0)
{
UML_MOV(block, MEM(&sh2->pc), IMM(desc->pc));
save_fast_iregs(sh2, block);
UML_DEBUG(block, IMM(desc->pc));
}
else
{
if (sh2->drcoptions & SH2DRC_FLUSH_PC)
{
UML_MOV(block, MEM(&sh2->pc), IMM(desc->pc));
}
else
{
int pcflush;
for (pcflush = 0; pcflush < sh2->pcfsel; pcflush++)
{
if (desc->pc == sh2->pcflushes[pcflush])
{
UML_MOV(block, MEM(&sh2->pc), IMM(desc->pc));
}
}
}
}
if (desc->flags & OPFLAG_COMPILER_UNMAPPED)
{
UML_MOV(block, MEM(&sh2->pc), IMM(desc->pc));
save_fast_iregs(sh2, block);
UML_EXIT(block, IMM(EXECUTE_UNMAPPED_CODE));
}
if (desc->flags & OPFLAG_INVALID_OPCODE)
{
fatalerror("SH2DRC: invalid opcode!\n");
}
else if (!(desc->flags & OPFLAG_VIRTUAL_NOOP))
{
if (!generate_opcode(sh2, block, compiler, desc))
{
UML_MOV(block, MEM(&sh2->pc), IMM(desc->pc));
UML_MOV(block, MEM(&sh2->arg0), IMM(desc->opptr.w[0]));
UML_CALLC(block, cfunc_unimplemented, sh2);
}
}
} | [
"static",
"void",
"generate_sequence_instruction",
"(",
"sh2_state",
"*",
"sh2",
",",
"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",
"(",
"block",
",",
"desc",
"->",
"pc",
",",
"desc",
"->",
"opptr",
".",
"w",
"[",
"0",
"]",
")",
";",
"expc",
"=",
"(",
"desc",
"->",
"flags",
"&",
"OPFLAG_IN_DELAY_SLOT",
")",
"?",
"desc",
"->",
"pc",
"-",
"1",
":",
"desc",
"->",
"pc",
";",
"UML_MAPVAR",
"(",
"block",
",",
"MAPVAR_PC",
",",
"expc",
")",
";",
"compiler",
"->",
"cycles",
"+=",
"desc",
"->",
"cycles",
";",
"UML_MAPVAR",
"(",
"block",
",",
"MAPVAR_CYCLES",
",",
"compiler",
"->",
"cycles",
")",
";",
"if",
"(",
"desc",
"->",
"pc",
"==",
"PROBE_ADDRESS",
")",
"{",
"UML_MOV",
"(",
"block",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"pc",
")",
",",
"IMM",
"(",
"desc",
"->",
"pc",
")",
")",
";",
"UML_CALLC",
"(",
"block",
",",
"cfunc_printf_probe",
",",
"sh2",
")",
";",
"}",
"if",
"(",
"(",
"sh2",
"->",
"device",
"->",
"machine",
"->",
"debug_flags",
"&",
"DEBUG_FLAG_ENABLED",
")",
"!=",
"0",
")",
"{",
"UML_MOV",
"(",
"block",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"pc",
")",
",",
"IMM",
"(",
"desc",
"->",
"pc",
")",
")",
";",
"save_fast_iregs",
"(",
"sh2",
",",
"block",
")",
";",
"UML_DEBUG",
"(",
"block",
",",
"IMM",
"(",
"desc",
"->",
"pc",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"sh2",
"->",
"drcoptions",
"&",
"SH2DRC_FLUSH_PC",
")",
"{",
"UML_MOV",
"(",
"block",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"pc",
")",
",",
"IMM",
"(",
"desc",
"->",
"pc",
")",
")",
";",
"}",
"else",
"{",
"int",
"pcflush",
";",
"for",
"(",
"pcflush",
"=",
"0",
";",
"pcflush",
"<",
"sh2",
"->",
"pcfsel",
";",
"pcflush",
"++",
")",
"{",
"if",
"(",
"desc",
"->",
"pc",
"==",
"sh2",
"->",
"pcflushes",
"[",
"pcflush",
"]",
")",
"{",
"UML_MOV",
"(",
"block",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"pc",
")",
",",
"IMM",
"(",
"desc",
"->",
"pc",
")",
")",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"desc",
"->",
"flags",
"&",
"OPFLAG_COMPILER_UNMAPPED",
")",
"{",
"UML_MOV",
"(",
"block",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"pc",
")",
",",
"IMM",
"(",
"desc",
"->",
"pc",
")",
")",
";",
"save_fast_iregs",
"(",
"sh2",
",",
"block",
")",
";",
"UML_EXIT",
"(",
"block",
",",
"IMM",
"(",
"EXECUTE_UNMAPPED_CODE",
")",
")",
";",
"}",
"if",
"(",
"desc",
"->",
"flags",
"&",
"OPFLAG_INVALID_OPCODE",
")",
"{",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
")",
";",
"}",
"else",
"if",
"(",
"!",
"(",
"desc",
"->",
"flags",
"&",
"OPFLAG_VIRTUAL_NOOP",
")",
")",
"{",
"if",
"(",
"!",
"generate_opcode",
"(",
"sh2",
",",
"block",
",",
"compiler",
",",
"desc",
")",
")",
"{",
"UML_MOV",
"(",
"block",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"pc",
")",
",",
"IMM",
"(",
"desc",
"->",
"pc",
")",
")",
";",
"UML_MOV",
"(",
"block",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"arg0",
")",
",",
"IMM",
"(",
"desc",
"->",
"opptr",
".",
"w",
"[",
"0",
"]",
")",
")",
";",
"UML_CALLC",
"(",
"block",
",",
"cfunc_unimplemented",
",",
"sh2",
")",
";",
"}",
"}",
"}"
] | 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 want a probe, add it here */",
"// mov [pc],desc->pc\r",
"// callc cfunc_printf_probe,sh2\r",
"/* if we are debugging, call the debugger */",
"// mov [pc],desc->pc\r",
"// debug desc->pc\r",
"// not debug, see what other reasons there are for flushing the PC\r",
"// always flush?\r",
"// mov sh2->pc, desc->pc\r",
"// check for driver-selected flushes\r",
"// mov sh2->pc, desc->pc\r",
"/* if we hit an unmapped address, fatal error */",
"// mov [pc],desc->pc\r",
"// exit EXECUTE_UNMAPPED_CODE\r",
"/* if this is an invalid opcode, die */",
"/* otherwise, unless this is a virtual no-op, it's a regular instruction */",
"/* compile the instruction */",
"// mov [pc],desc->pc\r",
"// mov [arg0],opcode\r",
"// callc cfunc_unimplemented\r"
] | [
{
"param": "sh2",
"type": "sh2_state"
},
{
"param": "block",
"type": "drcuml_block"
},
{
"param": "compiler",
"type": "compiler_state"
},
{
"param": "desc",
"type": "opcode_desc"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sh2",
"type": "sh2_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": []
} |
908ba337e95781df892f5f60b9b28b6f64a544d5 | lofunz/mieme | Reloaded/trunk/src/emu/cpu/sh2/sh2drc.c | [
"Unlicense"
] | C | generate_opcode | int | static int generate_opcode(sh2_state *sh2, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc)
{
UINT32 scratch, scratch2;
INT32 disp;
UINT16 opcode = desc->opptr.w[0];
UINT8 opswitch = opcode >> 12;
int in_delay_slot = ((desc->flags & OPFLAG_IN_DELAY_SLOT) != 0);
switch (opswitch)
{
case 0:
return generate_group_0(sh2, block, compiler, desc, opcode, in_delay_slot);
case 1: // MOVLS4
scratch = (opcode & 0x0f) * 4;
UML_ADD(block, IREG(0), R32(Rn), IMM(scratch)); // add r0, Rn, scratch
UML_MOV(block, IREG(1), R32(Rm)); // mov r1, Rm
SETEA(0); // set ea for debug
UML_CALLH(block, sh2->write32);
if (!in_delay_slot)
generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
return TRUE;
case 2:
return generate_group_2(sh2, block, compiler, desc, opcode, in_delay_slot);
case 3:
return generate_group_3(sh2, block, compiler, desc, opcode);
case 4:
return generate_group_4(sh2, block, compiler, desc, opcode, in_delay_slot);
case 5: // MOVLL4
scratch = (opcode & 0x0f) * 4;
UML_ADD(block, IREG(0), R32(Rm), IMM(scratch)); // add r0, Rm, scratch
SETEA(0); // set ea for debug
UML_CALLH(block, sh2->read32); // call read32
UML_MOV(block, R32(Rn), IREG(0)); // mov Rn, r0
if (!in_delay_slot)
generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
return TRUE;
case 6:
return generate_group_6(sh2, block, compiler, desc, opcode, in_delay_slot);
case 7: // ADDI
scratch = opcode & 0xff;
scratch2 = (UINT32)(INT32)(INT16)(INT8)scratch;
UML_ADD(block, R32(Rn), R32(Rn), IMM(scratch2)); // add Rn, Rn, scratch2
return TRUE;
case 8:
return generate_group_8(sh2, block, compiler, desc, opcode, in_delay_slot);
case 9: // MOVWI
scratch = (desc->pc + 2) + ((opcode & 0xff) * 2) + 2;
if (sh2->drcoptions & SH2DRC_STRICT_PCREL)
{
UML_MOV(block, IREG(0), IMM(scratch)); // mov r0, scratch
SETEA(0); // set ea for debug
UML_CALLH(block, sh2->read16); // read16(r0, r1)
UML_SEXT(block, R32(Rn), IREG(0), WORD); // sext Rn, r0, WORD
}
else
{
scratch2 = (UINT32)(INT32)(INT16) RW(sh2, scratch);
UML_MOV(block, R32(Rn), IMM(scratch2)); // mov Rn, scratch2
}
if (!in_delay_slot)
generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
return TRUE;
case 10: // BRA
generate_delay_slot(sh2, block, compiler, desc);
disp = ((INT32)opcode << 20) >> 20;
sh2->ea = (desc->pc + 2) + disp * 2 + 2; // sh2->ea = pc+4 + disp*2 + 2
generate_update_cycles(sh2, block, compiler, IMM(sh2->ea), TRUE); // <subtract cycles>
UML_HASHJMP(block, IMM(0), IMM(sh2->ea), sh2->nocode); // hashjmp sh2->ea
return TRUE;
case 11: // BSR
// panicstr @ 403da22 relies on the delay slot clobbering the PR set by a BSR, so
// do this before running the delay slot
UML_ADD(block, MEM(&sh2->pr), IMM(desc->pc), IMM(4)); // add sh2->pr, desc->pc, #4 (skip the current insn & delay slot)
generate_delay_slot(sh2, block, compiler, desc);
disp = ((INT32)opcode << 20) >> 20;
sh2->ea = (desc->pc + 2) + disp * 2 + 2; // sh2->ea = pc+4 + disp*2 + 2
generate_update_cycles(sh2, block, compiler, IMM(sh2->ea), TRUE); // <subtract cycles>
UML_HASHJMP(block, IMM(0), IMM(sh2->ea), sh2->nocode); // hashjmp sh2->ea
return TRUE;
case 12:
return generate_group_12(sh2, block, compiler, desc, opcode, in_delay_slot);
case 13: // MOVLI
scratch = ((desc->pc + 4) & ~3) + ((opcode & 0xff) * 4);
if (sh2->drcoptions & SH2DRC_STRICT_PCREL)
{
UML_MOV(block, IREG(0), IMM(scratch)); // mov r0, scratch
UML_CALLH(block, sh2->read32); // read32(r0, r1)
UML_MOV(block, R32(Rn), IREG(0)); // mov Rn, r0
}
else
{
scratch2 = RL(sh2, scratch);
UML_MOV(block, R32(Rn), IMM(scratch2)); // mov Rn, scratch2
}
if (!in_delay_slot)
generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
return TRUE;
case 14: // MOVI
scratch = opcode & 0xff;
scratch2 = (UINT32)(INT32)(INT16)(INT8)scratch;
UML_MOV(block, R32(Rn), IMM(scratch2));
return TRUE;
case 15: // NOP
return TRUE;
}
return FALSE;
} | /*-------------------------------------------------
generate_opcode - generate code for a specific
opcode
-------------------------------------------------*/ | generate code for a specific
opcode | [
"generate",
"code",
"for",
"a",
"specific",
"opcode"
] | static int generate_opcode(sh2_state *sh2, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc)
{
UINT32 scratch, scratch2;
INT32 disp;
UINT16 opcode = desc->opptr.w[0];
UINT8 opswitch = opcode >> 12;
int in_delay_slot = ((desc->flags & OPFLAG_IN_DELAY_SLOT) != 0);
switch (opswitch)
{
case 0:
return generate_group_0(sh2, block, compiler, desc, opcode, in_delay_slot);
case 1:
scratch = (opcode & 0x0f) * 4;
UML_ADD(block, IREG(0), R32(Rn), IMM(scratch));
UML_MOV(block, IREG(1), R32(Rm));
SETEA(0);
UML_CALLH(block, sh2->write32);
if (!in_delay_slot)
generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
return TRUE;
case 2:
return generate_group_2(sh2, block, compiler, desc, opcode, in_delay_slot);
case 3:
return generate_group_3(sh2, block, compiler, desc, opcode);
case 4:
return generate_group_4(sh2, block, compiler, desc, opcode, in_delay_slot);
case 5:
scratch = (opcode & 0x0f) * 4;
UML_ADD(block, IREG(0), R32(Rm), IMM(scratch));
SETEA(0);
UML_CALLH(block, sh2->read32);
UML_MOV(block, R32(Rn), IREG(0));
if (!in_delay_slot)
generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
return TRUE;
case 6:
return generate_group_6(sh2, block, compiler, desc, opcode, in_delay_slot);
case 7:
scratch = opcode & 0xff;
scratch2 = (UINT32)(INT32)(INT16)(INT8)scratch;
UML_ADD(block, R32(Rn), R32(Rn), IMM(scratch2));
return TRUE;
case 8:
return generate_group_8(sh2, block, compiler, desc, opcode, in_delay_slot);
case 9:
scratch = (desc->pc + 2) + ((opcode & 0xff) * 2) + 2;
if (sh2->drcoptions & SH2DRC_STRICT_PCREL)
{
UML_MOV(block, IREG(0), IMM(scratch));
SETEA(0);
UML_CALLH(block, sh2->read16);
UML_SEXT(block, R32(Rn), IREG(0), WORD);
}
else
{
scratch2 = (UINT32)(INT32)(INT16) RW(sh2, scratch);
UML_MOV(block, R32(Rn), IMM(scratch2));
}
if (!in_delay_slot)
generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
return TRUE;
case 10:
generate_delay_slot(sh2, block, compiler, desc);
disp = ((INT32)opcode << 20) >> 20;
sh2->ea = (desc->pc + 2) + disp * 2 + 2;
generate_update_cycles(sh2, block, compiler, IMM(sh2->ea), TRUE);
UML_HASHJMP(block, IMM(0), IMM(sh2->ea), sh2->nocode);
return TRUE;
case 11:
UML_ADD(block, MEM(&sh2->pr), IMM(desc->pc), IMM(4));
generate_delay_slot(sh2, block, compiler, desc);
disp = ((INT32)opcode << 20) >> 20;
sh2->ea = (desc->pc + 2) + disp * 2 + 2;
generate_update_cycles(sh2, block, compiler, IMM(sh2->ea), TRUE);
UML_HASHJMP(block, IMM(0), IMM(sh2->ea), sh2->nocode);
return TRUE;
case 12:
return generate_group_12(sh2, block, compiler, desc, opcode, in_delay_slot);
case 13:
scratch = ((desc->pc + 4) & ~3) + ((opcode & 0xff) * 4);
if (sh2->drcoptions & SH2DRC_STRICT_PCREL)
{
UML_MOV(block, IREG(0), IMM(scratch));
UML_CALLH(block, sh2->read32);
UML_MOV(block, R32(Rn), IREG(0));
}
else
{
scratch2 = RL(sh2, scratch);
UML_MOV(block, R32(Rn), IMM(scratch2));
}
if (!in_delay_slot)
generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
return TRUE;
case 14:
scratch = opcode & 0xff;
scratch2 = (UINT32)(INT32)(INT16)(INT8)scratch;
UML_MOV(block, R32(Rn), IMM(scratch2));
return TRUE;
case 15:
return TRUE;
}
return FALSE;
} | [
"static",
"int",
"generate_opcode",
"(",
"sh2_state",
"*",
"sh2",
",",
"drcuml_block",
"*",
"block",
",",
"compiler_state",
"*",
"compiler",
",",
"const",
"opcode_desc",
"*",
"desc",
")",
"{",
"UINT32",
"scratch",
",",
"scratch2",
";",
"INT32",
"disp",
";",
"UINT16",
"opcode",
"=",
"desc",
"->",
"opptr",
".",
"w",
"[",
"0",
"]",
";",
"UINT8",
"opswitch",
"=",
"opcode",
">>",
"12",
";",
"int",
"in_delay_slot",
"=",
"(",
"(",
"desc",
"->",
"flags",
"&",
"OPFLAG_IN_DELAY_SLOT",
")",
"!=",
"0",
")",
";",
"switch",
"(",
"opswitch",
")",
"{",
"case",
"0",
":",
"return",
"generate_group_0",
"(",
"sh2",
",",
"block",
",",
"compiler",
",",
"desc",
",",
"opcode",
",",
"in_delay_slot",
")",
";",
"case",
"1",
":",
"scratch",
"=",
"(",
"opcode",
"&",
"0x0f",
")",
"*",
"4",
";",
"UML_ADD",
"(",
"block",
",",
"IREG",
"(",
"0",
")",
",",
"R32",
"(",
"Rn",
")",
",",
"IMM",
"(",
"scratch",
")",
")",
";",
"UML_MOV",
"(",
"block",
",",
"IREG",
"(",
"1",
")",
",",
"R32",
"(",
"Rm",
")",
")",
";",
"SETEA",
"(",
"0",
")",
";",
"UML_CALLH",
"(",
"block",
",",
"sh2",
"->",
"write32",
")",
";",
"if",
"(",
"!",
"in_delay_slot",
")",
"generate_update_cycles",
"(",
"sh2",
",",
"block",
",",
"compiler",
",",
"IMM",
"(",
"desc",
"->",
"pc",
"+",
"2",
")",
",",
"TRUE",
")",
";",
"return",
"TRUE",
";",
"case",
"2",
":",
"return",
"generate_group_2",
"(",
"sh2",
",",
"block",
",",
"compiler",
",",
"desc",
",",
"opcode",
",",
"in_delay_slot",
")",
";",
"case",
"3",
":",
"return",
"generate_group_3",
"(",
"sh2",
",",
"block",
",",
"compiler",
",",
"desc",
",",
"opcode",
")",
";",
"case",
"4",
":",
"return",
"generate_group_4",
"(",
"sh2",
",",
"block",
",",
"compiler",
",",
"desc",
",",
"opcode",
",",
"in_delay_slot",
")",
";",
"case",
"5",
":",
"scratch",
"=",
"(",
"opcode",
"&",
"0x0f",
")",
"*",
"4",
";",
"UML_ADD",
"(",
"block",
",",
"IREG",
"(",
"0",
")",
",",
"R32",
"(",
"Rm",
")",
",",
"IMM",
"(",
"scratch",
")",
")",
";",
"SETEA",
"(",
"0",
")",
";",
"UML_CALLH",
"(",
"block",
",",
"sh2",
"->",
"read32",
")",
";",
"UML_MOV",
"(",
"block",
",",
"R32",
"(",
"Rn",
")",
",",
"IREG",
"(",
"0",
")",
")",
";",
"if",
"(",
"!",
"in_delay_slot",
")",
"generate_update_cycles",
"(",
"sh2",
",",
"block",
",",
"compiler",
",",
"IMM",
"(",
"desc",
"->",
"pc",
"+",
"2",
")",
",",
"TRUE",
")",
";",
"return",
"TRUE",
";",
"case",
"6",
":",
"return",
"generate_group_6",
"(",
"sh2",
",",
"block",
",",
"compiler",
",",
"desc",
",",
"opcode",
",",
"in_delay_slot",
")",
";",
"case",
"7",
":",
"scratch",
"=",
"opcode",
"&",
"0xff",
";",
"scratch2",
"=",
"(",
"UINT32",
")",
"(",
"INT32",
")",
"(",
"INT16",
")",
"(",
"INT8",
")",
"scratch",
";",
"UML_ADD",
"(",
"block",
",",
"R32",
"(",
"Rn",
")",
",",
"R32",
"(",
"Rn",
")",
",",
"IMM",
"(",
"scratch2",
")",
")",
";",
"return",
"TRUE",
";",
"case",
"8",
":",
"return",
"generate_group_8",
"(",
"sh2",
",",
"block",
",",
"compiler",
",",
"desc",
",",
"opcode",
",",
"in_delay_slot",
")",
";",
"case",
"9",
":",
"scratch",
"=",
"(",
"desc",
"->",
"pc",
"+",
"2",
")",
"+",
"(",
"(",
"opcode",
"&",
"0xff",
")",
"*",
"2",
")",
"+",
"2",
";",
"if",
"(",
"sh2",
"->",
"drcoptions",
"&",
"SH2DRC_STRICT_PCREL",
")",
"{",
"UML_MOV",
"(",
"block",
",",
"IREG",
"(",
"0",
")",
",",
"IMM",
"(",
"scratch",
")",
")",
";",
"SETEA",
"(",
"0",
")",
";",
"UML_CALLH",
"(",
"block",
",",
"sh2",
"->",
"read16",
")",
";",
"UML_SEXT",
"(",
"block",
",",
"R32",
"(",
"Rn",
")",
",",
"IREG",
"(",
"0",
")",
",",
"WORD",
")",
";",
"}",
"else",
"{",
"scratch2",
"=",
"(",
"UINT32",
")",
"(",
"INT32",
")",
"(",
"INT16",
")",
"RW",
"(",
"sh2",
",",
"scratch",
")",
";",
"UML_MOV",
"(",
"block",
",",
"R32",
"(",
"Rn",
")",
",",
"IMM",
"(",
"scratch2",
")",
")",
";",
"}",
"if",
"(",
"!",
"in_delay_slot",
")",
"generate_update_cycles",
"(",
"sh2",
",",
"block",
",",
"compiler",
",",
"IMM",
"(",
"desc",
"->",
"pc",
"+",
"2",
")",
",",
"TRUE",
")",
";",
"return",
"TRUE",
";",
"case",
"10",
":",
"generate_delay_slot",
"(",
"sh2",
",",
"block",
",",
"compiler",
",",
"desc",
")",
";",
"disp",
"=",
"(",
"(",
"INT32",
")",
"opcode",
"<<",
"20",
")",
">>",
"20",
";",
"sh2",
"->",
"ea",
"=",
"(",
"desc",
"->",
"pc",
"+",
"2",
")",
"+",
"disp",
"*",
"2",
"+",
"2",
";",
"generate_update_cycles",
"(",
"sh2",
",",
"block",
",",
"compiler",
",",
"IMM",
"(",
"sh2",
"->",
"ea",
")",
",",
"TRUE",
")",
";",
"UML_HASHJMP",
"(",
"block",
",",
"IMM",
"(",
"0",
")",
",",
"IMM",
"(",
"sh2",
"->",
"ea",
")",
",",
"sh2",
"->",
"nocode",
")",
";",
"return",
"TRUE",
";",
"case",
"11",
":",
"UML_ADD",
"(",
"block",
",",
"MEM",
"(",
"&",
"sh2",
"->",
"pr",
")",
",",
"IMM",
"(",
"desc",
"->",
"pc",
")",
",",
"IMM",
"(",
"4",
")",
")",
";",
"generate_delay_slot",
"(",
"sh2",
",",
"block",
",",
"compiler",
",",
"desc",
")",
";",
"disp",
"=",
"(",
"(",
"INT32",
")",
"opcode",
"<<",
"20",
")",
">>",
"20",
";",
"sh2",
"->",
"ea",
"=",
"(",
"desc",
"->",
"pc",
"+",
"2",
")",
"+",
"disp",
"*",
"2",
"+",
"2",
";",
"generate_update_cycles",
"(",
"sh2",
",",
"block",
",",
"compiler",
",",
"IMM",
"(",
"sh2",
"->",
"ea",
")",
",",
"TRUE",
")",
";",
"UML_HASHJMP",
"(",
"block",
",",
"IMM",
"(",
"0",
")",
",",
"IMM",
"(",
"sh2",
"->",
"ea",
")",
",",
"sh2",
"->",
"nocode",
")",
";",
"return",
"TRUE",
";",
"case",
"12",
":",
"return",
"generate_group_12",
"(",
"sh2",
",",
"block",
",",
"compiler",
",",
"desc",
",",
"opcode",
",",
"in_delay_slot",
")",
";",
"case",
"13",
":",
"scratch",
"=",
"(",
"(",
"desc",
"->",
"pc",
"+",
"4",
")",
"&",
"~",
"3",
")",
"+",
"(",
"(",
"opcode",
"&",
"0xff",
")",
"*",
"4",
")",
";",
"if",
"(",
"sh2",
"->",
"drcoptions",
"&",
"SH2DRC_STRICT_PCREL",
")",
"{",
"UML_MOV",
"(",
"block",
",",
"IREG",
"(",
"0",
")",
",",
"IMM",
"(",
"scratch",
")",
")",
";",
"UML_CALLH",
"(",
"block",
",",
"sh2",
"->",
"read32",
")",
";",
"UML_MOV",
"(",
"block",
",",
"R32",
"(",
"Rn",
")",
",",
"IREG",
"(",
"0",
")",
")",
";",
"}",
"else",
"{",
"scratch2",
"=",
"RL",
"(",
"sh2",
",",
"scratch",
")",
";",
"UML_MOV",
"(",
"block",
",",
"R32",
"(",
"Rn",
")",
",",
"IMM",
"(",
"scratch2",
")",
")",
";",
"}",
"if",
"(",
"!",
"in_delay_slot",
")",
"generate_update_cycles",
"(",
"sh2",
",",
"block",
",",
"compiler",
",",
"IMM",
"(",
"desc",
"->",
"pc",
"+",
"2",
")",
",",
"TRUE",
")",
";",
"return",
"TRUE",
";",
"case",
"14",
":",
"scratch",
"=",
"opcode",
"&",
"0xff",
";",
"scratch2",
"=",
"(",
"UINT32",
")",
"(",
"INT32",
")",
"(",
"INT16",
")",
"(",
"INT8",
")",
"scratch",
";",
"UML_MOV",
"(",
"block",
",",
"R32",
"(",
"Rn",
")",
",",
"IMM",
"(",
"scratch2",
")",
")",
";",
"return",
"TRUE",
";",
"case",
"15",
":",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}"
] | generate_opcode - generate code for a specific
opcode | [
"generate_opcode",
"-",
"generate",
"code",
"for",
"a",
"specific",
"opcode"
] | [
"// MOVLS4\r",
"// add r0, Rn, scratch\r",
"// mov r1, Rm\r",
"// set ea for debug\r",
"// MOVLL4\r",
"// add r0, Rm, scratch\r",
"// set ea for debug\r",
"// call read32\r",
"// mov Rn, r0\r",
"// ADDI\r",
"// add Rn, Rn, scratch2\r",
"// MOVWI\r",
"// mov r0, scratch\r",
"// set ea for debug\r",
"// read16(r0, r1)\r",
"// sext Rn, r0, WORD\r",
"// mov Rn, scratch2\r",
"// BRA\r",
"// sh2->ea = pc+4 + disp*2 + 2\r",
"// <subtract cycles>\r",
"// hashjmp sh2->ea\r",
"// BSR\r",
"// panicstr @ 403da22 relies on the delay slot clobbering the PR set by a BSR, so\r",
"// do this before running the delay slot\r",
"// add sh2->pr, desc->pc, #4 (skip the current insn & delay slot)\r",
"// sh2->ea = pc+4 + disp*2 + 2\r",
"// <subtract cycles>\r",
"// hashjmp sh2->ea\r",
"// MOVLI\r",
"// mov r0, scratch\r",
"// read32(r0, r1)\r",
"// mov Rn, r0\r",
"// mov Rn, scratch2\r",
"// MOVI\r",
"// NOP\r"
] | [
{
"param": "sh2",
"type": "sh2_state"
},
{
"param": "block",
"type": "drcuml_block"
},
{
"param": "compiler",
"type": "compiler_state"
},
{
"param": "desc",
"type": "opcode_desc"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sh2",
"type": "sh2_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": []
} |
908ba337e95781df892f5f60b9b28b6f64a544d5 | lofunz/mieme | Reloaded/trunk/src/emu/cpu/sh2/sh2drc.c | [
"Unlicense"
] | C | sh2drc_add_pcflush | void | void sh2drc_add_pcflush(running_device *device, offs_t address)
{
sh2_state *sh2 = get_safe_token(device);
if (sh2->pcfsel < ARRAY_LENGTH(sh2->pcflushes))
sh2->pcflushes[sh2->pcfsel++] = address;
} | /*-------------------------------------------------
sh2drc_add_pcflush - add a new address where
the PC must be flushed for speedups to work
-------------------------------------------------*/ | add a new address where
the PC must be flushed for speedups to work | [
"add",
"a",
"new",
"address",
"where",
"the",
"PC",
"must",
"be",
"flushed",
"for",
"speedups",
"to",
"work"
] | void sh2drc_add_pcflush(running_device *device, offs_t address)
{
sh2_state *sh2 = get_safe_token(device);
if (sh2->pcfsel < ARRAY_LENGTH(sh2->pcflushes))
sh2->pcflushes[sh2->pcfsel++] = address;
} | [
"void",
"sh2drc_add_pcflush",
"(",
"running_device",
"*",
"device",
",",
"offs_t",
"address",
")",
"{",
"sh2_state",
"*",
"sh2",
"=",
"get_safe_token",
"(",
"device",
")",
";",
"if",
"(",
"sh2",
"->",
"pcfsel",
"<",
"ARRAY_LENGTH",
"(",
"sh2",
"->",
"pcflushes",
")",
")",
"sh2",
"->",
"pcflushes",
"[",
"sh2",
"->",
"pcfsel",
"++",
"]",
"=",
"address",
";",
"}"
] | sh2drc_add_pcflush - add a new address where
the PC must be flushed for speedups to work | [
"sh2drc_add_pcflush",
"-",
"add",
"a",
"new",
"address",
"where",
"the",
"PC",
"must",
"be",
"flushed",
"for",
"speedups",
"to",
"work"
] | [] | [
{
"param": "device",
"type": "running_device"
},
{
"param": "address",
"type": "offs_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "device",
"type": "running_device",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "address",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6b3f3a42553d6602ab7cfadd1cc1914206d0a431 | lofunz/mieme | Reloaded/trunk/src/mame/machine/snesdsp1.c | [
"Unlicense"
] | C | dsp1_fsm_step | void | static void dsp1_fsm_step( UINT8 read, UINT8 *data )
{
if (0 == (dsp1_state.Sr & RQM))
return;
// Now RQM would be cleared; however, as this code is not to be used in
// a multithread environment, we will simply fake RQM operation.
// (The only exception would be Op1A's freeze.)
// binding
if (read)
{
if (dsp1_state.Sr & DRS)
*data = (UINT8)(dsp1_state.Dr >> 8);
else
*data = (UINT8)(dsp1_state.Dr);
}
else
{
if (dsp1_state.Sr & DRS)
{
dsp1_state.Dr &= 0x00ff;
dsp1_state.Dr |= *data << 8;
}
else
{
dsp1_state.Dr &= 0xff00;
dsp1_state.Dr |= *data;
}
}
switch (dsp1_state.FsmMajorState)
{
case WAIT_COMMAND:
dsp1_state.Command = (UINT8)(dsp1_state.Dr);
if (!(dsp1_state.Command & 0xc0)) // valid command?
{
switch(dsp1_state.Command)
{
// freeze cases
case 0x1a:
case 0x2a:
case 0x3a:
dsp1_state.Freeze = TRUE;
break;
// normal cases
default:
dsp1_state.DataCounter = 0;
dsp1_state.FsmMajorState = READ_DATA;
dsp1_state.Sr &= ~DRC;
break;
}
}
break;
case READ_DATA:
dsp1_state.Sr ^= DRS;
if (!(dsp1_state.Sr & DRS))
{
dsp1_state.ReadBuffer[dsp1_state.DataCounter++] = (INT16)(dsp1_state.Dr);
if (dsp1_state.DataCounter >= mCommandTable[dsp1_state.Command].reads)
{
(*mCommandTable[dsp1_state.Command].callback)(dsp1_state.ReadBuffer, dsp1_state.WriteBuffer);
if (0 != mCommandTable[dsp1_state.Command].writes) // any output?
{
dsp1_state.DataCounter = 0;
dsp1_state.Dr = (UINT16)(dsp1_state.WriteBuffer[dsp1_state.DataCounter]);
dsp1_state.FsmMajorState = WRITE_DATA;
}
else
{
dsp1_state.Dr = 0x0080; // valid command completion
dsp1_state.FsmMajorState = WAIT_COMMAND;
dsp1_state.Sr |= DRC;
}
}
}
break;
case WRITE_DATA:
dsp1_state.Sr ^= DRS;
if (!(dsp1_state.Sr & DRS))
{
++dsp1_state.DataCounter;
if (dsp1_state.DataCounter >= mCommandTable[dsp1_state.Command].writes)
{
if ((dsp1_state.Command == 0x0a) && (dsp1_state.Dr != 0x8000))
{
// works in continuous mode
dsp1_state.ReadBuffer[0]++; // next raster line
(*mCommandTable[dsp1_state.Command].callback)(dsp1_state.ReadBuffer, dsp1_state.WriteBuffer);
dsp1_state.DataCounter = 0;
dsp1_state.Dr = (UINT16)(dsp1_state.WriteBuffer[dsp1_state.DataCounter]);
}
else
{
dsp1_state.Dr = 0x0080; // valid command completion
dsp1_state.FsmMajorState = WAIT_COMMAND;
dsp1_state.Sr |= DRC;
}
}
else
{
dsp1_state.Dr = (UINT16)(dsp1_state.WriteBuffer[dsp1_state.DataCounter]);
}
}
break;
}
// Now RQM would be set (except when executing Op1A -command equals 0x1a, 0x2a or 0x3a-).
if (dsp1_state.Freeze)
dsp1_state.Sr &= ~RQM;
} | // Though the DSP-1 is unaware of the type of operation (read or write)
// we need to know what is being done by the program, as the class
// is responsible for maintaining the binding between the
// "external" and "internal" representations of the DR (data register).
| Though the DSP-1 is unaware of the type of operation (read or write)
we need to know what is being done by the program, as the class
is responsible for maintaining the binding between the
"external" and "internal" representations of the DR (data register). | [
"Though",
"the",
"DSP",
"-",
"1",
"is",
"unaware",
"of",
"the",
"type",
"of",
"operation",
"(",
"read",
"or",
"write",
")",
"we",
"need",
"to",
"know",
"what",
"is",
"being",
"done",
"by",
"the",
"program",
"as",
"the",
"class",
"is",
"responsible",
"for",
"maintaining",
"the",
"binding",
"between",
"the",
"\"",
"external",
"\"",
"and",
"\"",
"internal",
"\"",
"representations",
"of",
"the",
"DR",
"(",
"data",
"register",
")",
"."
] | static void dsp1_fsm_step( UINT8 read, UINT8 *data )
{
if (0 == (dsp1_state.Sr & RQM))
return;
if (read)
{
if (dsp1_state.Sr & DRS)
*data = (UINT8)(dsp1_state.Dr >> 8);
else
*data = (UINT8)(dsp1_state.Dr);
}
else
{
if (dsp1_state.Sr & DRS)
{
dsp1_state.Dr &= 0x00ff;
dsp1_state.Dr |= *data << 8;
}
else
{
dsp1_state.Dr &= 0xff00;
dsp1_state.Dr |= *data;
}
}
switch (dsp1_state.FsmMajorState)
{
case WAIT_COMMAND:
dsp1_state.Command = (UINT8)(dsp1_state.Dr);
if (!(dsp1_state.Command & 0xc0))
{
switch(dsp1_state.Command)
{
case 0x1a:
case 0x2a:
case 0x3a:
dsp1_state.Freeze = TRUE;
break;
default:
dsp1_state.DataCounter = 0;
dsp1_state.FsmMajorState = READ_DATA;
dsp1_state.Sr &= ~DRC;
break;
}
}
break;
case READ_DATA:
dsp1_state.Sr ^= DRS;
if (!(dsp1_state.Sr & DRS))
{
dsp1_state.ReadBuffer[dsp1_state.DataCounter++] = (INT16)(dsp1_state.Dr);
if (dsp1_state.DataCounter >= mCommandTable[dsp1_state.Command].reads)
{
(*mCommandTable[dsp1_state.Command].callback)(dsp1_state.ReadBuffer, dsp1_state.WriteBuffer);
if (0 != mCommandTable[dsp1_state.Command].writes)
{
dsp1_state.DataCounter = 0;
dsp1_state.Dr = (UINT16)(dsp1_state.WriteBuffer[dsp1_state.DataCounter]);
dsp1_state.FsmMajorState = WRITE_DATA;
}
else
{
dsp1_state.Dr = 0x0080;
dsp1_state.FsmMajorState = WAIT_COMMAND;
dsp1_state.Sr |= DRC;
}
}
}
break;
case WRITE_DATA:
dsp1_state.Sr ^= DRS;
if (!(dsp1_state.Sr & DRS))
{
++dsp1_state.DataCounter;
if (dsp1_state.DataCounter >= mCommandTable[dsp1_state.Command].writes)
{
if ((dsp1_state.Command == 0x0a) && (dsp1_state.Dr != 0x8000))
{
dsp1_state.ReadBuffer[0]++;
(*mCommandTable[dsp1_state.Command].callback)(dsp1_state.ReadBuffer, dsp1_state.WriteBuffer);
dsp1_state.DataCounter = 0;
dsp1_state.Dr = (UINT16)(dsp1_state.WriteBuffer[dsp1_state.DataCounter]);
}
else
{
dsp1_state.Dr = 0x0080;
dsp1_state.FsmMajorState = WAIT_COMMAND;
dsp1_state.Sr |= DRC;
}
}
else
{
dsp1_state.Dr = (UINT16)(dsp1_state.WriteBuffer[dsp1_state.DataCounter]);
}
}
break;
}
if (dsp1_state.Freeze)
dsp1_state.Sr &= ~RQM;
} | [
"static",
"void",
"dsp1_fsm_step",
"(",
"UINT8",
"read",
",",
"UINT8",
"*",
"data",
")",
"{",
"if",
"(",
"0",
"==",
"(",
"dsp1_state",
".",
"Sr",
"&",
"RQM",
")",
")",
"return",
";",
"if",
"(",
"read",
")",
"{",
"if",
"(",
"dsp1_state",
".",
"Sr",
"&",
"DRS",
")",
"*",
"data",
"=",
"(",
"UINT8",
")",
"(",
"dsp1_state",
".",
"Dr",
">>",
"8",
")",
";",
"else",
"*",
"data",
"=",
"(",
"UINT8",
")",
"(",
"dsp1_state",
".",
"Dr",
")",
";",
"}",
"else",
"{",
"if",
"(",
"dsp1_state",
".",
"Sr",
"&",
"DRS",
")",
"{",
"dsp1_state",
".",
"Dr",
"&=",
"0x00ff",
";",
"dsp1_state",
".",
"Dr",
"|=",
"*",
"data",
"<<",
"8",
";",
"}",
"else",
"{",
"dsp1_state",
".",
"Dr",
"&=",
"0xff00",
";",
"dsp1_state",
".",
"Dr",
"|=",
"*",
"data",
";",
"}",
"}",
"switch",
"(",
"dsp1_state",
".",
"FsmMajorState",
")",
"{",
"case",
"WAIT_COMMAND",
":",
"dsp1_state",
".",
"Command",
"=",
"(",
"UINT8",
")",
"(",
"dsp1_state",
".",
"Dr",
")",
";",
"if",
"(",
"!",
"(",
"dsp1_state",
".",
"Command",
"&",
"0xc0",
")",
")",
"{",
"switch",
"(",
"dsp1_state",
".",
"Command",
")",
"{",
"case",
"0x1a",
":",
"case",
"0x2a",
":",
"case",
"0x3a",
":",
"dsp1_state",
".",
"Freeze",
"=",
"TRUE",
";",
"break",
";",
"default",
":",
"dsp1_state",
".",
"DataCounter",
"=",
"0",
";",
"dsp1_state",
".",
"FsmMajorState",
"=",
"READ_DATA",
";",
"dsp1_state",
".",
"Sr",
"&=",
"~",
"DRC",
";",
"break",
";",
"}",
"}",
"break",
";",
"case",
"READ_DATA",
":",
"dsp1_state",
".",
"Sr",
"^=",
"DRS",
";",
"if",
"(",
"!",
"(",
"dsp1_state",
".",
"Sr",
"&",
"DRS",
")",
")",
"{",
"dsp1_state",
".",
"ReadBuffer",
"[",
"dsp1_state",
".",
"DataCounter",
"++",
"]",
"=",
"(",
"INT16",
")",
"(",
"dsp1_state",
".",
"Dr",
")",
";",
"if",
"(",
"dsp1_state",
".",
"DataCounter",
">=",
"mCommandTable",
"[",
"dsp1_state",
".",
"Command",
"]",
".",
"reads",
")",
"{",
"(",
"*",
"mCommandTable",
"[",
"dsp1_state",
".",
"Command",
"]",
".",
"callback",
")",
"(",
"dsp1_state",
".",
"ReadBuffer",
",",
"dsp1_state",
".",
"WriteBuffer",
")",
";",
"if",
"(",
"0",
"!=",
"mCommandTable",
"[",
"dsp1_state",
".",
"Command",
"]",
".",
"writes",
")",
"{",
"dsp1_state",
".",
"DataCounter",
"=",
"0",
";",
"dsp1_state",
".",
"Dr",
"=",
"(",
"UINT16",
")",
"(",
"dsp1_state",
".",
"WriteBuffer",
"[",
"dsp1_state",
".",
"DataCounter",
"]",
")",
";",
"dsp1_state",
".",
"FsmMajorState",
"=",
"WRITE_DATA",
";",
"}",
"else",
"{",
"dsp1_state",
".",
"Dr",
"=",
"0x0080",
";",
"dsp1_state",
".",
"FsmMajorState",
"=",
"WAIT_COMMAND",
";",
"dsp1_state",
".",
"Sr",
"|=",
"DRC",
";",
"}",
"}",
"}",
"break",
";",
"case",
"WRITE_DATA",
":",
"dsp1_state",
".",
"Sr",
"^=",
"DRS",
";",
"if",
"(",
"!",
"(",
"dsp1_state",
".",
"Sr",
"&",
"DRS",
")",
")",
"{",
"++",
"dsp1_state",
".",
"DataCounter",
";",
"if",
"(",
"dsp1_state",
".",
"DataCounter",
">=",
"mCommandTable",
"[",
"dsp1_state",
".",
"Command",
"]",
".",
"writes",
")",
"{",
"if",
"(",
"(",
"dsp1_state",
".",
"Command",
"==",
"0x0a",
")",
"&&",
"(",
"dsp1_state",
".",
"Dr",
"!=",
"0x8000",
")",
")",
"{",
"dsp1_state",
".",
"ReadBuffer",
"[",
"0",
"]",
"++",
";",
"(",
"*",
"mCommandTable",
"[",
"dsp1_state",
".",
"Command",
"]",
".",
"callback",
")",
"(",
"dsp1_state",
".",
"ReadBuffer",
",",
"dsp1_state",
".",
"WriteBuffer",
")",
";",
"dsp1_state",
".",
"DataCounter",
"=",
"0",
";",
"dsp1_state",
".",
"Dr",
"=",
"(",
"UINT16",
")",
"(",
"dsp1_state",
".",
"WriteBuffer",
"[",
"dsp1_state",
".",
"DataCounter",
"]",
")",
";",
"}",
"else",
"{",
"dsp1_state",
".",
"Dr",
"=",
"0x0080",
";",
"dsp1_state",
".",
"FsmMajorState",
"=",
"WAIT_COMMAND",
";",
"dsp1_state",
".",
"Sr",
"|=",
"DRC",
";",
"}",
"}",
"else",
"{",
"dsp1_state",
".",
"Dr",
"=",
"(",
"UINT16",
")",
"(",
"dsp1_state",
".",
"WriteBuffer",
"[",
"dsp1_state",
".",
"DataCounter",
"]",
")",
";",
"}",
"}",
"break",
";",
"}",
"if",
"(",
"dsp1_state",
".",
"Freeze",
")",
"dsp1_state",
".",
"Sr",
"&=",
"~",
"RQM",
";",
"}"
] | Though the DSP-1 is unaware of the type of operation (read or write)
we need to know what is being done by the program, as the class
is responsible for maintaining the binding between the
"external" and "internal" representations of the DR (data register). | [
"Though",
"the",
"DSP",
"-",
"1",
"is",
"unaware",
"of",
"the",
"type",
"of",
"operation",
"(",
"read",
"or",
"write",
")",
"we",
"need",
"to",
"know",
"what",
"is",
"being",
"done",
"by",
"the",
"program",
"as",
"the",
"class",
"is",
"responsible",
"for",
"maintaining",
"the",
"binding",
"between",
"the",
"\"",
"external",
"\"",
"and",
"\"",
"internal",
"\"",
"representations",
"of",
"the",
"DR",
"(",
"data",
"register",
")",
"."
] | [
"// Now RQM would be cleared; however, as this code is not to be used in\r",
"// a multithread environment, we will simply fake RQM operation.\r",
"// (The only exception would be Op1A's freeze.)\r",
"// binding\r",
"// valid command?\r",
"// freeze cases\r",
"// normal cases\r",
"// any output?\r",
"// valid command completion\r",
"// works in continuous mode\r",
"// next raster line\r",
"// valid command completion\r",
"// Now RQM would be set (except when executing Op1A -command equals 0x1a, 0x2a or 0x3a-).\r"
] | [
{
"param": "read",
"type": "UINT8"
},
{
"param": "data",
"type": "UINT8"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "read",
"type": "UINT8",
"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": []
} |
6b3f3a42553d6602ab7cfadd1cc1914206d0a431 | lofunz/mieme | Reloaded/trunk/src/mame/machine/snesdsp1.c | [
"Unlicense"
] | C | dsp1_inverse | void | static void dsp1_inverse( INT16 *input, INT16 *output )
{
INT16 Coefficient = input[0];
INT16 Exponent = input[1];
INT16* iCoefficient = &output[0];
INT16* iExponent = &output[1];
inverse(Coefficient, Exponent, iCoefficient, iExponent);
} | // This command determines the inverse of a floating point decimal number.
| This command determines the inverse of a floating point decimal number. | [
"This",
"command",
"determines",
"the",
"inverse",
"of",
"a",
"floating",
"point",
"decimal",
"number",
"."
] | static void dsp1_inverse( INT16 *input, INT16 *output )
{
INT16 Coefficient = input[0];
INT16 Exponent = input[1];
INT16* iCoefficient = &output[0];
INT16* iExponent = &output[1];
inverse(Coefficient, Exponent, iCoefficient, iExponent);
} | [
"static",
"void",
"dsp1_inverse",
"(",
"INT16",
"*",
"input",
",",
"INT16",
"*",
"output",
")",
"{",
"INT16",
"Coefficient",
"=",
"input",
"[",
"0",
"]",
";",
"INT16",
"Exponent",
"=",
"input",
"[",
"1",
"]",
";",
"INT16",
"*",
"iCoefficient",
"=",
"&",
"output",
"[",
"0",
"]",
";",
"INT16",
"*",
"iExponent",
"=",
"&",
"output",
"[",
"1",
"]",
";",
"inverse",
"(",
"Coefficient",
",",
"Exponent",
",",
"iCoefficient",
",",
"iExponent",
")",
";",
"}"
] | This command determines the inverse of a floating point decimal number. | [
"This",
"command",
"determines",
"the",
"inverse",
"of",
"a",
"floating",
"point",
"decimal",
"number",
"."
] | [] | [
{
"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_triangle | void | static void dsp1_triangle( INT16 *input, INT16 *output )
{
INT16 Angle = input[0];
INT16 Radius = input[1];
INT16* Y = &output[0];
INT16* X = &output[1];
*Y = dsp1_sin(Angle) * Radius >> 15;
*X = dsp1_cos(Angle) * Radius >> 15;
} | // Vector component calculation. Determines the X and Y components for a
// two-dimensional vector whose size and direction is known.
// Y = Radius * sin(Angle)
// X = Radius * cos(Angle)
| Vector component calculation. Determines the X and Y components for a
two-dimensional vector whose size and direction is known.
Y = Radius * sin(Angle)
X = Radius * cos(Angle) | [
"Vector",
"component",
"calculation",
".",
"Determines",
"the",
"X",
"and",
"Y",
"components",
"for",
"a",
"two",
"-",
"dimensional",
"vector",
"whose",
"size",
"and",
"direction",
"is",
"known",
".",
"Y",
"=",
"Radius",
"*",
"sin",
"(",
"Angle",
")",
"X",
"=",
"Radius",
"*",
"cos",
"(",
"Angle",
")"
] | static void dsp1_triangle( INT16 *input, INT16 *output )
{
INT16 Angle = input[0];
INT16 Radius = input[1];
INT16* Y = &output[0];
INT16* X = &output[1];
*Y = dsp1_sin(Angle) * Radius >> 15;
*X = dsp1_cos(Angle) * Radius >> 15;
} | [
"static",
"void",
"dsp1_triangle",
"(",
"INT16",
"*",
"input",
",",
"INT16",
"*",
"output",
")",
"{",
"INT16",
"Angle",
"=",
"input",
"[",
"0",
"]",
";",
"INT16",
"Radius",
"=",
"input",
"[",
"1",
"]",
";",
"INT16",
"*",
"Y",
"=",
"&",
"output",
"[",
"0",
"]",
";",
"INT16",
"*",
"X",
"=",
"&",
"output",
"[",
"1",
"]",
";",
"*",
"Y",
"=",
"dsp1_sin",
"(",
"Angle",
")",
"*",
"Radius",
">>",
"15",
";",
"*",
"X",
"=",
"dsp1_cos",
"(",
"Angle",
")",
"*",
"Radius",
">>",
"15",
";",
"}"
] | Vector component calculation. | [
"Vector",
"component",
"calculation",
"."
] | [] | [
{
"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_range | void | static void dsp1_range( INT16 *input, INT16 *output )
{
INT16 X = input[0];
INT16 Y = input[1];
INT16 Z = input[2];
INT16 Radius = input[3];
INT16* Range = &output[0];
*Range = (X * X + Y * Y + Z * Z - Radius * Radius) >> 15;
} | // Vector size comparison. This command compares the size of the vector (X,Y,Z) and the distance (R)
// from a particular point, and so may be used to determine if a point is within the sphere or radius R.
// The output is D = X^2+Y^2+Z^2-R^2
| Vector size comparison. This command compares the size of the vector (X,Y,Z) and the distance (R)
from a particular point, and so may be used to determine if a point is within the sphere or radius R. | [
"Vector",
"size",
"comparison",
".",
"This",
"command",
"compares",
"the",
"size",
"of",
"the",
"vector",
"(",
"X",
"Y",
"Z",
")",
"and",
"the",
"distance",
"(",
"R",
")",
"from",
"a",
"particular",
"point",
"and",
"so",
"may",
"be",
"used",
"to",
"determine",
"if",
"a",
"point",
"is",
"within",
"the",
"sphere",
"or",
"radius",
"R",
"."
] | static void dsp1_range( INT16 *input, INT16 *output )
{
INT16 X = input[0];
INT16 Y = input[1];
INT16 Z = input[2];
INT16 Radius = input[3];
INT16* Range = &output[0];
*Range = (X * X + Y * Y + Z * Z - Radius * Radius) >> 15;
} | [
"static",
"void",
"dsp1_range",
"(",
"INT16",
"*",
"input",
",",
"INT16",
"*",
"output",
")",
"{",
"INT16",
"X",
"=",
"input",
"[",
"0",
"]",
";",
"INT16",
"Y",
"=",
"input",
"[",
"1",
"]",
";",
"INT16",
"Z",
"=",
"input",
"[",
"2",
"]",
";",
"INT16",
"Radius",
"=",
"input",
"[",
"3",
"]",
";",
"INT16",
"*",
"Range",
"=",
"&",
"output",
"[",
"0",
"]",
";",
"*",
"Range",
"=",
"(",
"X",
"*",
"X",
"+",
"Y",
"*",
"Y",
"+",
"Z",
"*",
"Z",
"-",
"Radius",
"*",
"Radius",
")",
">>",
"15",
";",
"}"
] | Vector size comparison. | [
"Vector",
"size",
"comparison",
"."
] | [] | [
{
"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_attitudeB | void | static void dsp1_attitudeB( INT16 *input, INT16 *output )
{
INT16 S = input[0];
INT16 Rz = input[1];
INT16 Ry = input[2];
INT16 Rx = input[3];
INT16 SinRz = dsp1_sin(Rz);
INT16 CosRz = dsp1_cos(Rz);
INT16 SinRy = dsp1_sin(Ry);
INT16 CosRy = dsp1_cos(Ry);
INT16 SinRx = dsp1_sin(Rx);
INT16 CosRx = dsp1_cos(Rx);
S >>= 1;
dsp1_state.shared.MatrixB[0][0] = (S * CosRz >> 15) * CosRy >> 15;
dsp1_state.shared.MatrixB[0][1] = ((S * SinRz >> 15) * CosRx >> 15) + (((S * CosRz >> 15) * SinRx >> 15) * SinRy >> 15);
dsp1_state.shared.MatrixB[0][2] = ((S * SinRz >> 15) * SinRx >> 15) - (((S * CosRz >> 15) * CosRx >> 15) * SinRy >> 15);
dsp1_state.shared.MatrixB[1][0] = -((S * SinRz >> 15) * CosRy >> 15);
dsp1_state.shared.MatrixB[1][1] = ((S * CosRz >> 15) * CosRx >> 15) - (((S * SinRz >> 15) * SinRx >> 15) * SinRy >> 15);
dsp1_state.shared.MatrixB[1][2] = ((S * CosRz >> 15) * SinRx >> 15) + (((S * SinRz >> 15) * CosRx >> 15) * SinRy >> 15);
dsp1_state.shared.MatrixB[2][0] = S * SinRy >> 15;
dsp1_state.shared.MatrixB[2][1] = -((S * SinRx >> 15) * CosRy >> 15);
dsp1_state.shared.MatrixB[2][2] = (S * CosRx >> 15) * CosRy >> 15;
} | // Same than 'attitudeA', but with a difference attitude matrix (matrixB)
| Same than 'attitudeA', but with a difference attitude matrix (matrixB) | [
"Same",
"than",
"'",
"attitudeA",
"'",
"but",
"with",
"a",
"difference",
"attitude",
"matrix",
"(",
"matrixB",
")"
] | static void dsp1_attitudeB( INT16 *input, INT16 *output )
{
INT16 S = input[0];
INT16 Rz = input[1];
INT16 Ry = input[2];
INT16 Rx = input[3];
INT16 SinRz = dsp1_sin(Rz);
INT16 CosRz = dsp1_cos(Rz);
INT16 SinRy = dsp1_sin(Ry);
INT16 CosRy = dsp1_cos(Ry);
INT16 SinRx = dsp1_sin(Rx);
INT16 CosRx = dsp1_cos(Rx);
S >>= 1;
dsp1_state.shared.MatrixB[0][0] = (S * CosRz >> 15) * CosRy >> 15;
dsp1_state.shared.MatrixB[0][1] = ((S * SinRz >> 15) * CosRx >> 15) + (((S * CosRz >> 15) * SinRx >> 15) * SinRy >> 15);
dsp1_state.shared.MatrixB[0][2] = ((S * SinRz >> 15) * SinRx >> 15) - (((S * CosRz >> 15) * CosRx >> 15) * SinRy >> 15);
dsp1_state.shared.MatrixB[1][0] = -((S * SinRz >> 15) * CosRy >> 15);
dsp1_state.shared.MatrixB[1][1] = ((S * CosRz >> 15) * CosRx >> 15) - (((S * SinRz >> 15) * SinRx >> 15) * SinRy >> 15);
dsp1_state.shared.MatrixB[1][2] = ((S * CosRz >> 15) * SinRx >> 15) + (((S * SinRz >> 15) * CosRx >> 15) * SinRy >> 15);
dsp1_state.shared.MatrixB[2][0] = S * SinRy >> 15;
dsp1_state.shared.MatrixB[2][1] = -((S * SinRx >> 15) * CosRy >> 15);
dsp1_state.shared.MatrixB[2][2] = (S * CosRx >> 15) * CosRy >> 15;
} | [
"static",
"void",
"dsp1_attitudeB",
"(",
"INT16",
"*",
"input",
",",
"INT16",
"*",
"output",
")",
"{",
"INT16",
"S",
"=",
"input",
"[",
"0",
"]",
";",
"INT16",
"Rz",
"=",
"input",
"[",
"1",
"]",
";",
"INT16",
"Ry",
"=",
"input",
"[",
"2",
"]",
";",
"INT16",
"Rx",
"=",
"input",
"[",
"3",
"]",
";",
"INT16",
"SinRz",
"=",
"dsp1_sin",
"(",
"Rz",
")",
";",
"INT16",
"CosRz",
"=",
"dsp1_cos",
"(",
"Rz",
")",
";",
"INT16",
"SinRy",
"=",
"dsp1_sin",
"(",
"Ry",
")",
";",
"INT16",
"CosRy",
"=",
"dsp1_cos",
"(",
"Ry",
")",
";",
"INT16",
"SinRx",
"=",
"dsp1_sin",
"(",
"Rx",
")",
";",
"INT16",
"CosRx",
"=",
"dsp1_cos",
"(",
"Rx",
")",
";",
"S",
">>=",
"1",
";",
"dsp1_state",
".",
"shared",
".",
"MatrixB",
"[",
"0",
"]",
"[",
"0",
"]",
"=",
"(",
"S",
"*",
"CosRz",
">>",
"15",
")",
"*",
"CosRy",
">>",
"15",
";",
"dsp1_state",
".",
"shared",
".",
"MatrixB",
"[",
"0",
"]",
"[",
"1",
"]",
"=",
"(",
"(",
"S",
"*",
"SinRz",
">>",
"15",
")",
"*",
"CosRx",
">>",
"15",
")",
"+",
"(",
"(",
"(",
"S",
"*",
"CosRz",
">>",
"15",
")",
"*",
"SinRx",
">>",
"15",
")",
"*",
"SinRy",
">>",
"15",
")",
";",
"dsp1_state",
".",
"shared",
".",
"MatrixB",
"[",
"0",
"]",
"[",
"2",
"]",
"=",
"(",
"(",
"S",
"*",
"SinRz",
">>",
"15",
")",
"*",
"SinRx",
">>",
"15",
")",
"-",
"(",
"(",
"(",
"S",
"*",
"CosRz",
">>",
"15",
")",
"*",
"CosRx",
">>",
"15",
")",
"*",
"SinRy",
">>",
"15",
")",
";",
"dsp1_state",
".",
"shared",
".",
"MatrixB",
"[",
"1",
"]",
"[",
"0",
"]",
"=",
"-",
"(",
"(",
"S",
"*",
"SinRz",
">>",
"15",
")",
"*",
"CosRy",
">>",
"15",
")",
";",
"dsp1_state",
".",
"shared",
".",
"MatrixB",
"[",
"1",
"]",
"[",
"1",
"]",
"=",
"(",
"(",
"S",
"*",
"CosRz",
">>",
"15",
")",
"*",
"CosRx",
">>",
"15",
")",
"-",
"(",
"(",
"(",
"S",
"*",
"SinRz",
">>",
"15",
")",
"*",
"SinRx",
">>",
"15",
")",
"*",
"SinRy",
">>",
"15",
")",
";",
"dsp1_state",
".",
"shared",
".",
"MatrixB",
"[",
"1",
"]",
"[",
"2",
"]",
"=",
"(",
"(",
"S",
"*",
"CosRz",
">>",
"15",
")",
"*",
"SinRx",
">>",
"15",
")",
"+",
"(",
"(",
"(",
"S",
"*",
"SinRz",
">>",
"15",
")",
"*",
"CosRx",
">>",
"15",
")",
"*",
"SinRy",
">>",
"15",
")",
";",
"dsp1_state",
".",
"shared",
".",
"MatrixB",
"[",
"2",
"]",
"[",
"0",
"]",
"=",
"S",
"*",
"SinRy",
">>",
"15",
";",
"dsp1_state",
".",
"shared",
".",
"MatrixB",
"[",
"2",
"]",
"[",
"1",
"]",
"=",
"-",
"(",
"(",
"S",
"*",
"SinRx",
">>",
"15",
")",
"*",
"CosRy",
">>",
"15",
")",
";",
"dsp1_state",
".",
"shared",
".",
"MatrixB",
"[",
"2",
"]",
"[",
"2",
"]",
"=",
"(",
"S",
"*",
"CosRx",
">>",
"15",
")",
"*",
"CosRy",
">>",
"15",
";",
"}"
] | Same than 'attitudeA', but with a difference attitude matrix (matrixB) | [
"Same",
"than",
"'",
"attitudeA",
"'",
"but",
"with",
"a",
"difference",
"attitude",
"matrix",
"(",
"matrixB",
")"
] | [] | [
{
"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_attitudeC | void | static void dsp1_attitudeC( INT16 *input, INT16 *output )
{
INT16 S = input[0];
INT16 Rz = input[1];
INT16 Ry = input[2];
INT16 Rx = input[3];
INT16 SinRz = dsp1_sin(Rz);
INT16 CosRz = dsp1_cos(Rz);
INT16 SinRy = dsp1_sin(Ry);
INT16 CosRy = dsp1_cos(Ry);
INT16 SinRx = dsp1_sin(Rx);
INT16 CosRx = dsp1_cos(Rx);
S >>= 1;
dsp1_state.shared.MatrixC[0][0] = (S * CosRz >> 15) * CosRy >> 15;
dsp1_state.shared.MatrixC[0][1] = ((S * SinRz >> 15) * CosRx >> 15) + (((S * CosRz >> 15) * SinRx >> 15) * SinRy >> 15);
dsp1_state.shared.MatrixC[0][2] = ((S * SinRz >> 15) * SinRx >> 15) - (((S * CosRz >> 15) * CosRx >> 15) * SinRy >> 15);
dsp1_state.shared.MatrixC[1][0] = -((S * SinRz >> 15) * CosRy >> 15);
dsp1_state.shared.MatrixC[1][1] = ((S * CosRz >> 15) * CosRx >> 15) - (((S * SinRz >> 15) * SinRx >> 15) * SinRy >> 15);
dsp1_state.shared.MatrixC[1][2] = ((S * CosRz >> 15) * SinRx >> 15) + (((S * SinRz >> 15) * CosRx >> 15) * SinRy >> 15);
dsp1_state.shared.MatrixC[2][0] = S * SinRy >> 15;
dsp1_state.shared.MatrixC[2][1] = -((S * SinRx >> 15) * CosRy >> 15);
dsp1_state.shared.MatrixC[2][2] = (S * CosRx >> 15) * CosRy >> 15;
} | // Same than 'attitudeA', but with a difference attitude matrix (matrixC)
| Same than 'attitudeA', but with a difference attitude matrix (matrixC) | [
"Same",
"than",
"'",
"attitudeA",
"'",
"but",
"with",
"a",
"difference",
"attitude",
"matrix",
"(",
"matrixC",
")"
] | static void dsp1_attitudeC( INT16 *input, INT16 *output )
{
INT16 S = input[0];
INT16 Rz = input[1];
INT16 Ry = input[2];
INT16 Rx = input[3];
INT16 SinRz = dsp1_sin(Rz);
INT16 CosRz = dsp1_cos(Rz);
INT16 SinRy = dsp1_sin(Ry);
INT16 CosRy = dsp1_cos(Ry);
INT16 SinRx = dsp1_sin(Rx);
INT16 CosRx = dsp1_cos(Rx);
S >>= 1;
dsp1_state.shared.MatrixC[0][0] = (S * CosRz >> 15) * CosRy >> 15;
dsp1_state.shared.MatrixC[0][1] = ((S * SinRz >> 15) * CosRx >> 15) + (((S * CosRz >> 15) * SinRx >> 15) * SinRy >> 15);
dsp1_state.shared.MatrixC[0][2] = ((S * SinRz >> 15) * SinRx >> 15) - (((S * CosRz >> 15) * CosRx >> 15) * SinRy >> 15);
dsp1_state.shared.MatrixC[1][0] = -((S * SinRz >> 15) * CosRy >> 15);
dsp1_state.shared.MatrixC[1][1] = ((S * CosRz >> 15) * CosRx >> 15) - (((S * SinRz >> 15) * SinRx >> 15) * SinRy >> 15);
dsp1_state.shared.MatrixC[1][2] = ((S * CosRz >> 15) * SinRx >> 15) + (((S * SinRz >> 15) * CosRx >> 15) * SinRy >> 15);
dsp1_state.shared.MatrixC[2][0] = S * SinRy >> 15;
dsp1_state.shared.MatrixC[2][1] = -((S * SinRx >> 15) * CosRy >> 15);
dsp1_state.shared.MatrixC[2][2] = (S * CosRx >> 15) * CosRy >> 15;
} | [
"static",
"void",
"dsp1_attitudeC",
"(",
"INT16",
"*",
"input",
",",
"INT16",
"*",
"output",
")",
"{",
"INT16",
"S",
"=",
"input",
"[",
"0",
"]",
";",
"INT16",
"Rz",
"=",
"input",
"[",
"1",
"]",
";",
"INT16",
"Ry",
"=",
"input",
"[",
"2",
"]",
";",
"INT16",
"Rx",
"=",
"input",
"[",
"3",
"]",
";",
"INT16",
"SinRz",
"=",
"dsp1_sin",
"(",
"Rz",
")",
";",
"INT16",
"CosRz",
"=",
"dsp1_cos",
"(",
"Rz",
")",
";",
"INT16",
"SinRy",
"=",
"dsp1_sin",
"(",
"Ry",
")",
";",
"INT16",
"CosRy",
"=",
"dsp1_cos",
"(",
"Ry",
")",
";",
"INT16",
"SinRx",
"=",
"dsp1_sin",
"(",
"Rx",
")",
";",
"INT16",
"CosRx",
"=",
"dsp1_cos",
"(",
"Rx",
")",
";",
"S",
">>=",
"1",
";",
"dsp1_state",
".",
"shared",
".",
"MatrixC",
"[",
"0",
"]",
"[",
"0",
"]",
"=",
"(",
"S",
"*",
"CosRz",
">>",
"15",
")",
"*",
"CosRy",
">>",
"15",
";",
"dsp1_state",
".",
"shared",
".",
"MatrixC",
"[",
"0",
"]",
"[",
"1",
"]",
"=",
"(",
"(",
"S",
"*",
"SinRz",
">>",
"15",
")",
"*",
"CosRx",
">>",
"15",
")",
"+",
"(",
"(",
"(",
"S",
"*",
"CosRz",
">>",
"15",
")",
"*",
"SinRx",
">>",
"15",
")",
"*",
"SinRy",
">>",
"15",
")",
";",
"dsp1_state",
".",
"shared",
".",
"MatrixC",
"[",
"0",
"]",
"[",
"2",
"]",
"=",
"(",
"(",
"S",
"*",
"SinRz",
">>",
"15",
")",
"*",
"SinRx",
">>",
"15",
")",
"-",
"(",
"(",
"(",
"S",
"*",
"CosRz",
">>",
"15",
")",
"*",
"CosRx",
">>",
"15",
")",
"*",
"SinRy",
">>",
"15",
")",
";",
"dsp1_state",
".",
"shared",
".",
"MatrixC",
"[",
"1",
"]",
"[",
"0",
"]",
"=",
"-",
"(",
"(",
"S",
"*",
"SinRz",
">>",
"15",
")",
"*",
"CosRy",
">>",
"15",
")",
";",
"dsp1_state",
".",
"shared",
".",
"MatrixC",
"[",
"1",
"]",
"[",
"1",
"]",
"=",
"(",
"(",
"S",
"*",
"CosRz",
">>",
"15",
")",
"*",
"CosRx",
">>",
"15",
")",
"-",
"(",
"(",
"(",
"S",
"*",
"SinRz",
">>",
"15",
")",
"*",
"SinRx",
">>",
"15",
")",
"*",
"SinRy",
">>",
"15",
")",
";",
"dsp1_state",
".",
"shared",
".",
"MatrixC",
"[",
"1",
"]",
"[",
"2",
"]",
"=",
"(",
"(",
"S",
"*",
"CosRz",
">>",
"15",
")",
"*",
"SinRx",
">>",
"15",
")",
"+",
"(",
"(",
"(",
"S",
"*",
"SinRz",
">>",
"15",
")",
"*",
"CosRx",
">>",
"15",
")",
"*",
"SinRy",
">>",
"15",
")",
";",
"dsp1_state",
".",
"shared",
".",
"MatrixC",
"[",
"2",
"]",
"[",
"0",
"]",
"=",
"S",
"*",
"SinRy",
">>",
"15",
";",
"dsp1_state",
".",
"shared",
".",
"MatrixC",
"[",
"2",
"]",
"[",
"1",
"]",
"=",
"-",
"(",
"(",
"S",
"*",
"SinRx",
">>",
"15",
")",
"*",
"CosRy",
">>",
"15",
")",
";",
"dsp1_state",
".",
"shared",
".",
"MatrixC",
"[",
"2",
"]",
"[",
"2",
"]",
"=",
"(",
"S",
"*",
"CosRx",
">>",
"15",
")",
"*",
"CosRy",
">>",
"15",
";",
"}"
] | Same than 'attitudeA', but with a difference attitude matrix (matrixC) | [
"Same",
"than",
"'",
"attitudeA",
"'",
"but",
"with",
"a",
"difference",
"attitude",
"matrix",
"(",
"matrixC",
")"
] | [] | [
{
"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_scalarA | void | static void dsp1_scalarA( INT16 *input, INT16 *output )
{
INT16 X = input[0];
INT16 Y = input[1];
INT16 Z = input[2];
INT16* S = &output[0];
*S = (X * dsp1_state.shared.MatrixA[0][0] + Y * dsp1_state.shared.MatrixA[1][0] + Z * dsp1_state.shared.MatrixA[2][0]) >> 15;
} | // This command calculates the inner product (S) of a vector (X,Y,Z) and
// the first column of MatrixA. It should be noted that that first column
// represent the global coordinates of an unity vector in the forward
// direction in the object coordinate system (coordinates (1,0,0) in the FLU
// axes system).
//
// input[0]: X ; input[1]: Y ; input[2]: Z
// &output[0]: S
| This command calculates the inner product (S) of a vector (X,Y,Z) and
the first column of MatrixA. It should be noted that that first column
represent the global coordinates of an unity vector in the forward
direction in the object coordinate system (coordinates (1,0,0) in the FLU
axes system).
| [
"This",
"command",
"calculates",
"the",
"inner",
"product",
"(",
"S",
")",
"of",
"a",
"vector",
"(",
"X",
"Y",
"Z",
")",
"and",
"the",
"first",
"column",
"of",
"MatrixA",
".",
"It",
"should",
"be",
"noted",
"that",
"that",
"first",
"column",
"represent",
"the",
"global",
"coordinates",
"of",
"an",
"unity",
"vector",
"in",
"the",
"forward",
"direction",
"in",
"the",
"object",
"coordinate",
"system",
"(",
"coordinates",
"(",
"1",
"0",
"0",
")",
"in",
"the",
"FLU",
"axes",
"system",
")",
"."
] | static void dsp1_scalarA( INT16 *input, INT16 *output )
{
INT16 X = input[0];
INT16 Y = input[1];
INT16 Z = input[2];
INT16* S = &output[0];
*S = (X * dsp1_state.shared.MatrixA[0][0] + Y * dsp1_state.shared.MatrixA[1][0] + Z * dsp1_state.shared.MatrixA[2][0]) >> 15;
} | [
"static",
"void",
"dsp1_scalarA",
"(",
"INT16",
"*",
"input",
",",
"INT16",
"*",
"output",
")",
"{",
"INT16",
"X",
"=",
"input",
"[",
"0",
"]",
";",
"INT16",
"Y",
"=",
"input",
"[",
"1",
"]",
";",
"INT16",
"Z",
"=",
"input",
"[",
"2",
"]",
";",
"INT16",
"*",
"S",
"=",
"&",
"output",
"[",
"0",
"]",
";",
"*",
"S",
"=",
"(",
"X",
"*",
"dsp1_state",
".",
"shared",
".",
"MatrixA",
"[",
"0",
"]",
"[",
"0",
"]",
"+",
"Y",
"*",
"dsp1_state",
".",
"shared",
".",
"MatrixA",
"[",
"1",
"]",
"[",
"0",
"]",
"+",
"Z",
"*",
"dsp1_state",
".",
"shared",
".",
"MatrixA",
"[",
"2",
"]",
"[",
"0",
"]",
")",
">>",
"15",
";",
"}"
] | This command calculates the inner product (S) of a vector (X,Y,Z) and
the first column of MatrixA. | [
"This",
"command",
"calculates",
"the",
"inner",
"product",
"(",
"S",
")",
"of",
"a",
"vector",
"(",
"X",
"Y",
"Z",
")",
"and",
"the",
"first",
"column",
"of",
"MatrixA",
"."
] | [] | [
{
"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": []
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.