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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f054e6ac2fe6449a9ecbfaa10b4d393e317bb448 | lofunz/mieme | Reloaded/trunk/src/mame/machine/snes7110.c | [
"Unlicense"
] | C | spc7110_update_time | void | static void spc7110_update_time(running_machine *machine, UINT8 offset)
{
system_time curtime, *systime = &curtime;
machine->current_datetime(curtime);
int update = 1;
snes_spc7110.rtc_offset += offset;
// TEST: can we go beyond 24hrs of rounding?!? I doubt it will ever go beyond 3600, but I could be wrong...
assert(snes_spc7110.rtc_offset < 86400);
/* do not update if CR0 or CR2 timer disable flags are set */
if ((snes_spc7110.rtc_ram[13] & 0x01) || (snes_spc7110.rtc_ram[15] & 0x03))
update = 0;
if (update)
{
/* update time with offset, assuming offset < 3600s */
UINT8 second = systime->local_time.second;
UINT8 minute = systime->local_time.minute;
UINT8 hour = systime->local_time.hour;
UINT8 mday = systime->local_time.mday;
while (snes_spc7110.rtc_offset >= 3600)
{
snes_spc7110.rtc_offset -= 3600;
hour++;
if (hour == 24)
{
mday++;
hour = 0;
}
}
while (snes_spc7110.rtc_offset >= 60)
{
snes_spc7110.rtc_offset -= 60;
minute++;
if (minute == 60)
{
hour++;
minute = 0;
}
}
while (snes_spc7110.rtc_offset)
{
snes_spc7110.rtc_offset -= 1;
second++;
if (second == 60)
{
minute++;
second = 0;
}
}
snes_spc7110.rtc_ram[0] = second % 10;
snes_spc7110.rtc_ram[1] = second / 10;
snes_spc7110.rtc_ram[2] = minute % 10;
snes_spc7110.rtc_ram[3] = minute / 10;
snes_spc7110.rtc_ram[4] = hour % 10;
snes_spc7110.rtc_ram[5] = hour / 10;
snes_spc7110.rtc_ram[6] = mday % 10;
snes_spc7110.rtc_ram[7] = mday / 10;
snes_spc7110.rtc_ram[8] = systime->local_time.month % 10;
snes_spc7110.rtc_ram[9] = systime->local_time.month / 10;
snes_spc7110.rtc_ram[8] = systime->local_time.month;
snes_spc7110.rtc_ram[10] = (systime->local_time.year - 1900) % 10;
snes_spc7110.rtc_ram[11] = ((systime->local_time.year - 1900) / 10) % 10;
snes_spc7110.rtc_ram[12] = systime->local_time.weekday % 7;
}
} | // FIXME: SPC7110 RTC is capable of rounding/adding/zero-ing seconds, so
// we should probably keep track internally of the time rather than updating
// to the system time at each call with a "offset" tracking as we do now...
// (and indeed current code fails to pass Tengai Makyou Zero tests)
| SPC7110 RTC is capable of rounding/adding/zero-ing seconds, so
we should probably keep track internally of the time rather than updating
to the system time at each call with a "offset" tracking as we do now
(and indeed current code fails to pass Tengai Makyou Zero tests) | [
"SPC7110",
"RTC",
"is",
"capable",
"of",
"rounding",
"/",
"adding",
"/",
"zero",
"-",
"ing",
"seconds",
"so",
"we",
"should",
"probably",
"keep",
"track",
"internally",
"of",
"the",
"time",
"rather",
"than",
"updating",
"to",
"the",
"system",
"time",
"at",
"each",
"call",
"with",
"a",
"\"",
"offset",
"\"",
"tracking",
"as",
"we",
"do",
"now",
"(",
"and",
"indeed",
"current",
"code",
"fails",
"to",
"pass",
"Tengai",
"Makyou",
"Zero",
"tests",
")"
] | static void spc7110_update_time(running_machine *machine, UINT8 offset)
{
system_time curtime, *systime = &curtime;
machine->current_datetime(curtime);
int update = 1;
snes_spc7110.rtc_offset += offset;
assert(snes_spc7110.rtc_offset < 86400);
if ((snes_spc7110.rtc_ram[13] & 0x01) || (snes_spc7110.rtc_ram[15] & 0x03))
update = 0;
if (update)
{
UINT8 second = systime->local_time.second;
UINT8 minute = systime->local_time.minute;
UINT8 hour = systime->local_time.hour;
UINT8 mday = systime->local_time.mday;
while (snes_spc7110.rtc_offset >= 3600)
{
snes_spc7110.rtc_offset -= 3600;
hour++;
if (hour == 24)
{
mday++;
hour = 0;
}
}
while (snes_spc7110.rtc_offset >= 60)
{
snes_spc7110.rtc_offset -= 60;
minute++;
if (minute == 60)
{
hour++;
minute = 0;
}
}
while (snes_spc7110.rtc_offset)
{
snes_spc7110.rtc_offset -= 1;
second++;
if (second == 60)
{
minute++;
second = 0;
}
}
snes_spc7110.rtc_ram[0] = second % 10;
snes_spc7110.rtc_ram[1] = second / 10;
snes_spc7110.rtc_ram[2] = minute % 10;
snes_spc7110.rtc_ram[3] = minute / 10;
snes_spc7110.rtc_ram[4] = hour % 10;
snes_spc7110.rtc_ram[5] = hour / 10;
snes_spc7110.rtc_ram[6] = mday % 10;
snes_spc7110.rtc_ram[7] = mday / 10;
snes_spc7110.rtc_ram[8] = systime->local_time.month % 10;
snes_spc7110.rtc_ram[9] = systime->local_time.month / 10;
snes_spc7110.rtc_ram[8] = systime->local_time.month;
snes_spc7110.rtc_ram[10] = (systime->local_time.year - 1900) % 10;
snes_spc7110.rtc_ram[11] = ((systime->local_time.year - 1900) / 10) % 10;
snes_spc7110.rtc_ram[12] = systime->local_time.weekday % 7;
}
} | [
"static",
"void",
"spc7110_update_time",
"(",
"running_machine",
"*",
"machine",
",",
"UINT8",
"offset",
")",
"{",
"system_time",
"curtime",
",",
"*",
"systime",
"=",
"&",
"curtime",
";",
"machine",
"->",
"current_datetime",
"(",
"curtime",
")",
";",
"int",
"update",
"=",
"1",
";",
"snes_spc7110",
".",
"rtc_offset",
"+=",
"offset",
";",
"assert",
"(",
"snes_spc7110",
".",
"rtc_offset",
"<",
"86400",
")",
";",
"if",
"(",
"(",
"snes_spc7110",
".",
"rtc_ram",
"[",
"13",
"]",
"&",
"0x01",
")",
"||",
"(",
"snes_spc7110",
".",
"rtc_ram",
"[",
"15",
"]",
"&",
"0x03",
")",
")",
"update",
"=",
"0",
";",
"if",
"(",
"update",
")",
"{",
"UINT8",
"second",
"=",
"systime",
"->",
"local_time",
".",
"second",
";",
"UINT8",
"minute",
"=",
"systime",
"->",
"local_time",
".",
"minute",
";",
"UINT8",
"hour",
"=",
"systime",
"->",
"local_time",
".",
"hour",
";",
"UINT8",
"mday",
"=",
"systime",
"->",
"local_time",
".",
"mday",
";",
"while",
"(",
"snes_spc7110",
".",
"rtc_offset",
">=",
"3600",
")",
"{",
"snes_spc7110",
".",
"rtc_offset",
"-=",
"3600",
";",
"hour",
"++",
";",
"if",
"(",
"hour",
"==",
"24",
")",
"{",
"mday",
"++",
";",
"hour",
"=",
"0",
";",
"}",
"}",
"while",
"(",
"snes_spc7110",
".",
"rtc_offset",
">=",
"60",
")",
"{",
"snes_spc7110",
".",
"rtc_offset",
"-=",
"60",
";",
"minute",
"++",
";",
"if",
"(",
"minute",
"==",
"60",
")",
"{",
"hour",
"++",
";",
"minute",
"=",
"0",
";",
"}",
"}",
"while",
"(",
"snes_spc7110",
".",
"rtc_offset",
")",
"{",
"snes_spc7110",
".",
"rtc_offset",
"-=",
"1",
";",
"second",
"++",
";",
"if",
"(",
"second",
"==",
"60",
")",
"{",
"minute",
"++",
";",
"second",
"=",
"0",
";",
"}",
"}",
"snes_spc7110",
".",
"rtc_ram",
"[",
"0",
"]",
"=",
"second",
"%",
"10",
";",
"snes_spc7110",
".",
"rtc_ram",
"[",
"1",
"]",
"=",
"second",
"/",
"10",
";",
"snes_spc7110",
".",
"rtc_ram",
"[",
"2",
"]",
"=",
"minute",
"%",
"10",
";",
"snes_spc7110",
".",
"rtc_ram",
"[",
"3",
"]",
"=",
"minute",
"/",
"10",
";",
"snes_spc7110",
".",
"rtc_ram",
"[",
"4",
"]",
"=",
"hour",
"%",
"10",
";",
"snes_spc7110",
".",
"rtc_ram",
"[",
"5",
"]",
"=",
"hour",
"/",
"10",
";",
"snes_spc7110",
".",
"rtc_ram",
"[",
"6",
"]",
"=",
"mday",
"%",
"10",
";",
"snes_spc7110",
".",
"rtc_ram",
"[",
"7",
"]",
"=",
"mday",
"/",
"10",
";",
"snes_spc7110",
".",
"rtc_ram",
"[",
"8",
"]",
"=",
"systime",
"->",
"local_time",
".",
"month",
"%",
"10",
";",
"snes_spc7110",
".",
"rtc_ram",
"[",
"9",
"]",
"=",
"systime",
"->",
"local_time",
".",
"month",
"/",
"10",
";",
"snes_spc7110",
".",
"rtc_ram",
"[",
"8",
"]",
"=",
"systime",
"->",
"local_time",
".",
"month",
";",
"snes_spc7110",
".",
"rtc_ram",
"[",
"10",
"]",
"=",
"(",
"systime",
"->",
"local_time",
".",
"year",
"-",
"1900",
")",
"%",
"10",
";",
"snes_spc7110",
".",
"rtc_ram",
"[",
"11",
"]",
"=",
"(",
"(",
"systime",
"->",
"local_time",
".",
"year",
"-",
"1900",
")",
"/",
"10",
")",
"%",
"10",
";",
"snes_spc7110",
".",
"rtc_ram",
"[",
"12",
"]",
"=",
"systime",
"->",
"local_time",
".",
"weekday",
"%",
"7",
";",
"}",
"}"
] | FIXME: SPC7110 RTC is capable of rounding/adding/zero-ing seconds, so
we should probably keep track internally of the time rather than updating
to the system time at each call with a "offset" tracking as we do now...
(and indeed current code fails to pass Tengai Makyou Zero tests) | [
"FIXME",
":",
"SPC7110",
"RTC",
"is",
"capable",
"of",
"rounding",
"/",
"adding",
"/",
"zero",
"-",
"ing",
"seconds",
"so",
"we",
"should",
"probably",
"keep",
"track",
"internally",
"of",
"the",
"time",
"rather",
"than",
"updating",
"to",
"the",
"system",
"time",
"at",
"each",
"call",
"with",
"a",
"\"",
"offset",
"\"",
"tracking",
"as",
"we",
"do",
"now",
"...",
"(",
"and",
"indeed",
"current",
"code",
"fails",
"to",
"pass",
"Tengai",
"Makyou",
"Zero",
"tests",
")"
] | [
"// TEST: can we go beyond 24hrs of rounding?!? I doubt it will ever go beyond 3600, but I could be wrong...\r",
"/* do not update if CR0 or CR2 timer disable flags are set */",
"/* update time with offset, assuming offset < 3600s */"
] | [
{
"param": "machine",
"type": "running_machine"
},
{
"param": "offset",
"type": "UINT8"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "machine",
"type": "running_machine",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offset",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f0608db3dd71bbe92d11b93f07d742e6d28f0a62 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/osd/windows/winalloc.c | [
"Unlicense"
] | C | malloc_file_line | void | void *malloc_file_line(size_t size, const char *file, int line)
{
UINT8 *block_base;
int id = current_id++;
// perform global intialization if not already done
global_init_if_not_done();
// only proceed if enabled
if (use_malloc_tracking)
{
UINT8 *page_base;
size_t rounded_size;
memory_entry *entry;
// round the size up to a page boundary
rounded_size = ((size + PAGE_SIZE - 1) / PAGE_SIZE) * PAGE_SIZE;
// reserve that much memory, plus two guard pages
page_base = (UINT8 *)VirtualAlloc(NULL, rounded_size + 2 * PAGE_SIZE, MEM_RESERVE, PAGE_NOACCESS);
if (page_base == NULL)
return NULL;
// now allow access to everything but the first and last pages
page_base = (UINT8 *)VirtualAlloc(page_base + PAGE_SIZE, rounded_size, MEM_COMMIT, PAGE_READWRITE);
if (page_base == NULL)
return NULL;
// work backwards from the page base to get to the block base
if (ALIGN_START)
block_base = page_base;
else
block_base = page_base + rounded_size - size;
// fill in the entry
entry = allocate_entry();
entry->size = size;
entry->base = block_base;
entry->file = file;
entry->line = line;
entry->id = id;
}
else
{
block_base = (UINT8 *)GlobalAlloc(GMEM_FIXED, size);
}
// logging
if (file != NULL)
LOG(("malloc #%06d size = %d (%s:%d)\n", id, size, file, line));
else
LOG(("malloc #%06d size = %d\n", id, size));
return block_base;
} | //============================================================
// malloc_file_line - debugging version of malloc which
// accepts filename and line number
//============================================================ | debugging version of malloc which
accepts filename and line number | [
"debugging",
"version",
"of",
"malloc",
"which",
"accepts",
"filename",
"and",
"line",
"number"
] | void *malloc_file_line(size_t size, const char *file, int line)
{
UINT8 *block_base;
int id = current_id++;
global_init_if_not_done();
if (use_malloc_tracking)
{
UINT8 *page_base;
size_t rounded_size;
memory_entry *entry;
rounded_size = ((size + PAGE_SIZE - 1) / PAGE_SIZE) * PAGE_SIZE;
page_base = (UINT8 *)VirtualAlloc(NULL, rounded_size + 2 * PAGE_SIZE, MEM_RESERVE, PAGE_NOACCESS);
if (page_base == NULL)
return NULL;
page_base = (UINT8 *)VirtualAlloc(page_base + PAGE_SIZE, rounded_size, MEM_COMMIT, PAGE_READWRITE);
if (page_base == NULL)
return NULL;
if (ALIGN_START)
block_base = page_base;
else
block_base = page_base + rounded_size - size;
entry = allocate_entry();
entry->size = size;
entry->base = block_base;
entry->file = file;
entry->line = line;
entry->id = id;
}
else
{
block_base = (UINT8 *)GlobalAlloc(GMEM_FIXED, size);
}
if (file != NULL)
LOG(("malloc #%06d size = %d (%s:%d)\n", id, size, file, line));
else
LOG(("malloc #%06d size = %d\n", id, size));
return block_base;
} | [
"void",
"*",
"malloc_file_line",
"(",
"size_t",
"size",
",",
"const",
"char",
"*",
"file",
",",
"int",
"line",
")",
"{",
"UINT8",
"*",
"block_base",
";",
"int",
"id",
"=",
"current_id",
"++",
";",
"global_init_if_not_done",
"(",
")",
";",
"if",
"(",
"use_malloc_tracking",
")",
"{",
"UINT8",
"*",
"page_base",
";",
"size_t",
"rounded_size",
";",
"memory_entry",
"*",
"entry",
";",
"rounded_size",
"=",
"(",
"(",
"size",
"+",
"PAGE_SIZE",
"-",
"1",
")",
"/",
"PAGE_SIZE",
")",
"*",
"PAGE_SIZE",
";",
"page_base",
"=",
"(",
"UINT8",
"*",
")",
"VirtualAlloc",
"(",
"NULL",
",",
"rounded_size",
"+",
"2",
"*",
"PAGE_SIZE",
",",
"MEM_RESERVE",
",",
"PAGE_NOACCESS",
")",
";",
"if",
"(",
"page_base",
"==",
"NULL",
")",
"return",
"NULL",
";",
"page_base",
"=",
"(",
"UINT8",
"*",
")",
"VirtualAlloc",
"(",
"page_base",
"+",
"PAGE_SIZE",
",",
"rounded_size",
",",
"MEM_COMMIT",
",",
"PAGE_READWRITE",
")",
";",
"if",
"(",
"page_base",
"==",
"NULL",
")",
"return",
"NULL",
";",
"if",
"(",
"ALIGN_START",
")",
"block_base",
"=",
"page_base",
";",
"else",
"block_base",
"=",
"page_base",
"+",
"rounded_size",
"-",
"size",
";",
"entry",
"=",
"allocate_entry",
"(",
")",
";",
"entry",
"->",
"size",
"=",
"size",
";",
"entry",
"->",
"base",
"=",
"block_base",
";",
"entry",
"->",
"file",
"=",
"file",
";",
"entry",
"->",
"line",
"=",
"line",
";",
"entry",
"->",
"id",
"=",
"id",
";",
"}",
"else",
"{",
"block_base",
"=",
"(",
"UINT8",
"*",
")",
"GlobalAlloc",
"(",
"GMEM_FIXED",
",",
"size",
")",
";",
"}",
"if",
"(",
"file",
"!=",
"NULL",
")",
"LOG",
"(",
"(",
"\"",
"\\n",
"\"",
",",
"id",
",",
"size",
",",
"file",
",",
"line",
")",
")",
";",
"else",
"LOG",
"(",
"(",
"\"",
"\\n",
"\"",
",",
"id",
",",
"size",
")",
")",
";",
"return",
"block_base",
";",
"}"
] | malloc_file_line - debugging version of malloc which
accepts filename and line number | [
"malloc_file_line",
"-",
"debugging",
"version",
"of",
"malloc",
"which",
"accepts",
"filename",
"and",
"line",
"number"
] | [
"// perform global intialization if not already done",
"// only proceed if enabled",
"// round the size up to a page boundary",
"// reserve that much memory, plus two guard pages",
"// now allow access to everything but the first and last pages",
"// work backwards from the page base to get to the block base",
"// fill in the entry",
"// logging"
] | [
{
"param": "size",
"type": "size_t"
},
{
"param": "file",
"type": "char"
},
{
"param": "line",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "size",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "line",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f0608db3dd71bbe92d11b93f07d742e6d28f0a62 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/osd/windows/winalloc.c | [
"Unlicense"
] | C | calloc_file_line | void | void *calloc_file_line(size_t size, size_t count, const char *file, int line)
{
// first allocate the memory
void *memory = malloc_file_line(size * count, file, line);
if (memory == NULL)
return NULL;
// then memset it
memset(memory, 0, size * count);
return memory;
} | //============================================================
// calloc_file_line - debugging version of calloc which
// accepts filename and line number
//============================================================ | debugging version of calloc which
accepts filename and line number | [
"debugging",
"version",
"of",
"calloc",
"which",
"accepts",
"filename",
"and",
"line",
"number"
] | void *calloc_file_line(size_t size, size_t count, const char *file, int line)
{
void *memory = malloc_file_line(size * count, file, line);
if (memory == NULL)
return NULL;
memset(memory, 0, size * count);
return memory;
} | [
"void",
"*",
"calloc_file_line",
"(",
"size_t",
"size",
",",
"size_t",
"count",
",",
"const",
"char",
"*",
"file",
",",
"int",
"line",
")",
"{",
"void",
"*",
"memory",
"=",
"malloc_file_line",
"(",
"size",
"*",
"count",
",",
"file",
",",
"line",
")",
";",
"if",
"(",
"memory",
"==",
"NULL",
")",
"return",
"NULL",
";",
"memset",
"(",
"memory",
",",
"0",
",",
"size",
"*",
"count",
")",
";",
"return",
"memory",
";",
"}"
] | calloc_file_line - debugging version of calloc which
accepts filename and line number | [
"calloc_file_line",
"-",
"debugging",
"version",
"of",
"calloc",
"which",
"accepts",
"filename",
"and",
"line",
"number"
] | [
"// first allocate the memory",
"// then memset it"
] | [
{
"param": "size",
"type": "size_t"
},
{
"param": "count",
"type": "size_t"
},
{
"param": "file",
"type": "char"
},
{
"param": "line",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "size",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "count",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "line",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f0608db3dd71bbe92d11b93f07d742e6d28f0a62 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/osd/windows/winalloc.c | [
"Unlicense"
] | C | realloc_file_line | void | void *realloc_file_line(void *memory, size_t size, const char *file, int line)
{
void *newmemory = NULL;
// perform global intialization if not already done
global_init_if_not_done();
// only proceed if enabled
if (use_malloc_tracking)
{
// if size is non-zero, we need to reallocate memory
if (size != 0)
{
// allocate space for the new amount
newmemory = malloc_file_line(size, file, line);
if (newmemory == NULL)
return NULL;
// if we have an old pointer, copy it
if (memory != NULL)
{
memory_entry *entry = find_entry(memory);
if (entry == NULL)
{
if (winalloc_in_main_code)
{
fprintf(stderr, "Error: realloc a non-existant block (%s:%d)\n", file, line);
osd_break_into_debugger("Error: realloc a non-existant block\n");
}
}
else
memcpy(newmemory, memory, (size < entry->size) ? size : entry->size);
}
}
// if we have an original pointer, free it
if (memory != NULL)
free(memory);
}
else
{
if (memory != NULL)
newmemory = (void *) GlobalReAlloc(memory, size, GMEM_MOVEABLE);
else
newmemory = (void *) GlobalAlloc(GMEM_FIXED, size);
}
return newmemory;
} | //============================================================
// realloc_file_line - debugging version of realloc which
// accepts filename and line number
//============================================================ | debugging version of realloc which
accepts filename and line number | [
"debugging",
"version",
"of",
"realloc",
"which",
"accepts",
"filename",
"and",
"line",
"number"
] | void *realloc_file_line(void *memory, size_t size, const char *file, int line)
{
void *newmemory = NULL;
global_init_if_not_done();
if (use_malloc_tracking)
{
if (size != 0)
{
newmemory = malloc_file_line(size, file, line);
if (newmemory == NULL)
return NULL;
if (memory != NULL)
{
memory_entry *entry = find_entry(memory);
if (entry == NULL)
{
if (winalloc_in_main_code)
{
fprintf(stderr, "Error: realloc a non-existant block (%s:%d)\n", file, line);
osd_break_into_debugger("Error: realloc a non-existant block\n");
}
}
else
memcpy(newmemory, memory, (size < entry->size) ? size : entry->size);
}
}
if (memory != NULL)
free(memory);
}
else
{
if (memory != NULL)
newmemory = (void *) GlobalReAlloc(memory, size, GMEM_MOVEABLE);
else
newmemory = (void *) GlobalAlloc(GMEM_FIXED, size);
}
return newmemory;
} | [
"void",
"*",
"realloc_file_line",
"(",
"void",
"*",
"memory",
",",
"size_t",
"size",
",",
"const",
"char",
"*",
"file",
",",
"int",
"line",
")",
"{",
"void",
"*",
"newmemory",
"=",
"NULL",
";",
"global_init_if_not_done",
"(",
")",
";",
"if",
"(",
"use_malloc_tracking",
")",
"{",
"if",
"(",
"size",
"!=",
"0",
")",
"{",
"newmemory",
"=",
"malloc_file_line",
"(",
"size",
",",
"file",
",",
"line",
")",
";",
"if",
"(",
"newmemory",
"==",
"NULL",
")",
"return",
"NULL",
";",
"if",
"(",
"memory",
"!=",
"NULL",
")",
"{",
"memory_entry",
"*",
"entry",
"=",
"find_entry",
"(",
"memory",
")",
";",
"if",
"(",
"entry",
"==",
"NULL",
")",
"{",
"if",
"(",
"winalloc_in_main_code",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"file",
",",
"line",
")",
";",
"osd_break_into_debugger",
"(",
"\"",
"\\n",
"\"",
")",
";",
"}",
"}",
"else",
"memcpy",
"(",
"newmemory",
",",
"memory",
",",
"(",
"size",
"<",
"entry",
"->",
"size",
")",
"?",
"size",
":",
"entry",
"->",
"size",
")",
";",
"}",
"}",
"if",
"(",
"memory",
"!=",
"NULL",
")",
"free",
"(",
"memory",
")",
";",
"}",
"else",
"{",
"if",
"(",
"memory",
"!=",
"NULL",
")",
"newmemory",
"=",
"(",
"void",
"*",
")",
"GlobalReAlloc",
"(",
"memory",
",",
"size",
",",
"GMEM_MOVEABLE",
")",
";",
"else",
"newmemory",
"=",
"(",
"void",
"*",
")",
"GlobalAlloc",
"(",
"GMEM_FIXED",
",",
"size",
")",
";",
"}",
"return",
"newmemory",
";",
"}"
] | realloc_file_line - debugging version of realloc which
accepts filename and line number | [
"realloc_file_line",
"-",
"debugging",
"version",
"of",
"realloc",
"which",
"accepts",
"filename",
"and",
"line",
"number"
] | [
"// perform global intialization if not already done",
"// only proceed if enabled",
"// if size is non-zero, we need to reallocate memory",
"// allocate space for the new amount",
"// if we have an old pointer, copy it",
"// if we have an original pointer, free it"
] | [
{
"param": "memory",
"type": "void"
},
{
"param": "size",
"type": "size_t"
},
{
"param": "file",
"type": "char"
},
{
"param": "line",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "memory",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "size",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "line",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f0608db3dd71bbe92d11b93f07d742e6d28f0a62 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/osd/windows/winalloc.c | [
"Unlicense"
] | C | check_unfreed_mem | void | void check_unfreed_mem(void)
{
memory_entry *entry;
int total = 0;
// only valid if we are tracking
if (use_malloc_tracking)
{
memory_lock_acquire();
// check for leaked memory
for (entry = alloc_list; entry; entry = entry->next)
if (entry->file != NULL)
{
if (total == 0)
fprintf(stderr, "--- memory leak warning ---\n");
total += entry->size;
fprintf(stderr, "allocation #%06d, %d bytes (%s:%d)\n", entry->id, entry->size, entry->file, entry->line);
}
memory_lock_release();
if (total > 0)
fprintf(stderr, "a total of %d bytes were not free()'d\n", total);
}
} | //============================================================
// check_unfreed_mem - called from the exit path of any
// code that wants to check for unfreed memory
//============================================================ | called from the exit path of any
code that wants to check for unfreed memory | [
"called",
"from",
"the",
"exit",
"path",
"of",
"any",
"code",
"that",
"wants",
"to",
"check",
"for",
"unfreed",
"memory"
] | void check_unfreed_mem(void)
{
memory_entry *entry;
int total = 0;
if (use_malloc_tracking)
{
memory_lock_acquire();
for (entry = alloc_list; entry; entry = entry->next)
if (entry->file != NULL)
{
if (total == 0)
fprintf(stderr, "--- memory leak warning ---\n");
total += entry->size;
fprintf(stderr, "allocation #%06d, %d bytes (%s:%d)\n", entry->id, entry->size, entry->file, entry->line);
}
memory_lock_release();
if (total > 0)
fprintf(stderr, "a total of %d bytes were not free()'d\n", total);
}
} | [
"void",
"check_unfreed_mem",
"(",
"void",
")",
"{",
"memory_entry",
"*",
"entry",
";",
"int",
"total",
"=",
"0",
";",
"if",
"(",
"use_malloc_tracking",
")",
"{",
"memory_lock_acquire",
"(",
")",
";",
"for",
"(",
"entry",
"=",
"alloc_list",
";",
"entry",
";",
"entry",
"=",
"entry",
"->",
"next",
")",
"if",
"(",
"entry",
"->",
"file",
"!=",
"NULL",
")",
"{",
"if",
"(",
"total",
"==",
"0",
")",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
")",
";",
"total",
"+=",
"entry",
"->",
"size",
";",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"entry",
"->",
"id",
",",
"entry",
"->",
"size",
",",
"entry",
"->",
"file",
",",
"entry",
"->",
"line",
")",
";",
"}",
"memory_lock_release",
"(",
")",
";",
"if",
"(",
"total",
">",
"0",
")",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"total",
")",
";",
"}",
"}"
] | check_unfreed_mem - called from the exit path of any
code that wants to check for unfreed memory | [
"check_unfreed_mem",
"-",
"called",
"from",
"the",
"exit",
"path",
"of",
"any",
"code",
"that",
"wants",
"to",
"check",
"for",
"unfreed",
"memory"
] | [
"// only valid if we are tracking",
"// check for leaked memory"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f0608db3dd71bbe92d11b93f07d742e6d28f0a62 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/osd/windows/winalloc.c | [
"Unlicense"
] | C | allocate_entry | memory_entry | static memory_entry *allocate_entry(void)
{
memory_entry *entry;
// always take the lock when allocating
memory_lock_acquire();
// if we're out of entries, allocate some more
if (free_list == NULL)
{
int entries_per_page = PAGE_SIZE / sizeof(memory_entry);
// allocate a new pages' worth of entry
entry = (memory_entry *)VirtualAlloc(NULL, PAGE_SIZE, MEM_COMMIT, PAGE_READWRITE);
if (entry == NULL)
{
memory_lock_release();
fprintf(stderr, "Out of memory for malloc tracking!\n");
exit(1);
}
// add all the entries to the list
while (entries_per_page--)
{
entry->next = free_list;
free_list = entry;
entry++;
}
}
// grab a free list entry
entry = free_list;
free_list = free_list->next;
// add ourselves to the alloc list
entry->next = alloc_list;
if (entry->next)
entry->next->prev = entry;
entry->prev = NULL;
alloc_list = entry;
// release the lock when finished
memory_lock_release();
return entry;
} | //============================================================
// allocate_entry - allocate a new entry and link it into
// the list of allocated memory
//============================================================ | allocate a new entry and link it into
the list of allocated memory | [
"allocate",
"a",
"new",
"entry",
"and",
"link",
"it",
"into",
"the",
"list",
"of",
"allocated",
"memory"
] | static memory_entry *allocate_entry(void)
{
memory_entry *entry;
memory_lock_acquire();
if (free_list == NULL)
{
int entries_per_page = PAGE_SIZE / sizeof(memory_entry);
entry = (memory_entry *)VirtualAlloc(NULL, PAGE_SIZE, MEM_COMMIT, PAGE_READWRITE);
if (entry == NULL)
{
memory_lock_release();
fprintf(stderr, "Out of memory for malloc tracking!\n");
exit(1);
}
while (entries_per_page--)
{
entry->next = free_list;
free_list = entry;
entry++;
}
}
entry = free_list;
free_list = free_list->next;
entry->next = alloc_list;
if (entry->next)
entry->next->prev = entry;
entry->prev = NULL;
alloc_list = entry;
memory_lock_release();
return entry;
} | [
"static",
"memory_entry",
"*",
"allocate_entry",
"(",
"void",
")",
"{",
"memory_entry",
"*",
"entry",
";",
"memory_lock_acquire",
"(",
")",
";",
"if",
"(",
"free_list",
"==",
"NULL",
")",
"{",
"int",
"entries_per_page",
"=",
"PAGE_SIZE",
"/",
"sizeof",
"(",
"memory_entry",
")",
";",
"entry",
"=",
"(",
"memory_entry",
"*",
")",
"VirtualAlloc",
"(",
"NULL",
",",
"PAGE_SIZE",
",",
"MEM_COMMIT",
",",
"PAGE_READWRITE",
")",
";",
"if",
"(",
"entry",
"==",
"NULL",
")",
"{",
"memory_lock_release",
"(",
")",
";",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
")",
";",
"exit",
"(",
"1",
")",
";",
"}",
"while",
"(",
"entries_per_page",
"--",
")",
"{",
"entry",
"->",
"next",
"=",
"free_list",
";",
"free_list",
"=",
"entry",
";",
"entry",
"++",
";",
"}",
"}",
"entry",
"=",
"free_list",
";",
"free_list",
"=",
"free_list",
"->",
"next",
";",
"entry",
"->",
"next",
"=",
"alloc_list",
";",
"if",
"(",
"entry",
"->",
"next",
")",
"entry",
"->",
"next",
"->",
"prev",
"=",
"entry",
";",
"entry",
"->",
"prev",
"=",
"NULL",
";",
"alloc_list",
"=",
"entry",
";",
"memory_lock_release",
"(",
")",
";",
"return",
"entry",
";",
"}"
] | allocate_entry - allocate a new entry and link it into
the list of allocated memory | [
"allocate_entry",
"-",
"allocate",
"a",
"new",
"entry",
"and",
"link",
"it",
"into",
"the",
"list",
"of",
"allocated",
"memory"
] | [
"// always take the lock when allocating",
"// if we're out of entries, allocate some more",
"// allocate a new pages' worth of entry",
"// add all the entries to the list",
"// grab a free list entry",
"// add ourselves to the alloc list",
"// release the lock when finished"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f0608db3dd71bbe92d11b93f07d742e6d28f0a62 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/osd/windows/winalloc.c | [
"Unlicense"
] | C | find_entry | memory_entry | static memory_entry *find_entry(void *pointer)
{
memory_entry *entry;
// scan the list looking for a matching base
if (pointer)
{
memory_lock_acquire();
for (entry = alloc_list; entry; entry = entry->next)
if (entry->base == pointer)
break;
memory_lock_release();
return entry;
}
return NULL;
} | //============================================================
// find_entry - find a memory_object entry in the list that
// contains the given pointer
//============================================================ | find a memory_object entry in the list that
contains the given pointer | [
"find",
"a",
"memory_object",
"entry",
"in",
"the",
"list",
"that",
"contains",
"the",
"given",
"pointer"
] | static memory_entry *find_entry(void *pointer)
{
memory_entry *entry;
if (pointer)
{
memory_lock_acquire();
for (entry = alloc_list; entry; entry = entry->next)
if (entry->base == pointer)
break;
memory_lock_release();
return entry;
}
return NULL;
} | [
"static",
"memory_entry",
"*",
"find_entry",
"(",
"void",
"*",
"pointer",
")",
"{",
"memory_entry",
"*",
"entry",
";",
"if",
"(",
"pointer",
")",
"{",
"memory_lock_acquire",
"(",
")",
";",
"for",
"(",
"entry",
"=",
"alloc_list",
";",
"entry",
";",
"entry",
"=",
"entry",
"->",
"next",
")",
"if",
"(",
"entry",
"->",
"base",
"==",
"pointer",
")",
"break",
";",
"memory_lock_release",
"(",
")",
";",
"return",
"entry",
";",
"}",
"return",
"NULL",
";",
"}"
] | find_entry - find a memory_object entry in the list that
contains the given pointer | [
"find_entry",
"-",
"find",
"a",
"memory_object",
"entry",
"in",
"the",
"list",
"that",
"contains",
"the",
"given",
"pointer"
] | [
"// scan the list looking for a matching base"
] | [
{
"param": "pointer",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pointer",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2ca52623ad8880ad97d06cb040f0354da015414f | lofunz/mieme | Reloaded/trunk/src/emu/romload.c | [
"Unlicense"
] | C | add_disk_handle | void | static void add_disk_handle(running_machine *machine, open_chd *chd)
{
romload_private *romload_data = machine->romload_data;
*romload_data->chd_list_tailptr = auto_alloc(machine, open_chd);
**romload_data->chd_list_tailptr = *chd;
romload_data->chd_list_tailptr = &(*romload_data->chd_list_tailptr)->next;
} | /*-------------------------------------------------
add_disk_handle - add a disk to the to the
list of CHD files
-------------------------------------------------*/ | add a disk to the to the
list of CHD files | [
"add",
"a",
"disk",
"to",
"the",
"to",
"the",
"list",
"of",
"CHD",
"files"
] | static void add_disk_handle(running_machine *machine, open_chd *chd)
{
romload_private *romload_data = machine->romload_data;
*romload_data->chd_list_tailptr = auto_alloc(machine, open_chd);
**romload_data->chd_list_tailptr = *chd;
romload_data->chd_list_tailptr = &(*romload_data->chd_list_tailptr)->next;
} | [
"static",
"void",
"add_disk_handle",
"(",
"running_machine",
"*",
"machine",
",",
"open_chd",
"*",
"chd",
")",
"{",
"romload_private",
"*",
"romload_data",
"=",
"machine",
"->",
"romload_data",
";",
"*",
"romload_data",
"->",
"chd_list_tailptr",
"=",
"auto_alloc",
"(",
"machine",
",",
"open_chd",
")",
";",
"*",
"*",
"romload_data",
"->",
"chd_list_tailptr",
"=",
"*",
"chd",
";",
"romload_data",
"->",
"chd_list_tailptr",
"=",
"&",
"(",
"*",
"romload_data",
"->",
"chd_list_tailptr",
")",
"->",
"next",
";",
"}"
] | add_disk_handle - add a disk to the to the
list of CHD files | [
"add_disk_handle",
"-",
"add",
"a",
"disk",
"to",
"the",
"to",
"the",
"list",
"of",
"CHD",
"files"
] | [] | [
{
"param": "machine",
"type": "running_machine"
},
{
"param": "chd",
"type": "open_chd"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "machine",
"type": "running_machine",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "chd",
"type": "open_chd",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2ca52623ad8880ad97d06cb040f0354da015414f | lofunz/mieme | Reloaded/trunk/src/emu/romload.c | [
"Unlicense"
] | C | rom_first_source | rom_source | const rom_source *rom_first_source(const game_driver *drv, const machine_config *config)
{
const device_config *devconfig;
/* if the driver has a ROM pointer, that's what we want */
if (drv->rom != NULL)
return (rom_source *)drv;
/* otherwise, look through devices */
if (config != NULL)
for (devconfig = config->m_devicelist.first(); devconfig != NULL; devconfig = devconfig->next())
{
const rom_entry *devromp = devconfig->rom_region();
if (devromp != NULL)
return (rom_source *)devconfig;
}
return NULL;
} | /*-------------------------------------------------
rom_first_source - return pointer to first ROM
source
-------------------------------------------------*/ | return pointer to first ROM
source | [
"return",
"pointer",
"to",
"first",
"ROM",
"source"
] | const rom_source *rom_first_source(const game_driver *drv, const machine_config *config)
{
const device_config *devconfig;
if (drv->rom != NULL)
return (rom_source *)drv;
if (config != NULL)
for (devconfig = config->m_devicelist.first(); devconfig != NULL; devconfig = devconfig->next())
{
const rom_entry *devromp = devconfig->rom_region();
if (devromp != NULL)
return (rom_source *)devconfig;
}
return NULL;
} | [
"const",
"rom_source",
"*",
"rom_first_source",
"(",
"const",
"game_driver",
"*",
"drv",
",",
"const",
"machine_config",
"*",
"config",
")",
"{",
"const",
"device_config",
"*",
"devconfig",
";",
"if",
"(",
"drv",
"->",
"rom",
"!=",
"NULL",
")",
"return",
"(",
"rom_source",
"*",
")",
"drv",
";",
"if",
"(",
"config",
"!=",
"NULL",
")",
"for",
"(",
"devconfig",
"=",
"config",
"->",
"m_devicelist",
".",
"first",
"(",
")",
";",
"devconfig",
"!=",
"NULL",
";",
"devconfig",
"=",
"devconfig",
"->",
"next",
"(",
")",
")",
"{",
"const",
"rom_entry",
"*",
"devromp",
"=",
"devconfig",
"->",
"rom_region",
"(",
")",
";",
"if",
"(",
"devromp",
"!=",
"NULL",
")",
"return",
"(",
"rom_source",
"*",
")",
"devconfig",
";",
"}",
"return",
"NULL",
";",
"}"
] | rom_first_source - return pointer to first ROM
source | [
"rom_first_source",
"-",
"return",
"pointer",
"to",
"first",
"ROM",
"source"
] | [
"/* if the driver has a ROM pointer, that's what we want */",
"/* otherwise, look through devices */"
] | [
{
"param": "drv",
"type": "game_driver"
},
{
"param": "config",
"type": "machine_config"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "drv",
"type": "game_driver",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "config",
"type": "machine_config",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2ca52623ad8880ad97d06cb040f0354da015414f | lofunz/mieme | Reloaded/trunk/src/emu/romload.c | [
"Unlicense"
] | C | rom_next_source | rom_source | const rom_source *rom_next_source(const game_driver *drv, const machine_config *config, const rom_source *previous)
{
const device_config *devconfig;
/* if the previous was the driver, we want the first device */
if (rom_source_is_gamedrv(drv, previous))
devconfig = (config != NULL) ? config->m_devicelist.first() : NULL;
else
devconfig = ((const device_config *)previous)->next();
/* look for further devices with ROM definitions */
for ( ; devconfig != NULL; devconfig = devconfig->next())
{
const rom_entry *devromp = devconfig->rom_region();
if (devromp != NULL)
return (rom_source *)devconfig;
}
return NULL;
} | /*-------------------------------------------------
rom_next_source - return pointer to next ROM
source
-------------------------------------------------*/ | return pointer to next ROM
source | [
"return",
"pointer",
"to",
"next",
"ROM",
"source"
] | const rom_source *rom_next_source(const game_driver *drv, const machine_config *config, const rom_source *previous)
{
const device_config *devconfig;
if (rom_source_is_gamedrv(drv, previous))
devconfig = (config != NULL) ? config->m_devicelist.first() : NULL;
else
devconfig = ((const device_config *)previous)->next();
for ( ; devconfig != NULL; devconfig = devconfig->next())
{
const rom_entry *devromp = devconfig->rom_region();
if (devromp != NULL)
return (rom_source *)devconfig;
}
return NULL;
} | [
"const",
"rom_source",
"*",
"rom_next_source",
"(",
"const",
"game_driver",
"*",
"drv",
",",
"const",
"machine_config",
"*",
"config",
",",
"const",
"rom_source",
"*",
"previous",
")",
"{",
"const",
"device_config",
"*",
"devconfig",
";",
"if",
"(",
"rom_source_is_gamedrv",
"(",
"drv",
",",
"previous",
")",
")",
"devconfig",
"=",
"(",
"config",
"!=",
"NULL",
")",
"?",
"config",
"->",
"m_devicelist",
".",
"first",
"(",
")",
":",
"NULL",
";",
"else",
"devconfig",
"=",
"(",
"(",
"const",
"device_config",
"*",
")",
"previous",
")",
"->",
"next",
"(",
")",
";",
"for",
"(",
";",
"devconfig",
"!=",
"NULL",
";",
"devconfig",
"=",
"devconfig",
"->",
"next",
"(",
")",
")",
"{",
"const",
"rom_entry",
"*",
"devromp",
"=",
"devconfig",
"->",
"rom_region",
"(",
")",
";",
"if",
"(",
"devromp",
"!=",
"NULL",
")",
"return",
"(",
"rom_source",
"*",
")",
"devconfig",
";",
"}",
"return",
"NULL",
";",
"}"
] | rom_next_source - return pointer to next ROM
source | [
"rom_next_source",
"-",
"return",
"pointer",
"to",
"next",
"ROM",
"source"
] | [
"/* if the previous was the driver, we want the first device */",
"/* look for further devices with ROM definitions */"
] | [
{
"param": "drv",
"type": "game_driver"
},
{
"param": "config",
"type": "machine_config"
},
{
"param": "previous",
"type": "rom_source"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "drv",
"type": "game_driver",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "config",
"type": "machine_config",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "previous",
"type": "rom_source",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2ca52623ad8880ad97d06cb040f0354da015414f | lofunz/mieme | Reloaded/trunk/src/emu/romload.c | [
"Unlicense"
] | C | rom_first_region | rom_entry | const rom_entry *rom_first_region(const game_driver *drv, const rom_source *source)
{
const rom_entry *romp;
if (source == NULL || rom_source_is_gamedrv(drv, source))
romp = drv->rom;
else
romp = ((const device_config *)source)->rom_region();
return (romp != NULL && !ROMENTRY_ISEND(romp)) ? romp : NULL;
} | /*-------------------------------------------------
rom_first_region - return pointer to first ROM
region
-------------------------------------------------*/ | return pointer to first ROM
region | [
"return",
"pointer",
"to",
"first",
"ROM",
"region"
] | const rom_entry *rom_first_region(const game_driver *drv, const rom_source *source)
{
const rom_entry *romp;
if (source == NULL || rom_source_is_gamedrv(drv, source))
romp = drv->rom;
else
romp = ((const device_config *)source)->rom_region();
return (romp != NULL && !ROMENTRY_ISEND(romp)) ? romp : NULL;
} | [
"const",
"rom_entry",
"*",
"rom_first_region",
"(",
"const",
"game_driver",
"*",
"drv",
",",
"const",
"rom_source",
"*",
"source",
")",
"{",
"const",
"rom_entry",
"*",
"romp",
";",
"if",
"(",
"source",
"==",
"NULL",
"||",
"rom_source_is_gamedrv",
"(",
"drv",
",",
"source",
")",
")",
"romp",
"=",
"drv",
"->",
"rom",
";",
"else",
"romp",
"=",
"(",
"(",
"const",
"device_config",
"*",
")",
"source",
")",
"->",
"rom_region",
"(",
")",
";",
"return",
"(",
"romp",
"!=",
"NULL",
"&&",
"!",
"ROMENTRY_ISEND",
"(",
"romp",
")",
")",
"?",
"romp",
":",
"NULL",
";",
"}"
] | rom_first_region - return pointer to first ROM
region | [
"rom_first_region",
"-",
"return",
"pointer",
"to",
"first",
"ROM",
"region"
] | [] | [
{
"param": "drv",
"type": "game_driver"
},
{
"param": "source",
"type": "rom_source"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "drv",
"type": "game_driver",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "source",
"type": "rom_source",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2ca52623ad8880ad97d06cb040f0354da015414f | lofunz/mieme | Reloaded/trunk/src/emu/romload.c | [
"Unlicense"
] | C | rom_file_size | UINT32 | UINT32 rom_file_size(const rom_entry *romp)
{
UINT32 maxlength = 0;
/* loop until we run out of reloads */
do
{
UINT32 curlength;
/* loop until we run out of continues/ignores */
curlength = ROM_GETLENGTH(romp++);
while (ROMENTRY_ISCONTINUE(romp) || ROMENTRY_ISIGNORE(romp))
curlength += ROM_GETLENGTH(romp++);
/* track the maximum length */
maxlength = MAX(maxlength, curlength);
}
while (ROMENTRY_ISRELOAD(romp));
return maxlength;
} | /*-------------------------------------------------
rom_file_size - return the expected size of a
file given the ROM description
-------------------------------------------------*/ | return the expected size of a
file given the ROM description | [
"return",
"the",
"expected",
"size",
"of",
"a",
"file",
"given",
"the",
"ROM",
"description"
] | UINT32 rom_file_size(const rom_entry *romp)
{
UINT32 maxlength = 0;
do
{
UINT32 curlength;
curlength = ROM_GETLENGTH(romp++);
while (ROMENTRY_ISCONTINUE(romp) || ROMENTRY_ISIGNORE(romp))
curlength += ROM_GETLENGTH(romp++);
maxlength = MAX(maxlength, curlength);
}
while (ROMENTRY_ISRELOAD(romp));
return maxlength;
} | [
"UINT32",
"rom_file_size",
"(",
"const",
"rom_entry",
"*",
"romp",
")",
"{",
"UINT32",
"maxlength",
"=",
"0",
";",
"do",
"{",
"UINT32",
"curlength",
";",
"curlength",
"=",
"ROM_GETLENGTH",
"(",
"romp",
"++",
")",
";",
"while",
"(",
"ROMENTRY_ISCONTINUE",
"(",
"romp",
")",
"||",
"ROMENTRY_ISIGNORE",
"(",
"romp",
")",
")",
"curlength",
"+=",
"ROM_GETLENGTH",
"(",
"romp",
"++",
")",
";",
"maxlength",
"=",
"MAX",
"(",
"maxlength",
",",
"curlength",
")",
";",
"}",
"while",
"(",
"ROMENTRY_ISRELOAD",
"(",
"romp",
")",
")",
";",
"return",
"maxlength",
";",
"}"
] | rom_file_size - return the expected size of a
file given the ROM description | [
"rom_file_size",
"-",
"return",
"the",
"expected",
"size",
"of",
"a",
"file",
"given",
"the",
"ROM",
"description"
] | [
"/* loop until we run out of reloads */",
"/* loop until we run out of continues/ignores */",
"/* track the maximum length */"
] | [
{
"param": "romp",
"type": "rom_entry"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "romp",
"type": "rom_entry",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2ca52623ad8880ad97d06cb040f0354da015414f | lofunz/mieme | Reloaded/trunk/src/emu/romload.c | [
"Unlicense"
] | C | count_roms | void | static void count_roms(rom_load_data *romdata)
{
const rom_entry *region, *rom;
const rom_source *source;
/* start with 0 */
romdata->romstotal = 0;
romdata->romstotalsize = 0;
/* loop over regions, then over files */
for (source = rom_first_source(romdata->machine->gamedrv, romdata->machine->config); source != NULL; source = rom_next_source(romdata->machine->gamedrv, romdata->machine->config, source))
for (region = rom_first_region(romdata->machine->gamedrv, source); region != NULL; region = rom_next_region(region))
for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom))
if (ROM_GETBIOSFLAGS(rom) == 0 || ROM_GETBIOSFLAGS(rom) == romdata->system_bios)
{
romdata->romstotal++;
romdata->romstotalsize += rom_file_size(rom);
}
} | /*-------------------------------------------------
count_roms - counts the total number of ROMs
that will need to be loaded
-------------------------------------------------*/ | counts the total number of ROMs
that will need to be loaded | [
"counts",
"the",
"total",
"number",
"of",
"ROMs",
"that",
"will",
"need",
"to",
"be",
"loaded"
] | static void count_roms(rom_load_data *romdata)
{
const rom_entry *region, *rom;
const rom_source *source;
romdata->romstotal = 0;
romdata->romstotalsize = 0;
for (source = rom_first_source(romdata->machine->gamedrv, romdata->machine->config); source != NULL; source = rom_next_source(romdata->machine->gamedrv, romdata->machine->config, source))
for (region = rom_first_region(romdata->machine->gamedrv, source); region != NULL; region = rom_next_region(region))
for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom))
if (ROM_GETBIOSFLAGS(rom) == 0 || ROM_GETBIOSFLAGS(rom) == romdata->system_bios)
{
romdata->romstotal++;
romdata->romstotalsize += rom_file_size(rom);
}
} | [
"static",
"void",
"count_roms",
"(",
"rom_load_data",
"*",
"romdata",
")",
"{",
"const",
"rom_entry",
"*",
"region",
",",
"*",
"rom",
";",
"const",
"rom_source",
"*",
"source",
";",
"romdata",
"->",
"romstotal",
"=",
"0",
";",
"romdata",
"->",
"romstotalsize",
"=",
"0",
";",
"for",
"(",
"source",
"=",
"rom_first_source",
"(",
"romdata",
"->",
"machine",
"->",
"gamedrv",
",",
"romdata",
"->",
"machine",
"->",
"config",
")",
";",
"source",
"!=",
"NULL",
";",
"source",
"=",
"rom_next_source",
"(",
"romdata",
"->",
"machine",
"->",
"gamedrv",
",",
"romdata",
"->",
"machine",
"->",
"config",
",",
"source",
")",
")",
"for",
"(",
"region",
"=",
"rom_first_region",
"(",
"romdata",
"->",
"machine",
"->",
"gamedrv",
",",
"source",
")",
";",
"region",
"!=",
"NULL",
";",
"region",
"=",
"rom_next_region",
"(",
"region",
")",
")",
"for",
"(",
"rom",
"=",
"rom_first_file",
"(",
"region",
")",
";",
"rom",
"!=",
"NULL",
";",
"rom",
"=",
"rom_next_file",
"(",
"rom",
")",
")",
"if",
"(",
"ROM_GETBIOSFLAGS",
"(",
"rom",
")",
"==",
"0",
"||",
"ROM_GETBIOSFLAGS",
"(",
"rom",
")",
"==",
"romdata",
"->",
"system_bios",
")",
"{",
"romdata",
"->",
"romstotal",
"++",
";",
"romdata",
"->",
"romstotalsize",
"+=",
"rom_file_size",
"(",
"rom",
")",
";",
"}",
"}"
] | count_roms - counts the total number of ROMs
that will need to be loaded | [
"count_roms",
"-",
"counts",
"the",
"total",
"number",
"of",
"ROMs",
"that",
"will",
"need",
"to",
"be",
"loaded"
] | [
"/* start with 0 */",
"/* loop over regions, then over files */"
] | [
{
"param": "romdata",
"type": "rom_load_data"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "romdata",
"type": "rom_load_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2ca52623ad8880ad97d06cb040f0354da015414f | lofunz/mieme | Reloaded/trunk/src/emu/romload.c | [
"Unlicense"
] | C | fill_random | void | static void fill_random(running_machine *machine, UINT8 *base, UINT32 length)
{
while (length--)
*base++ = mame_rand(machine);
} | /*-------------------------------------------------
fill_random - fills an area of memory with
random data
-------------------------------------------------*/ | fills an area of memory with
random data | [
"fills",
"an",
"area",
"of",
"memory",
"with",
"random",
"data"
] | static void fill_random(running_machine *machine, UINT8 *base, UINT32 length)
{
while (length--)
*base++ = mame_rand(machine);
} | [
"static",
"void",
"fill_random",
"(",
"running_machine",
"*",
"machine",
",",
"UINT8",
"*",
"base",
",",
"UINT32",
"length",
")",
"{",
"while",
"(",
"length",
"--",
")",
"*",
"base",
"++",
"=",
"mame_rand",
"(",
"machine",
")",
";",
"}"
] | fill_random - fills an area of memory with
random data | [
"fill_random",
"-",
"fills",
"an",
"area",
"of",
"memory",
"with",
"random",
"data"
] | [] | [
{
"param": "machine",
"type": "running_machine"
},
{
"param": "base",
"type": "UINT8"
},
{
"param": "length",
"type": "UINT32"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "machine",
"type": "running_machine",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "base",
"type": "UINT8",
"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": []
} |
2ca52623ad8880ad97d06cb040f0354da015414f | lofunz/mieme | Reloaded/trunk/src/emu/romload.c | [
"Unlicense"
] | C | handle_missing_file | void | static void handle_missing_file(rom_load_data *romdata, const rom_entry *romp)
{
/* optional files are okay */
if (ROM_ISOPTIONAL(romp))
{
romdata->errorstring.catprintf("OPTIONAL %s NOT FOUND\n", ROM_GETNAME(romp));
romdata->warnings++;
}
/* no good dumps are okay */
else if (ROM_NOGOODDUMP(romp))
{
romdata->errorstring.catprintf("%s NOT FOUND (NO GOOD DUMP KNOWN)\n", ROM_GETNAME(romp));
romdata->warnings++;
}
/* anything else is bad */
else
{
romdata->errorstring.catprintf("%s NOT FOUND\n", ROM_GETNAME(romp));
romdata->errors++;
}
} | /*-------------------------------------------------
handle_missing_file - handles error generation
for missing files
-------------------------------------------------*/ | handles error generation
for missing files | [
"handles",
"error",
"generation",
"for",
"missing",
"files"
] | static void handle_missing_file(rom_load_data *romdata, const rom_entry *romp)
{
if (ROM_ISOPTIONAL(romp))
{
romdata->errorstring.catprintf("OPTIONAL %s NOT FOUND\n", ROM_GETNAME(romp));
romdata->warnings++;
}
else if (ROM_NOGOODDUMP(romp))
{
romdata->errorstring.catprintf("%s NOT FOUND (NO GOOD DUMP KNOWN)\n", ROM_GETNAME(romp));
romdata->warnings++;
}
else
{
romdata->errorstring.catprintf("%s NOT FOUND\n", ROM_GETNAME(romp));
romdata->errors++;
}
} | [
"static",
"void",
"handle_missing_file",
"(",
"rom_load_data",
"*",
"romdata",
",",
"const",
"rom_entry",
"*",
"romp",
")",
"{",
"if",
"(",
"ROM_ISOPTIONAL",
"(",
"romp",
")",
")",
"{",
"romdata",
"->",
"errorstring",
".",
"catprintf",
"(",
"\"",
"\\n",
"\"",
",",
"ROM_GETNAME",
"(",
"romp",
")",
")",
";",
"romdata",
"->",
"warnings",
"++",
";",
"}",
"else",
"if",
"(",
"ROM_NOGOODDUMP",
"(",
"romp",
")",
")",
"{",
"romdata",
"->",
"errorstring",
".",
"catprintf",
"(",
"\"",
"\\n",
"\"",
",",
"ROM_GETNAME",
"(",
"romp",
")",
")",
";",
"romdata",
"->",
"warnings",
"++",
";",
"}",
"else",
"{",
"romdata",
"->",
"errorstring",
".",
"catprintf",
"(",
"\"",
"\\n",
"\"",
",",
"ROM_GETNAME",
"(",
"romp",
")",
")",
";",
"romdata",
"->",
"errors",
"++",
";",
"}",
"}"
] | handle_missing_file - handles error generation
for missing files | [
"handle_missing_file",
"-",
"handles",
"error",
"generation",
"for",
"missing",
"files"
] | [
"/* optional files are okay */",
"/* no good dumps are okay */",
"/* anything else is bad */"
] | [
{
"param": "romdata",
"type": "rom_load_data"
},
{
"param": "romp",
"type": "rom_entry"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "romdata",
"type": "rom_load_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "romp",
"type": "rom_entry",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2ca52623ad8880ad97d06cb040f0354da015414f | lofunz/mieme | Reloaded/trunk/src/emu/romload.c | [
"Unlicense"
] | C | dump_wrong_and_correct_checksums | void | static void dump_wrong_and_correct_checksums(rom_load_data *romdata, const char *hash, const char *acthash)
{
unsigned i;
char chksum[256];
unsigned found_functions;
unsigned wrong_functions;
found_functions = hash_data_used_functions(hash) & hash_data_used_functions(acthash);
hash_data_print(hash, found_functions, chksum);
romdata->errorstring.catprintf(" EXPECTED: %s\n", chksum);
/* We dump informations only of the functions for which MAME provided
a correct checksum. Other functions we might have calculated are
useless here */
hash_data_print(acthash, found_functions, chksum);
romdata->errorstring.catprintf(" FOUND: %s\n", chksum);
/* For debugging purposes, we check if the checksums available in the
driver are correctly specified or not. This can be done by checking
the return value of one of the extract functions. Maybe we want to
activate this only in debug buils, but many developers only use
release builds, so I keep it as is for now. */
wrong_functions = 0;
for (i = 0; i < HASH_NUM_FUNCTIONS; i++)
if (hash_data_extract_printable_checksum(hash, 1 << i, chksum) == 2)
wrong_functions |= 1 << i;
if (wrong_functions)
{
for (i = 0; i < HASH_NUM_FUNCTIONS; i++)
if (wrong_functions & (1 << i))
{
romdata->errorstring.catprintf(
"\tInvalid %s checksum treated as 0 (check leading zeros)\n",
hash_function_name(1 << i));
romdata->warnings++;
}
}
} | /*-------------------------------------------------
dump_wrong_and_correct_checksums - dump an
error message containing the wrong and the
correct checksums for a given ROM
-------------------------------------------------*/ | dump an
error message containing the wrong and the
correct checksums for a given ROM | [
"dump",
"an",
"error",
"message",
"containing",
"the",
"wrong",
"and",
"the",
"correct",
"checksums",
"for",
"a",
"given",
"ROM"
] | static void dump_wrong_and_correct_checksums(rom_load_data *romdata, const char *hash, const char *acthash)
{
unsigned i;
char chksum[256];
unsigned found_functions;
unsigned wrong_functions;
found_functions = hash_data_used_functions(hash) & hash_data_used_functions(acthash);
hash_data_print(hash, found_functions, chksum);
romdata->errorstring.catprintf(" EXPECTED: %s\n", chksum);
hash_data_print(acthash, found_functions, chksum);
romdata->errorstring.catprintf(" FOUND: %s\n", chksum);
wrong_functions = 0;
for (i = 0; i < HASH_NUM_FUNCTIONS; i++)
if (hash_data_extract_printable_checksum(hash, 1 << i, chksum) == 2)
wrong_functions |= 1 << i;
if (wrong_functions)
{
for (i = 0; i < HASH_NUM_FUNCTIONS; i++)
if (wrong_functions & (1 << i))
{
romdata->errorstring.catprintf(
"\tInvalid %s checksum treated as 0 (check leading zeros)\n",
hash_function_name(1 << i));
romdata->warnings++;
}
}
} | [
"static",
"void",
"dump_wrong_and_correct_checksums",
"(",
"rom_load_data",
"*",
"romdata",
",",
"const",
"char",
"*",
"hash",
",",
"const",
"char",
"*",
"acthash",
")",
"{",
"unsigned",
"i",
";",
"char",
"chksum",
"[",
"256",
"]",
";",
"unsigned",
"found_functions",
";",
"unsigned",
"wrong_functions",
";",
"found_functions",
"=",
"hash_data_used_functions",
"(",
"hash",
")",
"&",
"hash_data_used_functions",
"(",
"acthash",
")",
";",
"hash_data_print",
"(",
"hash",
",",
"found_functions",
",",
"chksum",
")",
";",
"romdata",
"->",
"errorstring",
".",
"catprintf",
"(",
"\"",
"\\n",
"\"",
",",
"chksum",
")",
";",
"hash_data_print",
"(",
"acthash",
",",
"found_functions",
",",
"chksum",
")",
";",
"romdata",
"->",
"errorstring",
".",
"catprintf",
"(",
"\"",
"\\n",
"\"",
",",
"chksum",
")",
";",
"wrong_functions",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"HASH_NUM_FUNCTIONS",
";",
"i",
"++",
")",
"if",
"(",
"hash_data_extract_printable_checksum",
"(",
"hash",
",",
"1",
"<<",
"i",
",",
"chksum",
")",
"==",
"2",
")",
"wrong_functions",
"|=",
"1",
"<<",
"i",
";",
"if",
"(",
"wrong_functions",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"HASH_NUM_FUNCTIONS",
";",
"i",
"++",
")",
"if",
"(",
"wrong_functions",
"&",
"(",
"1",
"<<",
"i",
")",
")",
"{",
"romdata",
"->",
"errorstring",
".",
"catprintf",
"(",
"\"",
"\\t",
"\\n",
"\"",
",",
"hash_function_name",
"(",
"1",
"<<",
"i",
")",
")",
";",
"romdata",
"->",
"warnings",
"++",
";",
"}",
"}",
"}"
] | dump_wrong_and_correct_checksums - dump an
error message containing the wrong and the
correct checksums for a given ROM | [
"dump_wrong_and_correct_checksums",
"-",
"dump",
"an",
"error",
"message",
"containing",
"the",
"wrong",
"and",
"the",
"correct",
"checksums",
"for",
"a",
"given",
"ROM"
] | [
"/* We dump informations only of the functions for which MAME provided\r\n a correct checksum. Other functions we might have calculated are\r\n useless here */",
"/* For debugging purposes, we check if the checksums available in the\r\n driver are correctly specified or not. This can be done by checking\r\n the return value of one of the extract functions. Maybe we want to\r\n activate this only in debug buils, but many developers only use\r\n release builds, so I keep it as is for now. */"
] | [
{
"param": "romdata",
"type": "rom_load_data"
},
{
"param": "hash",
"type": "char"
},
{
"param": "acthash",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "romdata",
"type": "rom_load_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "hash",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "acthash",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2ca52623ad8880ad97d06cb040f0354da015414f | lofunz/mieme | Reloaded/trunk/src/emu/romload.c | [
"Unlicense"
] | C | verify_length_and_hash | void | static void verify_length_and_hash(rom_load_data *romdata, const char *name, UINT32 explength, const char *hash)
{
UINT32 actlength;
const char* acthash;
/* we've already complained if there is no file */
if (romdata->file == NULL)
return;
/* get the length and CRC from the file */
actlength = mame_fsize(romdata->file);
acthash = mame_fhash(romdata->file, hash_data_used_functions(hash));
/* verify length */
if (explength != actlength)
{
romdata->errorstring.catprintf("%s WRONG LENGTH (expected: %08x found: %08x)\n", name, explength, actlength);
romdata->warnings++;
}
/* If there is no good dump known, write it */
if (hash_data_has_info(hash, HASH_INFO_NO_DUMP))
{
romdata->errorstring.catprintf("%s NO GOOD DUMP KNOWN\n", name);
romdata->warnings++;
}
/* verify checksums */
else if (!hash_data_is_equal(hash, acthash, 0))
{
/* otherwise, it's just bad */
romdata->errorstring.catprintf("%s WRONG CHECKSUMS:\n", name);
dump_wrong_and_correct_checksums(romdata, hash, acthash);
romdata->warnings++;
}
/* If it matches, but it is actually a bad dump, write it */
else if (hash_data_has_info(hash, HASH_INFO_BAD_DUMP))
{
romdata->errorstring.catprintf("%s ROM NEEDS REDUMP\n",name);
romdata->warnings++;
}
} | /*-------------------------------------------------
verify_length_and_hash - verify the length
and hash signatures of a file
-------------------------------------------------*/ | verify the length
and hash signatures of a file | [
"verify",
"the",
"length",
"and",
"hash",
"signatures",
"of",
"a",
"file"
] | static void verify_length_and_hash(rom_load_data *romdata, const char *name, UINT32 explength, const char *hash)
{
UINT32 actlength;
const char* acthash;
if (romdata->file == NULL)
return;
actlength = mame_fsize(romdata->file);
acthash = mame_fhash(romdata->file, hash_data_used_functions(hash));
if (explength != actlength)
{
romdata->errorstring.catprintf("%s WRONG LENGTH (expected: %08x found: %08x)\n", name, explength, actlength);
romdata->warnings++;
}
if (hash_data_has_info(hash, HASH_INFO_NO_DUMP))
{
romdata->errorstring.catprintf("%s NO GOOD DUMP KNOWN\n", name);
romdata->warnings++;
}
else if (!hash_data_is_equal(hash, acthash, 0))
{
romdata->errorstring.catprintf("%s WRONG CHECKSUMS:\n", name);
dump_wrong_and_correct_checksums(romdata, hash, acthash);
romdata->warnings++;
}
else if (hash_data_has_info(hash, HASH_INFO_BAD_DUMP))
{
romdata->errorstring.catprintf("%s ROM NEEDS REDUMP\n",name);
romdata->warnings++;
}
} | [
"static",
"void",
"verify_length_and_hash",
"(",
"rom_load_data",
"*",
"romdata",
",",
"const",
"char",
"*",
"name",
",",
"UINT32",
"explength",
",",
"const",
"char",
"*",
"hash",
")",
"{",
"UINT32",
"actlength",
";",
"const",
"char",
"*",
"acthash",
";",
"if",
"(",
"romdata",
"->",
"file",
"==",
"NULL",
")",
"return",
";",
"actlength",
"=",
"mame_fsize",
"(",
"romdata",
"->",
"file",
")",
";",
"acthash",
"=",
"mame_fhash",
"(",
"romdata",
"->",
"file",
",",
"hash_data_used_functions",
"(",
"hash",
")",
")",
";",
"if",
"(",
"explength",
"!=",
"actlength",
")",
"{",
"romdata",
"->",
"errorstring",
".",
"catprintf",
"(",
"\"",
"\\n",
"\"",
",",
"name",
",",
"explength",
",",
"actlength",
")",
";",
"romdata",
"->",
"warnings",
"++",
";",
"}",
"if",
"(",
"hash_data_has_info",
"(",
"hash",
",",
"HASH_INFO_NO_DUMP",
")",
")",
"{",
"romdata",
"->",
"errorstring",
".",
"catprintf",
"(",
"\"",
"\\n",
"\"",
",",
"name",
")",
";",
"romdata",
"->",
"warnings",
"++",
";",
"}",
"else",
"if",
"(",
"!",
"hash_data_is_equal",
"(",
"hash",
",",
"acthash",
",",
"0",
")",
")",
"{",
"romdata",
"->",
"errorstring",
".",
"catprintf",
"(",
"\"",
"\\n",
"\"",
",",
"name",
")",
";",
"dump_wrong_and_correct_checksums",
"(",
"romdata",
",",
"hash",
",",
"acthash",
")",
";",
"romdata",
"->",
"warnings",
"++",
";",
"}",
"else",
"if",
"(",
"hash_data_has_info",
"(",
"hash",
",",
"HASH_INFO_BAD_DUMP",
")",
")",
"{",
"romdata",
"->",
"errorstring",
".",
"catprintf",
"(",
"\"",
"\\n",
"\"",
",",
"name",
")",
";",
"romdata",
"->",
"warnings",
"++",
";",
"}",
"}"
] | verify_length_and_hash - verify the length
and hash signatures of a file | [
"verify_length_and_hash",
"-",
"verify",
"the",
"length",
"and",
"hash",
"signatures",
"of",
"a",
"file"
] | [
"/* we've already complained if there is no file */",
"/* get the length and CRC from the file */",
"/* verify length */",
"/* If there is no good dump known, write it */",
"/* verify checksums */",
"/* otherwise, it's just bad */",
"/* If it matches, but it is actually a bad dump, write it */"
] | [
{
"param": "romdata",
"type": "rom_load_data"
},
{
"param": "name",
"type": "char"
},
{
"param": "explength",
"type": "UINT32"
},
{
"param": "hash",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "romdata",
"type": "rom_load_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "explength",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "hash",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2ca52623ad8880ad97d06cb040f0354da015414f | lofunz/mieme | Reloaded/trunk/src/emu/romload.c | [
"Unlicense"
] | C | display_loading_rom_message | void | static void display_loading_rom_message(rom_load_data *romdata, const char *name)
{
char buffer[200];
// 2010-04, FP - FIXME: in MESS, load_software_part_region sometimes calls this with romstotalsize = 0!
// as a temp workaround, I added a check for romstotalsize !=0.
if (name != NULL && romdata->romstotalsize)
sprintf(buffer, "Loading (%d%%)", (UINT32)(100 * (UINT64)romdata->romsloadedsize / (UINT64)romdata->romstotalsize));
else
sprintf(buffer, "Loading Complete");
ui_set_startup_text(romdata->machine, buffer, FALSE);
} | /*-------------------------------------------------
display_loading_rom_message - display
messages about ROM loading to the user
-------------------------------------------------*/ | display
messages about ROM loading to the user | [
"display",
"messages",
"about",
"ROM",
"loading",
"to",
"the",
"user"
] | static void display_loading_rom_message(rom_load_data *romdata, const char *name)
{
char buffer[200];
if (name != NULL && romdata->romstotalsize)
sprintf(buffer, "Loading (%d%%)", (UINT32)(100 * (UINT64)romdata->romsloadedsize / (UINT64)romdata->romstotalsize));
else
sprintf(buffer, "Loading Complete");
ui_set_startup_text(romdata->machine, buffer, FALSE);
} | [
"static",
"void",
"display_loading_rom_message",
"(",
"rom_load_data",
"*",
"romdata",
",",
"const",
"char",
"*",
"name",
")",
"{",
"char",
"buffer",
"[",
"200",
"]",
";",
"if",
"(",
"name",
"!=",
"NULL",
"&&",
"romdata",
"->",
"romstotalsize",
")",
"sprintf",
"(",
"buffer",
",",
"\"",
"\"",
",",
"(",
"UINT32",
")",
"(",
"100",
"*",
"(",
"UINT64",
")",
"romdata",
"->",
"romsloadedsize",
"/",
"(",
"UINT64",
")",
"romdata",
"->",
"romstotalsize",
")",
")",
";",
"else",
"sprintf",
"(",
"buffer",
",",
"\"",
"\"",
")",
";",
"ui_set_startup_text",
"(",
"romdata",
"->",
"machine",
",",
"buffer",
",",
"FALSE",
")",
";",
"}"
] | display_loading_rom_message - display
messages about ROM loading to the user | [
"display_loading_rom_message",
"-",
"display",
"messages",
"about",
"ROM",
"loading",
"to",
"the",
"user"
] | [
"// 2010-04, FP - FIXME: in MESS, load_software_part_region sometimes calls this with romstotalsize = 0!\r",
"// as a temp workaround, I added a check for romstotalsize !=0.\r"
] | [
{
"param": "romdata",
"type": "rom_load_data"
},
{
"param": "name",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "romdata",
"type": "rom_load_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2ca52623ad8880ad97d06cb040f0354da015414f | lofunz/mieme | Reloaded/trunk/src/emu/romload.c | [
"Unlicense"
] | C | region_post_process | void | static void region_post_process(rom_load_data *romdata, const char *rgntag)
{
const region_info *region = romdata->machine->region(rgntag);
UINT8 *base;
int i, j;
// do nothing if no region
if (region == NULL)
return;
LOG(("+ datawidth=%d little=%d\n", region->width(), region->endianness() == ENDIANNESS_LITTLE));
/* if the region is inverted, do that now */
if (region->invert())
{
LOG(("+ Inverting region\n"));
for (i = 0, base = region->base(); i < region->bytes(); i++)
*base++ ^= 0xff;
}
/* swap the endianness if we need to */
if (region->width() > 1 && region->endianness() != ENDIANNESS_NATIVE)
{
LOG(("+ Byte swapping region\n"));
int datawidth = region->width();
for (i = 0, base = region->base(); i < region->bytes(); i += datawidth)
{
UINT8 temp[8];
memcpy(temp, base, datawidth);
for (j = datawidth - 1; j >= 0; j--)
*base++ = temp[j];
}
}
} | /*-------------------------------------------------
region_post_process - post-process a region,
byte swapping and inverting data as necessary
-------------------------------------------------*/ | post-process a region,
byte swapping and inverting data as necessary | [
"post",
"-",
"process",
"a",
"region",
"byte",
"swapping",
"and",
"inverting",
"data",
"as",
"necessary"
] | static void region_post_process(rom_load_data *romdata, const char *rgntag)
{
const region_info *region = romdata->machine->region(rgntag);
UINT8 *base;
int i, j;
if (region == NULL)
return;
LOG(("+ datawidth=%d little=%d\n", region->width(), region->endianness() == ENDIANNESS_LITTLE));
if (region->invert())
{
LOG(("+ Inverting region\n"));
for (i = 0, base = region->base(); i < region->bytes(); i++)
*base++ ^= 0xff;
}
if (region->width() > 1 && region->endianness() != ENDIANNESS_NATIVE)
{
LOG(("+ Byte swapping region\n"));
int datawidth = region->width();
for (i = 0, base = region->base(); i < region->bytes(); i += datawidth)
{
UINT8 temp[8];
memcpy(temp, base, datawidth);
for (j = datawidth - 1; j >= 0; j--)
*base++ = temp[j];
}
}
} | [
"static",
"void",
"region_post_process",
"(",
"rom_load_data",
"*",
"romdata",
",",
"const",
"char",
"*",
"rgntag",
")",
"{",
"const",
"region_info",
"*",
"region",
"=",
"romdata",
"->",
"machine",
"->",
"region",
"(",
"rgntag",
")",
";",
"UINT8",
"*",
"base",
";",
"int",
"i",
",",
"j",
";",
"if",
"(",
"region",
"==",
"NULL",
")",
"return",
";",
"LOG",
"(",
"(",
"\"",
"\\n",
"\"",
",",
"region",
"->",
"width",
"(",
")",
",",
"region",
"->",
"endianness",
"(",
")",
"==",
"ENDIANNESS_LITTLE",
")",
")",
";",
"if",
"(",
"region",
"->",
"invert",
"(",
")",
")",
"{",
"LOG",
"(",
"(",
"\"",
"\\n",
"\"",
")",
")",
";",
"for",
"(",
"i",
"=",
"0",
",",
"base",
"=",
"region",
"->",
"base",
"(",
")",
";",
"i",
"<",
"region",
"->",
"bytes",
"(",
")",
";",
"i",
"++",
")",
"*",
"base",
"++",
"^=",
"0xff",
";",
"}",
"if",
"(",
"region",
"->",
"width",
"(",
")",
">",
"1",
"&&",
"region",
"->",
"endianness",
"(",
")",
"!=",
"ENDIANNESS_NATIVE",
")",
"{",
"LOG",
"(",
"(",
"\"",
"\\n",
"\"",
")",
")",
";",
"int",
"datawidth",
"=",
"region",
"->",
"width",
"(",
")",
";",
"for",
"(",
"i",
"=",
"0",
",",
"base",
"=",
"region",
"->",
"base",
"(",
")",
";",
"i",
"<",
"region",
"->",
"bytes",
"(",
")",
";",
"i",
"+=",
"datawidth",
")",
"{",
"UINT8",
"temp",
"[",
"8",
"]",
";",
"memcpy",
"(",
"temp",
",",
"base",
",",
"datawidth",
")",
";",
"for",
"(",
"j",
"=",
"datawidth",
"-",
"1",
";",
"j",
">=",
"0",
";",
"j",
"--",
")",
"*",
"base",
"++",
"=",
"temp",
"[",
"j",
"]",
";",
"}",
"}",
"}"
] | region_post_process - post-process a region,
byte swapping and inverting data as necessary | [
"region_post_process",
"-",
"post",
"-",
"process",
"a",
"region",
"byte",
"swapping",
"and",
"inverting",
"data",
"as",
"necessary"
] | [
"// do nothing if no region\r",
"/* if the region is inverted, do that now */",
"/* swap the endianness if we need to */"
] | [
{
"param": "romdata",
"type": "rom_load_data"
},
{
"param": "rgntag",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "romdata",
"type": "rom_load_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rgntag",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2ca52623ad8880ad97d06cb040f0354da015414f | lofunz/mieme | Reloaded/trunk/src/emu/romload.c | [
"Unlicense"
] | C | rom_fread | int | static int rom_fread(rom_load_data *romdata, UINT8 *buffer, int length)
{
/* files just pass through */
if (romdata->file != NULL)
return mame_fread(romdata->file, buffer, length);
/* otherwise, fill with randomness */
else
fill_random(romdata->machine, buffer, length);
return length;
} | /*-------------------------------------------------
rom_fread - cheesy fread that fills with
random data for a NULL file
-------------------------------------------------*/ | cheesy fread that fills with
random data for a NULL file | [
"cheesy",
"fread",
"that",
"fills",
"with",
"random",
"data",
"for",
"a",
"NULL",
"file"
] | static int rom_fread(rom_load_data *romdata, UINT8 *buffer, int length)
{
if (romdata->file != NULL)
return mame_fread(romdata->file, buffer, length);
else
fill_random(romdata->machine, buffer, length);
return length;
} | [
"static",
"int",
"rom_fread",
"(",
"rom_load_data",
"*",
"romdata",
",",
"UINT8",
"*",
"buffer",
",",
"int",
"length",
")",
"{",
"if",
"(",
"romdata",
"->",
"file",
"!=",
"NULL",
")",
"return",
"mame_fread",
"(",
"romdata",
"->",
"file",
",",
"buffer",
",",
"length",
")",
";",
"else",
"fill_random",
"(",
"romdata",
"->",
"machine",
",",
"buffer",
",",
"length",
")",
";",
"return",
"length",
";",
"}"
] | rom_fread - cheesy fread that fills with
random data for a NULL file | [
"rom_fread",
"-",
"cheesy",
"fread",
"that",
"fills",
"with",
"random",
"data",
"for",
"a",
"NULL",
"file"
] | [
"/* files just pass through */",
"/* otherwise, fill with randomness */"
] | [
{
"param": "romdata",
"type": "rom_load_data"
},
{
"param": "buffer",
"type": "UINT8"
},
{
"param": "length",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "romdata",
"type": "rom_load_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "buffer",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "length",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2ca52623ad8880ad97d06cb040f0354da015414f | lofunz/mieme | Reloaded/trunk/src/emu/romload.c | [
"Unlicense"
] | C | read_rom_data | int | static int read_rom_data(rom_load_data *romdata, const rom_entry *romp)
{
int datashift = ROM_GETBITSHIFT(romp);
int datamask = ((1 << ROM_GETBITWIDTH(romp)) - 1) << datashift;
int numbytes = ROM_GETLENGTH(romp);
int groupsize = ROM_GETGROUPSIZE(romp);
int skip = ROM_GETSKIPCOUNT(romp);
int reversed = ROM_ISREVERSED(romp);
int numgroups = (numbytes + groupsize - 1) / groupsize;
UINT8 *base = romdata->region->base() + ROM_GETOFFSET(romp);
UINT32 tempbufsize;
UINT8 *tempbuf;
int i;
LOG(("Loading ROM data: offs=%X len=%X mask=%02X group=%d skip=%d reverse=%d\n", ROM_GETOFFSET(romp), numbytes, datamask, groupsize, skip, reversed));
/* make sure the length was an even multiple of the group size */
if (numbytes % groupsize != 0)
fatalerror("Error in RomModule definition: %s length not an even multiple of group size\n", ROM_GETNAME(romp));
/* make sure we only fill within the region space */
if (ROM_GETOFFSET(romp) + numgroups * groupsize + (numgroups - 1) * skip > romdata->region->bytes())
fatalerror("Error in RomModule definition: %s out of memory region space\n", ROM_GETNAME(romp));
/* make sure the length was valid */
if (numbytes == 0)
fatalerror("Error in RomModule definition: %s has an invalid length\n", ROM_GETNAME(romp));
/* special case for simple loads */
if (datamask == 0xff && (groupsize == 1 || !reversed) && skip == 0)
return rom_fread(romdata, base, numbytes);
/* use a temporary buffer for complex loads */
tempbufsize = MIN(TEMPBUFFER_MAX_SIZE, numbytes);
tempbuf = auto_alloc_array(romdata->machine, UINT8, tempbufsize);
/* chunky reads for complex loads */
skip += groupsize;
while (numbytes > 0)
{
int evengroupcount = (tempbufsize / groupsize) * groupsize;
int bytesleft = (numbytes > evengroupcount) ? evengroupcount : numbytes;
UINT8 *bufptr = tempbuf;
/* read as much as we can */
LOG((" Reading %X bytes into buffer\n", bytesleft));
if (rom_fread(romdata, bufptr, bytesleft) != bytesleft)
{
auto_free(romdata->machine, tempbuf);
return 0;
}
numbytes -= bytesleft;
LOG((" Copying to %p\n", base));
/* unmasked cases */
if (datamask == 0xff)
{
/* non-grouped data */
if (groupsize == 1)
for (i = 0; i < bytesleft; i++, base += skip)
*base = *bufptr++;
/* grouped data -- non-reversed case */
else if (!reversed)
while (bytesleft)
{
for (i = 0; i < groupsize && bytesleft; i++, bytesleft--)
base[i] = *bufptr++;
base += skip;
}
/* grouped data -- reversed case */
else
while (bytesleft)
{
for (i = groupsize - 1; i >= 0 && bytesleft; i--, bytesleft--)
base[i] = *bufptr++;
base += skip;
}
}
/* masked cases */
else
{
/* non-grouped data */
if (groupsize == 1)
for (i = 0; i < bytesleft; i++, base += skip)
*base = (*base & ~datamask) | ((*bufptr++ << datashift) & datamask);
/* grouped data -- non-reversed case */
else if (!reversed)
while (bytesleft)
{
for (i = 0; i < groupsize && bytesleft; i++, bytesleft--)
base[i] = (base[i] & ~datamask) | ((*bufptr++ << datashift) & datamask);
base += skip;
}
/* grouped data -- reversed case */
else
while (bytesleft)
{
for (i = groupsize - 1; i >= 0 && bytesleft; i--, bytesleft--)
base[i] = (base[i] & ~datamask) | ((*bufptr++ << datashift) & datamask);
base += skip;
}
}
}
auto_free(romdata->machine, tempbuf);
LOG((" All done\n"));
return ROM_GETLENGTH(romp);
} | /*-------------------------------------------------
read_rom_data - read ROM data for a single
entry
-------------------------------------------------*/ | read ROM data for a single
entry | [
"read",
"ROM",
"data",
"for",
"a",
"single",
"entry"
] | static int read_rom_data(rom_load_data *romdata, const rom_entry *romp)
{
int datashift = ROM_GETBITSHIFT(romp);
int datamask = ((1 << ROM_GETBITWIDTH(romp)) - 1) << datashift;
int numbytes = ROM_GETLENGTH(romp);
int groupsize = ROM_GETGROUPSIZE(romp);
int skip = ROM_GETSKIPCOUNT(romp);
int reversed = ROM_ISREVERSED(romp);
int numgroups = (numbytes + groupsize - 1) / groupsize;
UINT8 *base = romdata->region->base() + ROM_GETOFFSET(romp);
UINT32 tempbufsize;
UINT8 *tempbuf;
int i;
LOG(("Loading ROM data: offs=%X len=%X mask=%02X group=%d skip=%d reverse=%d\n", ROM_GETOFFSET(romp), numbytes, datamask, groupsize, skip, reversed));
if (numbytes % groupsize != 0)
fatalerror("Error in RomModule definition: %s length not an even multiple of group size\n", ROM_GETNAME(romp));
if (ROM_GETOFFSET(romp) + numgroups * groupsize + (numgroups - 1) * skip > romdata->region->bytes())
fatalerror("Error in RomModule definition: %s out of memory region space\n", ROM_GETNAME(romp));
if (numbytes == 0)
fatalerror("Error in RomModule definition: %s has an invalid length\n", ROM_GETNAME(romp));
if (datamask == 0xff && (groupsize == 1 || !reversed) && skip == 0)
return rom_fread(romdata, base, numbytes);
tempbufsize = MIN(TEMPBUFFER_MAX_SIZE, numbytes);
tempbuf = auto_alloc_array(romdata->machine, UINT8, tempbufsize);
skip += groupsize;
while (numbytes > 0)
{
int evengroupcount = (tempbufsize / groupsize) * groupsize;
int bytesleft = (numbytes > evengroupcount) ? evengroupcount : numbytes;
UINT8 *bufptr = tempbuf;
LOG((" Reading %X bytes into buffer\n", bytesleft));
if (rom_fread(romdata, bufptr, bytesleft) != bytesleft)
{
auto_free(romdata->machine, tempbuf);
return 0;
}
numbytes -= bytesleft;
LOG((" Copying to %p\n", base));
if (datamask == 0xff)
{
if (groupsize == 1)
for (i = 0; i < bytesleft; i++, base += skip)
*base = *bufptr++;
else if (!reversed)
while (bytesleft)
{
for (i = 0; i < groupsize && bytesleft; i++, bytesleft--)
base[i] = *bufptr++;
base += skip;
}
else
while (bytesleft)
{
for (i = groupsize - 1; i >= 0 && bytesleft; i--, bytesleft--)
base[i] = *bufptr++;
base += skip;
}
}
else
{
if (groupsize == 1)
for (i = 0; i < bytesleft; i++, base += skip)
*base = (*base & ~datamask) | ((*bufptr++ << datashift) & datamask);
else if (!reversed)
while (bytesleft)
{
for (i = 0; i < groupsize && bytesleft; i++, bytesleft--)
base[i] = (base[i] & ~datamask) | ((*bufptr++ << datashift) & datamask);
base += skip;
}
else
while (bytesleft)
{
for (i = groupsize - 1; i >= 0 && bytesleft; i--, bytesleft--)
base[i] = (base[i] & ~datamask) | ((*bufptr++ << datashift) & datamask);
base += skip;
}
}
}
auto_free(romdata->machine, tempbuf);
LOG((" All done\n"));
return ROM_GETLENGTH(romp);
} | [
"static",
"int",
"read_rom_data",
"(",
"rom_load_data",
"*",
"romdata",
",",
"const",
"rom_entry",
"*",
"romp",
")",
"{",
"int",
"datashift",
"=",
"ROM_GETBITSHIFT",
"(",
"romp",
")",
";",
"int",
"datamask",
"=",
"(",
"(",
"1",
"<<",
"ROM_GETBITWIDTH",
"(",
"romp",
")",
")",
"-",
"1",
")",
"<<",
"datashift",
";",
"int",
"numbytes",
"=",
"ROM_GETLENGTH",
"(",
"romp",
")",
";",
"int",
"groupsize",
"=",
"ROM_GETGROUPSIZE",
"(",
"romp",
")",
";",
"int",
"skip",
"=",
"ROM_GETSKIPCOUNT",
"(",
"romp",
")",
";",
"int",
"reversed",
"=",
"ROM_ISREVERSED",
"(",
"romp",
")",
";",
"int",
"numgroups",
"=",
"(",
"numbytes",
"+",
"groupsize",
"-",
"1",
")",
"/",
"groupsize",
";",
"UINT8",
"*",
"base",
"=",
"romdata",
"->",
"region",
"->",
"base",
"(",
")",
"+",
"ROM_GETOFFSET",
"(",
"romp",
")",
";",
"UINT32",
"tempbufsize",
";",
"UINT8",
"*",
"tempbuf",
";",
"int",
"i",
";",
"LOG",
"(",
"(",
"\"",
"\\n",
"\"",
",",
"ROM_GETOFFSET",
"(",
"romp",
")",
",",
"numbytes",
",",
"datamask",
",",
"groupsize",
",",
"skip",
",",
"reversed",
")",
")",
";",
"if",
"(",
"numbytes",
"%",
"groupsize",
"!=",
"0",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"ROM_GETNAME",
"(",
"romp",
")",
")",
";",
"if",
"(",
"ROM_GETOFFSET",
"(",
"romp",
")",
"+",
"numgroups",
"*",
"groupsize",
"+",
"(",
"numgroups",
"-",
"1",
")",
"*",
"skip",
">",
"romdata",
"->",
"region",
"->",
"bytes",
"(",
")",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"ROM_GETNAME",
"(",
"romp",
")",
")",
";",
"if",
"(",
"numbytes",
"==",
"0",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"ROM_GETNAME",
"(",
"romp",
")",
")",
";",
"if",
"(",
"datamask",
"==",
"0xff",
"&&",
"(",
"groupsize",
"==",
"1",
"||",
"!",
"reversed",
")",
"&&",
"skip",
"==",
"0",
")",
"return",
"rom_fread",
"(",
"romdata",
",",
"base",
",",
"numbytes",
")",
";",
"tempbufsize",
"=",
"MIN",
"(",
"TEMPBUFFER_MAX_SIZE",
",",
"numbytes",
")",
";",
"tempbuf",
"=",
"auto_alloc_array",
"(",
"romdata",
"->",
"machine",
",",
"UINT8",
",",
"tempbufsize",
")",
";",
"skip",
"+=",
"groupsize",
";",
"while",
"(",
"numbytes",
">",
"0",
")",
"{",
"int",
"evengroupcount",
"=",
"(",
"tempbufsize",
"/",
"groupsize",
")",
"*",
"groupsize",
";",
"int",
"bytesleft",
"=",
"(",
"numbytes",
">",
"evengroupcount",
")",
"?",
"evengroupcount",
":",
"numbytes",
";",
"UINT8",
"*",
"bufptr",
"=",
"tempbuf",
";",
"LOG",
"(",
"(",
"\"",
"\\n",
"\"",
",",
"bytesleft",
")",
")",
";",
"if",
"(",
"rom_fread",
"(",
"romdata",
",",
"bufptr",
",",
"bytesleft",
")",
"!=",
"bytesleft",
")",
"{",
"auto_free",
"(",
"romdata",
"->",
"machine",
",",
"tempbuf",
")",
";",
"return",
"0",
";",
"}",
"numbytes",
"-=",
"bytesleft",
";",
"LOG",
"(",
"(",
"\"",
"\\n",
"\"",
",",
"base",
")",
")",
";",
"if",
"(",
"datamask",
"==",
"0xff",
")",
"{",
"if",
"(",
"groupsize",
"==",
"1",
")",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"bytesleft",
";",
"i",
"++",
",",
"base",
"+=",
"skip",
")",
"*",
"base",
"=",
"*",
"bufptr",
"++",
";",
"else",
"if",
"(",
"!",
"reversed",
")",
"while",
"(",
"bytesleft",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"groupsize",
"&&",
"bytesleft",
";",
"i",
"++",
",",
"bytesleft",
"--",
")",
"base",
"[",
"i",
"]",
"=",
"*",
"bufptr",
"++",
";",
"base",
"+=",
"skip",
";",
"}",
"else",
"while",
"(",
"bytesleft",
")",
"{",
"for",
"(",
"i",
"=",
"groupsize",
"-",
"1",
";",
"i",
">=",
"0",
"&&",
"bytesleft",
";",
"i",
"--",
",",
"bytesleft",
"--",
")",
"base",
"[",
"i",
"]",
"=",
"*",
"bufptr",
"++",
";",
"base",
"+=",
"skip",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"groupsize",
"==",
"1",
")",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"bytesleft",
";",
"i",
"++",
",",
"base",
"+=",
"skip",
")",
"*",
"base",
"=",
"(",
"*",
"base",
"&",
"~",
"datamask",
")",
"|",
"(",
"(",
"*",
"bufptr",
"++",
"<<",
"datashift",
")",
"&",
"datamask",
")",
";",
"else",
"if",
"(",
"!",
"reversed",
")",
"while",
"(",
"bytesleft",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"groupsize",
"&&",
"bytesleft",
";",
"i",
"++",
",",
"bytesleft",
"--",
")",
"base",
"[",
"i",
"]",
"=",
"(",
"base",
"[",
"i",
"]",
"&",
"~",
"datamask",
")",
"|",
"(",
"(",
"*",
"bufptr",
"++",
"<<",
"datashift",
")",
"&",
"datamask",
")",
";",
"base",
"+=",
"skip",
";",
"}",
"else",
"while",
"(",
"bytesleft",
")",
"{",
"for",
"(",
"i",
"=",
"groupsize",
"-",
"1",
";",
"i",
">=",
"0",
"&&",
"bytesleft",
";",
"i",
"--",
",",
"bytesleft",
"--",
")",
"base",
"[",
"i",
"]",
"=",
"(",
"base",
"[",
"i",
"]",
"&",
"~",
"datamask",
")",
"|",
"(",
"(",
"*",
"bufptr",
"++",
"<<",
"datashift",
")",
"&",
"datamask",
")",
";",
"base",
"+=",
"skip",
";",
"}",
"}",
"}",
"auto_free",
"(",
"romdata",
"->",
"machine",
",",
"tempbuf",
")",
";",
"LOG",
"(",
"(",
"\"",
"\\n",
"\"",
")",
")",
";",
"return",
"ROM_GETLENGTH",
"(",
"romp",
")",
";",
"}"
] | read_rom_data - read ROM data for a single
entry | [
"read_rom_data",
"-",
"read",
"ROM",
"data",
"for",
"a",
"single",
"entry"
] | [
"/* make sure the length was an even multiple of the group size */",
"/* make sure we only fill within the region space */",
"/* make sure the length was valid */",
"/* special case for simple loads */",
"/* use a temporary buffer for complex loads */",
"/* chunky reads for complex loads */",
"/* read as much as we can */",
"/* unmasked cases */",
"/* non-grouped data */",
"/* grouped data -- non-reversed case */",
"/* grouped data -- reversed case */",
"/* masked cases */",
"/* non-grouped data */",
"/* grouped data -- non-reversed case */",
"/* grouped data -- reversed case */"
] | [
{
"param": "romdata",
"type": "rom_load_data"
},
{
"param": "romp",
"type": "rom_entry"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "romdata",
"type": "rom_load_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "romp",
"type": "rom_entry",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2ca52623ad8880ad97d06cb040f0354da015414f | lofunz/mieme | Reloaded/trunk/src/emu/romload.c | [
"Unlicense"
] | C | fill_rom_data | void | static void fill_rom_data(rom_load_data *romdata, const rom_entry *romp)
{
UINT32 numbytes = ROM_GETLENGTH(romp);
UINT8 *base = romdata->region->base() + ROM_GETOFFSET(romp);
/* make sure we fill within the region space */
if (ROM_GETOFFSET(romp) + numbytes > romdata->region->bytes())
fatalerror("Error in RomModule definition: FILL out of memory region space\n");
/* make sure the length was valid */
if (numbytes == 0)
fatalerror("Error in RomModule definition: FILL has an invalid length\n");
/* fill the data (filling value is stored in place of the hashdata) */
memset(base, (FPTR)ROM_GETHASHDATA(romp) & 0xff, numbytes);
} | /*-------------------------------------------------
fill_rom_data - fill a region of ROM space
-------------------------------------------------*/ | fill a region of ROM space | [
"fill",
"a",
"region",
"of",
"ROM",
"space"
] | static void fill_rom_data(rom_load_data *romdata, const rom_entry *romp)
{
UINT32 numbytes = ROM_GETLENGTH(romp);
UINT8 *base = romdata->region->base() + ROM_GETOFFSET(romp);
if (ROM_GETOFFSET(romp) + numbytes > romdata->region->bytes())
fatalerror("Error in RomModule definition: FILL out of memory region space\n");
if (numbytes == 0)
fatalerror("Error in RomModule definition: FILL has an invalid length\n");
memset(base, (FPTR)ROM_GETHASHDATA(romp) & 0xff, numbytes);
} | [
"static",
"void",
"fill_rom_data",
"(",
"rom_load_data",
"*",
"romdata",
",",
"const",
"rom_entry",
"*",
"romp",
")",
"{",
"UINT32",
"numbytes",
"=",
"ROM_GETLENGTH",
"(",
"romp",
")",
";",
"UINT8",
"*",
"base",
"=",
"romdata",
"->",
"region",
"->",
"base",
"(",
")",
"+",
"ROM_GETOFFSET",
"(",
"romp",
")",
";",
"if",
"(",
"ROM_GETOFFSET",
"(",
"romp",
")",
"+",
"numbytes",
">",
"romdata",
"->",
"region",
"->",
"bytes",
"(",
")",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
")",
";",
"if",
"(",
"numbytes",
"==",
"0",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
")",
";",
"memset",
"(",
"base",
",",
"(",
"FPTR",
")",
"ROM_GETHASHDATA",
"(",
"romp",
")",
"&",
"0xff",
",",
"numbytes",
")",
";",
"}"
] | fill_rom_data - fill a region of ROM space | [
"fill_rom_data",
"-",
"fill",
"a",
"region",
"of",
"ROM",
"space"
] | [
"/* make sure we fill within the region space */",
"/* make sure the length was valid */",
"/* fill the data (filling value is stored in place of the hashdata) */"
] | [
{
"param": "romdata",
"type": "rom_load_data"
},
{
"param": "romp",
"type": "rom_entry"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "romdata",
"type": "rom_load_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "romp",
"type": "rom_entry",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2ca52623ad8880ad97d06cb040f0354da015414f | lofunz/mieme | Reloaded/trunk/src/emu/romload.c | [
"Unlicense"
] | C | copy_rom_data | void | static void copy_rom_data(rom_load_data *romdata, const rom_entry *romp)
{
UINT8 *base = romdata->region->base() + ROM_GETOFFSET(romp);
const char *srcrgntag = ROM_GETNAME(romp);
UINT32 numbytes = ROM_GETLENGTH(romp);
UINT32 srcoffs = (FPTR)ROM_GETHASHDATA(romp); /* srcoffset in place of hashdata */
/* make sure we copy within the region space */
if (ROM_GETOFFSET(romp) + numbytes > romdata->region->bytes())
fatalerror("Error in RomModule definition: COPY out of target memory region space\n");
/* make sure the length was valid */
if (numbytes == 0)
fatalerror("Error in RomModule definition: COPY has an invalid length\n");
/* make sure the source was valid */
const region_info *region = romdata->machine->region(srcrgntag);
if (region == NULL)
fatalerror("Error in RomModule definition: COPY from an invalid region\n");
/* make sure we find within the region space */
if (srcoffs + numbytes > region->bytes())
fatalerror("Error in RomModule definition: COPY out of source memory region space\n");
/* fill the data */
memcpy(base, region->base() + srcoffs, numbytes);
} | /*-------------------------------------------------
copy_rom_data - copy a region of ROM space
-------------------------------------------------*/ | copy a region of ROM space | [
"copy",
"a",
"region",
"of",
"ROM",
"space"
] | static void copy_rom_data(rom_load_data *romdata, const rom_entry *romp)
{
UINT8 *base = romdata->region->base() + ROM_GETOFFSET(romp);
const char *srcrgntag = ROM_GETNAME(romp);
UINT32 numbytes = ROM_GETLENGTH(romp);
UINT32 srcoffs = (FPTR)ROM_GETHASHDATA(romp);
if (ROM_GETOFFSET(romp) + numbytes > romdata->region->bytes())
fatalerror("Error in RomModule definition: COPY out of target memory region space\n");
if (numbytes == 0)
fatalerror("Error in RomModule definition: COPY has an invalid length\n");
const region_info *region = romdata->machine->region(srcrgntag);
if (region == NULL)
fatalerror("Error in RomModule definition: COPY from an invalid region\n");
if (srcoffs + numbytes > region->bytes())
fatalerror("Error in RomModule definition: COPY out of source memory region space\n");
memcpy(base, region->base() + srcoffs, numbytes);
} | [
"static",
"void",
"copy_rom_data",
"(",
"rom_load_data",
"*",
"romdata",
",",
"const",
"rom_entry",
"*",
"romp",
")",
"{",
"UINT8",
"*",
"base",
"=",
"romdata",
"->",
"region",
"->",
"base",
"(",
")",
"+",
"ROM_GETOFFSET",
"(",
"romp",
")",
";",
"const",
"char",
"*",
"srcrgntag",
"=",
"ROM_GETNAME",
"(",
"romp",
")",
";",
"UINT32",
"numbytes",
"=",
"ROM_GETLENGTH",
"(",
"romp",
")",
";",
"UINT32",
"srcoffs",
"=",
"(",
"FPTR",
")",
"ROM_GETHASHDATA",
"(",
"romp",
")",
";",
"if",
"(",
"ROM_GETOFFSET",
"(",
"romp",
")",
"+",
"numbytes",
">",
"romdata",
"->",
"region",
"->",
"bytes",
"(",
")",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
")",
";",
"if",
"(",
"numbytes",
"==",
"0",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
")",
";",
"const",
"region_info",
"*",
"region",
"=",
"romdata",
"->",
"machine",
"->",
"region",
"(",
"srcrgntag",
")",
";",
"if",
"(",
"region",
"==",
"NULL",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
")",
";",
"if",
"(",
"srcoffs",
"+",
"numbytes",
">",
"region",
"->",
"bytes",
"(",
")",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
")",
";",
"memcpy",
"(",
"base",
",",
"region",
"->",
"base",
"(",
")",
"+",
"srcoffs",
",",
"numbytes",
")",
";",
"}"
] | copy_rom_data - copy a region of ROM space | [
"copy_rom_data",
"-",
"copy",
"a",
"region",
"of",
"ROM",
"space"
] | [
"/* srcoffset in place of hashdata */",
"/* make sure we copy within the region space */",
"/* make sure the length was valid */",
"/* make sure the source was valid */",
"/* make sure we find within the region space */",
"/* fill the data */"
] | [
{
"param": "romdata",
"type": "rom_load_data"
},
{
"param": "romp",
"type": "rom_entry"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "romdata",
"type": "rom_load_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "romp",
"type": "rom_entry",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2ca52623ad8880ad97d06cb040f0354da015414f | lofunz/mieme | Reloaded/trunk/src/emu/romload.c | [
"Unlicense"
] | C | process_rom_entries | void | static void process_rom_entries(rom_load_data *romdata, const char *regiontag, const rom_entry *romp)
{
UINT32 lastflags = 0;
/* loop until we hit the end of this region */
while (!ROMENTRY_ISREGIONEND(romp))
{
/* if this is a continue entry, it's invalid */
if (ROMENTRY_ISCONTINUE(romp))
fatalerror("Error in RomModule definition: ROM_CONTINUE not preceded by ROM_LOAD\n");
/* if this is an ignore entry, it's invalid */
if (ROMENTRY_ISIGNORE(romp))
fatalerror("Error in RomModule definition: ROM_IGNORE not preceded by ROM_LOAD\n");
/* if this is a reload entry, it's invalid */
if (ROMENTRY_ISRELOAD(romp))
fatalerror("Error in RomModule definition: ROM_RELOAD not preceded by ROM_LOAD\n");
/* handle fills */
if (ROMENTRY_ISFILL(romp))
fill_rom_data(romdata, romp++);
/* handle copies */
else if (ROMENTRY_ISCOPY(romp))
copy_rom_data(romdata, romp++);
/* handle files */
else if (ROMENTRY_ISFILE(romp))
{
int irrelevantbios = (ROM_GETBIOSFLAGS(romp) != 0 && ROM_GETBIOSFLAGS(romp) != romdata->system_bios);
const rom_entry *baserom = romp;
int explength = 0;
/* open the file if it is a non-BIOS or matches the current BIOS */
LOG(("Opening ROM file: %s\n", ROM_GETNAME(romp)));
if (!irrelevantbios && !open_rom_file(romdata, regiontag, romp))
handle_missing_file(romdata, romp);
/* loop until we run out of reloads */
do
{
/* loop until we run out of continues/ignores */
do
{
rom_entry modified_romp = *romp++;
//int readresult;
/* handle flag inheritance */
if (!ROM_INHERITSFLAGS(&modified_romp))
lastflags = modified_romp._flags;
else
modified_romp._flags = (modified_romp._flags & ~ROM_INHERITEDFLAGS) | lastflags;
explength += ROM_GETLENGTH(&modified_romp);
/* attempt to read using the modified entry */
if (!ROMENTRY_ISIGNORE(&modified_romp) && !irrelevantbios)
/*readresult = */read_rom_data(romdata, &modified_romp);
}
while (ROMENTRY_ISCONTINUE(romp) || ROMENTRY_ISIGNORE(romp));
/* if this was the first use of this file, verify the length and CRC */
if (baserom)
{
LOG(("Verifying length (%X) and checksums\n", explength));
verify_length_and_hash(romdata, ROM_GETNAME(baserom), explength, ROM_GETHASHDATA(baserom));
LOG(("Verify finished\n"));
}
/* reseek to the start and clear the baserom so we don't reverify */
if (romdata->file != NULL)
mame_fseek(romdata->file, 0, SEEK_SET);
baserom = NULL;
explength = 0;
}
while (ROMENTRY_ISRELOAD(romp));
/* close the file */
if (romdata->file != NULL)
{
LOG(("Closing ROM file\n"));
mame_fclose(romdata->file);
romdata->file = NULL;
}
}
else
{
romp++; /* something else; skip */
}
}
} | /*-------------------------------------------------
process_rom_entries - process all ROM entries
for a region
-------------------------------------------------*/ | process all ROM entries
for a region | [
"process",
"all",
"ROM",
"entries",
"for",
"a",
"region"
] | static void process_rom_entries(rom_load_data *romdata, const char *regiontag, const rom_entry *romp)
{
UINT32 lastflags = 0;
while (!ROMENTRY_ISREGIONEND(romp))
{
if (ROMENTRY_ISCONTINUE(romp))
fatalerror("Error in RomModule definition: ROM_CONTINUE not preceded by ROM_LOAD\n");
if (ROMENTRY_ISIGNORE(romp))
fatalerror("Error in RomModule definition: ROM_IGNORE not preceded by ROM_LOAD\n");
if (ROMENTRY_ISRELOAD(romp))
fatalerror("Error in RomModule definition: ROM_RELOAD not preceded by ROM_LOAD\n");
if (ROMENTRY_ISFILL(romp))
fill_rom_data(romdata, romp++);
else if (ROMENTRY_ISCOPY(romp))
copy_rom_data(romdata, romp++);
else if (ROMENTRY_ISFILE(romp))
{
int irrelevantbios = (ROM_GETBIOSFLAGS(romp) != 0 && ROM_GETBIOSFLAGS(romp) != romdata->system_bios);
const rom_entry *baserom = romp;
int explength = 0;
LOG(("Opening ROM file: %s\n", ROM_GETNAME(romp)));
if (!irrelevantbios && !open_rom_file(romdata, regiontag, romp))
handle_missing_file(romdata, romp);
do
{
do
{
rom_entry modified_romp = *romp++;
if (!ROM_INHERITSFLAGS(&modified_romp))
lastflags = modified_romp._flags;
else
modified_romp._flags = (modified_romp._flags & ~ROM_INHERITEDFLAGS) | lastflags;
explength += ROM_GETLENGTH(&modified_romp);
if (!ROMENTRY_ISIGNORE(&modified_romp) && !irrelevantbios)
read_rom_data(romdata, &modified_romp);
}
while (ROMENTRY_ISCONTINUE(romp) || ROMENTRY_ISIGNORE(romp));
if (baserom)
{
LOG(("Verifying length (%X) and checksums\n", explength));
verify_length_and_hash(romdata, ROM_GETNAME(baserom), explength, ROM_GETHASHDATA(baserom));
LOG(("Verify finished\n"));
}
if (romdata->file != NULL)
mame_fseek(romdata->file, 0, SEEK_SET);
baserom = NULL;
explength = 0;
}
while (ROMENTRY_ISRELOAD(romp));
if (romdata->file != NULL)
{
LOG(("Closing ROM file\n"));
mame_fclose(romdata->file);
romdata->file = NULL;
}
}
else
{
romp++;
}
}
} | [
"static",
"void",
"process_rom_entries",
"(",
"rom_load_data",
"*",
"romdata",
",",
"const",
"char",
"*",
"regiontag",
",",
"const",
"rom_entry",
"*",
"romp",
")",
"{",
"UINT32",
"lastflags",
"=",
"0",
";",
"while",
"(",
"!",
"ROMENTRY_ISREGIONEND",
"(",
"romp",
")",
")",
"{",
"if",
"(",
"ROMENTRY_ISCONTINUE",
"(",
"romp",
")",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
")",
";",
"if",
"(",
"ROMENTRY_ISIGNORE",
"(",
"romp",
")",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
")",
";",
"if",
"(",
"ROMENTRY_ISRELOAD",
"(",
"romp",
")",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
")",
";",
"if",
"(",
"ROMENTRY_ISFILL",
"(",
"romp",
")",
")",
"fill_rom_data",
"(",
"romdata",
",",
"romp",
"++",
")",
";",
"else",
"if",
"(",
"ROMENTRY_ISCOPY",
"(",
"romp",
")",
")",
"copy_rom_data",
"(",
"romdata",
",",
"romp",
"++",
")",
";",
"else",
"if",
"(",
"ROMENTRY_ISFILE",
"(",
"romp",
")",
")",
"{",
"int",
"irrelevantbios",
"=",
"(",
"ROM_GETBIOSFLAGS",
"(",
"romp",
")",
"!=",
"0",
"&&",
"ROM_GETBIOSFLAGS",
"(",
"romp",
")",
"!=",
"romdata",
"->",
"system_bios",
")",
";",
"const",
"rom_entry",
"*",
"baserom",
"=",
"romp",
";",
"int",
"explength",
"=",
"0",
";",
"LOG",
"(",
"(",
"\"",
"\\n",
"\"",
",",
"ROM_GETNAME",
"(",
"romp",
")",
")",
")",
";",
"if",
"(",
"!",
"irrelevantbios",
"&&",
"!",
"open_rom_file",
"(",
"romdata",
",",
"regiontag",
",",
"romp",
")",
")",
"handle_missing_file",
"(",
"romdata",
",",
"romp",
")",
";",
"do",
"{",
"do",
"{",
"rom_entry",
"modified_romp",
"=",
"*",
"romp",
"++",
";",
"if",
"(",
"!",
"ROM_INHERITSFLAGS",
"(",
"&",
"modified_romp",
")",
")",
"lastflags",
"=",
"modified_romp",
".",
"_flags",
";",
"else",
"modified_romp",
".",
"_flags",
"=",
"(",
"modified_romp",
".",
"_flags",
"&",
"~",
"ROM_INHERITEDFLAGS",
")",
"|",
"lastflags",
";",
"explength",
"+=",
"ROM_GETLENGTH",
"(",
"&",
"modified_romp",
")",
";",
"if",
"(",
"!",
"ROMENTRY_ISIGNORE",
"(",
"&",
"modified_romp",
")",
"&&",
"!",
"irrelevantbios",
")",
"read_rom_data",
"(",
"romdata",
",",
"&",
"modified_romp",
")",
";",
"}",
"while",
"(",
"ROMENTRY_ISCONTINUE",
"(",
"romp",
")",
"||",
"ROMENTRY_ISIGNORE",
"(",
"romp",
")",
")",
";",
"if",
"(",
"baserom",
")",
"{",
"LOG",
"(",
"(",
"\"",
"\\n",
"\"",
",",
"explength",
")",
")",
";",
"verify_length_and_hash",
"(",
"romdata",
",",
"ROM_GETNAME",
"(",
"baserom",
")",
",",
"explength",
",",
"ROM_GETHASHDATA",
"(",
"baserom",
")",
")",
";",
"LOG",
"(",
"(",
"\"",
"\\n",
"\"",
")",
")",
";",
"}",
"if",
"(",
"romdata",
"->",
"file",
"!=",
"NULL",
")",
"mame_fseek",
"(",
"romdata",
"->",
"file",
",",
"0",
",",
"SEEK_SET",
")",
";",
"baserom",
"=",
"NULL",
";",
"explength",
"=",
"0",
";",
"}",
"while",
"(",
"ROMENTRY_ISRELOAD",
"(",
"romp",
")",
")",
";",
"if",
"(",
"romdata",
"->",
"file",
"!=",
"NULL",
")",
"{",
"LOG",
"(",
"(",
"\"",
"\\n",
"\"",
")",
")",
";",
"mame_fclose",
"(",
"romdata",
"->",
"file",
")",
";",
"romdata",
"->",
"file",
"=",
"NULL",
";",
"}",
"}",
"else",
"{",
"romp",
"++",
";",
"}",
"}",
"}"
] | process_rom_entries - process all ROM entries
for a region | [
"process_rom_entries",
"-",
"process",
"all",
"ROM",
"entries",
"for",
"a",
"region"
] | [
"/* loop until we hit the end of this region */",
"/* if this is a continue entry, it's invalid */",
"/* if this is an ignore entry, it's invalid */",
"/* if this is a reload entry, it's invalid */",
"/* handle fills */",
"/* handle copies */",
"/* handle files */",
"/* open the file if it is a non-BIOS or matches the current BIOS */",
"/* loop until we run out of reloads */",
"/* loop until we run out of continues/ignores */",
"//int readresult;\r",
"/* handle flag inheritance */",
"/* attempt to read using the modified entry */",
"/*readresult = */",
"/* if this was the first use of this file, verify the length and CRC */",
"/* reseek to the start and clear the baserom so we don't reverify */",
"/* close the file */",
"/* something else; skip */"
] | [
{
"param": "romdata",
"type": "rom_load_data"
},
{
"param": "regiontag",
"type": "char"
},
{
"param": "romp",
"type": "rom_entry"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "romdata",
"type": "rom_load_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "regiontag",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "romp",
"type": "rom_entry",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2ca52623ad8880ad97d06cb040f0354da015414f | lofunz/mieme | Reloaded/trunk/src/emu/romload.c | [
"Unlicense"
] | C | normalize_flags_for_device | UINT32 | static UINT32 normalize_flags_for_device(running_machine *machine, UINT32 startflags, const char *rgntag)
{
device_t *device = machine->device(rgntag);
device_memory_interface *memory;
if (device->interface(memory))
{
const address_space_config *spaceconfig = memory->space_config();
if (device != NULL && spaceconfig != NULL)
{
int buswidth;
/* set the endianness */
startflags &= ~ROMREGION_ENDIANMASK;
if (spaceconfig->m_endianness == ENDIANNESS_LITTLE)
startflags |= ROMREGION_LE;
else
startflags |= ROMREGION_BE;
/* set the width */
startflags &= ~ROMREGION_WIDTHMASK;
buswidth = spaceconfig->m_databus_width;
if (buswidth <= 8)
startflags |= ROMREGION_8BIT;
else if (buswidth <= 16)
startflags |= ROMREGION_16BIT;
else if (buswidth <= 32)
startflags |= ROMREGION_32BIT;
else
startflags |= ROMREGION_64BIT;
}
}
return startflags;
} | /*-------------------------------------------------
normalize_flags_for_device - modify the region
flags for the given device
-------------------------------------------------*/ | modify the region
flags for the given device | [
"modify",
"the",
"region",
"flags",
"for",
"the",
"given",
"device"
] | static UINT32 normalize_flags_for_device(running_machine *machine, UINT32 startflags, const char *rgntag)
{
device_t *device = machine->device(rgntag);
device_memory_interface *memory;
if (device->interface(memory))
{
const address_space_config *spaceconfig = memory->space_config();
if (device != NULL && spaceconfig != NULL)
{
int buswidth;
startflags &= ~ROMREGION_ENDIANMASK;
if (spaceconfig->m_endianness == ENDIANNESS_LITTLE)
startflags |= ROMREGION_LE;
else
startflags |= ROMREGION_BE;
startflags &= ~ROMREGION_WIDTHMASK;
buswidth = spaceconfig->m_databus_width;
if (buswidth <= 8)
startflags |= ROMREGION_8BIT;
else if (buswidth <= 16)
startflags |= ROMREGION_16BIT;
else if (buswidth <= 32)
startflags |= ROMREGION_32BIT;
else
startflags |= ROMREGION_64BIT;
}
}
return startflags;
} | [
"static",
"UINT32",
"normalize_flags_for_device",
"(",
"running_machine",
"*",
"machine",
",",
"UINT32",
"startflags",
",",
"const",
"char",
"*",
"rgntag",
")",
"{",
"device_t",
"*",
"device",
"=",
"machine",
"->",
"device",
"(",
"rgntag",
")",
";",
"device_memory_interface",
"*",
"memory",
";",
"if",
"(",
"device",
"->",
"interface",
"(",
"memory",
")",
")",
"{",
"const",
"address_space_config",
"*",
"spaceconfig",
"=",
"memory",
"->",
"space_config",
"(",
")",
";",
"if",
"(",
"device",
"!=",
"NULL",
"&&",
"spaceconfig",
"!=",
"NULL",
")",
"{",
"int",
"buswidth",
";",
"startflags",
"&=",
"~",
"ROMREGION_ENDIANMASK",
";",
"if",
"(",
"spaceconfig",
"->",
"m_endianness",
"==",
"ENDIANNESS_LITTLE",
")",
"startflags",
"|=",
"ROMREGION_LE",
";",
"else",
"startflags",
"|=",
"ROMREGION_BE",
";",
"startflags",
"&=",
"~",
"ROMREGION_WIDTHMASK",
";",
"buswidth",
"=",
"spaceconfig",
"->",
"m_databus_width",
";",
"if",
"(",
"buswidth",
"<=",
"8",
")",
"startflags",
"|=",
"ROMREGION_8BIT",
";",
"else",
"if",
"(",
"buswidth",
"<=",
"16",
")",
"startflags",
"|=",
"ROMREGION_16BIT",
";",
"else",
"if",
"(",
"buswidth",
"<=",
"32",
")",
"startflags",
"|=",
"ROMREGION_32BIT",
";",
"else",
"startflags",
"|=",
"ROMREGION_64BIT",
";",
"}",
"}",
"return",
"startflags",
";",
"}"
] | normalize_flags_for_device - modify the region
flags for the given device | [
"normalize_flags_for_device",
"-",
"modify",
"the",
"region",
"flags",
"for",
"the",
"given",
"device"
] | [
"/* set the endianness */",
"/* set the width */"
] | [
{
"param": "machine",
"type": "running_machine"
},
{
"param": "startflags",
"type": "UINT32"
},
{
"param": "rgntag",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "machine",
"type": "running_machine",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "startflags",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rgntag",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2ca52623ad8880ad97d06cb040f0354da015414f | lofunz/mieme | Reloaded/trunk/src/emu/romload.c | [
"Unlicense"
] | C | rom_init | void | void rom_init(running_machine *machine)
{
rom_load_data *romdata;
/* allocate private data */
machine->romload_data = romdata = auto_alloc_clear(machine, romload_private);
/* make sure we get called back on the way out */
machine->add_notifier(MACHINE_NOTIFY_EXIT, rom_exit);
/* reset the romdata struct */
romdata->machine = machine;
/* figure out which BIOS we are using */
determine_bios_rom(romdata);
/* count the total number of ROMs */
count_roms(romdata);
/* reset the disk list */
romdata->chd_list = NULL;
romdata->chd_list_tailptr = &machine->romload_data->chd_list;
/* process the ROM entries we were passed */
process_region_list(romdata);
/* display the results and exit */
display_rom_load_results(romdata);
} | /*-------------------------------------------------
rom_init - load the ROMs and open the disk
images associated with the given machine
-------------------------------------------------*/ | load the ROMs and open the disk
images associated with the given machine | [
"load",
"the",
"ROMs",
"and",
"open",
"the",
"disk",
"images",
"associated",
"with",
"the",
"given",
"machine"
] | void rom_init(running_machine *machine)
{
rom_load_data *romdata;
machine->romload_data = romdata = auto_alloc_clear(machine, romload_private);
machine->add_notifier(MACHINE_NOTIFY_EXIT, rom_exit);
romdata->machine = machine;
determine_bios_rom(romdata);
count_roms(romdata);
romdata->chd_list = NULL;
romdata->chd_list_tailptr = &machine->romload_data->chd_list;
process_region_list(romdata);
display_rom_load_results(romdata);
} | [
"void",
"rom_init",
"(",
"running_machine",
"*",
"machine",
")",
"{",
"rom_load_data",
"*",
"romdata",
";",
"machine",
"->",
"romload_data",
"=",
"romdata",
"=",
"auto_alloc_clear",
"(",
"machine",
",",
"romload_private",
")",
";",
"machine",
"->",
"add_notifier",
"(",
"MACHINE_NOTIFY_EXIT",
",",
"rom_exit",
")",
";",
"romdata",
"->",
"machine",
"=",
"machine",
";",
"determine_bios_rom",
"(",
"romdata",
")",
";",
"count_roms",
"(",
"romdata",
")",
";",
"romdata",
"->",
"chd_list",
"=",
"NULL",
";",
"romdata",
"->",
"chd_list_tailptr",
"=",
"&",
"machine",
"->",
"romload_data",
"->",
"chd_list",
";",
"process_region_list",
"(",
"romdata",
")",
";",
"display_rom_load_results",
"(",
"romdata",
")",
";",
"}"
] | rom_init - load the ROMs and open the disk
images associated with the given machine | [
"rom_init",
"-",
"load",
"the",
"ROMs",
"and",
"open",
"the",
"disk",
"images",
"associated",
"with",
"the",
"given",
"machine"
] | [
"/* allocate private data */",
"/* make sure we get called back on the way out */",
"/* reset the romdata struct */",
"/* figure out which BIOS we are using */",
"/* count the total number of ROMs */",
"/* reset the disk list */",
"/* process the ROM entries we were passed */",
"/* display the results and exit */"
] | [
{
"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": []
} |
714c180994a5e8288aac90c97e97c0a8b6092184 | lofunz/mieme | Reloaded/trunk/src/mame/machine/nitedrvr.c | [
"Unlicense"
] | C | nitedrvr_steering | int | static int nitedrvr_steering( running_machine *machine )
{
nitedrvr_state *state = machine->driver_data<nitedrvr_state>();
int this_val = input_port_read(machine, "STEER");
int delta = this_val - state->last_steering_val;
state->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 */
state->steering_buf += (delta / 4);
if (state->steering_buf > 0)
{
state->steering_buf--;
state->steering_val = 0xc0;
}
else if (state->steering_buf < 0)
{
state->steering_buf++;
state->steering_val = 0x80;
}
else
{
state->steering_val = 0x00;
}
return state->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 )
{
nitedrvr_state *state = machine->driver_data<nitedrvr_state>();
int this_val = input_port_read(machine, "STEER");
int delta = this_val - state->last_steering_val;
state->last_steering_val = this_val;
if (delta > 128)
delta -= 256;
else if (delta < -128)
delta += 256;
state->steering_buf += (delta / 4);
if (state->steering_buf > 0)
{
state->steering_buf--;
state->steering_val = 0xc0;
}
else if (state->steering_buf < 0)
{
state->steering_buf++;
state->steering_val = 0x80;
}
else
{
state->steering_val = 0x00;
}
return state->steering_val;
} | [
"static",
"int",
"nitedrvr_steering",
"(",
"running_machine",
"*",
"machine",
")",
"{",
"nitedrvr_state",
"*",
"state",
"=",
"machine",
"->",
"driver_data",
"<",
"nitedrvr_state",
">",
"(",
"",
")",
";",
"int",
"this_val",
"=",
"input_port_read",
"(",
"machine",
",",
"\"",
"\"",
")",
";",
"int",
"delta",
"=",
"this_val",
"-",
"state",
"->",
"last_steering_val",
";",
"state",
"->",
"last_steering_val",
"=",
"this_val",
";",
"if",
"(",
"delta",
">",
"128",
")",
"delta",
"-=",
"256",
";",
"else",
"if",
"(",
"delta",
"<",
"-128",
")",
"delta",
"+=",
"256",
";",
"state",
"->",
"steering_buf",
"+=",
"(",
"delta",
"/",
"4",
")",
";",
"if",
"(",
"state",
"->",
"steering_buf",
">",
"0",
")",
"{",
"state",
"->",
"steering_buf",
"--",
";",
"state",
"->",
"steering_val",
"=",
"0xc0",
";",
"}",
"else",
"if",
"(",
"state",
"->",
"steering_buf",
"<",
"0",
")",
"{",
"state",
"->",
"steering_buf",
"++",
";",
"state",
"->",
"steering_val",
"=",
"0x80",
";",
"}",
"else",
"{",
"state",
"->",
"steering_val",
"=",
"0x00",
";",
"}",
"return",
"state",
"->",
"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": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | memory_set_decrypted_region | void | void memory_set_decrypted_region(const address_space *space, offs_t addrstart, offs_t addrend, void *base)
{
offs_t bytestart = memory_address_to_byte(space, addrstart);
offs_t byteend = memory_address_to_byte_end(space, addrend);
int found = FALSE;
bank_info *bank;
/* loop over banks looking for a match */
for (bank = space->machine->memory_data->banklist; bank != NULL; bank = bank->next)
{
/* consider this bank if it is used for reading and matches the address space */
if (bank->read && bank_references_space(bank, space))
{
/* verify that the region fully covers the decrypted range */
if (bank->bytestart >= bytestart && bank->byteend <= byteend)
{
/* set the decrypted pointer for the corresponding memory bank */
space->machine->memory_data->bankd_ptr[bank->index] = (UINT8 *)base + bank->bytestart - bytestart;
found = TRUE;
/* if we are executing from here, force an opcode base update */
if (space->direct.entry == bank->index)
force_opbase_update(space);
}
/* fatal error if the decrypted region straddles the bank */
else if (bank->bytestart < byteend && bank->byteend > bytestart)
fatalerror("memory_set_decrypted_region found straddled region %08X-%08X for device '%s'", bytestart, byteend, space->cpu->tag());
}
}
/* fatal error as well if we didn't find any relevant memory banks */
if (!found)
fatalerror("memory_set_decrypted_region unable to find matching region %08X-%08X for device '%s'", bytestart, byteend, space->cpu->tag());
} | /*-------------------------------------------------
memory_set_decrypted_region - registers an
address range as having a decrypted data
pointer
-------------------------------------------------*/ | registers an
address range as having a decrypted data
pointer | [
"registers",
"an",
"address",
"range",
"as",
"having",
"a",
"decrypted",
"data",
"pointer"
] | void memory_set_decrypted_region(const address_space *space, offs_t addrstart, offs_t addrend, void *base)
{
offs_t bytestart = memory_address_to_byte(space, addrstart);
offs_t byteend = memory_address_to_byte_end(space, addrend);
int found = FALSE;
bank_info *bank;
for (bank = space->machine->memory_data->banklist; bank != NULL; bank = bank->next)
{
if (bank->read && bank_references_space(bank, space))
{
if (bank->bytestart >= bytestart && bank->byteend <= byteend)
{
space->machine->memory_data->bankd_ptr[bank->index] = (UINT8 *)base + bank->bytestart - bytestart;
found = TRUE;
if (space->direct.entry == bank->index)
force_opbase_update(space);
}
else if (bank->bytestart < byteend && bank->byteend > bytestart)
fatalerror("memory_set_decrypted_region found straddled region %08X-%08X for device '%s'", bytestart, byteend, space->cpu->tag());
}
}
if (!found)
fatalerror("memory_set_decrypted_region unable to find matching region %08X-%08X for device '%s'", bytestart, byteend, space->cpu->tag());
} | [
"void",
"memory_set_decrypted_region",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"addrstart",
",",
"offs_t",
"addrend",
",",
"void",
"*",
"base",
")",
"{",
"offs_t",
"bytestart",
"=",
"memory_address_to_byte",
"(",
"space",
",",
"addrstart",
")",
";",
"offs_t",
"byteend",
"=",
"memory_address_to_byte_end",
"(",
"space",
",",
"addrend",
")",
";",
"int",
"found",
"=",
"FALSE",
";",
"bank_info",
"*",
"bank",
";",
"for",
"(",
"bank",
"=",
"space",
"->",
"machine",
"->",
"memory_data",
"->",
"banklist",
";",
"bank",
"!=",
"NULL",
";",
"bank",
"=",
"bank",
"->",
"next",
")",
"{",
"if",
"(",
"bank",
"->",
"read",
"&&",
"bank_references_space",
"(",
"bank",
",",
"space",
")",
")",
"{",
"if",
"(",
"bank",
"->",
"bytestart",
">=",
"bytestart",
"&&",
"bank",
"->",
"byteend",
"<=",
"byteend",
")",
"{",
"space",
"->",
"machine",
"->",
"memory_data",
"->",
"bankd_ptr",
"[",
"bank",
"->",
"index",
"]",
"=",
"(",
"UINT8",
"*",
")",
"base",
"+",
"bank",
"->",
"bytestart",
"-",
"bytestart",
";",
"found",
"=",
"TRUE",
";",
"if",
"(",
"space",
"->",
"direct",
".",
"entry",
"==",
"bank",
"->",
"index",
")",
"force_opbase_update",
"(",
"space",
")",
";",
"}",
"else",
"if",
"(",
"bank",
"->",
"bytestart",
"<",
"byteend",
"&&",
"bank",
"->",
"byteend",
">",
"bytestart",
")",
"fatalerror",
"(",
"\"",
"\"",
",",
"bytestart",
",",
"byteend",
",",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"!",
"found",
")",
"fatalerror",
"(",
"\"",
"\"",
",",
"bytestart",
",",
"byteend",
",",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
")",
";",
"}"
] | memory_set_decrypted_region - registers an
address range as having a decrypted data
pointer | [
"memory_set_decrypted_region",
"-",
"registers",
"an",
"address",
"range",
"as",
"having",
"a",
"decrypted",
"data",
"pointer"
] | [
"/* loop over banks looking for a match */",
"/* consider this bank if it is used for reading and matches the address space */",
"/* verify that the region fully covers the decrypted range */",
"/* set the decrypted pointer for the corresponding memory bank */",
"/* if we are executing from here, force an opcode base update */",
"/* fatal error if the decrypted region straddles the bank */",
"/* fatal error as well if we didn't find any relevant memory banks */"
] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "addrstart",
"type": "offs_t"
},
{
"param": "addrend",
"type": "offs_t"
},
{
"param": "base",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrstart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "base",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | memory_set_direct_region | int | int memory_set_direct_region(const address_space *space, offs_t *byteaddress)
{
memory_private *memdata = space->machine->memory_data;
address_space *spacerw = (address_space *)space;
UINT8 *base = NULL, *based = NULL;
const handler_data *handlers;
direct_range *range;
offs_t maskedbits;
offs_t overrideaddress = *byteaddress;
UINT8 entry;
/* allow overrides */
if (spacerw->directupdate != NULL)
{
overrideaddress = (*spacerw->directupdate)(spacerw, overrideaddress, &spacerw->direct);
if (overrideaddress == ~0)
return TRUE;
*byteaddress = overrideaddress;
}
/* remove the masked bits (we'll put them back later) */
maskedbits = overrideaddress & ~spacerw->bytemask;
/* find or allocate a matching range */
range = direct_range_find(spacerw, overrideaddress, &entry);
/* keep track of current entry */
spacerw->direct.entry = entry;
/* if we don't map to a bank, return FALSE */
if (entry < STATIC_BANK1 || entry >= STATIC_RAM)
{
/* ensure future updates to land here as well until we get back into a bank */
spacerw->direct.byteend = 0;
spacerw->direct.bytestart = 1;
return FALSE;
}
/* if no decrypted opcodes, point to the same base */
base = memdata->bank_ptr[entry];
based = memdata->bankd_ptr[entry];
if (based == NULL)
based = base;
/* compute the adjusted base */
handlers = spacerw->read.handlers[entry];
spacerw->direct.bytemask = handlers->bytemask;
spacerw->direct.raw = base - (handlers->bytestart & spacerw->direct.bytemask);
spacerw->direct.decrypted = based - (handlers->bytestart & spacerw->direct.bytemask);
spacerw->direct.bytestart = maskedbits | range->bytestart;
spacerw->direct.byteend = maskedbits | range->byteend;
return TRUE;
} | /*-------------------------------------------------
memory_set_direct_region - called by device
cores to update the opcode base for the given
address
-------------------------------------------------*/ | called by device
cores to update the opcode base for the given
address | [
"called",
"by",
"device",
"cores",
"to",
"update",
"the",
"opcode",
"base",
"for",
"the",
"given",
"address"
] | int memory_set_direct_region(const address_space *space, offs_t *byteaddress)
{
memory_private *memdata = space->machine->memory_data;
address_space *spacerw = (address_space *)space;
UINT8 *base = NULL, *based = NULL;
const handler_data *handlers;
direct_range *range;
offs_t maskedbits;
offs_t overrideaddress = *byteaddress;
UINT8 entry;
if (spacerw->directupdate != NULL)
{
overrideaddress = (*spacerw->directupdate)(spacerw, overrideaddress, &spacerw->direct);
if (overrideaddress == ~0)
return TRUE;
*byteaddress = overrideaddress;
}
maskedbits = overrideaddress & ~spacerw->bytemask;
range = direct_range_find(spacerw, overrideaddress, &entry);
spacerw->direct.entry = entry;
if (entry < STATIC_BANK1 || entry >= STATIC_RAM)
{
spacerw->direct.byteend = 0;
spacerw->direct.bytestart = 1;
return FALSE;
}
base = memdata->bank_ptr[entry];
based = memdata->bankd_ptr[entry];
if (based == NULL)
based = base;
handlers = spacerw->read.handlers[entry];
spacerw->direct.bytemask = handlers->bytemask;
spacerw->direct.raw = base - (handlers->bytestart & spacerw->direct.bytemask);
spacerw->direct.decrypted = based - (handlers->bytestart & spacerw->direct.bytemask);
spacerw->direct.bytestart = maskedbits | range->bytestart;
spacerw->direct.byteend = maskedbits | range->byteend;
return TRUE;
} | [
"int",
"memory_set_direct_region",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"*",
"byteaddress",
")",
"{",
"memory_private",
"*",
"memdata",
"=",
"space",
"->",
"machine",
"->",
"memory_data",
";",
"address_space",
"*",
"spacerw",
"=",
"(",
"address_space",
"*",
")",
"space",
";",
"UINT8",
"*",
"base",
"=",
"NULL",
",",
"*",
"based",
"=",
"NULL",
";",
"const",
"handler_data",
"*",
"handlers",
";",
"direct_range",
"*",
"range",
";",
"offs_t",
"maskedbits",
";",
"offs_t",
"overrideaddress",
"=",
"*",
"byteaddress",
";",
"UINT8",
"entry",
";",
"if",
"(",
"spacerw",
"->",
"directupdate",
"!=",
"NULL",
")",
"{",
"overrideaddress",
"=",
"(",
"*",
"spacerw",
"->",
"directupdate",
")",
"(",
"spacerw",
",",
"overrideaddress",
",",
"&",
"spacerw",
"->",
"direct",
")",
";",
"if",
"(",
"overrideaddress",
"==",
"~",
"0",
")",
"return",
"TRUE",
";",
"*",
"byteaddress",
"=",
"overrideaddress",
";",
"}",
"maskedbits",
"=",
"overrideaddress",
"&",
"~",
"spacerw",
"->",
"bytemask",
";",
"range",
"=",
"direct_range_find",
"(",
"spacerw",
",",
"overrideaddress",
",",
"&",
"entry",
")",
";",
"spacerw",
"->",
"direct",
".",
"entry",
"=",
"entry",
";",
"if",
"(",
"entry",
"<",
"STATIC_BANK1",
"||",
"entry",
">=",
"STATIC_RAM",
")",
"{",
"spacerw",
"->",
"direct",
".",
"byteend",
"=",
"0",
";",
"spacerw",
"->",
"direct",
".",
"bytestart",
"=",
"1",
";",
"return",
"FALSE",
";",
"}",
"base",
"=",
"memdata",
"->",
"bank_ptr",
"[",
"entry",
"]",
";",
"based",
"=",
"memdata",
"->",
"bankd_ptr",
"[",
"entry",
"]",
";",
"if",
"(",
"based",
"==",
"NULL",
")",
"based",
"=",
"base",
";",
"handlers",
"=",
"spacerw",
"->",
"read",
".",
"handlers",
"[",
"entry",
"]",
";",
"spacerw",
"->",
"direct",
".",
"bytemask",
"=",
"handlers",
"->",
"bytemask",
";",
"spacerw",
"->",
"direct",
".",
"raw",
"=",
"base",
"-",
"(",
"handlers",
"->",
"bytestart",
"&",
"spacerw",
"->",
"direct",
".",
"bytemask",
")",
";",
"spacerw",
"->",
"direct",
".",
"decrypted",
"=",
"based",
"-",
"(",
"handlers",
"->",
"bytestart",
"&",
"spacerw",
"->",
"direct",
".",
"bytemask",
")",
";",
"spacerw",
"->",
"direct",
".",
"bytestart",
"=",
"maskedbits",
"|",
"range",
"->",
"bytestart",
";",
"spacerw",
"->",
"direct",
".",
"byteend",
"=",
"maskedbits",
"|",
"range",
"->",
"byteend",
";",
"return",
"TRUE",
";",
"}"
] | memory_set_direct_region - called by device
cores to update the opcode base for the given
address | [
"memory_set_direct_region",
"-",
"called",
"by",
"device",
"cores",
"to",
"update",
"the",
"opcode",
"base",
"for",
"the",
"given",
"address"
] | [
"/* allow overrides */",
"/* remove the masked bits (we'll put them back later) */",
"/* find or allocate a matching range */",
"/* keep track of current entry */",
"/* if we don't map to a bank, return FALSE */",
"/* ensure future updates to land here as well until we get back into a bank */",
"/* if no decrypted opcodes, point to the same base */",
"/* compute the adjusted base */"
] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "byteaddress",
"type": "offs_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "byteaddress",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | memory_get_read_ptr | void | void *memory_get_read_ptr(const address_space *space, offs_t byteaddress)
{
const handler_data *handler;
offs_t byteoffset;
UINT8 entry;
/* perform the lookup */
byteaddress &= space->bytemask;
entry = space->read.table[LEVEL1_INDEX(byteaddress)];
if (entry >= SUBTABLE_BASE)
entry = space->read.table[LEVEL2_INDEX(entry, byteaddress)];
handler = space->read.handlers[entry];
/* 8-bit case: RAM/ROM */
if (entry >= STATIC_RAM)
return NULL;
byteoffset = (byteaddress - handler->bytestart) & handler->bytemask;
return &(*handler->bankbaseptr)[byteoffset];
} | /*-------------------------------------------------
memory_get_read_ptr - return a pointer the
memory byte provided in the given address
space, or NULL if it is not mapped to a bank
-------------------------------------------------*/ | return a pointer the
memory byte provided in the given address
space, or NULL if it is not mapped to a bank | [
"return",
"a",
"pointer",
"the",
"memory",
"byte",
"provided",
"in",
"the",
"given",
"address",
"space",
"or",
"NULL",
"if",
"it",
"is",
"not",
"mapped",
"to",
"a",
"bank"
] | void *memory_get_read_ptr(const address_space *space, offs_t byteaddress)
{
const handler_data *handler;
offs_t byteoffset;
UINT8 entry;
byteaddress &= space->bytemask;
entry = space->read.table[LEVEL1_INDEX(byteaddress)];
if (entry >= SUBTABLE_BASE)
entry = space->read.table[LEVEL2_INDEX(entry, byteaddress)];
handler = space->read.handlers[entry];
if (entry >= STATIC_RAM)
return NULL;
byteoffset = (byteaddress - handler->bytestart) & handler->bytemask;
return &(*handler->bankbaseptr)[byteoffset];
} | [
"void",
"*",
"memory_get_read_ptr",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"byteaddress",
")",
"{",
"const",
"handler_data",
"*",
"handler",
";",
"offs_t",
"byteoffset",
";",
"UINT8",
"entry",
";",
"byteaddress",
"&=",
"space",
"->",
"bytemask",
";",
"entry",
"=",
"space",
"->",
"read",
".",
"table",
"[",
"LEVEL1_INDEX",
"(",
"byteaddress",
")",
"]",
";",
"if",
"(",
"entry",
">=",
"SUBTABLE_BASE",
")",
"entry",
"=",
"space",
"->",
"read",
".",
"table",
"[",
"LEVEL2_INDEX",
"(",
"entry",
",",
"byteaddress",
")",
"]",
";",
"handler",
"=",
"space",
"->",
"read",
".",
"handlers",
"[",
"entry",
"]",
";",
"if",
"(",
"entry",
">=",
"STATIC_RAM",
")",
"return",
"NULL",
";",
"byteoffset",
"=",
"(",
"byteaddress",
"-",
"handler",
"->",
"bytestart",
")",
"&",
"handler",
"->",
"bytemask",
";",
"return",
"&",
"(",
"*",
"handler",
"->",
"bankbaseptr",
")",
"[",
"byteoffset",
"]",
";",
"}"
] | memory_get_read_ptr - return a pointer the
memory byte provided in the given address
space, or NULL if it is not mapped to a bank | [
"memory_get_read_ptr",
"-",
"return",
"a",
"pointer",
"the",
"memory",
"byte",
"provided",
"in",
"the",
"given",
"address",
"space",
"or",
"NULL",
"if",
"it",
"is",
"not",
"mapped",
"to",
"a",
"bank"
] | [
"/* perform the lookup */",
"/* 8-bit case: RAM/ROM */"
] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "byteaddress",
"type": "offs_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "byteaddress",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | memory_get_write_ptr | void | void *memory_get_write_ptr(const address_space *space, offs_t byteaddress)
{
const handler_data *handler;
offs_t byteoffset;
UINT8 entry;
/* perform the lookup */
byteaddress &= space->bytemask;
entry = space->write.table[LEVEL1_INDEX(byteaddress)];
if (entry >= SUBTABLE_BASE)
entry = space->write.table[LEVEL2_INDEX(entry, byteaddress)];
handler = space->write.handlers[entry];
/* 8-bit case: RAM/ROM */
if (entry >= STATIC_RAM)
return NULL;
byteoffset = (byteaddress - handler->bytestart) & handler->bytemask;
return &(*handler->bankbaseptr)[byteoffset];
} | /*-------------------------------------------------
memory_get_write_ptr - return a pointer the
memory byte provided in the given address
space, or NULL if it is not mapped to a
writeable bank
-------------------------------------------------*/ | return a pointer the
memory byte provided in the given address
space, or NULL if it is not mapped to a
writeable bank | [
"return",
"a",
"pointer",
"the",
"memory",
"byte",
"provided",
"in",
"the",
"given",
"address",
"space",
"or",
"NULL",
"if",
"it",
"is",
"not",
"mapped",
"to",
"a",
"writeable",
"bank"
] | void *memory_get_write_ptr(const address_space *space, offs_t byteaddress)
{
const handler_data *handler;
offs_t byteoffset;
UINT8 entry;
byteaddress &= space->bytemask;
entry = space->write.table[LEVEL1_INDEX(byteaddress)];
if (entry >= SUBTABLE_BASE)
entry = space->write.table[LEVEL2_INDEX(entry, byteaddress)];
handler = space->write.handlers[entry];
if (entry >= STATIC_RAM)
return NULL;
byteoffset = (byteaddress - handler->bytestart) & handler->bytemask;
return &(*handler->bankbaseptr)[byteoffset];
} | [
"void",
"*",
"memory_get_write_ptr",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"byteaddress",
")",
"{",
"const",
"handler_data",
"*",
"handler",
";",
"offs_t",
"byteoffset",
";",
"UINT8",
"entry",
";",
"byteaddress",
"&=",
"space",
"->",
"bytemask",
";",
"entry",
"=",
"space",
"->",
"write",
".",
"table",
"[",
"LEVEL1_INDEX",
"(",
"byteaddress",
")",
"]",
";",
"if",
"(",
"entry",
">=",
"SUBTABLE_BASE",
")",
"entry",
"=",
"space",
"->",
"write",
".",
"table",
"[",
"LEVEL2_INDEX",
"(",
"entry",
",",
"byteaddress",
")",
"]",
";",
"handler",
"=",
"space",
"->",
"write",
".",
"handlers",
"[",
"entry",
"]",
";",
"if",
"(",
"entry",
">=",
"STATIC_RAM",
")",
"return",
"NULL",
";",
"byteoffset",
"=",
"(",
"byteaddress",
"-",
"handler",
"->",
"bytestart",
")",
"&",
"handler",
"->",
"bytemask",
";",
"return",
"&",
"(",
"*",
"handler",
"->",
"bankbaseptr",
")",
"[",
"byteoffset",
"]",
";",
"}"
] | memory_get_write_ptr - return a pointer the
memory byte provided in the given address
space, or NULL if it is not mapped to a
writeable bank | [
"memory_get_write_ptr",
"-",
"return",
"a",
"pointer",
"the",
"memory",
"byte",
"provided",
"in",
"the",
"given",
"address",
"space",
"or",
"NULL",
"if",
"it",
"is",
"not",
"mapped",
"to",
"a",
"writeable",
"bank"
] | [
"/* perform the lookup */",
"/* 8-bit case: RAM/ROM */"
] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "byteaddress",
"type": "offs_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "byteaddress",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | memory_configure_bank | void | void memory_configure_bank(running_machine *machine, const char *tag, int startentry, int numentries, void *base, offs_t stride)
{
memory_private *memdata = machine->memory_data;
bank_info *bank = memdata->bankmap.find_hash_only(tag);
int entrynum;
/* validation checks */
if (bank == NULL)
fatalerror("memory_configure_bank called for unknown bank '%s'", tag);
if (startentry < 0 || startentry + numentries > MAX_BANK_ENTRIES)
fatalerror("memory_configure_bank called with out-of-range entries %d-%d", startentry, startentry + numentries - 1);
if (!base)
fatalerror("memory_configure_bank called NULL base");
/* fill in the requested bank entries */
for (entrynum = startentry; entrynum < startentry + numentries; entrynum++)
bank->entry[entrynum] = (UINT8 *)base + (entrynum - startentry) * stride;
/* if we have no bankptr yet, set it to the first entry */
if (memdata->bank_ptr[bank->index] == NULL)
memdata->bank_ptr[bank->index] = (UINT8 *)bank->entry[0];
} | /*-------------------------------------------------
memory_configure_bank - configure the
addresses for a bank
-------------------------------------------------*/ | configure the
addresses for a bank | [
"configure",
"the",
"addresses",
"for",
"a",
"bank"
] | void memory_configure_bank(running_machine *machine, const char *tag, int startentry, int numentries, void *base, offs_t stride)
{
memory_private *memdata = machine->memory_data;
bank_info *bank = memdata->bankmap.find_hash_only(tag);
int entrynum;
if (bank == NULL)
fatalerror("memory_configure_bank called for unknown bank '%s'", tag);
if (startentry < 0 || startentry + numentries > MAX_BANK_ENTRIES)
fatalerror("memory_configure_bank called with out-of-range entries %d-%d", startentry, startentry + numentries - 1);
if (!base)
fatalerror("memory_configure_bank called NULL base");
for (entrynum = startentry; entrynum < startentry + numentries; entrynum++)
bank->entry[entrynum] = (UINT8 *)base + (entrynum - startentry) * stride;
if (memdata->bank_ptr[bank->index] == NULL)
memdata->bank_ptr[bank->index] = (UINT8 *)bank->entry[0];
} | [
"void",
"memory_configure_bank",
"(",
"running_machine",
"*",
"machine",
",",
"const",
"char",
"*",
"tag",
",",
"int",
"startentry",
",",
"int",
"numentries",
",",
"void",
"*",
"base",
",",
"offs_t",
"stride",
")",
"{",
"memory_private",
"*",
"memdata",
"=",
"machine",
"->",
"memory_data",
";",
"bank_info",
"*",
"bank",
"=",
"memdata",
"->",
"bankmap",
".",
"find_hash_only",
"(",
"tag",
")",
";",
"int",
"entrynum",
";",
"if",
"(",
"bank",
"==",
"NULL",
")",
"fatalerror",
"(",
"\"",
"\"",
",",
"tag",
")",
";",
"if",
"(",
"startentry",
"<",
"0",
"||",
"startentry",
"+",
"numentries",
">",
"MAX_BANK_ENTRIES",
")",
"fatalerror",
"(",
"\"",
"\"",
",",
"startentry",
",",
"startentry",
"+",
"numentries",
"-",
"1",
")",
";",
"if",
"(",
"!",
"base",
")",
"fatalerror",
"(",
"\"",
"\"",
")",
";",
"for",
"(",
"entrynum",
"=",
"startentry",
";",
"entrynum",
"<",
"startentry",
"+",
"numentries",
";",
"entrynum",
"++",
")",
"bank",
"->",
"entry",
"[",
"entrynum",
"]",
"=",
"(",
"UINT8",
"*",
")",
"base",
"+",
"(",
"entrynum",
"-",
"startentry",
")",
"*",
"stride",
";",
"if",
"(",
"memdata",
"->",
"bank_ptr",
"[",
"bank",
"->",
"index",
"]",
"==",
"NULL",
")",
"memdata",
"->",
"bank_ptr",
"[",
"bank",
"->",
"index",
"]",
"=",
"(",
"UINT8",
"*",
")",
"bank",
"->",
"entry",
"[",
"0",
"]",
";",
"}"
] | memory_configure_bank - configure the
addresses for a bank | [
"memory_configure_bank",
"-",
"configure",
"the",
"addresses",
"for",
"a",
"bank"
] | [
"/* validation checks */",
"/* fill in the requested bank entries */",
"/* if we have no bankptr yet, set it to the first entry */"
] | [
{
"param": "machine",
"type": "running_machine"
},
{
"param": "tag",
"type": "char"
},
{
"param": "startentry",
"type": "int"
},
{
"param": "numentries",
"type": "int"
},
{
"param": "base",
"type": "void"
},
{
"param": "stride",
"type": "offs_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "machine",
"type": "running_machine",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tag",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "startentry",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "numentries",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "base",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "stride",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | memory_configure_bank_decrypted | void | void memory_configure_bank_decrypted(running_machine *machine, const char *tag, int startentry, int numentries, void *base, offs_t stride)
{
memory_private *memdata = machine->memory_data;
bank_info *bank = memdata->bankmap.find_hash_only(tag);
int entrynum;
/* validation checks */
if (bank == NULL)
fatalerror("memory_configure_bank_decrypted called for unknown bank '%s'", tag);
if (startentry < 0 || startentry + numentries > MAX_BANK_ENTRIES)
fatalerror("memory_configure_bank_decrypted called with out-of-range entries %d-%d", startentry, startentry + numentries - 1);
if (!base)
fatalerror("memory_configure_bank_decrypted called NULL base");
/* fill in the requested bank entries */
for (entrynum = startentry; entrynum < startentry + numentries; entrynum++)
bank->entryd[entrynum] = (UINT8 *)base + (entrynum - startentry) * stride;
/* if we have no bankptr yet, set it to the first entry */
if (memdata->bankd_ptr[bank->index] == NULL)
memdata->bankd_ptr[bank->index] = (UINT8 *)bank->entryd[0];
} | /*-------------------------------------------------
memory_configure_bank_decrypted - configure
the decrypted addresses for a bank
-------------------------------------------------*/ | configure
the decrypted addresses for a bank | [
"configure",
"the",
"decrypted",
"addresses",
"for",
"a",
"bank"
] | void memory_configure_bank_decrypted(running_machine *machine, const char *tag, int startentry, int numentries, void *base, offs_t stride)
{
memory_private *memdata = machine->memory_data;
bank_info *bank = memdata->bankmap.find_hash_only(tag);
int entrynum;
if (bank == NULL)
fatalerror("memory_configure_bank_decrypted called for unknown bank '%s'", tag);
if (startentry < 0 || startentry + numentries > MAX_BANK_ENTRIES)
fatalerror("memory_configure_bank_decrypted called with out-of-range entries %d-%d", startentry, startentry + numentries - 1);
if (!base)
fatalerror("memory_configure_bank_decrypted called NULL base");
for (entrynum = startentry; entrynum < startentry + numentries; entrynum++)
bank->entryd[entrynum] = (UINT8 *)base + (entrynum - startentry) * stride;
if (memdata->bankd_ptr[bank->index] == NULL)
memdata->bankd_ptr[bank->index] = (UINT8 *)bank->entryd[0];
} | [
"void",
"memory_configure_bank_decrypted",
"(",
"running_machine",
"*",
"machine",
",",
"const",
"char",
"*",
"tag",
",",
"int",
"startentry",
",",
"int",
"numentries",
",",
"void",
"*",
"base",
",",
"offs_t",
"stride",
")",
"{",
"memory_private",
"*",
"memdata",
"=",
"machine",
"->",
"memory_data",
";",
"bank_info",
"*",
"bank",
"=",
"memdata",
"->",
"bankmap",
".",
"find_hash_only",
"(",
"tag",
")",
";",
"int",
"entrynum",
";",
"if",
"(",
"bank",
"==",
"NULL",
")",
"fatalerror",
"(",
"\"",
"\"",
",",
"tag",
")",
";",
"if",
"(",
"startentry",
"<",
"0",
"||",
"startentry",
"+",
"numentries",
">",
"MAX_BANK_ENTRIES",
")",
"fatalerror",
"(",
"\"",
"\"",
",",
"startentry",
",",
"startentry",
"+",
"numentries",
"-",
"1",
")",
";",
"if",
"(",
"!",
"base",
")",
"fatalerror",
"(",
"\"",
"\"",
")",
";",
"for",
"(",
"entrynum",
"=",
"startentry",
";",
"entrynum",
"<",
"startentry",
"+",
"numentries",
";",
"entrynum",
"++",
")",
"bank",
"->",
"entryd",
"[",
"entrynum",
"]",
"=",
"(",
"UINT8",
"*",
")",
"base",
"+",
"(",
"entrynum",
"-",
"startentry",
")",
"*",
"stride",
";",
"if",
"(",
"memdata",
"->",
"bankd_ptr",
"[",
"bank",
"->",
"index",
"]",
"==",
"NULL",
")",
"memdata",
"->",
"bankd_ptr",
"[",
"bank",
"->",
"index",
"]",
"=",
"(",
"UINT8",
"*",
")",
"bank",
"->",
"entryd",
"[",
"0",
"]",
";",
"}"
] | memory_configure_bank_decrypted - configure
the decrypted addresses for a bank | [
"memory_configure_bank_decrypted",
"-",
"configure",
"the",
"decrypted",
"addresses",
"for",
"a",
"bank"
] | [
"/* validation checks */",
"/* fill in the requested bank entries */",
"/* if we have no bankptr yet, set it to the first entry */"
] | [
{
"param": "machine",
"type": "running_machine"
},
{
"param": "tag",
"type": "char"
},
{
"param": "startentry",
"type": "int"
},
{
"param": "numentries",
"type": "int"
},
{
"param": "base",
"type": "void"
},
{
"param": "stride",
"type": "offs_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "machine",
"type": "running_machine",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tag",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "startentry",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "numentries",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "base",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "stride",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | memory_set_bank | void | void memory_set_bank(running_machine *machine, const char *tag, int entrynum)
{
memory_private *memdata = machine->memory_data;
bank_info *bank = memdata->bankmap.find_hash_only(tag);
bank_reference *ref;
/* validation checks */
if (bank == NULL)
fatalerror("memory_set_bank called for unknown bank '%s'", tag);
if (entrynum < 0 || entrynum > MAX_BANK_ENTRIES)
fatalerror("memory_set_bank called with out-of-range entry %d", entrynum);
if (!bank->entry[entrynum])
fatalerror("memory_set_bank called for bank '%s' with invalid bank entry %d", tag, entrynum);
/* set the base */
bank->curentry = entrynum;
memdata->bank_ptr[bank->index] = (UINT8 *)bank->entry[entrynum];
memdata->bankd_ptr[bank->index] = (UINT8 *)bank->entryd[entrynum];
/* invalidate all the direct references to any referenced address spaces */
for (ref = bank->reflist; ref != NULL; ref = ref->next)
force_opbase_update(ref->space);
} | /*-------------------------------------------------
memory_set_bank - select one pre-configured
entry to be the new bank base
-------------------------------------------------*/ | select one pre-configured
entry to be the new bank base | [
"select",
"one",
"pre",
"-",
"configured",
"entry",
"to",
"be",
"the",
"new",
"bank",
"base"
] | void memory_set_bank(running_machine *machine, const char *tag, int entrynum)
{
memory_private *memdata = machine->memory_data;
bank_info *bank = memdata->bankmap.find_hash_only(tag);
bank_reference *ref;
if (bank == NULL)
fatalerror("memory_set_bank called for unknown bank '%s'", tag);
if (entrynum < 0 || entrynum > MAX_BANK_ENTRIES)
fatalerror("memory_set_bank called with out-of-range entry %d", entrynum);
if (!bank->entry[entrynum])
fatalerror("memory_set_bank called for bank '%s' with invalid bank entry %d", tag, entrynum);
bank->curentry = entrynum;
memdata->bank_ptr[bank->index] = (UINT8 *)bank->entry[entrynum];
memdata->bankd_ptr[bank->index] = (UINT8 *)bank->entryd[entrynum];
for (ref = bank->reflist; ref != NULL; ref = ref->next)
force_opbase_update(ref->space);
} | [
"void",
"memory_set_bank",
"(",
"running_machine",
"*",
"machine",
",",
"const",
"char",
"*",
"tag",
",",
"int",
"entrynum",
")",
"{",
"memory_private",
"*",
"memdata",
"=",
"machine",
"->",
"memory_data",
";",
"bank_info",
"*",
"bank",
"=",
"memdata",
"->",
"bankmap",
".",
"find_hash_only",
"(",
"tag",
")",
";",
"bank_reference",
"*",
"ref",
";",
"if",
"(",
"bank",
"==",
"NULL",
")",
"fatalerror",
"(",
"\"",
"\"",
",",
"tag",
")",
";",
"if",
"(",
"entrynum",
"<",
"0",
"||",
"entrynum",
">",
"MAX_BANK_ENTRIES",
")",
"fatalerror",
"(",
"\"",
"\"",
",",
"entrynum",
")",
";",
"if",
"(",
"!",
"bank",
"->",
"entry",
"[",
"entrynum",
"]",
")",
"fatalerror",
"(",
"\"",
"\"",
",",
"tag",
",",
"entrynum",
")",
";",
"bank",
"->",
"curentry",
"=",
"entrynum",
";",
"memdata",
"->",
"bank_ptr",
"[",
"bank",
"->",
"index",
"]",
"=",
"(",
"UINT8",
"*",
")",
"bank",
"->",
"entry",
"[",
"entrynum",
"]",
";",
"memdata",
"->",
"bankd_ptr",
"[",
"bank",
"->",
"index",
"]",
"=",
"(",
"UINT8",
"*",
")",
"bank",
"->",
"entryd",
"[",
"entrynum",
"]",
";",
"for",
"(",
"ref",
"=",
"bank",
"->",
"reflist",
";",
"ref",
"!=",
"NULL",
";",
"ref",
"=",
"ref",
"->",
"next",
")",
"force_opbase_update",
"(",
"ref",
"->",
"space",
")",
";",
"}"
] | memory_set_bank - select one pre-configured
entry to be the new bank base | [
"memory_set_bank",
"-",
"select",
"one",
"pre",
"-",
"configured",
"entry",
"to",
"be",
"the",
"new",
"bank",
"base"
] | [
"/* validation checks */",
"/* set the base */",
"/* invalidate all the direct references to any referenced address spaces */"
] | [
{
"param": "machine",
"type": "running_machine"
},
{
"param": "tag",
"type": "char"
},
{
"param": "entrynum",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "machine",
"type": "running_machine",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tag",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "entrynum",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | memory_set_bankptr | void | void memory_set_bankptr(running_machine *machine, const char *tag, void *base)
{
memory_private *memdata = machine->memory_data;
bank_info *bank = memdata->bankmap.find_hash_only(tag);
bank_reference *ref;
/* validation checks */
if (bank == NULL)
fatalerror("memory_set_bankptr called for unknown bank '%s'", tag);
if (base == NULL)
fatalerror("memory_set_bankptr called NULL base");
// if (ALLOW_ONLY_AUTO_MALLOC_BANKS)
// validate_auto_malloc_memory(base, bank->byteend - bank->bytestart + 1);
/* set the base */
memdata->bank_ptr[bank->index] = (UINT8 *)base;
/* invalidate all the direct references to any referenced address spaces */
for (ref = bank->reflist; ref != NULL; ref = ref->next)
force_opbase_update(ref->space);
} | /*-------------------------------------------------
memory_set_bankptr - set the base of a bank
-------------------------------------------------*/ | set the base of a bank | [
"set",
"the",
"base",
"of",
"a",
"bank"
] | void memory_set_bankptr(running_machine *machine, const char *tag, void *base)
{
memory_private *memdata = machine->memory_data;
bank_info *bank = memdata->bankmap.find_hash_only(tag);
bank_reference *ref;
if (bank == NULL)
fatalerror("memory_set_bankptr called for unknown bank '%s'", tag);
if (base == NULL)
fatalerror("memory_set_bankptr called NULL base");
memdata->bank_ptr[bank->index] = (UINT8 *)base;
for (ref = bank->reflist; ref != NULL; ref = ref->next)
force_opbase_update(ref->space);
} | [
"void",
"memory_set_bankptr",
"(",
"running_machine",
"*",
"machine",
",",
"const",
"char",
"*",
"tag",
",",
"void",
"*",
"base",
")",
"{",
"memory_private",
"*",
"memdata",
"=",
"machine",
"->",
"memory_data",
";",
"bank_info",
"*",
"bank",
"=",
"memdata",
"->",
"bankmap",
".",
"find_hash_only",
"(",
"tag",
")",
";",
"bank_reference",
"*",
"ref",
";",
"if",
"(",
"bank",
"==",
"NULL",
")",
"fatalerror",
"(",
"\"",
"\"",
",",
"tag",
")",
";",
"if",
"(",
"base",
"==",
"NULL",
")",
"fatalerror",
"(",
"\"",
"\"",
")",
";",
"memdata",
"->",
"bank_ptr",
"[",
"bank",
"->",
"index",
"]",
"=",
"(",
"UINT8",
"*",
")",
"base",
";",
"for",
"(",
"ref",
"=",
"bank",
"->",
"reflist",
";",
"ref",
"!=",
"NULL",
";",
"ref",
"=",
"ref",
"->",
"next",
")",
"force_opbase_update",
"(",
"ref",
"->",
"space",
")",
";",
"}"
] | memory_set_bankptr - set the base of a bank | [
"memory_set_bankptr",
"-",
"set",
"the",
"base",
"of",
"a",
"bank"
] | [
"/* validation checks */",
"// if (ALLOW_ONLY_AUTO_MALLOC_BANKS)\r",
"// validate_auto_malloc_memory(base, bank->byteend - bank->bytestart + 1);\r",
"/* set the base */",
"/* invalidate all the direct references to any referenced address spaces */"
] | [
{
"param": "machine",
"type": "running_machine"
},
{
"param": "tag",
"type": "char"
},
{
"param": "base",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "machine",
"type": "running_machine",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tag",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "base",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | _memory_install_handler8 | UINT8 | UINT8 *_memory_install_handler8(const address_space *space, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read8_space_func rhandler, const char *rhandler_name, write8_space_func whandler, const char *whandler_name, int handlerunitmask)
{
address_space *spacerw = (address_space *)space;
if (rhandler != NULL && (FPTR)rhandler < STATIC_COUNT)
fatalerror("Attempted to install invalid read handler in space %s of device '%s'\n", space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (whandler != NULL && (FPTR)whandler < STATIC_COUNT)
fatalerror("Attempted to install invalid write handler in space %s of device '%s'\n", space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (rhandler != NULL)
space_map_range(spacerw, ROW_READ, 8, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, spacerw, rhandler_name);
if (whandler != NULL)
space_map_range(spacerw, ROW_WRITE, 8, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, spacerw, whandler_name);
mem_dump(space->machine);
return (UINT8 *)space_find_backing_memory(spacerw, addrstart, addrend);
} | /*-------------------------------------------------
_memory_install_handler8 - same as above but
explicitly for 8-bit handlers
-------------------------------------------------*/ | same as above but
explicitly for 8-bit handlers | [
"same",
"as",
"above",
"but",
"explicitly",
"for",
"8",
"-",
"bit",
"handlers"
] | UINT8 *_memory_install_handler8(const address_space *space, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read8_space_func rhandler, const char *rhandler_name, write8_space_func whandler, const char *whandler_name, int handlerunitmask)
{
address_space *spacerw = (address_space *)space;
if (rhandler != NULL && (FPTR)rhandler < STATIC_COUNT)
fatalerror("Attempted to install invalid read handler in space %s of device '%s'\n", space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (whandler != NULL && (FPTR)whandler < STATIC_COUNT)
fatalerror("Attempted to install invalid write handler in space %s of device '%s'\n", space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (rhandler != NULL)
space_map_range(spacerw, ROW_READ, 8, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, spacerw, rhandler_name);
if (whandler != NULL)
space_map_range(spacerw, ROW_WRITE, 8, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, spacerw, whandler_name);
mem_dump(space->machine);
return (UINT8 *)space_find_backing_memory(spacerw, addrstart, addrend);
} | [
"UINT8",
"*",
"_memory_install_handler8",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"addrstart",
",",
"offs_t",
"addrend",
",",
"offs_t",
"addrmask",
",",
"offs_t",
"addrmirror",
",",
"read8_space_func",
"rhandler",
",",
"const",
"char",
"*",
"rhandler_name",
",",
"write8_space_func",
"whandler",
",",
"const",
"char",
"*",
"whandler_name",
",",
"int",
"handlerunitmask",
")",
"{",
"address_space",
"*",
"spacerw",
"=",
"(",
"address_space",
"*",
")",
"space",
";",
"if",
"(",
"rhandler",
"!=",
"NULL",
"&&",
"(",
"FPTR",
")",
"rhandler",
"<",
"STATIC_COUNT",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"space",
"->",
"name",
",",
"(",
"space",
"->",
"cpu",
"!=",
"NULL",
")",
"?",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"whandler",
"!=",
"NULL",
"&&",
"(",
"FPTR",
")",
"whandler",
"<",
"STATIC_COUNT",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"space",
"->",
"name",
",",
"(",
"space",
"->",
"cpu",
"!=",
"NULL",
")",
"?",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"rhandler",
"!=",
"NULL",
")",
"space_map_range",
"(",
"spacerw",
",",
"ROW_READ",
",",
"8",
",",
"handlerunitmask",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"(",
"genf",
"*",
")",
"rhandler",
",",
"spacerw",
",",
"rhandler_name",
")",
";",
"if",
"(",
"whandler",
"!=",
"NULL",
")",
"space_map_range",
"(",
"spacerw",
",",
"ROW_WRITE",
",",
"8",
",",
"handlerunitmask",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"(",
"genf",
"*",
")",
"whandler",
",",
"spacerw",
",",
"whandler_name",
")",
";",
"mem_dump",
"(",
"space",
"->",
"machine",
")",
";",
"return",
"(",
"UINT8",
"*",
")",
"space_find_backing_memory",
"(",
"spacerw",
",",
"addrstart",
",",
"addrend",
")",
";",
"}"
] | _memory_install_handler8 - same as above but
explicitly for 8-bit handlers | [
"_memory_install_handler8",
"-",
"same",
"as",
"above",
"but",
"explicitly",
"for",
"8",
"-",
"bit",
"handlers"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "addrstart",
"type": "offs_t"
},
{
"param": "addrend",
"type": "offs_t"
},
{
"param": "addrmask",
"type": "offs_t"
},
{
"param": "addrmirror",
"type": "offs_t"
},
{
"param": "rhandler",
"type": "read8_space_func"
},
{
"param": "rhandler_name",
"type": "char"
},
{
"param": "whandler",
"type": "write8_space_func"
},
{
"param": "whandler_name",
"type": "char"
},
{
"param": "handlerunitmask",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrstart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmask",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmirror",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rhandler",
"type": "read8_space_func",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rhandler_name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "whandler",
"type": "write8_space_func",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "whandler_name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "handlerunitmask",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | _memory_install_handler16 | UINT16 | UINT16 *_memory_install_handler16(const address_space *space, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read16_space_func rhandler, const char *rhandler_name, write16_space_func whandler, const char *whandler_name, int handlerunitmask)
{
address_space *spacerw = (address_space *)space;
if (rhandler != NULL && (FPTR)rhandler < STATIC_COUNT)
fatalerror("Attempted to install invalid read handler in space %s of device '%s'\n", space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (whandler != NULL && (FPTR)whandler < STATIC_COUNT)
fatalerror("Attempted to install invalid write handler in space %s of device '%s'\n", space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (rhandler != NULL)
space_map_range(spacerw, ROW_READ, 16, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, spacerw, rhandler_name);
if (whandler != NULL)
space_map_range(spacerw, ROW_WRITE, 16, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, spacerw, whandler_name);
mem_dump(space->machine);
return (UINT16 *)space_find_backing_memory(spacerw, addrstart, addrend);
} | /*-------------------------------------------------
_memory_install_handler16 - same as above but
explicitly for 16-bit handlers
-------------------------------------------------*/ | same as above but
explicitly for 16-bit handlers | [
"same",
"as",
"above",
"but",
"explicitly",
"for",
"16",
"-",
"bit",
"handlers"
] | UINT16 *_memory_install_handler16(const address_space *space, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read16_space_func rhandler, const char *rhandler_name, write16_space_func whandler, const char *whandler_name, int handlerunitmask)
{
address_space *spacerw = (address_space *)space;
if (rhandler != NULL && (FPTR)rhandler < STATIC_COUNT)
fatalerror("Attempted to install invalid read handler in space %s of device '%s'\n", space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (whandler != NULL && (FPTR)whandler < STATIC_COUNT)
fatalerror("Attempted to install invalid write handler in space %s of device '%s'\n", space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (rhandler != NULL)
space_map_range(spacerw, ROW_READ, 16, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, spacerw, rhandler_name);
if (whandler != NULL)
space_map_range(spacerw, ROW_WRITE, 16, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, spacerw, whandler_name);
mem_dump(space->machine);
return (UINT16 *)space_find_backing_memory(spacerw, addrstart, addrend);
} | [
"UINT16",
"*",
"_memory_install_handler16",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"addrstart",
",",
"offs_t",
"addrend",
",",
"offs_t",
"addrmask",
",",
"offs_t",
"addrmirror",
",",
"read16_space_func",
"rhandler",
",",
"const",
"char",
"*",
"rhandler_name",
",",
"write16_space_func",
"whandler",
",",
"const",
"char",
"*",
"whandler_name",
",",
"int",
"handlerunitmask",
")",
"{",
"address_space",
"*",
"spacerw",
"=",
"(",
"address_space",
"*",
")",
"space",
";",
"if",
"(",
"rhandler",
"!=",
"NULL",
"&&",
"(",
"FPTR",
")",
"rhandler",
"<",
"STATIC_COUNT",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"space",
"->",
"name",
",",
"(",
"space",
"->",
"cpu",
"!=",
"NULL",
")",
"?",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"whandler",
"!=",
"NULL",
"&&",
"(",
"FPTR",
")",
"whandler",
"<",
"STATIC_COUNT",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"space",
"->",
"name",
",",
"(",
"space",
"->",
"cpu",
"!=",
"NULL",
")",
"?",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"rhandler",
"!=",
"NULL",
")",
"space_map_range",
"(",
"spacerw",
",",
"ROW_READ",
",",
"16",
",",
"handlerunitmask",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"(",
"genf",
"*",
")",
"rhandler",
",",
"spacerw",
",",
"rhandler_name",
")",
";",
"if",
"(",
"whandler",
"!=",
"NULL",
")",
"space_map_range",
"(",
"spacerw",
",",
"ROW_WRITE",
",",
"16",
",",
"handlerunitmask",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"(",
"genf",
"*",
")",
"whandler",
",",
"spacerw",
",",
"whandler_name",
")",
";",
"mem_dump",
"(",
"space",
"->",
"machine",
")",
";",
"return",
"(",
"UINT16",
"*",
")",
"space_find_backing_memory",
"(",
"spacerw",
",",
"addrstart",
",",
"addrend",
")",
";",
"}"
] | _memory_install_handler16 - same as above but
explicitly for 16-bit handlers | [
"_memory_install_handler16",
"-",
"same",
"as",
"above",
"but",
"explicitly",
"for",
"16",
"-",
"bit",
"handlers"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "addrstart",
"type": "offs_t"
},
{
"param": "addrend",
"type": "offs_t"
},
{
"param": "addrmask",
"type": "offs_t"
},
{
"param": "addrmirror",
"type": "offs_t"
},
{
"param": "rhandler",
"type": "read16_space_func"
},
{
"param": "rhandler_name",
"type": "char"
},
{
"param": "whandler",
"type": "write16_space_func"
},
{
"param": "whandler_name",
"type": "char"
},
{
"param": "handlerunitmask",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrstart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmask",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmirror",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rhandler",
"type": "read16_space_func",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rhandler_name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "whandler",
"type": "write16_space_func",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "whandler_name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "handlerunitmask",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | _memory_install_handler32 | UINT32 | UINT32 *_memory_install_handler32(const address_space *space, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read32_space_func rhandler, const char *rhandler_name, write32_space_func whandler, const char *whandler_name, int handlerunitmask)
{
address_space *spacerw = (address_space *)space;
if (rhandler != NULL && (FPTR)rhandler < STATIC_COUNT)
fatalerror("Attempted to install invalid read handler in space %s of device '%s'\n", space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (whandler != NULL && (FPTR)whandler < STATIC_COUNT)
fatalerror("Attempted to install invalid write handler in space %s of device '%s'\n", space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (rhandler != NULL)
space_map_range(spacerw, ROW_READ, 32, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, spacerw, rhandler_name);
if (whandler != NULL)
space_map_range(spacerw, ROW_WRITE, 32, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, spacerw, whandler_name);
mem_dump(space->machine);
return (UINT32 *)space_find_backing_memory(spacerw, addrstart, addrend);
} | /*-------------------------------------------------
_memory_install_handler32 - same as above but
explicitly for 32-bit handlers
-------------------------------------------------*/ | same as above but
explicitly for 32-bit handlers | [
"same",
"as",
"above",
"but",
"explicitly",
"for",
"32",
"-",
"bit",
"handlers"
] | UINT32 *_memory_install_handler32(const address_space *space, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read32_space_func rhandler, const char *rhandler_name, write32_space_func whandler, const char *whandler_name, int handlerunitmask)
{
address_space *spacerw = (address_space *)space;
if (rhandler != NULL && (FPTR)rhandler < STATIC_COUNT)
fatalerror("Attempted to install invalid read handler in space %s of device '%s'\n", space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (whandler != NULL && (FPTR)whandler < STATIC_COUNT)
fatalerror("Attempted to install invalid write handler in space %s of device '%s'\n", space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (rhandler != NULL)
space_map_range(spacerw, ROW_READ, 32, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, spacerw, rhandler_name);
if (whandler != NULL)
space_map_range(spacerw, ROW_WRITE, 32, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, spacerw, whandler_name);
mem_dump(space->machine);
return (UINT32 *)space_find_backing_memory(spacerw, addrstart, addrend);
} | [
"UINT32",
"*",
"_memory_install_handler32",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"addrstart",
",",
"offs_t",
"addrend",
",",
"offs_t",
"addrmask",
",",
"offs_t",
"addrmirror",
",",
"read32_space_func",
"rhandler",
",",
"const",
"char",
"*",
"rhandler_name",
",",
"write32_space_func",
"whandler",
",",
"const",
"char",
"*",
"whandler_name",
",",
"int",
"handlerunitmask",
")",
"{",
"address_space",
"*",
"spacerw",
"=",
"(",
"address_space",
"*",
")",
"space",
";",
"if",
"(",
"rhandler",
"!=",
"NULL",
"&&",
"(",
"FPTR",
")",
"rhandler",
"<",
"STATIC_COUNT",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"space",
"->",
"name",
",",
"(",
"space",
"->",
"cpu",
"!=",
"NULL",
")",
"?",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"whandler",
"!=",
"NULL",
"&&",
"(",
"FPTR",
")",
"whandler",
"<",
"STATIC_COUNT",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"space",
"->",
"name",
",",
"(",
"space",
"->",
"cpu",
"!=",
"NULL",
")",
"?",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"rhandler",
"!=",
"NULL",
")",
"space_map_range",
"(",
"spacerw",
",",
"ROW_READ",
",",
"32",
",",
"handlerunitmask",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"(",
"genf",
"*",
")",
"rhandler",
",",
"spacerw",
",",
"rhandler_name",
")",
";",
"if",
"(",
"whandler",
"!=",
"NULL",
")",
"space_map_range",
"(",
"spacerw",
",",
"ROW_WRITE",
",",
"32",
",",
"handlerunitmask",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"(",
"genf",
"*",
")",
"whandler",
",",
"spacerw",
",",
"whandler_name",
")",
";",
"mem_dump",
"(",
"space",
"->",
"machine",
")",
";",
"return",
"(",
"UINT32",
"*",
")",
"space_find_backing_memory",
"(",
"spacerw",
",",
"addrstart",
",",
"addrend",
")",
";",
"}"
] | _memory_install_handler32 - same as above but
explicitly for 32-bit handlers | [
"_memory_install_handler32",
"-",
"same",
"as",
"above",
"but",
"explicitly",
"for",
"32",
"-",
"bit",
"handlers"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "addrstart",
"type": "offs_t"
},
{
"param": "addrend",
"type": "offs_t"
},
{
"param": "addrmask",
"type": "offs_t"
},
{
"param": "addrmirror",
"type": "offs_t"
},
{
"param": "rhandler",
"type": "read32_space_func"
},
{
"param": "rhandler_name",
"type": "char"
},
{
"param": "whandler",
"type": "write32_space_func"
},
{
"param": "whandler_name",
"type": "char"
},
{
"param": "handlerunitmask",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrstart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmask",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmirror",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rhandler",
"type": "read32_space_func",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rhandler_name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "whandler",
"type": "write32_space_func",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "whandler_name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "handlerunitmask",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | _memory_install_handler64 | UINT64 | UINT64 *_memory_install_handler64(const address_space *space, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read64_space_func rhandler, const char *rhandler_name, write64_space_func whandler, const char *whandler_name, int handlerunitmask)
{
address_space *spacerw = (address_space *)space;
if (rhandler != NULL && (FPTR)rhandler < STATIC_COUNT)
fatalerror("Attempted to install invalid read handler in space %s of device '%s'\n", space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (whandler != NULL && (FPTR)whandler < STATIC_COUNT)
fatalerror("Attempted to install invalid write handler in space %s of device '%s'\n", space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (rhandler != NULL)
space_map_range(spacerw, ROW_READ, 64, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, spacerw, rhandler_name);
if (whandler != NULL)
space_map_range(spacerw, ROW_WRITE, 64, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, spacerw, whandler_name);
mem_dump(space->machine);
return (UINT64 *)space_find_backing_memory(spacerw, addrstart, addrend);
} | /*-------------------------------------------------
_memory_install_handler64 - same as above but
explicitly for 64-bit handlers
-------------------------------------------------*/ | same as above but
explicitly for 64-bit handlers | [
"same",
"as",
"above",
"but",
"explicitly",
"for",
"64",
"-",
"bit",
"handlers"
] | UINT64 *_memory_install_handler64(const address_space *space, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read64_space_func rhandler, const char *rhandler_name, write64_space_func whandler, const char *whandler_name, int handlerunitmask)
{
address_space *spacerw = (address_space *)space;
if (rhandler != NULL && (FPTR)rhandler < STATIC_COUNT)
fatalerror("Attempted to install invalid read handler in space %s of device '%s'\n", space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (whandler != NULL && (FPTR)whandler < STATIC_COUNT)
fatalerror("Attempted to install invalid write handler in space %s of device '%s'\n", space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (rhandler != NULL)
space_map_range(spacerw, ROW_READ, 64, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, spacerw, rhandler_name);
if (whandler != NULL)
space_map_range(spacerw, ROW_WRITE, 64, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, spacerw, whandler_name);
mem_dump(space->machine);
return (UINT64 *)space_find_backing_memory(spacerw, addrstart, addrend);
} | [
"UINT64",
"*",
"_memory_install_handler64",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"addrstart",
",",
"offs_t",
"addrend",
",",
"offs_t",
"addrmask",
",",
"offs_t",
"addrmirror",
",",
"read64_space_func",
"rhandler",
",",
"const",
"char",
"*",
"rhandler_name",
",",
"write64_space_func",
"whandler",
",",
"const",
"char",
"*",
"whandler_name",
",",
"int",
"handlerunitmask",
")",
"{",
"address_space",
"*",
"spacerw",
"=",
"(",
"address_space",
"*",
")",
"space",
";",
"if",
"(",
"rhandler",
"!=",
"NULL",
"&&",
"(",
"FPTR",
")",
"rhandler",
"<",
"STATIC_COUNT",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"space",
"->",
"name",
",",
"(",
"space",
"->",
"cpu",
"!=",
"NULL",
")",
"?",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"whandler",
"!=",
"NULL",
"&&",
"(",
"FPTR",
")",
"whandler",
"<",
"STATIC_COUNT",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"space",
"->",
"name",
",",
"(",
"space",
"->",
"cpu",
"!=",
"NULL",
")",
"?",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"rhandler",
"!=",
"NULL",
")",
"space_map_range",
"(",
"spacerw",
",",
"ROW_READ",
",",
"64",
",",
"handlerunitmask",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"(",
"genf",
"*",
")",
"rhandler",
",",
"spacerw",
",",
"rhandler_name",
")",
";",
"if",
"(",
"whandler",
"!=",
"NULL",
")",
"space_map_range",
"(",
"spacerw",
",",
"ROW_WRITE",
",",
"64",
",",
"handlerunitmask",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"(",
"genf",
"*",
")",
"whandler",
",",
"spacerw",
",",
"whandler_name",
")",
";",
"mem_dump",
"(",
"space",
"->",
"machine",
")",
";",
"return",
"(",
"UINT64",
"*",
")",
"space_find_backing_memory",
"(",
"spacerw",
",",
"addrstart",
",",
"addrend",
")",
";",
"}"
] | _memory_install_handler64 - same as above but
explicitly for 64-bit handlers | [
"_memory_install_handler64",
"-",
"same",
"as",
"above",
"but",
"explicitly",
"for",
"64",
"-",
"bit",
"handlers"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "addrstart",
"type": "offs_t"
},
{
"param": "addrend",
"type": "offs_t"
},
{
"param": "addrmask",
"type": "offs_t"
},
{
"param": "addrmirror",
"type": "offs_t"
},
{
"param": "rhandler",
"type": "read64_space_func"
},
{
"param": "rhandler_name",
"type": "char"
},
{
"param": "whandler",
"type": "write64_space_func"
},
{
"param": "whandler_name",
"type": "char"
},
{
"param": "handlerunitmask",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrstart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmask",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmirror",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rhandler",
"type": "read64_space_func",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rhandler_name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "whandler",
"type": "write64_space_func",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "whandler_name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "handlerunitmask",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | _memory_install_device_handler8 | UINT8 | UINT8 *_memory_install_device_handler8(const address_space *space, device_t *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read8_device_func rhandler, const char *rhandler_name, write8_device_func whandler, const char *whandler_name, int handlerunitmask)
{
address_space *spacerw = (address_space *)space;
if (rhandler != NULL && (FPTR)rhandler < STATIC_COUNT)
fatalerror("Attempted to install invalid read handler for device '%s' in space %s of device '%s'\n", device->tag(), space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (whandler != NULL && (FPTR)whandler < STATIC_COUNT)
fatalerror("Attempted to install invalid write handler for device '%s' in space %s of device '%s'\n", device->tag(), space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (rhandler != NULL)
space_map_range(spacerw, ROW_READ, 8, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, (void *)device, rhandler_name);
if (whandler != NULL)
space_map_range(spacerw, ROW_WRITE, 8, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, (void *)device, whandler_name);
mem_dump(space->machine);
return (UINT8 *)space_find_backing_memory(spacerw, addrstart, addrend);
} | /*-------------------------------------------------
_memory_install_device_handler8 - same as above
but explicitly for 8-bit handlers
-------------------------------------------------*/ | same as above
but explicitly for 8-bit handlers | [
"same",
"as",
"above",
"but",
"explicitly",
"for",
"8",
"-",
"bit",
"handlers"
] | UINT8 *_memory_install_device_handler8(const address_space *space, device_t *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read8_device_func rhandler, const char *rhandler_name, write8_device_func whandler, const char *whandler_name, int handlerunitmask)
{
address_space *spacerw = (address_space *)space;
if (rhandler != NULL && (FPTR)rhandler < STATIC_COUNT)
fatalerror("Attempted to install invalid read handler for device '%s' in space %s of device '%s'\n", device->tag(), space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (whandler != NULL && (FPTR)whandler < STATIC_COUNT)
fatalerror("Attempted to install invalid write handler for device '%s' in space %s of device '%s'\n", device->tag(), space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (rhandler != NULL)
space_map_range(spacerw, ROW_READ, 8, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, (void *)device, rhandler_name);
if (whandler != NULL)
space_map_range(spacerw, ROW_WRITE, 8, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, (void *)device, whandler_name);
mem_dump(space->machine);
return (UINT8 *)space_find_backing_memory(spacerw, addrstart, addrend);
} | [
"UINT8",
"*",
"_memory_install_device_handler8",
"(",
"const",
"address_space",
"*",
"space",
",",
"device_t",
"*",
"device",
",",
"offs_t",
"addrstart",
",",
"offs_t",
"addrend",
",",
"offs_t",
"addrmask",
",",
"offs_t",
"addrmirror",
",",
"read8_device_func",
"rhandler",
",",
"const",
"char",
"*",
"rhandler_name",
",",
"write8_device_func",
"whandler",
",",
"const",
"char",
"*",
"whandler_name",
",",
"int",
"handlerunitmask",
")",
"{",
"address_space",
"*",
"spacerw",
"=",
"(",
"address_space",
"*",
")",
"space",
";",
"if",
"(",
"rhandler",
"!=",
"NULL",
"&&",
"(",
"FPTR",
")",
"rhandler",
"<",
"STATIC_COUNT",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"device",
"->",
"tag",
"(",
")",
",",
"space",
"->",
"name",
",",
"(",
"space",
"->",
"cpu",
"!=",
"NULL",
")",
"?",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"whandler",
"!=",
"NULL",
"&&",
"(",
"FPTR",
")",
"whandler",
"<",
"STATIC_COUNT",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"device",
"->",
"tag",
"(",
")",
",",
"space",
"->",
"name",
",",
"(",
"space",
"->",
"cpu",
"!=",
"NULL",
")",
"?",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"rhandler",
"!=",
"NULL",
")",
"space_map_range",
"(",
"spacerw",
",",
"ROW_READ",
",",
"8",
",",
"handlerunitmask",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"(",
"genf",
"*",
")",
"rhandler",
",",
"(",
"void",
"*",
")",
"device",
",",
"rhandler_name",
")",
";",
"if",
"(",
"whandler",
"!=",
"NULL",
")",
"space_map_range",
"(",
"spacerw",
",",
"ROW_WRITE",
",",
"8",
",",
"handlerunitmask",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"(",
"genf",
"*",
")",
"whandler",
",",
"(",
"void",
"*",
")",
"device",
",",
"whandler_name",
")",
";",
"mem_dump",
"(",
"space",
"->",
"machine",
")",
";",
"return",
"(",
"UINT8",
"*",
")",
"space_find_backing_memory",
"(",
"spacerw",
",",
"addrstart",
",",
"addrend",
")",
";",
"}"
] | _memory_install_device_handler8 - same as above
but explicitly for 8-bit handlers | [
"_memory_install_device_handler8",
"-",
"same",
"as",
"above",
"but",
"explicitly",
"for",
"8",
"-",
"bit",
"handlers"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "device",
"type": "device_t"
},
{
"param": "addrstart",
"type": "offs_t"
},
{
"param": "addrend",
"type": "offs_t"
},
{
"param": "addrmask",
"type": "offs_t"
},
{
"param": "addrmirror",
"type": "offs_t"
},
{
"param": "rhandler",
"type": "read8_device_func"
},
{
"param": "rhandler_name",
"type": "char"
},
{
"param": "whandler",
"type": "write8_device_func"
},
{
"param": "whandler_name",
"type": "char"
},
{
"param": "handlerunitmask",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "device",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrstart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmask",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmirror",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rhandler",
"type": "read8_device_func",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rhandler_name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "whandler",
"type": "write8_device_func",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "whandler_name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "handlerunitmask",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | _memory_install_device_handler16 | UINT16 | UINT16 *_memory_install_device_handler16(const address_space *space, device_t *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read16_device_func rhandler, const char *rhandler_name, write16_device_func whandler, const char *whandler_name, int handlerunitmask)
{
address_space *spacerw = (address_space *)space;
if (rhandler != NULL && (FPTR)rhandler < STATIC_COUNT)
fatalerror("Attempted to install invalid read handler for device '%s' in space %s of device '%s'\n", device->tag(), space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (whandler != NULL && (FPTR)whandler < STATIC_COUNT)
fatalerror("Attempted to install invalid write handler for device '%s' in space %s of device '%s'\n", device->tag(), space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (rhandler != NULL)
space_map_range(spacerw, ROW_READ, 16, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, (void *)device, rhandler_name);
if (whandler != NULL)
space_map_range(spacerw, ROW_WRITE, 16, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, (void *)device, whandler_name);
mem_dump(space->machine);
return (UINT16 *)space_find_backing_memory(spacerw, addrstart, addrend);
} | /*-------------------------------------------------
_memory_install_device_handler16 - same as
above but explicitly for 16-bit handlers
-------------------------------------------------*/ | same as
above but explicitly for 16-bit handlers | [
"same",
"as",
"above",
"but",
"explicitly",
"for",
"16",
"-",
"bit",
"handlers"
] | UINT16 *_memory_install_device_handler16(const address_space *space, device_t *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read16_device_func rhandler, const char *rhandler_name, write16_device_func whandler, const char *whandler_name, int handlerunitmask)
{
address_space *spacerw = (address_space *)space;
if (rhandler != NULL && (FPTR)rhandler < STATIC_COUNT)
fatalerror("Attempted to install invalid read handler for device '%s' in space %s of device '%s'\n", device->tag(), space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (whandler != NULL && (FPTR)whandler < STATIC_COUNT)
fatalerror("Attempted to install invalid write handler for device '%s' in space %s of device '%s'\n", device->tag(), space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (rhandler != NULL)
space_map_range(spacerw, ROW_READ, 16, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, (void *)device, rhandler_name);
if (whandler != NULL)
space_map_range(spacerw, ROW_WRITE, 16, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, (void *)device, whandler_name);
mem_dump(space->machine);
return (UINT16 *)space_find_backing_memory(spacerw, addrstart, addrend);
} | [
"UINT16",
"*",
"_memory_install_device_handler16",
"(",
"const",
"address_space",
"*",
"space",
",",
"device_t",
"*",
"device",
",",
"offs_t",
"addrstart",
",",
"offs_t",
"addrend",
",",
"offs_t",
"addrmask",
",",
"offs_t",
"addrmirror",
",",
"read16_device_func",
"rhandler",
",",
"const",
"char",
"*",
"rhandler_name",
",",
"write16_device_func",
"whandler",
",",
"const",
"char",
"*",
"whandler_name",
",",
"int",
"handlerunitmask",
")",
"{",
"address_space",
"*",
"spacerw",
"=",
"(",
"address_space",
"*",
")",
"space",
";",
"if",
"(",
"rhandler",
"!=",
"NULL",
"&&",
"(",
"FPTR",
")",
"rhandler",
"<",
"STATIC_COUNT",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"device",
"->",
"tag",
"(",
")",
",",
"space",
"->",
"name",
",",
"(",
"space",
"->",
"cpu",
"!=",
"NULL",
")",
"?",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"whandler",
"!=",
"NULL",
"&&",
"(",
"FPTR",
")",
"whandler",
"<",
"STATIC_COUNT",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"device",
"->",
"tag",
"(",
")",
",",
"space",
"->",
"name",
",",
"(",
"space",
"->",
"cpu",
"!=",
"NULL",
")",
"?",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"rhandler",
"!=",
"NULL",
")",
"space_map_range",
"(",
"spacerw",
",",
"ROW_READ",
",",
"16",
",",
"handlerunitmask",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"(",
"genf",
"*",
")",
"rhandler",
",",
"(",
"void",
"*",
")",
"device",
",",
"rhandler_name",
")",
";",
"if",
"(",
"whandler",
"!=",
"NULL",
")",
"space_map_range",
"(",
"spacerw",
",",
"ROW_WRITE",
",",
"16",
",",
"handlerunitmask",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"(",
"genf",
"*",
")",
"whandler",
",",
"(",
"void",
"*",
")",
"device",
",",
"whandler_name",
")",
";",
"mem_dump",
"(",
"space",
"->",
"machine",
")",
";",
"return",
"(",
"UINT16",
"*",
")",
"space_find_backing_memory",
"(",
"spacerw",
",",
"addrstart",
",",
"addrend",
")",
";",
"}"
] | _memory_install_device_handler16 - same as
above but explicitly for 16-bit handlers | [
"_memory_install_device_handler16",
"-",
"same",
"as",
"above",
"but",
"explicitly",
"for",
"16",
"-",
"bit",
"handlers"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "device",
"type": "device_t"
},
{
"param": "addrstart",
"type": "offs_t"
},
{
"param": "addrend",
"type": "offs_t"
},
{
"param": "addrmask",
"type": "offs_t"
},
{
"param": "addrmirror",
"type": "offs_t"
},
{
"param": "rhandler",
"type": "read16_device_func"
},
{
"param": "rhandler_name",
"type": "char"
},
{
"param": "whandler",
"type": "write16_device_func"
},
{
"param": "whandler_name",
"type": "char"
},
{
"param": "handlerunitmask",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "device",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrstart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmask",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmirror",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rhandler",
"type": "read16_device_func",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rhandler_name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "whandler",
"type": "write16_device_func",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "whandler_name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "handlerunitmask",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | _memory_install_device_handler32 | UINT32 | UINT32 *_memory_install_device_handler32(const address_space *space, device_t *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read32_device_func rhandler, const char *rhandler_name, write32_device_func whandler, const char *whandler_name, int handlerunitmask)
{
address_space *spacerw = (address_space *)space;
if (rhandler != NULL && (FPTR)rhandler < STATIC_COUNT)
fatalerror("Attempted to install invalid read handler for device '%s' in space %s of device '%s'\n", device->tag(), space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (whandler != NULL && (FPTR)whandler < STATIC_COUNT)
fatalerror("Attempted to install invalid write handler for device '%s' in space %s of device '%s'\n", device->tag(), space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (rhandler != NULL)
space_map_range(spacerw, ROW_READ, 32, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, (void *)device, rhandler_name);
if (whandler != NULL)
space_map_range(spacerw, ROW_WRITE, 32, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, (void *)device, whandler_name);
mem_dump(space->machine);
return (UINT32 *)space_find_backing_memory(spacerw, addrstart, addrend);
} | /*-------------------------------------------------
_memory_install_device_handler32 - same as
above but explicitly for 32-bit handlers
-------------------------------------------------*/ | same as
above but explicitly for 32-bit handlers | [
"same",
"as",
"above",
"but",
"explicitly",
"for",
"32",
"-",
"bit",
"handlers"
] | UINT32 *_memory_install_device_handler32(const address_space *space, device_t *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read32_device_func rhandler, const char *rhandler_name, write32_device_func whandler, const char *whandler_name, int handlerunitmask)
{
address_space *spacerw = (address_space *)space;
if (rhandler != NULL && (FPTR)rhandler < STATIC_COUNT)
fatalerror("Attempted to install invalid read handler for device '%s' in space %s of device '%s'\n", device->tag(), space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (whandler != NULL && (FPTR)whandler < STATIC_COUNT)
fatalerror("Attempted to install invalid write handler for device '%s' in space %s of device '%s'\n", device->tag(), space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (rhandler != NULL)
space_map_range(spacerw, ROW_READ, 32, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, (void *)device, rhandler_name);
if (whandler != NULL)
space_map_range(spacerw, ROW_WRITE, 32, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, (void *)device, whandler_name);
mem_dump(space->machine);
return (UINT32 *)space_find_backing_memory(spacerw, addrstart, addrend);
} | [
"UINT32",
"*",
"_memory_install_device_handler32",
"(",
"const",
"address_space",
"*",
"space",
",",
"device_t",
"*",
"device",
",",
"offs_t",
"addrstart",
",",
"offs_t",
"addrend",
",",
"offs_t",
"addrmask",
",",
"offs_t",
"addrmirror",
",",
"read32_device_func",
"rhandler",
",",
"const",
"char",
"*",
"rhandler_name",
",",
"write32_device_func",
"whandler",
",",
"const",
"char",
"*",
"whandler_name",
",",
"int",
"handlerunitmask",
")",
"{",
"address_space",
"*",
"spacerw",
"=",
"(",
"address_space",
"*",
")",
"space",
";",
"if",
"(",
"rhandler",
"!=",
"NULL",
"&&",
"(",
"FPTR",
")",
"rhandler",
"<",
"STATIC_COUNT",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"device",
"->",
"tag",
"(",
")",
",",
"space",
"->",
"name",
",",
"(",
"space",
"->",
"cpu",
"!=",
"NULL",
")",
"?",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"whandler",
"!=",
"NULL",
"&&",
"(",
"FPTR",
")",
"whandler",
"<",
"STATIC_COUNT",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"device",
"->",
"tag",
"(",
")",
",",
"space",
"->",
"name",
",",
"(",
"space",
"->",
"cpu",
"!=",
"NULL",
")",
"?",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"rhandler",
"!=",
"NULL",
")",
"space_map_range",
"(",
"spacerw",
",",
"ROW_READ",
",",
"32",
",",
"handlerunitmask",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"(",
"genf",
"*",
")",
"rhandler",
",",
"(",
"void",
"*",
")",
"device",
",",
"rhandler_name",
")",
";",
"if",
"(",
"whandler",
"!=",
"NULL",
")",
"space_map_range",
"(",
"spacerw",
",",
"ROW_WRITE",
",",
"32",
",",
"handlerunitmask",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"(",
"genf",
"*",
")",
"whandler",
",",
"(",
"void",
"*",
")",
"device",
",",
"whandler_name",
")",
";",
"mem_dump",
"(",
"space",
"->",
"machine",
")",
";",
"return",
"(",
"UINT32",
"*",
")",
"space_find_backing_memory",
"(",
"spacerw",
",",
"addrstart",
",",
"addrend",
")",
";",
"}"
] | _memory_install_device_handler32 - same as
above but explicitly for 32-bit handlers | [
"_memory_install_device_handler32",
"-",
"same",
"as",
"above",
"but",
"explicitly",
"for",
"32",
"-",
"bit",
"handlers"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "device",
"type": "device_t"
},
{
"param": "addrstart",
"type": "offs_t"
},
{
"param": "addrend",
"type": "offs_t"
},
{
"param": "addrmask",
"type": "offs_t"
},
{
"param": "addrmirror",
"type": "offs_t"
},
{
"param": "rhandler",
"type": "read32_device_func"
},
{
"param": "rhandler_name",
"type": "char"
},
{
"param": "whandler",
"type": "write32_device_func"
},
{
"param": "whandler_name",
"type": "char"
},
{
"param": "handlerunitmask",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "device",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrstart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmask",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmirror",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rhandler",
"type": "read32_device_func",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rhandler_name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "whandler",
"type": "write32_device_func",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "whandler_name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "handlerunitmask",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | _memory_install_device_handler64 | UINT64 | UINT64 *_memory_install_device_handler64(const address_space *space, device_t *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read64_device_func rhandler, const char *rhandler_name, write64_device_func whandler, const char *whandler_name, int handlerunitmask)
{
address_space *spacerw = (address_space *)space;
if (rhandler != NULL && (FPTR)rhandler < STATIC_COUNT)
fatalerror("Attempted to install invalid read handler for device '%s' in space %s of device '%s'\n", device->tag(), space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (whandler != NULL && (FPTR)whandler < STATIC_COUNT)
fatalerror("Attempted to install invalid write handler for device '%s' in space %s of device '%s'\n", device->tag(), space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (rhandler != NULL)
space_map_range(spacerw, ROW_READ, 64, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, (void *)device, rhandler_name);
if (whandler != NULL)
space_map_range(spacerw, ROW_WRITE, 64, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, (void *)device, whandler_name);
mem_dump(space->machine);
return (UINT64 *)space_find_backing_memory(spacerw, addrstart, addrend);
} | /*-------------------------------------------------
_memory_install_device_handler64 - same as
above but explicitly for 64-bit handlers
-------------------------------------------------*/ | same as
above but explicitly for 64-bit handlers | [
"same",
"as",
"above",
"but",
"explicitly",
"for",
"64",
"-",
"bit",
"handlers"
] | UINT64 *_memory_install_device_handler64(const address_space *space, device_t *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read64_device_func rhandler, const char *rhandler_name, write64_device_func whandler, const char *whandler_name, int handlerunitmask)
{
address_space *spacerw = (address_space *)space;
if (rhandler != NULL && (FPTR)rhandler < STATIC_COUNT)
fatalerror("Attempted to install invalid read handler for device '%s' in space %s of device '%s'\n", device->tag(), space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (whandler != NULL && (FPTR)whandler < STATIC_COUNT)
fatalerror("Attempted to install invalid write handler for device '%s' in space %s of device '%s'\n", device->tag(), space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
if (rhandler != NULL)
space_map_range(spacerw, ROW_READ, 64, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, (void *)device, rhandler_name);
if (whandler != NULL)
space_map_range(spacerw, ROW_WRITE, 64, handlerunitmask, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, (void *)device, whandler_name);
mem_dump(space->machine);
return (UINT64 *)space_find_backing_memory(spacerw, addrstart, addrend);
} | [
"UINT64",
"*",
"_memory_install_device_handler64",
"(",
"const",
"address_space",
"*",
"space",
",",
"device_t",
"*",
"device",
",",
"offs_t",
"addrstart",
",",
"offs_t",
"addrend",
",",
"offs_t",
"addrmask",
",",
"offs_t",
"addrmirror",
",",
"read64_device_func",
"rhandler",
",",
"const",
"char",
"*",
"rhandler_name",
",",
"write64_device_func",
"whandler",
",",
"const",
"char",
"*",
"whandler_name",
",",
"int",
"handlerunitmask",
")",
"{",
"address_space",
"*",
"spacerw",
"=",
"(",
"address_space",
"*",
")",
"space",
";",
"if",
"(",
"rhandler",
"!=",
"NULL",
"&&",
"(",
"FPTR",
")",
"rhandler",
"<",
"STATIC_COUNT",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"device",
"->",
"tag",
"(",
")",
",",
"space",
"->",
"name",
",",
"(",
"space",
"->",
"cpu",
"!=",
"NULL",
")",
"?",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"whandler",
"!=",
"NULL",
"&&",
"(",
"FPTR",
")",
"whandler",
"<",
"STATIC_COUNT",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"device",
"->",
"tag",
"(",
")",
",",
"space",
"->",
"name",
",",
"(",
"space",
"->",
"cpu",
"!=",
"NULL",
")",
"?",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"rhandler",
"!=",
"NULL",
")",
"space_map_range",
"(",
"spacerw",
",",
"ROW_READ",
",",
"64",
",",
"handlerunitmask",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"(",
"genf",
"*",
")",
"rhandler",
",",
"(",
"void",
"*",
")",
"device",
",",
"rhandler_name",
")",
";",
"if",
"(",
"whandler",
"!=",
"NULL",
")",
"space_map_range",
"(",
"spacerw",
",",
"ROW_WRITE",
",",
"64",
",",
"handlerunitmask",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"(",
"genf",
"*",
")",
"whandler",
",",
"(",
"void",
"*",
")",
"device",
",",
"whandler_name",
")",
";",
"mem_dump",
"(",
"space",
"->",
"machine",
")",
";",
"return",
"(",
"UINT64",
"*",
")",
"space_find_backing_memory",
"(",
"spacerw",
",",
"addrstart",
",",
"addrend",
")",
";",
"}"
] | _memory_install_device_handler64 - same as
above but explicitly for 64-bit handlers | [
"_memory_install_device_handler64",
"-",
"same",
"as",
"above",
"but",
"explicitly",
"for",
"64",
"-",
"bit",
"handlers"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "device",
"type": "device_t"
},
{
"param": "addrstart",
"type": "offs_t"
},
{
"param": "addrend",
"type": "offs_t"
},
{
"param": "addrmask",
"type": "offs_t"
},
{
"param": "addrmirror",
"type": "offs_t"
},
{
"param": "rhandler",
"type": "read64_device_func"
},
{
"param": "rhandler_name",
"type": "char"
},
{
"param": "whandler",
"type": "write64_device_func"
},
{
"param": "whandler_name",
"type": "char"
},
{
"param": "handlerunitmask",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "device",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrstart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmask",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmirror",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rhandler",
"type": "read64_device_func",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rhandler_name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "whandler",
"type": "write64_device_func",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "whandler_name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "handlerunitmask",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | _memory_install_port | void | void _memory_install_port(const address_space *space, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *rtag, const char *wtag)
{
address_space *spacerw = (address_space *)space;
genf *rhandler = NULL;
genf *whandler = NULL;
/* pick the appropriate read/write handlers */
switch (space->dbits)
{
case 8: rhandler = (genf *)input_port_read8; whandler = (genf *)input_port_write8; break;
case 16: rhandler = (genf *)input_port_read16; whandler = (genf *)input_port_write16; break;
case 32: rhandler = (genf *)input_port_read32; whandler = (genf *)input_port_write32; break;
case 64: rhandler = (genf *)input_port_read64; whandler = (genf *)input_port_write64; break;
}
/* assign the read handler */
if (rtag != NULL)
{
const input_port_config *port = space->machine->port(rtag);
if (port == NULL)
fatalerror("Attempted to map non-existent port '%s' for read in space %s of device '%s'\n", rtag, space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
space_map_range(spacerw, ROW_READ, space->dbits, 0, addrstart, addrend, addrmask, addrmirror, rhandler, (void *)port, rtag);
}
/* assign the write handler */
if (wtag != NULL)
{
const input_port_config *port = space->machine->port(wtag);
if (port == NULL)
fatalerror("Attempted to map non-existent port '%s' for write in space %s of device '%s'\n", wtag, space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
space_map_range(spacerw, ROW_WRITE, space->dbits, 0, addrstart, addrend, addrmask, addrmirror, whandler, (void *)port, wtag);
}
/* update the memory dump */
mem_dump(space->machine);
} | /*-------------------------------------------------
_memory_install_port - install a
new port handler into the given address space
-------------------------------------------------*/ | install a
new port handler into the given address space | [
"install",
"a",
"new",
"port",
"handler",
"into",
"the",
"given",
"address",
"space"
] | void _memory_install_port(const address_space *space, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *rtag, const char *wtag)
{
address_space *spacerw = (address_space *)space;
genf *rhandler = NULL;
genf *whandler = NULL;
switch (space->dbits)
{
case 8: rhandler = (genf *)input_port_read8; whandler = (genf *)input_port_write8; break;
case 16: rhandler = (genf *)input_port_read16; whandler = (genf *)input_port_write16; break;
case 32: rhandler = (genf *)input_port_read32; whandler = (genf *)input_port_write32; break;
case 64: rhandler = (genf *)input_port_read64; whandler = (genf *)input_port_write64; break;
}
if (rtag != NULL)
{
const input_port_config *port = space->machine->port(rtag);
if (port == NULL)
fatalerror("Attempted to map non-existent port '%s' for read in space %s of device '%s'\n", rtag, space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
space_map_range(spacerw, ROW_READ, space->dbits, 0, addrstart, addrend, addrmask, addrmirror, rhandler, (void *)port, rtag);
}
if (wtag != NULL)
{
const input_port_config *port = space->machine->port(wtag);
if (port == NULL)
fatalerror("Attempted to map non-existent port '%s' for write in space %s of device '%s'\n", wtag, space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
space_map_range(spacerw, ROW_WRITE, space->dbits, 0, addrstart, addrend, addrmask, addrmirror, whandler, (void *)port, wtag);
}
mem_dump(space->machine);
} | [
"void",
"_memory_install_port",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"addrstart",
",",
"offs_t",
"addrend",
",",
"offs_t",
"addrmask",
",",
"offs_t",
"addrmirror",
",",
"const",
"char",
"*",
"rtag",
",",
"const",
"char",
"*",
"wtag",
")",
"{",
"address_space",
"*",
"spacerw",
"=",
"(",
"address_space",
"*",
")",
"space",
";",
"genf",
"*",
"rhandler",
"=",
"NULL",
";",
"genf",
"*",
"whandler",
"=",
"NULL",
";",
"switch",
"(",
"space",
"->",
"dbits",
")",
"{",
"case",
"8",
":",
"rhandler",
"=",
"(",
"genf",
"*",
")",
"input_port_read8",
";",
"whandler",
"=",
"(",
"genf",
"*",
")",
"input_port_write8",
";",
"break",
";",
"case",
"16",
":",
"rhandler",
"=",
"(",
"genf",
"*",
")",
"input_port_read16",
";",
"whandler",
"=",
"(",
"genf",
"*",
")",
"input_port_write16",
";",
"break",
";",
"case",
"32",
":",
"rhandler",
"=",
"(",
"genf",
"*",
")",
"input_port_read32",
";",
"whandler",
"=",
"(",
"genf",
"*",
")",
"input_port_write32",
";",
"break",
";",
"case",
"64",
":",
"rhandler",
"=",
"(",
"genf",
"*",
")",
"input_port_read64",
";",
"whandler",
"=",
"(",
"genf",
"*",
")",
"input_port_write64",
";",
"break",
";",
"}",
"if",
"(",
"rtag",
"!=",
"NULL",
")",
"{",
"const",
"input_port_config",
"*",
"port",
"=",
"space",
"->",
"machine",
"->",
"port",
"(",
"rtag",
")",
";",
"if",
"(",
"port",
"==",
"NULL",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"rtag",
",",
"space",
"->",
"name",
",",
"(",
"space",
"->",
"cpu",
"!=",
"NULL",
")",
"?",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
":",
"\"",
"\"",
")",
";",
"space_map_range",
"(",
"spacerw",
",",
"ROW_READ",
",",
"space",
"->",
"dbits",
",",
"0",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"rhandler",
",",
"(",
"void",
"*",
")",
"port",
",",
"rtag",
")",
";",
"}",
"if",
"(",
"wtag",
"!=",
"NULL",
")",
"{",
"const",
"input_port_config",
"*",
"port",
"=",
"space",
"->",
"machine",
"->",
"port",
"(",
"wtag",
")",
";",
"if",
"(",
"port",
"==",
"NULL",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"wtag",
",",
"space",
"->",
"name",
",",
"(",
"space",
"->",
"cpu",
"!=",
"NULL",
")",
"?",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
":",
"\"",
"\"",
")",
";",
"space_map_range",
"(",
"spacerw",
",",
"ROW_WRITE",
",",
"space",
"->",
"dbits",
",",
"0",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"whandler",
",",
"(",
"void",
"*",
")",
"port",
",",
"wtag",
")",
";",
"}",
"mem_dump",
"(",
"space",
"->",
"machine",
")",
";",
"}"
] | _memory_install_port - install a
new port handler into the given address space | [
"_memory_install_port",
"-",
"install",
"a",
"new",
"port",
"handler",
"into",
"the",
"given",
"address",
"space"
] | [
"/* pick the appropriate read/write handlers */",
"/* assign the read handler */",
"/* assign the write handler */",
"/* update the memory dump */"
] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "addrstart",
"type": "offs_t"
},
{
"param": "addrend",
"type": "offs_t"
},
{
"param": "addrmask",
"type": "offs_t"
},
{
"param": "addrmirror",
"type": "offs_t"
},
{
"param": "rtag",
"type": "char"
},
{
"param": "wtag",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrstart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmask",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmirror",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rtag",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "wtag",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | _memory_install_bank | void | void _memory_install_bank(const address_space *space, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *rtag, const char *wtag)
{
address_space *spacerw = (address_space *)space;
/* map the read bank */
if (rtag != NULL)
{
genf *handler = bank_find_or_allocate(space, rtag, addrstart, addrend, addrmask, addrmirror, ROW_READ);
space_map_range(spacerw, ROW_READ, space->dbits, 0, addrstart, addrend, addrmask, addrmirror, handler, spacerw, rtag);
}
/* map the write bank */
if (wtag != NULL)
{
genf *handler = bank_find_or_allocate(space, wtag, addrstart, addrend, addrmask, addrmirror, ROW_WRITE);
space_map_range(spacerw, ROW_WRITE, space->dbits, 0, addrstart, addrend, addrmask, addrmirror, handler, spacerw, wtag);
}
/* update the memory dump */
mem_dump(space->machine);
} | /*-------------------------------------------------
_memory_install_bank - install a
new port handler into the given address space
-------------------------------------------------*/ | install a
new port handler into the given address space | [
"install",
"a",
"new",
"port",
"handler",
"into",
"the",
"given",
"address",
"space"
] | void _memory_install_bank(const address_space *space, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *rtag, const char *wtag)
{
address_space *spacerw = (address_space *)space;
if (rtag != NULL)
{
genf *handler = bank_find_or_allocate(space, rtag, addrstart, addrend, addrmask, addrmirror, ROW_READ);
space_map_range(spacerw, ROW_READ, space->dbits, 0, addrstart, addrend, addrmask, addrmirror, handler, spacerw, rtag);
}
if (wtag != NULL)
{
genf *handler = bank_find_or_allocate(space, wtag, addrstart, addrend, addrmask, addrmirror, ROW_WRITE);
space_map_range(spacerw, ROW_WRITE, space->dbits, 0, addrstart, addrend, addrmask, addrmirror, handler, spacerw, wtag);
}
mem_dump(space->machine);
} | [
"void",
"_memory_install_bank",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"addrstart",
",",
"offs_t",
"addrend",
",",
"offs_t",
"addrmask",
",",
"offs_t",
"addrmirror",
",",
"const",
"char",
"*",
"rtag",
",",
"const",
"char",
"*",
"wtag",
")",
"{",
"address_space",
"*",
"spacerw",
"=",
"(",
"address_space",
"*",
")",
"space",
";",
"if",
"(",
"rtag",
"!=",
"NULL",
")",
"{",
"genf",
"*",
"handler",
"=",
"bank_find_or_allocate",
"(",
"space",
",",
"rtag",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"ROW_READ",
")",
";",
"space_map_range",
"(",
"spacerw",
",",
"ROW_READ",
",",
"space",
"->",
"dbits",
",",
"0",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"handler",
",",
"spacerw",
",",
"rtag",
")",
";",
"}",
"if",
"(",
"wtag",
"!=",
"NULL",
")",
"{",
"genf",
"*",
"handler",
"=",
"bank_find_or_allocate",
"(",
"space",
",",
"wtag",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"ROW_WRITE",
")",
";",
"space_map_range",
"(",
"spacerw",
",",
"ROW_WRITE",
",",
"space",
"->",
"dbits",
",",
"0",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"handler",
",",
"spacerw",
",",
"wtag",
")",
";",
"}",
"mem_dump",
"(",
"space",
"->",
"machine",
")",
";",
"}"
] | _memory_install_bank - install a
new port handler into the given address space | [
"_memory_install_bank",
"-",
"install",
"a",
"new",
"port",
"handler",
"into",
"the",
"given",
"address",
"space"
] | [
"/* map the read bank */",
"/* map the write bank */",
"/* update the memory dump */"
] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "addrstart",
"type": "offs_t"
},
{
"param": "addrend",
"type": "offs_t"
},
{
"param": "addrmask",
"type": "offs_t"
},
{
"param": "addrmirror",
"type": "offs_t"
},
{
"param": "rtag",
"type": "char"
},
{
"param": "wtag",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrstart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmask",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmirror",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rtag",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "wtag",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | _memory_install_ram | void | void *_memory_install_ram(const address_space *space, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, UINT8 install_read, UINT8 install_write, void *baseptr)
{
memory_private *memdata = space->machine->memory_data;
address_space *spacerw = (address_space *)space;
FPTR bankindex;
genf *handler;
/* map for read */
if (install_read)
{
handler = bank_find_or_allocate(space, NULL, addrstart, addrend, addrmask, addrmirror, ROW_READ);
space_map_range(spacerw, ROW_READ, space->dbits, 0, addrstart, addrend, addrmask, addrmirror, handler, spacerw, "ram");
/* if we are provided a pointer, set it */
bankindex = (FPTR)handler;
if (baseptr != NULL)
memdata->bank_ptr[bankindex] = (UINT8 *)baseptr;
/* if we don't have a bank pointer yet, try to find one */
if (memdata->bank_ptr[bankindex] == NULL)
memdata->bank_ptr[bankindex] = (UINT8 *)space_find_backing_memory(space, addrstart, addrend);
/* if we still don't have a pointer, and we're past the initialization phase, allocate a new block */
if (memdata->bank_ptr[bankindex] == NULL && memdata->initialized)
{
if (space->machine->phase() >= MACHINE_PHASE_RESET)
fatalerror("Attempted to call memory_install_ram() after initialization time without a baseptr!");
memdata->bank_ptr[bankindex] = (UINT8 *)block_allocate(space, memory_address_to_byte(space, addrstart), memory_address_to_byte_end(space, addrend), NULL);
}
}
/* map for write */
if (install_write)
{
handler = bank_find_or_allocate(space, NULL, addrstart, addrend, addrmask, addrmirror, ROW_WRITE);
space_map_range(spacerw, ROW_WRITE, space->dbits, 0, addrstart, addrend, addrmask, addrmirror, handler, spacerw, "ram");
/* if we are provided a pointer, set it */
bankindex = (FPTR)handler;
if (baseptr != NULL)
memdata->bank_ptr[bankindex] = (UINT8 *)baseptr;
/* if we don't have a bank pointer yet, try to find one */
if (memdata->bank_ptr[bankindex] == NULL)
memdata->bank_ptr[bankindex] = (UINT8 *)space_find_backing_memory(space, addrstart, addrend);
/* if we still don't have a pointer, and we're past the initialization phase, allocate a new block */
if (memdata->bank_ptr[bankindex] == NULL && memdata->initialized)
{
if (space->machine->phase() >= MACHINE_PHASE_RESET)
fatalerror("Attempted to call memory_install_ram() after initialization time without a baseptr!");
memdata->bank_ptr[bankindex] = (UINT8 *)block_allocate(space, memory_address_to_byte(space, addrstart), memory_address_to_byte_end(space, addrend), NULL);
}
}
return (void *)space_find_backing_memory(spacerw, addrstart, addrend);
} | /*-------------------------------------------------
_memory_install_ram - install a simple fixed
RAM region into the given address space
-------------------------------------------------*/ | install a simple fixed
RAM region into the given address space | [
"install",
"a",
"simple",
"fixed",
"RAM",
"region",
"into",
"the",
"given",
"address",
"space"
] | void *_memory_install_ram(const address_space *space, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, UINT8 install_read, UINT8 install_write, void *baseptr)
{
memory_private *memdata = space->machine->memory_data;
address_space *spacerw = (address_space *)space;
FPTR bankindex;
genf *handler;
if (install_read)
{
handler = bank_find_or_allocate(space, NULL, addrstart, addrend, addrmask, addrmirror, ROW_READ);
space_map_range(spacerw, ROW_READ, space->dbits, 0, addrstart, addrend, addrmask, addrmirror, handler, spacerw, "ram");
bankindex = (FPTR)handler;
if (baseptr != NULL)
memdata->bank_ptr[bankindex] = (UINT8 *)baseptr;
if (memdata->bank_ptr[bankindex] == NULL)
memdata->bank_ptr[bankindex] = (UINT8 *)space_find_backing_memory(space, addrstart, addrend);
if (memdata->bank_ptr[bankindex] == NULL && memdata->initialized)
{
if (space->machine->phase() >= MACHINE_PHASE_RESET)
fatalerror("Attempted to call memory_install_ram() after initialization time without a baseptr!");
memdata->bank_ptr[bankindex] = (UINT8 *)block_allocate(space, memory_address_to_byte(space, addrstart), memory_address_to_byte_end(space, addrend), NULL);
}
}
if (install_write)
{
handler = bank_find_or_allocate(space, NULL, addrstart, addrend, addrmask, addrmirror, ROW_WRITE);
space_map_range(spacerw, ROW_WRITE, space->dbits, 0, addrstart, addrend, addrmask, addrmirror, handler, spacerw, "ram");
bankindex = (FPTR)handler;
if (baseptr != NULL)
memdata->bank_ptr[bankindex] = (UINT8 *)baseptr;
if (memdata->bank_ptr[bankindex] == NULL)
memdata->bank_ptr[bankindex] = (UINT8 *)space_find_backing_memory(space, addrstart, addrend);
if (memdata->bank_ptr[bankindex] == NULL && memdata->initialized)
{
if (space->machine->phase() >= MACHINE_PHASE_RESET)
fatalerror("Attempted to call memory_install_ram() after initialization time without a baseptr!");
memdata->bank_ptr[bankindex] = (UINT8 *)block_allocate(space, memory_address_to_byte(space, addrstart), memory_address_to_byte_end(space, addrend), NULL);
}
}
return (void *)space_find_backing_memory(spacerw, addrstart, addrend);
} | [
"void",
"*",
"_memory_install_ram",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"addrstart",
",",
"offs_t",
"addrend",
",",
"offs_t",
"addrmask",
",",
"offs_t",
"addrmirror",
",",
"UINT8",
"install_read",
",",
"UINT8",
"install_write",
",",
"void",
"*",
"baseptr",
")",
"{",
"memory_private",
"*",
"memdata",
"=",
"space",
"->",
"machine",
"->",
"memory_data",
";",
"address_space",
"*",
"spacerw",
"=",
"(",
"address_space",
"*",
")",
"space",
";",
"FPTR",
"bankindex",
";",
"genf",
"*",
"handler",
";",
"if",
"(",
"install_read",
")",
"{",
"handler",
"=",
"bank_find_or_allocate",
"(",
"space",
",",
"NULL",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"ROW_READ",
")",
";",
"space_map_range",
"(",
"spacerw",
",",
"ROW_READ",
",",
"space",
"->",
"dbits",
",",
"0",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"handler",
",",
"spacerw",
",",
"\"",
"\"",
")",
";",
"bankindex",
"=",
"(",
"FPTR",
")",
"handler",
";",
"if",
"(",
"baseptr",
"!=",
"NULL",
")",
"memdata",
"->",
"bank_ptr",
"[",
"bankindex",
"]",
"=",
"(",
"UINT8",
"*",
")",
"baseptr",
";",
"if",
"(",
"memdata",
"->",
"bank_ptr",
"[",
"bankindex",
"]",
"==",
"NULL",
")",
"memdata",
"->",
"bank_ptr",
"[",
"bankindex",
"]",
"=",
"(",
"UINT8",
"*",
")",
"space_find_backing_memory",
"(",
"space",
",",
"addrstart",
",",
"addrend",
")",
";",
"if",
"(",
"memdata",
"->",
"bank_ptr",
"[",
"bankindex",
"]",
"==",
"NULL",
"&&",
"memdata",
"->",
"initialized",
")",
"{",
"if",
"(",
"space",
"->",
"machine",
"->",
"phase",
"(",
")",
">=",
"MACHINE_PHASE_RESET",
")",
"fatalerror",
"(",
"\"",
"\"",
")",
";",
"memdata",
"->",
"bank_ptr",
"[",
"bankindex",
"]",
"=",
"(",
"UINT8",
"*",
")",
"block_allocate",
"(",
"space",
",",
"memory_address_to_byte",
"(",
"space",
",",
"addrstart",
")",
",",
"memory_address_to_byte_end",
"(",
"space",
",",
"addrend",
")",
",",
"NULL",
")",
";",
"}",
"}",
"if",
"(",
"install_write",
")",
"{",
"handler",
"=",
"bank_find_or_allocate",
"(",
"space",
",",
"NULL",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"ROW_WRITE",
")",
";",
"space_map_range",
"(",
"spacerw",
",",
"ROW_WRITE",
",",
"space",
"->",
"dbits",
",",
"0",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"handler",
",",
"spacerw",
",",
"\"",
"\"",
")",
";",
"bankindex",
"=",
"(",
"FPTR",
")",
"handler",
";",
"if",
"(",
"baseptr",
"!=",
"NULL",
")",
"memdata",
"->",
"bank_ptr",
"[",
"bankindex",
"]",
"=",
"(",
"UINT8",
"*",
")",
"baseptr",
";",
"if",
"(",
"memdata",
"->",
"bank_ptr",
"[",
"bankindex",
"]",
"==",
"NULL",
")",
"memdata",
"->",
"bank_ptr",
"[",
"bankindex",
"]",
"=",
"(",
"UINT8",
"*",
")",
"space_find_backing_memory",
"(",
"space",
",",
"addrstart",
",",
"addrend",
")",
";",
"if",
"(",
"memdata",
"->",
"bank_ptr",
"[",
"bankindex",
"]",
"==",
"NULL",
"&&",
"memdata",
"->",
"initialized",
")",
"{",
"if",
"(",
"space",
"->",
"machine",
"->",
"phase",
"(",
")",
">=",
"MACHINE_PHASE_RESET",
")",
"fatalerror",
"(",
"\"",
"\"",
")",
";",
"memdata",
"->",
"bank_ptr",
"[",
"bankindex",
"]",
"=",
"(",
"UINT8",
"*",
")",
"block_allocate",
"(",
"space",
",",
"memory_address_to_byte",
"(",
"space",
",",
"addrstart",
")",
",",
"memory_address_to_byte_end",
"(",
"space",
",",
"addrend",
")",
",",
"NULL",
")",
";",
"}",
"}",
"return",
"(",
"void",
"*",
")",
"space_find_backing_memory",
"(",
"spacerw",
",",
"addrstart",
",",
"addrend",
")",
";",
"}"
] | _memory_install_ram - install a simple fixed
RAM region into the given address space | [
"_memory_install_ram",
"-",
"install",
"a",
"simple",
"fixed",
"RAM",
"region",
"into",
"the",
"given",
"address",
"space"
] | [
"/* map for read */",
"/* if we are provided a pointer, set it */",
"/* if we don't have a bank pointer yet, try to find one */",
"/* if we still don't have a pointer, and we're past the initialization phase, allocate a new block */",
"/* map for write */",
"/* if we are provided a pointer, set it */",
"/* if we don't have a bank pointer yet, try to find one */",
"/* if we still don't have a pointer, and we're past the initialization phase, allocate a new block */"
] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "addrstart",
"type": "offs_t"
},
{
"param": "addrend",
"type": "offs_t"
},
{
"param": "addrmask",
"type": "offs_t"
},
{
"param": "addrmirror",
"type": "offs_t"
},
{
"param": "install_read",
"type": "UINT8"
},
{
"param": "install_write",
"type": "UINT8"
},
{
"param": "baseptr",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrstart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmask",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmirror",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "install_read",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "install_write",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "baseptr",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | _memory_unmap | void | void _memory_unmap(const address_space *space, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, UINT8 unmap_read, UINT8 unmap_write, UINT8 quiet)
{
address_space *spacerw = (address_space *)space;
if (unmap_read)
space_map_range(spacerw, ROW_READ, space->dbits, 0, addrstart, addrend, addrmask, addrmirror, (genf *)(FPTR)(quiet ? STATIC_NOP : STATIC_UNMAP), spacerw, "unmapped");
if (unmap_write)
space_map_range(spacerw, ROW_WRITE, space->dbits, 0, addrstart, addrend, addrmask, addrmirror, (genf *)(FPTR)(quiet ? STATIC_NOP : STATIC_UNMAP), spacerw, "unmapped");
} | /*-------------------------------------------------
_memory_unmap - unmap a section of address
space
-------------------------------------------------*/ | unmap a section of address
space | [
"unmap",
"a",
"section",
"of",
"address",
"space"
] | void _memory_unmap(const address_space *space, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, UINT8 unmap_read, UINT8 unmap_write, UINT8 quiet)
{
address_space *spacerw = (address_space *)space;
if (unmap_read)
space_map_range(spacerw, ROW_READ, space->dbits, 0, addrstart, addrend, addrmask, addrmirror, (genf *)(FPTR)(quiet ? STATIC_NOP : STATIC_UNMAP), spacerw, "unmapped");
if (unmap_write)
space_map_range(spacerw, ROW_WRITE, space->dbits, 0, addrstart, addrend, addrmask, addrmirror, (genf *)(FPTR)(quiet ? STATIC_NOP : STATIC_UNMAP), spacerw, "unmapped");
} | [
"void",
"_memory_unmap",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"addrstart",
",",
"offs_t",
"addrend",
",",
"offs_t",
"addrmask",
",",
"offs_t",
"addrmirror",
",",
"UINT8",
"unmap_read",
",",
"UINT8",
"unmap_write",
",",
"UINT8",
"quiet",
")",
"{",
"address_space",
"*",
"spacerw",
"=",
"(",
"address_space",
"*",
")",
"space",
";",
"if",
"(",
"unmap_read",
")",
"space_map_range",
"(",
"spacerw",
",",
"ROW_READ",
",",
"space",
"->",
"dbits",
",",
"0",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"(",
"genf",
"*",
")",
"(",
"FPTR",
")",
"(",
"quiet",
"?",
"STATIC_NOP",
":",
"STATIC_UNMAP",
")",
",",
"spacerw",
",",
"\"",
"\"",
")",
";",
"if",
"(",
"unmap_write",
")",
"space_map_range",
"(",
"spacerw",
",",
"ROW_WRITE",
",",
"space",
"->",
"dbits",
",",
"0",
",",
"addrstart",
",",
"addrend",
",",
"addrmask",
",",
"addrmirror",
",",
"(",
"genf",
"*",
")",
"(",
"FPTR",
")",
"(",
"quiet",
"?",
"STATIC_NOP",
":",
"STATIC_UNMAP",
")",
",",
"spacerw",
",",
"\"",
"\"",
")",
";",
"}"
] | _memory_unmap - unmap a section of address
space | [
"_memory_unmap",
"-",
"unmap",
"a",
"section",
"of",
"address",
"space"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "addrstart",
"type": "offs_t"
},
{
"param": "addrend",
"type": "offs_t"
},
{
"param": "addrmask",
"type": "offs_t"
},
{
"param": "addrmirror",
"type": "offs_t"
},
{
"param": "unmap_read",
"type": "UINT8"
},
{
"param": "unmap_write",
"type": "UINT8"
},
{
"param": "quiet",
"type": "UINT8"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrstart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmask",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmirror",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "unmap_read",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "unmap_write",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "quiet",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | memory_get_handler_string | char | const char *memory_get_handler_string(const address_space *space, int read0_or_write1, offs_t byteaddress)
{
const address_table *table = read0_or_write1 ? &space->write : &space->read;
UINT8 entry;
/* perform the lookup */
byteaddress &= space->bytemask;
entry = table->table[LEVEL1_INDEX(byteaddress)];
if (entry >= SUBTABLE_BASE)
entry = table->table[LEVEL2_INDEX(entry, byteaddress)];
/* 8-bit case: RAM/ROM */
return handler_to_string(space, table, entry);
} | /*-------------------------------------------------
memory_get_handler_string - return a string
describing the handler at a particular offset
-------------------------------------------------*/ | return a string
describing the handler at a particular offset | [
"return",
"a",
"string",
"describing",
"the",
"handler",
"at",
"a",
"particular",
"offset"
] | const char *memory_get_handler_string(const address_space *space, int read0_or_write1, offs_t byteaddress)
{
const address_table *table = read0_or_write1 ? &space->write : &space->read;
UINT8 entry;
byteaddress &= space->bytemask;
entry = table->table[LEVEL1_INDEX(byteaddress)];
if (entry >= SUBTABLE_BASE)
entry = table->table[LEVEL2_INDEX(entry, byteaddress)];
return handler_to_string(space, table, entry);
} | [
"const",
"char",
"*",
"memory_get_handler_string",
"(",
"const",
"address_space",
"*",
"space",
",",
"int",
"read0_or_write1",
",",
"offs_t",
"byteaddress",
")",
"{",
"const",
"address_table",
"*",
"table",
"=",
"read0_or_write1",
"?",
"&",
"space",
"->",
"write",
":",
"&",
"space",
"->",
"read",
";",
"UINT8",
"entry",
";",
"byteaddress",
"&=",
"space",
"->",
"bytemask",
";",
"entry",
"=",
"table",
"->",
"table",
"[",
"LEVEL1_INDEX",
"(",
"byteaddress",
")",
"]",
";",
"if",
"(",
"entry",
">=",
"SUBTABLE_BASE",
")",
"entry",
"=",
"table",
"->",
"table",
"[",
"LEVEL2_INDEX",
"(",
"entry",
",",
"byteaddress",
")",
"]",
";",
"return",
"handler_to_string",
"(",
"space",
",",
"table",
",",
"entry",
")",
";",
"}"
] | memory_get_handler_string - return a string
describing the handler at a particular offset | [
"memory_get_handler_string",
"-",
"return",
"a",
"string",
"describing",
"the",
"handler",
"at",
"a",
"particular",
"offset"
] | [
"/* perform the lookup */",
"/* 8-bit case: RAM/ROM */"
] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "read0_or_write1",
"type": "int"
},
{
"param": "byteaddress",
"type": "offs_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "read0_or_write1",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "byteaddress",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | memory_enable_read_watchpoints | void | void memory_enable_read_watchpoints(const address_space *space, int enable)
{
address_space *spacerw = (address_space *)space;
if (enable)
spacerw->readlookup = space->machine->memory_data->wptable;
else
spacerw->readlookup = spacerw->read.table;
} | /*-------------------------------------------------
memory_enable_read_watchpoints - enable/disable
read watchpoint tracking for a given address
space
-------------------------------------------------*/ | enable/disable
read watchpoint tracking for a given address
space | [
"enable",
"/",
"disable",
"read",
"watchpoint",
"tracking",
"for",
"a",
"given",
"address",
"space"
] | void memory_enable_read_watchpoints(const address_space *space, int enable)
{
address_space *spacerw = (address_space *)space;
if (enable)
spacerw->readlookup = space->machine->memory_data->wptable;
else
spacerw->readlookup = spacerw->read.table;
} | [
"void",
"memory_enable_read_watchpoints",
"(",
"const",
"address_space",
"*",
"space",
",",
"int",
"enable",
")",
"{",
"address_space",
"*",
"spacerw",
"=",
"(",
"address_space",
"*",
")",
"space",
";",
"if",
"(",
"enable",
")",
"spacerw",
"->",
"readlookup",
"=",
"space",
"->",
"machine",
"->",
"memory_data",
"->",
"wptable",
";",
"else",
"spacerw",
"->",
"readlookup",
"=",
"spacerw",
"->",
"read",
".",
"table",
";",
"}"
] | memory_enable_read_watchpoints - enable/disable
read watchpoint tracking for a given address
space | [
"memory_enable_read_watchpoints",
"-",
"enable",
"/",
"disable",
"read",
"watchpoint",
"tracking",
"for",
"a",
"given",
"address",
"space"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "enable",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "enable",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | memory_enable_write_watchpoints | void | void memory_enable_write_watchpoints(const address_space *space, int enable)
{
address_space *spacerw = (address_space *)space;
if (enable)
spacerw->writelookup = space->machine->memory_data->wptable;
else
spacerw->writelookup = spacerw->write.table;
} | /*-------------------------------------------------
memory_enable_write_watchpoints - enable/disable
write watchpoint tracking for a given address
space
-------------------------------------------------*/ | enable/disable
write watchpoint tracking for a given address
space | [
"enable",
"/",
"disable",
"write",
"watchpoint",
"tracking",
"for",
"a",
"given",
"address",
"space"
] | void memory_enable_write_watchpoints(const address_space *space, int enable)
{
address_space *spacerw = (address_space *)space;
if (enable)
spacerw->writelookup = space->machine->memory_data->wptable;
else
spacerw->writelookup = spacerw->write.table;
} | [
"void",
"memory_enable_write_watchpoints",
"(",
"const",
"address_space",
"*",
"space",
",",
"int",
"enable",
")",
"{",
"address_space",
"*",
"spacerw",
"=",
"(",
"address_space",
"*",
")",
"space",
";",
"if",
"(",
"enable",
")",
"spacerw",
"->",
"writelookup",
"=",
"space",
"->",
"machine",
"->",
"memory_data",
"->",
"wptable",
";",
"else",
"spacerw",
"->",
"writelookup",
"=",
"spacerw",
"->",
"write",
".",
"table",
";",
"}"
] | memory_enable_write_watchpoints - enable/disable
write watchpoint tracking for a given address
space | [
"memory_enable_write_watchpoints",
"-",
"enable",
"/",
"disable",
"write",
"watchpoint",
"tracking",
"for",
"a",
"given",
"address",
"space"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "enable",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "enable",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | memory_set_debugger_access | void | void memory_set_debugger_access(const address_space *space, int debugger)
{
address_space *spacerw = (address_space *)space;
spacerw->debugger_access = debugger;
} | /*-------------------------------------------------
memory_set_debugger_access - control whether
subsequent accesses are treated as coming from
the debugger
-------------------------------------------------*/ | control whether
subsequent accesses are treated as coming from
the debugger | [
"control",
"whether",
"subsequent",
"accesses",
"are",
"treated",
"as",
"coming",
"from",
"the",
"debugger"
] | void memory_set_debugger_access(const address_space *space, int debugger)
{
address_space *spacerw = (address_space *)space;
spacerw->debugger_access = debugger;
} | [
"void",
"memory_set_debugger_access",
"(",
"const",
"address_space",
"*",
"space",
",",
"int",
"debugger",
")",
"{",
"address_space",
"*",
"spacerw",
"=",
"(",
"address_space",
"*",
")",
"space",
";",
"spacerw",
"->",
"debugger_access",
"=",
"debugger",
";",
"}"
] | memory_set_debugger_access - control whether
subsequent accesses are treated as coming from
the debugger | [
"memory_set_debugger_access",
"-",
"control",
"whether",
"subsequent",
"accesses",
"are",
"treated",
"as",
"coming",
"from",
"the",
"debugger"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "debugger",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "debugger",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | memory_set_log_unmap | void | void memory_set_log_unmap(const address_space *space, int log)
{
address_space *spacerw = (address_space *)space;
spacerw->log_unmap = log;
} | /*-------------------------------------------------
memory_set_log_unmap - sets whether unmapped
memory accesses should be logged or not
-------------------------------------------------*/ | sets whether unmapped
memory accesses should be logged or not | [
"sets",
"whether",
"unmapped",
"memory",
"accesses",
"should",
"be",
"logged",
"or",
"not"
] | void memory_set_log_unmap(const address_space *space, int log)
{
address_space *spacerw = (address_space *)space;
spacerw->log_unmap = log;
} | [
"void",
"memory_set_log_unmap",
"(",
"const",
"address_space",
"*",
"space",
",",
"int",
"log",
")",
"{",
"address_space",
"*",
"spacerw",
"=",
"(",
"address_space",
"*",
")",
"space",
";",
"spacerw",
"->",
"log_unmap",
"=",
"log",
";",
"}"
] | memory_set_log_unmap - sets whether unmapped
memory accesses should be logged or not | [
"memory_set_log_unmap",
"-",
"sets",
"whether",
"unmapped",
"memory",
"accesses",
"should",
"be",
"logged",
"or",
"not"
] | [] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "log",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "log",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | memory_dump | void | void memory_dump(running_machine *machine, FILE *file)
{
memory_private *memdata = machine->memory_data;
const address_space *space;
/* skip if we can't open the file */
if (!file)
return;
/* loop over valid address spaces */
for (space = memdata->spacelist; space != NULL; space = space->next)
{
fprintf(file, "\n\n"
"====================================================\n"
"Device '%s' %s address space read handler dump\n"
"====================================================\n", space->cpu->tag(), space->name);
dump_map(file, space, &space->read);
fprintf(file, "\n\n"
"====================================================\n"
"Device '%s' %s address space write handler dump\n"
"====================================================\n", space->cpu->tag(), space->name);
dump_map(file, space, &space->write);
}
} | /*-------------------------------------------------
memory_dump - dump the internal memory tables
to the given file
-------------------------------------------------*/ | dump the internal memory tables
to the given file | [
"dump",
"the",
"internal",
"memory",
"tables",
"to",
"the",
"given",
"file"
] | void memory_dump(running_machine *machine, FILE *file)
{
memory_private *memdata = machine->memory_data;
const address_space *space;
if (!file)
return;
for (space = memdata->spacelist; space != NULL; space = space->next)
{
fprintf(file, "\n\n"
"====================================================\n"
"Device '%s' %s address space read handler dump\n"
"====================================================\n", space->cpu->tag(), space->name);
dump_map(file, space, &space->read);
fprintf(file, "\n\n"
"====================================================\n"
"Device '%s' %s address space write handler dump\n"
"====================================================\n", space->cpu->tag(), space->name);
dump_map(file, space, &space->write);
}
} | [
"void",
"memory_dump",
"(",
"running_machine",
"*",
"machine",
",",
"FILE",
"*",
"file",
")",
"{",
"memory_private",
"*",
"memdata",
"=",
"machine",
"->",
"memory_data",
";",
"const",
"address_space",
"*",
"space",
";",
"if",
"(",
"!",
"file",
")",
"return",
";",
"for",
"(",
"space",
"=",
"memdata",
"->",
"spacelist",
";",
"space",
"!=",
"NULL",
";",
"space",
"=",
"space",
"->",
"next",
")",
"{",
"fprintf",
"(",
"file",
",",
"\"",
"\\n",
"\\n",
"\"",
"\"",
"\\n",
"\"",
"\"",
"\\n",
"\"",
"\"",
"\\n",
"\"",
",",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
",",
"space",
"->",
"name",
")",
";",
"dump_map",
"(",
"file",
",",
"space",
",",
"&",
"space",
"->",
"read",
")",
";",
"fprintf",
"(",
"file",
",",
"\"",
"\\n",
"\\n",
"\"",
"\"",
"\\n",
"\"",
"\"",
"\\n",
"\"",
"\"",
"\\n",
"\"",
",",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
",",
"space",
"->",
"name",
")",
";",
"dump_map",
"(",
"file",
",",
"space",
",",
"&",
"space",
"->",
"write",
")",
";",
"}",
"}"
] | memory_dump - dump the internal memory tables
to the given file | [
"memory_dump",
"-",
"dump",
"the",
"internal",
"memory",
"tables",
"to",
"the",
"given",
"file"
] | [
"/* skip if we can't open the file */",
"/* loop over valid address spaces */"
] | [
{
"param": "machine",
"type": "running_machine"
},
{
"param": "file",
"type": "FILE"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "machine",
"type": "running_machine",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type": "FILE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | memory_init_preflight | void | static void memory_init_preflight(running_machine *machine)
{
memory_private *memdata = machine->memory_data;
address_space *space;
/* reset the banking state */
memdata->banknext = STATIC_BANK1;
/* loop over valid address spaces */
for (space = (address_space *)memdata->spacelist; space != NULL; space = (address_space *)space->next)
{
const region_info *devregion = (space->spacenum == ADDRESS_SPACE_0) ? space->machine->region(space->cpu->tag()) : NULL;
int devregionsize = (devregion != NULL) ? devregion->bytes() : 0;
address_map_entry *entry;
int entrynum;
/* allocate the address map */
space->map = global_alloc(address_map(space->cpu->baseconfig(), space->spacenum));
/* extract global parameters specified by the map */
space->unmap = (space->map->m_unmapval == 0) ? 0 : ~0;
if (space->map->m_globalmask != 0)
{
space->addrmask = space->map->m_globalmask;
space->bytemask = memory_address_to_byte_end(space, space->addrmask);
}
/* make a pass over the address map, adjusting for the device and getting memory pointers */
for (entry = space->map->m_entrylist; entry != NULL; entry = entry->m_next)
{
/* if we have a share entry, add it to our map */
if (entry->m_share != NULL)
memdata->sharemap.add(entry->m_share, UNMAPPED_SHARE_PTR, FALSE);
/* computed adjusted addresses first */
entry->m_bytestart = entry->m_addrstart;
entry->m_byteend = entry->m_addrend;
entry->m_bytemirror = entry->m_addrmirror;
entry->m_bytemask = entry->m_addrmask;
adjust_addresses(space, &entry->m_bytestart, &entry->m_byteend, &entry->m_bytemask, &entry->m_bytemirror);
/* if this is a ROM handler without a specified region, attach it to the implicit region */
if (space->spacenum == ADDRESS_SPACE_0 && entry->m_read.type == AMH_ROM && entry->m_region == NULL)
{
/* make sure it fits within the memory region before doing so, however */
if (entry->m_byteend < devregionsize)
{
entry->m_region = space->cpu->tag();
entry->m_rgnoffs = entry->m_bytestart;
}
}
/* validate adjusted addresses against implicit regions */
if (entry->m_region != NULL && entry->m_share == NULL && entry->m_baseptr == NULL)
{
const region_info *region = machine->region(entry->m_region);
if (region == NULL)
fatalerror("Error: device '%s' %s space memory map entry %X-%X references non-existant region \"%s\"", space->cpu->tag(), space->name, entry->m_addrstart, entry->m_addrend, entry->m_region);
/* validate the region */
if (entry->m_rgnoffs + (entry->m_byteend - entry->m_bytestart + 1) > region->bytes())
fatalerror("Error: device '%s' %s space memory map entry %X-%X extends beyond region \"%s\" size (%X)", space->cpu->tag(), space->name, entry->m_addrstart, entry->m_addrend, entry->m_region, region->bytes());
}
/* convert any region-relative entries to their memory pointers */
if (entry->m_region != NULL)
entry->m_memory = machine->region(entry->m_region)->base() + entry->m_rgnoffs;
}
/* now loop over all the handlers and enforce the address mask */
/* we don't loop over map entries because the mask applies to static handlers as well */
for (entrynum = 0; entrynum < ENTRY_COUNT; entrynum++)
{
space->read.handlers[entrynum]->bytemask &= space->bytemask;
space->write.handlers[entrynum]->bytemask &= space->bytemask;
}
}
} | /*-------------------------------------------------
memory_init_preflight - verify the memory structs
and track which banks are referenced
-------------------------------------------------*/ | verify the memory structs
and track which banks are referenced | [
"verify",
"the",
"memory",
"structs",
"and",
"track",
"which",
"banks",
"are",
"referenced"
] | static void memory_init_preflight(running_machine *machine)
{
memory_private *memdata = machine->memory_data;
address_space *space;
memdata->banknext = STATIC_BANK1;
for (space = (address_space *)memdata->spacelist; space != NULL; space = (address_space *)space->next)
{
const region_info *devregion = (space->spacenum == ADDRESS_SPACE_0) ? space->machine->region(space->cpu->tag()) : NULL;
int devregionsize = (devregion != NULL) ? devregion->bytes() : 0;
address_map_entry *entry;
int entrynum;
space->map = global_alloc(address_map(space->cpu->baseconfig(), space->spacenum));
space->unmap = (space->map->m_unmapval == 0) ? 0 : ~0;
if (space->map->m_globalmask != 0)
{
space->addrmask = space->map->m_globalmask;
space->bytemask = memory_address_to_byte_end(space, space->addrmask);
}
for (entry = space->map->m_entrylist; entry != NULL; entry = entry->m_next)
{
if (entry->m_share != NULL)
memdata->sharemap.add(entry->m_share, UNMAPPED_SHARE_PTR, FALSE);
entry->m_bytestart = entry->m_addrstart;
entry->m_byteend = entry->m_addrend;
entry->m_bytemirror = entry->m_addrmirror;
entry->m_bytemask = entry->m_addrmask;
adjust_addresses(space, &entry->m_bytestart, &entry->m_byteend, &entry->m_bytemask, &entry->m_bytemirror);
if (space->spacenum == ADDRESS_SPACE_0 && entry->m_read.type == AMH_ROM && entry->m_region == NULL)
{
if (entry->m_byteend < devregionsize)
{
entry->m_region = space->cpu->tag();
entry->m_rgnoffs = entry->m_bytestart;
}
}
if (entry->m_region != NULL && entry->m_share == NULL && entry->m_baseptr == NULL)
{
const region_info *region = machine->region(entry->m_region);
if (region == NULL)
fatalerror("Error: device '%s' %s space memory map entry %X-%X references non-existant region \"%s\"", space->cpu->tag(), space->name, entry->m_addrstart, entry->m_addrend, entry->m_region);
if (entry->m_rgnoffs + (entry->m_byteend - entry->m_bytestart + 1) > region->bytes())
fatalerror("Error: device '%s' %s space memory map entry %X-%X extends beyond region \"%s\" size (%X)", space->cpu->tag(), space->name, entry->m_addrstart, entry->m_addrend, entry->m_region, region->bytes());
}
if (entry->m_region != NULL)
entry->m_memory = machine->region(entry->m_region)->base() + entry->m_rgnoffs;
}
for (entrynum = 0; entrynum < ENTRY_COUNT; entrynum++)
{
space->read.handlers[entrynum]->bytemask &= space->bytemask;
space->write.handlers[entrynum]->bytemask &= space->bytemask;
}
}
} | [
"static",
"void",
"memory_init_preflight",
"(",
"running_machine",
"*",
"machine",
")",
"{",
"memory_private",
"*",
"memdata",
"=",
"machine",
"->",
"memory_data",
";",
"address_space",
"*",
"space",
";",
"memdata",
"->",
"banknext",
"=",
"STATIC_BANK1",
";",
"for",
"(",
"space",
"=",
"(",
"address_space",
"*",
")",
"memdata",
"->",
"spacelist",
";",
"space",
"!=",
"NULL",
";",
"space",
"=",
"(",
"address_space",
"*",
")",
"space",
"->",
"next",
")",
"{",
"const",
"region_info",
"*",
"devregion",
"=",
"(",
"space",
"->",
"spacenum",
"==",
"ADDRESS_SPACE_0",
")",
"?",
"space",
"->",
"machine",
"->",
"region",
"(",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
")",
":",
"NULL",
";",
"int",
"devregionsize",
"=",
"(",
"devregion",
"!=",
"NULL",
")",
"?",
"devregion",
"->",
"bytes",
"(",
")",
":",
"0",
";",
"address_map_entry",
"*",
"entry",
";",
"int",
"entrynum",
";",
"space",
"->",
"map",
"=",
"global_alloc",
"(",
"address_map",
"(",
"space",
"->",
"cpu",
"->",
"baseconfig",
"(",
")",
",",
"space",
"->",
"spacenum",
")",
")",
";",
"space",
"->",
"unmap",
"=",
"(",
"space",
"->",
"map",
"->",
"m_unmapval",
"==",
"0",
")",
"?",
"0",
":",
"~",
"0",
";",
"if",
"(",
"space",
"->",
"map",
"->",
"m_globalmask",
"!=",
"0",
")",
"{",
"space",
"->",
"addrmask",
"=",
"space",
"->",
"map",
"->",
"m_globalmask",
";",
"space",
"->",
"bytemask",
"=",
"memory_address_to_byte_end",
"(",
"space",
",",
"space",
"->",
"addrmask",
")",
";",
"}",
"for",
"(",
"entry",
"=",
"space",
"->",
"map",
"->",
"m_entrylist",
";",
"entry",
"!=",
"NULL",
";",
"entry",
"=",
"entry",
"->",
"m_next",
")",
"{",
"if",
"(",
"entry",
"->",
"m_share",
"!=",
"NULL",
")",
"memdata",
"->",
"sharemap",
".",
"add",
"(",
"entry",
"->",
"m_share",
",",
"UNMAPPED_SHARE_PTR",
",",
"FALSE",
")",
";",
"entry",
"->",
"m_bytestart",
"=",
"entry",
"->",
"m_addrstart",
";",
"entry",
"->",
"m_byteend",
"=",
"entry",
"->",
"m_addrend",
";",
"entry",
"->",
"m_bytemirror",
"=",
"entry",
"->",
"m_addrmirror",
";",
"entry",
"->",
"m_bytemask",
"=",
"entry",
"->",
"m_addrmask",
";",
"adjust_addresses",
"(",
"space",
",",
"&",
"entry",
"->",
"m_bytestart",
",",
"&",
"entry",
"->",
"m_byteend",
",",
"&",
"entry",
"->",
"m_bytemask",
",",
"&",
"entry",
"->",
"m_bytemirror",
")",
";",
"if",
"(",
"space",
"->",
"spacenum",
"==",
"ADDRESS_SPACE_0",
"&&",
"entry",
"->",
"m_read",
".",
"type",
"==",
"AMH_ROM",
"&&",
"entry",
"->",
"m_region",
"==",
"NULL",
")",
"{",
"if",
"(",
"entry",
"->",
"m_byteend",
"<",
"devregionsize",
")",
"{",
"entry",
"->",
"m_region",
"=",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
";",
"entry",
"->",
"m_rgnoffs",
"=",
"entry",
"->",
"m_bytestart",
";",
"}",
"}",
"if",
"(",
"entry",
"->",
"m_region",
"!=",
"NULL",
"&&",
"entry",
"->",
"m_share",
"==",
"NULL",
"&&",
"entry",
"->",
"m_baseptr",
"==",
"NULL",
")",
"{",
"const",
"region_info",
"*",
"region",
"=",
"machine",
"->",
"region",
"(",
"entry",
"->",
"m_region",
")",
";",
"if",
"(",
"region",
"==",
"NULL",
")",
"fatalerror",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
",",
"space",
"->",
"name",
",",
"entry",
"->",
"m_addrstart",
",",
"entry",
"->",
"m_addrend",
",",
"entry",
"->",
"m_region",
")",
";",
"if",
"(",
"entry",
"->",
"m_rgnoffs",
"+",
"(",
"entry",
"->",
"m_byteend",
"-",
"entry",
"->",
"m_bytestart",
"+",
"1",
")",
">",
"region",
"->",
"bytes",
"(",
")",
")",
"fatalerror",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
",",
"space",
"->",
"name",
",",
"entry",
"->",
"m_addrstart",
",",
"entry",
"->",
"m_addrend",
",",
"entry",
"->",
"m_region",
",",
"region",
"->",
"bytes",
"(",
")",
")",
";",
"}",
"if",
"(",
"entry",
"->",
"m_region",
"!=",
"NULL",
")",
"entry",
"->",
"m_memory",
"=",
"machine",
"->",
"region",
"(",
"entry",
"->",
"m_region",
")",
"->",
"base",
"(",
")",
"+",
"entry",
"->",
"m_rgnoffs",
";",
"}",
"for",
"(",
"entrynum",
"=",
"0",
";",
"entrynum",
"<",
"ENTRY_COUNT",
";",
"entrynum",
"++",
")",
"{",
"space",
"->",
"read",
".",
"handlers",
"[",
"entrynum",
"]",
"->",
"bytemask",
"&=",
"space",
"->",
"bytemask",
";",
"space",
"->",
"write",
".",
"handlers",
"[",
"entrynum",
"]",
"->",
"bytemask",
"&=",
"space",
"->",
"bytemask",
";",
"}",
"}",
"}"
] | memory_init_preflight - verify the memory structs
and track which banks are referenced | [
"memory_init_preflight",
"-",
"verify",
"the",
"memory",
"structs",
"and",
"track",
"which",
"banks",
"are",
"referenced"
] | [
"/* reset the banking state */",
"/* loop over valid address spaces */",
"/* allocate the address map */",
"/* extract global parameters specified by the map */",
"/* make a pass over the address map, adjusting for the device and getting memory pointers */",
"/* if we have a share entry, add it to our map */",
"/* computed adjusted addresses first */",
"/* if this is a ROM handler without a specified region, attach it to the implicit region */",
"/* make sure it fits within the memory region before doing so, however */",
"/* validate adjusted addresses against implicit regions */",
"/* validate the region */",
"/* convert any region-relative entries to their memory pointers */",
"/* now loop over all the handlers and enforce the address mask */",
"/* we don't loop over map entries because the mask applies to static handlers as well */"
] | [
{
"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": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | memory_init_populate | void | static void memory_init_populate(running_machine *machine)
{
memory_private *memdata = machine->memory_data;
address_space *space;
/* loop over valid address spaces */
for (space = (address_space *)memdata->spacelist; space != NULL; space = (address_space *)space->next)
if (space->map != NULL)
{
const address_map_entry *last_entry = NULL;
/* install the handlers, using the original, unadjusted memory map */
while (last_entry != space->map->m_entrylist)
{
const address_map_entry *entry;
/* find the entry before the last one we processed */
for (entry = space->map->m_entrylist; entry->m_next != last_entry; entry = entry->m_next) ;
last_entry = entry;
/* map both read and write halves */
memory_init_map_entry(space, entry, ROW_READ);
memory_init_map_entry(space, entry, ROW_WRITE);
}
}
} | /*-------------------------------------------------
memory_init_populate - populate the memory
mapping tables with entries
-------------------------------------------------*/ | populate the memory
mapping tables with entries | [
"populate",
"the",
"memory",
"mapping",
"tables",
"with",
"entries"
] | static void memory_init_populate(running_machine *machine)
{
memory_private *memdata = machine->memory_data;
address_space *space;
for (space = (address_space *)memdata->spacelist; space != NULL; space = (address_space *)space->next)
if (space->map != NULL)
{
const address_map_entry *last_entry = NULL;
while (last_entry != space->map->m_entrylist)
{
const address_map_entry *entry;
for (entry = space->map->m_entrylist; entry->m_next != last_entry; entry = entry->m_next) ;
last_entry = entry;
memory_init_map_entry(space, entry, ROW_READ);
memory_init_map_entry(space, entry, ROW_WRITE);
}
}
} | [
"static",
"void",
"memory_init_populate",
"(",
"running_machine",
"*",
"machine",
")",
"{",
"memory_private",
"*",
"memdata",
"=",
"machine",
"->",
"memory_data",
";",
"address_space",
"*",
"space",
";",
"for",
"(",
"space",
"=",
"(",
"address_space",
"*",
")",
"memdata",
"->",
"spacelist",
";",
"space",
"!=",
"NULL",
";",
"space",
"=",
"(",
"address_space",
"*",
")",
"space",
"->",
"next",
")",
"if",
"(",
"space",
"->",
"map",
"!=",
"NULL",
")",
"{",
"const",
"address_map_entry",
"*",
"last_entry",
"=",
"NULL",
";",
"while",
"(",
"last_entry",
"!=",
"space",
"->",
"map",
"->",
"m_entrylist",
")",
"{",
"const",
"address_map_entry",
"*",
"entry",
";",
"for",
"(",
"entry",
"=",
"space",
"->",
"map",
"->",
"m_entrylist",
";",
"entry",
"->",
"m_next",
"!=",
"last_entry",
";",
"entry",
"=",
"entry",
"->",
"m_next",
")",
";",
"last_entry",
"=",
"entry",
";",
"memory_init_map_entry",
"(",
"space",
",",
"entry",
",",
"ROW_READ",
")",
";",
"memory_init_map_entry",
"(",
"space",
",",
"entry",
",",
"ROW_WRITE",
")",
";",
"}",
"}",
"}"
] | memory_init_populate - populate the memory
mapping tables with entries | [
"memory_init_populate",
"-",
"populate",
"the",
"memory",
"mapping",
"tables",
"with",
"entries"
] | [
"/* loop over valid address spaces */",
"/* install the handlers, using the original, unadjusted memory map */",
"/* find the entry before the last one we processed */",
"/* map both read and write halves */"
] | [
{
"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": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | memory_init_map_entry | void | static void memory_init_map_entry(address_space *space, const address_map_entry *entry, read_or_write readorwrite)
{
const map_handler_data *handler = (readorwrite == ROW_READ) ? &entry->m_read : &entry->m_write;
device_t *device;
/* based on the handler type, alter the bits, name, funcptr, and object */
switch (handler->type)
{
case AMH_NONE:
return;
case AMH_ROM:
if (readorwrite == ROW_WRITE)
return;
/* fall through to the RAM case otherwise */
case AMH_RAM:
_memory_install_ram(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
readorwrite == ROW_READ, readorwrite == ROW_WRITE, NULL);
break;
case AMH_NOP:
_memory_unmap(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
readorwrite == ROW_READ, readorwrite == ROW_WRITE, TRUE);
break;
case AMH_UNMAP:
_memory_unmap(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
readorwrite == ROW_READ, readorwrite == ROW_WRITE, FALSE);
break;
case AMH_HANDLER:
switch ((handler->bits != 0) ? handler->bits : space->dbits)
{
case 8:
_memory_install_handler8(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
(readorwrite == ROW_READ) ? handler->handler.read.shandler8 : NULL, handler->name,
(readorwrite == ROW_WRITE) ? handler->handler.write.shandler8 : NULL, handler->name,
handler->mask);
break;
case 16:
_memory_install_handler16(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
(readorwrite == ROW_READ) ? handler->handler.read.shandler16 : NULL, handler->name,
(readorwrite == ROW_WRITE) ? handler->handler.write.shandler16 : NULL, handler->name,
handler->mask);
break;
case 32:
_memory_install_handler32(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
(readorwrite == ROW_READ) ? handler->handler.read.shandler32 : NULL, handler->name,
(readorwrite == ROW_WRITE) ? handler->handler.write.shandler32 : NULL, handler->name,
handler->mask);
break;
case 64:
_memory_install_handler64(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
(readorwrite == ROW_READ) ? handler->handler.read.shandler64 : NULL, handler->name,
(readorwrite == ROW_WRITE) ? handler->handler.write.shandler64 : NULL, handler->name,
handler->mask);
break;
}
break;
case AMH_DEVICE_HANDLER:
device = space->machine->device(handler->tag);
if (device == NULL)
fatalerror("Attempted to map a non-existent device '%s' in space %s of device '%s'\n", handler->tag, space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
switch ((handler->bits != 0) ? handler->bits : space->dbits)
{
case 8:
_memory_install_device_handler8(space, device, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
(readorwrite == ROW_READ) ? handler->handler.read.dhandler8 : NULL, handler->name,
(readorwrite == ROW_WRITE) ? handler->handler.write.dhandler8 : NULL, handler->name,
handler->mask);
break;
case 16:
_memory_install_device_handler16(space, device, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
(readorwrite == ROW_READ) ? handler->handler.read.dhandler16 : NULL, handler->name,
(readorwrite == ROW_WRITE) ? handler->handler.write.dhandler16 : NULL, handler->name,
handler->mask);
break;
case 32:
_memory_install_device_handler32(space, device, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
(readorwrite == ROW_READ) ? handler->handler.read.dhandler32 : NULL, handler->name,
(readorwrite == ROW_WRITE) ? handler->handler.write.dhandler32 : NULL, handler->name,
handler->mask);
break;
case 64:
_memory_install_device_handler64(space, device, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
(readorwrite == ROW_READ) ? handler->handler.read.dhandler64 : NULL, handler->name,
(readorwrite == ROW_WRITE) ? handler->handler.write.dhandler64 : NULL, handler->name,
handler->mask);
break;
}
break;
case AMH_PORT:
_memory_install_port(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
(readorwrite == ROW_READ) ? handler->tag : NULL,
(readorwrite == ROW_WRITE) ? handler->tag : NULL);
break;
case AMH_BANK:
_memory_install_bank(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
(readorwrite == ROW_READ) ? handler->tag : NULL,
(readorwrite == ROW_WRITE) ? handler->tag : NULL);
break;
}
} | /*-------------------------------------------------
memory_init_map_entry - map a single read or
write entry based on information from an
address map entry
-------------------------------------------------*/ | map a single read or
write entry based on information from an
address map entry | [
"map",
"a",
"single",
"read",
"or",
"write",
"entry",
"based",
"on",
"information",
"from",
"an",
"address",
"map",
"entry"
] | static void memory_init_map_entry(address_space *space, const address_map_entry *entry, read_or_write readorwrite)
{
const map_handler_data *handler = (readorwrite == ROW_READ) ? &entry->m_read : &entry->m_write;
device_t *device;
switch (handler->type)
{
case AMH_NONE:
return;
case AMH_ROM:
if (readorwrite == ROW_WRITE)
return;
case AMH_RAM:
_memory_install_ram(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
readorwrite == ROW_READ, readorwrite == ROW_WRITE, NULL);
break;
case AMH_NOP:
_memory_unmap(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
readorwrite == ROW_READ, readorwrite == ROW_WRITE, TRUE);
break;
case AMH_UNMAP:
_memory_unmap(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
readorwrite == ROW_READ, readorwrite == ROW_WRITE, FALSE);
break;
case AMH_HANDLER:
switch ((handler->bits != 0) ? handler->bits : space->dbits)
{
case 8:
_memory_install_handler8(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
(readorwrite == ROW_READ) ? handler->handler.read.shandler8 : NULL, handler->name,
(readorwrite == ROW_WRITE) ? handler->handler.write.shandler8 : NULL, handler->name,
handler->mask);
break;
case 16:
_memory_install_handler16(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
(readorwrite == ROW_READ) ? handler->handler.read.shandler16 : NULL, handler->name,
(readorwrite == ROW_WRITE) ? handler->handler.write.shandler16 : NULL, handler->name,
handler->mask);
break;
case 32:
_memory_install_handler32(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
(readorwrite == ROW_READ) ? handler->handler.read.shandler32 : NULL, handler->name,
(readorwrite == ROW_WRITE) ? handler->handler.write.shandler32 : NULL, handler->name,
handler->mask);
break;
case 64:
_memory_install_handler64(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
(readorwrite == ROW_READ) ? handler->handler.read.shandler64 : NULL, handler->name,
(readorwrite == ROW_WRITE) ? handler->handler.write.shandler64 : NULL, handler->name,
handler->mask);
break;
}
break;
case AMH_DEVICE_HANDLER:
device = space->machine->device(handler->tag);
if (device == NULL)
fatalerror("Attempted to map a non-existent device '%s' in space %s of device '%s'\n", handler->tag, space->name, (space->cpu != NULL) ? space->cpu->tag() : "??");
switch ((handler->bits != 0) ? handler->bits : space->dbits)
{
case 8:
_memory_install_device_handler8(space, device, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
(readorwrite == ROW_READ) ? handler->handler.read.dhandler8 : NULL, handler->name,
(readorwrite == ROW_WRITE) ? handler->handler.write.dhandler8 : NULL, handler->name,
handler->mask);
break;
case 16:
_memory_install_device_handler16(space, device, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
(readorwrite == ROW_READ) ? handler->handler.read.dhandler16 : NULL, handler->name,
(readorwrite == ROW_WRITE) ? handler->handler.write.dhandler16 : NULL, handler->name,
handler->mask);
break;
case 32:
_memory_install_device_handler32(space, device, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
(readorwrite == ROW_READ) ? handler->handler.read.dhandler32 : NULL, handler->name,
(readorwrite == ROW_WRITE) ? handler->handler.write.dhandler32 : NULL, handler->name,
handler->mask);
break;
case 64:
_memory_install_device_handler64(space, device, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
(readorwrite == ROW_READ) ? handler->handler.read.dhandler64 : NULL, handler->name,
(readorwrite == ROW_WRITE) ? handler->handler.write.dhandler64 : NULL, handler->name,
handler->mask);
break;
}
break;
case AMH_PORT:
_memory_install_port(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
(readorwrite == ROW_READ) ? handler->tag : NULL,
(readorwrite == ROW_WRITE) ? handler->tag : NULL);
break;
case AMH_BANK:
_memory_install_bank(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror,
(readorwrite == ROW_READ) ? handler->tag : NULL,
(readorwrite == ROW_WRITE) ? handler->tag : NULL);
break;
}
} | [
"static",
"void",
"memory_init_map_entry",
"(",
"address_space",
"*",
"space",
",",
"const",
"address_map_entry",
"*",
"entry",
",",
"read_or_write",
"readorwrite",
")",
"{",
"const",
"map_handler_data",
"*",
"handler",
"=",
"(",
"readorwrite",
"==",
"ROW_READ",
")",
"?",
"&",
"entry",
"->",
"m_read",
":",
"&",
"entry",
"->",
"m_write",
";",
"device_t",
"*",
"device",
";",
"switch",
"(",
"handler",
"->",
"type",
")",
"{",
"case",
"AMH_NONE",
":",
"return",
";",
"case",
"AMH_ROM",
":",
"if",
"(",
"readorwrite",
"==",
"ROW_WRITE",
")",
"return",
";",
"case",
"AMH_RAM",
":",
"_memory_install_ram",
"(",
"space",
",",
"entry",
"->",
"m_addrstart",
",",
"entry",
"->",
"m_addrend",
",",
"entry",
"->",
"m_addrmask",
",",
"entry",
"->",
"m_addrmirror",
",",
"readorwrite",
"==",
"ROW_READ",
",",
"readorwrite",
"==",
"ROW_WRITE",
",",
"NULL",
")",
";",
"break",
";",
"case",
"AMH_NOP",
":",
"_memory_unmap",
"(",
"space",
",",
"entry",
"->",
"m_addrstart",
",",
"entry",
"->",
"m_addrend",
",",
"entry",
"->",
"m_addrmask",
",",
"entry",
"->",
"m_addrmirror",
",",
"readorwrite",
"==",
"ROW_READ",
",",
"readorwrite",
"==",
"ROW_WRITE",
",",
"TRUE",
")",
";",
"break",
";",
"case",
"AMH_UNMAP",
":",
"_memory_unmap",
"(",
"space",
",",
"entry",
"->",
"m_addrstart",
",",
"entry",
"->",
"m_addrend",
",",
"entry",
"->",
"m_addrmask",
",",
"entry",
"->",
"m_addrmirror",
",",
"readorwrite",
"==",
"ROW_READ",
",",
"readorwrite",
"==",
"ROW_WRITE",
",",
"FALSE",
")",
";",
"break",
";",
"case",
"AMH_HANDLER",
":",
"switch",
"(",
"(",
"handler",
"->",
"bits",
"!=",
"0",
")",
"?",
"handler",
"->",
"bits",
":",
"space",
"->",
"dbits",
")",
"{",
"case",
"8",
":",
"_memory_install_handler8",
"(",
"space",
",",
"entry",
"->",
"m_addrstart",
",",
"entry",
"->",
"m_addrend",
",",
"entry",
"->",
"m_addrmask",
",",
"entry",
"->",
"m_addrmirror",
",",
"(",
"readorwrite",
"==",
"ROW_READ",
")",
"?",
"handler",
"->",
"handler",
".",
"read",
".",
"shandler8",
":",
"NULL",
",",
"handler",
"->",
"name",
",",
"(",
"readorwrite",
"==",
"ROW_WRITE",
")",
"?",
"handler",
"->",
"handler",
".",
"write",
".",
"shandler8",
":",
"NULL",
",",
"handler",
"->",
"name",
",",
"handler",
"->",
"mask",
")",
";",
"break",
";",
"case",
"16",
":",
"_memory_install_handler16",
"(",
"space",
",",
"entry",
"->",
"m_addrstart",
",",
"entry",
"->",
"m_addrend",
",",
"entry",
"->",
"m_addrmask",
",",
"entry",
"->",
"m_addrmirror",
",",
"(",
"readorwrite",
"==",
"ROW_READ",
")",
"?",
"handler",
"->",
"handler",
".",
"read",
".",
"shandler16",
":",
"NULL",
",",
"handler",
"->",
"name",
",",
"(",
"readorwrite",
"==",
"ROW_WRITE",
")",
"?",
"handler",
"->",
"handler",
".",
"write",
".",
"shandler16",
":",
"NULL",
",",
"handler",
"->",
"name",
",",
"handler",
"->",
"mask",
")",
";",
"break",
";",
"case",
"32",
":",
"_memory_install_handler32",
"(",
"space",
",",
"entry",
"->",
"m_addrstart",
",",
"entry",
"->",
"m_addrend",
",",
"entry",
"->",
"m_addrmask",
",",
"entry",
"->",
"m_addrmirror",
",",
"(",
"readorwrite",
"==",
"ROW_READ",
")",
"?",
"handler",
"->",
"handler",
".",
"read",
".",
"shandler32",
":",
"NULL",
",",
"handler",
"->",
"name",
",",
"(",
"readorwrite",
"==",
"ROW_WRITE",
")",
"?",
"handler",
"->",
"handler",
".",
"write",
".",
"shandler32",
":",
"NULL",
",",
"handler",
"->",
"name",
",",
"handler",
"->",
"mask",
")",
";",
"break",
";",
"case",
"64",
":",
"_memory_install_handler64",
"(",
"space",
",",
"entry",
"->",
"m_addrstart",
",",
"entry",
"->",
"m_addrend",
",",
"entry",
"->",
"m_addrmask",
",",
"entry",
"->",
"m_addrmirror",
",",
"(",
"readorwrite",
"==",
"ROW_READ",
")",
"?",
"handler",
"->",
"handler",
".",
"read",
".",
"shandler64",
":",
"NULL",
",",
"handler",
"->",
"name",
",",
"(",
"readorwrite",
"==",
"ROW_WRITE",
")",
"?",
"handler",
"->",
"handler",
".",
"write",
".",
"shandler64",
":",
"NULL",
",",
"handler",
"->",
"name",
",",
"handler",
"->",
"mask",
")",
";",
"break",
";",
"}",
"break",
";",
"case",
"AMH_DEVICE_HANDLER",
":",
"device",
"=",
"space",
"->",
"machine",
"->",
"device",
"(",
"handler",
"->",
"tag",
")",
";",
"if",
"(",
"device",
"==",
"NULL",
")",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"handler",
"->",
"tag",
",",
"space",
"->",
"name",
",",
"(",
"space",
"->",
"cpu",
"!=",
"NULL",
")",
"?",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
":",
"\"",
"\"",
")",
";",
"switch",
"(",
"(",
"handler",
"->",
"bits",
"!=",
"0",
")",
"?",
"handler",
"->",
"bits",
":",
"space",
"->",
"dbits",
")",
"{",
"case",
"8",
":",
"_memory_install_device_handler8",
"(",
"space",
",",
"device",
",",
"entry",
"->",
"m_addrstart",
",",
"entry",
"->",
"m_addrend",
",",
"entry",
"->",
"m_addrmask",
",",
"entry",
"->",
"m_addrmirror",
",",
"(",
"readorwrite",
"==",
"ROW_READ",
")",
"?",
"handler",
"->",
"handler",
".",
"read",
".",
"dhandler8",
":",
"NULL",
",",
"handler",
"->",
"name",
",",
"(",
"readorwrite",
"==",
"ROW_WRITE",
")",
"?",
"handler",
"->",
"handler",
".",
"write",
".",
"dhandler8",
":",
"NULL",
",",
"handler",
"->",
"name",
",",
"handler",
"->",
"mask",
")",
";",
"break",
";",
"case",
"16",
":",
"_memory_install_device_handler16",
"(",
"space",
",",
"device",
",",
"entry",
"->",
"m_addrstart",
",",
"entry",
"->",
"m_addrend",
",",
"entry",
"->",
"m_addrmask",
",",
"entry",
"->",
"m_addrmirror",
",",
"(",
"readorwrite",
"==",
"ROW_READ",
")",
"?",
"handler",
"->",
"handler",
".",
"read",
".",
"dhandler16",
":",
"NULL",
",",
"handler",
"->",
"name",
",",
"(",
"readorwrite",
"==",
"ROW_WRITE",
")",
"?",
"handler",
"->",
"handler",
".",
"write",
".",
"dhandler16",
":",
"NULL",
",",
"handler",
"->",
"name",
",",
"handler",
"->",
"mask",
")",
";",
"break",
";",
"case",
"32",
":",
"_memory_install_device_handler32",
"(",
"space",
",",
"device",
",",
"entry",
"->",
"m_addrstart",
",",
"entry",
"->",
"m_addrend",
",",
"entry",
"->",
"m_addrmask",
",",
"entry",
"->",
"m_addrmirror",
",",
"(",
"readorwrite",
"==",
"ROW_READ",
")",
"?",
"handler",
"->",
"handler",
".",
"read",
".",
"dhandler32",
":",
"NULL",
",",
"handler",
"->",
"name",
",",
"(",
"readorwrite",
"==",
"ROW_WRITE",
")",
"?",
"handler",
"->",
"handler",
".",
"write",
".",
"dhandler32",
":",
"NULL",
",",
"handler",
"->",
"name",
",",
"handler",
"->",
"mask",
")",
";",
"break",
";",
"case",
"64",
":",
"_memory_install_device_handler64",
"(",
"space",
",",
"device",
",",
"entry",
"->",
"m_addrstart",
",",
"entry",
"->",
"m_addrend",
",",
"entry",
"->",
"m_addrmask",
",",
"entry",
"->",
"m_addrmirror",
",",
"(",
"readorwrite",
"==",
"ROW_READ",
")",
"?",
"handler",
"->",
"handler",
".",
"read",
".",
"dhandler64",
":",
"NULL",
",",
"handler",
"->",
"name",
",",
"(",
"readorwrite",
"==",
"ROW_WRITE",
")",
"?",
"handler",
"->",
"handler",
".",
"write",
".",
"dhandler64",
":",
"NULL",
",",
"handler",
"->",
"name",
",",
"handler",
"->",
"mask",
")",
";",
"break",
";",
"}",
"break",
";",
"case",
"AMH_PORT",
":",
"_memory_install_port",
"(",
"space",
",",
"entry",
"->",
"m_addrstart",
",",
"entry",
"->",
"m_addrend",
",",
"entry",
"->",
"m_addrmask",
",",
"entry",
"->",
"m_addrmirror",
",",
"(",
"readorwrite",
"==",
"ROW_READ",
")",
"?",
"handler",
"->",
"tag",
":",
"NULL",
",",
"(",
"readorwrite",
"==",
"ROW_WRITE",
")",
"?",
"handler",
"->",
"tag",
":",
"NULL",
")",
";",
"break",
";",
"case",
"AMH_BANK",
":",
"_memory_install_bank",
"(",
"space",
",",
"entry",
"->",
"m_addrstart",
",",
"entry",
"->",
"m_addrend",
",",
"entry",
"->",
"m_addrmask",
",",
"entry",
"->",
"m_addrmirror",
",",
"(",
"readorwrite",
"==",
"ROW_READ",
")",
"?",
"handler",
"->",
"tag",
":",
"NULL",
",",
"(",
"readorwrite",
"==",
"ROW_WRITE",
")",
"?",
"handler",
"->",
"tag",
":",
"NULL",
")",
";",
"break",
";",
"}",
"}"
] | memory_init_map_entry - map a single read or
write entry based on information from an
address map entry | [
"memory_init_map_entry",
"-",
"map",
"a",
"single",
"read",
"or",
"write",
"entry",
"based",
"on",
"information",
"from",
"an",
"address",
"map",
"entry"
] | [
"/* based on the handler type, alter the bits, name, funcptr, and object */",
"/* fall through to the RAM case otherwise */"
] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "entry",
"type": "address_map_entry"
},
{
"param": "readorwrite",
"type": "read_or_write"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "entry",
"type": "address_map_entry",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "readorwrite",
"type": "read_or_write",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | memory_init_allocate | void | static void memory_init_allocate(running_machine *machine)
{
memory_private *memdata = machine->memory_data;
address_space *space;
/* loop over valid address spaces */
for (space = (address_space *)memdata->spacelist; space != NULL; space = (address_space *)space->next)
{
address_map_entry *unassigned = NULL;
address_map_entry *entry;
memory_block *prev_memblock_head = memdata->memory_block_list;
memory_block *memblock;
/* make a first pass over the memory map and track blocks with hardcoded pointers */
/* we do this to make sure they are found by space_find_backing_memory first */
for (entry = space->map->m_entrylist; entry != NULL; entry = entry->m_next)
if (entry->m_memory != NULL)
block_allocate(space, entry->m_bytestart, entry->m_byteend, entry->m_memory);
/* loop over all blocks just allocated and assign pointers from them */
for (memblock = memdata->memory_block_list; memblock != prev_memblock_head; memblock = memblock->next)
unassigned = block_assign_intersecting(space, memblock->bytestart, memblock->byteend, memblock->data);
/* if we don't have an unassigned pointer yet, try to find one */
if (unassigned == NULL)
unassigned = block_assign_intersecting(space, ~0, 0, NULL);
/* loop until we've assigned all memory in this space */
while (unassigned != NULL)
{
offs_t curbytestart, curbyteend;
int changed;
void *block;
/* work in MEMORY_BLOCK_CHUNK-sized chunks */
offs_t curblockstart = unassigned->m_bytestart / MEMORY_BLOCK_CHUNK;
offs_t curblockend = unassigned->m_byteend / MEMORY_BLOCK_CHUNK;
/* loop while we keep finding unassigned blocks in neighboring MEMORY_BLOCK_CHUNK chunks */
do
{
changed = FALSE;
/* scan for unmapped blocks in the adjusted map */
for (entry = space->map->m_entrylist; entry != NULL; entry = entry->m_next)
if (entry->m_memory == NULL && entry != unassigned && space_needs_backing_store(space, entry))
{
offs_t blockstart, blockend;
/* get block start/end blocks for this block */
blockstart = entry->m_bytestart / MEMORY_BLOCK_CHUNK;
blockend = entry->m_byteend / MEMORY_BLOCK_CHUNK;
/* if we intersect or are adjacent, adjust the start/end */
if (blockstart <= curblockend + 1 && blockend >= curblockstart - 1)
{
if (blockstart < curblockstart)
curblockstart = blockstart, changed = TRUE;
if (blockend > curblockend)
curblockend = blockend, changed = TRUE;
}
}
} while (changed);
/* we now have a block to allocate; do it */
curbytestart = curblockstart * MEMORY_BLOCK_CHUNK;
curbyteend = curblockend * MEMORY_BLOCK_CHUNK + (MEMORY_BLOCK_CHUNK - 1);
block = block_allocate(space, curbytestart, curbyteend, NULL);
/* assign memory that intersected the new block */
unassigned = block_assign_intersecting(space, curbytestart, curbyteend, (UINT8 *)block);
}
}
} | /*-------------------------------------------------
memory_init_allocate - allocate memory for
device address spaces
-------------------------------------------------*/ | allocate memory for
device address spaces | [
"allocate",
"memory",
"for",
"device",
"address",
"spaces"
] | static void memory_init_allocate(running_machine *machine)
{
memory_private *memdata = machine->memory_data;
address_space *space;
for (space = (address_space *)memdata->spacelist; space != NULL; space = (address_space *)space->next)
{
address_map_entry *unassigned = NULL;
address_map_entry *entry;
memory_block *prev_memblock_head = memdata->memory_block_list;
memory_block *memblock;
for (entry = space->map->m_entrylist; entry != NULL; entry = entry->m_next)
if (entry->m_memory != NULL)
block_allocate(space, entry->m_bytestart, entry->m_byteend, entry->m_memory);
for (memblock = memdata->memory_block_list; memblock != prev_memblock_head; memblock = memblock->next)
unassigned = block_assign_intersecting(space, memblock->bytestart, memblock->byteend, memblock->data);
if (unassigned == NULL)
unassigned = block_assign_intersecting(space, ~0, 0, NULL);
while (unassigned != NULL)
{
offs_t curbytestart, curbyteend;
int changed;
void *block;
offs_t curblockstart = unassigned->m_bytestart / MEMORY_BLOCK_CHUNK;
offs_t curblockend = unassigned->m_byteend / MEMORY_BLOCK_CHUNK;
do
{
changed = FALSE;
for (entry = space->map->m_entrylist; entry != NULL; entry = entry->m_next)
if (entry->m_memory == NULL && entry != unassigned && space_needs_backing_store(space, entry))
{
offs_t blockstart, blockend;
blockstart = entry->m_bytestart / MEMORY_BLOCK_CHUNK;
blockend = entry->m_byteend / MEMORY_BLOCK_CHUNK;
if (blockstart <= curblockend + 1 && blockend >= curblockstart - 1)
{
if (blockstart < curblockstart)
curblockstart = blockstart, changed = TRUE;
if (blockend > curblockend)
curblockend = blockend, changed = TRUE;
}
}
} while (changed);
curbytestart = curblockstart * MEMORY_BLOCK_CHUNK;
curbyteend = curblockend * MEMORY_BLOCK_CHUNK + (MEMORY_BLOCK_CHUNK - 1);
block = block_allocate(space, curbytestart, curbyteend, NULL);
unassigned = block_assign_intersecting(space, curbytestart, curbyteend, (UINT8 *)block);
}
}
} | [
"static",
"void",
"memory_init_allocate",
"(",
"running_machine",
"*",
"machine",
")",
"{",
"memory_private",
"*",
"memdata",
"=",
"machine",
"->",
"memory_data",
";",
"address_space",
"*",
"space",
";",
"for",
"(",
"space",
"=",
"(",
"address_space",
"*",
")",
"memdata",
"->",
"spacelist",
";",
"space",
"!=",
"NULL",
";",
"space",
"=",
"(",
"address_space",
"*",
")",
"space",
"->",
"next",
")",
"{",
"address_map_entry",
"*",
"unassigned",
"=",
"NULL",
";",
"address_map_entry",
"*",
"entry",
";",
"memory_block",
"*",
"prev_memblock_head",
"=",
"memdata",
"->",
"memory_block_list",
";",
"memory_block",
"*",
"memblock",
";",
"for",
"(",
"entry",
"=",
"space",
"->",
"map",
"->",
"m_entrylist",
";",
"entry",
"!=",
"NULL",
";",
"entry",
"=",
"entry",
"->",
"m_next",
")",
"if",
"(",
"entry",
"->",
"m_memory",
"!=",
"NULL",
")",
"block_allocate",
"(",
"space",
",",
"entry",
"->",
"m_bytestart",
",",
"entry",
"->",
"m_byteend",
",",
"entry",
"->",
"m_memory",
")",
";",
"for",
"(",
"memblock",
"=",
"memdata",
"->",
"memory_block_list",
";",
"memblock",
"!=",
"prev_memblock_head",
";",
"memblock",
"=",
"memblock",
"->",
"next",
")",
"unassigned",
"=",
"block_assign_intersecting",
"(",
"space",
",",
"memblock",
"->",
"bytestart",
",",
"memblock",
"->",
"byteend",
",",
"memblock",
"->",
"data",
")",
";",
"if",
"(",
"unassigned",
"==",
"NULL",
")",
"unassigned",
"=",
"block_assign_intersecting",
"(",
"space",
",",
"~",
"0",
",",
"0",
",",
"NULL",
")",
";",
"while",
"(",
"unassigned",
"!=",
"NULL",
")",
"{",
"offs_t",
"curbytestart",
",",
"curbyteend",
";",
"int",
"changed",
";",
"void",
"*",
"block",
";",
"offs_t",
"curblockstart",
"=",
"unassigned",
"->",
"m_bytestart",
"/",
"MEMORY_BLOCK_CHUNK",
";",
"offs_t",
"curblockend",
"=",
"unassigned",
"->",
"m_byteend",
"/",
"MEMORY_BLOCK_CHUNK",
";",
"do",
"{",
"changed",
"=",
"FALSE",
";",
"for",
"(",
"entry",
"=",
"space",
"->",
"map",
"->",
"m_entrylist",
";",
"entry",
"!=",
"NULL",
";",
"entry",
"=",
"entry",
"->",
"m_next",
")",
"if",
"(",
"entry",
"->",
"m_memory",
"==",
"NULL",
"&&",
"entry",
"!=",
"unassigned",
"&&",
"space_needs_backing_store",
"(",
"space",
",",
"entry",
")",
")",
"{",
"offs_t",
"blockstart",
",",
"blockend",
";",
"blockstart",
"=",
"entry",
"->",
"m_bytestart",
"/",
"MEMORY_BLOCK_CHUNK",
";",
"blockend",
"=",
"entry",
"->",
"m_byteend",
"/",
"MEMORY_BLOCK_CHUNK",
";",
"if",
"(",
"blockstart",
"<=",
"curblockend",
"+",
"1",
"&&",
"blockend",
">=",
"curblockstart",
"-",
"1",
")",
"{",
"if",
"(",
"blockstart",
"<",
"curblockstart",
")",
"curblockstart",
"=",
"blockstart",
",",
"changed",
"=",
"TRUE",
";",
"if",
"(",
"blockend",
">",
"curblockend",
")",
"curblockend",
"=",
"blockend",
",",
"changed",
"=",
"TRUE",
";",
"}",
"}",
"}",
"while",
"(",
"changed",
")",
";",
"curbytestart",
"=",
"curblockstart",
"*",
"MEMORY_BLOCK_CHUNK",
";",
"curbyteend",
"=",
"curblockend",
"*",
"MEMORY_BLOCK_CHUNK",
"+",
"(",
"MEMORY_BLOCK_CHUNK",
"-",
"1",
")",
";",
"block",
"=",
"block_allocate",
"(",
"space",
",",
"curbytestart",
",",
"curbyteend",
",",
"NULL",
")",
";",
"unassigned",
"=",
"block_assign_intersecting",
"(",
"space",
",",
"curbytestart",
",",
"curbyteend",
",",
"(",
"UINT8",
"*",
")",
"block",
")",
";",
"}",
"}",
"}"
] | memory_init_allocate - allocate memory for
device address spaces | [
"memory_init_allocate",
"-",
"allocate",
"memory",
"for",
"device",
"address",
"spaces"
] | [
"/* loop over valid address spaces */",
"/* make a first pass over the memory map and track blocks with hardcoded pointers */",
"/* we do this to make sure they are found by space_find_backing_memory first */",
"/* loop over all blocks just allocated and assign pointers from them */",
"/* if we don't have an unassigned pointer yet, try to find one */",
"/* loop until we've assigned all memory in this space */",
"/* work in MEMORY_BLOCK_CHUNK-sized chunks */",
"/* loop while we keep finding unassigned blocks in neighboring MEMORY_BLOCK_CHUNK chunks */",
"/* scan for unmapped blocks in the adjusted map */",
"/* get block start/end blocks for this block */",
"/* if we intersect or are adjacent, adjust the start/end */",
"/* we now have a block to allocate; do it */",
"/* assign memory that intersected the new block */"
] | [
{
"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": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | space_map_range | void | static void space_map_range(address_space *space, read_or_write readorwrite, int handlerbits, int handlerunitmask, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, genf *handler, void *object, const char *handler_name)
{
address_table *tabledata = (readorwrite == ROW_WRITE) ? &space->write : &space->read;
int reset_write = (space->writelookup == space->write.table);
int reset_read = (space->readlookup == space->read.table);
offs_t bytestart, byteend, bytemask, bytemirror;
UINT8 entry;
/* sanity checks */
assert(space != NULL);
assert(handlerbits == 8 || handlerbits == 16 || handlerbits == 32 || handlerbits == 64);
/* adjust the incoming addresses */
bytestart = addrstart;
byteend = addrend;
bytemirror = addrmirror;
bytemask = addrmask;
adjust_addresses(space, &bytestart, &byteend, &bytemask, &bytemirror);
/* validity checks */
assert_always(!HANDLER_IS_ROM(handler), "space_map_range called with ROM after initialization");
assert_always(!HANDLER_IS_RAM(handler), "space_map_range called with RAM after initialization");
assert_always(addrstart <= addrend, "space_map_range called with start greater than end");
assert_always(handlerbits <= space->dbits, "space_map_range called with handlers larger than the address space");
assert_always((bytestart & (space->dbits / 8 - 1)) == 0, "space_map_range called with misaligned start address");
assert_always((byteend & (space->dbits / 8 - 1)) == (space->dbits / 8 - 1), "space_map_range called with misaligned end address");
/* get the final handler index */
entry = table_assign_handler(space, tabledata->handlers, object, handler, handler_name, bytestart, byteend, bytemask);
/* fix up the handler if a stub is required */
if (handlerbits != space->dbits)
table_compute_subhandler(tabledata->handlers, entry, readorwrite, space->dbits, space->endianness, handlerbits, handlerunitmask);
/* populate it */
table_populate_range_mirrored(space, tabledata, bytestart, byteend, bytemirror, entry);
/* reset read/write pointers if necessary (could have moved due to realloc) */
if (reset_write)
space->writelookup = space->write.table;
if (reset_read)
space->readlookup = space->read.table;
/* recompute any direct access on this space if it is a read modification */
if (readorwrite == ROW_READ && entry == space->direct.entry)
{
space->direct.entry = STATIC_UNMAP;
space->direct.bytestart = 1;
space->direct.byteend = 0;
}
} | /*-------------------------------------------------
space_map_range - maps a range of addresses
to the specified handler within an address
space
-------------------------------------------------*/ | maps a range of addresses
to the specified handler within an address
space | [
"maps",
"a",
"range",
"of",
"addresses",
"to",
"the",
"specified",
"handler",
"within",
"an",
"address",
"space"
] | static void space_map_range(address_space *space, read_or_write readorwrite, int handlerbits, int handlerunitmask, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, genf *handler, void *object, const char *handler_name)
{
address_table *tabledata = (readorwrite == ROW_WRITE) ? &space->write : &space->read;
int reset_write = (space->writelookup == space->write.table);
int reset_read = (space->readlookup == space->read.table);
offs_t bytestart, byteend, bytemask, bytemirror;
UINT8 entry;
assert(space != NULL);
assert(handlerbits == 8 || handlerbits == 16 || handlerbits == 32 || handlerbits == 64);
bytestart = addrstart;
byteend = addrend;
bytemirror = addrmirror;
bytemask = addrmask;
adjust_addresses(space, &bytestart, &byteend, &bytemask, &bytemirror);
assert_always(!HANDLER_IS_ROM(handler), "space_map_range called with ROM after initialization");
assert_always(!HANDLER_IS_RAM(handler), "space_map_range called with RAM after initialization");
assert_always(addrstart <= addrend, "space_map_range called with start greater than end");
assert_always(handlerbits <= space->dbits, "space_map_range called with handlers larger than the address space");
assert_always((bytestart & (space->dbits / 8 - 1)) == 0, "space_map_range called with misaligned start address");
assert_always((byteend & (space->dbits / 8 - 1)) == (space->dbits / 8 - 1), "space_map_range called with misaligned end address");
entry = table_assign_handler(space, tabledata->handlers, object, handler, handler_name, bytestart, byteend, bytemask);
if (handlerbits != space->dbits)
table_compute_subhandler(tabledata->handlers, entry, readorwrite, space->dbits, space->endianness, handlerbits, handlerunitmask);
table_populate_range_mirrored(space, tabledata, bytestart, byteend, bytemirror, entry);
if (reset_write)
space->writelookup = space->write.table;
if (reset_read)
space->readlookup = space->read.table;
if (readorwrite == ROW_READ && entry == space->direct.entry)
{
space->direct.entry = STATIC_UNMAP;
space->direct.bytestart = 1;
space->direct.byteend = 0;
}
} | [
"static",
"void",
"space_map_range",
"(",
"address_space",
"*",
"space",
",",
"read_or_write",
"readorwrite",
",",
"int",
"handlerbits",
",",
"int",
"handlerunitmask",
",",
"offs_t",
"addrstart",
",",
"offs_t",
"addrend",
",",
"offs_t",
"addrmask",
",",
"offs_t",
"addrmirror",
",",
"genf",
"*",
"handler",
",",
"void",
"*",
"object",
",",
"const",
"char",
"*",
"handler_name",
")",
"{",
"address_table",
"*",
"tabledata",
"=",
"(",
"readorwrite",
"==",
"ROW_WRITE",
")",
"?",
"&",
"space",
"->",
"write",
":",
"&",
"space",
"->",
"read",
";",
"int",
"reset_write",
"=",
"(",
"space",
"->",
"writelookup",
"==",
"space",
"->",
"write",
".",
"table",
")",
";",
"int",
"reset_read",
"=",
"(",
"space",
"->",
"readlookup",
"==",
"space",
"->",
"read",
".",
"table",
")",
";",
"offs_t",
"bytestart",
",",
"byteend",
",",
"bytemask",
",",
"bytemirror",
";",
"UINT8",
"entry",
";",
"assert",
"(",
"space",
"!=",
"NULL",
")",
";",
"assert",
"(",
"handlerbits",
"==",
"8",
"||",
"handlerbits",
"==",
"16",
"||",
"handlerbits",
"==",
"32",
"||",
"handlerbits",
"==",
"64",
")",
";",
"bytestart",
"=",
"addrstart",
";",
"byteend",
"=",
"addrend",
";",
"bytemirror",
"=",
"addrmirror",
";",
"bytemask",
"=",
"addrmask",
";",
"adjust_addresses",
"(",
"space",
",",
"&",
"bytestart",
",",
"&",
"byteend",
",",
"&",
"bytemask",
",",
"&",
"bytemirror",
")",
";",
"assert_always",
"(",
"!",
"HANDLER_IS_ROM",
"(",
"handler",
")",
",",
"\"",
"\"",
")",
";",
"assert_always",
"(",
"!",
"HANDLER_IS_RAM",
"(",
"handler",
")",
",",
"\"",
"\"",
")",
";",
"assert_always",
"(",
"addrstart",
"<=",
"addrend",
",",
"\"",
"\"",
")",
";",
"assert_always",
"(",
"handlerbits",
"<=",
"space",
"->",
"dbits",
",",
"\"",
"\"",
")",
";",
"assert_always",
"(",
"(",
"bytestart",
"&",
"(",
"space",
"->",
"dbits",
"/",
"8",
"-",
"1",
")",
")",
"==",
"0",
",",
"\"",
"\"",
")",
";",
"assert_always",
"(",
"(",
"byteend",
"&",
"(",
"space",
"->",
"dbits",
"/",
"8",
"-",
"1",
")",
")",
"==",
"(",
"space",
"->",
"dbits",
"/",
"8",
"-",
"1",
")",
",",
"\"",
"\"",
")",
";",
"entry",
"=",
"table_assign_handler",
"(",
"space",
",",
"tabledata",
"->",
"handlers",
",",
"object",
",",
"handler",
",",
"handler_name",
",",
"bytestart",
",",
"byteend",
",",
"bytemask",
")",
";",
"if",
"(",
"handlerbits",
"!=",
"space",
"->",
"dbits",
")",
"table_compute_subhandler",
"(",
"tabledata",
"->",
"handlers",
",",
"entry",
",",
"readorwrite",
",",
"space",
"->",
"dbits",
",",
"space",
"->",
"endianness",
",",
"handlerbits",
",",
"handlerunitmask",
")",
";",
"table_populate_range_mirrored",
"(",
"space",
",",
"tabledata",
",",
"bytestart",
",",
"byteend",
",",
"bytemirror",
",",
"entry",
")",
";",
"if",
"(",
"reset_write",
")",
"space",
"->",
"writelookup",
"=",
"space",
"->",
"write",
".",
"table",
";",
"if",
"(",
"reset_read",
")",
"space",
"->",
"readlookup",
"=",
"space",
"->",
"read",
".",
"table",
";",
"if",
"(",
"readorwrite",
"==",
"ROW_READ",
"&&",
"entry",
"==",
"space",
"->",
"direct",
".",
"entry",
")",
"{",
"space",
"->",
"direct",
".",
"entry",
"=",
"STATIC_UNMAP",
";",
"space",
"->",
"direct",
".",
"bytestart",
"=",
"1",
";",
"space",
"->",
"direct",
".",
"byteend",
"=",
"0",
";",
"}",
"}"
] | space_map_range - maps a range of addresses
to the specified handler within an address
space | [
"space_map_range",
"-",
"maps",
"a",
"range",
"of",
"addresses",
"to",
"the",
"specified",
"handler",
"within",
"an",
"address",
"space"
] | [
"/* sanity checks */",
"/* adjust the incoming addresses */",
"/* validity checks */",
"/* get the final handler index */",
"/* fix up the handler if a stub is required */",
"/* populate it */",
"/* reset read/write pointers if necessary (could have moved due to realloc) */",
"/* recompute any direct access on this space if it is a read modification */"
] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "readorwrite",
"type": "read_or_write"
},
{
"param": "handlerbits",
"type": "int"
},
{
"param": "handlerunitmask",
"type": "int"
},
{
"param": "addrstart",
"type": "offs_t"
},
{
"param": "addrend",
"type": "offs_t"
},
{
"param": "addrmask",
"type": "offs_t"
},
{
"param": "addrmirror",
"type": "offs_t"
},
{
"param": "handler",
"type": "genf"
},
{
"param": "object",
"type": "void"
},
{
"param": "handler_name",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "readorwrite",
"type": "read_or_write",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "handlerbits",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "handlerunitmask",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrstart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmask",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmirror",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "handler",
"type": "genf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "object",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "handler_name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | space_find_backing_memory | void | static void *space_find_backing_memory(const address_space *space, offs_t addrstart, offs_t addrend)
{
offs_t bytestart = memory_address_to_byte(space, addrstart);
offs_t byteend = memory_address_to_byte_end(space, addrend);
memory_private *memdata = space->machine->memory_data;
address_map_entry *entry;
memory_block *block;
VPRINTF(("space_find_backing_memory('%s',%s,%08X-%08X) -> ", space->cpu->tag(), space->name, bytestart, byteend));
/* look in the address map first */
for (entry = space->map->m_entrylist; entry != NULL; entry = entry->m_next)
{
offs_t maskstart = bytestart & entry->m_bytemask;
offs_t maskend = byteend & entry->m_bytemask;
if (entry->m_memory != NULL && maskstart >= entry->m_bytestart && maskend <= entry->m_byteend)
{
VPRINTF(("found in entry %08X-%08X [%p]\n", entry->m_addrstart, entry->m_addrend, (UINT8 *)entry->m_memory + (maskstart - entry->m_bytestart)));
return (UINT8 *)entry->m_memory + (maskstart - entry->m_bytestart);
}
}
/* if not found there, look in the allocated blocks */
for (block = memdata->memory_block_list; block != NULL; block = block->next)
if (block->space == space && block->bytestart <= bytestart && block->byteend >= byteend)
{
VPRINTF(("found in allocated memory block %08X-%08X [%p]\n", block->bytestart, block->byteend, block->data + (bytestart - block->bytestart)));
return block->data + bytestart - block->bytestart;
}
VPRINTF(("did not find\n"));
return NULL;
} | /*-------------------------------------------------
space_find_backing_memory - return a pointer to
the base of RAM associated with the given
device and offset
-------------------------------------------------*/ | return a pointer to
the base of RAM associated with the given
device and offset | [
"return",
"a",
"pointer",
"to",
"the",
"base",
"of",
"RAM",
"associated",
"with",
"the",
"given",
"device",
"and",
"offset"
] | static void *space_find_backing_memory(const address_space *space, offs_t addrstart, offs_t addrend)
{
offs_t bytestart = memory_address_to_byte(space, addrstart);
offs_t byteend = memory_address_to_byte_end(space, addrend);
memory_private *memdata = space->machine->memory_data;
address_map_entry *entry;
memory_block *block;
VPRINTF(("space_find_backing_memory('%s',%s,%08X-%08X) -> ", space->cpu->tag(), space->name, bytestart, byteend));
for (entry = space->map->m_entrylist; entry != NULL; entry = entry->m_next)
{
offs_t maskstart = bytestart & entry->m_bytemask;
offs_t maskend = byteend & entry->m_bytemask;
if (entry->m_memory != NULL && maskstart >= entry->m_bytestart && maskend <= entry->m_byteend)
{
VPRINTF(("found in entry %08X-%08X [%p]\n", entry->m_addrstart, entry->m_addrend, (UINT8 *)entry->m_memory + (maskstart - entry->m_bytestart)));
return (UINT8 *)entry->m_memory + (maskstart - entry->m_bytestart);
}
}
for (block = memdata->memory_block_list; block != NULL; block = block->next)
if (block->space == space && block->bytestart <= bytestart && block->byteend >= byteend)
{
VPRINTF(("found in allocated memory block %08X-%08X [%p]\n", block->bytestart, block->byteend, block->data + (bytestart - block->bytestart)));
return block->data + bytestart - block->bytestart;
}
VPRINTF(("did not find\n"));
return NULL;
} | [
"static",
"void",
"*",
"space_find_backing_memory",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"addrstart",
",",
"offs_t",
"addrend",
")",
"{",
"offs_t",
"bytestart",
"=",
"memory_address_to_byte",
"(",
"space",
",",
"addrstart",
")",
";",
"offs_t",
"byteend",
"=",
"memory_address_to_byte_end",
"(",
"space",
",",
"addrend",
")",
";",
"memory_private",
"*",
"memdata",
"=",
"space",
"->",
"machine",
"->",
"memory_data",
";",
"address_map_entry",
"*",
"entry",
";",
"memory_block",
"*",
"block",
";",
"VPRINTF",
"(",
"(",
"\"",
"\"",
",",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
",",
"space",
"->",
"name",
",",
"bytestart",
",",
"byteend",
")",
")",
";",
"for",
"(",
"entry",
"=",
"space",
"->",
"map",
"->",
"m_entrylist",
";",
"entry",
"!=",
"NULL",
";",
"entry",
"=",
"entry",
"->",
"m_next",
")",
"{",
"offs_t",
"maskstart",
"=",
"bytestart",
"&",
"entry",
"->",
"m_bytemask",
";",
"offs_t",
"maskend",
"=",
"byteend",
"&",
"entry",
"->",
"m_bytemask",
";",
"if",
"(",
"entry",
"->",
"m_memory",
"!=",
"NULL",
"&&",
"maskstart",
">=",
"entry",
"->",
"m_bytestart",
"&&",
"maskend",
"<=",
"entry",
"->",
"m_byteend",
")",
"{",
"VPRINTF",
"(",
"(",
"\"",
"\\n",
"\"",
",",
"entry",
"->",
"m_addrstart",
",",
"entry",
"->",
"m_addrend",
",",
"(",
"UINT8",
"*",
")",
"entry",
"->",
"m_memory",
"+",
"(",
"maskstart",
"-",
"entry",
"->",
"m_bytestart",
")",
")",
")",
";",
"return",
"(",
"UINT8",
"*",
")",
"entry",
"->",
"m_memory",
"+",
"(",
"maskstart",
"-",
"entry",
"->",
"m_bytestart",
")",
";",
"}",
"}",
"for",
"(",
"block",
"=",
"memdata",
"->",
"memory_block_list",
";",
"block",
"!=",
"NULL",
";",
"block",
"=",
"block",
"->",
"next",
")",
"if",
"(",
"block",
"->",
"space",
"==",
"space",
"&&",
"block",
"->",
"bytestart",
"<=",
"bytestart",
"&&",
"block",
"->",
"byteend",
">=",
"byteend",
")",
"{",
"VPRINTF",
"(",
"(",
"\"",
"\\n",
"\"",
",",
"block",
"->",
"bytestart",
",",
"block",
"->",
"byteend",
",",
"block",
"->",
"data",
"+",
"(",
"bytestart",
"-",
"block",
"->",
"bytestart",
")",
")",
")",
";",
"return",
"block",
"->",
"data",
"+",
"bytestart",
"-",
"block",
"->",
"bytestart",
";",
"}",
"VPRINTF",
"(",
"(",
"\"",
"\\n",
"\"",
")",
")",
";",
"return",
"NULL",
";",
"}"
] | space_find_backing_memory - return a pointer to
the base of RAM associated with the given
device and offset | [
"space_find_backing_memory",
"-",
"return",
"a",
"pointer",
"to",
"the",
"base",
"of",
"RAM",
"associated",
"with",
"the",
"given",
"device",
"and",
"offset"
] | [
"/* look in the address map first */",
"/* if not found there, look in the allocated blocks */"
] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "addrstart",
"type": "offs_t"
},
{
"param": "addrend",
"type": "offs_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrstart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | space_needs_backing_store | int | static int space_needs_backing_store(const address_space *space, const address_map_entry *entry)
{
/* if we are asked to provide a base pointer, then yes, we do need backing */
if (entry->m_baseptr != NULL || entry->m_baseptroffs_plus1 != 0 || entry->m_genbaseptroffs_plus1 != 0)
return TRUE;
/* if we're writing to any sort of bank or RAM, then yes, we do need backing */
if (entry->m_write.type == AMH_BANK || entry->m_write.type == AMH_RAM)
return TRUE;
/* if we're reading from RAM or from ROM outside of address space 0 or its region, then yes, we do need backing */
const region_info *region = space->machine->region(space->cpu->tag());
if (entry->m_read.type == AMH_RAM ||
(entry->m_read.type == AMH_ROM && (space->spacenum != ADDRESS_SPACE_0 || region == NULL || entry->m_addrstart >= region->bytes())))
return TRUE;
/* all other cases don't need backing */
return FALSE;
} | /*-------------------------------------------------
space_needs_backing_store - return whether a
given memory map entry implies the need of
allocating and registering memory
-------------------------------------------------*/ | return whether a
given memory map entry implies the need of
allocating and registering memory | [
"return",
"whether",
"a",
"given",
"memory",
"map",
"entry",
"implies",
"the",
"need",
"of",
"allocating",
"and",
"registering",
"memory"
] | static int space_needs_backing_store(const address_space *space, const address_map_entry *entry)
{
if (entry->m_baseptr != NULL || entry->m_baseptroffs_plus1 != 0 || entry->m_genbaseptroffs_plus1 != 0)
return TRUE;
if (entry->m_write.type == AMH_BANK || entry->m_write.type == AMH_RAM)
return TRUE;
const region_info *region = space->machine->region(space->cpu->tag());
if (entry->m_read.type == AMH_RAM ||
(entry->m_read.type == AMH_ROM && (space->spacenum != ADDRESS_SPACE_0 || region == NULL || entry->m_addrstart >= region->bytes())))
return TRUE;
return FALSE;
} | [
"static",
"int",
"space_needs_backing_store",
"(",
"const",
"address_space",
"*",
"space",
",",
"const",
"address_map_entry",
"*",
"entry",
")",
"{",
"if",
"(",
"entry",
"->",
"m_baseptr",
"!=",
"NULL",
"||",
"entry",
"->",
"m_baseptroffs_plus1",
"!=",
"0",
"||",
"entry",
"->",
"m_genbaseptroffs_plus1",
"!=",
"0",
")",
"return",
"TRUE",
";",
"if",
"(",
"entry",
"->",
"m_write",
".",
"type",
"==",
"AMH_BANK",
"||",
"entry",
"->",
"m_write",
".",
"type",
"==",
"AMH_RAM",
")",
"return",
"TRUE",
";",
"const",
"region_info",
"*",
"region",
"=",
"space",
"->",
"machine",
"->",
"region",
"(",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
")",
";",
"if",
"(",
"entry",
"->",
"m_read",
".",
"type",
"==",
"AMH_RAM",
"||",
"(",
"entry",
"->",
"m_read",
".",
"type",
"==",
"AMH_ROM",
"&&",
"(",
"space",
"->",
"spacenum",
"!=",
"ADDRESS_SPACE_0",
"||",
"region",
"==",
"NULL",
"||",
"entry",
"->",
"m_addrstart",
">=",
"region",
"->",
"bytes",
"(",
")",
")",
")",
")",
"return",
"TRUE",
";",
"return",
"FALSE",
";",
"}"
] | space_needs_backing_store - return whether a
given memory map entry implies the need of
allocating and registering memory | [
"space_needs_backing_store",
"-",
"return",
"whether",
"a",
"given",
"memory",
"map",
"entry",
"implies",
"the",
"need",
"of",
"allocating",
"and",
"registering",
"memory"
] | [
"/* if we are asked to provide a base pointer, then yes, we do need backing */",
"/* if we're writing to any sort of bank or RAM, then yes, we do need backing */",
"/* if we're reading from RAM or from ROM outside of address space 0 or its region, then yes, we do need backing */",
"/* all other cases don't need backing */"
] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "entry",
"type": "address_map_entry"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "entry",
"type": "address_map_entry",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | bank_find_or_allocate | genf | static genf *bank_find_or_allocate(const address_space *space, const char *tag, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read_or_write readorwrite)
{
memory_private *memdata = space->machine->memory_data;
offs_t bytemirror = addrmirror;
offs_t bytestart = addrstart;
offs_t bytemask = addrmask;
offs_t byteend = addrend;
bank_info *bank = NULL;
char temptag[10];
char name[30];
/* adjust the addresses, handling mirrors and such */
adjust_addresses(space, &bytestart, &byteend, &bytemask, &bytemirror);
/* if this bank is named, look it up */
if (tag != NULL)
bank = memdata->bankmap.find_hash_only(tag);
/* else try to find an exact match */
else
{
for (bank = memdata->banklist; bank != NULL; bank = bank->next)
if (bank->tag[0] == '~' && bank->bytestart == bytestart && bank->byteend == byteend && bank->reflist != NULL && bank->reflist->space == space)
break;
}
/* if we don't have a bank yet, find a free one */
if (bank == NULL)
{
int banknum = memdata->banknext++;
/* handle failure */
if (banknum > STATIC_BANKMAX)
{
if (tag != NULL)
fatalerror("Unable to allocate new bank '%s'", tag);
else
fatalerror("Unable to allocate bank for RAM/ROM area %X-%X\n", bytestart, byteend);
}
/* generate an internal tag if we don't have one */
if (tag == NULL)
{
sprintf(temptag, "~%d~", banknum);
tag = temptag;
sprintf(name, "Internal bank #%d", banknum);
}
else
sprintf(name, "Bank '%s'", tag);
/* allocate the bank */
bank = (bank_info *)auto_alloc_array_clear(space->machine, UINT8, sizeof(bank_info) + strlen(tag) + 1 + strlen(name));
/* populate it */
bank->index = banknum;
bank->handler = (void *)(FPTR)(STATIC_BANK1 + banknum - 1);
bank->bytestart = bytestart;
bank->byteend = byteend;
bank->curentry = MAX_BANK_ENTRIES;
strcpy(bank->tag, tag);
bank->name = bank->tag + strlen(tag) + 1;
strcpy(bank->name, name);
/* add us to the list */
bank->next = memdata->banklist;
memdata->banklist = bank;
/* for named banks, add to the map and register for save states */
if (tag[0] != '~')
{
memdata->bankmap.add_unique_hash(tag, bank, FALSE);
if (state_save_registration_allowed(space->machine))
state_save_register_item(space->machine, "memory", bank->tag, 0, bank->curentry);
}
}
/* update the read/write state for this bank */
if (readorwrite == ROW_READ)
bank->read = TRUE;
if (readorwrite == ROW_WRITE)
bank->write = TRUE;
/* add a reference for this space */
add_bank_reference(bank, space);
return (genf *)bank->handler;
} | /*-------------------------------------------------
bank_find_or_allocate - allocate a new
bank, or find an existing one, and return the
read/write handler
-------------------------------------------------*/ | allocate a new
bank, or find an existing one, and return the
read/write handler | [
"allocate",
"a",
"new",
"bank",
"or",
"find",
"an",
"existing",
"one",
"and",
"return",
"the",
"read",
"/",
"write",
"handler"
] | static genf *bank_find_or_allocate(const address_space *space, const char *tag, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read_or_write readorwrite)
{
memory_private *memdata = space->machine->memory_data;
offs_t bytemirror = addrmirror;
offs_t bytestart = addrstart;
offs_t bytemask = addrmask;
offs_t byteend = addrend;
bank_info *bank = NULL;
char temptag[10];
char name[30];
adjust_addresses(space, &bytestart, &byteend, &bytemask, &bytemirror);
if (tag != NULL)
bank = memdata->bankmap.find_hash_only(tag);
else
{
for (bank = memdata->banklist; bank != NULL; bank = bank->next)
if (bank->tag[0] == '~' && bank->bytestart == bytestart && bank->byteend == byteend && bank->reflist != NULL && bank->reflist->space == space)
break;
}
if (bank == NULL)
{
int banknum = memdata->banknext++;
if (banknum > STATIC_BANKMAX)
{
if (tag != NULL)
fatalerror("Unable to allocate new bank '%s'", tag);
else
fatalerror("Unable to allocate bank for RAM/ROM area %X-%X\n", bytestart, byteend);
}
if (tag == NULL)
{
sprintf(temptag, "~%d~", banknum);
tag = temptag;
sprintf(name, "Internal bank #%d", banknum);
}
else
sprintf(name, "Bank '%s'", tag);
bank = (bank_info *)auto_alloc_array_clear(space->machine, UINT8, sizeof(bank_info) + strlen(tag) + 1 + strlen(name));
bank->index = banknum;
bank->handler = (void *)(FPTR)(STATIC_BANK1 + banknum - 1);
bank->bytestart = bytestart;
bank->byteend = byteend;
bank->curentry = MAX_BANK_ENTRIES;
strcpy(bank->tag, tag);
bank->name = bank->tag + strlen(tag) + 1;
strcpy(bank->name, name);
bank->next = memdata->banklist;
memdata->banklist = bank;
if (tag[0] != '~')
{
memdata->bankmap.add_unique_hash(tag, bank, FALSE);
if (state_save_registration_allowed(space->machine))
state_save_register_item(space->machine, "memory", bank->tag, 0, bank->curentry);
}
}
if (readorwrite == ROW_READ)
bank->read = TRUE;
if (readorwrite == ROW_WRITE)
bank->write = TRUE;
add_bank_reference(bank, space);
return (genf *)bank->handler;
} | [
"static",
"genf",
"*",
"bank_find_or_allocate",
"(",
"const",
"address_space",
"*",
"space",
",",
"const",
"char",
"*",
"tag",
",",
"offs_t",
"addrstart",
",",
"offs_t",
"addrend",
",",
"offs_t",
"addrmask",
",",
"offs_t",
"addrmirror",
",",
"read_or_write",
"readorwrite",
")",
"{",
"memory_private",
"*",
"memdata",
"=",
"space",
"->",
"machine",
"->",
"memory_data",
";",
"offs_t",
"bytemirror",
"=",
"addrmirror",
";",
"offs_t",
"bytestart",
"=",
"addrstart",
";",
"offs_t",
"bytemask",
"=",
"addrmask",
";",
"offs_t",
"byteend",
"=",
"addrend",
";",
"bank_info",
"*",
"bank",
"=",
"NULL",
";",
"char",
"temptag",
"[",
"10",
"]",
";",
"char",
"name",
"[",
"30",
"]",
";",
"adjust_addresses",
"(",
"space",
",",
"&",
"bytestart",
",",
"&",
"byteend",
",",
"&",
"bytemask",
",",
"&",
"bytemirror",
")",
";",
"if",
"(",
"tag",
"!=",
"NULL",
")",
"bank",
"=",
"memdata",
"->",
"bankmap",
".",
"find_hash_only",
"(",
"tag",
")",
";",
"else",
"{",
"for",
"(",
"bank",
"=",
"memdata",
"->",
"banklist",
";",
"bank",
"!=",
"NULL",
";",
"bank",
"=",
"bank",
"->",
"next",
")",
"if",
"(",
"bank",
"->",
"tag",
"[",
"0",
"]",
"==",
"'",
"'",
"&&",
"bank",
"->",
"bytestart",
"==",
"bytestart",
"&&",
"bank",
"->",
"byteend",
"==",
"byteend",
"&&",
"bank",
"->",
"reflist",
"!=",
"NULL",
"&&",
"bank",
"->",
"reflist",
"->",
"space",
"==",
"space",
")",
"break",
";",
"}",
"if",
"(",
"bank",
"==",
"NULL",
")",
"{",
"int",
"banknum",
"=",
"memdata",
"->",
"banknext",
"++",
";",
"if",
"(",
"banknum",
">",
"STATIC_BANKMAX",
")",
"{",
"if",
"(",
"tag",
"!=",
"NULL",
")",
"fatalerror",
"(",
"\"",
"\"",
",",
"tag",
")",
";",
"else",
"fatalerror",
"(",
"\"",
"\\n",
"\"",
",",
"bytestart",
",",
"byteend",
")",
";",
"}",
"if",
"(",
"tag",
"==",
"NULL",
")",
"{",
"sprintf",
"(",
"temptag",
",",
"\"",
"\"",
",",
"banknum",
")",
";",
"tag",
"=",
"temptag",
";",
"sprintf",
"(",
"name",
",",
"\"",
"\"",
",",
"banknum",
")",
";",
"}",
"else",
"sprintf",
"(",
"name",
",",
"\"",
"\"",
",",
"tag",
")",
";",
"bank",
"=",
"(",
"bank_info",
"*",
")",
"auto_alloc_array_clear",
"(",
"space",
"->",
"machine",
",",
"UINT8",
",",
"sizeof",
"(",
"bank_info",
")",
"+",
"strlen",
"(",
"tag",
")",
"+",
"1",
"+",
"strlen",
"(",
"name",
")",
")",
";",
"bank",
"->",
"index",
"=",
"banknum",
";",
"bank",
"->",
"handler",
"=",
"(",
"void",
"*",
")",
"(",
"FPTR",
")",
"(",
"STATIC_BANK1",
"+",
"banknum",
"-",
"1",
")",
";",
"bank",
"->",
"bytestart",
"=",
"bytestart",
";",
"bank",
"->",
"byteend",
"=",
"byteend",
";",
"bank",
"->",
"curentry",
"=",
"MAX_BANK_ENTRIES",
";",
"strcpy",
"(",
"bank",
"->",
"tag",
",",
"tag",
")",
";",
"bank",
"->",
"name",
"=",
"bank",
"->",
"tag",
"+",
"strlen",
"(",
"tag",
")",
"+",
"1",
";",
"strcpy",
"(",
"bank",
"->",
"name",
",",
"name",
")",
";",
"bank",
"->",
"next",
"=",
"memdata",
"->",
"banklist",
";",
"memdata",
"->",
"banklist",
"=",
"bank",
";",
"if",
"(",
"tag",
"[",
"0",
"]",
"!=",
"'",
"'",
")",
"{",
"memdata",
"->",
"bankmap",
".",
"add_unique_hash",
"(",
"tag",
",",
"bank",
",",
"FALSE",
")",
";",
"if",
"(",
"state_save_registration_allowed",
"(",
"space",
"->",
"machine",
")",
")",
"state_save_register_item",
"(",
"space",
"->",
"machine",
",",
"\"",
"\"",
",",
"bank",
"->",
"tag",
",",
"0",
",",
"bank",
"->",
"curentry",
")",
";",
"}",
"}",
"if",
"(",
"readorwrite",
"==",
"ROW_READ",
")",
"bank",
"->",
"read",
"=",
"TRUE",
";",
"if",
"(",
"readorwrite",
"==",
"ROW_WRITE",
")",
"bank",
"->",
"write",
"=",
"TRUE",
";",
"add_bank_reference",
"(",
"bank",
",",
"space",
")",
";",
"return",
"(",
"genf",
"*",
")",
"bank",
"->",
"handler",
";",
"}"
] | bank_find_or_allocate - allocate a new
bank, or find an existing one, and return the
read/write handler | [
"bank_find_or_allocate",
"-",
"allocate",
"a",
"new",
"bank",
"or",
"find",
"an",
"existing",
"one",
"and",
"return",
"the",
"read",
"/",
"write",
"handler"
] | [
"/* adjust the addresses, handling mirrors and such */",
"/* if this bank is named, look it up */",
"/* else try to find an exact match */",
"/* if we don't have a bank yet, find a free one */",
"/* handle failure */",
"/* generate an internal tag if we don't have one */",
"/* allocate the bank */",
"/* populate it */",
"/* add us to the list */",
"/* for named banks, add to the map and register for save states */",
"/* update the read/write state for this bank */",
"/* add a reference for this space */"
] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "tag",
"type": "char"
},
{
"param": "addrstart",
"type": "offs_t"
},
{
"param": "addrend",
"type": "offs_t"
},
{
"param": "addrmask",
"type": "offs_t"
},
{
"param": "addrmirror",
"type": "offs_t"
},
{
"param": "readorwrite",
"type": "read_or_write"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tag",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrstart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmask",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrmirror",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "readorwrite",
"type": "read_or_write",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | table_assign_handler | UINT8 | static UINT8 table_assign_handler(const address_space *space, handler_data **table, void *object, genf *handler, const char *handler_name, offs_t bytestart, offs_t byteend, offs_t bytemask)
{
int entry;
/* all static handlers are hardcoded */
if (HANDLER_IS_STATIC(handler))
{
entry = (FPTR)handler;
/* if it is a bank, copy in the relevant information */
if (HANDLER_IS_BANK(handler))
{
handler_data *hdata = table[entry];
hdata->bytestart = bytestart;
hdata->byteend = byteend;
hdata->bytemask = bytemask;
hdata->bankbaseptr = &space->machine->memory_data->bank_ptr[entry];
hdata->name = handler_name;
}
return entry;
}
/* otherwise, we have to search */
for (entry = STATIC_COUNT; entry < SUBTABLE_BASE; entry++)
{
handler_data *hdata = table[entry];
/* if we hit a NULL hdata, then we need to allocate this one as a new one */
if (hdata->handler.generic == NULL)
{
hdata->handler.generic = handler;
hdata->bytestart = bytestart;
hdata->byteend = byteend;
hdata->bytemask = bytemask;
hdata->name = handler_name;
hdata->object = object;
return entry;
}
/* if we find a perfect match, return a duplicate entry */
if (hdata->handler.generic == handler && hdata->bytestart == bytestart && hdata->bytemask == bytemask && hdata->object == object)
return entry;
}
return 0;
} | /*-------------------------------------------------
table_assign_handler - finds the index of a
handler, or allocates a new one as necessary
-------------------------------------------------*/ | finds the index of a
handler, or allocates a new one as necessary | [
"finds",
"the",
"index",
"of",
"a",
"handler",
"or",
"allocates",
"a",
"new",
"one",
"as",
"necessary"
] | static UINT8 table_assign_handler(const address_space *space, handler_data **table, void *object, genf *handler, const char *handler_name, offs_t bytestart, offs_t byteend, offs_t bytemask)
{
int entry;
if (HANDLER_IS_STATIC(handler))
{
entry = (FPTR)handler;
if (HANDLER_IS_BANK(handler))
{
handler_data *hdata = table[entry];
hdata->bytestart = bytestart;
hdata->byteend = byteend;
hdata->bytemask = bytemask;
hdata->bankbaseptr = &space->machine->memory_data->bank_ptr[entry];
hdata->name = handler_name;
}
return entry;
}
for (entry = STATIC_COUNT; entry < SUBTABLE_BASE; entry++)
{
handler_data *hdata = table[entry];
if (hdata->handler.generic == NULL)
{
hdata->handler.generic = handler;
hdata->bytestart = bytestart;
hdata->byteend = byteend;
hdata->bytemask = bytemask;
hdata->name = handler_name;
hdata->object = object;
return entry;
}
if (hdata->handler.generic == handler && hdata->bytestart == bytestart && hdata->bytemask == bytemask && hdata->object == object)
return entry;
}
return 0;
} | [
"static",
"UINT8",
"table_assign_handler",
"(",
"const",
"address_space",
"*",
"space",
",",
"handler_data",
"*",
"*",
"table",
",",
"void",
"*",
"object",
",",
"genf",
"*",
"handler",
",",
"const",
"char",
"*",
"handler_name",
",",
"offs_t",
"bytestart",
",",
"offs_t",
"byteend",
",",
"offs_t",
"bytemask",
")",
"{",
"int",
"entry",
";",
"if",
"(",
"HANDLER_IS_STATIC",
"(",
"handler",
")",
")",
"{",
"entry",
"=",
"(",
"FPTR",
")",
"handler",
";",
"if",
"(",
"HANDLER_IS_BANK",
"(",
"handler",
")",
")",
"{",
"handler_data",
"*",
"hdata",
"=",
"table",
"[",
"entry",
"]",
";",
"hdata",
"->",
"bytestart",
"=",
"bytestart",
";",
"hdata",
"->",
"byteend",
"=",
"byteend",
";",
"hdata",
"->",
"bytemask",
"=",
"bytemask",
";",
"hdata",
"->",
"bankbaseptr",
"=",
"&",
"space",
"->",
"machine",
"->",
"memory_data",
"->",
"bank_ptr",
"[",
"entry",
"]",
";",
"hdata",
"->",
"name",
"=",
"handler_name",
";",
"}",
"return",
"entry",
";",
"}",
"for",
"(",
"entry",
"=",
"STATIC_COUNT",
";",
"entry",
"<",
"SUBTABLE_BASE",
";",
"entry",
"++",
")",
"{",
"handler_data",
"*",
"hdata",
"=",
"table",
"[",
"entry",
"]",
";",
"if",
"(",
"hdata",
"->",
"handler",
".",
"generic",
"==",
"NULL",
")",
"{",
"hdata",
"->",
"handler",
".",
"generic",
"=",
"handler",
";",
"hdata",
"->",
"bytestart",
"=",
"bytestart",
";",
"hdata",
"->",
"byteend",
"=",
"byteend",
";",
"hdata",
"->",
"bytemask",
"=",
"bytemask",
";",
"hdata",
"->",
"name",
"=",
"handler_name",
";",
"hdata",
"->",
"object",
"=",
"object",
";",
"return",
"entry",
";",
"}",
"if",
"(",
"hdata",
"->",
"handler",
".",
"generic",
"==",
"handler",
"&&",
"hdata",
"->",
"bytestart",
"==",
"bytestart",
"&&",
"hdata",
"->",
"bytemask",
"==",
"bytemask",
"&&",
"hdata",
"->",
"object",
"==",
"object",
")",
"return",
"entry",
";",
"}",
"return",
"0",
";",
"}"
] | table_assign_handler - finds the index of a
handler, or allocates a new one as necessary | [
"table_assign_handler",
"-",
"finds",
"the",
"index",
"of",
"a",
"handler",
"or",
"allocates",
"a",
"new",
"one",
"as",
"necessary"
] | [
"/* all static handlers are hardcoded */",
"/* if it is a bank, copy in the relevant information */",
"/* otherwise, we have to search */",
"/* if we hit a NULL hdata, then we need to allocate this one as a new one */",
"/* if we find a perfect match, return a duplicate entry */"
] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "table",
"type": "handler_data"
},
{
"param": "object",
"type": "void"
},
{
"param": "handler",
"type": "genf"
},
{
"param": "handler_name",
"type": "char"
},
{
"param": "bytestart",
"type": "offs_t"
},
{
"param": "byteend",
"type": "offs_t"
},
{
"param": "bytemask",
"type": "offs_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "table",
"type": "handler_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "object",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "handler",
"type": "genf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "handler_name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bytestart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "byteend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bytemask",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | table_populate_range | void | static void table_populate_range(address_table *tabledata, offs_t bytestart, offs_t byteend, UINT8 handler)
{
offs_t l2mask = (1 << LEVEL2_BITS) - 1;
offs_t l1start = bytestart >> LEVEL2_BITS;
offs_t l2start = bytestart & l2mask;
offs_t l1stop = byteend >> LEVEL2_BITS;
offs_t l2stop = byteend & l2mask;
offs_t l1index;
/* sanity check */
if (bytestart > byteend)
return;
/* handle the starting edge if it's not on a block boundary */
if (l2start != 0)
{
UINT8 *subtable = subtable_open(tabledata, l1start);
/* if the start and stop end within the same block, handle that */
if (l1start == l1stop)
{
memset(&subtable[l2start], handler, l2stop - l2start + 1);
subtable_close(tabledata, l1start);
return;
}
/* otherwise, fill until the end */
memset(&subtable[l2start], handler, (1 << LEVEL2_BITS) - l2start);
subtable_close(tabledata, l1start);
if (l1start != (offs_t)~0) l1start++;
}
/* handle the trailing edge if it's not on a block boundary */
if (l2stop != l2mask)
{
UINT8 *subtable = subtable_open(tabledata, l1stop);
/* fill from the beginning */
memset(&subtable[0], handler, l2stop + 1);
subtable_close(tabledata, l1stop);
/* if the start and stop end within the same block, handle that */
if (l1start == l1stop)
return;
if (l1stop != 0) l1stop--;
}
/* now fill in the middle tables */
for (l1index = l1start; l1index <= l1stop; l1index++)
{
/* if we have a subtable here, release it */
if (tabledata->table[l1index] >= SUBTABLE_BASE)
subtable_release(tabledata, tabledata->table[l1index]);
tabledata->table[l1index] = handler;
}
} | /*-------------------------------------------------
table_populate_range - assign a memory handler
to a range of addresses
-------------------------------------------------*/ | assign a memory handler
to a range of addresses | [
"assign",
"a",
"memory",
"handler",
"to",
"a",
"range",
"of",
"addresses"
] | static void table_populate_range(address_table *tabledata, offs_t bytestart, offs_t byteend, UINT8 handler)
{
offs_t l2mask = (1 << LEVEL2_BITS) - 1;
offs_t l1start = bytestart >> LEVEL2_BITS;
offs_t l2start = bytestart & l2mask;
offs_t l1stop = byteend >> LEVEL2_BITS;
offs_t l2stop = byteend & l2mask;
offs_t l1index;
if (bytestart > byteend)
return;
if (l2start != 0)
{
UINT8 *subtable = subtable_open(tabledata, l1start);
if (l1start == l1stop)
{
memset(&subtable[l2start], handler, l2stop - l2start + 1);
subtable_close(tabledata, l1start);
return;
}
memset(&subtable[l2start], handler, (1 << LEVEL2_BITS) - l2start);
subtable_close(tabledata, l1start);
if (l1start != (offs_t)~0) l1start++;
}
if (l2stop != l2mask)
{
UINT8 *subtable = subtable_open(tabledata, l1stop);
memset(&subtable[0], handler, l2stop + 1);
subtable_close(tabledata, l1stop);
if (l1start == l1stop)
return;
if (l1stop != 0) l1stop--;
}
for (l1index = l1start; l1index <= l1stop; l1index++)
{
if (tabledata->table[l1index] >= SUBTABLE_BASE)
subtable_release(tabledata, tabledata->table[l1index]);
tabledata->table[l1index] = handler;
}
} | [
"static",
"void",
"table_populate_range",
"(",
"address_table",
"*",
"tabledata",
",",
"offs_t",
"bytestart",
",",
"offs_t",
"byteend",
",",
"UINT8",
"handler",
")",
"{",
"offs_t",
"l2mask",
"=",
"(",
"1",
"<<",
"LEVEL2_BITS",
")",
"-",
"1",
";",
"offs_t",
"l1start",
"=",
"bytestart",
">>",
"LEVEL2_BITS",
";",
"offs_t",
"l2start",
"=",
"bytestart",
"&",
"l2mask",
";",
"offs_t",
"l1stop",
"=",
"byteend",
">>",
"LEVEL2_BITS",
";",
"offs_t",
"l2stop",
"=",
"byteend",
"&",
"l2mask",
";",
"offs_t",
"l1index",
";",
"if",
"(",
"bytestart",
">",
"byteend",
")",
"return",
";",
"if",
"(",
"l2start",
"!=",
"0",
")",
"{",
"UINT8",
"*",
"subtable",
"=",
"subtable_open",
"(",
"tabledata",
",",
"l1start",
")",
";",
"if",
"(",
"l1start",
"==",
"l1stop",
")",
"{",
"memset",
"(",
"&",
"subtable",
"[",
"l2start",
"]",
",",
"handler",
",",
"l2stop",
"-",
"l2start",
"+",
"1",
")",
";",
"subtable_close",
"(",
"tabledata",
",",
"l1start",
")",
";",
"return",
";",
"}",
"memset",
"(",
"&",
"subtable",
"[",
"l2start",
"]",
",",
"handler",
",",
"(",
"1",
"<<",
"LEVEL2_BITS",
")",
"-",
"l2start",
")",
";",
"subtable_close",
"(",
"tabledata",
",",
"l1start",
")",
";",
"if",
"(",
"l1start",
"!=",
"(",
"offs_t",
")",
"~",
"0",
")",
"l1start",
"++",
";",
"}",
"if",
"(",
"l2stop",
"!=",
"l2mask",
")",
"{",
"UINT8",
"*",
"subtable",
"=",
"subtable_open",
"(",
"tabledata",
",",
"l1stop",
")",
";",
"memset",
"(",
"&",
"subtable",
"[",
"0",
"]",
",",
"handler",
",",
"l2stop",
"+",
"1",
")",
";",
"subtable_close",
"(",
"tabledata",
",",
"l1stop",
")",
";",
"if",
"(",
"l1start",
"==",
"l1stop",
")",
"return",
";",
"if",
"(",
"l1stop",
"!=",
"0",
")",
"l1stop",
"--",
";",
"}",
"for",
"(",
"l1index",
"=",
"l1start",
";",
"l1index",
"<=",
"l1stop",
";",
"l1index",
"++",
")",
"{",
"if",
"(",
"tabledata",
"->",
"table",
"[",
"l1index",
"]",
">=",
"SUBTABLE_BASE",
")",
"subtable_release",
"(",
"tabledata",
",",
"tabledata",
"->",
"table",
"[",
"l1index",
"]",
")",
";",
"tabledata",
"->",
"table",
"[",
"l1index",
"]",
"=",
"handler",
";",
"}",
"}"
] | table_populate_range - assign a memory handler
to a range of addresses | [
"table_populate_range",
"-",
"assign",
"a",
"memory",
"handler",
"to",
"a",
"range",
"of",
"addresses"
] | [
"/* sanity check */",
"/* handle the starting edge if it's not on a block boundary */",
"/* if the start and stop end within the same block, handle that */",
"/* otherwise, fill until the end */",
"/* handle the trailing edge if it's not on a block boundary */",
"/* fill from the beginning */",
"/* if the start and stop end within the same block, handle that */",
"/* now fill in the middle tables */",
"/* if we have a subtable here, release it */"
] | [
{
"param": "tabledata",
"type": "address_table"
},
{
"param": "bytestart",
"type": "offs_t"
},
{
"param": "byteend",
"type": "offs_t"
},
{
"param": "handler",
"type": "UINT8"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tabledata",
"type": "address_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bytestart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "byteend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "handler",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | table_populate_range_mirrored | void | static void table_populate_range_mirrored(address_space *space, address_table *tabledata, offs_t bytestart, offs_t byteend, offs_t bytemirror, UINT8 handler)
{
offs_t lmirrorbit[LEVEL2_BITS], lmirrorbits, hmirrorbit[32 - LEVEL2_BITS], hmirrorbits, lmirrorcount, hmirrorcount;
UINT8 prev_entry = STATIC_INVALID;
int cur_index, prev_index = 0;
int i;
/* determine the mirror bits */
hmirrorbits = lmirrorbits = 0;
for (i = 0; i < LEVEL2_BITS; i++)
if (bytemirror & (1 << i))
lmirrorbit[lmirrorbits++] = 1 << i;
for (i = LEVEL2_BITS; i < 32; i++)
if (bytemirror & (1 << i))
hmirrorbit[hmirrorbits++] = 1 << i;
/* loop over mirrors in the level 2 table */
for (hmirrorcount = 0; hmirrorcount < (1 << hmirrorbits); hmirrorcount++)
{
/* compute the base of this mirror */
offs_t hmirrorbase = 0;
for (i = 0; i < hmirrorbits; i++)
if (hmirrorcount & (1 << i))
hmirrorbase |= hmirrorbit[i];
/* invalidate any intersecting cached ranges */
for (lmirrorcount = 0; lmirrorcount < (1 << lmirrorbits); lmirrorcount++)
{
/* compute the base of this mirror */
offs_t lmirrorbase = hmirrorbase;
for (i = 0; i < lmirrorbits; i++)
if (lmirrorcount & (1 << i))
lmirrorbase |= lmirrorbit[i];
direct_range_remove_intersecting(space, bytestart + lmirrorbase, byteend + lmirrorbase);
}
/* if this is not our first time through, and the level 2 entry matches the previous
level 2 entry, just do a quick map and get out; note that this only works for entries
which don't span multiple level 1 table entries */
cur_index = LEVEL1_INDEX(bytestart + hmirrorbase);
if (cur_index == LEVEL1_INDEX(byteend + hmirrorbase))
{
if (hmirrorcount != 0 && prev_entry == tabledata->table[cur_index])
{
VPRINTF(("Quick mapping subtable at %08X to match subtable at %08X\n", cur_index << LEVEL2_BITS, prev_index << LEVEL2_BITS));
/* release the subtable if the old value was a subtable */
if (tabledata->table[cur_index] >= SUBTABLE_BASE)
subtable_release(tabledata, tabledata->table[cur_index]);
/* reallocate the subtable if the new value is a subtable */
if (tabledata->table[prev_index] >= SUBTABLE_BASE)
subtable_realloc(tabledata, tabledata->table[prev_index]);
/* set the new value and short-circuit the mapping step */
tabledata->table[cur_index] = tabledata->table[prev_index];
continue;
}
prev_index = cur_index;
prev_entry = tabledata->table[cur_index];
}
/* loop over mirrors in the level 1 table */
for (lmirrorcount = 0; lmirrorcount < (1 << lmirrorbits); lmirrorcount++)
{
/* compute the base of this mirror */
offs_t lmirrorbase = hmirrorbase;
for (i = 0; i < lmirrorbits; i++)
if (lmirrorcount & (1 << i))
lmirrorbase |= lmirrorbit[i];
/* populate the tables */
table_populate_range(tabledata, bytestart + lmirrorbase, byteend + lmirrorbase, handler);
}
}
} | /*-------------------------------------------------
table_populate_range_mirrored - assign a
memory handler to a range of addresses
including mirrors
-------------------------------------------------*/ | assign a
memory handler to a range of addresses
including mirrors | [
"assign",
"a",
"memory",
"handler",
"to",
"a",
"range",
"of",
"addresses",
"including",
"mirrors"
] | static void table_populate_range_mirrored(address_space *space, address_table *tabledata, offs_t bytestart, offs_t byteend, offs_t bytemirror, UINT8 handler)
{
offs_t lmirrorbit[LEVEL2_BITS], lmirrorbits, hmirrorbit[32 - LEVEL2_BITS], hmirrorbits, lmirrorcount, hmirrorcount;
UINT8 prev_entry = STATIC_INVALID;
int cur_index, prev_index = 0;
int i;
hmirrorbits = lmirrorbits = 0;
for (i = 0; i < LEVEL2_BITS; i++)
if (bytemirror & (1 << i))
lmirrorbit[lmirrorbits++] = 1 << i;
for (i = LEVEL2_BITS; i < 32; i++)
if (bytemirror & (1 << i))
hmirrorbit[hmirrorbits++] = 1 << i;
for (hmirrorcount = 0; hmirrorcount < (1 << hmirrorbits); hmirrorcount++)
{
offs_t hmirrorbase = 0;
for (i = 0; i < hmirrorbits; i++)
if (hmirrorcount & (1 << i))
hmirrorbase |= hmirrorbit[i];
for (lmirrorcount = 0; lmirrorcount < (1 << lmirrorbits); lmirrorcount++)
{
offs_t lmirrorbase = hmirrorbase;
for (i = 0; i < lmirrorbits; i++)
if (lmirrorcount & (1 << i))
lmirrorbase |= lmirrorbit[i];
direct_range_remove_intersecting(space, bytestart + lmirrorbase, byteend + lmirrorbase);
}
cur_index = LEVEL1_INDEX(bytestart + hmirrorbase);
if (cur_index == LEVEL1_INDEX(byteend + hmirrorbase))
{
if (hmirrorcount != 0 && prev_entry == tabledata->table[cur_index])
{
VPRINTF(("Quick mapping subtable at %08X to match subtable at %08X\n", cur_index << LEVEL2_BITS, prev_index << LEVEL2_BITS));
if (tabledata->table[cur_index] >= SUBTABLE_BASE)
subtable_release(tabledata, tabledata->table[cur_index]);
if (tabledata->table[prev_index] >= SUBTABLE_BASE)
subtable_realloc(tabledata, tabledata->table[prev_index]);
tabledata->table[cur_index] = tabledata->table[prev_index];
continue;
}
prev_index = cur_index;
prev_entry = tabledata->table[cur_index];
}
for (lmirrorcount = 0; lmirrorcount < (1 << lmirrorbits); lmirrorcount++)
{
offs_t lmirrorbase = hmirrorbase;
for (i = 0; i < lmirrorbits; i++)
if (lmirrorcount & (1 << i))
lmirrorbase |= lmirrorbit[i];
table_populate_range(tabledata, bytestart + lmirrorbase, byteend + lmirrorbase, handler);
}
}
} | [
"static",
"void",
"table_populate_range_mirrored",
"(",
"address_space",
"*",
"space",
",",
"address_table",
"*",
"tabledata",
",",
"offs_t",
"bytestart",
",",
"offs_t",
"byteend",
",",
"offs_t",
"bytemirror",
",",
"UINT8",
"handler",
")",
"{",
"offs_t",
"lmirrorbit",
"[",
"LEVEL2_BITS",
"]",
",",
"lmirrorbits",
",",
"hmirrorbit",
"[",
"32",
"-",
"LEVEL2_BITS",
"]",
",",
"hmirrorbits",
",",
"lmirrorcount",
",",
"hmirrorcount",
";",
"UINT8",
"prev_entry",
"=",
"STATIC_INVALID",
";",
"int",
"cur_index",
",",
"prev_index",
"=",
"0",
";",
"int",
"i",
";",
"hmirrorbits",
"=",
"lmirrorbits",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"LEVEL2_BITS",
";",
"i",
"++",
")",
"if",
"(",
"bytemirror",
"&",
"(",
"1",
"<<",
"i",
")",
")",
"lmirrorbit",
"[",
"lmirrorbits",
"++",
"]",
"=",
"1",
"<<",
"i",
";",
"for",
"(",
"i",
"=",
"LEVEL2_BITS",
";",
"i",
"<",
"32",
";",
"i",
"++",
")",
"if",
"(",
"bytemirror",
"&",
"(",
"1",
"<<",
"i",
")",
")",
"hmirrorbit",
"[",
"hmirrorbits",
"++",
"]",
"=",
"1",
"<<",
"i",
";",
"for",
"(",
"hmirrorcount",
"=",
"0",
";",
"hmirrorcount",
"<",
"(",
"1",
"<<",
"hmirrorbits",
")",
";",
"hmirrorcount",
"++",
")",
"{",
"offs_t",
"hmirrorbase",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"hmirrorbits",
";",
"i",
"++",
")",
"if",
"(",
"hmirrorcount",
"&",
"(",
"1",
"<<",
"i",
")",
")",
"hmirrorbase",
"|=",
"hmirrorbit",
"[",
"i",
"]",
";",
"for",
"(",
"lmirrorcount",
"=",
"0",
";",
"lmirrorcount",
"<",
"(",
"1",
"<<",
"lmirrorbits",
")",
";",
"lmirrorcount",
"++",
")",
"{",
"offs_t",
"lmirrorbase",
"=",
"hmirrorbase",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"lmirrorbits",
";",
"i",
"++",
")",
"if",
"(",
"lmirrorcount",
"&",
"(",
"1",
"<<",
"i",
")",
")",
"lmirrorbase",
"|=",
"lmirrorbit",
"[",
"i",
"]",
";",
"direct_range_remove_intersecting",
"(",
"space",
",",
"bytestart",
"+",
"lmirrorbase",
",",
"byteend",
"+",
"lmirrorbase",
")",
";",
"}",
"cur_index",
"=",
"LEVEL1_INDEX",
"(",
"bytestart",
"+",
"hmirrorbase",
")",
";",
"if",
"(",
"cur_index",
"==",
"LEVEL1_INDEX",
"(",
"byteend",
"+",
"hmirrorbase",
")",
")",
"{",
"if",
"(",
"hmirrorcount",
"!=",
"0",
"&&",
"prev_entry",
"==",
"tabledata",
"->",
"table",
"[",
"cur_index",
"]",
")",
"{",
"VPRINTF",
"(",
"(",
"\"",
"\\n",
"\"",
",",
"cur_index",
"<<",
"LEVEL2_BITS",
",",
"prev_index",
"<<",
"LEVEL2_BITS",
")",
")",
";",
"if",
"(",
"tabledata",
"->",
"table",
"[",
"cur_index",
"]",
">=",
"SUBTABLE_BASE",
")",
"subtable_release",
"(",
"tabledata",
",",
"tabledata",
"->",
"table",
"[",
"cur_index",
"]",
")",
";",
"if",
"(",
"tabledata",
"->",
"table",
"[",
"prev_index",
"]",
">=",
"SUBTABLE_BASE",
")",
"subtable_realloc",
"(",
"tabledata",
",",
"tabledata",
"->",
"table",
"[",
"prev_index",
"]",
")",
";",
"tabledata",
"->",
"table",
"[",
"cur_index",
"]",
"=",
"tabledata",
"->",
"table",
"[",
"prev_index",
"]",
";",
"continue",
";",
"}",
"prev_index",
"=",
"cur_index",
";",
"prev_entry",
"=",
"tabledata",
"->",
"table",
"[",
"cur_index",
"]",
";",
"}",
"for",
"(",
"lmirrorcount",
"=",
"0",
";",
"lmirrorcount",
"<",
"(",
"1",
"<<",
"lmirrorbits",
")",
";",
"lmirrorcount",
"++",
")",
"{",
"offs_t",
"lmirrorbase",
"=",
"hmirrorbase",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"lmirrorbits",
";",
"i",
"++",
")",
"if",
"(",
"lmirrorcount",
"&",
"(",
"1",
"<<",
"i",
")",
")",
"lmirrorbase",
"|=",
"lmirrorbit",
"[",
"i",
"]",
";",
"table_populate_range",
"(",
"tabledata",
",",
"bytestart",
"+",
"lmirrorbase",
",",
"byteend",
"+",
"lmirrorbase",
",",
"handler",
")",
";",
"}",
"}",
"}"
] | table_populate_range_mirrored - assign a
memory handler to a range of addresses
including mirrors | [
"table_populate_range_mirrored",
"-",
"assign",
"a",
"memory",
"handler",
"to",
"a",
"range",
"of",
"addresses",
"including",
"mirrors"
] | [
"/* determine the mirror bits */",
"/* loop over mirrors in the level 2 table */",
"/* compute the base of this mirror */",
"/* invalidate any intersecting cached ranges */",
"/* compute the base of this mirror */",
"/* if this is not our first time through, and the level 2 entry matches the previous\r\n level 2 entry, just do a quick map and get out; note that this only works for entries\r\n which don't span multiple level 1 table entries */",
"/* release the subtable if the old value was a subtable */",
"/* reallocate the subtable if the new value is a subtable */",
"/* set the new value and short-circuit the mapping step */",
"/* loop over mirrors in the level 1 table */",
"/* compute the base of this mirror */",
"/* populate the tables */"
] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "tabledata",
"type": "address_table"
},
{
"param": "bytestart",
"type": "offs_t"
},
{
"param": "byteend",
"type": "offs_t"
},
{
"param": "bytemirror",
"type": "offs_t"
},
{
"param": "handler",
"type": "UINT8"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tabledata",
"type": "address_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bytestart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "byteend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bytemirror",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "handler",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | table_derive_range | UINT8 | static UINT8 table_derive_range(const address_table *table, offs_t byteaddress, offs_t *bytestart, offs_t *byteend)
{
UINT32 curentry, entry, curl1entry, l1entry;
const handler_data *handler;
offs_t minscan, maxscan;
/* look up the initial address to get the entry we care about */
entry = l1entry = table->table[LEVEL1_INDEX(byteaddress)];
if (l1entry >= SUBTABLE_BASE)
entry = table->table[LEVEL2_INDEX(l1entry, byteaddress)];
handler = table->handlers[entry];
/* use the bytemask of the entry to set minimum and maximum bounds */
minscan = handler->bytestart | ((byteaddress - handler->bytestart) & ~handler->bytemask);
maxscan = handler->byteend | ((byteaddress - handler->bytestart) & ~handler->bytemask);
/* first scan backwards to find the start address */
curl1entry = l1entry;
curentry = entry;
*bytestart = byteaddress;
while (1)
{
/* if we need to scan the subtable, do it */
if (curentry != curl1entry)
{
UINT32 minindex = LEVEL2_INDEX(curl1entry, 0);
UINT32 index;
/* scan backwards from the current address, until the previous entry doesn't match */
for (index = LEVEL2_INDEX(curl1entry, *bytestart); index > minindex; index--, *bytestart -= 1)
if (table->table[index - 1] != entry)
break;
/* if we didn't hit the beginning, then we're finished scanning */
if (index != minindex)
break;
}
/* move to the beginning of this L1 entry; stop at the minimum address */
*bytestart &= ~((1 << LEVEL2_BITS) - 1);
if (*bytestart <= minscan)
break;
/* look up the entry of the byte at the end of the previous L1 entry; if it doesn't match, stop */
curentry = curl1entry = table->table[LEVEL1_INDEX(*bytestart - 1)];
if (curl1entry >= SUBTABLE_BASE)
curentry = table->table[LEVEL2_INDEX(curl1entry, *bytestart - 1)];
if (curentry != entry)
break;
/* move into the previous entry and resume searching */
*bytestart -= 1;
}
/* then scan forwards to find the end address */
curl1entry = l1entry;
curentry = entry;
*byteend = byteaddress;
while (1)
{
/* if we need to scan the subtable, do it */
if (curentry != curl1entry)
{
UINT32 maxindex = LEVEL2_INDEX(curl1entry, ~0);
UINT32 index;
/* scan forwards from the current address, until the next entry doesn't match */
for (index = LEVEL2_INDEX(curl1entry, *byteend); index < maxindex; index++, *byteend += 1)
if (table->table[index + 1] != entry)
break;
/* if we didn't hit the end, then we're finished scanning */
if (index != maxindex)
break;
}
/* move to the end of this L1 entry; stop at the maximum address */
*byteend |= (1 << LEVEL2_BITS) - 1;
if (*byteend >= maxscan)
break;
/* look up the entry of the byte at the start of the next L1 entry; if it doesn't match, stop */
curentry = curl1entry = table->table[LEVEL1_INDEX(*byteend + 1)];
if (curl1entry >= SUBTABLE_BASE)
curentry = table->table[LEVEL2_INDEX(curl1entry, *byteend + 1)];
if (curentry != entry)
break;
/* move into the next entry and resume searching */
*byteend += 1;
}
return entry;
} | /*-------------------------------------------------
table_derive_range - look up the entry for
a memory range, and then compute the extent
of that range based on the lookup tables
-------------------------------------------------*/ | look up the entry for
a memory range, and then compute the extent
of that range based on the lookup tables | [
"look",
"up",
"the",
"entry",
"for",
"a",
"memory",
"range",
"and",
"then",
"compute",
"the",
"extent",
"of",
"that",
"range",
"based",
"on",
"the",
"lookup",
"tables"
] | static UINT8 table_derive_range(const address_table *table, offs_t byteaddress, offs_t *bytestart, offs_t *byteend)
{
UINT32 curentry, entry, curl1entry, l1entry;
const handler_data *handler;
offs_t minscan, maxscan;
entry = l1entry = table->table[LEVEL1_INDEX(byteaddress)];
if (l1entry >= SUBTABLE_BASE)
entry = table->table[LEVEL2_INDEX(l1entry, byteaddress)];
handler = table->handlers[entry];
minscan = handler->bytestart | ((byteaddress - handler->bytestart) & ~handler->bytemask);
maxscan = handler->byteend | ((byteaddress - handler->bytestart) & ~handler->bytemask);
curl1entry = l1entry;
curentry = entry;
*bytestart = byteaddress;
while (1)
{
if (curentry != curl1entry)
{
UINT32 minindex = LEVEL2_INDEX(curl1entry, 0);
UINT32 index;
for (index = LEVEL2_INDEX(curl1entry, *bytestart); index > minindex; index--, *bytestart -= 1)
if (table->table[index - 1] != entry)
break;
if (index != minindex)
break;
}
*bytestart &= ~((1 << LEVEL2_BITS) - 1);
if (*bytestart <= minscan)
break;
curentry = curl1entry = table->table[LEVEL1_INDEX(*bytestart - 1)];
if (curl1entry >= SUBTABLE_BASE)
curentry = table->table[LEVEL2_INDEX(curl1entry, *bytestart - 1)];
if (curentry != entry)
break;
*bytestart -= 1;
}
curl1entry = l1entry;
curentry = entry;
*byteend = byteaddress;
while (1)
{
if (curentry != curl1entry)
{
UINT32 maxindex = LEVEL2_INDEX(curl1entry, ~0);
UINT32 index;
for (index = LEVEL2_INDEX(curl1entry, *byteend); index < maxindex; index++, *byteend += 1)
if (table->table[index + 1] != entry)
break;
if (index != maxindex)
break;
}
*byteend |= (1 << LEVEL2_BITS) - 1;
if (*byteend >= maxscan)
break;
curentry = curl1entry = table->table[LEVEL1_INDEX(*byteend + 1)];
if (curl1entry >= SUBTABLE_BASE)
curentry = table->table[LEVEL2_INDEX(curl1entry, *byteend + 1)];
if (curentry != entry)
break;
*byteend += 1;
}
return entry;
} | [
"static",
"UINT8",
"table_derive_range",
"(",
"const",
"address_table",
"*",
"table",
",",
"offs_t",
"byteaddress",
",",
"offs_t",
"*",
"bytestart",
",",
"offs_t",
"*",
"byteend",
")",
"{",
"UINT32",
"curentry",
",",
"entry",
",",
"curl1entry",
",",
"l1entry",
";",
"const",
"handler_data",
"*",
"handler",
";",
"offs_t",
"minscan",
",",
"maxscan",
";",
"entry",
"=",
"l1entry",
"=",
"table",
"->",
"table",
"[",
"LEVEL1_INDEX",
"(",
"byteaddress",
")",
"]",
";",
"if",
"(",
"l1entry",
">=",
"SUBTABLE_BASE",
")",
"entry",
"=",
"table",
"->",
"table",
"[",
"LEVEL2_INDEX",
"(",
"l1entry",
",",
"byteaddress",
")",
"]",
";",
"handler",
"=",
"table",
"->",
"handlers",
"[",
"entry",
"]",
";",
"minscan",
"=",
"handler",
"->",
"bytestart",
"|",
"(",
"(",
"byteaddress",
"-",
"handler",
"->",
"bytestart",
")",
"&",
"~",
"handler",
"->",
"bytemask",
")",
";",
"maxscan",
"=",
"handler",
"->",
"byteend",
"|",
"(",
"(",
"byteaddress",
"-",
"handler",
"->",
"bytestart",
")",
"&",
"~",
"handler",
"->",
"bytemask",
")",
";",
"curl1entry",
"=",
"l1entry",
";",
"curentry",
"=",
"entry",
";",
"*",
"bytestart",
"=",
"byteaddress",
";",
"while",
"(",
"1",
")",
"{",
"if",
"(",
"curentry",
"!=",
"curl1entry",
")",
"{",
"UINT32",
"minindex",
"=",
"LEVEL2_INDEX",
"(",
"curl1entry",
",",
"0",
")",
";",
"UINT32",
"index",
";",
"for",
"(",
"index",
"=",
"LEVEL2_INDEX",
"(",
"curl1entry",
",",
"*",
"bytestart",
")",
";",
"index",
">",
"minindex",
";",
"index",
"--",
",",
"*",
"bytestart",
"-=",
"1",
")",
"if",
"(",
"table",
"->",
"table",
"[",
"index",
"-",
"1",
"]",
"!=",
"entry",
")",
"break",
";",
"if",
"(",
"index",
"!=",
"minindex",
")",
"break",
";",
"}",
"*",
"bytestart",
"&=",
"~",
"(",
"(",
"1",
"<<",
"LEVEL2_BITS",
")",
"-",
"1",
")",
";",
"if",
"(",
"*",
"bytestart",
"<=",
"minscan",
")",
"break",
";",
"curentry",
"=",
"curl1entry",
"=",
"table",
"->",
"table",
"[",
"LEVEL1_INDEX",
"(",
"*",
"bytestart",
"-",
"1",
")",
"]",
";",
"if",
"(",
"curl1entry",
">=",
"SUBTABLE_BASE",
")",
"curentry",
"=",
"table",
"->",
"table",
"[",
"LEVEL2_INDEX",
"(",
"curl1entry",
",",
"*",
"bytestart",
"-",
"1",
")",
"]",
";",
"if",
"(",
"curentry",
"!=",
"entry",
")",
"break",
";",
"*",
"bytestart",
"-=",
"1",
";",
"}",
"curl1entry",
"=",
"l1entry",
";",
"curentry",
"=",
"entry",
";",
"*",
"byteend",
"=",
"byteaddress",
";",
"while",
"(",
"1",
")",
"{",
"if",
"(",
"curentry",
"!=",
"curl1entry",
")",
"{",
"UINT32",
"maxindex",
"=",
"LEVEL2_INDEX",
"(",
"curl1entry",
",",
"~",
"0",
")",
";",
"UINT32",
"index",
";",
"for",
"(",
"index",
"=",
"LEVEL2_INDEX",
"(",
"curl1entry",
",",
"*",
"byteend",
")",
";",
"index",
"<",
"maxindex",
";",
"index",
"++",
",",
"*",
"byteend",
"+=",
"1",
")",
"if",
"(",
"table",
"->",
"table",
"[",
"index",
"+",
"1",
"]",
"!=",
"entry",
")",
"break",
";",
"if",
"(",
"index",
"!=",
"maxindex",
")",
"break",
";",
"}",
"*",
"byteend",
"|=",
"(",
"1",
"<<",
"LEVEL2_BITS",
")",
"-",
"1",
";",
"if",
"(",
"*",
"byteend",
">=",
"maxscan",
")",
"break",
";",
"curentry",
"=",
"curl1entry",
"=",
"table",
"->",
"table",
"[",
"LEVEL1_INDEX",
"(",
"*",
"byteend",
"+",
"1",
")",
"]",
";",
"if",
"(",
"curl1entry",
">=",
"SUBTABLE_BASE",
")",
"curentry",
"=",
"table",
"->",
"table",
"[",
"LEVEL2_INDEX",
"(",
"curl1entry",
",",
"*",
"byteend",
"+",
"1",
")",
"]",
";",
"if",
"(",
"curentry",
"!=",
"entry",
")",
"break",
";",
"*",
"byteend",
"+=",
"1",
";",
"}",
"return",
"entry",
";",
"}"
] | table_derive_range - look up the entry for
a memory range, and then compute the extent
of that range based on the lookup tables | [
"table_derive_range",
"-",
"look",
"up",
"the",
"entry",
"for",
"a",
"memory",
"range",
"and",
"then",
"compute",
"the",
"extent",
"of",
"that",
"range",
"based",
"on",
"the",
"lookup",
"tables"
] | [
"/* look up the initial address to get the entry we care about */",
"/* use the bytemask of the entry to set minimum and maximum bounds */",
"/* first scan backwards to find the start address */",
"/* if we need to scan the subtable, do it */",
"/* scan backwards from the current address, until the previous entry doesn't match */",
"/* if we didn't hit the beginning, then we're finished scanning */",
"/* move to the beginning of this L1 entry; stop at the minimum address */",
"/* look up the entry of the byte at the end of the previous L1 entry; if it doesn't match, stop */",
"/* move into the previous entry and resume searching */",
"/* then scan forwards to find the end address */",
"/* if we need to scan the subtable, do it */",
"/* scan forwards from the current address, until the next entry doesn't match */",
"/* if we didn't hit the end, then we're finished scanning */",
"/* move to the end of this L1 entry; stop at the maximum address */",
"/* look up the entry of the byte at the start of the next L1 entry; if it doesn't match, stop */",
"/* move into the next entry and resume searching */"
] | [
{
"param": "table",
"type": "address_table"
},
{
"param": "byteaddress",
"type": "offs_t"
},
{
"param": "bytestart",
"type": "offs_t"
},
{
"param": "byteend",
"type": "offs_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "table",
"type": "address_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "byteaddress",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bytestart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "byteend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | subtable_alloc | UINT8 | static UINT8 subtable_alloc(address_table *tabledata)
{
/* loop */
while (1)
{
UINT8 subindex;
/* find a subtable with a usecount of 0 */
for (subindex = 0; subindex < SUBTABLE_COUNT; subindex++)
if (tabledata->subtable[subindex].usecount == 0)
{
/* if this is past our allocation budget, allocate some more */
if (subindex >= tabledata->subtable_alloc)
{
UINT32 oldsize = (1 << LEVEL1_BITS) + (tabledata->subtable_alloc << LEVEL2_BITS);
tabledata->subtable_alloc += SUBTABLE_ALLOC;
UINT32 newsize = (1 << LEVEL1_BITS) + (tabledata->subtable_alloc << LEVEL2_BITS);
UINT8 *newtable = auto_alloc_array(tabledata->machine, UINT8, newsize);
memcpy(newtable, tabledata->table, oldsize);
auto_free(tabledata->machine, tabledata->table);
tabledata->table = newtable;
}
/* bump the usecount and return */
tabledata->subtable[subindex].usecount++;
return subindex + SUBTABLE_BASE;
}
/* merge any subtables we can */
if (!subtable_merge(tabledata))
fatalerror("Ran out of subtables!");
}
} | /*-------------------------------------------------
subtable_alloc - allocate a fresh subtable
and set its usecount to 1
-------------------------------------------------*/ | allocate a fresh subtable
and set its usecount to 1 | [
"allocate",
"a",
"fresh",
"subtable",
"and",
"set",
"its",
"usecount",
"to",
"1"
] | static UINT8 subtable_alloc(address_table *tabledata)
{
while (1)
{
UINT8 subindex;
for (subindex = 0; subindex < SUBTABLE_COUNT; subindex++)
if (tabledata->subtable[subindex].usecount == 0)
{
if (subindex >= tabledata->subtable_alloc)
{
UINT32 oldsize = (1 << LEVEL1_BITS) + (tabledata->subtable_alloc << LEVEL2_BITS);
tabledata->subtable_alloc += SUBTABLE_ALLOC;
UINT32 newsize = (1 << LEVEL1_BITS) + (tabledata->subtable_alloc << LEVEL2_BITS);
UINT8 *newtable = auto_alloc_array(tabledata->machine, UINT8, newsize);
memcpy(newtable, tabledata->table, oldsize);
auto_free(tabledata->machine, tabledata->table);
tabledata->table = newtable;
}
tabledata->subtable[subindex].usecount++;
return subindex + SUBTABLE_BASE;
}
if (!subtable_merge(tabledata))
fatalerror("Ran out of subtables!");
}
} | [
"static",
"UINT8",
"subtable_alloc",
"(",
"address_table",
"*",
"tabledata",
")",
"{",
"while",
"(",
"1",
")",
"{",
"UINT8",
"subindex",
";",
"for",
"(",
"subindex",
"=",
"0",
";",
"subindex",
"<",
"SUBTABLE_COUNT",
";",
"subindex",
"++",
")",
"if",
"(",
"tabledata",
"->",
"subtable",
"[",
"subindex",
"]",
".",
"usecount",
"==",
"0",
")",
"{",
"if",
"(",
"subindex",
">=",
"tabledata",
"->",
"subtable_alloc",
")",
"{",
"UINT32",
"oldsize",
"=",
"(",
"1",
"<<",
"LEVEL1_BITS",
")",
"+",
"(",
"tabledata",
"->",
"subtable_alloc",
"<<",
"LEVEL2_BITS",
")",
";",
"tabledata",
"->",
"subtable_alloc",
"+=",
"SUBTABLE_ALLOC",
";",
"UINT32",
"newsize",
"=",
"(",
"1",
"<<",
"LEVEL1_BITS",
")",
"+",
"(",
"tabledata",
"->",
"subtable_alloc",
"<<",
"LEVEL2_BITS",
")",
";",
"UINT8",
"*",
"newtable",
"=",
"auto_alloc_array",
"(",
"tabledata",
"->",
"machine",
",",
"UINT8",
",",
"newsize",
")",
";",
"memcpy",
"(",
"newtable",
",",
"tabledata",
"->",
"table",
",",
"oldsize",
")",
";",
"auto_free",
"(",
"tabledata",
"->",
"machine",
",",
"tabledata",
"->",
"table",
")",
";",
"tabledata",
"->",
"table",
"=",
"newtable",
";",
"}",
"tabledata",
"->",
"subtable",
"[",
"subindex",
"]",
".",
"usecount",
"++",
";",
"return",
"subindex",
"+",
"SUBTABLE_BASE",
";",
"}",
"if",
"(",
"!",
"subtable_merge",
"(",
"tabledata",
")",
")",
"fatalerror",
"(",
"\"",
"\"",
")",
";",
"}",
"}"
] | subtable_alloc - allocate a fresh subtable
and set its usecount to 1 | [
"subtable_alloc",
"-",
"allocate",
"a",
"fresh",
"subtable",
"and",
"set",
"its",
"usecount",
"to",
"1"
] | [
"/* loop */",
"/* find a subtable with a usecount of 0 */",
"/* if this is past our allocation budget, allocate some more */",
"/* bump the usecount and return */",
"/* merge any subtables we can */"
] | [
{
"param": "tabledata",
"type": "address_table"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tabledata",
"type": "address_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | subtable_realloc | void | static void subtable_realloc(address_table *tabledata, UINT8 subentry)
{
UINT8 subindex = subentry - SUBTABLE_BASE;
/* sanity check */
if (tabledata->subtable[subindex].usecount <= 0)
fatalerror("Called subtable_realloc on a table with a usecount of 0");
/* increment the usecount */
tabledata->subtable[subindex].usecount++;
} | /*-------------------------------------------------
subtable_realloc - increment the usecount on
a subtable
-------------------------------------------------*/ | increment the usecount on
a subtable | [
"increment",
"the",
"usecount",
"on",
"a",
"subtable"
] | static void subtable_realloc(address_table *tabledata, UINT8 subentry)
{
UINT8 subindex = subentry - SUBTABLE_BASE;
if (tabledata->subtable[subindex].usecount <= 0)
fatalerror("Called subtable_realloc on a table with a usecount of 0");
tabledata->subtable[subindex].usecount++;
} | [
"static",
"void",
"subtable_realloc",
"(",
"address_table",
"*",
"tabledata",
",",
"UINT8",
"subentry",
")",
"{",
"UINT8",
"subindex",
"=",
"subentry",
"-",
"SUBTABLE_BASE",
";",
"if",
"(",
"tabledata",
"->",
"subtable",
"[",
"subindex",
"]",
".",
"usecount",
"<=",
"0",
")",
"fatalerror",
"(",
"\"",
"\"",
")",
";",
"tabledata",
"->",
"subtable",
"[",
"subindex",
"]",
".",
"usecount",
"++",
";",
"}"
] | subtable_realloc - increment the usecount on
a subtable | [
"subtable_realloc",
"-",
"increment",
"the",
"usecount",
"on",
"a",
"subtable"
] | [
"/* sanity check */",
"/* increment the usecount */"
] | [
{
"param": "tabledata",
"type": "address_table"
},
{
"param": "subentry",
"type": "UINT8"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tabledata",
"type": "address_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "subentry",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | subtable_release | void | static void subtable_release(address_table *tabledata, UINT8 subentry)
{
UINT8 subindex = subentry - SUBTABLE_BASE;
/* sanity check */
if (tabledata->subtable[subindex].usecount <= 0)
fatalerror("Called subtable_release on a table with a usecount of 0");
/* decrement the usecount and clear the checksum if we're at 0 */
tabledata->subtable[subindex].usecount--;
if (tabledata->subtable[subindex].usecount == 0)
tabledata->subtable[subindex].checksum = 0;
} | /*-------------------------------------------------
subtable_release - decrement the usecount on
a subtable and free it if we're done
-------------------------------------------------*/ | decrement the usecount on
a subtable and free it if we're done | [
"decrement",
"the",
"usecount",
"on",
"a",
"subtable",
"and",
"free",
"it",
"if",
"we",
"'",
"re",
"done"
] | static void subtable_release(address_table *tabledata, UINT8 subentry)
{
UINT8 subindex = subentry - SUBTABLE_BASE;
if (tabledata->subtable[subindex].usecount <= 0)
fatalerror("Called subtable_release on a table with a usecount of 0");
tabledata->subtable[subindex].usecount--;
if (tabledata->subtable[subindex].usecount == 0)
tabledata->subtable[subindex].checksum = 0;
} | [
"static",
"void",
"subtable_release",
"(",
"address_table",
"*",
"tabledata",
",",
"UINT8",
"subentry",
")",
"{",
"UINT8",
"subindex",
"=",
"subentry",
"-",
"SUBTABLE_BASE",
";",
"if",
"(",
"tabledata",
"->",
"subtable",
"[",
"subindex",
"]",
".",
"usecount",
"<=",
"0",
")",
"fatalerror",
"(",
"\"",
"\"",
")",
";",
"tabledata",
"->",
"subtable",
"[",
"subindex",
"]",
".",
"usecount",
"--",
";",
"if",
"(",
"tabledata",
"->",
"subtable",
"[",
"subindex",
"]",
".",
"usecount",
"==",
"0",
")",
"tabledata",
"->",
"subtable",
"[",
"subindex",
"]",
".",
"checksum",
"=",
"0",
";",
"}"
] | subtable_release - decrement the usecount on
a subtable and free it if we're done | [
"subtable_release",
"-",
"decrement",
"the",
"usecount",
"on",
"a",
"subtable",
"and",
"free",
"it",
"if",
"we",
"'",
"re",
"done"
] | [
"/* sanity check */",
"/* decrement the usecount and clear the checksum if we're at 0 */"
] | [
{
"param": "tabledata",
"type": "address_table"
},
{
"param": "subentry",
"type": "UINT8"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tabledata",
"type": "address_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "subentry",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | subtable_open | UINT8 | static UINT8 *subtable_open(address_table *tabledata, offs_t l1index)
{
UINT8 subentry = tabledata->table[l1index];
/* if we don't have a subtable yet, allocate a new one */
if (subentry < SUBTABLE_BASE)
{
UINT8 newentry = subtable_alloc(tabledata);
memset(SUBTABLE_PTR(tabledata, newentry), subentry, 1 << LEVEL2_BITS);
tabledata->table[l1index] = newentry;
tabledata->subtable[newentry - SUBTABLE_BASE].checksum = (subentry + (subentry << 8) + (subentry << 16) + (subentry << 24)) * ((1 << LEVEL2_BITS)/4);
subentry = newentry;
}
/* if we're sharing this subtable, we also need to allocate a fresh copy */
else if (tabledata->subtable[subentry - SUBTABLE_BASE].usecount > 1)
{
UINT8 newentry = subtable_alloc(tabledata);
/* allocate may cause some additional merging -- look up the subentry again */
/* when we're done; it should still require a split */
subentry = tabledata->table[l1index];
assert(subentry >= SUBTABLE_BASE);
assert(tabledata->subtable[subentry - SUBTABLE_BASE].usecount > 1);
memcpy(SUBTABLE_PTR(tabledata, newentry), SUBTABLE_PTR(tabledata, subentry), 1 << LEVEL2_BITS);
subtable_release(tabledata, subentry);
tabledata->table[l1index] = newentry;
tabledata->subtable[newentry - SUBTABLE_BASE].checksum = tabledata->subtable[subentry - SUBTABLE_BASE].checksum;
subentry = newentry;
}
/* mark the table dirty */
tabledata->subtable[subentry - SUBTABLE_BASE].checksum_valid = 0;
/* return the pointer to the subtable */
return SUBTABLE_PTR(tabledata, subentry);
} | /*-------------------------------------------------
subtable_open - gain access to a subtable for
modification
-------------------------------------------------*/ | gain access to a subtable for
modification | [
"gain",
"access",
"to",
"a",
"subtable",
"for",
"modification"
] | static UINT8 *subtable_open(address_table *tabledata, offs_t l1index)
{
UINT8 subentry = tabledata->table[l1index];
if (subentry < SUBTABLE_BASE)
{
UINT8 newentry = subtable_alloc(tabledata);
memset(SUBTABLE_PTR(tabledata, newentry), subentry, 1 << LEVEL2_BITS);
tabledata->table[l1index] = newentry;
tabledata->subtable[newentry - SUBTABLE_BASE].checksum = (subentry + (subentry << 8) + (subentry << 16) + (subentry << 24)) * ((1 << LEVEL2_BITS)/4);
subentry = newentry;
}
else if (tabledata->subtable[subentry - SUBTABLE_BASE].usecount > 1)
{
UINT8 newentry = subtable_alloc(tabledata);
subentry = tabledata->table[l1index];
assert(subentry >= SUBTABLE_BASE);
assert(tabledata->subtable[subentry - SUBTABLE_BASE].usecount > 1);
memcpy(SUBTABLE_PTR(tabledata, newentry), SUBTABLE_PTR(tabledata, subentry), 1 << LEVEL2_BITS);
subtable_release(tabledata, subentry);
tabledata->table[l1index] = newentry;
tabledata->subtable[newentry - SUBTABLE_BASE].checksum = tabledata->subtable[subentry - SUBTABLE_BASE].checksum;
subentry = newentry;
}
tabledata->subtable[subentry - SUBTABLE_BASE].checksum_valid = 0;
return SUBTABLE_PTR(tabledata, subentry);
} | [
"static",
"UINT8",
"*",
"subtable_open",
"(",
"address_table",
"*",
"tabledata",
",",
"offs_t",
"l1index",
")",
"{",
"UINT8",
"subentry",
"=",
"tabledata",
"->",
"table",
"[",
"l1index",
"]",
";",
"if",
"(",
"subentry",
"<",
"SUBTABLE_BASE",
")",
"{",
"UINT8",
"newentry",
"=",
"subtable_alloc",
"(",
"tabledata",
")",
";",
"memset",
"(",
"SUBTABLE_PTR",
"(",
"tabledata",
",",
"newentry",
")",
",",
"subentry",
",",
"1",
"<<",
"LEVEL2_BITS",
")",
";",
"tabledata",
"->",
"table",
"[",
"l1index",
"]",
"=",
"newentry",
";",
"tabledata",
"->",
"subtable",
"[",
"newentry",
"-",
"SUBTABLE_BASE",
"]",
".",
"checksum",
"=",
"(",
"subentry",
"+",
"(",
"subentry",
"<<",
"8",
")",
"+",
"(",
"subentry",
"<<",
"16",
")",
"+",
"(",
"subentry",
"<<",
"24",
")",
")",
"*",
"(",
"(",
"1",
"<<",
"LEVEL2_BITS",
")",
"/",
"4",
")",
";",
"subentry",
"=",
"newentry",
";",
"}",
"else",
"if",
"(",
"tabledata",
"->",
"subtable",
"[",
"subentry",
"-",
"SUBTABLE_BASE",
"]",
".",
"usecount",
">",
"1",
")",
"{",
"UINT8",
"newentry",
"=",
"subtable_alloc",
"(",
"tabledata",
")",
";",
"subentry",
"=",
"tabledata",
"->",
"table",
"[",
"l1index",
"]",
";",
"assert",
"(",
"subentry",
">=",
"SUBTABLE_BASE",
")",
";",
"assert",
"(",
"tabledata",
"->",
"subtable",
"[",
"subentry",
"-",
"SUBTABLE_BASE",
"]",
".",
"usecount",
">",
"1",
")",
";",
"memcpy",
"(",
"SUBTABLE_PTR",
"(",
"tabledata",
",",
"newentry",
")",
",",
"SUBTABLE_PTR",
"(",
"tabledata",
",",
"subentry",
")",
",",
"1",
"<<",
"LEVEL2_BITS",
")",
";",
"subtable_release",
"(",
"tabledata",
",",
"subentry",
")",
";",
"tabledata",
"->",
"table",
"[",
"l1index",
"]",
"=",
"newentry",
";",
"tabledata",
"->",
"subtable",
"[",
"newentry",
"-",
"SUBTABLE_BASE",
"]",
".",
"checksum",
"=",
"tabledata",
"->",
"subtable",
"[",
"subentry",
"-",
"SUBTABLE_BASE",
"]",
".",
"checksum",
";",
"subentry",
"=",
"newentry",
";",
"}",
"tabledata",
"->",
"subtable",
"[",
"subentry",
"-",
"SUBTABLE_BASE",
"]",
".",
"checksum_valid",
"=",
"0",
";",
"return",
"SUBTABLE_PTR",
"(",
"tabledata",
",",
"subentry",
")",
";",
"}"
] | subtable_open - gain access to a subtable for
modification | [
"subtable_open",
"-",
"gain",
"access",
"to",
"a",
"subtable",
"for",
"modification"
] | [
"/* if we don't have a subtable yet, allocate a new one */",
"/* if we're sharing this subtable, we also need to allocate a fresh copy */",
"/* allocate may cause some additional merging -- look up the subentry again */",
"/* when we're done; it should still require a split */",
"/* mark the table dirty */",
"/* return the pointer to the subtable */"
] | [
{
"param": "tabledata",
"type": "address_table"
},
{
"param": "l1index",
"type": "offs_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tabledata",
"type": "address_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "l1index",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | direct_range_find | direct_range | static direct_range *direct_range_find(address_space *space, offs_t byteaddress, UINT8 *entry)
{
direct_range **rangelistptr;
direct_range **rangeptr;
direct_range *range;
/* determine which entry */
byteaddress &= space->bytemask;
*entry = space->read.table[LEVEL1_INDEX(byteaddress)];
if (*entry >= SUBTABLE_BASE)
*entry = space->read.table[LEVEL2_INDEX(*entry, byteaddress)];
rangelistptr = &space->direct.rangelist[*entry];
/* scan our table */
for (rangeptr = rangelistptr; *rangeptr != NULL; rangeptr = &(*rangeptr)->next)
if (byteaddress >= (*rangeptr)->bytestart && byteaddress <= (*rangeptr)->byteend)
{
/* found a match; move us to the head of the list if we're not already there */
range = *rangeptr;
if (range != *rangelistptr)
{
*rangeptr = range->next;
range->next = *rangelistptr;
*rangelistptr = range;
}
return range;
}
/* didn't find out; allocate a new one */
range = space->direct.freerangelist;
if (range != NULL)
space->direct.freerangelist = range->next;
else
range = auto_alloc(space->machine, direct_range);
/* fill in the range */
table_derive_range(&space->read, byteaddress, &range->bytestart, &range->byteend);
range->next = *rangelistptr;
*rangelistptr = range;
return range;
} | /*-------------------------------------------------
direct_range_find - find a byte address in
a range
-------------------------------------------------*/ | find a byte address in
a range | [
"find",
"a",
"byte",
"address",
"in",
"a",
"range"
] | static direct_range *direct_range_find(address_space *space, offs_t byteaddress, UINT8 *entry)
{
direct_range **rangelistptr;
direct_range **rangeptr;
direct_range *range;
byteaddress &= space->bytemask;
*entry = space->read.table[LEVEL1_INDEX(byteaddress)];
if (*entry >= SUBTABLE_BASE)
*entry = space->read.table[LEVEL2_INDEX(*entry, byteaddress)];
rangelistptr = &space->direct.rangelist[*entry];
for (rangeptr = rangelistptr; *rangeptr != NULL; rangeptr = &(*rangeptr)->next)
if (byteaddress >= (*rangeptr)->bytestart && byteaddress <= (*rangeptr)->byteend)
{
range = *rangeptr;
if (range != *rangelistptr)
{
*rangeptr = range->next;
range->next = *rangelistptr;
*rangelistptr = range;
}
return range;
}
range = space->direct.freerangelist;
if (range != NULL)
space->direct.freerangelist = range->next;
else
range = auto_alloc(space->machine, direct_range);
table_derive_range(&space->read, byteaddress, &range->bytestart, &range->byteend);
range->next = *rangelistptr;
*rangelistptr = range;
return range;
} | [
"static",
"direct_range",
"*",
"direct_range_find",
"(",
"address_space",
"*",
"space",
",",
"offs_t",
"byteaddress",
",",
"UINT8",
"*",
"entry",
")",
"{",
"direct_range",
"*",
"*",
"rangelistptr",
";",
"direct_range",
"*",
"*",
"rangeptr",
";",
"direct_range",
"*",
"range",
";",
"byteaddress",
"&=",
"space",
"->",
"bytemask",
";",
"*",
"entry",
"=",
"space",
"->",
"read",
".",
"table",
"[",
"LEVEL1_INDEX",
"(",
"byteaddress",
")",
"]",
";",
"if",
"(",
"*",
"entry",
">=",
"SUBTABLE_BASE",
")",
"*",
"entry",
"=",
"space",
"->",
"read",
".",
"table",
"[",
"LEVEL2_INDEX",
"(",
"*",
"entry",
",",
"byteaddress",
")",
"]",
";",
"rangelistptr",
"=",
"&",
"space",
"->",
"direct",
".",
"rangelist",
"[",
"*",
"entry",
"]",
";",
"for",
"(",
"rangeptr",
"=",
"rangelistptr",
";",
"*",
"rangeptr",
"!=",
"NULL",
";",
"rangeptr",
"=",
"&",
"(",
"*",
"rangeptr",
")",
"->",
"next",
")",
"if",
"(",
"byteaddress",
">=",
"(",
"*",
"rangeptr",
")",
"->",
"bytestart",
"&&",
"byteaddress",
"<=",
"(",
"*",
"rangeptr",
")",
"->",
"byteend",
")",
"{",
"range",
"=",
"*",
"rangeptr",
";",
"if",
"(",
"range",
"!=",
"*",
"rangelistptr",
")",
"{",
"*",
"rangeptr",
"=",
"range",
"->",
"next",
";",
"range",
"->",
"next",
"=",
"*",
"rangelistptr",
";",
"*",
"rangelistptr",
"=",
"range",
";",
"}",
"return",
"range",
";",
"}",
"range",
"=",
"space",
"->",
"direct",
".",
"freerangelist",
";",
"if",
"(",
"range",
"!=",
"NULL",
")",
"space",
"->",
"direct",
".",
"freerangelist",
"=",
"range",
"->",
"next",
";",
"else",
"range",
"=",
"auto_alloc",
"(",
"space",
"->",
"machine",
",",
"direct_range",
")",
";",
"table_derive_range",
"(",
"&",
"space",
"->",
"read",
",",
"byteaddress",
",",
"&",
"range",
"->",
"bytestart",
",",
"&",
"range",
"->",
"byteend",
")",
";",
"range",
"->",
"next",
"=",
"*",
"rangelistptr",
";",
"*",
"rangelistptr",
"=",
"range",
";",
"return",
"range",
";",
"}"
] | direct_range_find - find a byte address in
a range | [
"direct_range_find",
"-",
"find",
"a",
"byte",
"address",
"in",
"a",
"range"
] | [
"/* determine which entry */",
"/* scan our table */",
"/* found a match; move us to the head of the list if we're not already there */",
"/* didn't find out; allocate a new one */",
"/* fill in the range */"
] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "byteaddress",
"type": "offs_t"
},
{
"param": "entry",
"type": "UINT8"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "byteaddress",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "entry",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | direct_range_remove_intersecting | void | static void direct_range_remove_intersecting(address_space *space, offs_t bytestart, offs_t byteend)
{
int entry;
/* loop over all entries */
for (entry = 0; entry < ARRAY_LENGTH(space->read.handlers); entry++)
{
direct_range **rangeptr, **nextrangeptr;
/* loop over all ranges in this entry's list */
for (nextrangeptr = rangeptr = &space->direct.rangelist[entry]; *rangeptr != NULL; rangeptr = nextrangeptr)
{
/* if we intersect, remove and add to the free range list */
if (bytestart <= (*rangeptr)->byteend && byteend >= (*rangeptr)->bytestart)
{
direct_range *range = *rangeptr;
*rangeptr = range->next;
range->next = space->direct.freerangelist;
space->direct.freerangelist = range;
}
/* otherwise advance to the next in the list */
else
nextrangeptr = &(*rangeptr)->next;
}
}
} | /*-------------------------------------------------
direct_range_remove_intersecting - remove
all cached ranges that intersect the given
address range
-------------------------------------------------*/ | remove
all cached ranges that intersect the given
address range | [
"remove",
"all",
"cached",
"ranges",
"that",
"intersect",
"the",
"given",
"address",
"range"
] | static void direct_range_remove_intersecting(address_space *space, offs_t bytestart, offs_t byteend)
{
int entry;
for (entry = 0; entry < ARRAY_LENGTH(space->read.handlers); entry++)
{
direct_range **rangeptr, **nextrangeptr;
for (nextrangeptr = rangeptr = &space->direct.rangelist[entry]; *rangeptr != NULL; rangeptr = nextrangeptr)
{
if (bytestart <= (*rangeptr)->byteend && byteend >= (*rangeptr)->bytestart)
{
direct_range *range = *rangeptr;
*rangeptr = range->next;
range->next = space->direct.freerangelist;
space->direct.freerangelist = range;
}
else
nextrangeptr = &(*rangeptr)->next;
}
}
} | [
"static",
"void",
"direct_range_remove_intersecting",
"(",
"address_space",
"*",
"space",
",",
"offs_t",
"bytestart",
",",
"offs_t",
"byteend",
")",
"{",
"int",
"entry",
";",
"for",
"(",
"entry",
"=",
"0",
";",
"entry",
"<",
"ARRAY_LENGTH",
"(",
"space",
"->",
"read",
".",
"handlers",
")",
";",
"entry",
"++",
")",
"{",
"direct_range",
"*",
"*",
"rangeptr",
",",
"*",
"*",
"nextrangeptr",
";",
"for",
"(",
"nextrangeptr",
"=",
"rangeptr",
"=",
"&",
"space",
"->",
"direct",
".",
"rangelist",
"[",
"entry",
"]",
";",
"*",
"rangeptr",
"!=",
"NULL",
";",
"rangeptr",
"=",
"nextrangeptr",
")",
"{",
"if",
"(",
"bytestart",
"<=",
"(",
"*",
"rangeptr",
")",
"->",
"byteend",
"&&",
"byteend",
">=",
"(",
"*",
"rangeptr",
")",
"->",
"bytestart",
")",
"{",
"direct_range",
"*",
"range",
"=",
"*",
"rangeptr",
";",
"*",
"rangeptr",
"=",
"range",
"->",
"next",
";",
"range",
"->",
"next",
"=",
"space",
"->",
"direct",
".",
"freerangelist",
";",
"space",
"->",
"direct",
".",
"freerangelist",
"=",
"range",
";",
"}",
"else",
"nextrangeptr",
"=",
"&",
"(",
"*",
"rangeptr",
")",
"->",
"next",
";",
"}",
"}",
"}"
] | direct_range_remove_intersecting - remove
all cached ranges that intersect the given
address range | [
"direct_range_remove_intersecting",
"-",
"remove",
"all",
"cached",
"ranges",
"that",
"intersect",
"the",
"given",
"address",
"range"
] | [
"/* loop over all entries */",
"/* loop over all ranges in this entry's list */",
"/* if we intersect, remove and add to the free range list */",
"/* otherwise advance to the next in the list */"
] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "bytestart",
"type": "offs_t"
},
{
"param": "byteend",
"type": "offs_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bytestart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "byteend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | block_allocate | void | static void *block_allocate(const address_space *space, offs_t bytestart, offs_t byteend, void *memory)
{
memory_private *memdata = space->machine->memory_data;
int allocatemem = (memory == NULL);
memory_block *block;
size_t bytestoalloc;
const region_info *region;
VPRINTF(("block_allocate('%s',%s,%08X,%08X,%p)\n", space->cpu->tag(), space->name, bytestart, byteend, memory));
/* determine how much memory to allocate for this */
bytestoalloc = sizeof(*block);
if (allocatemem)
bytestoalloc += byteend - bytestart + 1;
/* allocate and clear the memory */
block = (memory_block *)auto_alloc_array_clear(space->machine, UINT8, bytestoalloc);
if (allocatemem)
memory = block + 1;
/* register for saving, but only if we're not part of a memory region */
for (region = space->machine->m_regionlist.first(); region != NULL; region = region->next())
{
if ((UINT8 *)memory >= region->base() && ((UINT8 *)memory + (byteend - bytestart + 1)) < region->end())
{
VPRINTF(("skipping save of this memory block as it is covered by a memory region\n"));
break;
}
}
/* if we didn't find a match, register */
if (region == NULL)
{
int bytes_per_element = space->dbits/8;
char name[256];
sprintf(name, "%08x-%08x", bytestart, byteend);
state_save_register_memory(space->machine, "memory", space->cpu->tag(), space->spacenum, name, memory, bytes_per_element, (UINT32)(byteend - bytestart + 1) / bytes_per_element, __FILE__, __LINE__);
}
/* fill in the tracking block */
block->space = space;
block->isallocated = allocatemem;
block->bytestart = bytestart;
block->byteend = byteend;
block->data = (UINT8 *)memory;
/* attach us to the head of the list */
block->next = memdata->memory_block_list;
memdata->memory_block_list = block;
return memory;
} | /*-------------------------------------------------
block_allocate - allocate a single
memory block of data
-------------------------------------------------*/ | allocate a single
memory block of data | [
"allocate",
"a",
"single",
"memory",
"block",
"of",
"data"
] | static void *block_allocate(const address_space *space, offs_t bytestart, offs_t byteend, void *memory)
{
memory_private *memdata = space->machine->memory_data;
int allocatemem = (memory == NULL);
memory_block *block;
size_t bytestoalloc;
const region_info *region;
VPRINTF(("block_allocate('%s',%s,%08X,%08X,%p)\n", space->cpu->tag(), space->name, bytestart, byteend, memory));
bytestoalloc = sizeof(*block);
if (allocatemem)
bytestoalloc += byteend - bytestart + 1;
block = (memory_block *)auto_alloc_array_clear(space->machine, UINT8, bytestoalloc);
if (allocatemem)
memory = block + 1;
for (region = space->machine->m_regionlist.first(); region != NULL; region = region->next())
{
if ((UINT8 *)memory >= region->base() && ((UINT8 *)memory + (byteend - bytestart + 1)) < region->end())
{
VPRINTF(("skipping save of this memory block as it is covered by a memory region\n"));
break;
}
}
if (region == NULL)
{
int bytes_per_element = space->dbits/8;
char name[256];
sprintf(name, "%08x-%08x", bytestart, byteend);
state_save_register_memory(space->machine, "memory", space->cpu->tag(), space->spacenum, name, memory, bytes_per_element, (UINT32)(byteend - bytestart + 1) / bytes_per_element, __FILE__, __LINE__);
}
block->space = space;
block->isallocated = allocatemem;
block->bytestart = bytestart;
block->byteend = byteend;
block->data = (UINT8 *)memory;
block->next = memdata->memory_block_list;
memdata->memory_block_list = block;
return memory;
} | [
"static",
"void",
"*",
"block_allocate",
"(",
"const",
"address_space",
"*",
"space",
",",
"offs_t",
"bytestart",
",",
"offs_t",
"byteend",
",",
"void",
"*",
"memory",
")",
"{",
"memory_private",
"*",
"memdata",
"=",
"space",
"->",
"machine",
"->",
"memory_data",
";",
"int",
"allocatemem",
"=",
"(",
"memory",
"==",
"NULL",
")",
";",
"memory_block",
"*",
"block",
";",
"size_t",
"bytestoalloc",
";",
"const",
"region_info",
"*",
"region",
";",
"VPRINTF",
"(",
"(",
"\"",
"\\n",
"\"",
",",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
",",
"space",
"->",
"name",
",",
"bytestart",
",",
"byteend",
",",
"memory",
")",
")",
";",
"bytestoalloc",
"=",
"sizeof",
"(",
"*",
"block",
")",
";",
"if",
"(",
"allocatemem",
")",
"bytestoalloc",
"+=",
"byteend",
"-",
"bytestart",
"+",
"1",
";",
"block",
"=",
"(",
"memory_block",
"*",
")",
"auto_alloc_array_clear",
"(",
"space",
"->",
"machine",
",",
"UINT8",
",",
"bytestoalloc",
")",
";",
"if",
"(",
"allocatemem",
")",
"memory",
"=",
"block",
"+",
"1",
";",
"for",
"(",
"region",
"=",
"space",
"->",
"machine",
"->",
"m_regionlist",
".",
"first",
"(",
")",
";",
"region",
"!=",
"NULL",
";",
"region",
"=",
"region",
"->",
"next",
"(",
")",
")",
"{",
"if",
"(",
"(",
"UINT8",
"*",
")",
"memory",
">=",
"region",
"->",
"base",
"(",
")",
"&&",
"(",
"(",
"UINT8",
"*",
")",
"memory",
"+",
"(",
"byteend",
"-",
"bytestart",
"+",
"1",
")",
")",
"<",
"region",
"->",
"end",
"(",
")",
")",
"{",
"VPRINTF",
"(",
"(",
"\"",
"\\n",
"\"",
")",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"region",
"==",
"NULL",
")",
"{",
"int",
"bytes_per_element",
"=",
"space",
"->",
"dbits",
"/",
"8",
";",
"char",
"name",
"[",
"256",
"]",
";",
"sprintf",
"(",
"name",
",",
"\"",
"\"",
",",
"bytestart",
",",
"byteend",
")",
";",
"state_save_register_memory",
"(",
"space",
"->",
"machine",
",",
"\"",
"\"",
",",
"space",
"->",
"cpu",
"->",
"tag",
"(",
")",
",",
"space",
"->",
"spacenum",
",",
"name",
",",
"memory",
",",
"bytes_per_element",
",",
"(",
"UINT32",
")",
"(",
"byteend",
"-",
"bytestart",
"+",
"1",
")",
"/",
"bytes_per_element",
",",
"__FILE__",
",",
"__LINE__",
")",
";",
"}",
"block",
"->",
"space",
"=",
"space",
";",
"block",
"->",
"isallocated",
"=",
"allocatemem",
";",
"block",
"->",
"bytestart",
"=",
"bytestart",
";",
"block",
"->",
"byteend",
"=",
"byteend",
";",
"block",
"->",
"data",
"=",
"(",
"UINT8",
"*",
")",
"memory",
";",
"block",
"->",
"next",
"=",
"memdata",
"->",
"memory_block_list",
";",
"memdata",
"->",
"memory_block_list",
"=",
"block",
";",
"return",
"memory",
";",
"}"
] | block_allocate - allocate a single
memory block of data | [
"block_allocate",
"-",
"allocate",
"a",
"single",
"memory",
"block",
"of",
"data"
] | [
"/* determine how much memory to allocate for this */",
"/* allocate and clear the memory */",
"/* register for saving, but only if we're not part of a memory region */",
"/* if we didn't find a match, register */",
"/* fill in the tracking block */",
"/* attach us to the head of the list */"
] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "bytestart",
"type": "offs_t"
},
{
"param": "byteend",
"type": "offs_t"
},
{
"param": "memory",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bytestart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "byteend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "memory",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | block_assign_intersecting | address_map_entry | static address_map_entry *block_assign_intersecting(address_space *space, offs_t bytestart, offs_t byteend, UINT8 *base)
{
memory_private *memdata = space->machine->memory_data;
address_map_entry *entry, *unassigned = NULL;
/* loop over the adjusted map and assign memory to any blocks we can */
for (entry = space->map->m_entrylist; entry != NULL; entry = entry->m_next)
{
/* if we haven't assigned this block yet, see if we have a mapped shared pointer for it */
if (entry->m_memory == NULL && entry->m_share != NULL)
{
void *shareptr = memdata->sharemap.find(entry->m_share);
if (shareptr != UNMAPPED_SHARE_PTR)
{
entry->m_memory = shareptr;
VPRINTF(("memory range %08X-%08X -> shared_ptr '%s' [%p]\n", entry->m_addrstart, entry->m_addrend, entry->m_share, entry->m_memory));
}
}
/* otherwise, look for a match in this block */
if (entry->m_memory == NULL && entry->m_bytestart >= bytestart && entry->m_byteend <= byteend)
{
entry->m_memory = base + (entry->m_bytestart - bytestart);
VPRINTF(("memory range %08X-%08X -> found in block from %08X-%08X [%p]\n", entry->m_addrstart, entry->m_addrend, bytestart, byteend, entry->m_memory));
}
/* if we're the first match on a shared pointer, assign it now */
if (entry->m_memory != NULL && entry->m_share != NULL)
{
void *shareptr = memdata->sharemap.find(entry->m_share);
if (shareptr == UNMAPPED_SHARE_PTR)
memdata->sharemap.add(entry->m_share, entry->m_memory, TRUE);
}
/* keep track of the first unassigned entry */
if (entry->m_memory == NULL && unassigned == NULL && space_needs_backing_store(space, entry))
unassigned = entry;
}
return unassigned;
} | /*-------------------------------------------------
block_assign_intersecting - find all
intersecting blocks and assign their pointers
-------------------------------------------------*/ | find all
intersecting blocks and assign their pointers | [
"find",
"all",
"intersecting",
"blocks",
"and",
"assign",
"their",
"pointers"
] | static address_map_entry *block_assign_intersecting(address_space *space, offs_t bytestart, offs_t byteend, UINT8 *base)
{
memory_private *memdata = space->machine->memory_data;
address_map_entry *entry, *unassigned = NULL;
for (entry = space->map->m_entrylist; entry != NULL; entry = entry->m_next)
{
if (entry->m_memory == NULL && entry->m_share != NULL)
{
void *shareptr = memdata->sharemap.find(entry->m_share);
if (shareptr != UNMAPPED_SHARE_PTR)
{
entry->m_memory = shareptr;
VPRINTF(("memory range %08X-%08X -> shared_ptr '%s' [%p]\n", entry->m_addrstart, entry->m_addrend, entry->m_share, entry->m_memory));
}
}
if (entry->m_memory == NULL && entry->m_bytestart >= bytestart && entry->m_byteend <= byteend)
{
entry->m_memory = base + (entry->m_bytestart - bytestart);
VPRINTF(("memory range %08X-%08X -> found in block from %08X-%08X [%p]\n", entry->m_addrstart, entry->m_addrend, bytestart, byteend, entry->m_memory));
}
if (entry->m_memory != NULL && entry->m_share != NULL)
{
void *shareptr = memdata->sharemap.find(entry->m_share);
if (shareptr == UNMAPPED_SHARE_PTR)
memdata->sharemap.add(entry->m_share, entry->m_memory, TRUE);
}
if (entry->m_memory == NULL && unassigned == NULL && space_needs_backing_store(space, entry))
unassigned = entry;
}
return unassigned;
} | [
"static",
"address_map_entry",
"*",
"block_assign_intersecting",
"(",
"address_space",
"*",
"space",
",",
"offs_t",
"bytestart",
",",
"offs_t",
"byteend",
",",
"UINT8",
"*",
"base",
")",
"{",
"memory_private",
"*",
"memdata",
"=",
"space",
"->",
"machine",
"->",
"memory_data",
";",
"address_map_entry",
"*",
"entry",
",",
"*",
"unassigned",
"=",
"NULL",
";",
"for",
"(",
"entry",
"=",
"space",
"->",
"map",
"->",
"m_entrylist",
";",
"entry",
"!=",
"NULL",
";",
"entry",
"=",
"entry",
"->",
"m_next",
")",
"{",
"if",
"(",
"entry",
"->",
"m_memory",
"==",
"NULL",
"&&",
"entry",
"->",
"m_share",
"!=",
"NULL",
")",
"{",
"void",
"*",
"shareptr",
"=",
"memdata",
"->",
"sharemap",
".",
"find",
"(",
"entry",
"->",
"m_share",
")",
";",
"if",
"(",
"shareptr",
"!=",
"UNMAPPED_SHARE_PTR",
")",
"{",
"entry",
"->",
"m_memory",
"=",
"shareptr",
";",
"VPRINTF",
"(",
"(",
"\"",
"\\n",
"\"",
",",
"entry",
"->",
"m_addrstart",
",",
"entry",
"->",
"m_addrend",
",",
"entry",
"->",
"m_share",
",",
"entry",
"->",
"m_memory",
")",
")",
";",
"}",
"}",
"if",
"(",
"entry",
"->",
"m_memory",
"==",
"NULL",
"&&",
"entry",
"->",
"m_bytestart",
">=",
"bytestart",
"&&",
"entry",
"->",
"m_byteend",
"<=",
"byteend",
")",
"{",
"entry",
"->",
"m_memory",
"=",
"base",
"+",
"(",
"entry",
"->",
"m_bytestart",
"-",
"bytestart",
")",
";",
"VPRINTF",
"(",
"(",
"\"",
"\\n",
"\"",
",",
"entry",
"->",
"m_addrstart",
",",
"entry",
"->",
"m_addrend",
",",
"bytestart",
",",
"byteend",
",",
"entry",
"->",
"m_memory",
")",
")",
";",
"}",
"if",
"(",
"entry",
"->",
"m_memory",
"!=",
"NULL",
"&&",
"entry",
"->",
"m_share",
"!=",
"NULL",
")",
"{",
"void",
"*",
"shareptr",
"=",
"memdata",
"->",
"sharemap",
".",
"find",
"(",
"entry",
"->",
"m_share",
")",
";",
"if",
"(",
"shareptr",
"==",
"UNMAPPED_SHARE_PTR",
")",
"memdata",
"->",
"sharemap",
".",
"add",
"(",
"entry",
"->",
"m_share",
",",
"entry",
"->",
"m_memory",
",",
"TRUE",
")",
";",
"}",
"if",
"(",
"entry",
"->",
"m_memory",
"==",
"NULL",
"&&",
"unassigned",
"==",
"NULL",
"&&",
"space_needs_backing_store",
"(",
"space",
",",
"entry",
")",
")",
"unassigned",
"=",
"entry",
";",
"}",
"return",
"unassigned",
";",
"}"
] | block_assign_intersecting - find all
intersecting blocks and assign their pointers | [
"block_assign_intersecting",
"-",
"find",
"all",
"intersecting",
"blocks",
"and",
"assign",
"their",
"pointers"
] | [
"/* loop over the adjusted map and assign memory to any blocks we can */",
"/* if we haven't assigned this block yet, see if we have a mapped shared pointer for it */",
"/* otherwise, look for a match in this block */",
"/* if we're the first match on a shared pointer, assign it now */",
"/* keep track of the first unassigned entry */"
] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "bytestart",
"type": "offs_t"
},
{
"param": "byteend",
"type": "offs_t"
},
{
"param": "base",
"type": "UINT8"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bytestart",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "byteend",
"type": "offs_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "base",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | handler_to_string | char | static const char *handler_to_string(const address_space *space, const address_table *table, UINT8 entry)
{
static const char *const strings[] =
{
"invalid", "bank 1", "bank 2", "bank 3",
"bank 4", "bank 5", "bank 6", "bank 7",
"bank 8", "bank 9", "bank 10", "bank 11",
"bank 12", "bank 13", "bank 14", "bank 15",
"bank 16", "bank 17", "bank 18", "bank 19",
"bank 20", "bank 21", "bank 22", "bank 23",
"bank 24", "bank 25", "bank 26", "bank 27",
"bank 28", "bank 29", "bank 30", "bank 31",
"bank 32", "bank 33", "bank 34", "bank 35",
"bank 36", "bank 37", "bank 38", "bank 39",
"bank 40", "bank 41", "bank 42", "bank 43",
"bank 44", "bank 45", "bank 46", "bank 47",
"bank 48", "bank 49", "bank 50", "bank 51",
"bank 52", "bank 53", "bank 54", "bank 55",
"bank 56", "bank 57", "bank 58", "bank 59",
"bank 60", "bank 61", "bank 62", "bank 63",
"bank 64", "bank 65", "bank 66", "bank 67",
"bank 68", "bank 69", "bank 70", "bank 71",
"bank 72", "bank 73", "bank 74", "bank 75",
"bank 76", "bank 77", "bank 78", "bank 79",
"bank 80", "bank 81", "bank 82", "bank 83",
"bank 84", "bank 85", "bank 86", "bank 87",
"bank 88", "bank 89", "bank 90", "bank 91",
"bank 92", "bank 93", "bank 94", "bank 95",
"bank 96", "bank 97", "bank 98", "bank 99",
"bank 100", "bank 101", "bank 102", "bank 103",
"bank 104", "bank 105", "bank 106", "bank 107",
"bank 108", "bank 109", "bank 110", "bank 111",
"bank 112", "bank 113", "bank 114", "bank 115",
"bank 116", "bank 117", "bank 118", "bank 119",
"bank 120", "bank 121", "bank 122", "ram",
"rom", "nop", "unmapped", "watchpoint"
};
/* banks have names */
if (entry >= STATIC_BANK1 && entry <= STATIC_BANKMAX)
{
bank_info *info;
for (info = space->machine->memory_data->banklist; info != NULL; info = info->next)
if (info->index == entry)
return info->name;
}
/* constant strings for lower entries */
if (entry < STATIC_COUNT)
return strings[entry];
else
return (table->handlers[entry]->name != NULL) ? table->handlers[entry]->name : "???";
} | /*-------------------------------------------------
handler_to_string - return friendly string
description of a handler
-------------------------------------------------*/ | return friendly string
description of a handler | [
"return",
"friendly",
"string",
"description",
"of",
"a",
"handler"
] | static const char *handler_to_string(const address_space *space, const address_table *table, UINT8 entry)
{
static const char *const strings[] =
{
"invalid", "bank 1", "bank 2", "bank 3",
"bank 4", "bank 5", "bank 6", "bank 7",
"bank 8", "bank 9", "bank 10", "bank 11",
"bank 12", "bank 13", "bank 14", "bank 15",
"bank 16", "bank 17", "bank 18", "bank 19",
"bank 20", "bank 21", "bank 22", "bank 23",
"bank 24", "bank 25", "bank 26", "bank 27",
"bank 28", "bank 29", "bank 30", "bank 31",
"bank 32", "bank 33", "bank 34", "bank 35",
"bank 36", "bank 37", "bank 38", "bank 39",
"bank 40", "bank 41", "bank 42", "bank 43",
"bank 44", "bank 45", "bank 46", "bank 47",
"bank 48", "bank 49", "bank 50", "bank 51",
"bank 52", "bank 53", "bank 54", "bank 55",
"bank 56", "bank 57", "bank 58", "bank 59",
"bank 60", "bank 61", "bank 62", "bank 63",
"bank 64", "bank 65", "bank 66", "bank 67",
"bank 68", "bank 69", "bank 70", "bank 71",
"bank 72", "bank 73", "bank 74", "bank 75",
"bank 76", "bank 77", "bank 78", "bank 79",
"bank 80", "bank 81", "bank 82", "bank 83",
"bank 84", "bank 85", "bank 86", "bank 87",
"bank 88", "bank 89", "bank 90", "bank 91",
"bank 92", "bank 93", "bank 94", "bank 95",
"bank 96", "bank 97", "bank 98", "bank 99",
"bank 100", "bank 101", "bank 102", "bank 103",
"bank 104", "bank 105", "bank 106", "bank 107",
"bank 108", "bank 109", "bank 110", "bank 111",
"bank 112", "bank 113", "bank 114", "bank 115",
"bank 116", "bank 117", "bank 118", "bank 119",
"bank 120", "bank 121", "bank 122", "ram",
"rom", "nop", "unmapped", "watchpoint"
};
if (entry >= STATIC_BANK1 && entry <= STATIC_BANKMAX)
{
bank_info *info;
for (info = space->machine->memory_data->banklist; info != NULL; info = info->next)
if (info->index == entry)
return info->name;
}
if (entry < STATIC_COUNT)
return strings[entry];
else
return (table->handlers[entry]->name != NULL) ? table->handlers[entry]->name : "???";
} | [
"static",
"const",
"char",
"*",
"handler_to_string",
"(",
"const",
"address_space",
"*",
"space",
",",
"const",
"address_table",
"*",
"table",
",",
"UINT8",
"entry",
")",
"{",
"static",
"const",
"char",
"*",
"const",
"strings",
"[",
"]",
"=",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
";",
"if",
"(",
"entry",
">=",
"STATIC_BANK1",
"&&",
"entry",
"<=",
"STATIC_BANKMAX",
")",
"{",
"bank_info",
"*",
"info",
";",
"for",
"(",
"info",
"=",
"space",
"->",
"machine",
"->",
"memory_data",
"->",
"banklist",
";",
"info",
"!=",
"NULL",
";",
"info",
"=",
"info",
"->",
"next",
")",
"if",
"(",
"info",
"->",
"index",
"==",
"entry",
")",
"return",
"info",
"->",
"name",
";",
"}",
"if",
"(",
"entry",
"<",
"STATIC_COUNT",
")",
"return",
"strings",
"[",
"entry",
"]",
";",
"else",
"return",
"(",
"table",
"->",
"handlers",
"[",
"entry",
"]",
"->",
"name",
"!=",
"NULL",
")",
"?",
"table",
"->",
"handlers",
"[",
"entry",
"]",
"->",
"name",
":",
"\"",
"\"",
";",
"}"
] | handler_to_string - return friendly string
description of a handler | [
"handler_to_string",
"-",
"return",
"friendly",
"string",
"description",
"of",
"a",
"handler"
] | [
"/* banks have names */",
"/* constant strings for lower entries */"
] | [
{
"param": "space",
"type": "address_space"
},
{
"param": "table",
"type": "address_table"
},
{
"param": "entry",
"type": "UINT8"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "table",
"type": "address_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "entry",
"type": "UINT8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9eebc413938ae7d8faf0b044e724c2cae4cef66e | lofunz/mieme | Reloaded/trunk/src/emu/memory.c | [
"Unlicense"
] | C | dump_map | void | static void dump_map(FILE *file, const address_space *space, const address_table *table)
{
offs_t byteaddress, bytestart, byteend;
/* dump generic information */
fprintf(file, " Address bits = %d\n", space->abits);
fprintf(file, " Data bits = %d\n", space->dbits);
fprintf(file, " L1 bits = %d\n", LEVEL1_BITS);
fprintf(file, " L2 bits = %d\n", LEVEL2_BITS);
fprintf(file, " Address mask = %X\n", space->bytemask);
fprintf(file, "\n");
/* iterate over addresses */
for (byteaddress = 0; byteaddress <= space->bytemask; byteaddress = byteend + 1)
{
UINT8 entry = table_derive_range(table, byteaddress, &bytestart, &byteend);
fprintf(file, "%08X-%08X = %02X: %s [offset=%08X]\n",
bytestart, byteend, entry, handler_to_string(space, table, entry), table->handlers[entry]->bytestart);
}
} | /*-------------------------------------------------
dump_map - dump the contents of a single
address space
-------------------------------------------------*/ | dump the contents of a single
address space | [
"dump",
"the",
"contents",
"of",
"a",
"single",
"address",
"space"
] | static void dump_map(FILE *file, const address_space *space, const address_table *table)
{
offs_t byteaddress, bytestart, byteend;
fprintf(file, " Address bits = %d\n", space->abits);
fprintf(file, " Data bits = %d\n", space->dbits);
fprintf(file, " L1 bits = %d\n", LEVEL1_BITS);
fprintf(file, " L2 bits = %d\n", LEVEL2_BITS);
fprintf(file, " Address mask = %X\n", space->bytemask);
fprintf(file, "\n");
for (byteaddress = 0; byteaddress <= space->bytemask; byteaddress = byteend + 1)
{
UINT8 entry = table_derive_range(table, byteaddress, &bytestart, &byteend);
fprintf(file, "%08X-%08X = %02X: %s [offset=%08X]\n",
bytestart, byteend, entry, handler_to_string(space, table, entry), table->handlers[entry]->bytestart);
}
} | [
"static",
"void",
"dump_map",
"(",
"FILE",
"*",
"file",
",",
"const",
"address_space",
"*",
"space",
",",
"const",
"address_table",
"*",
"table",
")",
"{",
"offs_t",
"byteaddress",
",",
"bytestart",
",",
"byteend",
";",
"fprintf",
"(",
"file",
",",
"\"",
"\\n",
"\"",
",",
"space",
"->",
"abits",
")",
";",
"fprintf",
"(",
"file",
",",
"\"",
"\\n",
"\"",
",",
"space",
"->",
"dbits",
")",
";",
"fprintf",
"(",
"file",
",",
"\"",
"\\n",
"\"",
",",
"LEVEL1_BITS",
")",
";",
"fprintf",
"(",
"file",
",",
"\"",
"\\n",
"\"",
",",
"LEVEL2_BITS",
")",
";",
"fprintf",
"(",
"file",
",",
"\"",
"\\n",
"\"",
",",
"space",
"->",
"bytemask",
")",
";",
"fprintf",
"(",
"file",
",",
"\"",
"\\n",
"\"",
")",
";",
"for",
"(",
"byteaddress",
"=",
"0",
";",
"byteaddress",
"<=",
"space",
"->",
"bytemask",
";",
"byteaddress",
"=",
"byteend",
"+",
"1",
")",
"{",
"UINT8",
"entry",
"=",
"table_derive_range",
"(",
"table",
",",
"byteaddress",
",",
"&",
"bytestart",
",",
"&",
"byteend",
")",
";",
"fprintf",
"(",
"file",
",",
"\"",
"\\n",
"\"",
",",
"bytestart",
",",
"byteend",
",",
"entry",
",",
"handler_to_string",
"(",
"space",
",",
"table",
",",
"entry",
")",
",",
"table",
"->",
"handlers",
"[",
"entry",
"]",
"->",
"bytestart",
")",
";",
"}",
"}"
] | dump_map - dump the contents of a single
address space | [
"dump_map",
"-",
"dump",
"the",
"contents",
"of",
"a",
"single",
"address",
"space"
] | [
"/* dump generic information */",
"/* iterate over addresses */"
] | [
{
"param": "file",
"type": "FILE"
},
{
"param": "space",
"type": "address_space"
},
{
"param": "table",
"type": "address_table"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": "FILE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "space",
"type": "address_space",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "table",
"type": "address_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c81b6d4cd5156becd8d9d8cffd659a6a67e8b32 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/debug/express.c | [
"Unlicense"
] | C | print_tokens | void | static void print_tokens(FILE *out, parsed_expression *expr)
{
#if DEBUG_TOKENS
parse_token *token = expr->token;
mame_printf_debug("----\n");
while (token->type != TOK_END)
{
switch (token->type)
{
default:
case TOK_INVALID:
fprintf(out, "INVALID\n");
break;
case TOK_END:
fprintf(out, "END\n");
break;
case TOK_NUMBER:
fprintf(out, "NUMBER: %08X%08X\n", (UINT32)(token->value.i >> 32), (UINT32)token->value.i);
break;
case TOK_STRING:
fprintf(out, "STRING: ""%s""\n", (char *)token->value.p);
break;
case TOK_SYMBOL:
fprintf(out, "SYMBOL: %08X%08X\n", (UINT32)(token->value.i >> 32), (UINT32)token->value.i);
break;
case TOK_OPERATOR:
switch (token->value.i)
{
case TVL_LPAREN: fprintf(out, "(\n"); break;
case TVL_RPAREN: fprintf(out, ")\n"); break;
case TVL_PLUSPLUS: fprintf(out, "++ (unspecified)\n"); break;
case TVL_MINUSMINUS: fprintf(out, "-- (unspecified)\n"); break;
case TVL_PREINCREMENT: fprintf(out, "++ (prefix)\n"); break;
case TVL_PREDECREMENT: fprintf(out, "-- (prefix)\n"); break;
case TVL_POSTINCREMENT: fprintf(out, "++ (postfix)\n"); break;
case TVL_POSTDECREMENT: fprintf(out, "-- (postfix)\n"); break;
case TVL_COMPLEMENT: fprintf(out, "!\n"); break;
case TVL_NOT: fprintf(out, "~\n"); break;
case TVL_UPLUS: fprintf(out, "+ (unary)\n"); break;
case TVL_UMINUS: fprintf(out, "- (unary)\n"); break;
case TVL_MULTIPLY: fprintf(out, "*\n"); break;
case TVL_DIVIDE: fprintf(out, "/\n"); break;
case TVL_MODULO: fprintf(out, "%%\n"); break;
case TVL_ADD: fprintf(out, "+\n"); break;
case TVL_SUBTRACT: fprintf(out, "-\n"); break;
case TVL_LSHIFT: fprintf(out, "<<\n"); break;
case TVL_RSHIFT: fprintf(out, ">>\n"); break;
case TVL_LESS: fprintf(out, "<\n"); break;
case TVL_LESSOREQUAL: fprintf(out, "<=\n"); break;
case TVL_GREATER: fprintf(out, ">\n"); break;
case TVL_GREATEROREQUAL:fprintf(out, ">=\n"); break;
case TVL_EQUAL: fprintf(out, "==\n"); break;
case TVL_NOTEQUAL: fprintf(out, "!=\n"); break;
case TVL_BAND: fprintf(out, "&\n"); break;
case TVL_BXOR: fprintf(out, "^\n"); break;
case TVL_BOR: fprintf(out, "|\n"); break;
case TVL_LAND: fprintf(out, "&&\n"); break;
case TVL_LOR: fprintf(out, "||\n"); break;
case TVL_ASSIGN: fprintf(out, "=\n"); break;
case TVL_ASSIGNMULTIPLY:fprintf(out, "*=\n"); break;
case TVL_ASSIGNDIVIDE: fprintf(out, "/=\n"); break;
case TVL_ASSIGNMODULO: fprintf(out, "%%=\n"); break;
case TVL_ASSIGNADD: fprintf(out, "+=\n"); break;
case TVL_ASSIGNSUBTRACT:fprintf(out, "-=\n"); break;
case TVL_ASSIGNLSHIFT: fprintf(out, "<<=\n"); break;
case TVL_ASSIGNRSHIFT: fprintf(out, ">>=\n"); break;
case TVL_ASSIGNBAND: fprintf(out, "&=\n"); break;
case TVL_ASSIGNBXOR: fprintf(out, "^=\n"); break;
case TVL_ASSIGNBOR: fprintf(out, "|=\n"); break;
case TVL_COMMA: fprintf(out, ",\n"); break;
case TVL_MEMORYAT: fprintf(out, "mem@\n"); break;
case TVL_EXECUTEFUNC: fprintf(out, "execute\n"); break;
default: fprintf(out, "INVALID OPERATOR\n"); break;
}
break;
}
token++;
}
mame_printf_debug("----\n");
#endif
} | /*-------------------------------------------------
print_token - debugging took to print a
human readable token representation
-------------------------------------------------*/ | debugging took to print a
human readable token representation | [
"debugging",
"took",
"to",
"print",
"a",
"human",
"readable",
"token",
"representation"
] | static void print_tokens(FILE *out, parsed_expression *expr)
{
#if DEBUG_TOKENS
parse_token *token = expr->token;
mame_printf_debug("----\n");
while (token->type != TOK_END)
{
switch (token->type)
{
default:
case TOK_INVALID:
fprintf(out, "INVALID\n");
break;
case TOK_END:
fprintf(out, "END\n");
break;
case TOK_NUMBER:
fprintf(out, "NUMBER: %08X%08X\n", (UINT32)(token->value.i >> 32), (UINT32)token->value.i);
break;
case TOK_STRING:
fprintf(out, "STRING: ""%s""\n", (char *)token->value.p);
break;
case TOK_SYMBOL:
fprintf(out, "SYMBOL: %08X%08X\n", (UINT32)(token->value.i >> 32), (UINT32)token->value.i);
break;
case TOK_OPERATOR:
switch (token->value.i)
{
case TVL_LPAREN: fprintf(out, "(\n"); break;
case TVL_RPAREN: fprintf(out, ")\n"); break;
case TVL_PLUSPLUS: fprintf(out, "++ (unspecified)\n"); break;
case TVL_MINUSMINUS: fprintf(out, "-- (unspecified)\n"); break;
case TVL_PREINCREMENT: fprintf(out, "++ (prefix)\n"); break;
case TVL_PREDECREMENT: fprintf(out, "-- (prefix)\n"); break;
case TVL_POSTINCREMENT: fprintf(out, "++ (postfix)\n"); break;
case TVL_POSTDECREMENT: fprintf(out, "-- (postfix)\n"); break;
case TVL_COMPLEMENT: fprintf(out, "!\n"); break;
case TVL_NOT: fprintf(out, "~\n"); break;
case TVL_UPLUS: fprintf(out, "+ (unary)\n"); break;
case TVL_UMINUS: fprintf(out, "- (unary)\n"); break;
case TVL_MULTIPLY: fprintf(out, "*\n"); break;
case TVL_DIVIDE: fprintf(out, "/\n"); break;
case TVL_MODULO: fprintf(out, "%%\n"); break;
case TVL_ADD: fprintf(out, "+\n"); break;
case TVL_SUBTRACT: fprintf(out, "-\n"); break;
case TVL_LSHIFT: fprintf(out, "<<\n"); break;
case TVL_RSHIFT: fprintf(out, ">>\n"); break;
case TVL_LESS: fprintf(out, "<\n"); break;
case TVL_LESSOREQUAL: fprintf(out, "<=\n"); break;
case TVL_GREATER: fprintf(out, ">\n"); break;
case TVL_GREATEROREQUAL:fprintf(out, ">=\n"); break;
case TVL_EQUAL: fprintf(out, "==\n"); break;
case TVL_NOTEQUAL: fprintf(out, "!=\n"); break;
case TVL_BAND: fprintf(out, "&\n"); break;
case TVL_BXOR: fprintf(out, "^\n"); break;
case TVL_BOR: fprintf(out, "|\n"); break;
case TVL_LAND: fprintf(out, "&&\n"); break;
case TVL_LOR: fprintf(out, "||\n"); break;
case TVL_ASSIGN: fprintf(out, "=\n"); break;
case TVL_ASSIGNMULTIPLY:fprintf(out, "*=\n"); break;
case TVL_ASSIGNDIVIDE: fprintf(out, "/=\n"); break;
case TVL_ASSIGNMODULO: fprintf(out, "%%=\n"); break;
case TVL_ASSIGNADD: fprintf(out, "+=\n"); break;
case TVL_ASSIGNSUBTRACT:fprintf(out, "-=\n"); break;
case TVL_ASSIGNLSHIFT: fprintf(out, "<<=\n"); break;
case TVL_ASSIGNRSHIFT: fprintf(out, ">>=\n"); break;
case TVL_ASSIGNBAND: fprintf(out, "&=\n"); break;
case TVL_ASSIGNBXOR: fprintf(out, "^=\n"); break;
case TVL_ASSIGNBOR: fprintf(out, "|=\n"); break;
case TVL_COMMA: fprintf(out, ",\n"); break;
case TVL_MEMORYAT: fprintf(out, "mem@\n"); break;
case TVL_EXECUTEFUNC: fprintf(out, "execute\n"); break;
default: fprintf(out, "INVALID OPERATOR\n"); break;
}
break;
}
token++;
}
mame_printf_debug("----\n");
#endif
} | [
"static",
"void",
"print_tokens",
"(",
"FILE",
"*",
"out",
",",
"parsed_expression",
"*",
"expr",
")",
"{",
"#if",
"DEBUG_TOKENS",
"\n",
"parse_token",
"*",
"token",
"=",
"expr",
"->",
"token",
";",
"mame_printf_debug",
"(",
"\"",
"\\n",
"\"",
")",
";",
"while",
"(",
"token",
"->",
"type",
"!=",
"TOK_END",
")",
"{",
"switch",
"(",
"token",
"->",
"type",
")",
"{",
"default",
":",
"case",
"TOK_INVALID",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TOK_END",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TOK_NUMBER",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
",",
"(",
"UINT32",
")",
"(",
"token",
"->",
"value",
".",
"i",
">>",
"32",
")",
",",
"(",
"UINT32",
")",
"token",
"->",
"value",
".",
"i",
")",
";",
"break",
";",
"case",
"TOK_STRING",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\"",
"\"",
"\"",
"\"",
"\\n",
"\"",
",",
"(",
"char",
"*",
")",
"token",
"->",
"value",
".",
"p",
")",
";",
"break",
";",
"case",
"TOK_SYMBOL",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
",",
"(",
"UINT32",
")",
"(",
"token",
"->",
"value",
".",
"i",
">>",
"32",
")",
",",
"(",
"UINT32",
")",
"token",
"->",
"value",
".",
"i",
")",
";",
"break",
";",
"case",
"TOK_OPERATOR",
":",
"switch",
"(",
"token",
"->",
"value",
".",
"i",
")",
"{",
"case",
"TVL_LPAREN",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_RPAREN",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_PLUSPLUS",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_MINUSMINUS",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_PREINCREMENT",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_PREDECREMENT",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_POSTINCREMENT",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_POSTDECREMENT",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_COMPLEMENT",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_NOT",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_UPLUS",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_UMINUS",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_MULTIPLY",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_DIVIDE",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_MODULO",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_ADD",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_SUBTRACT",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_LSHIFT",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_RSHIFT",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_LESS",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_LESSOREQUAL",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_GREATER",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_GREATEROREQUAL",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_EQUAL",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_NOTEQUAL",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_BAND",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_BXOR",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_BOR",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_LAND",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_LOR",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_ASSIGN",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_ASSIGNMULTIPLY",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_ASSIGNDIVIDE",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_ASSIGNMODULO",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_ASSIGNADD",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_ASSIGNSUBTRACT",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_ASSIGNLSHIFT",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_ASSIGNRSHIFT",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_ASSIGNBAND",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_ASSIGNBXOR",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_ASSIGNBOR",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_COMMA",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_MEMORYAT",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TVL_EXECUTEFUNC",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"default",
":",
"fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
")",
";",
"break",
";",
"}",
"break",
";",
"}",
"token",
"++",
";",
"}",
"mame_printf_debug",
"(",
"\"",
"\\n",
"\"",
")",
";",
"#endif",
"}"
] | print_token - debugging took to print a
human readable token representation | [
"print_token",
"-",
"debugging",
"took",
"to",
"print",
"a",
"human",
"readable",
"token",
"representation"
] | [] | [
{
"param": "out",
"type": "FILE"
},
{
"param": "expr",
"type": "parsed_expression"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "out",
"type": "FILE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "expr",
"type": "parsed_expression",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c81b6d4cd5156becd8d9d8cffd659a6a67e8b32 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/debug/express.c | [
"Unlicense"
] | C | parse_memory_operator | EXPRERR | static EXPRERR parse_memory_operator(parsed_expression *expr, int offset, const char *buffer, token_info *flags)
{
const char *startbuffer = buffer;
const char *namestring = NULL;
int space = 'p', size;
int physical = FALSE;
const char *dot;
int length;
*flags = 0;
/* if there is a '.', it means we have a name */
dot = strrchr(buffer, '.');
if (dot != NULL)
{
UINT16 index = 0;
namestring = add_expression_string(expr, buffer, dot - buffer, &index);
if (namestring == NULL)
return MAKE_EXPRERR_OUT_OF_MEMORY(offset);
*flags |= index << TIN_MEMORY_INDEX_SHIFT;
buffer = dot + 1;
}
/* length 3 means logical/physical, then space, then size */
length = (int)strlen(buffer);
if (length == 3)
{
if (buffer[0] != 'l' && buffer[0] != 'p')
return MAKE_EXPRERR_INVALID_MEMORY_SPACE(offset + (buffer - startbuffer));
if (buffer[1] != 'p' && buffer[1] != 'd' && buffer[1] != 'i' && buffer[1] != '3')
return MAKE_EXPRERR_INVALID_MEMORY_SPACE(offset + (buffer - startbuffer));
physical = (buffer[0] == 'p');
space = buffer[1];
size = buffer[2];
}
/* length 2 means space then size */
else if (length == 2)
{
space = buffer[0];
size = buffer[1];
}
/* length 1 means size */
else if (length == 1)
size = buffer[0];
/* anything else is invalid */
else
return MAKE_EXPRERR_INVALID_TOKEN(offset);
/* convert the space to flags */
switch (space)
{
case 'p': *flags |= physical ? TIN_MEMORY_PROGRAM_PHYS : TIN_MEMORY_PROGRAM_LOG; break;
case 'd': *flags |= physical ? TIN_MEMORY_DATA_PHYS : TIN_MEMORY_DATA_LOG; break;
case 'i': *flags |= physical ? TIN_MEMORY_IO_PHYS : TIN_MEMORY_IO_LOG; break;
case '3': *flags |= physical ? TIN_MEMORY_SPACE3_PHYS : TIN_MEMORY_SPACE3_LOG; break;
case 'o': *flags |= TIN_MEMORY_OPCODE; break;
case 'r': *flags |= TIN_MEMORY_RAMWRITE; break;
case 'e': *flags |= TIN_MEMORY_EEPROM; break;
case 'm': *flags |= TIN_MEMORY_REGION; break;
default: return MAKE_EXPRERR_INVALID_MEMORY_SPACE(offset + (buffer - startbuffer));
}
/* convert the size to flags */
switch (size)
{
case 'b': *flags |= TIN_MEMORY_BYTE; break;
case 'w': *flags |= TIN_MEMORY_WORD; break;
case 'd': *flags |= TIN_MEMORY_DWORD; break;
case 'q': *flags |= TIN_MEMORY_QWORD; break;
default: return MAKE_EXPRERR_INVALID_MEMORY_SIZE(offset + (buffer - startbuffer) + length - 1);
}
/* validate the name */
if (expr->callbacks.valid != NULL)
{
EXPRERR err = (*expr->callbacks.valid)(expr->cbparam, namestring, (*flags & TIN_MEMORY_SPACE_MASK) >> TIN_MEMORY_SPACE_SHIFT);
if (err == EXPRERR_INVALID_MEMORY_SPACE)
return MAKE_EXPRERR_INVALID_MEMORY_SPACE(offset + (buffer - startbuffer));
else if (err != EXPRERR_NONE)
return MAKE_EXPRERR(err, offset);
}
return EXPRERR_NONE;
} | /*-------------------------------------------------
parse_memory_operator - parse the several
forms of memory operators
-------------------------------------------------*/ | parse the several
forms of memory operators | [
"parse",
"the",
"several",
"forms",
"of",
"memory",
"operators"
] | static EXPRERR parse_memory_operator(parsed_expression *expr, int offset, const char *buffer, token_info *flags)
{
const char *startbuffer = buffer;
const char *namestring = NULL;
int space = 'p', size;
int physical = FALSE;
const char *dot;
int length;
*flags = 0;
dot = strrchr(buffer, '.');
if (dot != NULL)
{
UINT16 index = 0;
namestring = add_expression_string(expr, buffer, dot - buffer, &index);
if (namestring == NULL)
return MAKE_EXPRERR_OUT_OF_MEMORY(offset);
*flags |= index << TIN_MEMORY_INDEX_SHIFT;
buffer = dot + 1;
}
length = (int)strlen(buffer);
if (length == 3)
{
if (buffer[0] != 'l' && buffer[0] != 'p')
return MAKE_EXPRERR_INVALID_MEMORY_SPACE(offset + (buffer - startbuffer));
if (buffer[1] != 'p' && buffer[1] != 'd' && buffer[1] != 'i' && buffer[1] != '3')
return MAKE_EXPRERR_INVALID_MEMORY_SPACE(offset + (buffer - startbuffer));
physical = (buffer[0] == 'p');
space = buffer[1];
size = buffer[2];
}
else if (length == 2)
{
space = buffer[0];
size = buffer[1];
}
else if (length == 1)
size = buffer[0];
else
return MAKE_EXPRERR_INVALID_TOKEN(offset);
switch (space)
{
case 'p': *flags |= physical ? TIN_MEMORY_PROGRAM_PHYS : TIN_MEMORY_PROGRAM_LOG; break;
case 'd': *flags |= physical ? TIN_MEMORY_DATA_PHYS : TIN_MEMORY_DATA_LOG; break;
case 'i': *flags |= physical ? TIN_MEMORY_IO_PHYS : TIN_MEMORY_IO_LOG; break;
case '3': *flags |= physical ? TIN_MEMORY_SPACE3_PHYS : TIN_MEMORY_SPACE3_LOG; break;
case 'o': *flags |= TIN_MEMORY_OPCODE; break;
case 'r': *flags |= TIN_MEMORY_RAMWRITE; break;
case 'e': *flags |= TIN_MEMORY_EEPROM; break;
case 'm': *flags |= TIN_MEMORY_REGION; break;
default: return MAKE_EXPRERR_INVALID_MEMORY_SPACE(offset + (buffer - startbuffer));
}
switch (size)
{
case 'b': *flags |= TIN_MEMORY_BYTE; break;
case 'w': *flags |= TIN_MEMORY_WORD; break;
case 'd': *flags |= TIN_MEMORY_DWORD; break;
case 'q': *flags |= TIN_MEMORY_QWORD; break;
default: return MAKE_EXPRERR_INVALID_MEMORY_SIZE(offset + (buffer - startbuffer) + length - 1);
}
if (expr->callbacks.valid != NULL)
{
EXPRERR err = (*expr->callbacks.valid)(expr->cbparam, namestring, (*flags & TIN_MEMORY_SPACE_MASK) >> TIN_MEMORY_SPACE_SHIFT);
if (err == EXPRERR_INVALID_MEMORY_SPACE)
return MAKE_EXPRERR_INVALID_MEMORY_SPACE(offset + (buffer - startbuffer));
else if (err != EXPRERR_NONE)
return MAKE_EXPRERR(err, offset);
}
return EXPRERR_NONE;
} | [
"static",
"EXPRERR",
"parse_memory_operator",
"(",
"parsed_expression",
"*",
"expr",
",",
"int",
"offset",
",",
"const",
"char",
"*",
"buffer",
",",
"token_info",
"*",
"flags",
")",
"{",
"const",
"char",
"*",
"startbuffer",
"=",
"buffer",
";",
"const",
"char",
"*",
"namestring",
"=",
"NULL",
";",
"int",
"space",
"=",
"'",
"'",
",",
"size",
";",
"int",
"physical",
"=",
"FALSE",
";",
"const",
"char",
"*",
"dot",
";",
"int",
"length",
";",
"*",
"flags",
"=",
"0",
";",
"dot",
"=",
"strrchr",
"(",
"buffer",
",",
"'",
"'",
")",
";",
"if",
"(",
"dot",
"!=",
"NULL",
")",
"{",
"UINT16",
"index",
"=",
"0",
";",
"namestring",
"=",
"add_expression_string",
"(",
"expr",
",",
"buffer",
",",
"dot",
"-",
"buffer",
",",
"&",
"index",
")",
";",
"if",
"(",
"namestring",
"==",
"NULL",
")",
"return",
"MAKE_EXPRERR_OUT_OF_MEMORY",
"(",
"offset",
")",
";",
"*",
"flags",
"|=",
"index",
"<<",
"TIN_MEMORY_INDEX_SHIFT",
";",
"buffer",
"=",
"dot",
"+",
"1",
";",
"}",
"length",
"=",
"(",
"int",
")",
"strlen",
"(",
"buffer",
")",
";",
"if",
"(",
"length",
"==",
"3",
")",
"{",
"if",
"(",
"buffer",
"[",
"0",
"]",
"!=",
"'",
"'",
"&&",
"buffer",
"[",
"0",
"]",
"!=",
"'",
"'",
")",
"return",
"MAKE_EXPRERR_INVALID_MEMORY_SPACE",
"(",
"offset",
"+",
"(",
"buffer",
"-",
"startbuffer",
")",
")",
";",
"if",
"(",
"buffer",
"[",
"1",
"]",
"!=",
"'",
"'",
"&&",
"buffer",
"[",
"1",
"]",
"!=",
"'",
"'",
"&&",
"buffer",
"[",
"1",
"]",
"!=",
"'",
"'",
"&&",
"buffer",
"[",
"1",
"]",
"!=",
"'",
"'",
")",
"return",
"MAKE_EXPRERR_INVALID_MEMORY_SPACE",
"(",
"offset",
"+",
"(",
"buffer",
"-",
"startbuffer",
")",
")",
";",
"physical",
"=",
"(",
"buffer",
"[",
"0",
"]",
"==",
"'",
"'",
")",
";",
"space",
"=",
"buffer",
"[",
"1",
"]",
";",
"size",
"=",
"buffer",
"[",
"2",
"]",
";",
"}",
"else",
"if",
"(",
"length",
"==",
"2",
")",
"{",
"space",
"=",
"buffer",
"[",
"0",
"]",
";",
"size",
"=",
"buffer",
"[",
"1",
"]",
";",
"}",
"else",
"if",
"(",
"length",
"==",
"1",
")",
"size",
"=",
"buffer",
"[",
"0",
"]",
";",
"else",
"return",
"MAKE_EXPRERR_INVALID_TOKEN",
"(",
"offset",
")",
";",
"switch",
"(",
"space",
")",
"{",
"case",
"'",
"'",
":",
"*",
"flags",
"|=",
"physical",
"?",
"TIN_MEMORY_PROGRAM_PHYS",
":",
"TIN_MEMORY_PROGRAM_LOG",
";",
"break",
";",
"case",
"'",
"'",
":",
"*",
"flags",
"|=",
"physical",
"?",
"TIN_MEMORY_DATA_PHYS",
":",
"TIN_MEMORY_DATA_LOG",
";",
"break",
";",
"case",
"'",
"'",
":",
"*",
"flags",
"|=",
"physical",
"?",
"TIN_MEMORY_IO_PHYS",
":",
"TIN_MEMORY_IO_LOG",
";",
"break",
";",
"case",
"'",
"'",
":",
"*",
"flags",
"|=",
"physical",
"?",
"TIN_MEMORY_SPACE3_PHYS",
":",
"TIN_MEMORY_SPACE3_LOG",
";",
"break",
";",
"case",
"'",
"'",
":",
"*",
"flags",
"|=",
"TIN_MEMORY_OPCODE",
";",
"break",
";",
"case",
"'",
"'",
":",
"*",
"flags",
"|=",
"TIN_MEMORY_RAMWRITE",
";",
"break",
";",
"case",
"'",
"'",
":",
"*",
"flags",
"|=",
"TIN_MEMORY_EEPROM",
";",
"break",
";",
"case",
"'",
"'",
":",
"*",
"flags",
"|=",
"TIN_MEMORY_REGION",
";",
"break",
";",
"default",
":",
"return",
"MAKE_EXPRERR_INVALID_MEMORY_SPACE",
"(",
"offset",
"+",
"(",
"buffer",
"-",
"startbuffer",
")",
")",
";",
"}",
"switch",
"(",
"size",
")",
"{",
"case",
"'",
"'",
":",
"*",
"flags",
"|=",
"TIN_MEMORY_BYTE",
";",
"break",
";",
"case",
"'",
"'",
":",
"*",
"flags",
"|=",
"TIN_MEMORY_WORD",
";",
"break",
";",
"case",
"'",
"'",
":",
"*",
"flags",
"|=",
"TIN_MEMORY_DWORD",
";",
"break",
";",
"case",
"'",
"'",
":",
"*",
"flags",
"|=",
"TIN_MEMORY_QWORD",
";",
"break",
";",
"default",
":",
"return",
"MAKE_EXPRERR_INVALID_MEMORY_SIZE",
"(",
"offset",
"+",
"(",
"buffer",
"-",
"startbuffer",
")",
"+",
"length",
"-",
"1",
")",
";",
"}",
"if",
"(",
"expr",
"->",
"callbacks",
".",
"valid",
"!=",
"NULL",
")",
"{",
"EXPRERR",
"err",
"=",
"(",
"*",
"expr",
"->",
"callbacks",
".",
"valid",
")",
"(",
"expr",
"->",
"cbparam",
",",
"namestring",
",",
"(",
"*",
"flags",
"&",
"TIN_MEMORY_SPACE_MASK",
")",
">>",
"TIN_MEMORY_SPACE_SHIFT",
")",
";",
"if",
"(",
"err",
"==",
"EXPRERR_INVALID_MEMORY_SPACE",
")",
"return",
"MAKE_EXPRERR_INVALID_MEMORY_SPACE",
"(",
"offset",
"+",
"(",
"buffer",
"-",
"startbuffer",
")",
")",
";",
"else",
"if",
"(",
"err",
"!=",
"EXPRERR_NONE",
")",
"return",
"MAKE_EXPRERR",
"(",
"err",
",",
"offset",
")",
";",
"}",
"return",
"EXPRERR_NONE",
";",
"}"
] | parse_memory_operator - parse the several
forms of memory operators | [
"parse_memory_operator",
"-",
"parse",
"the",
"several",
"forms",
"of",
"memory",
"operators"
] | [
"/* if there is a '.', it means we have a name */",
"/* length 3 means logical/physical, then space, then size */",
"/* length 2 means space then size */",
"/* length 1 means size */",
"/* anything else is invalid */",
"/* convert the space to flags */",
"/* convert the size to flags */",
"/* validate the name */"
] | [
{
"param": "expr",
"type": "parsed_expression"
},
{
"param": "offset",
"type": "int"
},
{
"param": "buffer",
"type": "char"
},
{
"param": "flags",
"type": "token_info"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "expr",
"type": "parsed_expression",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offset",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "buffer",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "flags",
"type": "token_info",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c81b6d4cd5156becd8d9d8cffd659a6a67e8b32 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/debug/express.c | [
"Unlicense"
] | C | normalize_operator | EXPRERR | static EXPRERR normalize_operator(parsed_expression *expr, int tokindex)
{
parse_token *thistoken = &expr->token[tokindex];
parse_token *nexttoken = thistoken + 1;
parse_token *prevtoken = (tokindex == 0) ? NULL : (thistoken - 1);
switch (thistoken->value.i)
{
/* Determine if an open paren is part of a function or not */
case TVL_LPAREN:
if (prevtoken != NULL && prevtoken->type == TOK_OPERATOR && prevtoken->value.i == TVL_EXECUTEFUNC)
thistoken->info |= TIN_FUNCTION;
break;
/* Determine if ++ is a pre or post increment */
case TVL_PLUSPLUS:
if (nexttoken->type == TOK_SYMBOL || (nexttoken->type == TOK_OPERATOR && nexttoken->value.i == TVL_MEMORYAT))
{
thistoken->value.i = TVL_PREINCREMENT;
thistoken->info = TIN_PRECEDENCE_2;
}
else if (prevtoken != NULL && (prevtoken->type == TOK_SYMBOL || (prevtoken->type == TOK_OPERATOR && prevtoken->value.i == TVL_MEMORYAT)))
{
thistoken->value.i = TVL_POSTINCREMENT;
thistoken->info = TIN_PRECEDENCE_1;
}
else
return MAKE_EXPRERR_SYNTAX(thistoken->offset);
break;
/* Determine if -- is a pre or post decrement */
case TVL_MINUSMINUS:
if (nexttoken->type == TOK_SYMBOL || (nexttoken->type == TOK_OPERATOR && nexttoken->value.i == TVL_MEMORYAT))
{
thistoken->value.i = TVL_PREDECREMENT;
thistoken->info = TIN_PRECEDENCE_2;
}
else if (prevtoken != NULL && (prevtoken->type == TOK_SYMBOL || (prevtoken->type == TOK_OPERATOR && prevtoken->value.i == TVL_MEMORYAT)))
{
thistoken->value.i = TVL_POSTDECREMENT;
thistoken->info = TIN_PRECEDENCE_1;
}
else
return MAKE_EXPRERR_SYNTAX(thistoken->offset);
break;
/* Determine if +/- is a unary or binary */
case TVL_ADD:
case TVL_SUBTRACT:
/* Assume we're unary if we are the first token, or if the previous token is not
a symbol, a number, or a right parenthesis */
if (prevtoken == NULL ||
(prevtoken->type != TOK_SYMBOL && prevtoken->type != TOK_NUMBER &&
(prevtoken->type != TOK_OPERATOR || prevtoken->value.i != TVL_RPAREN)))
{
thistoken->value.i = (thistoken->value.i == TVL_ADD) ? TVL_UPLUS : TVL_UMINUS;
thistoken->info = TIN_PRECEDENCE_2;
}
break;
/* Determine if , refers to a function parameter */
case TVL_COMMA:
{
int lookback;
for (lookback = 0; lookback < MAX_STACK_DEPTH; lookback++)
{
parse_token *peek = peek_token(expr, lookback);
if (!peek)
break;
if (peek->value.i == TVL_LPAREN)
{
if (peek->info & TIN_FUNCTION)
thistoken->info |= TIN_FUNCTION;
break;
}
if (peek->value.i == TVL_EXECUTEFUNC)
{
thistoken->info |= TIN_FUNCTION;
break;
}
}
break;
}
}
return EXPRERR_NONE;
} | /*-------------------------------------------------
normalize_operator - resolve operator
ambiguities based on neighboring tokens
-------------------------------------------------*/ | resolve operator
ambiguities based on neighboring tokens | [
"resolve",
"operator",
"ambiguities",
"based",
"on",
"neighboring",
"tokens"
] | static EXPRERR normalize_operator(parsed_expression *expr, int tokindex)
{
parse_token *thistoken = &expr->token[tokindex];
parse_token *nexttoken = thistoken + 1;
parse_token *prevtoken = (tokindex == 0) ? NULL : (thistoken - 1);
switch (thistoken->value.i)
{
case TVL_LPAREN:
if (prevtoken != NULL && prevtoken->type == TOK_OPERATOR && prevtoken->value.i == TVL_EXECUTEFUNC)
thistoken->info |= TIN_FUNCTION;
break;
case TVL_PLUSPLUS:
if (nexttoken->type == TOK_SYMBOL || (nexttoken->type == TOK_OPERATOR && nexttoken->value.i == TVL_MEMORYAT))
{
thistoken->value.i = TVL_PREINCREMENT;
thistoken->info = TIN_PRECEDENCE_2;
}
else if (prevtoken != NULL && (prevtoken->type == TOK_SYMBOL || (prevtoken->type == TOK_OPERATOR && prevtoken->value.i == TVL_MEMORYAT)))
{
thistoken->value.i = TVL_POSTINCREMENT;
thistoken->info = TIN_PRECEDENCE_1;
}
else
return MAKE_EXPRERR_SYNTAX(thistoken->offset);
break;
case TVL_MINUSMINUS:
if (nexttoken->type == TOK_SYMBOL || (nexttoken->type == TOK_OPERATOR && nexttoken->value.i == TVL_MEMORYAT))
{
thistoken->value.i = TVL_PREDECREMENT;
thistoken->info = TIN_PRECEDENCE_2;
}
else if (prevtoken != NULL && (prevtoken->type == TOK_SYMBOL || (prevtoken->type == TOK_OPERATOR && prevtoken->value.i == TVL_MEMORYAT)))
{
thistoken->value.i = TVL_POSTDECREMENT;
thistoken->info = TIN_PRECEDENCE_1;
}
else
return MAKE_EXPRERR_SYNTAX(thistoken->offset);
break;
case TVL_ADD:
case TVL_SUBTRACT:
if (prevtoken == NULL ||
(prevtoken->type != TOK_SYMBOL && prevtoken->type != TOK_NUMBER &&
(prevtoken->type != TOK_OPERATOR || prevtoken->value.i != TVL_RPAREN)))
{
thistoken->value.i = (thistoken->value.i == TVL_ADD) ? TVL_UPLUS : TVL_UMINUS;
thistoken->info = TIN_PRECEDENCE_2;
}
break;
case TVL_COMMA:
{
int lookback;
for (lookback = 0; lookback < MAX_STACK_DEPTH; lookback++)
{
parse_token *peek = peek_token(expr, lookback);
if (!peek)
break;
if (peek->value.i == TVL_LPAREN)
{
if (peek->info & TIN_FUNCTION)
thistoken->info |= TIN_FUNCTION;
break;
}
if (peek->value.i == TVL_EXECUTEFUNC)
{
thistoken->info |= TIN_FUNCTION;
break;
}
}
break;
}
}
return EXPRERR_NONE;
} | [
"static",
"EXPRERR",
"normalize_operator",
"(",
"parsed_expression",
"*",
"expr",
",",
"int",
"tokindex",
")",
"{",
"parse_token",
"*",
"thistoken",
"=",
"&",
"expr",
"->",
"token",
"[",
"tokindex",
"]",
";",
"parse_token",
"*",
"nexttoken",
"=",
"thistoken",
"+",
"1",
";",
"parse_token",
"*",
"prevtoken",
"=",
"(",
"tokindex",
"==",
"0",
")",
"?",
"NULL",
":",
"(",
"thistoken",
"-",
"1",
")",
";",
"switch",
"(",
"thistoken",
"->",
"value",
".",
"i",
")",
"{",
"case",
"TVL_LPAREN",
":",
"if",
"(",
"prevtoken",
"!=",
"NULL",
"&&",
"prevtoken",
"->",
"type",
"==",
"TOK_OPERATOR",
"&&",
"prevtoken",
"->",
"value",
".",
"i",
"==",
"TVL_EXECUTEFUNC",
")",
"thistoken",
"->",
"info",
"|=",
"TIN_FUNCTION",
";",
"break",
";",
"case",
"TVL_PLUSPLUS",
":",
"if",
"(",
"nexttoken",
"->",
"type",
"==",
"TOK_SYMBOL",
"||",
"(",
"nexttoken",
"->",
"type",
"==",
"TOK_OPERATOR",
"&&",
"nexttoken",
"->",
"value",
".",
"i",
"==",
"TVL_MEMORYAT",
")",
")",
"{",
"thistoken",
"->",
"value",
".",
"i",
"=",
"TVL_PREINCREMENT",
";",
"thistoken",
"->",
"info",
"=",
"TIN_PRECEDENCE_2",
";",
"}",
"else",
"if",
"(",
"prevtoken",
"!=",
"NULL",
"&&",
"(",
"prevtoken",
"->",
"type",
"==",
"TOK_SYMBOL",
"||",
"(",
"prevtoken",
"->",
"type",
"==",
"TOK_OPERATOR",
"&&",
"prevtoken",
"->",
"value",
".",
"i",
"==",
"TVL_MEMORYAT",
")",
")",
")",
"{",
"thistoken",
"->",
"value",
".",
"i",
"=",
"TVL_POSTINCREMENT",
";",
"thistoken",
"->",
"info",
"=",
"TIN_PRECEDENCE_1",
";",
"}",
"else",
"return",
"MAKE_EXPRERR_SYNTAX",
"(",
"thistoken",
"->",
"offset",
")",
";",
"break",
";",
"case",
"TVL_MINUSMINUS",
":",
"if",
"(",
"nexttoken",
"->",
"type",
"==",
"TOK_SYMBOL",
"||",
"(",
"nexttoken",
"->",
"type",
"==",
"TOK_OPERATOR",
"&&",
"nexttoken",
"->",
"value",
".",
"i",
"==",
"TVL_MEMORYAT",
")",
")",
"{",
"thistoken",
"->",
"value",
".",
"i",
"=",
"TVL_PREDECREMENT",
";",
"thistoken",
"->",
"info",
"=",
"TIN_PRECEDENCE_2",
";",
"}",
"else",
"if",
"(",
"prevtoken",
"!=",
"NULL",
"&&",
"(",
"prevtoken",
"->",
"type",
"==",
"TOK_SYMBOL",
"||",
"(",
"prevtoken",
"->",
"type",
"==",
"TOK_OPERATOR",
"&&",
"prevtoken",
"->",
"value",
".",
"i",
"==",
"TVL_MEMORYAT",
")",
")",
")",
"{",
"thistoken",
"->",
"value",
".",
"i",
"=",
"TVL_POSTDECREMENT",
";",
"thistoken",
"->",
"info",
"=",
"TIN_PRECEDENCE_1",
";",
"}",
"else",
"return",
"MAKE_EXPRERR_SYNTAX",
"(",
"thistoken",
"->",
"offset",
")",
";",
"break",
";",
"case",
"TVL_ADD",
":",
"case",
"TVL_SUBTRACT",
":",
"if",
"(",
"prevtoken",
"==",
"NULL",
"||",
"(",
"prevtoken",
"->",
"type",
"!=",
"TOK_SYMBOL",
"&&",
"prevtoken",
"->",
"type",
"!=",
"TOK_NUMBER",
"&&",
"(",
"prevtoken",
"->",
"type",
"!=",
"TOK_OPERATOR",
"||",
"prevtoken",
"->",
"value",
".",
"i",
"!=",
"TVL_RPAREN",
")",
")",
")",
"{",
"thistoken",
"->",
"value",
".",
"i",
"=",
"(",
"thistoken",
"->",
"value",
".",
"i",
"==",
"TVL_ADD",
")",
"?",
"TVL_UPLUS",
":",
"TVL_UMINUS",
";",
"thistoken",
"->",
"info",
"=",
"TIN_PRECEDENCE_2",
";",
"}",
"break",
";",
"case",
"TVL_COMMA",
":",
"{",
"int",
"lookback",
";",
"for",
"(",
"lookback",
"=",
"0",
";",
"lookback",
"<",
"MAX_STACK_DEPTH",
";",
"lookback",
"++",
")",
"{",
"parse_token",
"*",
"peek",
"=",
"peek_token",
"(",
"expr",
",",
"lookback",
")",
";",
"if",
"(",
"!",
"peek",
")",
"break",
";",
"if",
"(",
"peek",
"->",
"value",
".",
"i",
"==",
"TVL_LPAREN",
")",
"{",
"if",
"(",
"peek",
"->",
"info",
"&",
"TIN_FUNCTION",
")",
"thistoken",
"->",
"info",
"|=",
"TIN_FUNCTION",
";",
"break",
";",
"}",
"if",
"(",
"peek",
"->",
"value",
".",
"i",
"==",
"TVL_EXECUTEFUNC",
")",
"{",
"thistoken",
"->",
"info",
"|=",
"TIN_FUNCTION",
";",
"break",
";",
"}",
"}",
"break",
";",
"}",
"}",
"return",
"EXPRERR_NONE",
";",
"}"
] | normalize_operator - resolve operator
ambiguities based on neighboring tokens | [
"normalize_operator",
"-",
"resolve",
"operator",
"ambiguities",
"based",
"on",
"neighboring",
"tokens"
] | [
"/* Determine if an open paren is part of a function or not */",
"/* Determine if ++ is a pre or post increment */",
"/* Determine if -- is a pre or post decrement */",
"/* Determine if +/- is a unary or binary */",
"/* Assume we're unary if we are the first token, or if the previous token is not\n a symbol, a number, or a right parenthesis */",
"/* Determine if , refers to a function parameter */"
] | [
{
"param": "expr",
"type": "parsed_expression"
},
{
"param": "tokindex",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "expr",
"type": "parsed_expression",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tokindex",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c81b6d4cd5156becd8d9d8cffd659a6a67e8b32 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/debug/express.c | [
"Unlicense"
] | C | infix_to_postfix | EXPRERR | static EXPRERR infix_to_postfix(parsed_expression *expr)
{
parse_token *dest = expr->token;
parse_token dummy;
parse_token *peek;
int tokindex = 0;
EXPRERR exprerr;
memset(&dummy, 0, sizeof(dummy));
/* start with an empty stack */
init_token_stack(expr);
/* loop over all the original tokens */
for ( ; expr->token[tokindex].type != TOK_END; tokindex++)
{
parse_token *token = &expr->token[tokindex];
/* If the character is an operand, append it to the result string */
if (token->type == TOK_NUMBER || token->type == TOK_SYMBOL || token->type == TOK_STRING)
*dest++ = *token;
/* If this is an operator, process it */
else if (token->type == TOK_OPERATOR)
{
int exprerr = normalize_operator(expr, tokindex);
if (exprerr != 0)
return exprerr;
/* If the token is an opening parenthesis, push it onto the stack. */
if (token->value.i == TVL_LPAREN)
{
exprerr = push_token(expr, token);
if (exprerr != 0)
return exprerr;
}
/* If the token is a closing parenthesis, pop all operators until we
reach an opening parenthesis and append them to the result string. */
else if (token->value.i == TVL_RPAREN)
{
/* loop until we can't peek at the stack anymore */
while ((peek = peek_token(expr, 0)) != NULL)
{
if (peek->value.i == TVL_LPAREN)
break;
exprerr = pop_token(expr, dest++);
if (exprerr != 0)
return exprerr;
}
/* if we didn't find an open paren, it's an error */
if (peek == NULL)
return MAKE_EXPRERR_UNBALANCED_PARENS(token->offset);
/* pop the open paren off the stack */
exprerr = pop_token(expr, &dummy);
if (exprerr != 0)
return exprerr;
}
/* If the token is an operator, pop operators until we reach an opening parenthesis,
an operator of lower precedence, or a right associative symbol of equal precedence.
Push the operator onto the stack. */
else
{
int our_precedence = token->info & TIN_PRECEDENCE_MASK;
/* loop until we can't peek at the stack anymore */
while ((peek = peek_token(expr, 0)) != NULL)
{
int stack_precedence = peek->info & TIN_PRECEDENCE_MASK;
/* break if any of the above conditions are true */
if (peek->value.i == TVL_LPAREN)
break;
if (stack_precedence > our_precedence)
break;
if (stack_precedence == our_precedence && (peek->info & TIN_RIGHT_TO_LEFT))
break;
/* pop this token */
exprerr = pop_token(expr, dest++);
if (exprerr != 0)
return exprerr;
}
/* push the new operator */
exprerr = push_token(expr, token);
if (exprerr != 0)
return exprerr;
}
}
}
/* finish popping the stack */
while ((peek = peek_token(expr, 0)) != NULL)
{
/* it is an error to have a left parenthesis still on the stack */
if (peek->value.i == TVL_LPAREN)
return MAKE_EXPRERR_UNBALANCED_PARENS(peek->offset);
/* pop this token */
exprerr = pop_token(expr, dest++);
if (exprerr != 0)
return exprerr;
}
/* copy the end token to the final stream */
*dest++ = expr->token[tokindex];
return EXPRERR_NONE;
} | /*-------------------------------------------------
infix_to_postfix - convert an infix sequence
of tokens to a postfix sequence for processing
-------------------------------------------------*/ | convert an infix sequence
of tokens to a postfix sequence for processing | [
"convert",
"an",
"infix",
"sequence",
"of",
"tokens",
"to",
"a",
"postfix",
"sequence",
"for",
"processing"
] | static EXPRERR infix_to_postfix(parsed_expression *expr)
{
parse_token *dest = expr->token;
parse_token dummy;
parse_token *peek;
int tokindex = 0;
EXPRERR exprerr;
memset(&dummy, 0, sizeof(dummy));
init_token_stack(expr);
for ( ; expr->token[tokindex].type != TOK_END; tokindex++)
{
parse_token *token = &expr->token[tokindex];
if (token->type == TOK_NUMBER || token->type == TOK_SYMBOL || token->type == TOK_STRING)
*dest++ = *token;
else if (token->type == TOK_OPERATOR)
{
int exprerr = normalize_operator(expr, tokindex);
if (exprerr != 0)
return exprerr;
if (token->value.i == TVL_LPAREN)
{
exprerr = push_token(expr, token);
if (exprerr != 0)
return exprerr;
}
else if (token->value.i == TVL_RPAREN)
{
while ((peek = peek_token(expr, 0)) != NULL)
{
if (peek->value.i == TVL_LPAREN)
break;
exprerr = pop_token(expr, dest++);
if (exprerr != 0)
return exprerr;
}
if (peek == NULL)
return MAKE_EXPRERR_UNBALANCED_PARENS(token->offset);
exprerr = pop_token(expr, &dummy);
if (exprerr != 0)
return exprerr;
}
else
{
int our_precedence = token->info & TIN_PRECEDENCE_MASK;
while ((peek = peek_token(expr, 0)) != NULL)
{
int stack_precedence = peek->info & TIN_PRECEDENCE_MASK;
if (peek->value.i == TVL_LPAREN)
break;
if (stack_precedence > our_precedence)
break;
if (stack_precedence == our_precedence && (peek->info & TIN_RIGHT_TO_LEFT))
break;
exprerr = pop_token(expr, dest++);
if (exprerr != 0)
return exprerr;
}
exprerr = push_token(expr, token);
if (exprerr != 0)
return exprerr;
}
}
}
while ((peek = peek_token(expr, 0)) != NULL)
{
if (peek->value.i == TVL_LPAREN)
return MAKE_EXPRERR_UNBALANCED_PARENS(peek->offset);
exprerr = pop_token(expr, dest++);
if (exprerr != 0)
return exprerr;
}
*dest++ = expr->token[tokindex];
return EXPRERR_NONE;
} | [
"static",
"EXPRERR",
"infix_to_postfix",
"(",
"parsed_expression",
"*",
"expr",
")",
"{",
"parse_token",
"*",
"dest",
"=",
"expr",
"->",
"token",
";",
"parse_token",
"dummy",
";",
"parse_token",
"*",
"peek",
";",
"int",
"tokindex",
"=",
"0",
";",
"EXPRERR",
"exprerr",
";",
"memset",
"(",
"&",
"dummy",
",",
"0",
",",
"sizeof",
"(",
"dummy",
")",
")",
";",
"init_token_stack",
"(",
"expr",
")",
";",
"for",
"(",
";",
"expr",
"->",
"token",
"[",
"tokindex",
"]",
".",
"type",
"!=",
"TOK_END",
";",
"tokindex",
"++",
")",
"{",
"parse_token",
"*",
"token",
"=",
"&",
"expr",
"->",
"token",
"[",
"tokindex",
"]",
";",
"if",
"(",
"token",
"->",
"type",
"==",
"TOK_NUMBER",
"||",
"token",
"->",
"type",
"==",
"TOK_SYMBOL",
"||",
"token",
"->",
"type",
"==",
"TOK_STRING",
")",
"*",
"dest",
"++",
"=",
"*",
"token",
";",
"else",
"if",
"(",
"token",
"->",
"type",
"==",
"TOK_OPERATOR",
")",
"{",
"int",
"exprerr",
"=",
"normalize_operator",
"(",
"expr",
",",
"tokindex",
")",
";",
"if",
"(",
"exprerr",
"!=",
"0",
")",
"return",
"exprerr",
";",
"if",
"(",
"token",
"->",
"value",
".",
"i",
"==",
"TVL_LPAREN",
")",
"{",
"exprerr",
"=",
"push_token",
"(",
"expr",
",",
"token",
")",
";",
"if",
"(",
"exprerr",
"!=",
"0",
")",
"return",
"exprerr",
";",
"}",
"else",
"if",
"(",
"token",
"->",
"value",
".",
"i",
"==",
"TVL_RPAREN",
")",
"{",
"while",
"(",
"(",
"peek",
"=",
"peek_token",
"(",
"expr",
",",
"0",
")",
")",
"!=",
"NULL",
")",
"{",
"if",
"(",
"peek",
"->",
"value",
".",
"i",
"==",
"TVL_LPAREN",
")",
"break",
";",
"exprerr",
"=",
"pop_token",
"(",
"expr",
",",
"dest",
"++",
")",
";",
"if",
"(",
"exprerr",
"!=",
"0",
")",
"return",
"exprerr",
";",
"}",
"if",
"(",
"peek",
"==",
"NULL",
")",
"return",
"MAKE_EXPRERR_UNBALANCED_PARENS",
"(",
"token",
"->",
"offset",
")",
";",
"exprerr",
"=",
"pop_token",
"(",
"expr",
",",
"&",
"dummy",
")",
";",
"if",
"(",
"exprerr",
"!=",
"0",
")",
"return",
"exprerr",
";",
"}",
"else",
"{",
"int",
"our_precedence",
"=",
"token",
"->",
"info",
"&",
"TIN_PRECEDENCE_MASK",
";",
"while",
"(",
"(",
"peek",
"=",
"peek_token",
"(",
"expr",
",",
"0",
")",
")",
"!=",
"NULL",
")",
"{",
"int",
"stack_precedence",
"=",
"peek",
"->",
"info",
"&",
"TIN_PRECEDENCE_MASK",
";",
"if",
"(",
"peek",
"->",
"value",
".",
"i",
"==",
"TVL_LPAREN",
")",
"break",
";",
"if",
"(",
"stack_precedence",
">",
"our_precedence",
")",
"break",
";",
"if",
"(",
"stack_precedence",
"==",
"our_precedence",
"&&",
"(",
"peek",
"->",
"info",
"&",
"TIN_RIGHT_TO_LEFT",
")",
")",
"break",
";",
"exprerr",
"=",
"pop_token",
"(",
"expr",
",",
"dest",
"++",
")",
";",
"if",
"(",
"exprerr",
"!=",
"0",
")",
"return",
"exprerr",
";",
"}",
"exprerr",
"=",
"push_token",
"(",
"expr",
",",
"token",
")",
";",
"if",
"(",
"exprerr",
"!=",
"0",
")",
"return",
"exprerr",
";",
"}",
"}",
"}",
"while",
"(",
"(",
"peek",
"=",
"peek_token",
"(",
"expr",
",",
"0",
")",
")",
"!=",
"NULL",
")",
"{",
"if",
"(",
"peek",
"->",
"value",
".",
"i",
"==",
"TVL_LPAREN",
")",
"return",
"MAKE_EXPRERR_UNBALANCED_PARENS",
"(",
"peek",
"->",
"offset",
")",
";",
"exprerr",
"=",
"pop_token",
"(",
"expr",
",",
"dest",
"++",
")",
";",
"if",
"(",
"exprerr",
"!=",
"0",
")",
"return",
"exprerr",
";",
"}",
"*",
"dest",
"++",
"=",
"expr",
"->",
"token",
"[",
"tokindex",
"]",
";",
"return",
"EXPRERR_NONE",
";",
"}"
] | infix_to_postfix - convert an infix sequence
of tokens to a postfix sequence for processing | [
"infix_to_postfix",
"-",
"convert",
"an",
"infix",
"sequence",
"of",
"tokens",
"to",
"a",
"postfix",
"sequence",
"for",
"processing"
] | [
"/* start with an empty stack */",
"/* loop over all the original tokens */",
"/* If the character is an operand, append it to the result string */",
"/* If this is an operator, process it */",
"/* If the token is an opening parenthesis, push it onto the stack. */",
"/* If the token is a closing parenthesis, pop all operators until we\n reach an opening parenthesis and append them to the result string. */",
"/* loop until we can't peek at the stack anymore */",
"/* if we didn't find an open paren, it's an error */",
"/* pop the open paren off the stack */",
"/* If the token is an operator, pop operators until we reach an opening parenthesis,\n an operator of lower precedence, or a right associative symbol of equal precedence.\n Push the operator onto the stack. */",
"/* loop until we can't peek at the stack anymore */",
"/* break if any of the above conditions are true */",
"/* pop this token */",
"/* push the new operator */",
"/* finish popping the stack */",
"/* it is an error to have a left parenthesis still on the stack */",
"/* pop this token */",
"/* copy the end token to the final stream */"
] | [
{
"param": "expr",
"type": "parsed_expression"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "expr",
"type": "parsed_expression",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c81b6d4cd5156becd8d9d8cffd659a6a67e8b32 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/debug/express.c | [
"Unlicense"
] | C | add_expression_string | char | static char *add_expression_string(parsed_expression *expr, const char *string, int length, UINT16 *index)
{
expression_string *expstring;
/* allocate memory */
expstring = (expression_string *)malloc(sizeof(expression_string) + length);
if (expstring == NULL)
return NULL;
/* make the new string and link it in; we guarantee tha the index is never 0 */
expstring->next = expr->stringlist;
expstring->index = ++expr->stringcount;
memcpy(expstring->string, string, length);
expstring->string[length] = 0;
expr->stringlist = expstring;
/* return a pointer to the copied string */
if (index != NULL)
*index = expstring->index;
return expstring->string;
} | /*-------------------------------------------------
add_expression_string - add a string to the
list of expression strings
-------------------------------------------------*/ | add a string to the
list of expression strings | [
"add",
"a",
"string",
"to",
"the",
"list",
"of",
"expression",
"strings"
] | static char *add_expression_string(parsed_expression *expr, const char *string, int length, UINT16 *index)
{
expression_string *expstring;
expstring = (expression_string *)malloc(sizeof(expression_string) + length);
if (expstring == NULL)
return NULL;
expstring->next = expr->stringlist;
expstring->index = ++expr->stringcount;
memcpy(expstring->string, string, length);
expstring->string[length] = 0;
expr->stringlist = expstring;
if (index != NULL)
*index = expstring->index;
return expstring->string;
} | [
"static",
"char",
"*",
"add_expression_string",
"(",
"parsed_expression",
"*",
"expr",
",",
"const",
"char",
"*",
"string",
",",
"int",
"length",
",",
"UINT16",
"*",
"index",
")",
"{",
"expression_string",
"*",
"expstring",
";",
"expstring",
"=",
"(",
"expression_string",
"*",
")",
"malloc",
"(",
"sizeof",
"(",
"expression_string",
")",
"+",
"length",
")",
";",
"if",
"(",
"expstring",
"==",
"NULL",
")",
"return",
"NULL",
";",
"expstring",
"->",
"next",
"=",
"expr",
"->",
"stringlist",
";",
"expstring",
"->",
"index",
"=",
"++",
"expr",
"->",
"stringcount",
";",
"memcpy",
"(",
"expstring",
"->",
"string",
",",
"string",
",",
"length",
")",
";",
"expstring",
"->",
"string",
"[",
"length",
"]",
"=",
"0",
";",
"expr",
"->",
"stringlist",
"=",
"expstring",
";",
"if",
"(",
"index",
"!=",
"NULL",
")",
"*",
"index",
"=",
"expstring",
"->",
"index",
";",
"return",
"expstring",
"->",
"string",
";",
"}"
] | add_expression_string - add a string to the
list of expression strings | [
"add_expression_string",
"-",
"add",
"a",
"string",
"to",
"the",
"list",
"of",
"expression",
"strings"
] | [
"/* allocate memory */",
"/* make the new string and link it in; we guarantee tha the index is never 0 */",
"/* return a pointer to the copied string */"
] | [
{
"param": "expr",
"type": "parsed_expression"
},
{
"param": "string",
"type": "char"
},
{
"param": "length",
"type": "int"
},
{
"param": "index",
"type": "UINT16"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "expr",
"type": "parsed_expression",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "string",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "length",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "index",
"type": "UINT16",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c81b6d4cd5156becd8d9d8cffd659a6a67e8b32 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/debug/express.c | [
"Unlicense"
] | C | free_expression_strings | void | static void free_expression_strings(parsed_expression *expr)
{
/* free the original expression */
if (expr->original_string != NULL)
free(expr->original_string);
expr->original_string = NULL;
/* free all strings */
while (expr->stringlist != NULL)
{
expression_string *string = expr->stringlist;
expr->stringlist = string->next;
free(string);
}
} | /*-------------------------------------------------
free_expression_strings - free all strings
allocated to an expression
-------------------------------------------------*/ | free all strings
allocated to an expression | [
"free",
"all",
"strings",
"allocated",
"to",
"an",
"expression"
] | static void free_expression_strings(parsed_expression *expr)
{
if (expr->original_string != NULL)
free(expr->original_string);
expr->original_string = NULL;
while (expr->stringlist != NULL)
{
expression_string *string = expr->stringlist;
expr->stringlist = string->next;
free(string);
}
} | [
"static",
"void",
"free_expression_strings",
"(",
"parsed_expression",
"*",
"expr",
")",
"{",
"if",
"(",
"expr",
"->",
"original_string",
"!=",
"NULL",
")",
"free",
"(",
"expr",
"->",
"original_string",
")",
";",
"expr",
"->",
"original_string",
"=",
"NULL",
";",
"while",
"(",
"expr",
"->",
"stringlist",
"!=",
"NULL",
")",
"{",
"expression_string",
"*",
"string",
"=",
"expr",
"->",
"stringlist",
";",
"expr",
"->",
"stringlist",
"=",
"string",
"->",
"next",
";",
"free",
"(",
"string",
")",
";",
"}",
"}"
] | free_expression_strings - free all strings
allocated to an expression | [
"free_expression_strings",
"-",
"free",
"all",
"strings",
"allocated",
"to",
"an",
"expression"
] | [
"/* free the original expression */",
"/* free all strings */"
] | [
{
"param": "expr",
"type": "parsed_expression"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "expr",
"type": "parsed_expression",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c81b6d4cd5156becd8d9d8cffd659a6a67e8b32 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/debug/express.c | [
"Unlicense"
] | C | expression_evaluate | EXPRERR | EXPRERR expression_evaluate(const char *expression, const symbol_table *table, const express_callbacks *callbacks, void *cbparam, UINT64 *result)
{
parsed_expression temp_expression;
EXPRERR exprerr;
/* zap expression object and copy the callbacks */
memset(&temp_expression, 0, sizeof(temp_expression));
if (callbacks != NULL)
temp_expression.callbacks = *callbacks;
temp_expression.cbparam = cbparam;
/* first parse the tokens into the token array in order */
exprerr = parse_string_into_tokens(expression, &temp_expression, table);
if (exprerr != EXPRERR_NONE)
goto cleanup;
/* debugging */
print_tokens(stdout, &temp_expression);
/* convert the infix order to postfix order */
exprerr = infix_to_postfix(&temp_expression);
if (exprerr != EXPRERR_NONE)
goto cleanup;
/* debugging */
print_tokens(stdout, &temp_expression);
/* execute the expression to get the result */
exprerr = execute_tokens(&temp_expression, result);
cleanup:
free_expression_strings(&temp_expression);
return exprerr;
} | /*-------------------------------------------------
expression_evaluate - evaluate a string
expression using the passed symbol table
-------------------------------------------------*/ | evaluate a string
expression using the passed symbol table | [
"evaluate",
"a",
"string",
"expression",
"using",
"the",
"passed",
"symbol",
"table"
] | EXPRERR expression_evaluate(const char *expression, const symbol_table *table, const express_callbacks *callbacks, void *cbparam, UINT64 *result)
{
parsed_expression temp_expression;
EXPRERR exprerr;
memset(&temp_expression, 0, sizeof(temp_expression));
if (callbacks != NULL)
temp_expression.callbacks = *callbacks;
temp_expression.cbparam = cbparam;
exprerr = parse_string_into_tokens(expression, &temp_expression, table);
if (exprerr != EXPRERR_NONE)
goto cleanup;
print_tokens(stdout, &temp_expression);
exprerr = infix_to_postfix(&temp_expression);
if (exprerr != EXPRERR_NONE)
goto cleanup;
print_tokens(stdout, &temp_expression);
exprerr = execute_tokens(&temp_expression, result);
cleanup:
free_expression_strings(&temp_expression);
return exprerr;
} | [
"EXPRERR",
"expression_evaluate",
"(",
"const",
"char",
"*",
"expression",
",",
"const",
"symbol_table",
"*",
"table",
",",
"const",
"express_callbacks",
"*",
"callbacks",
",",
"void",
"*",
"cbparam",
",",
"UINT64",
"*",
"result",
")",
"{",
"parsed_expression",
"temp_expression",
";",
"EXPRERR",
"exprerr",
";",
"memset",
"(",
"&",
"temp_expression",
",",
"0",
",",
"sizeof",
"(",
"temp_expression",
")",
")",
";",
"if",
"(",
"callbacks",
"!=",
"NULL",
")",
"temp_expression",
".",
"callbacks",
"=",
"*",
"callbacks",
";",
"temp_expression",
".",
"cbparam",
"=",
"cbparam",
";",
"exprerr",
"=",
"parse_string_into_tokens",
"(",
"expression",
",",
"&",
"temp_expression",
",",
"table",
")",
";",
"if",
"(",
"exprerr",
"!=",
"EXPRERR_NONE",
")",
"goto",
"cleanup",
";",
"print_tokens",
"(",
"stdout",
",",
"&",
"temp_expression",
")",
";",
"exprerr",
"=",
"infix_to_postfix",
"(",
"&",
"temp_expression",
")",
";",
"if",
"(",
"exprerr",
"!=",
"EXPRERR_NONE",
")",
"goto",
"cleanup",
";",
"print_tokens",
"(",
"stdout",
",",
"&",
"temp_expression",
")",
";",
"exprerr",
"=",
"execute_tokens",
"(",
"&",
"temp_expression",
",",
"result",
")",
";",
"cleanup",
":",
"free_expression_strings",
"(",
"&",
"temp_expression",
")",
";",
"return",
"exprerr",
";",
"}"
] | expression_evaluate - evaluate a string
expression using the passed symbol table | [
"expression_evaluate",
"-",
"evaluate",
"a",
"string",
"expression",
"using",
"the",
"passed",
"symbol",
"table"
] | [
"/* zap expression object and copy the callbacks */",
"/* first parse the tokens into the token array in order */",
"/* debugging */",
"/* convert the infix order to postfix order */",
"/* debugging */",
"/* execute the expression to get the result */"
] | [
{
"param": "expression",
"type": "char"
},
{
"param": "table",
"type": "symbol_table"
},
{
"param": "callbacks",
"type": "express_callbacks"
},
{
"param": "cbparam",
"type": "void"
},
{
"param": "result",
"type": "UINT64"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "expression",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "table",
"type": "symbol_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "callbacks",
"type": "express_callbacks",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cbparam",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "result",
"type": "UINT64",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c81b6d4cd5156becd8d9d8cffd659a6a67e8b32 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/debug/express.c | [
"Unlicense"
] | C | expression_parse | EXPRERR | EXPRERR expression_parse(const char *expression, const symbol_table *table, const express_callbacks *callbacks, void *cbparam, parsed_expression **result)
{
parsed_expression temp_expression;
EXPRERR exprerr;
/* zap expression object and copy the callbacks */
memset(&temp_expression, 0, sizeof(temp_expression));
if (callbacks != NULL)
temp_expression.callbacks = *callbacks;
temp_expression.cbparam = cbparam;
/* first parse the tokens into the token array in order */
exprerr = parse_string_into_tokens(expression, &temp_expression, table);
if (exprerr != EXPRERR_NONE)
goto cleanup;
/* convert the infix order to postfix order */
exprerr = infix_to_postfix(&temp_expression);
if (exprerr != EXPRERR_NONE)
goto cleanup;
/* allocate memory for the result */
*result = (parsed_expression *)malloc(sizeof(temp_expression));
if (!*result)
{
exprerr = MAKE_EXPRERR_OUT_OF_MEMORY(0);
goto cleanup;
}
/* copy the final expression and return */
**result = temp_expression;
return EXPRERR_NONE;
cleanup:
free_expression_strings(&temp_expression);
return exprerr;
} | /*-------------------------------------------------
expression_parse - parse an expression and
return an allocated token array
-------------------------------------------------*/ | parse an expression and
return an allocated token array | [
"parse",
"an",
"expression",
"and",
"return",
"an",
"allocated",
"token",
"array"
] | EXPRERR expression_parse(const char *expression, const symbol_table *table, const express_callbacks *callbacks, void *cbparam, parsed_expression **result)
{
parsed_expression temp_expression;
EXPRERR exprerr;
memset(&temp_expression, 0, sizeof(temp_expression));
if (callbacks != NULL)
temp_expression.callbacks = *callbacks;
temp_expression.cbparam = cbparam;
exprerr = parse_string_into_tokens(expression, &temp_expression, table);
if (exprerr != EXPRERR_NONE)
goto cleanup;
exprerr = infix_to_postfix(&temp_expression);
if (exprerr != EXPRERR_NONE)
goto cleanup;
*result = (parsed_expression *)malloc(sizeof(temp_expression));
if (!*result)
{
exprerr = MAKE_EXPRERR_OUT_OF_MEMORY(0);
goto cleanup;
}
**result = temp_expression;
return EXPRERR_NONE;
cleanup:
free_expression_strings(&temp_expression);
return exprerr;
} | [
"EXPRERR",
"expression_parse",
"(",
"const",
"char",
"*",
"expression",
",",
"const",
"symbol_table",
"*",
"table",
",",
"const",
"express_callbacks",
"*",
"callbacks",
",",
"void",
"*",
"cbparam",
",",
"parsed_expression",
"*",
"*",
"result",
")",
"{",
"parsed_expression",
"temp_expression",
";",
"EXPRERR",
"exprerr",
";",
"memset",
"(",
"&",
"temp_expression",
",",
"0",
",",
"sizeof",
"(",
"temp_expression",
")",
")",
";",
"if",
"(",
"callbacks",
"!=",
"NULL",
")",
"temp_expression",
".",
"callbacks",
"=",
"*",
"callbacks",
";",
"temp_expression",
".",
"cbparam",
"=",
"cbparam",
";",
"exprerr",
"=",
"parse_string_into_tokens",
"(",
"expression",
",",
"&",
"temp_expression",
",",
"table",
")",
";",
"if",
"(",
"exprerr",
"!=",
"EXPRERR_NONE",
")",
"goto",
"cleanup",
";",
"exprerr",
"=",
"infix_to_postfix",
"(",
"&",
"temp_expression",
")",
";",
"if",
"(",
"exprerr",
"!=",
"EXPRERR_NONE",
")",
"goto",
"cleanup",
";",
"*",
"result",
"=",
"(",
"parsed_expression",
"*",
")",
"malloc",
"(",
"sizeof",
"(",
"temp_expression",
")",
")",
";",
"if",
"(",
"!",
"*",
"result",
")",
"{",
"exprerr",
"=",
"MAKE_EXPRERR_OUT_OF_MEMORY",
"(",
"0",
")",
";",
"goto",
"cleanup",
";",
"}",
"*",
"*",
"result",
"=",
"temp_expression",
";",
"return",
"EXPRERR_NONE",
";",
"cleanup",
":",
"free_expression_strings",
"(",
"&",
"temp_expression",
")",
";",
"return",
"exprerr",
";",
"}"
] | expression_parse - parse an expression and
return an allocated token array | [
"expression_parse",
"-",
"parse",
"an",
"expression",
"and",
"return",
"an",
"allocated",
"token",
"array"
] | [
"/* zap expression object and copy the callbacks */",
"/* first parse the tokens into the token array in order */",
"/* convert the infix order to postfix order */",
"/* allocate memory for the result */",
"/* copy the final expression and return */"
] | [
{
"param": "expression",
"type": "char"
},
{
"param": "table",
"type": "symbol_table"
},
{
"param": "callbacks",
"type": "express_callbacks"
},
{
"param": "cbparam",
"type": "void"
},
{
"param": "result",
"type": "parsed_expression"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "expression",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "table",
"type": "symbol_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "callbacks",
"type": "express_callbacks",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cbparam",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "result",
"type": "parsed_expression",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c81b6d4cd5156becd8d9d8cffd659a6a67e8b32 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/debug/express.c | [
"Unlicense"
] | C | expression_execute | EXPRERR | EXPRERR expression_execute(parsed_expression *expr, UINT64 *result)
{
/* execute the expression to get the result */
return execute_tokens(expr, result);
} | /*-------------------------------------------------
expression_execute - execute a
previously-parsed expression
-------------------------------------------------*/ | execute a
previously-parsed expression | [
"execute",
"a",
"previously",
"-",
"parsed",
"expression"
] | EXPRERR expression_execute(parsed_expression *expr, UINT64 *result)
{
return execute_tokens(expr, result);
} | [
"EXPRERR",
"expression_execute",
"(",
"parsed_expression",
"*",
"expr",
",",
"UINT64",
"*",
"result",
")",
"{",
"return",
"execute_tokens",
"(",
"expr",
",",
"result",
")",
";",
"}"
] | expression_execute - execute a
previously-parsed expression | [
"expression_execute",
"-",
"execute",
"a",
"previously",
"-",
"parsed",
"expression"
] | [
"/* execute the expression to get the result */"
] | [
{
"param": "expr",
"type": "parsed_expression"
},
{
"param": "result",
"type": "UINT64"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "expr",
"type": "parsed_expression",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "result",
"type": "UINT64",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c81b6d4cd5156becd8d9d8cffd659a6a67e8b32 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/debug/express.c | [
"Unlicense"
] | C | expression_free | void | void expression_free(parsed_expression *expr)
{
if (expr != NULL)
{
free_expression_strings(expr);
free(expr);
}
} | /*-------------------------------------------------
expression_free - free a previously
allocated parsed expression
-------------------------------------------------*/ | free a previously
allocated parsed expression | [
"free",
"a",
"previously",
"allocated",
"parsed",
"expression"
] | void expression_free(parsed_expression *expr)
{
if (expr != NULL)
{
free_expression_strings(expr);
free(expr);
}
} | [
"void",
"expression_free",
"(",
"parsed_expression",
"*",
"expr",
")",
"{",
"if",
"(",
"expr",
"!=",
"NULL",
")",
"{",
"free_expression_strings",
"(",
"expr",
")",
";",
"free",
"(",
"expr",
")",
";",
"}",
"}"
] | expression_free - free a previously
allocated parsed expression | [
"expression_free",
"-",
"free",
"a",
"previously",
"allocated",
"parsed",
"expression"
] | [] | [
{
"param": "expr",
"type": "parsed_expression"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "expr",
"type": "parsed_expression",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c81b6d4cd5156becd8d9d8cffd659a6a67e8b32 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/debug/express.c | [
"Unlicense"
] | C | exprerr_to_string | char | const char *exprerr_to_string(EXPRERR error)
{
switch (EXPRERR_ERROR_CLASS(error))
{
case EXPRERR_NOT_LVAL: return "not an lvalue";
case EXPRERR_NOT_RVAL: return "not an rvalue";
case EXPRERR_SYNTAX: return "syntax error";
case EXPRERR_UNKNOWN_SYMBOL: return "unknown symbol";
case EXPRERR_INVALID_NUMBER: return "invalid number";
case EXPRERR_INVALID_TOKEN: return "invalid token";
case EXPRERR_STACK_OVERFLOW: return "stack overflow";
case EXPRERR_STACK_UNDERFLOW: return "stack underflow";
case EXPRERR_UNBALANCED_PARENS: return "unbalanced parentheses";
case EXPRERR_DIVIDE_BY_ZERO: return "divide by zero";
case EXPRERR_OUT_OF_MEMORY: return "out of memory";
case EXPRERR_INVALID_PARAM_COUNT: return "invalid number of parameters";
case EXPRERR_UNBALANCED_QUOTES: return "unbalanced quotes";
case EXPRERR_TOO_MANY_STRINGS: return "too many strings";
case EXPRERR_INVALID_MEMORY_SIZE: return "invalid memory size (b/w/d/q expected)";
case EXPRERR_NO_SUCH_MEMORY_SPACE: return "non-existent memory space";
case EXPRERR_INVALID_MEMORY_SPACE: return "invalid memory space (p/d/i/o/r/m expected)";
case EXPRERR_INVALID_MEMORY_NAME: return "invalid memory name";
case EXPRERR_MISSING_MEMORY_NAME: return "missing memory name";
default: return "unknown error";
}
} | /*-------------------------------------------------
exprerr_to_string - return a friendly
string for a given expression error
-------------------------------------------------*/ | return a friendly
string for a given expression error | [
"return",
"a",
"friendly",
"string",
"for",
"a",
"given",
"expression",
"error"
] | const char *exprerr_to_string(EXPRERR error)
{
switch (EXPRERR_ERROR_CLASS(error))
{
case EXPRERR_NOT_LVAL: return "not an lvalue";
case EXPRERR_NOT_RVAL: return "not an rvalue";
case EXPRERR_SYNTAX: return "syntax error";
case EXPRERR_UNKNOWN_SYMBOL: return "unknown symbol";
case EXPRERR_INVALID_NUMBER: return "invalid number";
case EXPRERR_INVALID_TOKEN: return "invalid token";
case EXPRERR_STACK_OVERFLOW: return "stack overflow";
case EXPRERR_STACK_UNDERFLOW: return "stack underflow";
case EXPRERR_UNBALANCED_PARENS: return "unbalanced parentheses";
case EXPRERR_DIVIDE_BY_ZERO: return "divide by zero";
case EXPRERR_OUT_OF_MEMORY: return "out of memory";
case EXPRERR_INVALID_PARAM_COUNT: return "invalid number of parameters";
case EXPRERR_UNBALANCED_QUOTES: return "unbalanced quotes";
case EXPRERR_TOO_MANY_STRINGS: return "too many strings";
case EXPRERR_INVALID_MEMORY_SIZE: return "invalid memory size (b/w/d/q expected)";
case EXPRERR_NO_SUCH_MEMORY_SPACE: return "non-existent memory space";
case EXPRERR_INVALID_MEMORY_SPACE: return "invalid memory space (p/d/i/o/r/m expected)";
case EXPRERR_INVALID_MEMORY_NAME: return "invalid memory name";
case EXPRERR_MISSING_MEMORY_NAME: return "missing memory name";
default: return "unknown error";
}
} | [
"const",
"char",
"*",
"exprerr_to_string",
"(",
"EXPRERR",
"error",
")",
"{",
"switch",
"(",
"EXPRERR_ERROR_CLASS",
"(",
"error",
")",
")",
"{",
"case",
"EXPRERR_NOT_LVAL",
":",
"return",
"\"",
"\"",
";",
"case",
"EXPRERR_NOT_RVAL",
":",
"return",
"\"",
"\"",
";",
"case",
"EXPRERR_SYNTAX",
":",
"return",
"\"",
"\"",
";",
"case",
"EXPRERR_UNKNOWN_SYMBOL",
":",
"return",
"\"",
"\"",
";",
"case",
"EXPRERR_INVALID_NUMBER",
":",
"return",
"\"",
"\"",
";",
"case",
"EXPRERR_INVALID_TOKEN",
":",
"return",
"\"",
"\"",
";",
"case",
"EXPRERR_STACK_OVERFLOW",
":",
"return",
"\"",
"\"",
";",
"case",
"EXPRERR_STACK_UNDERFLOW",
":",
"return",
"\"",
"\"",
";",
"case",
"EXPRERR_UNBALANCED_PARENS",
":",
"return",
"\"",
"\"",
";",
"case",
"EXPRERR_DIVIDE_BY_ZERO",
":",
"return",
"\"",
"\"",
";",
"case",
"EXPRERR_OUT_OF_MEMORY",
":",
"return",
"\"",
"\"",
";",
"case",
"EXPRERR_INVALID_PARAM_COUNT",
":",
"return",
"\"",
"\"",
";",
"case",
"EXPRERR_UNBALANCED_QUOTES",
":",
"return",
"\"",
"\"",
";",
"case",
"EXPRERR_TOO_MANY_STRINGS",
":",
"return",
"\"",
"\"",
";",
"case",
"EXPRERR_INVALID_MEMORY_SIZE",
":",
"return",
"\"",
"\"",
";",
"case",
"EXPRERR_NO_SUCH_MEMORY_SPACE",
":",
"return",
"\"",
"\"",
";",
"case",
"EXPRERR_INVALID_MEMORY_SPACE",
":",
"return",
"\"",
"\"",
";",
"case",
"EXPRERR_INVALID_MEMORY_NAME",
":",
"return",
"\"",
"\"",
";",
"case",
"EXPRERR_MISSING_MEMORY_NAME",
":",
"return",
"\"",
"\"",
";",
"default",
":",
"return",
"\"",
"\"",
";",
"}",
"}"
] | exprerr_to_string - return a friendly
string for a given expression error | [
"exprerr_to_string",
"-",
"return",
"a",
"friendly",
"string",
"for",
"a",
"given",
"expression",
"error"
] | [] | [
{
"param": "error",
"type": "EXPRERR"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "error",
"type": "EXPRERR",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c81b6d4cd5156becd8d9d8cffd659a6a67e8b32 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/debug/express.c | [
"Unlicense"
] | C | symtable_add | int | int symtable_add(symbol_table *table, const char *name, const symbol_entry *entry)
{
internal_symbol_entry *symbol;
symbol_entry *oldentry;
char *newstring;
UINT32 hash_index;
int strindex;
int all_digits, i;
assert_always(entry->table == table, "Mismatched symbol tables");
/* we cannot add numeric symbols */
all_digits = TRUE;
for (i = 0; name[i]; i++)
{
if (!isdigit((UINT8)name[i]))
{
all_digits = FALSE;
break;
}
}
assert_always(!all_digits, "All-digit symbols are not allowed");
/* see if we already have an entry and just overwrite it if we do */
oldentry = (symbol_entry *)symtable_find(table, name);
if (oldentry)
{
*oldentry = *entry;
return 1;
}
/* otherwise, allocate a new entry */
symbol = (internal_symbol_entry *)malloc(sizeof(*symbol));
if (!symbol)
return 0;
memset(symbol, 0, sizeof(*symbol));
/* allocate space for a copy of the string */
newstring = (char *)malloc(strlen(name) + 1);
if (!newstring)
{
free(symbol);
return 0;
}
/* copy the string, converting to lowercase */
for (strindex = 0; name[strindex] != 0; strindex++)
newstring[strindex] = tolower((UINT8)name[strindex]);
newstring[strindex] = 0;
/* fill in the details */
symbol->name = newstring;
symbol->entry = *entry;
symbol->entry.table = table;
/* add the entry to the hash table */
hash_index = hash_string(newstring) % SYM_TABLE_HASH_SIZE;
symbol->next = table->hash[hash_index];
table->hash[hash_index] = symbol;
return 1;
} | /*-------------------------------------------------
symtable_add - add a new symbol to a
symbol table
-------------------------------------------------*/ | add a new symbol to a
symbol table | [
"add",
"a",
"new",
"symbol",
"to",
"a",
"symbol",
"table"
] | int symtable_add(symbol_table *table, const char *name, const symbol_entry *entry)
{
internal_symbol_entry *symbol;
symbol_entry *oldentry;
char *newstring;
UINT32 hash_index;
int strindex;
int all_digits, i;
assert_always(entry->table == table, "Mismatched symbol tables");
all_digits = TRUE;
for (i = 0; name[i]; i++)
{
if (!isdigit((UINT8)name[i]))
{
all_digits = FALSE;
break;
}
}
assert_always(!all_digits, "All-digit symbols are not allowed");
oldentry = (symbol_entry *)symtable_find(table, name);
if (oldentry)
{
*oldentry = *entry;
return 1;
}
symbol = (internal_symbol_entry *)malloc(sizeof(*symbol));
if (!symbol)
return 0;
memset(symbol, 0, sizeof(*symbol));
newstring = (char *)malloc(strlen(name) + 1);
if (!newstring)
{
free(symbol);
return 0;
}
for (strindex = 0; name[strindex] != 0; strindex++)
newstring[strindex] = tolower((UINT8)name[strindex]);
newstring[strindex] = 0;
symbol->name = newstring;
symbol->entry = *entry;
symbol->entry.table = table;
hash_index = hash_string(newstring) % SYM_TABLE_HASH_SIZE;
symbol->next = table->hash[hash_index];
table->hash[hash_index] = symbol;
return 1;
} | [
"int",
"symtable_add",
"(",
"symbol_table",
"*",
"table",
",",
"const",
"char",
"*",
"name",
",",
"const",
"symbol_entry",
"*",
"entry",
")",
"{",
"internal_symbol_entry",
"*",
"symbol",
";",
"symbol_entry",
"*",
"oldentry",
";",
"char",
"*",
"newstring",
";",
"UINT32",
"hash_index",
";",
"int",
"strindex",
";",
"int",
"all_digits",
",",
"i",
";",
"assert_always",
"(",
"entry",
"->",
"table",
"==",
"table",
",",
"\"",
"\"",
")",
";",
"all_digits",
"=",
"TRUE",
";",
"for",
"(",
"i",
"=",
"0",
";",
"name",
"[",
"i",
"]",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"isdigit",
"(",
"(",
"UINT8",
")",
"name",
"[",
"i",
"]",
")",
")",
"{",
"all_digits",
"=",
"FALSE",
";",
"break",
";",
"}",
"}",
"assert_always",
"(",
"!",
"all_digits",
",",
"\"",
"\"",
")",
";",
"oldentry",
"=",
"(",
"symbol_entry",
"*",
")",
"symtable_find",
"(",
"table",
",",
"name",
")",
";",
"if",
"(",
"oldentry",
")",
"{",
"*",
"oldentry",
"=",
"*",
"entry",
";",
"return",
"1",
";",
"}",
"symbol",
"=",
"(",
"internal_symbol_entry",
"*",
")",
"malloc",
"(",
"sizeof",
"(",
"*",
"symbol",
")",
")",
";",
"if",
"(",
"!",
"symbol",
")",
"return",
"0",
";",
"memset",
"(",
"symbol",
",",
"0",
",",
"sizeof",
"(",
"*",
"symbol",
")",
")",
";",
"newstring",
"=",
"(",
"char",
"*",
")",
"malloc",
"(",
"strlen",
"(",
"name",
")",
"+",
"1",
")",
";",
"if",
"(",
"!",
"newstring",
")",
"{",
"free",
"(",
"symbol",
")",
";",
"return",
"0",
";",
"}",
"for",
"(",
"strindex",
"=",
"0",
";",
"name",
"[",
"strindex",
"]",
"!=",
"0",
";",
"strindex",
"++",
")",
"newstring",
"[",
"strindex",
"]",
"=",
"tolower",
"(",
"(",
"UINT8",
")",
"name",
"[",
"strindex",
"]",
")",
";",
"newstring",
"[",
"strindex",
"]",
"=",
"0",
";",
"symbol",
"->",
"name",
"=",
"newstring",
";",
"symbol",
"->",
"entry",
"=",
"*",
"entry",
";",
"symbol",
"->",
"entry",
".",
"table",
"=",
"table",
";",
"hash_index",
"=",
"hash_string",
"(",
"newstring",
")",
"%",
"SYM_TABLE_HASH_SIZE",
";",
"symbol",
"->",
"next",
"=",
"table",
"->",
"hash",
"[",
"hash_index",
"]",
";",
"table",
"->",
"hash",
"[",
"hash_index",
"]",
"=",
"symbol",
";",
"return",
"1",
";",
"}"
] | symtable_add - add a new symbol to a
symbol table | [
"symtable_add",
"-",
"add",
"a",
"new",
"symbol",
"to",
"a",
"symbol",
"table"
] | [
"/* we cannot add numeric symbols */",
"/* see if we already have an entry and just overwrite it if we do */",
"/* otherwise, allocate a new entry */",
"/* allocate space for a copy of the string */",
"/* copy the string, converting to lowercase */",
"/* fill in the details */",
"/* add the entry to the hash table */"
] | [
{
"param": "table",
"type": "symbol_table"
},
{
"param": "name",
"type": "char"
},
{
"param": "entry",
"type": "symbol_entry"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "table",
"type": "symbol_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "entry",
"type": "symbol_entry",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c81b6d4cd5156becd8d9d8cffd659a6a67e8b32 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/debug/express.c | [
"Unlicense"
] | C | symtable_add_register | int | int symtable_add_register(symbol_table *table, const char *name, void *symref, symbol_getter_func getter, symbol_setter_func setter)
{
symbol_entry symbol;
symbol.ref = symref;
symbol.type = SMT_REGISTER;
symbol.info.reg.getter = getter;
symbol.info.reg.setter = setter;
symbol.table = table;
return symtable_add(table, name, &symbol);
} | /*-------------------------------------------------
symtable_add_register - add a new
register symbol to a symbol table
-------------------------------------------------*/ | add a new
register symbol to a symbol table | [
"add",
"a",
"new",
"register",
"symbol",
"to",
"a",
"symbol",
"table"
] | int symtable_add_register(symbol_table *table, const char *name, void *symref, symbol_getter_func getter, symbol_setter_func setter)
{
symbol_entry symbol;
symbol.ref = symref;
symbol.type = SMT_REGISTER;
symbol.info.reg.getter = getter;
symbol.info.reg.setter = setter;
symbol.table = table;
return symtable_add(table, name, &symbol);
} | [
"int",
"symtable_add_register",
"(",
"symbol_table",
"*",
"table",
",",
"const",
"char",
"*",
"name",
",",
"void",
"*",
"symref",
",",
"symbol_getter_func",
"getter",
",",
"symbol_setter_func",
"setter",
")",
"{",
"symbol_entry",
"symbol",
";",
"symbol",
".",
"ref",
"=",
"symref",
";",
"symbol",
".",
"type",
"=",
"SMT_REGISTER",
";",
"symbol",
".",
"info",
".",
"reg",
".",
"getter",
"=",
"getter",
";",
"symbol",
".",
"info",
".",
"reg",
".",
"setter",
"=",
"setter",
";",
"symbol",
".",
"table",
"=",
"table",
";",
"return",
"symtable_add",
"(",
"table",
",",
"name",
",",
"&",
"symbol",
")",
";",
"}"
] | symtable_add_register - add a new
register symbol to a symbol table | [
"symtable_add_register",
"-",
"add",
"a",
"new",
"register",
"symbol",
"to",
"a",
"symbol",
"table"
] | [] | [
{
"param": "table",
"type": "symbol_table"
},
{
"param": "name",
"type": "char"
},
{
"param": "symref",
"type": "void"
},
{
"param": "getter",
"type": "symbol_getter_func"
},
{
"param": "setter",
"type": "symbol_setter_func"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "table",
"type": "symbol_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "symref",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "getter",
"type": "symbol_getter_func",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "setter",
"type": "symbol_setter_func",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c81b6d4cd5156becd8d9d8cffd659a6a67e8b32 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/debug/express.c | [
"Unlicense"
] | C | symtable_add_function | int | int symtable_add_function(symbol_table *table, const char *name, void *symref, UINT16 minparams, UINT16 maxparams, function_execute_func execute)
{
symbol_entry symbol;
symbol.ref = symref;
symbol.type = SMT_FUNCTION;
symbol.info.func.minparams = minparams;
symbol.info.func.maxparams = maxparams;
symbol.info.func.execute = execute;
symbol.table = table;
return symtable_add(table, name, &symbol);
} | /*-------------------------------------------------
symtable_add_function - add a new
function symbol to a symbol table
-------------------------------------------------*/ | add a new
function symbol to a symbol table | [
"add",
"a",
"new",
"function",
"symbol",
"to",
"a",
"symbol",
"table"
] | int symtable_add_function(symbol_table *table, const char *name, void *symref, UINT16 minparams, UINT16 maxparams, function_execute_func execute)
{
symbol_entry symbol;
symbol.ref = symref;
symbol.type = SMT_FUNCTION;
symbol.info.func.minparams = minparams;
symbol.info.func.maxparams = maxparams;
symbol.info.func.execute = execute;
symbol.table = table;
return symtable_add(table, name, &symbol);
} | [
"int",
"symtable_add_function",
"(",
"symbol_table",
"*",
"table",
",",
"const",
"char",
"*",
"name",
",",
"void",
"*",
"symref",
",",
"UINT16",
"minparams",
",",
"UINT16",
"maxparams",
",",
"function_execute_func",
"execute",
")",
"{",
"symbol_entry",
"symbol",
";",
"symbol",
".",
"ref",
"=",
"symref",
";",
"symbol",
".",
"type",
"=",
"SMT_FUNCTION",
";",
"symbol",
".",
"info",
".",
"func",
".",
"minparams",
"=",
"minparams",
";",
"symbol",
".",
"info",
".",
"func",
".",
"maxparams",
"=",
"maxparams",
";",
"symbol",
".",
"info",
".",
"func",
".",
"execute",
"=",
"execute",
";",
"symbol",
".",
"table",
"=",
"table",
";",
"return",
"symtable_add",
"(",
"table",
",",
"name",
",",
"&",
"symbol",
")",
";",
"}"
] | symtable_add_function - add a new
function symbol to a symbol table | [
"symtable_add_function",
"-",
"add",
"a",
"new",
"function",
"symbol",
"to",
"a",
"symbol",
"table"
] | [] | [
{
"param": "table",
"type": "symbol_table"
},
{
"param": "name",
"type": "char"
},
{
"param": "symref",
"type": "void"
},
{
"param": "minparams",
"type": "UINT16"
},
{
"param": "maxparams",
"type": "UINT16"
},
{
"param": "execute",
"type": "function_execute_func"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "table",
"type": "symbol_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "symref",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "minparams",
"type": "UINT16",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "maxparams",
"type": "UINT16",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "execute",
"type": "function_execute_func",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c81b6d4cd5156becd8d9d8cffd659a6a67e8b32 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/debug/express.c | [
"Unlicense"
] | C | symtable_add_value | int | int symtable_add_value(symbol_table *table, const char *name, UINT64 value)
{
symbol_entry symbol;
symbol.ref = NULL;
symbol.type = SMT_VALUE;
symbol.info.gen.value = value;
symbol.table = table;
return symtable_add(table, name, &symbol);
} | /*-------------------------------------------------
symtable_add_value - add a new
value symbol to a symbol table
-------------------------------------------------*/ | add a new
value symbol to a symbol table | [
"add",
"a",
"new",
"value",
"symbol",
"to",
"a",
"symbol",
"table"
] | int symtable_add_value(symbol_table *table, const char *name, UINT64 value)
{
symbol_entry symbol;
symbol.ref = NULL;
symbol.type = SMT_VALUE;
symbol.info.gen.value = value;
symbol.table = table;
return symtable_add(table, name, &symbol);
} | [
"int",
"symtable_add_value",
"(",
"symbol_table",
"*",
"table",
",",
"const",
"char",
"*",
"name",
",",
"UINT64",
"value",
")",
"{",
"symbol_entry",
"symbol",
";",
"symbol",
".",
"ref",
"=",
"NULL",
";",
"symbol",
".",
"type",
"=",
"SMT_VALUE",
";",
"symbol",
".",
"info",
".",
"gen",
".",
"value",
"=",
"value",
";",
"symbol",
".",
"table",
"=",
"table",
";",
"return",
"symtable_add",
"(",
"table",
",",
"name",
",",
"&",
"symbol",
")",
";",
"}"
] | symtable_add_value - add a new
value symbol to a symbol table | [
"symtable_add_value",
"-",
"add",
"a",
"new",
"value",
"symbol",
"to",
"a",
"symbol",
"table"
] | [] | [
{
"param": "table",
"type": "symbol_table"
},
{
"param": "name",
"type": "char"
},
{
"param": "value",
"type": "UINT64"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "table",
"type": "symbol_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "value",
"type": "UINT64",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c81b6d4cd5156becd8d9d8cffd659a6a67e8b32 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/debug/express.c | [
"Unlicense"
] | C | symtable_find | symbol_entry | const symbol_entry *symtable_find(const symbol_table *table, const char *name)
{
UINT32 hash_index = hash_string(name) % SYM_TABLE_HASH_SIZE;
const internal_symbol_entry *symbol;
/* loop until we run out of tables */
while (table)
{
/* search linearly within this hash entry */
for (symbol = table->hash[hash_index]; symbol; symbol = symbol->next)
if (!strcmp(symbol->name, name))
return &symbol->entry;
/* look in the parent */
table = table->parent;
}
return NULL;
} | /*-------------------------------------------------
symtable_find - find a symbol in a symbol
table
-------------------------------------------------*/ | find a symbol in a symbol
table | [
"find",
"a",
"symbol",
"in",
"a",
"symbol",
"table"
] | const symbol_entry *symtable_find(const symbol_table *table, const char *name)
{
UINT32 hash_index = hash_string(name) % SYM_TABLE_HASH_SIZE;
const internal_symbol_entry *symbol;
while (table)
{
for (symbol = table->hash[hash_index]; symbol; symbol = symbol->next)
if (!strcmp(symbol->name, name))
return &symbol->entry;
table = table->parent;
}
return NULL;
} | [
"const",
"symbol_entry",
"*",
"symtable_find",
"(",
"const",
"symbol_table",
"*",
"table",
",",
"const",
"char",
"*",
"name",
")",
"{",
"UINT32",
"hash_index",
"=",
"hash_string",
"(",
"name",
")",
"%",
"SYM_TABLE_HASH_SIZE",
";",
"const",
"internal_symbol_entry",
"*",
"symbol",
";",
"while",
"(",
"table",
")",
"{",
"for",
"(",
"symbol",
"=",
"table",
"->",
"hash",
"[",
"hash_index",
"]",
";",
"symbol",
";",
"symbol",
"=",
"symbol",
"->",
"next",
")",
"if",
"(",
"!",
"strcmp",
"(",
"symbol",
"->",
"name",
",",
"name",
")",
")",
"return",
"&",
"symbol",
"->",
"entry",
";",
"table",
"=",
"table",
"->",
"parent",
";",
"}",
"return",
"NULL",
";",
"}"
] | symtable_find - find a symbol in a symbol
table | [
"symtable_find",
"-",
"find",
"a",
"symbol",
"in",
"a",
"symbol",
"table"
] | [
"/* loop until we run out of tables */",
"/* search linearly within this hash entry */",
"/* look in the parent */"
] | [
{
"param": "table",
"type": "symbol_table"
},
{
"param": "name",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "table",
"type": "symbol_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c81b6d4cd5156becd8d9d8cffd659a6a67e8b32 | lofunz/mieme | Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/debug/express.c | [
"Unlicense"
] | C | symtable_find_indexed | char | const char *symtable_find_indexed(const symbol_table *table, int index, const symbol_entry **entry)
{
const internal_symbol_entry *symbol;
int hash_index;
/* loop over hash entries, then over entries within each bucket */
for (hash_index = 0; hash_index < SYM_TABLE_HASH_SIZE; hash_index++)
for (symbol = table->hash[hash_index]; symbol; symbol = symbol->next)
if (index-- == 0)
{
if (entry)
*entry = &symbol->entry;
return symbol->name;
}
return NULL;
} | /*-------------------------------------------------
symtable_find_indexed - find an indexed symbol
in a symbol table
-------------------------------------------------*/ | find an indexed symbol
in a symbol table | [
"find",
"an",
"indexed",
"symbol",
"in",
"a",
"symbol",
"table"
] | const char *symtable_find_indexed(const symbol_table *table, int index, const symbol_entry **entry)
{
const internal_symbol_entry *symbol;
int hash_index;
for (hash_index = 0; hash_index < SYM_TABLE_HASH_SIZE; hash_index++)
for (symbol = table->hash[hash_index]; symbol; symbol = symbol->next)
if (index-- == 0)
{
if (entry)
*entry = &symbol->entry;
return symbol->name;
}
return NULL;
} | [
"const",
"char",
"*",
"symtable_find_indexed",
"(",
"const",
"symbol_table",
"*",
"table",
",",
"int",
"index",
",",
"const",
"symbol_entry",
"*",
"*",
"entry",
")",
"{",
"const",
"internal_symbol_entry",
"*",
"symbol",
";",
"int",
"hash_index",
";",
"for",
"(",
"hash_index",
"=",
"0",
";",
"hash_index",
"<",
"SYM_TABLE_HASH_SIZE",
";",
"hash_index",
"++",
")",
"for",
"(",
"symbol",
"=",
"table",
"->",
"hash",
"[",
"hash_index",
"]",
";",
"symbol",
";",
"symbol",
"=",
"symbol",
"->",
"next",
")",
"if",
"(",
"index",
"--",
"==",
"0",
")",
"{",
"if",
"(",
"entry",
")",
"*",
"entry",
"=",
"&",
"symbol",
"->",
"entry",
";",
"return",
"symbol",
"->",
"name",
";",
"}",
"return",
"NULL",
";",
"}"
] | symtable_find_indexed - find an indexed symbol
in a symbol table | [
"symtable_find_indexed",
"-",
"find",
"an",
"indexed",
"symbol",
"in",
"a",
"symbol",
"table"
] | [
"/* loop over hash entries, then over entries within each bucket */"
] | [
{
"param": "table",
"type": "symbol_table"
},
{
"param": "index",
"type": "int"
},
{
"param": "entry",
"type": "symbol_entry"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "table",
"type": "symbol_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "index",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "entry",
"type": "symbol_entry",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
555774830412f4457247ab31f4e20b521972476f | lofunz/mieme | Reloaded/trunk/src/emu/cpu/drcbeut.c | [
"Unlicense"
] | C | drchash_alloc | drchash_state | drchash_state *drchash_alloc(drccache *cache, int modes, int addrbits, int ignorebits)
{
int effaddrbits = addrbits - ignorebits;
drchash_state *drchash;
/* allocate permanent state from the cache */
drchash = (drchash_state *)drccache_memory_alloc(cache, sizeof(*drchash) + modes * sizeof(drchash->base[0]));
if (drchash == NULL)
return NULL;
memset(drchash, 0, sizeof(*drchash) + modes * sizeof(drchash->base[0]));
/* copy in parameters */
drchash->cache = cache;
drchash->modes = modes;
/* compute the sizes of the tables */
drchash->l1bits = effaddrbits / 2;
drchash->l2bits = effaddrbits - drchash->l1bits;
drchash->l1shift = ignorebits + drchash->l2bits;
drchash->l2shift = ignorebits;
drchash->l1mask = (1 << drchash->l1bits) - 1;
drchash->l2mask = (1 << drchash->l2bits) - 1;
/* reset the hash table, which allocates any subsequent tables */
if (!drchash_reset(drchash))
return NULL;
return drchash;
} | /*-------------------------------------------------
drchash_alloc - allocate memory in the cache
for the hash table tracker (it auto-frees
with the cache)
-------------------------------------------------*/ | allocate memory in the cache
for the hash table tracker (it auto-frees
with the cache) | [
"allocate",
"memory",
"in",
"the",
"cache",
"for",
"the",
"hash",
"table",
"tracker",
"(",
"it",
"auto",
"-",
"frees",
"with",
"the",
"cache",
")"
] | drchash_state *drchash_alloc(drccache *cache, int modes, int addrbits, int ignorebits)
{
int effaddrbits = addrbits - ignorebits;
drchash_state *drchash;
drchash = (drchash_state *)drccache_memory_alloc(cache, sizeof(*drchash) + modes * sizeof(drchash->base[0]));
if (drchash == NULL)
return NULL;
memset(drchash, 0, sizeof(*drchash) + modes * sizeof(drchash->base[0]));
drchash->cache = cache;
drchash->modes = modes;
drchash->l1bits = effaddrbits / 2;
drchash->l2bits = effaddrbits - drchash->l1bits;
drchash->l1shift = ignorebits + drchash->l2bits;
drchash->l2shift = ignorebits;
drchash->l1mask = (1 << drchash->l1bits) - 1;
drchash->l2mask = (1 << drchash->l2bits) - 1;
if (!drchash_reset(drchash))
return NULL;
return drchash;
} | [
"drchash_state",
"*",
"drchash_alloc",
"(",
"drccache",
"*",
"cache",
",",
"int",
"modes",
",",
"int",
"addrbits",
",",
"int",
"ignorebits",
")",
"{",
"int",
"effaddrbits",
"=",
"addrbits",
"-",
"ignorebits",
";",
"drchash_state",
"*",
"drchash",
";",
"drchash",
"=",
"(",
"drchash_state",
"*",
")",
"drccache_memory_alloc",
"(",
"cache",
",",
"sizeof",
"(",
"*",
"drchash",
")",
"+",
"modes",
"*",
"sizeof",
"(",
"drchash",
"->",
"base",
"[",
"0",
"]",
")",
")",
";",
"if",
"(",
"drchash",
"==",
"NULL",
")",
"return",
"NULL",
";",
"memset",
"(",
"drchash",
",",
"0",
",",
"sizeof",
"(",
"*",
"drchash",
")",
"+",
"modes",
"*",
"sizeof",
"(",
"drchash",
"->",
"base",
"[",
"0",
"]",
")",
")",
";",
"drchash",
"->",
"cache",
"=",
"cache",
";",
"drchash",
"->",
"modes",
"=",
"modes",
";",
"drchash",
"->",
"l1bits",
"=",
"effaddrbits",
"/",
"2",
";",
"drchash",
"->",
"l2bits",
"=",
"effaddrbits",
"-",
"drchash",
"->",
"l1bits",
";",
"drchash",
"->",
"l1shift",
"=",
"ignorebits",
"+",
"drchash",
"->",
"l2bits",
";",
"drchash",
"->",
"l2shift",
"=",
"ignorebits",
";",
"drchash",
"->",
"l1mask",
"=",
"(",
"1",
"<<",
"drchash",
"->",
"l1bits",
")",
"-",
"1",
";",
"drchash",
"->",
"l2mask",
"=",
"(",
"1",
"<<",
"drchash",
"->",
"l2bits",
")",
"-",
"1",
";",
"if",
"(",
"!",
"drchash_reset",
"(",
"drchash",
")",
")",
"return",
"NULL",
";",
"return",
"drchash",
";",
"}"
] | drchash_alloc - allocate memory in the cache
for the hash table tracker (it auto-frees
with the cache) | [
"drchash_alloc",
"-",
"allocate",
"memory",
"in",
"the",
"cache",
"for",
"the",
"hash",
"table",
"tracker",
"(",
"it",
"auto",
"-",
"frees",
"with",
"the",
"cache",
")"
] | [
"/* allocate permanent state from the cache */",
"/* copy in parameters */",
"/* compute the sizes of the tables */",
"/* reset the hash table, which allocates any subsequent tables */"
] | [
{
"param": "cache",
"type": "drccache"
},
{
"param": "modes",
"type": "int"
},
{
"param": "addrbits",
"type": "int"
},
{
"param": "ignorebits",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cache",
"type": "drccache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "modes",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrbits",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ignorebits",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
555774830412f4457247ab31f4e20b521972476f | lofunz/mieme | Reloaded/trunk/src/emu/cpu/drcbeut.c | [
"Unlicense"
] | C | drchash_reset | int | int drchash_reset(drchash_state *drchash)
{
int modenum, entry;
/* allocate an empty l2 hash table */
drchash->emptyl2 = (drccodeptr *)drccache_memory_alloc_temporary(drchash->cache, sizeof(drccodeptr) << drchash->l2bits);
if (drchash->emptyl2 == NULL)
return FALSE;
/* populate it with pointers to the recompile_exit code */
for (entry = 0; entry < (1 << drchash->l2bits); entry++)
drchash->emptyl2[entry] = drchash->nocodeptr;
/* allocate an empty l1 hash table */
drchash->emptyl1 = (drccodeptr **)drccache_memory_alloc_temporary(drchash->cache, sizeof(drccodeptr *) << drchash->l1bits);
if (drchash->emptyl1 == NULL)
return FALSE;
/* populate it with pointers to the empty l2 table */
for (entry = 0; entry < (1 << drchash->l1bits); entry++)
drchash->emptyl1[entry] = drchash->emptyl2;
/* reset the hash tables */
for (modenum = 0; modenum < drchash->modes; modenum++)
drchash->base[modenum] = drchash->emptyl1;
return TRUE;
} | /*-------------------------------------------------
drchash_reset - flush existing hash tables and
create new ones
-------------------------------------------------*/ | flush existing hash tables and
create new ones | [
"flush",
"existing",
"hash",
"tables",
"and",
"create",
"new",
"ones"
] | int drchash_reset(drchash_state *drchash)
{
int modenum, entry;
drchash->emptyl2 = (drccodeptr *)drccache_memory_alloc_temporary(drchash->cache, sizeof(drccodeptr) << drchash->l2bits);
if (drchash->emptyl2 == NULL)
return FALSE;
for (entry = 0; entry < (1 << drchash->l2bits); entry++)
drchash->emptyl2[entry] = drchash->nocodeptr;
drchash->emptyl1 = (drccodeptr **)drccache_memory_alloc_temporary(drchash->cache, sizeof(drccodeptr *) << drchash->l1bits);
if (drchash->emptyl1 == NULL)
return FALSE;
for (entry = 0; entry < (1 << drchash->l1bits); entry++)
drchash->emptyl1[entry] = drchash->emptyl2;
for (modenum = 0; modenum < drchash->modes; modenum++)
drchash->base[modenum] = drchash->emptyl1;
return TRUE;
} | [
"int",
"drchash_reset",
"(",
"drchash_state",
"*",
"drchash",
")",
"{",
"int",
"modenum",
",",
"entry",
";",
"drchash",
"->",
"emptyl2",
"=",
"(",
"drccodeptr",
"*",
")",
"drccache_memory_alloc_temporary",
"(",
"drchash",
"->",
"cache",
",",
"sizeof",
"(",
"drccodeptr",
")",
"<<",
"drchash",
"->",
"l2bits",
")",
";",
"if",
"(",
"drchash",
"->",
"emptyl2",
"==",
"NULL",
")",
"return",
"FALSE",
";",
"for",
"(",
"entry",
"=",
"0",
";",
"entry",
"<",
"(",
"1",
"<<",
"drchash",
"->",
"l2bits",
")",
";",
"entry",
"++",
")",
"drchash",
"->",
"emptyl2",
"[",
"entry",
"]",
"=",
"drchash",
"->",
"nocodeptr",
";",
"drchash",
"->",
"emptyl1",
"=",
"(",
"drccodeptr",
"*",
"*",
")",
"drccache_memory_alloc_temporary",
"(",
"drchash",
"->",
"cache",
",",
"sizeof",
"(",
"drccodeptr",
"*",
")",
"<<",
"drchash",
"->",
"l1bits",
")",
";",
"if",
"(",
"drchash",
"->",
"emptyl1",
"==",
"NULL",
")",
"return",
"FALSE",
";",
"for",
"(",
"entry",
"=",
"0",
";",
"entry",
"<",
"(",
"1",
"<<",
"drchash",
"->",
"l1bits",
")",
";",
"entry",
"++",
")",
"drchash",
"->",
"emptyl1",
"[",
"entry",
"]",
"=",
"drchash",
"->",
"emptyl2",
";",
"for",
"(",
"modenum",
"=",
"0",
";",
"modenum",
"<",
"drchash",
"->",
"modes",
";",
"modenum",
"++",
")",
"drchash",
"->",
"base",
"[",
"modenum",
"]",
"=",
"drchash",
"->",
"emptyl1",
";",
"return",
"TRUE",
";",
"}"
] | drchash_reset - flush existing hash tables and
create new ones | [
"drchash_reset",
"-",
"flush",
"existing",
"hash",
"tables",
"and",
"create",
"new",
"ones"
] | [
"/* allocate an empty l2 hash table */",
"/* populate it with pointers to the recompile_exit code */",
"/* allocate an empty l1 hash table */",
"/* populate it with pointers to the empty l2 table */",
"/* reset the hash tables */"
] | [
{
"param": "drchash",
"type": "drchash_state"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "drchash",
"type": "drchash_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
555774830412f4457247ab31f4e20b521972476f | lofunz/mieme | Reloaded/trunk/src/emu/cpu/drcbeut.c | [
"Unlicense"
] | C | drchash_block_begin | void | void drchash_block_begin(drchash_state *drchash, drcuml_block *block, const drcuml_instruction *instlist, UINT32 numinst)
{
int inum;
/* before generating code, pre-allocate any hash entries; we do this by setting dummy hash values */
for (inum = 0; inum < numinst; inum++)
{
const drcuml_instruction *inst = &instlist[inum];
/* if the opcode is a hash, verify that it makes sense and then set a NULL entry */
if (inst->opcode == DRCUML_OP_HASH)
{
assert(inst->numparams == 2);
assert(inst->param[0].type == DRCUML_PTYPE_IMMEDIATE);
assert(inst->param[1].type == DRCUML_PTYPE_IMMEDIATE);
/* if we fail to allocate, we must abort the block */
if (!drchash_set_codeptr(drchash, inst->param[0].value, inst->param[1].value, NULL))
drcuml_block_abort(block);
}
/* if the opcode is a hashjmp to a fixed location, make sure we preallocate the tables */
if (inst->opcode == DRCUML_OP_HASHJMP && inst->param[0].type == DRCUML_PTYPE_IMMEDIATE && inst->param[1].type == DRCUML_PTYPE_IMMEDIATE)
{
/* if we fail to allocate, we must abort the block */
drccodeptr code = drchash_get_codeptr(drchash, inst->param[0].value, inst->param[1].value);
if (!drchash_set_codeptr(drchash, inst->param[0].value, inst->param[1].value, code))
drcuml_block_abort(block);
}
}
} | /*-------------------------------------------------
drchash_block_begin - note the beginning of a
block
-------------------------------------------------*/ | note the beginning of a
block | [
"note",
"the",
"beginning",
"of",
"a",
"block"
] | void drchash_block_begin(drchash_state *drchash, drcuml_block *block, const drcuml_instruction *instlist, UINT32 numinst)
{
int inum;
for (inum = 0; inum < numinst; inum++)
{
const drcuml_instruction *inst = &instlist[inum];
if (inst->opcode == DRCUML_OP_HASH)
{
assert(inst->numparams == 2);
assert(inst->param[0].type == DRCUML_PTYPE_IMMEDIATE);
assert(inst->param[1].type == DRCUML_PTYPE_IMMEDIATE);
if (!drchash_set_codeptr(drchash, inst->param[0].value, inst->param[1].value, NULL))
drcuml_block_abort(block);
}
if (inst->opcode == DRCUML_OP_HASHJMP && inst->param[0].type == DRCUML_PTYPE_IMMEDIATE && inst->param[1].type == DRCUML_PTYPE_IMMEDIATE)
{
drccodeptr code = drchash_get_codeptr(drchash, inst->param[0].value, inst->param[1].value);
if (!drchash_set_codeptr(drchash, inst->param[0].value, inst->param[1].value, code))
drcuml_block_abort(block);
}
}
} | [
"void",
"drchash_block_begin",
"(",
"drchash_state",
"*",
"drchash",
",",
"drcuml_block",
"*",
"block",
",",
"const",
"drcuml_instruction",
"*",
"instlist",
",",
"UINT32",
"numinst",
")",
"{",
"int",
"inum",
";",
"for",
"(",
"inum",
"=",
"0",
";",
"inum",
"<",
"numinst",
";",
"inum",
"++",
")",
"{",
"const",
"drcuml_instruction",
"*",
"inst",
"=",
"&",
"instlist",
"[",
"inum",
"]",
";",
"if",
"(",
"inst",
"->",
"opcode",
"==",
"DRCUML_OP_HASH",
")",
"{",
"assert",
"(",
"inst",
"->",
"numparams",
"==",
"2",
")",
";",
"assert",
"(",
"inst",
"->",
"param",
"[",
"0",
"]",
".",
"type",
"==",
"DRCUML_PTYPE_IMMEDIATE",
")",
";",
"assert",
"(",
"inst",
"->",
"param",
"[",
"1",
"]",
".",
"type",
"==",
"DRCUML_PTYPE_IMMEDIATE",
")",
";",
"if",
"(",
"!",
"drchash_set_codeptr",
"(",
"drchash",
",",
"inst",
"->",
"param",
"[",
"0",
"]",
".",
"value",
",",
"inst",
"->",
"param",
"[",
"1",
"]",
".",
"value",
",",
"NULL",
")",
")",
"drcuml_block_abort",
"(",
"block",
")",
";",
"}",
"if",
"(",
"inst",
"->",
"opcode",
"==",
"DRCUML_OP_HASHJMP",
"&&",
"inst",
"->",
"param",
"[",
"0",
"]",
".",
"type",
"==",
"DRCUML_PTYPE_IMMEDIATE",
"&&",
"inst",
"->",
"param",
"[",
"1",
"]",
".",
"type",
"==",
"DRCUML_PTYPE_IMMEDIATE",
")",
"{",
"drccodeptr",
"code",
"=",
"drchash_get_codeptr",
"(",
"drchash",
",",
"inst",
"->",
"param",
"[",
"0",
"]",
".",
"value",
",",
"inst",
"->",
"param",
"[",
"1",
"]",
".",
"value",
")",
";",
"if",
"(",
"!",
"drchash_set_codeptr",
"(",
"drchash",
",",
"inst",
"->",
"param",
"[",
"0",
"]",
".",
"value",
",",
"inst",
"->",
"param",
"[",
"1",
"]",
".",
"value",
",",
"code",
")",
")",
"drcuml_block_abort",
"(",
"block",
")",
";",
"}",
"}",
"}"
] | drchash_block_begin - note the beginning of a
block | [
"drchash_block_begin",
"-",
"note",
"the",
"beginning",
"of",
"a",
"block"
] | [
"/* before generating code, pre-allocate any hash entries; we do this by setting dummy hash values */",
"/* if the opcode is a hash, verify that it makes sense and then set a NULL entry */",
"/* if we fail to allocate, we must abort the block */",
"/* if the opcode is a hashjmp to a fixed location, make sure we preallocate the tables */",
"/* if we fail to allocate, we must abort the block */"
] | [
{
"param": "drchash",
"type": "drchash_state"
},
{
"param": "block",
"type": "drcuml_block"
},
{
"param": "instlist",
"type": "drcuml_instruction"
},
{
"param": "numinst",
"type": "UINT32"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "drchash",
"type": "drchash_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": "instlist",
"type": "drcuml_instruction",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "numinst",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
555774830412f4457247ab31f4e20b521972476f | lofunz/mieme | Reloaded/trunk/src/emu/cpu/drcbeut.c | [
"Unlicense"
] | C | drchash_set_codeptr | int | int drchash_set_codeptr(drchash_state *drchash, UINT32 mode, UINT32 pc, drccodeptr code)
{
UINT32 l1 = (pc >> drchash->l1shift) & drchash->l1mask;
UINT32 l2 = (pc >> drchash->l2shift) & drchash->l2mask;
assert(mode < drchash->modes);
/* copy-on-write for the l1 hash table */
if (drchash->base[mode] == drchash->emptyl1)
{
drccodeptr **newtable = (drccodeptr **)drccache_memory_alloc_temporary(drchash->cache, sizeof(drccodeptr *) << drchash->l1bits);
if (newtable == NULL)
return FALSE;
memcpy(newtable, drchash->emptyl1, sizeof(drccodeptr *) << drchash->l1bits);
drchash->base[mode] = newtable;
}
/* copy-on-write for the l2 hash table */
if (drchash->base[mode][l1] == drchash->emptyl2)
{
drccodeptr *newtable = (drccodeptr *)drccache_memory_alloc_temporary(drchash->cache, sizeof(drccodeptr) << drchash->l2bits);
if (newtable == NULL)
return FALSE;
memcpy(newtable, drchash->emptyl2, sizeof(drccodeptr) << drchash->l2bits);
drchash->base[mode][l1] = newtable;
}
/* set the new entry */
drchash->base[mode][l1][l2] = code;
return TRUE;
} | /*-------------------------------------------------
drchash_set_codeptr - set the codeptr for the
given mode/pc
-------------------------------------------------*/ | set the codeptr for the
given mode/pc | [
"set",
"the",
"codeptr",
"for",
"the",
"given",
"mode",
"/",
"pc"
] | int drchash_set_codeptr(drchash_state *drchash, UINT32 mode, UINT32 pc, drccodeptr code)
{
UINT32 l1 = (pc >> drchash->l1shift) & drchash->l1mask;
UINT32 l2 = (pc >> drchash->l2shift) & drchash->l2mask;
assert(mode < drchash->modes);
if (drchash->base[mode] == drchash->emptyl1)
{
drccodeptr **newtable = (drccodeptr **)drccache_memory_alloc_temporary(drchash->cache, sizeof(drccodeptr *) << drchash->l1bits);
if (newtable == NULL)
return FALSE;
memcpy(newtable, drchash->emptyl1, sizeof(drccodeptr *) << drchash->l1bits);
drchash->base[mode] = newtable;
}
if (drchash->base[mode][l1] == drchash->emptyl2)
{
drccodeptr *newtable = (drccodeptr *)drccache_memory_alloc_temporary(drchash->cache, sizeof(drccodeptr) << drchash->l2bits);
if (newtable == NULL)
return FALSE;
memcpy(newtable, drchash->emptyl2, sizeof(drccodeptr) << drchash->l2bits);
drchash->base[mode][l1] = newtable;
}
drchash->base[mode][l1][l2] = code;
return TRUE;
} | [
"int",
"drchash_set_codeptr",
"(",
"drchash_state",
"*",
"drchash",
",",
"UINT32",
"mode",
",",
"UINT32",
"pc",
",",
"drccodeptr",
"code",
")",
"{",
"UINT32",
"l1",
"=",
"(",
"pc",
">>",
"drchash",
"->",
"l1shift",
")",
"&",
"drchash",
"->",
"l1mask",
";",
"UINT32",
"l2",
"=",
"(",
"pc",
">>",
"drchash",
"->",
"l2shift",
")",
"&",
"drchash",
"->",
"l2mask",
";",
"assert",
"(",
"mode",
"<",
"drchash",
"->",
"modes",
")",
";",
"if",
"(",
"drchash",
"->",
"base",
"[",
"mode",
"]",
"==",
"drchash",
"->",
"emptyl1",
")",
"{",
"drccodeptr",
"*",
"*",
"newtable",
"=",
"(",
"drccodeptr",
"*",
"*",
")",
"drccache_memory_alloc_temporary",
"(",
"drchash",
"->",
"cache",
",",
"sizeof",
"(",
"drccodeptr",
"*",
")",
"<<",
"drchash",
"->",
"l1bits",
")",
";",
"if",
"(",
"newtable",
"==",
"NULL",
")",
"return",
"FALSE",
";",
"memcpy",
"(",
"newtable",
",",
"drchash",
"->",
"emptyl1",
",",
"sizeof",
"(",
"drccodeptr",
"*",
")",
"<<",
"drchash",
"->",
"l1bits",
")",
";",
"drchash",
"->",
"base",
"[",
"mode",
"]",
"=",
"newtable",
";",
"}",
"if",
"(",
"drchash",
"->",
"base",
"[",
"mode",
"]",
"[",
"l1",
"]",
"==",
"drchash",
"->",
"emptyl2",
")",
"{",
"drccodeptr",
"*",
"newtable",
"=",
"(",
"drccodeptr",
"*",
")",
"drccache_memory_alloc_temporary",
"(",
"drchash",
"->",
"cache",
",",
"sizeof",
"(",
"drccodeptr",
")",
"<<",
"drchash",
"->",
"l2bits",
")",
";",
"if",
"(",
"newtable",
"==",
"NULL",
")",
"return",
"FALSE",
";",
"memcpy",
"(",
"newtable",
",",
"drchash",
"->",
"emptyl2",
",",
"sizeof",
"(",
"drccodeptr",
")",
"<<",
"drchash",
"->",
"l2bits",
")",
";",
"drchash",
"->",
"base",
"[",
"mode",
"]",
"[",
"l1",
"]",
"=",
"newtable",
";",
"}",
"drchash",
"->",
"base",
"[",
"mode",
"]",
"[",
"l1",
"]",
"[",
"l2",
"]",
"=",
"code",
";",
"return",
"TRUE",
";",
"}"
] | drchash_set_codeptr - set the codeptr for the
given mode/pc | [
"drchash_set_codeptr",
"-",
"set",
"the",
"codeptr",
"for",
"the",
"given",
"mode",
"/",
"pc"
] | [
"/* copy-on-write for the l1 hash table */",
"/* copy-on-write for the l2 hash table */",
"/* set the new entry */"
] | [
{
"param": "drchash",
"type": "drchash_state"
},
{
"param": "mode",
"type": "UINT32"
},
{
"param": "pc",
"type": "UINT32"
},
{
"param": "code",
"type": "drccodeptr"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "drchash",
"type": "drchash_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mode",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pc",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "code",
"type": "drccodeptr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
555774830412f4457247ab31f4e20b521972476f | lofunz/mieme | Reloaded/trunk/src/emu/cpu/drcbeut.c | [
"Unlicense"
] | C | drcmap_alloc | drcmap_state | drcmap_state *drcmap_alloc(drccache *cache, UINT64 uniquevalue)
{
drcmap_state *drcmap;
/* allocate permanent state from the cache */
drcmap = (drcmap_state *)drccache_memory_alloc(cache, sizeof(*drcmap));
if (drcmap == NULL)
return NULL;
memset(drcmap, 0, sizeof(*drcmap));
/* remember the cache */
drcmap->cache = cache;
drcmap->tailptr = &drcmap->head;
return drcmap;
} | /*-------------------------------------------------
drcmap_alloc - allocate memory in the cache
for the code mapper (it auto-frees with the
cache)
-------------------------------------------------*/ | allocate memory in the cache
for the code mapper (it auto-frees with the
cache) | [
"allocate",
"memory",
"in",
"the",
"cache",
"for",
"the",
"code",
"mapper",
"(",
"it",
"auto",
"-",
"frees",
"with",
"the",
"cache",
")"
] | drcmap_state *drcmap_alloc(drccache *cache, UINT64 uniquevalue)
{
drcmap_state *drcmap;
drcmap = (drcmap_state *)drccache_memory_alloc(cache, sizeof(*drcmap));
if (drcmap == NULL)
return NULL;
memset(drcmap, 0, sizeof(*drcmap));
drcmap->cache = cache;
drcmap->tailptr = &drcmap->head;
return drcmap;
} | [
"drcmap_state",
"*",
"drcmap_alloc",
"(",
"drccache",
"*",
"cache",
",",
"UINT64",
"uniquevalue",
")",
"{",
"drcmap_state",
"*",
"drcmap",
";",
"drcmap",
"=",
"(",
"drcmap_state",
"*",
")",
"drccache_memory_alloc",
"(",
"cache",
",",
"sizeof",
"(",
"*",
"drcmap",
")",
")",
";",
"if",
"(",
"drcmap",
"==",
"NULL",
")",
"return",
"NULL",
";",
"memset",
"(",
"drcmap",
",",
"0",
",",
"sizeof",
"(",
"*",
"drcmap",
")",
")",
";",
"drcmap",
"->",
"cache",
"=",
"cache",
";",
"drcmap",
"->",
"tailptr",
"=",
"&",
"drcmap",
"->",
"head",
";",
"return",
"drcmap",
";",
"}"
] | drcmap_alloc - allocate memory in the cache
for the code mapper (it auto-frees with the
cache) | [
"drcmap_alloc",
"-",
"allocate",
"memory",
"in",
"the",
"cache",
"for",
"the",
"code",
"mapper",
"(",
"it",
"auto",
"-",
"frees",
"with",
"the",
"cache",
")"
] | [
"/* allocate permanent state from the cache */",
"/* remember the cache */"
] | [
{
"param": "cache",
"type": "drccache"
},
{
"param": "uniquevalue",
"type": "UINT64"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cache",
"type": "drccache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "uniquevalue",
"type": "UINT64",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
555774830412f4457247ab31f4e20b521972476f | lofunz/mieme | Reloaded/trunk/src/emu/cpu/drcbeut.c | [
"Unlicense"
] | C | drcmap_block_begin | void | void drcmap_block_begin(drcmap_state *drcmap, drcuml_block *block)
{
/* release any remaining live entries */
while (drcmap->head != NULL)
{
drcmap_entry *entry = drcmap->head;
drcmap->head = entry->next;
drccache_memory_free(drcmap->cache, entry, sizeof(*entry));
}
/* reset the tailptr and count */
drcmap->tailptr = &drcmap->head;
drcmap->numvalues = 0;
/* reset the variable values */
memset(drcmap->mapvalue, 0, sizeof(drcmap->mapvalue));
} | /*-------------------------------------------------
drcmap_block_begin - note the beginning of a
block
-------------------------------------------------*/ | note the beginning of a
block | [
"note",
"the",
"beginning",
"of",
"a",
"block"
] | void drcmap_block_begin(drcmap_state *drcmap, drcuml_block *block)
{
while (drcmap->head != NULL)
{
drcmap_entry *entry = drcmap->head;
drcmap->head = entry->next;
drccache_memory_free(drcmap->cache, entry, sizeof(*entry));
}
drcmap->tailptr = &drcmap->head;
drcmap->numvalues = 0;
memset(drcmap->mapvalue, 0, sizeof(drcmap->mapvalue));
} | [
"void",
"drcmap_block_begin",
"(",
"drcmap_state",
"*",
"drcmap",
",",
"drcuml_block",
"*",
"block",
")",
"{",
"while",
"(",
"drcmap",
"->",
"head",
"!=",
"NULL",
")",
"{",
"drcmap_entry",
"*",
"entry",
"=",
"drcmap",
"->",
"head",
";",
"drcmap",
"->",
"head",
"=",
"entry",
"->",
"next",
";",
"drccache_memory_free",
"(",
"drcmap",
"->",
"cache",
",",
"entry",
",",
"sizeof",
"(",
"*",
"entry",
")",
")",
";",
"}",
"drcmap",
"->",
"tailptr",
"=",
"&",
"drcmap",
"->",
"head",
";",
"drcmap",
"->",
"numvalues",
"=",
"0",
";",
"memset",
"(",
"drcmap",
"->",
"mapvalue",
",",
"0",
",",
"sizeof",
"(",
"drcmap",
"->",
"mapvalue",
")",
")",
";",
"}"
] | drcmap_block_begin - note the beginning of a
block | [
"drcmap_block_begin",
"-",
"note",
"the",
"beginning",
"of",
"a",
"block"
] | [
"/* release any remaining live entries */",
"/* reset the tailptr and count */",
"/* reset the variable values */"
] | [
{
"param": "drcmap",
"type": "drcmap_state"
},
{
"param": "block",
"type": "drcuml_block"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "drcmap",
"type": "drcmap_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "block",
"type": "drcuml_block",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
555774830412f4457247ab31f4e20b521972476f | lofunz/mieme | Reloaded/trunk/src/emu/cpu/drcbeut.c | [
"Unlicense"
] | C | drcmap_block_end | void | void drcmap_block_end(drcmap_state *drcmap, drcuml_block *block)
{
UINT32 curvalue[DRCUML_MAPVAR_END - DRCUML_MAPVAR_M0] = { 0 };
UINT8 changed[DRCUML_MAPVAR_END - DRCUML_MAPVAR_M0] = { 0 };
drcmap_entry *entry;
drccodeptr lastptr;
drccodeptr *top;
UINT32 *dest;
/* only process if we have data */
if (drcmap->head == NULL)
return;
/* begin "code generation" aligned to an 8-byte boundary */
top = drccache_begin_codegen(drcmap->cache, sizeof(UINT64) + sizeof(UINT32) + 2 * sizeof(UINT32) * drcmap->numvalues);
if (top == NULL)
drcuml_block_abort(block);
dest = (UINT32 *)(((FPTR)*top + 7) & ~7);
/* store the cookie first */
*(UINT64 *)dest = drcmap->uniquevalue;
dest += 2;
/* get the pointer to the first item and store an initial backwards offset */
lastptr = drcmap->head->codeptr;
*dest = (drccodeptr)dest - lastptr;
dest++;
/* now iterate over entries and store them */
for (entry = drcmap->head; entry != NULL; entry = entry->next)
{
/* update the current value of the variable and detect changes */
if (curvalue[entry->mapvar] != entry->newval)
{
curvalue[entry->mapvar] = entry->newval;
changed[entry->mapvar] = TRUE;
}
/* if the next code pointer is different, or if we're at the end, flush changes */
if (entry->next == NULL || entry->next->codeptr != entry->codeptr)
{
UINT32 codedelta = entry->codeptr - lastptr;
UINT32 varmask = 0;
int numchanged;
int varnum;
/* build a mask of changed variables */
for (numchanged = varnum = 0; varnum < ARRAY_LENGTH(changed); varnum++)
if (changed[varnum])
{
changed[varnum] = FALSE;
varmask |= 1 << varnum;
numchanged++;
}
/* if nothing really changed, skip it */
if (numchanged == 0)
continue;
/* first word is a code delta plus mask of changed variables */
while (codedelta > 0xffff)
{
*dest++ = 0xffff << 16;
codedelta -= 0xffff;
}
*dest++ = (codedelta << 16) | (varmask << 4) | numchanged;
/* now output updated variable values */
for (varnum = 0; varnum < ARRAY_LENGTH(changed); varnum++)
if ((varmask >> varnum) & 1)
*dest++ = curvalue[varnum];
/* remember our lastptr */
lastptr = entry->codeptr;
}
}
/* add a terminator */
*dest++ = 0;
/* complete codegen */
*top = (drccodeptr)dest;
drccache_end_codegen(drcmap->cache);
} | /*-------------------------------------------------
drcmap_block_end - note the end of a block
-------------------------------------------------*/ | note the end of a block | [
"note",
"the",
"end",
"of",
"a",
"block"
] | void drcmap_block_end(drcmap_state *drcmap, drcuml_block *block)
{
UINT32 curvalue[DRCUML_MAPVAR_END - DRCUML_MAPVAR_M0] = { 0 };
UINT8 changed[DRCUML_MAPVAR_END - DRCUML_MAPVAR_M0] = { 0 };
drcmap_entry *entry;
drccodeptr lastptr;
drccodeptr *top;
UINT32 *dest;
if (drcmap->head == NULL)
return;
top = drccache_begin_codegen(drcmap->cache, sizeof(UINT64) + sizeof(UINT32) + 2 * sizeof(UINT32) * drcmap->numvalues);
if (top == NULL)
drcuml_block_abort(block);
dest = (UINT32 *)(((FPTR)*top + 7) & ~7);
*(UINT64 *)dest = drcmap->uniquevalue;
dest += 2;
lastptr = drcmap->head->codeptr;
*dest = (drccodeptr)dest - lastptr;
dest++;
for (entry = drcmap->head; entry != NULL; entry = entry->next)
{
if (curvalue[entry->mapvar] != entry->newval)
{
curvalue[entry->mapvar] = entry->newval;
changed[entry->mapvar] = TRUE;
}
if (entry->next == NULL || entry->next->codeptr != entry->codeptr)
{
UINT32 codedelta = entry->codeptr - lastptr;
UINT32 varmask = 0;
int numchanged;
int varnum;
for (numchanged = varnum = 0; varnum < ARRAY_LENGTH(changed); varnum++)
if (changed[varnum])
{
changed[varnum] = FALSE;
varmask |= 1 << varnum;
numchanged++;
}
if (numchanged == 0)
continue;
while (codedelta > 0xffff)
{
*dest++ = 0xffff << 16;
codedelta -= 0xffff;
}
*dest++ = (codedelta << 16) | (varmask << 4) | numchanged;
for (varnum = 0; varnum < ARRAY_LENGTH(changed); varnum++)
if ((varmask >> varnum) & 1)
*dest++ = curvalue[varnum];
lastptr = entry->codeptr;
}
}
*dest++ = 0;
*top = (drccodeptr)dest;
drccache_end_codegen(drcmap->cache);
} | [
"void",
"drcmap_block_end",
"(",
"drcmap_state",
"*",
"drcmap",
",",
"drcuml_block",
"*",
"block",
")",
"{",
"UINT32",
"curvalue",
"[",
"DRCUML_MAPVAR_END",
"-",
"DRCUML_MAPVAR_M0",
"]",
"=",
"{",
"0",
"}",
";",
"UINT8",
"changed",
"[",
"DRCUML_MAPVAR_END",
"-",
"DRCUML_MAPVAR_M0",
"]",
"=",
"{",
"0",
"}",
";",
"drcmap_entry",
"*",
"entry",
";",
"drccodeptr",
"lastptr",
";",
"drccodeptr",
"*",
"top",
";",
"UINT32",
"*",
"dest",
";",
"if",
"(",
"drcmap",
"->",
"head",
"==",
"NULL",
")",
"return",
";",
"top",
"=",
"drccache_begin_codegen",
"(",
"drcmap",
"->",
"cache",
",",
"sizeof",
"(",
"UINT64",
")",
"+",
"sizeof",
"(",
"UINT32",
")",
"+",
"2",
"*",
"sizeof",
"(",
"UINT32",
")",
"*",
"drcmap",
"->",
"numvalues",
")",
";",
"if",
"(",
"top",
"==",
"NULL",
")",
"drcuml_block_abort",
"(",
"block",
")",
";",
"dest",
"=",
"(",
"UINT32",
"*",
")",
"(",
"(",
"(",
"FPTR",
")",
"*",
"top",
"+",
"7",
")",
"&",
"~",
"7",
")",
";",
"*",
"(",
"UINT64",
"*",
")",
"dest",
"=",
"drcmap",
"->",
"uniquevalue",
";",
"dest",
"+=",
"2",
";",
"lastptr",
"=",
"drcmap",
"->",
"head",
"->",
"codeptr",
";",
"*",
"dest",
"=",
"(",
"drccodeptr",
")",
"dest",
"-",
"lastptr",
";",
"dest",
"++",
";",
"for",
"(",
"entry",
"=",
"drcmap",
"->",
"head",
";",
"entry",
"!=",
"NULL",
";",
"entry",
"=",
"entry",
"->",
"next",
")",
"{",
"if",
"(",
"curvalue",
"[",
"entry",
"->",
"mapvar",
"]",
"!=",
"entry",
"->",
"newval",
")",
"{",
"curvalue",
"[",
"entry",
"->",
"mapvar",
"]",
"=",
"entry",
"->",
"newval",
";",
"changed",
"[",
"entry",
"->",
"mapvar",
"]",
"=",
"TRUE",
";",
"}",
"if",
"(",
"entry",
"->",
"next",
"==",
"NULL",
"||",
"entry",
"->",
"next",
"->",
"codeptr",
"!=",
"entry",
"->",
"codeptr",
")",
"{",
"UINT32",
"codedelta",
"=",
"entry",
"->",
"codeptr",
"-",
"lastptr",
";",
"UINT32",
"varmask",
"=",
"0",
";",
"int",
"numchanged",
";",
"int",
"varnum",
";",
"for",
"(",
"numchanged",
"=",
"varnum",
"=",
"0",
";",
"varnum",
"<",
"ARRAY_LENGTH",
"(",
"changed",
")",
";",
"varnum",
"++",
")",
"if",
"(",
"changed",
"[",
"varnum",
"]",
")",
"{",
"changed",
"[",
"varnum",
"]",
"=",
"FALSE",
";",
"varmask",
"|=",
"1",
"<<",
"varnum",
";",
"numchanged",
"++",
";",
"}",
"if",
"(",
"numchanged",
"==",
"0",
")",
"continue",
";",
"while",
"(",
"codedelta",
">",
"0xffff",
")",
"{",
"*",
"dest",
"++",
"=",
"0xffff",
"<<",
"16",
";",
"codedelta",
"-=",
"0xffff",
";",
"}",
"*",
"dest",
"++",
"=",
"(",
"codedelta",
"<<",
"16",
")",
"|",
"(",
"varmask",
"<<",
"4",
")",
"|",
"numchanged",
";",
"for",
"(",
"varnum",
"=",
"0",
";",
"varnum",
"<",
"ARRAY_LENGTH",
"(",
"changed",
")",
";",
"varnum",
"++",
")",
"if",
"(",
"(",
"varmask",
">>",
"varnum",
")",
"&",
"1",
")",
"*",
"dest",
"++",
"=",
"curvalue",
"[",
"varnum",
"]",
";",
"lastptr",
"=",
"entry",
"->",
"codeptr",
";",
"}",
"}",
"*",
"dest",
"++",
"=",
"0",
";",
"*",
"top",
"=",
"(",
"drccodeptr",
")",
"dest",
";",
"drccache_end_codegen",
"(",
"drcmap",
"->",
"cache",
")",
";",
"}"
] | drcmap_block_end - note the end of a block | [
"drcmap_block_end",
"-",
"note",
"the",
"end",
"of",
"a",
"block"
] | [
"/* only process if we have data */",
"/* begin \"code generation\" aligned to an 8-byte boundary */",
"/* store the cookie first */",
"/* get the pointer to the first item and store an initial backwards offset */",
"/* now iterate over entries and store them */",
"/* update the current value of the variable and detect changes */",
"/* if the next code pointer is different, or if we're at the end, flush changes */",
"/* build a mask of changed variables */",
"/* if nothing really changed, skip it */",
"/* first word is a code delta plus mask of changed variables */",
"/* now output updated variable values */",
"/* remember our lastptr */",
"/* add a terminator */",
"/* complete codegen */"
] | [
{
"param": "drcmap",
"type": "drcmap_state"
},
{
"param": "block",
"type": "drcuml_block"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "drcmap",
"type": "drcmap_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "block",
"type": "drcuml_block",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
555774830412f4457247ab31f4e20b521972476f | lofunz/mieme | Reloaded/trunk/src/emu/cpu/drcbeut.c | [
"Unlicense"
] | C | drcmap_set_value | void | void drcmap_set_value(drcmap_state *drcmap, drccodeptr codebase, UINT32 mapvar, UINT32 newvalue)
{
drcmap_entry *entry;
assert(mapvar >= DRCUML_MAPVAR_M0 && mapvar < DRCUML_MAPVAR_END);
/* if this value isn't different, skip it */
if (drcmap->mapvalue[mapvar - DRCUML_MAPVAR_M0] == newvalue)
return;
/* allocate a new entry and fill it in */
entry = (drcmap_entry *)drccache_memory_alloc(drcmap->cache, sizeof(*entry));
entry->next = NULL;
entry->codeptr = codebase;
entry->mapvar = mapvar - DRCUML_MAPVAR_M0;
entry->newval = newvalue;
/* hook us into the end of the list */
*drcmap->tailptr = entry;
drcmap->tailptr = &entry->next;
/* update our state in the table as well */
drcmap->mapvalue[mapvar - DRCUML_MAPVAR_M0] = newvalue;
/* and increment the count */
drcmap->numvalues++;
} | /*-------------------------------------------------
drcmap_set_value - set a map value for the
given code pointer
-------------------------------------------------*/ | set a map value for the
given code pointer | [
"set",
"a",
"map",
"value",
"for",
"the",
"given",
"code",
"pointer"
] | void drcmap_set_value(drcmap_state *drcmap, drccodeptr codebase, UINT32 mapvar, UINT32 newvalue)
{
drcmap_entry *entry;
assert(mapvar >= DRCUML_MAPVAR_M0 && mapvar < DRCUML_MAPVAR_END);
if (drcmap->mapvalue[mapvar - DRCUML_MAPVAR_M0] == newvalue)
return;
entry = (drcmap_entry *)drccache_memory_alloc(drcmap->cache, sizeof(*entry));
entry->next = NULL;
entry->codeptr = codebase;
entry->mapvar = mapvar - DRCUML_MAPVAR_M0;
entry->newval = newvalue;
*drcmap->tailptr = entry;
drcmap->tailptr = &entry->next;
drcmap->mapvalue[mapvar - DRCUML_MAPVAR_M0] = newvalue;
drcmap->numvalues++;
} | [
"void",
"drcmap_set_value",
"(",
"drcmap_state",
"*",
"drcmap",
",",
"drccodeptr",
"codebase",
",",
"UINT32",
"mapvar",
",",
"UINT32",
"newvalue",
")",
"{",
"drcmap_entry",
"*",
"entry",
";",
"assert",
"(",
"mapvar",
">=",
"DRCUML_MAPVAR_M0",
"&&",
"mapvar",
"<",
"DRCUML_MAPVAR_END",
")",
";",
"if",
"(",
"drcmap",
"->",
"mapvalue",
"[",
"mapvar",
"-",
"DRCUML_MAPVAR_M0",
"]",
"==",
"newvalue",
")",
"return",
";",
"entry",
"=",
"(",
"drcmap_entry",
"*",
")",
"drccache_memory_alloc",
"(",
"drcmap",
"->",
"cache",
",",
"sizeof",
"(",
"*",
"entry",
")",
")",
";",
"entry",
"->",
"next",
"=",
"NULL",
";",
"entry",
"->",
"codeptr",
"=",
"codebase",
";",
"entry",
"->",
"mapvar",
"=",
"mapvar",
"-",
"DRCUML_MAPVAR_M0",
";",
"entry",
"->",
"newval",
"=",
"newvalue",
";",
"*",
"drcmap",
"->",
"tailptr",
"=",
"entry",
";",
"drcmap",
"->",
"tailptr",
"=",
"&",
"entry",
"->",
"next",
";",
"drcmap",
"->",
"mapvalue",
"[",
"mapvar",
"-",
"DRCUML_MAPVAR_M0",
"]",
"=",
"newvalue",
";",
"drcmap",
"->",
"numvalues",
"++",
";",
"}"
] | drcmap_set_value - set a map value for the
given code pointer | [
"drcmap_set_value",
"-",
"set",
"a",
"map",
"value",
"for",
"the",
"given",
"code",
"pointer"
] | [
"/* if this value isn't different, skip it */",
"/* allocate a new entry and fill it in */",
"/* hook us into the end of the list */",
"/* update our state in the table as well */",
"/* and increment the count */"
] | [
{
"param": "drcmap",
"type": "drcmap_state"
},
{
"param": "codebase",
"type": "drccodeptr"
},
{
"param": "mapvar",
"type": "UINT32"
},
{
"param": "newvalue",
"type": "UINT32"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "drcmap",
"type": "drcmap_state",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "codebase",
"type": "drccodeptr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mapvar",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "newvalue",
"type": "UINT32",
"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.