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
6c206383e2b4903e7a8ee3fbef5909b66ffa37cc
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/m68000/m68kcpu.c
[ "Unlicense" ]
C
readlong_d32_mmu
UINT32
static UINT32 readlong_d32_mmu(const address_space *space, offs_t address) { m68ki_cpu_core *m68k = get_safe_token(space->cpu); UINT32 result; if (m68k->pmmu_enabled) { address = pmmu_translate_addr(m68k, address); } if (!(address & 3)) return memory_read_dword_32be(space, address); else if (!(address & 1)) { result = memory_read_word_32be(space, address) << 16; return result | memory_read_word_32be(space, address + 2); } result = memory_read_byte_32be(space, address) << 24; result |= memory_read_word_32be(space, address + 1) << 8; return result | memory_read_byte_32be(space, address + 3); }
/* potentially misaligned 32-bit reads with a 32-bit data bus (and 24-bit address bus) */
potentially misaligned 32-bit reads with a 32-bit data bus (and 24-bit address bus)
[ "potentially", "misaligned", "32", "-", "bit", "reads", "with", "a", "32", "-", "bit", "data", "bus", "(", "and", "24", "-", "bit", "address", "bus", ")" ]
static UINT32 readlong_d32_mmu(const address_space *space, offs_t address) { m68ki_cpu_core *m68k = get_safe_token(space->cpu); UINT32 result; if (m68k->pmmu_enabled) { address = pmmu_translate_addr(m68k, address); } if (!(address & 3)) return memory_read_dword_32be(space, address); else if (!(address & 1)) { result = memory_read_word_32be(space, address) << 16; return result | memory_read_word_32be(space, address + 2); } result = memory_read_byte_32be(space, address) << 24; result |= memory_read_word_32be(space, address + 1) << 8; return result | memory_read_byte_32be(space, address + 3); }
[ "static", "UINT32", "readlong_d32_mmu", "(", "const", "address_space", "*", "space", ",", "offs_t", "address", ")", "{", "m68ki_cpu_core", "*", "m68k", "=", "get_safe_token", "(", "space", "->", "cpu", ")", ";", "UINT32", "result", ";", "if", "(", "m68k", "->", "pmmu_enabled", ")", "{", "address", "=", "pmmu_translate_addr", "(", "m68k", ",", "address", ")", ";", "}", "if", "(", "!", "(", "address", "&", "3", ")", ")", "return", "memory_read_dword_32be", "(", "space", ",", "address", ")", ";", "else", "if", "(", "!", "(", "address", "&", "1", ")", ")", "{", "result", "=", "memory_read_word_32be", "(", "space", ",", "address", ")", "<<", "16", ";", "return", "result", "|", "memory_read_word_32be", "(", "space", ",", "address", "+", "2", ")", ";", "}", "result", "=", "memory_read_byte_32be", "(", "space", ",", "address", ")", "<<", "24", ";", "result", "|=", "memory_read_word_32be", "(", "space", ",", "address", "+", "1", ")", "<<", "8", ";", "return", "result", "|", "memory_read_byte_32be", "(", "space", ",", "address", "+", "3", ")", ";", "}" ]
potentially misaligned 32-bit reads with a 32-bit data bus (and 24-bit address bus)
[ "potentially", "misaligned", "32", "-", "bit", "reads", "with", "a", "32", "-", "bit", "data", "bus", "(", "and", "24", "-", "bit", "address", "bus", ")" ]
[]
[ { "param": "space", "type": "address_space" }, { "param": "address", "type": "offs_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "space", "type": "address_space", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "offs_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6c206383e2b4903e7a8ee3fbef5909b66ffa37cc
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/m68000/m68kcpu.c
[ "Unlicense" ]
C
writelong_d32_mmu
void
static void writelong_d32_mmu(const address_space *space, offs_t address, UINT32 data) { m68ki_cpu_core *m68k = get_safe_token(space->cpu); if (m68k->pmmu_enabled) { address = pmmu_translate_addr(m68k, address); } if (!(address & 3)) { memory_write_dword_32be(space, address, data); return; } else if (!(address & 1)) { memory_write_word_32be(space, address, data >> 16); memory_write_word_32be(space, address + 2, data); return; } memory_write_byte_32be(space, address, data >> 24); memory_write_word_32be(space, address + 1, data >> 8); memory_write_byte_32be(space, address + 3, data); }
/* potentially misaligned 32-bit writes with a 32-bit data bus (and 24-bit address bus) */
potentially misaligned 32-bit writes with a 32-bit data bus (and 24-bit address bus)
[ "potentially", "misaligned", "32", "-", "bit", "writes", "with", "a", "32", "-", "bit", "data", "bus", "(", "and", "24", "-", "bit", "address", "bus", ")" ]
static void writelong_d32_mmu(const address_space *space, offs_t address, UINT32 data) { m68ki_cpu_core *m68k = get_safe_token(space->cpu); if (m68k->pmmu_enabled) { address = pmmu_translate_addr(m68k, address); } if (!(address & 3)) { memory_write_dword_32be(space, address, data); return; } else if (!(address & 1)) { memory_write_word_32be(space, address, data >> 16); memory_write_word_32be(space, address + 2, data); return; } memory_write_byte_32be(space, address, data >> 24); memory_write_word_32be(space, address + 1, data >> 8); memory_write_byte_32be(space, address + 3, data); }
[ "static", "void", "writelong_d32_mmu", "(", "const", "address_space", "*", "space", ",", "offs_t", "address", ",", "UINT32", "data", ")", "{", "m68ki_cpu_core", "*", "m68k", "=", "get_safe_token", "(", "space", "->", "cpu", ")", ";", "if", "(", "m68k", "->", "pmmu_enabled", ")", "{", "address", "=", "pmmu_translate_addr", "(", "m68k", ",", "address", ")", ";", "}", "if", "(", "!", "(", "address", "&", "3", ")", ")", "{", "memory_write_dword_32be", "(", "space", ",", "address", ",", "data", ")", ";", "return", ";", "}", "else", "if", "(", "!", "(", "address", "&", "1", ")", ")", "{", "memory_write_word_32be", "(", "space", ",", "address", ",", "data", ">>", "16", ")", ";", "memory_write_word_32be", "(", "space", ",", "address", "+", "2", ",", "data", ")", ";", "return", ";", "}", "memory_write_byte_32be", "(", "space", ",", "address", ",", "data", ">>", "24", ")", ";", "memory_write_word_32be", "(", "space", ",", "address", "+", "1", ",", "data", ">>", "8", ")", ";", "memory_write_byte_32be", "(", "space", ",", "address", "+", "3", ",", "data", ")", ";", "}" ]
potentially misaligned 32-bit writes with a 32-bit data bus (and 24-bit address bus)
[ "potentially", "misaligned", "32", "-", "bit", "writes", "with", "a", "32", "-", "bit", "data", "bus", "(", "and", "24", "-", "bit", "address", "bus", ")" ]
[]
[ { "param": "space", "type": "address_space" }, { "param": "address", "type": "offs_t" }, { "param": "data", "type": "UINT32" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "space", "type": "address_space", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "offs_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
403b57d5c621cc42de8b537064446af5df446983
lofunz/mieme
Reloaded/trunk/src/emu/sound/es5503.c
[ "Unlicense" ]
C
es5503_halt_osc
void
static void es5503_halt_osc(ES5503Chip *chip, int onum, int type, UINT32 *accumulator) { ES5503Osc *pOsc = &chip->oscillators[onum]; ES5503Osc *pPartner = &chip->oscillators[onum^1]; int mode = (pOsc->control>>1) & 3; // if 0 found in sample data or mode is not free-run, halt this oscillator if ((type != MODE_FREE) || (mode > 0)) { pOsc->control |= 1; } else { // reset the accumulator if not halting *accumulator = 0; } // if swap mode, start the partner if (mode == MODE_SWAP) { pPartner->control &= ~1; // clear the halt bit pPartner->accumulator = 0; // and make sure it starts from the top } // IRQ enabled for this voice? if (pOsc->control & 0x08) { pOsc->irqpend = 1; if (chip->irq_callback) { chip->irq_callback(chip->device, 1); } } }
// halt_osc: handle halting an oscillator // chip = chip ptr // onum = oscillator # // type = 1 for 0 found in sample data, 0 for hit end of table size
handle halting an oscillator chip = chip ptr onum = oscillator type = 1 for 0 found in sample data, 0 for hit end of table size
[ "handle", "halting", "an", "oscillator", "chip", "=", "chip", "ptr", "onum", "=", "oscillator", "type", "=", "1", "for", "0", "found", "in", "sample", "data", "0", "for", "hit", "end", "of", "table", "size" ]
static void es5503_halt_osc(ES5503Chip *chip, int onum, int type, UINT32 *accumulator) { ES5503Osc *pOsc = &chip->oscillators[onum]; ES5503Osc *pPartner = &chip->oscillators[onum^1]; int mode = (pOsc->control>>1) & 3; if ((type != MODE_FREE) || (mode > 0)) { pOsc->control |= 1; } else { *accumulator = 0; } if (mode == MODE_SWAP) { pPartner->control &= ~1; pPartner->accumulator = 0; } if (pOsc->control & 0x08) { pOsc->irqpend = 1; if (chip->irq_callback) { chip->irq_callback(chip->device, 1); } } }
[ "static", "void", "es5503_halt_osc", "(", "ES5503Chip", "*", "chip", ",", "int", "onum", ",", "int", "type", ",", "UINT32", "*", "accumulator", ")", "{", "ES5503Osc", "*", "pOsc", "=", "&", "chip", "->", "oscillators", "[", "onum", "]", ";", "ES5503Osc", "*", "pPartner", "=", "&", "chip", "->", "oscillators", "[", "onum", "^", "1", "]", ";", "int", "mode", "=", "(", "pOsc", "->", "control", ">>", "1", ")", "&", "3", ";", "if", "(", "(", "type", "!=", "MODE_FREE", ")", "||", "(", "mode", ">", "0", ")", ")", "{", "pOsc", "->", "control", "|=", "1", ";", "}", "else", "{", "*", "accumulator", "=", "0", ";", "}", "if", "(", "mode", "==", "MODE_SWAP", ")", "{", "pPartner", "->", "control", "&=", "~", "1", ";", "pPartner", "->", "accumulator", "=", "0", ";", "}", "if", "(", "pOsc", "->", "control", "&", "0x08", ")", "{", "pOsc", "->", "irqpend", "=", "1", ";", "if", "(", "chip", "->", "irq_callback", ")", "{", "chip", "->", "irq_callback", "(", "chip", "->", "device", ",", "1", ")", ";", "}", "}", "}" ]
halt_osc: handle halting an oscillator chip = chip ptr onum = oscillator type = 1 for 0 found in sample data, 0 for hit end of table size
[ "halt_osc", ":", "handle", "halting", "an", "oscillator", "chip", "=", "chip", "ptr", "onum", "=", "oscillator", "type", "=", "1", "for", "0", "found", "in", "sample", "data", "0", "for", "hit", "end", "of", "table", "size" ]
[ "// if 0 found in sample data or mode is not free-run, halt this oscillator\r", "// reset the accumulator if not halting\r", "// if swap mode, start the partner\r", "// clear the halt bit\r", "// and make sure it starts from the top\r", "// IRQ enabled for this voice?\r" ]
[ { "param": "chip", "type": "ES5503Chip" }, { "param": "onum", "type": "int" }, { "param": "type", "type": "int" }, { "param": "accumulator", "type": "UINT32" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "chip", "type": "ES5503Chip", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "onum", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "type", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "accumulator", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
17de2ee985ac78e368f6bc4308c0b0a24354d125
lofunz/mieme
Reloaded/tags/MAME4droid 1.6.0 (0.139u1)/src/emu/video.c
[ "Unlicense" ]
C
init_buffered_spriteram
void
static void init_buffered_spriteram(running_machine *machine) { assert_always(machine->generic.spriteram_size != 0, "Video buffers spriteram but spriteram size is 0"); /* allocate memory for the back buffer */ machine->generic.buffered_spriteram.u8 = auto_alloc_array(machine, UINT8, machine->generic.spriteram_size); /* register for saving it */ state_save_register_global_pointer(machine, machine->generic.buffered_spriteram.u8, machine->generic.spriteram_size); /* do the same for the second back buffer, if present */ if (machine->generic.spriteram2_size) { /* allocate memory */ machine->generic.buffered_spriteram2.u8 = auto_alloc_array(machine, UINT8, machine->generic.spriteram2_size); /* register for saving it */ state_save_register_global_pointer(machine, machine->generic.buffered_spriteram2.u8, machine->generic.spriteram2_size); } }
/*------------------------------------------------- init_buffered_spriteram - initialize the double-buffered spriteram -------------------------------------------------*/
initialize the double-buffered spriteram
[ "initialize", "the", "double", "-", "buffered", "spriteram" ]
static void init_buffered_spriteram(running_machine *machine) { assert_always(machine->generic.spriteram_size != 0, "Video buffers spriteram but spriteram size is 0"); machine->generic.buffered_spriteram.u8 = auto_alloc_array(machine, UINT8, machine->generic.spriteram_size); state_save_register_global_pointer(machine, machine->generic.buffered_spriteram.u8, machine->generic.spriteram_size); if (machine->generic.spriteram2_size) { machine->generic.buffered_spriteram2.u8 = auto_alloc_array(machine, UINT8, machine->generic.spriteram2_size); state_save_register_global_pointer(machine, machine->generic.buffered_spriteram2.u8, machine->generic.spriteram2_size); } }
[ "static", "void", "init_buffered_spriteram", "(", "running_machine", "*", "machine", ")", "{", "assert_always", "(", "machine", "->", "generic", ".", "spriteram_size", "!=", "0", ",", "\"", "\"", ")", ";", "machine", "->", "generic", ".", "buffered_spriteram", ".", "u8", "=", "auto_alloc_array", "(", "machine", ",", "UINT8", ",", "machine", "->", "generic", ".", "spriteram_size", ")", ";", "state_save_register_global_pointer", "(", "machine", ",", "machine", "->", "generic", ".", "buffered_spriteram", ".", "u8", ",", "machine", "->", "generic", ".", "spriteram_size", ")", ";", "if", "(", "machine", "->", "generic", ".", "spriteram2_size", ")", "{", "machine", "->", "generic", ".", "buffered_spriteram2", ".", "u8", "=", "auto_alloc_array", "(", "machine", ",", "UINT8", ",", "machine", "->", "generic", ".", "spriteram2_size", ")", ";", "state_save_register_global_pointer", "(", "machine", ",", "machine", "->", "generic", ".", "buffered_spriteram2", ".", "u8", ",", "machine", "->", "generic", ".", "spriteram2_size", ")", ";", "}", "}" ]
init_buffered_spriteram - initialize the double-buffered spriteram
[ "init_buffered_spriteram", "-", "initialize", "the", "double", "-", "buffered", "spriteram" ]
[ "/* allocate memory for the back buffer */", "/* register for saving it */", "/* do the same for the second back buffer, if present */", "/* allocate memory */", "/* register for saving it */" ]
[ { "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": [] }
17de2ee985ac78e368f6bc4308c0b0a24354d125
lofunz/mieme
Reloaded/tags/MAME4droid 1.6.0 (0.139u1)/src/emu/video.c
[ "Unlicense" ]
C
video_frame_update
void
void video_frame_update(running_machine *machine, int debug) { attotime current_time = timer_get_time(machine); int skipped_it = global.skipping_this_frame; int phase = machine->phase(); /* validate */ assert(machine != NULL); assert(machine->config != NULL); /* only render sound and video if we're in the running phase */ if (phase == MACHINE_PHASE_RUNNING && (!machine->paused() || options_get_bool(machine->options(), OPTION_UPDATEINPAUSE))) { int anything_changed = finish_screen_updates(machine); /* if none of the screens changed and we haven't skipped too many frames in a row, mark this frame as skipped to prevent throttling; this helps for games that don't update their screen at the monitor refresh rate */ if (!anything_changed && !global.auto_frameskip && global.frameskip_level == 0 && global.empty_skip_count++ < 3) skipped_it = TRUE; else global.empty_skip_count = 0; } /* draw the user interface */ ui_update_and_render(machine, render_container_get_ui()); /* update the internal render debugger */ debugint_update_during_game(machine); /* if we're throttling, synchronize before rendering */ if (!debug && !skipped_it && effective_throttle(machine)) update_throttle(machine, current_time); /* ask the OSD to update */ profiler_mark_start(PROFILER_BLIT); osd_update(machine, !debug && skipped_it); profiler_mark_end(); /* perform tasks for this frame */ if (!debug) machine->call_notifiers(MACHINE_NOTIFY_FRAME); /* update frameskipping */ if (!debug) update_frameskip(machine); /* update speed computations */ if (!debug && !skipped_it) recompute_speed(machine, current_time); /* call the end-of-frame callback */ if (phase == MACHINE_PHASE_RUNNING) { /* reset partial updates if we're paused or if the debugger is active */ if (machine->primary_screen != NULL && (machine->paused() || debug || debugger_within_instruction_hook(machine))) machine->primary_screen->scanline0_callback(); /* otherwise, call the video EOF callback */ else if (machine->config->m_video_eof != NULL) { profiler_mark_start(PROFILER_VIDEO); (*machine->config->m_video_eof)(machine); profiler_mark_end(); } } }
/*------------------------------------------------- video_frame_update - handle frameskipping and UI, plus updating the screen during normal operations -------------------------------------------------*/
handle frameskipping and UI, plus updating the screen during normal operations
[ "handle", "frameskipping", "and", "UI", "plus", "updating", "the", "screen", "during", "normal", "operations" ]
void video_frame_update(running_machine *machine, int debug) { attotime current_time = timer_get_time(machine); int skipped_it = global.skipping_this_frame; int phase = machine->phase(); assert(machine != NULL); assert(machine->config != NULL); if (phase == MACHINE_PHASE_RUNNING && (!machine->paused() || options_get_bool(machine->options(), OPTION_UPDATEINPAUSE))) { int anything_changed = finish_screen_updates(machine); if (!anything_changed && !global.auto_frameskip && global.frameskip_level == 0 && global.empty_skip_count++ < 3) skipped_it = TRUE; else global.empty_skip_count = 0; } ui_update_and_render(machine, render_container_get_ui()); debugint_update_during_game(machine); if (!debug && !skipped_it && effective_throttle(machine)) update_throttle(machine, current_time); profiler_mark_start(PROFILER_BLIT); osd_update(machine, !debug && skipped_it); profiler_mark_end(); if (!debug) machine->call_notifiers(MACHINE_NOTIFY_FRAME); if (!debug) update_frameskip(machine); if (!debug && !skipped_it) recompute_speed(machine, current_time); if (phase == MACHINE_PHASE_RUNNING) { if (machine->primary_screen != NULL && (machine->paused() || debug || debugger_within_instruction_hook(machine))) machine->primary_screen->scanline0_callback(); else if (machine->config->m_video_eof != NULL) { profiler_mark_start(PROFILER_VIDEO); (*machine->config->m_video_eof)(machine); profiler_mark_end(); } } }
[ "void", "video_frame_update", "(", "running_machine", "*", "machine", ",", "int", "debug", ")", "{", "attotime", "current_time", "=", "timer_get_time", "(", "machine", ")", ";", "int", "skipped_it", "=", "global", ".", "skipping_this_frame", ";", "int", "phase", "=", "machine", "->", "phase", "(", ")", ";", "assert", "(", "machine", "!=", "NULL", ")", ";", "assert", "(", "machine", "->", "config", "!=", "NULL", ")", ";", "if", "(", "phase", "==", "MACHINE_PHASE_RUNNING", "&&", "(", "!", "machine", "->", "paused", "(", ")", "||", "options_get_bool", "(", "machine", "->", "options", "(", ")", ",", "OPTION_UPDATEINPAUSE", ")", ")", ")", "{", "int", "anything_changed", "=", "finish_screen_updates", "(", "machine", ")", ";", "if", "(", "!", "anything_changed", "&&", "!", "global", ".", "auto_frameskip", "&&", "global", ".", "frameskip_level", "==", "0", "&&", "global", ".", "empty_skip_count", "++", "<", "3", ")", "skipped_it", "=", "TRUE", ";", "else", "global", ".", "empty_skip_count", "=", "0", ";", "}", "ui_update_and_render", "(", "machine", ",", "render_container_get_ui", "(", ")", ")", ";", "debugint_update_during_game", "(", "machine", ")", ";", "if", "(", "!", "debug", "&&", "!", "skipped_it", "&&", "effective_throttle", "(", "machine", ")", ")", "update_throttle", "(", "machine", ",", "current_time", ")", ";", "profiler_mark_start", "(", "PROFILER_BLIT", ")", ";", "osd_update", "(", "machine", ",", "!", "debug", "&&", "skipped_it", ")", ";", "profiler_mark_end", "(", ")", ";", "if", "(", "!", "debug", ")", "machine", "->", "call_notifiers", "(", "MACHINE_NOTIFY_FRAME", ")", ";", "if", "(", "!", "debug", ")", "update_frameskip", "(", "machine", ")", ";", "if", "(", "!", "debug", "&&", "!", "skipped_it", ")", "recompute_speed", "(", "machine", ",", "current_time", ")", ";", "if", "(", "phase", "==", "MACHINE_PHASE_RUNNING", ")", "{", "if", "(", "machine", "->", "primary_screen", "!=", "NULL", "&&", "(", "machine", "->", "paused", "(", ")", "||", "debug", "||", "debugger_within_instruction_hook", "(", "machine", ")", ")", ")", "machine", "->", "primary_screen", "->", "scanline0_callback", "(", ")", ";", "else", "if", "(", "machine", "->", "config", "->", "m_video_eof", "!=", "NULL", ")", "{", "profiler_mark_start", "(", "PROFILER_VIDEO", ")", ";", "(", "*", "machine", "->", "config", "->", "m_video_eof", ")", "(", "machine", ")", ";", "profiler_mark_end", "(", ")", ";", "}", "}", "}" ]
video_frame_update - handle frameskipping and UI, plus updating the screen during normal operations
[ "video_frame_update", "-", "handle", "frameskipping", "and", "UI", "plus", "updating", "the", "screen", "during", "normal", "operations" ]
[ "/* validate */", "/* only render sound and video if we're in the running phase */", "/* if none of the screens changed and we haven't skipped too many frames in a row,\r\n mark this frame as skipped to prevent throttling; this helps for games that\r\n don't update their screen at the monitor refresh rate */", "/* draw the user interface */", "/* update the internal render debugger */", "/* if we're throttling, synchronize before rendering */", "/* ask the OSD to update */", "/* perform tasks for this frame */", "/* update frameskipping */", "/* update speed computations */", "/* call the end-of-frame callback */", "/* reset partial updates if we're paused or if the debugger is active */", "/* otherwise, call the video EOF callback */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "debug", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "debug", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
17de2ee985ac78e368f6bc4308c0b0a24354d125
lofunz/mieme
Reloaded/tags/MAME4droid 1.6.0 (0.139u1)/src/emu/video.c
[ "Unlicense" ]
C
video_get_frameskip
int
int video_get_frameskip(void) { /* if autoframeskip is on, return -1 */ if (global.auto_frameskip) return -1; /* otherwise, return the direct level */ else return global.frameskip_level; }
/*------------------------------------------------- video_get_frameskip - return the current actual frameskip (-1 means autoframeskip) -------------------------------------------------*/
return the current actual frameskip (-1 means autoframeskip)
[ "return", "the", "current", "actual", "frameskip", "(", "-", "1", "means", "autoframeskip", ")" ]
int video_get_frameskip(void) { if (global.auto_frameskip) return -1; else return global.frameskip_level; }
[ "int", "video_get_frameskip", "(", "void", ")", "{", "if", "(", "global", ".", "auto_frameskip", ")", "return", "-1", ";", "else", "return", "global", ".", "frameskip_level", ";", "}" ]
video_get_frameskip - return the current actual frameskip (-1 means autoframeskip)
[ "video_get_frameskip", "-", "return", "the", "current", "actual", "frameskip", "(", "-", "1", "means", "autoframeskip", ")" ]
[ "/* if autoframeskip is on, return -1 */", "/* otherwise, return the direct level */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
17de2ee985ac78e368f6bc4308c0b0a24354d125
lofunz/mieme
Reloaded/tags/MAME4droid 1.6.0 (0.139u1)/src/emu/video.c
[ "Unlicense" ]
C
video_set_frameskip
void
void video_set_frameskip(int frameskip) { /* -1 means autoframeskip */ if (frameskip == -1) { global.auto_frameskip = TRUE; global.frameskip_level = 0; } /* any other level is a direct control */ else if (frameskip >= 0 && frameskip <= MAX_FRAMESKIP) { global.auto_frameskip = FALSE; global.frameskip_level = frameskip; } }
/*------------------------------------------------- video_set_frameskip - set the current actual frameskip (-1 means autoframeskip) -------------------------------------------------*/
set the current actual frameskip (-1 means autoframeskip)
[ "set", "the", "current", "actual", "frameskip", "(", "-", "1", "means", "autoframeskip", ")" ]
void video_set_frameskip(int frameskip) { if (frameskip == -1) { global.auto_frameskip = TRUE; global.frameskip_level = 0; } else if (frameskip >= 0 && frameskip <= MAX_FRAMESKIP) { global.auto_frameskip = FALSE; global.frameskip_level = frameskip; } }
[ "void", "video_set_frameskip", "(", "int", "frameskip", ")", "{", "if", "(", "frameskip", "==", "-1", ")", "{", "global", ".", "auto_frameskip", "=", "TRUE", ";", "global", ".", "frameskip_level", "=", "0", ";", "}", "else", "if", "(", "frameskip", ">=", "0", "&&", "frameskip", "<=", "MAX_FRAMESKIP", ")", "{", "global", ".", "auto_frameskip", "=", "FALSE", ";", "global", ".", "frameskip_level", "=", "frameskip", ";", "}", "}" ]
video_set_frameskip - set the current actual frameskip (-1 means autoframeskip)
[ "video_set_frameskip", "-", "set", "the", "current", "actual", "frameskip", "(", "-", "1", "means", "autoframeskip", ")" ]
[ "/* -1 means autoframeskip */", "/* any other level is a direct control */" ]
[ { "param": "frameskip", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "frameskip", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
17de2ee985ac78e368f6bc4308c0b0a24354d125
lofunz/mieme
Reloaded/tags/MAME4droid 1.6.0 (0.139u1)/src/emu/video.c
[ "Unlicense" ]
C
update_throttle
void
static void update_throttle(running_machine *machine, attotime emutime) { /* Throttling theory: This routine is called periodically with an up-to-date emulated time. The idea is to synchronize real time with emulated time. We do this by "throttling", or waiting for real time to catch up with emulated time. In an ideal world, it will take less real time to emulate and render each frame than the emulated time, so we need to slow things down to get both times in sync. There are many complications to this model: * some games run too slow, so each frame we get further and further behind real time; our only choice here is to not throttle * some games have very uneven frame rates; one frame will take a long time to emulate, and the next frame may be very fast * we run on top of multitasking OSes; sometimes execution time is taken away from us, and this means we may not get enough time to emulate one frame * we may be paused, and emulated time may not be marching forward * emulated time could jump due to resetting the machine or restoring from a saved state */ static const UINT8 popcount[256] = { 0,1,1,2,1,2,2,3, 1,2,2,3,2,3,3,4, 1,2,2,3,2,3,3,4, 2,3,3,4,3,4,4,5, 1,2,2,3,2,3,3,4, 2,3,3,4,3,4,4,5, 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, 1,2,2,3,2,3,3,4, 2,3,3,4,3,4,4,5, 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, 3,4,4,5,4,5,5,6, 4,5,5,6,5,6,6,7, 1,2,2,3,2,3,3,4, 2,3,3,4,3,4,4,5, 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, 3,4,4,5,4,5,5,6, 4,5,5,6,5,6,6,7, 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, 3,4,4,5,4,5,5,6, 4,5,5,6,5,6,6,7, 3,4,4,5,4,5,5,6, 4,5,5,6,5,6,6,7, 4,5,5,6,5,6,6,7, 5,6,6,7,6,7,7,8 }; attoseconds_t real_delta_attoseconds; attoseconds_t emu_delta_attoseconds; attoseconds_t real_is_ahead_attoseconds; attoseconds_t attoseconds_per_tick; osd_ticks_t ticks_per_second; osd_ticks_t target_ticks; osd_ticks_t diff_ticks; //dav hack if(myosd_speed!=old_speed) global.speed = original_speed_setting(); //end dav hack /* apply speed factor to emu time */ if (global.speed != 0 && global.speed != 100) { /* multiply emutime by 100, then divide by the global speed factor */ emutime = attotime_div(attotime_mul(emutime, 100), global.speed); } /* compute conversion factors up front */ ticks_per_second = osd_ticks_per_second(); attoseconds_per_tick = ATTOSECONDS_PER_SECOND / ticks_per_second; /* if we're paused, emutime will not advance; instead, we subtract a fixed amount of time (1/60th of a second) from the emulated time that was passed in, and explicitly reset our tracked real and emulated timers to that value ... this means we pretend that the last update was exactly 1/60th of a second ago, and was in sync in both real and emulated time */ if (machine->paused()) { global.throttle_emutime = attotime_sub_attoseconds(emutime, ATTOSECONDS_PER_SECOND / PAUSED_REFRESH_RATE); global.throttle_realtime = global.throttle_emutime; } /* attempt to detect anomalies in the emulated time by subtracting the previously reported value from our current value; this should be a small value somewhere between 0 and 1/10th of a second ... anything outside of this range is obviously wrong and requires a resync */ emu_delta_attoseconds = attotime_to_attoseconds(attotime_sub(emutime, global.throttle_emutime)); if (emu_delta_attoseconds < 0 || emu_delta_attoseconds > ATTOSECONDS_PER_SECOND / 10) { if (LOG_THROTTLE) logerror("Resync due to weird emutime delta: %s\n", attotime_string(attotime_make(0, emu_delta_attoseconds), 18)); goto resync; } /* now determine the current real time in OSD-specified ticks; we have to be careful here because counters can wrap, so we only use the difference between the last read value and the current value in our computations */ diff_ticks = osd_ticks() - global.throttle_last_ticks; global.throttle_last_ticks += diff_ticks; /* if it has been more than a full second of real time since the last call to this function, we just need to resynchronize */ if (diff_ticks >= ticks_per_second) { if (LOG_THROTTLE) logerror("Resync due to real time advancing by more than 1 second\n"); goto resync; } /* convert this value into attoseconds for easier comparison */ real_delta_attoseconds = diff_ticks * attoseconds_per_tick; /* now update our real and emulated timers with the current values */ global.throttle_emutime = emutime; global.throttle_realtime = attotime_add_attoseconds(global.throttle_realtime, real_delta_attoseconds); /* keep a history of whether or not emulated time beat real time over the last few updates; this can be used for future heuristics */ global.throttle_history = (global.throttle_history << 1) | (emu_delta_attoseconds > real_delta_attoseconds); /* determine how far ahead real time is versus emulated time; note that we use the accumulated times for this instead of the deltas for the current update because we want to track time over a longer duration than a single update */ real_is_ahead_attoseconds = attotime_to_attoseconds(attotime_sub(global.throttle_emutime, global.throttle_realtime)); /* if we're more than 1/10th of a second out, or if we are behind at all and emulation is taking longer than the real frame, we just need to resync */ if (real_is_ahead_attoseconds < -ATTOSECONDS_PER_SECOND / 10 || (real_is_ahead_attoseconds < 0 && popcount[global.throttle_history & 0xff] < 6)) { if (LOG_THROTTLE) logerror("Resync due to being behind: %s (history=%08X)\n", attotime_string(attotime_make(0, -real_is_ahead_attoseconds), 18), global.throttle_history); goto resync; } /* if we're behind, it's time to just get out */ if (real_is_ahead_attoseconds < 0) return; /* compute the target real time, in ticks, where we want to be */ target_ticks = global.throttle_last_ticks + real_is_ahead_attoseconds / attoseconds_per_tick; /* throttle until we read the target, and update real time to match the final time */ diff_ticks = throttle_until_ticks(machine, target_ticks) - global.throttle_last_ticks; global.throttle_last_ticks += diff_ticks; global.throttle_realtime = attotime_add_attoseconds(global.throttle_realtime, diff_ticks * attoseconds_per_tick); return; resync: /* reset realtime and emutime to the same value */ global.throttle_realtime = global.throttle_emutime = emutime; }
/*------------------------------------------------- update_throttle - throttle to the game's natural speed -------------------------------------------------*/
throttle to the game's natural speed
[ "throttle", "to", "the", "game", "'", "s", "natural", "speed" ]
static void update_throttle(running_machine *machine, attotime emutime) { static const UINT8 popcount[256] = { 0,1,1,2,1,2,2,3, 1,2,2,3,2,3,3,4, 1,2,2,3,2,3,3,4, 2,3,3,4,3,4,4,5, 1,2,2,3,2,3,3,4, 2,3,3,4,3,4,4,5, 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, 1,2,2,3,2,3,3,4, 2,3,3,4,3,4,4,5, 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, 3,4,4,5,4,5,5,6, 4,5,5,6,5,6,6,7, 1,2,2,3,2,3,3,4, 2,3,3,4,3,4,4,5, 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, 3,4,4,5,4,5,5,6, 4,5,5,6,5,6,6,7, 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, 3,4,4,5,4,5,5,6, 4,5,5,6,5,6,6,7, 3,4,4,5,4,5,5,6, 4,5,5,6,5,6,6,7, 4,5,5,6,5,6,6,7, 5,6,6,7,6,7,7,8 }; attoseconds_t real_delta_attoseconds; attoseconds_t emu_delta_attoseconds; attoseconds_t real_is_ahead_attoseconds; attoseconds_t attoseconds_per_tick; osd_ticks_t ticks_per_second; osd_ticks_t target_ticks; osd_ticks_t diff_ticks; if(myosd_speed!=old_speed) global.speed = original_speed_setting(); if (global.speed != 0 && global.speed != 100) { emutime = attotime_div(attotime_mul(emutime, 100), global.speed); } ticks_per_second = osd_ticks_per_second(); attoseconds_per_tick = ATTOSECONDS_PER_SECOND / ticks_per_second; if (machine->paused()) { global.throttle_emutime = attotime_sub_attoseconds(emutime, ATTOSECONDS_PER_SECOND / PAUSED_REFRESH_RATE); global.throttle_realtime = global.throttle_emutime; } emu_delta_attoseconds = attotime_to_attoseconds(attotime_sub(emutime, global.throttle_emutime)); if (emu_delta_attoseconds < 0 || emu_delta_attoseconds > ATTOSECONDS_PER_SECOND / 10) { if (LOG_THROTTLE) logerror("Resync due to weird emutime delta: %s\n", attotime_string(attotime_make(0, emu_delta_attoseconds), 18)); goto resync; } diff_ticks = osd_ticks() - global.throttle_last_ticks; global.throttle_last_ticks += diff_ticks; if (diff_ticks >= ticks_per_second) { if (LOG_THROTTLE) logerror("Resync due to real time advancing by more than 1 second\n"); goto resync; } real_delta_attoseconds = diff_ticks * attoseconds_per_tick; global.throttle_emutime = emutime; global.throttle_realtime = attotime_add_attoseconds(global.throttle_realtime, real_delta_attoseconds); global.throttle_history = (global.throttle_history << 1) | (emu_delta_attoseconds > real_delta_attoseconds); real_is_ahead_attoseconds = attotime_to_attoseconds(attotime_sub(global.throttle_emutime, global.throttle_realtime)); if (real_is_ahead_attoseconds < -ATTOSECONDS_PER_SECOND / 10 || (real_is_ahead_attoseconds < 0 && popcount[global.throttle_history & 0xff] < 6)) { if (LOG_THROTTLE) logerror("Resync due to being behind: %s (history=%08X)\n", attotime_string(attotime_make(0, -real_is_ahead_attoseconds), 18), global.throttle_history); goto resync; } if (real_is_ahead_attoseconds < 0) return; target_ticks = global.throttle_last_ticks + real_is_ahead_attoseconds / attoseconds_per_tick; diff_ticks = throttle_until_ticks(machine, target_ticks) - global.throttle_last_ticks; global.throttle_last_ticks += diff_ticks; global.throttle_realtime = attotime_add_attoseconds(global.throttle_realtime, diff_ticks * attoseconds_per_tick); return; resync: global.throttle_realtime = global.throttle_emutime = emutime; }
[ "static", "void", "update_throttle", "(", "running_machine", "*", "machine", ",", "attotime", "emutime", ")", "{", "static", "const", "UINT8", "popcount", "[", "256", "]", "=", "{", "0", ",", "1", ",", "1", ",", "2", ",", "1", ",", "2", ",", "2", ",", "3", ",", "1", ",", "2", ",", "2", ",", "3", ",", "2", ",", "3", ",", "3", ",", "4", ",", "1", ",", "2", ",", "2", ",", "3", ",", "2", ",", "3", ",", "3", ",", "4", ",", "2", ",", "3", ",", "3", ",", "4", ",", "3", ",", "4", ",", "4", ",", "5", ",", "1", ",", "2", ",", "2", ",", "3", ",", "2", ",", "3", ",", "3", ",", "4", ",", "2", ",", "3", ",", "3", ",", "4", ",", "3", ",", "4", ",", "4", ",", "5", ",", "2", ",", "3", ",", "3", ",", "4", ",", "3", ",", "4", ",", "4", ",", "5", ",", "3", ",", "4", ",", "4", ",", "5", ",", "4", ",", "5", ",", "5", ",", "6", ",", "1", ",", "2", ",", "2", ",", "3", ",", "2", ",", "3", ",", "3", ",", "4", ",", "2", ",", "3", ",", "3", ",", "4", ",", "3", ",", "4", ",", "4", ",", "5", ",", "2", ",", "3", ",", "3", ",", "4", ",", "3", ",", "4", ",", "4", ",", "5", ",", "3", ",", "4", ",", "4", ",", "5", ",", "4", ",", "5", ",", "5", ",", "6", ",", "2", ",", "3", ",", "3", ",", "4", ",", "3", ",", "4", ",", "4", ",", "5", ",", "3", ",", "4", ",", "4", ",", "5", ",", "4", ",", "5", ",", "5", ",", "6", ",", "3", ",", "4", ",", "4", ",", "5", ",", "4", ",", "5", ",", "5", ",", "6", ",", "4", ",", "5", ",", "5", ",", "6", ",", "5", ",", "6", ",", "6", ",", "7", ",", "1", ",", "2", ",", "2", ",", "3", ",", "2", ",", "3", ",", "3", ",", "4", ",", "2", ",", "3", ",", "3", ",", "4", ",", "3", ",", "4", ",", "4", ",", "5", ",", "2", ",", "3", ",", "3", ",", "4", ",", "3", ",", "4", ",", "4", ",", "5", ",", "3", ",", "4", ",", "4", ",", "5", ",", "4", ",", "5", ",", "5", ",", "6", ",", "2", ",", "3", ",", "3", ",", "4", ",", "3", ",", "4", ",", "4", ",", "5", ",", "3", ",", "4", ",", "4", ",", "5", ",", "4", ",", "5", ",", "5", ",", "6", ",", "3", ",", "4", ",", "4", ",", "5", ",", "4", ",", "5", ",", "5", ",", "6", ",", "4", ",", "5", ",", "5", ",", "6", ",", "5", ",", "6", ",", "6", ",", "7", ",", "2", ",", "3", ",", "3", ",", "4", ",", "3", ",", "4", ",", "4", ",", "5", ",", "3", ",", "4", ",", "4", ",", "5", ",", "4", ",", "5", ",", "5", ",", "6", ",", "3", ",", "4", ",", "4", ",", "5", ",", "4", ",", "5", ",", "5", ",", "6", ",", "4", ",", "5", ",", "5", ",", "6", ",", "5", ",", "6", ",", "6", ",", "7", ",", "3", ",", "4", ",", "4", ",", "5", ",", "4", ",", "5", ",", "5", ",", "6", ",", "4", ",", "5", ",", "5", ",", "6", ",", "5", ",", "6", ",", "6", ",", "7", ",", "4", ",", "5", ",", "5", ",", "6", ",", "5", ",", "6", ",", "6", ",", "7", ",", "5", ",", "6", ",", "6", ",", "7", ",", "6", ",", "7", ",", "7", ",", "8", "}", ";", "attoseconds_t", "real_delta_attoseconds", ";", "attoseconds_t", "emu_delta_attoseconds", ";", "attoseconds_t", "real_is_ahead_attoseconds", ";", "attoseconds_t", "attoseconds_per_tick", ";", "osd_ticks_t", "ticks_per_second", ";", "osd_ticks_t", "target_ticks", ";", "osd_ticks_t", "diff_ticks", ";", "if", "(", "myosd_speed", "!=", "old_speed", ")", "global", ".", "speed", "=", "original_speed_setting", "(", ")", ";", "if", "(", "global", ".", "speed", "!=", "0", "&&", "global", ".", "speed", "!=", "100", ")", "{", "emutime", "=", "attotime_div", "(", "attotime_mul", "(", "emutime", ",", "100", ")", ",", "global", ".", "speed", ")", ";", "}", "ticks_per_second", "=", "osd_ticks_per_second", "(", ")", ";", "attoseconds_per_tick", "=", "ATTOSECONDS_PER_SECOND", "/", "ticks_per_second", ";", "if", "(", "machine", "->", "paused", "(", ")", ")", "{", "global", ".", "throttle_emutime", "=", "attotime_sub_attoseconds", "(", "emutime", ",", "ATTOSECONDS_PER_SECOND", "/", "PAUSED_REFRESH_RATE", ")", ";", "global", ".", "throttle_realtime", "=", "global", ".", "throttle_emutime", ";", "}", "emu_delta_attoseconds", "=", "attotime_to_attoseconds", "(", "attotime_sub", "(", "emutime", ",", "global", ".", "throttle_emutime", ")", ")", ";", "if", "(", "emu_delta_attoseconds", "<", "0", "||", "emu_delta_attoseconds", ">", "ATTOSECONDS_PER_SECOND", "/", "10", ")", "{", "if", "(", "LOG_THROTTLE", ")", "logerror", "(", "\"", "\\n", "\"", ",", "attotime_string", "(", "attotime_make", "(", "0", ",", "emu_delta_attoseconds", ")", ",", "18", ")", ")", ";", "goto", "resync", ";", "}", "diff_ticks", "=", "osd_ticks", "(", ")", "-", "global", ".", "throttle_last_ticks", ";", "global", ".", "throttle_last_ticks", "+=", "diff_ticks", ";", "if", "(", "diff_ticks", ">=", "ticks_per_second", ")", "{", "if", "(", "LOG_THROTTLE", ")", "logerror", "(", "\"", "\\n", "\"", ")", ";", "goto", "resync", ";", "}", "real_delta_attoseconds", "=", "diff_ticks", "*", "attoseconds_per_tick", ";", "global", ".", "throttle_emutime", "=", "emutime", ";", "global", ".", "throttle_realtime", "=", "attotime_add_attoseconds", "(", "global", ".", "throttle_realtime", ",", "real_delta_attoseconds", ")", ";", "global", ".", "throttle_history", "=", "(", "global", ".", "throttle_history", "<<", "1", ")", "|", "(", "emu_delta_attoseconds", ">", "real_delta_attoseconds", ")", ";", "real_is_ahead_attoseconds", "=", "attotime_to_attoseconds", "(", "attotime_sub", "(", "global", ".", "throttle_emutime", ",", "global", ".", "throttle_realtime", ")", ")", ";", "if", "(", "real_is_ahead_attoseconds", "<", "-", "ATTOSECONDS_PER_SECOND", "/", "10", "||", "(", "real_is_ahead_attoseconds", "<", "0", "&&", "popcount", "[", "global", ".", "throttle_history", "&", "0xff", "]", "<", "6", ")", ")", "{", "if", "(", "LOG_THROTTLE", ")", "logerror", "(", "\"", "\\n", "\"", ",", "attotime_string", "(", "attotime_make", "(", "0", ",", "-", "real_is_ahead_attoseconds", ")", ",", "18", ")", ",", "global", ".", "throttle_history", ")", ";", "goto", "resync", ";", "}", "if", "(", "real_is_ahead_attoseconds", "<", "0", ")", "return", ";", "target_ticks", "=", "global", ".", "throttle_last_ticks", "+", "real_is_ahead_attoseconds", "/", "attoseconds_per_tick", ";", "diff_ticks", "=", "throttle_until_ticks", "(", "machine", ",", "target_ticks", ")", "-", "global", ".", "throttle_last_ticks", ";", "global", ".", "throttle_last_ticks", "+=", "diff_ticks", ";", "global", ".", "throttle_realtime", "=", "attotime_add_attoseconds", "(", "global", ".", "throttle_realtime", ",", "diff_ticks", "*", "attoseconds_per_tick", ")", ";", "return", ";", "resync", ":", "global", ".", "throttle_realtime", "=", "global", ".", "throttle_emutime", "=", "emutime", ";", "}" ]
update_throttle - throttle to the game's natural speed
[ "update_throttle", "-", "throttle", "to", "the", "game", "'", "s", "natural", "speed" ]
[ "/*\r\n\r\n Throttling theory:\r\n\r\n This routine is called periodically with an up-to-date emulated time.\r\n The idea is to synchronize real time with emulated time. We do this\r\n by \"throttling\", or waiting for real time to catch up with emulated\r\n time.\r\n\r\n In an ideal world, it will take less real time to emulate and render\r\n each frame than the emulated time, so we need to slow things down to\r\n get both times in sync.\r\n\r\n There are many complications to this model:\r\n\r\n * some games run too slow, so each frame we get further and\r\n further behind real time; our only choice here is to not\r\n throttle\r\n\r\n * some games have very uneven frame rates; one frame will take\r\n a long time to emulate, and the next frame may be very fast\r\n\r\n * we run on top of multitasking OSes; sometimes execution time\r\n is taken away from us, and this means we may not get enough\r\n time to emulate one frame\r\n\r\n * we may be paused, and emulated time may not be marching\r\n forward\r\n\r\n * emulated time could jump due to resetting the machine or\r\n restoring from a saved state\r\n\r\n*/", "//dav hack\r", "//end dav hack\r", "/* apply speed factor to emu time */", "/* multiply emutime by 100, then divide by the global speed factor */", "/* compute conversion factors up front */", "/* if we're paused, emutime will not advance; instead, we subtract a fixed\r\n amount of time (1/60th of a second) from the emulated time that was passed in,\r\n and explicitly reset our tracked real and emulated timers to that value ...\r\n this means we pretend that the last update was exactly 1/60th of a second\r\n ago, and was in sync in both real and emulated time */", "/* attempt to detect anomalies in the emulated time by subtracting the previously\r\n reported value from our current value; this should be a small value somewhere\r\n between 0 and 1/10th of a second ... anything outside of this range is obviously\r\n wrong and requires a resync */", "/* now determine the current real time in OSD-specified ticks; we have to be careful\r\n here because counters can wrap, so we only use the difference between the last\r\n read value and the current value in our computations */", "/* if it has been more than a full second of real time since the last call to this\r\n function, we just need to resynchronize */", "/* convert this value into attoseconds for easier comparison */", "/* now update our real and emulated timers with the current values */", "/* keep a history of whether or not emulated time beat real time over the last few\r\n updates; this can be used for future heuristics */", "/* determine how far ahead real time is versus emulated time; note that we use the\r\n accumulated times for this instead of the deltas for the current update because\r\n we want to track time over a longer duration than a single update */", "/* if we're more than 1/10th of a second out, or if we are behind at all and emulation\r\n is taking longer than the real frame, we just need to resync */", "/* if we're behind, it's time to just get out */", "/* compute the target real time, in ticks, where we want to be */", "/* throttle until we read the target, and update real time to match the final time */", "/* reset realtime and emutime to the same value */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "emutime", "type": "attotime" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "emutime", "type": "attotime", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
17de2ee985ac78e368f6bc4308c0b0a24354d125
lofunz/mieme
Reloaded/tags/MAME4droid 1.6.0 (0.139u1)/src/emu/video.c
[ "Unlicense" ]
C
throttle_until_ticks
osd_ticks_t
static osd_ticks_t throttle_until_ticks(running_machine *machine, osd_ticks_t target_ticks) { osd_ticks_t minimum_sleep = osd_ticks_per_second() / 1000; osd_ticks_t current_ticks = osd_ticks(); osd_ticks_t new_ticks; int allowed_to_sleep = FALSE; /* we're allowed to sleep via the OSD code only if we're configured to do so and we're not frameskipping due to autoframeskip, or if we're paused */ //DAV HACK //if (options_get_bool(machine->options(), OPTION_SLEEP) && (!effective_autoframeskip(machine) || effective_frameskip() == 0)) if (/*options_get_bool(mame_options(), OPTION_SLEEP)*/myosd_sleep && (!effective_autoframeskip(machine) || effective_frameskip() == 0)) allowed_to_sleep = TRUE; if (machine->paused()) allowed_to_sleep = TRUE; /* loop until we reach our target */ profiler_mark_start(PROFILER_IDLE); while (current_ticks < target_ticks) { osd_ticks_t delta; int slept = FALSE; /* compute how much time to sleep for, taking into account the average oversleep */ delta = (target_ticks - current_ticks) * 1000 / (1000 + global.average_oversleep); /* see if we can sleep */ if (allowed_to_sleep && delta >= minimum_sleep) { osd_sleep(delta); slept = TRUE; } /* read the new value */ new_ticks = osd_ticks(); /* keep some metrics on the sleeping patterns of the OSD layer */ if (slept) { osd_ticks_t actual_ticks = new_ticks - current_ticks; /* if we overslept, keep an average of the amount */ if (actual_ticks > delta) { osd_ticks_t oversleep_milliticks = 1000 * (actual_ticks - delta) / delta; /* take 90% of the previous average plus 10% of the new value */ global.average_oversleep = (global.average_oversleep * 99 + oversleep_milliticks) / 100; if (LOG_THROTTLE) logerror("Slept for %d ticks, got %d ticks, avgover = %d\n", (int)delta, (int)actual_ticks, (int)global.average_oversleep); } } current_ticks = new_ticks; } profiler_mark_end(); return current_ticks; }
/*------------------------------------------------- throttle_until_ticks - spin until the specified target time, calling the OSD code to sleep if possible -------------------------------------------------*/
spin until the specified target time, calling the OSD code to sleep if possible
[ "spin", "until", "the", "specified", "target", "time", "calling", "the", "OSD", "code", "to", "sleep", "if", "possible" ]
static osd_ticks_t throttle_until_ticks(running_machine *machine, osd_ticks_t target_ticks) { osd_ticks_t minimum_sleep = osd_ticks_per_second() / 1000; osd_ticks_t current_ticks = osd_ticks(); osd_ticks_t new_ticks; int allowed_to_sleep = FALSE; if (myosd_sleep && (!effective_autoframeskip(machine) || effective_frameskip() == 0)) allowed_to_sleep = TRUE; if (machine->paused()) allowed_to_sleep = TRUE; profiler_mark_start(PROFILER_IDLE); while (current_ticks < target_ticks) { osd_ticks_t delta; int slept = FALSE; delta = (target_ticks - current_ticks) * 1000 / (1000 + global.average_oversleep); if (allowed_to_sleep && delta >= minimum_sleep) { osd_sleep(delta); slept = TRUE; } new_ticks = osd_ticks(); if (slept) { osd_ticks_t actual_ticks = new_ticks - current_ticks; if (actual_ticks > delta) { osd_ticks_t oversleep_milliticks = 1000 * (actual_ticks - delta) / delta; global.average_oversleep = (global.average_oversleep * 99 + oversleep_milliticks) / 100; if (LOG_THROTTLE) logerror("Slept for %d ticks, got %d ticks, avgover = %d\n", (int)delta, (int)actual_ticks, (int)global.average_oversleep); } } current_ticks = new_ticks; } profiler_mark_end(); return current_ticks; }
[ "static", "osd_ticks_t", "throttle_until_ticks", "(", "running_machine", "*", "machine", ",", "osd_ticks_t", "target_ticks", ")", "{", "osd_ticks_t", "minimum_sleep", "=", "osd_ticks_per_second", "(", ")", "/", "1000", ";", "osd_ticks_t", "current_ticks", "=", "osd_ticks", "(", ")", ";", "osd_ticks_t", "new_ticks", ";", "int", "allowed_to_sleep", "=", "FALSE", ";", "if", "(", "myosd_sleep", "&&", "(", "!", "effective_autoframeskip", "(", "machine", ")", "||", "effective_frameskip", "(", ")", "==", "0", ")", ")", "allowed_to_sleep", "=", "TRUE", ";", "if", "(", "machine", "->", "paused", "(", ")", ")", "allowed_to_sleep", "=", "TRUE", ";", "profiler_mark_start", "(", "PROFILER_IDLE", ")", ";", "while", "(", "current_ticks", "<", "target_ticks", ")", "{", "osd_ticks_t", "delta", ";", "int", "slept", "=", "FALSE", ";", "delta", "=", "(", "target_ticks", "-", "current_ticks", ")", "*", "1000", "/", "(", "1000", "+", "global", ".", "average_oversleep", ")", ";", "if", "(", "allowed_to_sleep", "&&", "delta", ">=", "minimum_sleep", ")", "{", "osd_sleep", "(", "delta", ")", ";", "slept", "=", "TRUE", ";", "}", "new_ticks", "=", "osd_ticks", "(", ")", ";", "if", "(", "slept", ")", "{", "osd_ticks_t", "actual_ticks", "=", "new_ticks", "-", "current_ticks", ";", "if", "(", "actual_ticks", ">", "delta", ")", "{", "osd_ticks_t", "oversleep_milliticks", "=", "1000", "*", "(", "actual_ticks", "-", "delta", ")", "/", "delta", ";", "global", ".", "average_oversleep", "=", "(", "global", ".", "average_oversleep", "*", "99", "+", "oversleep_milliticks", ")", "/", "100", ";", "if", "(", "LOG_THROTTLE", ")", "logerror", "(", "\"", "\\n", "\"", ",", "(", "int", ")", "delta", ",", "(", "int", ")", "actual_ticks", ",", "(", "int", ")", "global", ".", "average_oversleep", ")", ";", "}", "}", "current_ticks", "=", "new_ticks", ";", "}", "profiler_mark_end", "(", ")", ";", "return", "current_ticks", ";", "}" ]
throttle_until_ticks - spin until the specified target time, calling the OSD code to sleep if possible
[ "throttle_until_ticks", "-", "spin", "until", "the", "specified", "target", "time", "calling", "the", "OSD", "code", "to", "sleep", "if", "possible" ]
[ "/* we're allowed to sleep via the OSD code only if we're configured to do so\r\n and we're not frameskipping due to autoframeskip, or if we're paused */", "//DAV HACK\r", "//if (options_get_bool(machine->options(), OPTION_SLEEP) && (!effective_autoframeskip(machine) || effective_frameskip() == 0))\r", "/*options_get_bool(mame_options(), OPTION_SLEEP)*/", "/* loop until we reach our target */", "/* compute how much time to sleep for, taking into account the average oversleep */", "/* see if we can sleep */", "/* read the new value */", "/* keep some metrics on the sleeping patterns of the OSD layer */", "/* if we overslept, keep an average of the amount */", "/* take 90% of the previous average plus 10% of the new value */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "target_ticks", "type": "osd_ticks_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "target_ticks", "type": "osd_ticks_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
17de2ee985ac78e368f6bc4308c0b0a24354d125
lofunz/mieme
Reloaded/tags/MAME4droid 1.6.0 (0.139u1)/src/emu/video.c
[ "Unlicense" ]
C
update_frameskip
void
static void update_frameskip(running_machine *machine) { /* if we're throttling and autoframeskip is on, adjust */ if (effective_throttle(machine) && effective_autoframeskip(machine) && global.frameskip_counter == 0) { double speed = global.speed * 0.01; /* if we're too fast, attempt to increase the frameskip */ if (global.speed_percent >= 0.995 * speed) { /* but only after 3 consecutive frames where we are too fast */ if (++global.frameskip_adjust >= 3) { global.frameskip_adjust = 0; if (global.frameskip_level > 0) global.frameskip_level--; } } /* if we're too slow, attempt to increase the frameskip */ else { /* if below 80% speed, be more aggressive */ if (global.speed_percent < 0.80 * speed) global.frameskip_adjust -= (0.90 * speed - global.speed_percent) / 0.05; /* if we're close, only force it up to frameskip 8 */ else if (global.frameskip_level < 8) global.frameskip_adjust--; /* perform the adjustment */ while (global.frameskip_adjust <= -2) { global.frameskip_adjust += 2; if (global.frameskip_level < MAX_FRAMESKIP) global.frameskip_level++; } } } /* increment the frameskip counter and determine if we will skip the next frame */ global.frameskip_counter = (global.frameskip_counter + 1) % FRAMESKIP_LEVELS; global.skipping_this_frame = skiptable[effective_frameskip()][global.frameskip_counter]; }
/*------------------------------------------------- update_frameskip - update frameskipping counters and periodically update autoframeskip -------------------------------------------------*/
update frameskipping counters and periodically update autoframeskip
[ "update", "frameskipping", "counters", "and", "periodically", "update", "autoframeskip" ]
static void update_frameskip(running_machine *machine) { if (effective_throttle(machine) && effective_autoframeskip(machine) && global.frameskip_counter == 0) { double speed = global.speed * 0.01; if (global.speed_percent >= 0.995 * speed) { if (++global.frameskip_adjust >= 3) { global.frameskip_adjust = 0; if (global.frameskip_level > 0) global.frameskip_level--; } } else { if (global.speed_percent < 0.80 * speed) global.frameskip_adjust -= (0.90 * speed - global.speed_percent) / 0.05; else if (global.frameskip_level < 8) global.frameskip_adjust--; while (global.frameskip_adjust <= -2) { global.frameskip_adjust += 2; if (global.frameskip_level < MAX_FRAMESKIP) global.frameskip_level++; } } } global.frameskip_counter = (global.frameskip_counter + 1) % FRAMESKIP_LEVELS; global.skipping_this_frame = skiptable[effective_frameskip()][global.frameskip_counter]; }
[ "static", "void", "update_frameskip", "(", "running_machine", "*", "machine", ")", "{", "if", "(", "effective_throttle", "(", "machine", ")", "&&", "effective_autoframeskip", "(", "machine", ")", "&&", "global", ".", "frameskip_counter", "==", "0", ")", "{", "double", "speed", "=", "global", ".", "speed", "*", "0.01", ";", "if", "(", "global", ".", "speed_percent", ">=", "0.995", "*", "speed", ")", "{", "if", "(", "++", "global", ".", "frameskip_adjust", ">=", "3", ")", "{", "global", ".", "frameskip_adjust", "=", "0", ";", "if", "(", "global", ".", "frameskip_level", ">", "0", ")", "global", ".", "frameskip_level", "--", ";", "}", "}", "else", "{", "if", "(", "global", ".", "speed_percent", "<", "0.80", "*", "speed", ")", "global", ".", "frameskip_adjust", "-=", "(", "0.90", "*", "speed", "-", "global", ".", "speed_percent", ")", "/", "0.05", ";", "else", "if", "(", "global", ".", "frameskip_level", "<", "8", ")", "global", ".", "frameskip_adjust", "--", ";", "while", "(", "global", ".", "frameskip_adjust", "<=", "-2", ")", "{", "global", ".", "frameskip_adjust", "+=", "2", ";", "if", "(", "global", ".", "frameskip_level", "<", "MAX_FRAMESKIP", ")", "global", ".", "frameskip_level", "++", ";", "}", "}", "}", "global", ".", "frameskip_counter", "=", "(", "global", ".", "frameskip_counter", "+", "1", ")", "%", "FRAMESKIP_LEVELS", ";", "global", ".", "skipping_this_frame", "=", "skiptable", "[", "effective_frameskip", "(", ")", "]", "[", "global", ".", "frameskip_counter", "]", ";", "}" ]
update_frameskip - update frameskipping counters and periodically update autoframeskip
[ "update_frameskip", "-", "update", "frameskipping", "counters", "and", "periodically", "update", "autoframeskip" ]
[ "/* if we're throttling and autoframeskip is on, adjust */", "/* if we're too fast, attempt to increase the frameskip */", "/* but only after 3 consecutive frames where we are too fast */", "/* if we're too slow, attempt to increase the frameskip */", "/* if below 80% speed, be more aggressive */", "/* if we're close, only force it up to frameskip 8 */", "/* perform the adjustment */", "/* increment the frameskip counter and determine if we will skip the next frame */" ]
[ { "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": [] }
17de2ee985ac78e368f6bc4308c0b0a24354d125
lofunz/mieme
Reloaded/tags/MAME4droid 1.6.0 (0.139u1)/src/emu/video.c
[ "Unlicense" ]
C
update_refresh_speed
void
static void update_refresh_speed(running_machine *machine) { /* only do this if the refreshspeed option is used */ if (0 || options_get_bool(machine->options(), OPTION_REFRESHSPEED)) { float minrefresh = 60.00f;//render_get_max_update_rate(); if (minrefresh != 0) { attoseconds_t min_frame_period = ATTOSECONDS_PER_SECOND; UINT32 original_speed = original_speed_setting(); UINT32 target_speed; /* find the screen with the shortest frame period (max refresh rate) */ /* note that we first check the token since this can get called before all screens are created */ for (screen_device *screen = screen_first(*machine); screen != NULL; screen = screen_next(screen)) { attoseconds_t period = screen->frame_period().attoseconds; if (period != 0) min_frame_period = MIN(min_frame_period, period); } /* compute a target speed as an integral percentage */ /* note that we lop 0.25Hz off of the minrefresh when doing the computation to allow for the fact that most refresh rates are not accurate to 10 digits... */ target_speed = floor((minrefresh - 0.25f) * 100.0 / ATTOSECONDS_TO_HZ(min_frame_period)); //target_speed = MIN(target_speed, original_speed); //target_speed = ((minrefresh + 0.25) * 100.0) / ATTOSECONDS_TO_HZ(min_frame_period); target_speed = MAX(target_speed, original_speed); /* if we changed, log that verbosely */ if (target_speed != global.speed) { printf("Adjusting target speed to %d%% (hw=%.2fHz, game=%.2fHz, adjusted=%.2fHz)\n", target_speed, minrefresh, ATTOSECONDS_TO_HZ(min_frame_period), ATTOSECONDS_TO_HZ(min_frame_period * 100 / target_speed)); mame_printf_verbose("Adjusting target speed to %d%% (hw=%.2fHz, game=%.2fHz, adjusted=%.2fHz)\n", target_speed, minrefresh, ATTOSECONDS_TO_HZ(min_frame_period), ATTOSECONDS_TO_HZ(min_frame_period * 100 / target_speed)); global.speed = target_speed; for (screen_device *screen = screen_first(*machine); screen != NULL; screen = screen_next(screen)) { screen->configure(screen->width(), screen->height(), screen->visible_area(), HZ_TO_ATTOSECONDS(60.00f)); } } } } }
/*------------------------------------------------- update_refresh_speed - update the global.speed based on the maximum refresh rate supported -------------------------------------------------*/
update the global.speed based on the maximum refresh rate supported
[ "update", "the", "global", ".", "speed", "based", "on", "the", "maximum", "refresh", "rate", "supported" ]
static void update_refresh_speed(running_machine *machine) { if (0 || options_get_bool(machine->options(), OPTION_REFRESHSPEED)) { float minrefresh = 60.00f; if (minrefresh != 0) { attoseconds_t min_frame_period = ATTOSECONDS_PER_SECOND; UINT32 original_speed = original_speed_setting(); UINT32 target_speed; for (screen_device *screen = screen_first(*machine); screen != NULL; screen = screen_next(screen)) { attoseconds_t period = screen->frame_period().attoseconds; if (period != 0) min_frame_period = MIN(min_frame_period, period); } target_speed = floor((minrefresh - 0.25f) * 100.0 / ATTOSECONDS_TO_HZ(min_frame_period)); target_speed = MAX(target_speed, original_speed); if (target_speed != global.speed) { printf("Adjusting target speed to %d%% (hw=%.2fHz, game=%.2fHz, adjusted=%.2fHz)\n", target_speed, minrefresh, ATTOSECONDS_TO_HZ(min_frame_period), ATTOSECONDS_TO_HZ(min_frame_period * 100 / target_speed)); mame_printf_verbose("Adjusting target speed to %d%% (hw=%.2fHz, game=%.2fHz, adjusted=%.2fHz)\n", target_speed, minrefresh, ATTOSECONDS_TO_HZ(min_frame_period), ATTOSECONDS_TO_HZ(min_frame_period * 100 / target_speed)); global.speed = target_speed; for (screen_device *screen = screen_first(*machine); screen != NULL; screen = screen_next(screen)) { screen->configure(screen->width(), screen->height(), screen->visible_area(), HZ_TO_ATTOSECONDS(60.00f)); } } } } }
[ "static", "void", "update_refresh_speed", "(", "running_machine", "*", "machine", ")", "{", "if", "(", "0", "||", "options_get_bool", "(", "machine", "->", "options", "(", ")", ",", "OPTION_REFRESHSPEED", ")", ")", "{", "float", "minrefresh", "=", "60.00f", ";", "if", "(", "minrefresh", "!=", "0", ")", "{", "attoseconds_t", "min_frame_period", "=", "ATTOSECONDS_PER_SECOND", ";", "UINT32", "original_speed", "=", "original_speed_setting", "(", ")", ";", "UINT32", "target_speed", ";", "for", "(", "screen_device", "*", "screen", "=", "screen_first", "(", "*", "machine", ")", ";", "screen", "!=", "NULL", ";", "screen", "=", "screen_next", "(", "screen", ")", ")", "{", "attoseconds_t", "period", "=", "screen", "->", "frame_period", "(", ")", ".", "attoseconds", ";", "if", "(", "period", "!=", "0", ")", "min_frame_period", "=", "MIN", "(", "min_frame_period", ",", "period", ")", ";", "}", "target_speed", "=", "floor", "(", "(", "minrefresh", "-", "0.25f", ")", "*", "100.0", "/", "ATTOSECONDS_TO_HZ", "(", "min_frame_period", ")", ")", ";", "target_speed", "=", "MAX", "(", "target_speed", ",", "original_speed", ")", ";", "if", "(", "target_speed", "!=", "global", ".", "speed", ")", "{", "printf", "(", "\"", "\\n", "\"", ",", "target_speed", ",", "minrefresh", ",", "ATTOSECONDS_TO_HZ", "(", "min_frame_period", ")", ",", "ATTOSECONDS_TO_HZ", "(", "min_frame_period", "*", "100", "/", "target_speed", ")", ")", ";", "mame_printf_verbose", "(", "\"", "\\n", "\"", ",", "target_speed", ",", "minrefresh", ",", "ATTOSECONDS_TO_HZ", "(", "min_frame_period", ")", ",", "ATTOSECONDS_TO_HZ", "(", "min_frame_period", "*", "100", "/", "target_speed", ")", ")", ";", "global", ".", "speed", "=", "target_speed", ";", "for", "(", "screen_device", "*", "screen", "=", "screen_first", "(", "*", "machine", ")", ";", "screen", "!=", "NULL", ";", "screen", "=", "screen_next", "(", "screen", ")", ")", "{", "screen", "->", "configure", "(", "screen", "->", "width", "(", ")", ",", "screen", "->", "height", "(", ")", ",", "screen", "->", "visible_area", "(", ")", ",", "HZ_TO_ATTOSECONDS", "(", "60.00f", ")", ")", ";", "}", "}", "}", "}", "}" ]
update_refresh_speed - update the global.speed based on the maximum refresh rate supported
[ "update_refresh_speed", "-", "update", "the", "global", ".", "speed", "based", "on", "the", "maximum", "refresh", "rate", "supported" ]
[ "/* only do this if the refreshspeed option is used */", "//render_get_max_update_rate();\r", "/* find the screen with the shortest frame period (max refresh rate) */", "/* note that we first check the token since this can get called before all screens are created */", "/* compute a target speed as an integral percentage */", "/* note that we lop 0.25Hz off of the minrefresh when doing the computation to allow for\r\n the fact that most refresh rates are not accurate to 10 digits... */", "//target_speed = MIN(target_speed, original_speed);\r", "//target_speed = ((minrefresh + 0.25) * 100.0) / ATTOSECONDS_TO_HZ(min_frame_period);\r", "/* if we changed, log that verbosely */" ]
[ { "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": [] }
17de2ee985ac78e368f6bc4308c0b0a24354d125
lofunz/mieme
Reloaded/tags/MAME4droid 1.6.0 (0.139u1)/src/emu/video.c
[ "Unlicense" ]
C
video_save_active_screen_snapshots
void
void video_save_active_screen_snapshots(running_machine *machine) { mame_file *fp; /* validate */ assert(machine != NULL); assert(machine->config != NULL); /* if we're native, then write one snapshot per visible screen */ if (global.snap_native) { /* write one snapshot per visible screen */ for (screen_device *screen = screen_first(*machine); screen != NULL; screen = screen_next(screen)) if (render_is_live_screen(screen)) { file_error filerr = mame_fopen_next(machine, SEARCHPATH_SCREENSHOT, "png", &fp); if (filerr == FILERR_NONE) { screen_save_snapshot(machine, screen, fp); mame_fclose(fp); } } } /* otherwise, just write a single snapshot */ else { file_error filerr = mame_fopen_next(machine, SEARCHPATH_SCREENSHOT, "png", &fp); if (filerr == FILERR_NONE) { screen_save_snapshot(machine, NULL, fp); mame_fclose(fp); } } }
/*------------------------------------------------- video_save_active_screen_snapshots - save a snapshot of all active screens -------------------------------------------------*/
save a snapshot of all active screens
[ "save", "a", "snapshot", "of", "all", "active", "screens" ]
void video_save_active_screen_snapshots(running_machine *machine) { mame_file *fp; assert(machine != NULL); assert(machine->config != NULL); if (global.snap_native) { for (screen_device *screen = screen_first(*machine); screen != NULL; screen = screen_next(screen)) if (render_is_live_screen(screen)) { file_error filerr = mame_fopen_next(machine, SEARCHPATH_SCREENSHOT, "png", &fp); if (filerr == FILERR_NONE) { screen_save_snapshot(machine, screen, fp); mame_fclose(fp); } } } else { file_error filerr = mame_fopen_next(machine, SEARCHPATH_SCREENSHOT, "png", &fp); if (filerr == FILERR_NONE) { screen_save_snapshot(machine, NULL, fp); mame_fclose(fp); } } }
[ "void", "video_save_active_screen_snapshots", "(", "running_machine", "*", "machine", ")", "{", "mame_file", "*", "fp", ";", "assert", "(", "machine", "!=", "NULL", ")", ";", "assert", "(", "machine", "->", "config", "!=", "NULL", ")", ";", "if", "(", "global", ".", "snap_native", ")", "{", "for", "(", "screen_device", "*", "screen", "=", "screen_first", "(", "*", "machine", ")", ";", "screen", "!=", "NULL", ";", "screen", "=", "screen_next", "(", "screen", ")", ")", "if", "(", "render_is_live_screen", "(", "screen", ")", ")", "{", "file_error", "filerr", "=", "mame_fopen_next", "(", "machine", ",", "SEARCHPATH_SCREENSHOT", ",", "\"", "\"", ",", "&", "fp", ")", ";", "if", "(", "filerr", "==", "FILERR_NONE", ")", "{", "screen_save_snapshot", "(", "machine", ",", "screen", ",", "fp", ")", ";", "mame_fclose", "(", "fp", ")", ";", "}", "}", "}", "else", "{", "file_error", "filerr", "=", "mame_fopen_next", "(", "machine", ",", "SEARCHPATH_SCREENSHOT", ",", "\"", "\"", ",", "&", "fp", ")", ";", "if", "(", "filerr", "==", "FILERR_NONE", ")", "{", "screen_save_snapshot", "(", "machine", ",", "NULL", ",", "fp", ")", ";", "mame_fclose", "(", "fp", ")", ";", "}", "}", "}" ]
video_save_active_screen_snapshots - save a snapshot of all active screens
[ "video_save_active_screen_snapshots", "-", "save", "a", "snapshot", "of", "all", "active", "screens" ]
[ "/* validate */", "/* if we're native, then write one snapshot per visible screen */", "/* write one snapshot per visible screen */", "/* otherwise, just write a single snapshot */" ]
[ { "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": [] }
17de2ee985ac78e368f6bc4308c0b0a24354d125
lofunz/mieme
Reloaded/tags/MAME4droid 1.6.0 (0.139u1)/src/emu/video.c
[ "Unlicense" ]
C
create_snapshot_bitmap
void
static void create_snapshot_bitmap(device_t *screen) { const render_primitive_list *primlist; INT32 width, height; int view_index; /* select the appropriate view in our dummy target */ if (global.snap_native && screen != NULL) { view_index = screen->machine->m_devicelist.index(SCREEN, screen->tag()); assert(view_index != -1); render_target_set_view(global.snap_target, view_index); } /* get the minimum width/height and set it on the target */ width = global.snap_width; height = global.snap_height; if (width == 0 || height == 0) render_target_get_minimum_size(global.snap_target, &width, &height); render_target_set_bounds(global.snap_target, width, height, 0); /* if we don't have a bitmap, or if it's not the right size, allocate a new one */ if (global.snap_bitmap == NULL || width != global.snap_bitmap->width || height != global.snap_bitmap->height) { if (global.snap_bitmap != NULL) global_free(global.snap_bitmap); global.snap_bitmap = global_alloc(bitmap_t(width, height, BITMAP_FORMAT_RGB32)); assert(global.snap_bitmap != NULL); } /* render the screen there */ primlist = render_target_get_primitives(global.snap_target); osd_lock_acquire(primlist->lock); rgb888_draw_primitives(primlist->head, global.snap_bitmap->base, width, height, global.snap_bitmap->rowpixels); osd_lock_release(primlist->lock); }
/*------------------------------------------------- creare_snapshot_bitmap - creates a bitmap containing the screenshot for the given screen -------------------------------------------------*/
creates a bitmap containing the screenshot for the given screen
[ "creates", "a", "bitmap", "containing", "the", "screenshot", "for", "the", "given", "screen" ]
static void create_snapshot_bitmap(device_t *screen) { const render_primitive_list *primlist; INT32 width, height; int view_index; if (global.snap_native && screen != NULL) { view_index = screen->machine->m_devicelist.index(SCREEN, screen->tag()); assert(view_index != -1); render_target_set_view(global.snap_target, view_index); } width = global.snap_width; height = global.snap_height; if (width == 0 || height == 0) render_target_get_minimum_size(global.snap_target, &width, &height); render_target_set_bounds(global.snap_target, width, height, 0); if (global.snap_bitmap == NULL || width != global.snap_bitmap->width || height != global.snap_bitmap->height) { if (global.snap_bitmap != NULL) global_free(global.snap_bitmap); global.snap_bitmap = global_alloc(bitmap_t(width, height, BITMAP_FORMAT_RGB32)); assert(global.snap_bitmap != NULL); } primlist = render_target_get_primitives(global.snap_target); osd_lock_acquire(primlist->lock); rgb888_draw_primitives(primlist->head, global.snap_bitmap->base, width, height, global.snap_bitmap->rowpixels); osd_lock_release(primlist->lock); }
[ "static", "void", "create_snapshot_bitmap", "(", "device_t", "*", "screen", ")", "{", "const", "render_primitive_list", "*", "primlist", ";", "INT32", "width", ",", "height", ";", "int", "view_index", ";", "if", "(", "global", ".", "snap_native", "&&", "screen", "!=", "NULL", ")", "{", "view_index", "=", "screen", "->", "machine", "->", "m_devicelist", ".", "index", "(", "SCREEN", ",", "screen", "->", "tag", "(", ")", ")", ";", "assert", "(", "view_index", "!=", "-1", ")", ";", "render_target_set_view", "(", "global", ".", "snap_target", ",", "view_index", ")", ";", "}", "width", "=", "global", ".", "snap_width", ";", "height", "=", "global", ".", "snap_height", ";", "if", "(", "width", "==", "0", "||", "height", "==", "0", ")", "render_target_get_minimum_size", "(", "global", ".", "snap_target", ",", "&", "width", ",", "&", "height", ")", ";", "render_target_set_bounds", "(", "global", ".", "snap_target", ",", "width", ",", "height", ",", "0", ")", ";", "if", "(", "global", ".", "snap_bitmap", "==", "NULL", "||", "width", "!=", "global", ".", "snap_bitmap", "->", "width", "||", "height", "!=", "global", ".", "snap_bitmap", "->", "height", ")", "{", "if", "(", "global", ".", "snap_bitmap", "!=", "NULL", ")", "global_free", "(", "global", ".", "snap_bitmap", ")", ";", "global", ".", "snap_bitmap", "=", "global_alloc", "(", "bitmap_t", "(", "width", ",", "height", ",", "BITMAP_FORMAT_RGB32", ")", ")", ";", "assert", "(", "global", ".", "snap_bitmap", "!=", "NULL", ")", ";", "}", "primlist", "=", "render_target_get_primitives", "(", "global", ".", "snap_target", ")", ";", "osd_lock_acquire", "(", "primlist", "->", "lock", ")", ";", "rgb888_draw_primitives", "(", "primlist", "->", "head", ",", "global", ".", "snap_bitmap", "->", "base", ",", "width", ",", "height", ",", "global", ".", "snap_bitmap", "->", "rowpixels", ")", ";", "osd_lock_release", "(", "primlist", "->", "lock", ")", ";", "}" ]
creare_snapshot_bitmap - creates a bitmap containing the screenshot for the given screen
[ "creare_snapshot_bitmap", "-", "creates", "a", "bitmap", "containing", "the", "screenshot", "for", "the", "given", "screen" ]
[ "/* select the appropriate view in our dummy target */", "/* get the minimum width/height and set it on the target */", "/* if we don't have a bitmap, or if it's not the right size, allocate a new one */", "/* render the screen there */" ]
[ { "param": "screen", "type": "device_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "screen", "type": "device_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
17de2ee985ac78e368f6bc4308c0b0a24354d125
lofunz/mieme
Reloaded/tags/MAME4droid 1.6.0 (0.139u1)/src/emu/video.c
[ "Unlicense" ]
C
mame_fopen_next
file_error
static file_error mame_fopen_next(running_machine *machine, const char *pathoption, const char *extension, mame_file **file) { const char *snapname = options_get_string(machine->options(), OPTION_SNAPNAME); file_error filerr; astring snapstr; astring fname; int index; /* handle defaults */ if (snapname == NULL || snapname[0] == 0) snapname = "%g/%i"; snapstr.cpy(snapname); /* strip any extension in the provided name and add our own */ index = snapstr.rchr(0, '.'); if (index != -1) snapstr.substr(0, index); snapstr.cat(".").cat(extension); /* substitute path and gamename up front */ snapstr.replace(0, "/", PATH_SEPARATOR); snapstr.replace(0, "%g", machine->basename()); /* determine if the template has an index; if not, we always use the same name */ if (snapstr.find(0, "%i") == -1) snapstr.cpy(snapstr); /* otherwise, we scan for the next available filename */ else { int seq; /* try until we succeed */ for (seq = 0; ; seq++) { char seqtext[10]; /* make text for the sequence number */ sprintf(seqtext, "%04d", seq); /* build up the filename */ fname.cpy(snapstr).replace(0, "%i", seqtext); /* try to open the file; stop when we fail */ filerr = mame_fopen(pathoption, fname, OPEN_FLAG_READ, file); if (filerr != FILERR_NONE) break; mame_fclose(*file); } } /* create the final file */ return mame_fopen(pathoption, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, file); }
/*------------------------------------------------- mame_fopen_next - open the next non-existing file of type filetype according to our numbering scheme -------------------------------------------------*/
open the next non-existing file of type filetype according to our numbering scheme
[ "open", "the", "next", "non", "-", "existing", "file", "of", "type", "filetype", "according", "to", "our", "numbering", "scheme" ]
static file_error mame_fopen_next(running_machine *machine, const char *pathoption, const char *extension, mame_file **file) { const char *snapname = options_get_string(machine->options(), OPTION_SNAPNAME); file_error filerr; astring snapstr; astring fname; int index; if (snapname == NULL || snapname[0] == 0) snapname = "%g/%i"; snapstr.cpy(snapname); index = snapstr.rchr(0, '.'); if (index != -1) snapstr.substr(0, index); snapstr.cat(".").cat(extension); snapstr.replace(0, "/", PATH_SEPARATOR); snapstr.replace(0, "%g", machine->basename()); if (snapstr.find(0, "%i") == -1) snapstr.cpy(snapstr); else { int seq; for (seq = 0; ; seq++) { char seqtext[10]; sprintf(seqtext, "%04d", seq); fname.cpy(snapstr).replace(0, "%i", seqtext); filerr = mame_fopen(pathoption, fname, OPEN_FLAG_READ, file); if (filerr != FILERR_NONE) break; mame_fclose(*file); } } return mame_fopen(pathoption, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, file); }
[ "static", "file_error", "mame_fopen_next", "(", "running_machine", "*", "machine", ",", "const", "char", "*", "pathoption", ",", "const", "char", "*", "extension", ",", "mame_file", "*", "*", "file", ")", "{", "const", "char", "*", "snapname", "=", "options_get_string", "(", "machine", "->", "options", "(", ")", ",", "OPTION_SNAPNAME", ")", ";", "file_error", "filerr", ";", "astring", "snapstr", ";", "astring", "fname", ";", "int", "index", ";", "if", "(", "snapname", "==", "NULL", "||", "snapname", "[", "0", "]", "==", "0", ")", "snapname", "=", "\"", "\"", ";", "snapstr", ".", "cpy", "(", "snapname", ")", ";", "index", "=", "snapstr", ".", "rchr", "(", "0", ",", "'", "'", ")", ";", "if", "(", "index", "!=", "-1", ")", "snapstr", ".", "substr", "(", "0", ",", "index", ")", ";", "snapstr", ".", "cat", "(", "\"", "\"", ")", ".", "cat", "(", "extension", ")", ";", "snapstr", ".", "replace", "(", "0", ",", "\"", "\"", ",", "PATH_SEPARATOR", ")", ";", "snapstr", ".", "replace", "(", "0", ",", "\"", "\"", ",", "machine", "->", "basename", "(", ")", ")", ";", "if", "(", "snapstr", ".", "find", "(", "0", ",", "\"", "\"", ")", "==", "-1", ")", "snapstr", ".", "cpy", "(", "snapstr", ")", ";", "else", "{", "int", "seq", ";", "for", "(", "seq", "=", "0", ";", ";", "seq", "++", ")", "{", "char", "seqtext", "[", "10", "]", ";", "sprintf", "(", "seqtext", ",", "\"", "\"", ",", "seq", ")", ";", "fname", ".", "cpy", "(", "snapstr", ")", ".", "replace", "(", "0", ",", "\"", "\"", ",", "seqtext", ")", ";", "filerr", "=", "mame_fopen", "(", "pathoption", ",", "fname", ",", "OPEN_FLAG_READ", ",", "file", ")", ";", "if", "(", "filerr", "!=", "FILERR_NONE", ")", "break", ";", "mame_fclose", "(", "*", "file", ")", ";", "}", "}", "return", "mame_fopen", "(", "pathoption", ",", "fname", ",", "OPEN_FLAG_WRITE", "|", "OPEN_FLAG_CREATE", "|", "OPEN_FLAG_CREATE_PATHS", ",", "file", ")", ";", "}" ]
mame_fopen_next - open the next non-existing file of type filetype according to our numbering scheme
[ "mame_fopen_next", "-", "open", "the", "next", "non", "-", "existing", "file", "of", "type", "filetype", "according", "to", "our", "numbering", "scheme" ]
[ "/* handle defaults */", "/* strip any extension in the provided name and add our own */", "/* substitute path and gamename up front */", "/* determine if the template has an index; if not, we always use the same name */", "/* otherwise, we scan for the next available filename */", "/* try until we succeed */", "/* make text for the sequence number */", "/* build up the filename */", "/* try to open the file; stop when we fail */", "/* create the final file */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "pathoption", "type": "char" }, { "param": "extension", "type": "char" }, { "param": "file", "type": "mame_file" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pathoption", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "extension", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "file", "type": "mame_file", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
17de2ee985ac78e368f6bc4308c0b0a24354d125
lofunz/mieme
Reloaded/tags/MAME4droid 1.6.0 (0.139u1)/src/emu/video.c
[ "Unlicense" ]
C
video_mng_end_recording
void
void video_mng_end_recording(running_machine *machine) { /* close the file if it exists */ if (global.mngfile != NULL) { mng_capture_stop(mame_core_file(global.mngfile)); mame_fclose(global.mngfile); global.mngfile = NULL; global.movie_frame = 0; } }
/*------------------------------------------------- video_mng_end_recording - stop recording of a MNG movie -------------------------------------------------*/
stop recording of a MNG movie
[ "stop", "recording", "of", "a", "MNG", "movie" ]
void video_mng_end_recording(running_machine *machine) { if (global.mngfile != NULL) { mng_capture_stop(mame_core_file(global.mngfile)); mame_fclose(global.mngfile); global.mngfile = NULL; global.movie_frame = 0; } }
[ "void", "video_mng_end_recording", "(", "running_machine", "*", "machine", ")", "{", "if", "(", "global", ".", "mngfile", "!=", "NULL", ")", "{", "mng_capture_stop", "(", "mame_core_file", "(", "global", ".", "mngfile", ")", ")", ";", "mame_fclose", "(", "global", ".", "mngfile", ")", ";", "global", ".", "mngfile", "=", "NULL", ";", "global", ".", "movie_frame", "=", "0", ";", "}", "}" ]
video_mng_end_recording - stop recording of a MNG movie
[ "video_mng_end_recording", "-", "stop", "recording", "of", "a", "MNG", "movie" ]
[ "/* close the file if it exists */" ]
[ { "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": [] }
17de2ee985ac78e368f6bc4308c0b0a24354d125
lofunz/mieme
Reloaded/tags/MAME4droid 1.6.0 (0.139u1)/src/emu/video.c
[ "Unlicense" ]
C
video_avi_end_recording
void
void video_avi_end_recording(running_machine *machine) { /* close the file if it exists */ if (global.avifile != NULL) { avi_close(global.avifile); global.avifile = NULL; global.movie_frame = 0; } }
/*------------------------------------------------- video_avi_end_recording - stop recording of a avi movie -------------------------------------------------*/
stop recording of a avi movie
[ "stop", "recording", "of", "a", "avi", "movie" ]
void video_avi_end_recording(running_machine *machine) { if (global.avifile != NULL) { avi_close(global.avifile); global.avifile = NULL; global.movie_frame = 0; } }
[ "void", "video_avi_end_recording", "(", "running_machine", "*", "machine", ")", "{", "if", "(", "global", ".", "avifile", "!=", "NULL", ")", "{", "avi_close", "(", "global", ".", "avifile", ")", ";", "global", ".", "avifile", "=", "NULL", ";", "global", ".", "movie_frame", "=", "0", ";", "}", "}" ]
video_avi_end_recording - stop recording of a avi movie
[ "video_avi_end_recording", "-", "stop", "recording", "of", "a", "avi", "movie" ]
[ "/* close the file if it exists */" ]
[ { "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": [] }
17de2ee985ac78e368f6bc4308c0b0a24354d125
lofunz/mieme
Reloaded/tags/MAME4droid 1.6.0 (0.139u1)/src/emu/video.c
[ "Unlicense" ]
C
video_avi_record_frame
void
static void video_avi_record_frame(running_machine *machine) { /* only record if we have a file */ if (global.avifile != NULL) { attotime curtime = timer_get_time(machine); avi_error avierr; profiler_mark_start(PROFILER_MOVIE_REC); /* create the bitmap */ create_snapshot_bitmap(NULL); /* loop until we hit the right time */ while (attotime_compare(global.movie_next_frame_time, curtime) <= 0) { /* write the next frame */ avierr = avi_append_video_frame_rgb32(global.avifile, global.snap_bitmap); if (avierr != AVIERR_NONE) { video_avi_end_recording(machine); break; } /* advance time */ global.movie_next_frame_time = attotime_add(global.movie_next_frame_time, global.movie_frame_period); global.movie_frame++; } profiler_mark_end(); } }
/*------------------------------------------------- video_avi_record_frame - record a frame of a movie -------------------------------------------------*/
record a frame of a movie
[ "record", "a", "frame", "of", "a", "movie" ]
static void video_avi_record_frame(running_machine *machine) { if (global.avifile != NULL) { attotime curtime = timer_get_time(machine); avi_error avierr; profiler_mark_start(PROFILER_MOVIE_REC); create_snapshot_bitmap(NULL); while (attotime_compare(global.movie_next_frame_time, curtime) <= 0) { avierr = avi_append_video_frame_rgb32(global.avifile, global.snap_bitmap); if (avierr != AVIERR_NONE) { video_avi_end_recording(machine); break; } global.movie_next_frame_time = attotime_add(global.movie_next_frame_time, global.movie_frame_period); global.movie_frame++; } profiler_mark_end(); } }
[ "static", "void", "video_avi_record_frame", "(", "running_machine", "*", "machine", ")", "{", "if", "(", "global", ".", "avifile", "!=", "NULL", ")", "{", "attotime", "curtime", "=", "timer_get_time", "(", "machine", ")", ";", "avi_error", "avierr", ";", "profiler_mark_start", "(", "PROFILER_MOVIE_REC", ")", ";", "create_snapshot_bitmap", "(", "NULL", ")", ";", "while", "(", "attotime_compare", "(", "global", ".", "movie_next_frame_time", ",", "curtime", ")", "<=", "0", ")", "{", "avierr", "=", "avi_append_video_frame_rgb32", "(", "global", ".", "avifile", ",", "global", ".", "snap_bitmap", ")", ";", "if", "(", "avierr", "!=", "AVIERR_NONE", ")", "{", "video_avi_end_recording", "(", "machine", ")", ";", "break", ";", "}", "global", ".", "movie_next_frame_time", "=", "attotime_add", "(", "global", ".", "movie_next_frame_time", ",", "global", ".", "movie_frame_period", ")", ";", "global", ".", "movie_frame", "++", ";", "}", "profiler_mark_end", "(", ")", ";", "}", "}" ]
video_avi_record_frame - record a frame of a movie
[ "video_avi_record_frame", "-", "record", "a", "frame", "of", "a", "movie" ]
[ "/* only record if we have a file */", "/* create the bitmap */", "/* loop until we hit the right time */", "/* write the next frame */", "/* advance time */" ]
[ { "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": [] }
17de2ee985ac78e368f6bc4308c0b0a24354d125
lofunz/mieme
Reloaded/tags/MAME4droid 1.6.0 (0.139u1)/src/emu/video.c
[ "Unlicense" ]
C
video_avi_add_sound
void
void video_avi_add_sound(running_machine *machine, const INT16 *sound, int numsamples) { /* only record if we have a file */ if (global.avifile != NULL) { avi_error avierr; profiler_mark_start(PROFILER_MOVIE_REC); /* write the next frame */ avierr = avi_append_sound_samples(global.avifile, 0, sound + 0, numsamples, 1); if (avierr == AVIERR_NONE) avierr = avi_append_sound_samples(global.avifile, 1, sound + 1, numsamples, 1); if (avierr != AVIERR_NONE) video_avi_end_recording(machine); profiler_mark_end(); } }
/*------------------------------------------------- video_avi_add_sound - add sound to an AVI recording -------------------------------------------------*/
add sound to an AVI recording
[ "add", "sound", "to", "an", "AVI", "recording" ]
void video_avi_add_sound(running_machine *machine, const INT16 *sound, int numsamples) { if (global.avifile != NULL) { avi_error avierr; profiler_mark_start(PROFILER_MOVIE_REC); avierr = avi_append_sound_samples(global.avifile, 0, sound + 0, numsamples, 1); if (avierr == AVIERR_NONE) avierr = avi_append_sound_samples(global.avifile, 1, sound + 1, numsamples, 1); if (avierr != AVIERR_NONE) video_avi_end_recording(machine); profiler_mark_end(); } }
[ "void", "video_avi_add_sound", "(", "running_machine", "*", "machine", ",", "const", "INT16", "*", "sound", ",", "int", "numsamples", ")", "{", "if", "(", "global", ".", "avifile", "!=", "NULL", ")", "{", "avi_error", "avierr", ";", "profiler_mark_start", "(", "PROFILER_MOVIE_REC", ")", ";", "avierr", "=", "avi_append_sound_samples", "(", "global", ".", "avifile", ",", "0", ",", "sound", "+", "0", ",", "numsamples", ",", "1", ")", ";", "if", "(", "avierr", "==", "AVIERR_NONE", ")", "avierr", "=", "avi_append_sound_samples", "(", "global", ".", "avifile", ",", "1", ",", "sound", "+", "1", ",", "numsamples", ",", "1", ")", ";", "if", "(", "avierr", "!=", "AVIERR_NONE", ")", "video_avi_end_recording", "(", "machine", ")", ";", "profiler_mark_end", "(", ")", ";", "}", "}" ]
video_avi_add_sound - add sound to an AVI recording
[ "video_avi_add_sound", "-", "add", "sound", "to", "an", "AVI", "recording" ]
[ "/* only record if we have a file */", "/* write the next frame */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "sound", "type": "INT16" }, { "param": "numsamples", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sound", "type": "INT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "numsamples", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
17de2ee985ac78e368f6bc4308c0b0a24354d125
lofunz/mieme
Reloaded/tags/MAME4droid 1.6.0 (0.139u1)/src/emu/video.c
[ "Unlicense" ]
C
video_get_view_for_target
int
int video_get_view_for_target(running_machine *machine, render_target *target, const char *viewname, int targetindex, int numtargets) { int viewindex = -1; /* auto view just selects the nth view */ if (strcmp(viewname, "auto") != 0) { /* scan for a matching view name */ for (viewindex = 0; ; viewindex++) { const char *name = render_target_get_view_name(target, viewindex); /* stop scanning when we hit NULL */ if (name == NULL) { viewindex = -1; break; } if (mame_strnicmp(name, viewname, strlen(viewname)) == 0) break; } } /* if we don't have a match, default to the nth view */ if (viewindex == -1) { int scrcount = screen_count(*machine->config); /* if we have enough targets to be one per screen, assign in order */ if (numtargets >= scrcount) { /* find the first view with this screen and this screen only */ for (viewindex = 0; ; viewindex++) { UINT32 viewscreens = render_target_get_view_screens(target, viewindex); if (viewscreens == (1 << targetindex)) break; if (viewscreens == 0) { viewindex = -1; break; } } } /* otherwise, find the first view that has all the screens */ if (viewindex == -1) { for (viewindex = 0; ; viewindex++) { UINT32 viewscreens = render_target_get_view_screens(target, viewindex); if (viewscreens == (1 << scrcount) - 1) break; if (viewscreens == 0) break; } } } /* make sure it's a valid view */ if (render_target_get_view_name(target, viewindex) == NULL) viewindex = 0; return viewindex; }
/*------------------------------------------------- video_get_view_for_target - select a view for a given target -------------------------------------------------*/
select a view for a given target
[ "select", "a", "view", "for", "a", "given", "target" ]
int video_get_view_for_target(running_machine *machine, render_target *target, const char *viewname, int targetindex, int numtargets) { int viewindex = -1; if (strcmp(viewname, "auto") != 0) { for (viewindex = 0; ; viewindex++) { const char *name = render_target_get_view_name(target, viewindex); if (name == NULL) { viewindex = -1; break; } if (mame_strnicmp(name, viewname, strlen(viewname)) == 0) break; } } if (viewindex == -1) { int scrcount = screen_count(*machine->config); if (numtargets >= scrcount) { for (viewindex = 0; ; viewindex++) { UINT32 viewscreens = render_target_get_view_screens(target, viewindex); if (viewscreens == (1 << targetindex)) break; if (viewscreens == 0) { viewindex = -1; break; } } } if (viewindex == -1) { for (viewindex = 0; ; viewindex++) { UINT32 viewscreens = render_target_get_view_screens(target, viewindex); if (viewscreens == (1 << scrcount) - 1) break; if (viewscreens == 0) break; } } } if (render_target_get_view_name(target, viewindex) == NULL) viewindex = 0; return viewindex; }
[ "int", "video_get_view_for_target", "(", "running_machine", "*", "machine", ",", "render_target", "*", "target", ",", "const", "char", "*", "viewname", ",", "int", "targetindex", ",", "int", "numtargets", ")", "{", "int", "viewindex", "=", "-1", ";", "if", "(", "strcmp", "(", "viewname", ",", "\"", "\"", ")", "!=", "0", ")", "{", "for", "(", "viewindex", "=", "0", ";", ";", "viewindex", "++", ")", "{", "const", "char", "*", "name", "=", "render_target_get_view_name", "(", "target", ",", "viewindex", ")", ";", "if", "(", "name", "==", "NULL", ")", "{", "viewindex", "=", "-1", ";", "break", ";", "}", "if", "(", "mame_strnicmp", "(", "name", ",", "viewname", ",", "strlen", "(", "viewname", ")", ")", "==", "0", ")", "break", ";", "}", "}", "if", "(", "viewindex", "==", "-1", ")", "{", "int", "scrcount", "=", "screen_count", "(", "*", "machine", "->", "config", ")", ";", "if", "(", "numtargets", ">=", "scrcount", ")", "{", "for", "(", "viewindex", "=", "0", ";", ";", "viewindex", "++", ")", "{", "UINT32", "viewscreens", "=", "render_target_get_view_screens", "(", "target", ",", "viewindex", ")", ";", "if", "(", "viewscreens", "==", "(", "1", "<<", "targetindex", ")", ")", "break", ";", "if", "(", "viewscreens", "==", "0", ")", "{", "viewindex", "=", "-1", ";", "break", ";", "}", "}", "}", "if", "(", "viewindex", "==", "-1", ")", "{", "for", "(", "viewindex", "=", "0", ";", ";", "viewindex", "++", ")", "{", "UINT32", "viewscreens", "=", "render_target_get_view_screens", "(", "target", ",", "viewindex", ")", ";", "if", "(", "viewscreens", "==", "(", "1", "<<", "scrcount", ")", "-", "1", ")", "break", ";", "if", "(", "viewscreens", "==", "0", ")", "break", ";", "}", "}", "}", "if", "(", "render_target_get_view_name", "(", "target", ",", "viewindex", ")", "==", "NULL", ")", "viewindex", "=", "0", ";", "return", "viewindex", ";", "}" ]
video_get_view_for_target - select a view for a given target
[ "video_get_view_for_target", "-", "select", "a", "view", "for", "a", "given", "target" ]
[ "/* auto view just selects the nth view */", "/* scan for a matching view name */", "/* stop scanning when we hit NULL */", "/* if we don't have a match, default to the nth view */", "/* if we have enough targets to be one per screen, assign in order */", "/* find the first view with this screen and this screen only */", "/* otherwise, find the first view that has all the screens */", "/* make sure it's a valid view */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "target", "type": "render_target" }, { "param": "viewname", "type": "char" }, { "param": "targetindex", "type": "int" }, { "param": "numtargets", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "target", "type": "render_target", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "viewname", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "targetindex", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "numtargets", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
17de2ee985ac78e368f6bc4308c0b0a24354d125
lofunz/mieme
Reloaded/tags/MAME4droid 1.6.0 (0.139u1)/src/emu/video.c
[ "Unlicense" ]
C
video_assert_out_of_range_pixels
void
void video_assert_out_of_range_pixels(running_machine *machine, bitmap_t *bitmap) { #ifdef MAME_DEBUG int maxindex = palette_get_max_index(machine->palette); int x, y; /* this only applies to indexed16 bitmaps */ if (bitmap->format != BITMAP_FORMAT_INDEXED16) return; /* iterate over rows */ for (y = 0; y < bitmap->height; y++) { UINT16 *rowbase = BITMAP_ADDR16(bitmap, y, 0); for (x = 0; x < bitmap->width; x++) assert(rowbase[x] < maxindex); } #endif }
/*------------------------------------------------- video_assert_out_of_range_pixels - assert if any pixels in the given bitmap contain an invalid palette index -------------------------------------------------*/
assert if any pixels in the given bitmap contain an invalid palette index
[ "assert", "if", "any", "pixels", "in", "the", "given", "bitmap", "contain", "an", "invalid", "palette", "index" ]
void video_assert_out_of_range_pixels(running_machine *machine, bitmap_t *bitmap) { #ifdef MAME_DEBUG int maxindex = palette_get_max_index(machine->palette); int x, y; if (bitmap->format != BITMAP_FORMAT_INDEXED16) return; for (y = 0; y < bitmap->height; y++) { UINT16 *rowbase = BITMAP_ADDR16(bitmap, y, 0); for (x = 0; x < bitmap->width; x++) assert(rowbase[x] < maxindex); } #endif }
[ "void", "video_assert_out_of_range_pixels", "(", "running_machine", "*", "machine", ",", "bitmap_t", "*", "bitmap", ")", "{", "#ifdef", "MAME_DEBUG", "int", "maxindex", "=", "palette_get_max_index", "(", "machine", "->", "palette", ")", ";", "int", "x", ",", "y", ";", "if", "(", "bitmap", "->", "format", "!=", "BITMAP_FORMAT_INDEXED16", ")", "return", ";", "for", "(", "y", "=", "0", ";", "y", "<", "bitmap", "->", "height", ";", "y", "++", ")", "{", "UINT16", "*", "rowbase", "=", "BITMAP_ADDR16", "(", "bitmap", ",", "y", ",", "0", ")", ";", "for", "(", "x", "=", "0", ";", "x", "<", "bitmap", "->", "width", ";", "x", "++", ")", "assert", "(", "rowbase", "[", "x", "]", "<", "maxindex", ")", ";", "}", "#endif", "}" ]
video_assert_out_of_range_pixels - assert if any pixels in the given bitmap contain an invalid palette index
[ "video_assert_out_of_range_pixels", "-", "assert", "if", "any", "pixels", "in", "the", "given", "bitmap", "contain", "an", "invalid", "palette", "index" ]
[ "/* this only applies to indexed16 bitmaps */", "/* iterate over rows */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "bitmap", "type": "bitmap_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bitmap", "type": "bitmap_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6c81fb7bc2615e707b368a3473ed3e5a5bbc45df
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/tms32010/tms32010.c
[ "Unlicense" ]
C
add_sh
void
static void add_sh(tms32010_state *cpustate) { cpustate->oldacc.d = cpustate->ACC.d; getdata(cpustate, (cpustate->opcode.b.h & 0xf),1); cpustate->ACC.d += cpustate->ALU.d; CALCULATE_ADD_OVERFLOW(cpustate, cpustate->ALU.d); }
/*** The manual doesn't mention overflow with the ADD? instructions however *** *** overflow is implemented here, because it makes little sense otherwise **** *** while newer generations of this type of chip supported it. The *********** *** manual may be wrong wrong (apart from other errors the manual has). ****** static void add_sh(cpustate) { getdata(cpustate, cpustate->opcode.b.h,1); cpustate->ACC.d += cpustate->ALU.d; } static void addh(cpustate) { getdata(cpustate, 0,0); cpustate->ACC.d += (cpustate->ALU.d << 16); } ***/
The manual doesn't mention overflow with the ADD. instructions however overflow is implemented here, because it makes little sense otherwise while newer generations of this type of chip supported it. The manual may be wrong wrong (apart from other errors the manual has).
[ "The", "manual", "doesn", "'", "t", "mention", "overflow", "with", "the", "ADD", ".", "instructions", "however", "overflow", "is", "implemented", "here", "because", "it", "makes", "little", "sense", "otherwise", "while", "newer", "generations", "of", "this", "type", "of", "chip", "supported", "it", ".", "The", "manual", "may", "be", "wrong", "wrong", "(", "apart", "from", "other", "errors", "the", "manual", "has", ")", "." ]
static void add_sh(tms32010_state *cpustate) { cpustate->oldacc.d = cpustate->ACC.d; getdata(cpustate, (cpustate->opcode.b.h & 0xf),1); cpustate->ACC.d += cpustate->ALU.d; CALCULATE_ADD_OVERFLOW(cpustate, cpustate->ALU.d); }
[ "static", "void", "add_sh", "(", "tms32010_state", "*", "cpustate", ")", "{", "cpustate", "->", "oldacc", ".", "d", "=", "cpustate", "->", "ACC", ".", "d", ";", "getdata", "(", "cpustate", ",", "(", "cpustate", "->", "opcode", ".", "b", ".", "h", "&", "0xf", ")", ",", "1", ")", ";", "cpustate", "->", "ACC", ".", "d", "+=", "cpustate", "->", "ALU", ".", "d", ";", "CALCULATE_ADD_OVERFLOW", "(", "cpustate", ",", "cpustate", "->", "ALU", ".", "d", ")", ";", "}" ]
The manual doesn't mention overflow with the ADD?
[ "The", "manual", "doesn", "'", "t", "mention", "overflow", "with", "the", "ADD?" ]
[]
[ { "param": "cpustate", "type": "tms32010_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cpustate", "type": "tms32010_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6c4cc14d3b372a0ea4f950d034b9311217f4c3f4
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/ldverify.c
[ "Unlicense" ]
C
open_avi
void
static void *open_avi(const char *filename, movie_info *info) { const avi_movie_info *aviinfo; avi_error avierr; avi_file *avi; /* open the file */ avierr = avi_open(filename, &avi); if (avierr != AVIERR_NONE) { fprintf(stderr, "Error opening AVI file: %s\n", avi_error_string(avierr)); return NULL; } /* extract movie info */ aviinfo = avi_get_movie_info(avi); info->framerate = (double)aviinfo->video_timescale / (double)aviinfo->video_sampletime; info->numframes = aviinfo->video_numsamples; info->width = aviinfo->video_width; info->height = aviinfo->video_height; info->samplerate = aviinfo->audio_samplerate; info->channels = aviinfo->audio_channels; return avi; }
/*------------------------------------------------- open_avi - open an AVI file and return information about it -------------------------------------------------*/
open an AVI file and return information about it
[ "open", "an", "AVI", "file", "and", "return", "information", "about", "it" ]
static void *open_avi(const char *filename, movie_info *info) { const avi_movie_info *aviinfo; avi_error avierr; avi_file *avi; avierr = avi_open(filename, &avi); if (avierr != AVIERR_NONE) { fprintf(stderr, "Error opening AVI file: %s\n", avi_error_string(avierr)); return NULL; } aviinfo = avi_get_movie_info(avi); info->framerate = (double)aviinfo->video_timescale / (double)aviinfo->video_sampletime; info->numframes = aviinfo->video_numsamples; info->width = aviinfo->video_width; info->height = aviinfo->video_height; info->samplerate = aviinfo->audio_samplerate; info->channels = aviinfo->audio_channels; return avi; }
[ "static", "void", "*", "open_avi", "(", "const", "char", "*", "filename", ",", "movie_info", "*", "info", ")", "{", "const", "avi_movie_info", "*", "aviinfo", ";", "avi_error", "avierr", ";", "avi_file", "*", "avi", ";", "avierr", "=", "avi_open", "(", "filename", ",", "&", "avi", ")", ";", "if", "(", "avierr", "!=", "AVIERR_NONE", ")", "{", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "avi_error_string", "(", "avierr", ")", ")", ";", "return", "NULL", ";", "}", "aviinfo", "=", "avi_get_movie_info", "(", "avi", ")", ";", "info", "->", "framerate", "=", "(", "double", ")", "aviinfo", "->", "video_timescale", "/", "(", "double", ")", "aviinfo", "->", "video_sampletime", ";", "info", "->", "numframes", "=", "aviinfo", "->", "video_numsamples", ";", "info", "->", "width", "=", "aviinfo", "->", "video_width", ";", "info", "->", "height", "=", "aviinfo", "->", "video_height", ";", "info", "->", "samplerate", "=", "aviinfo", "->", "audio_samplerate", ";", "info", "->", "channels", "=", "aviinfo", "->", "audio_channels", ";", "return", "avi", ";", "}" ]
open_avi - open an AVI file and return information about it
[ "open_avi", "-", "open", "an", "AVI", "file", "and", "return", "information", "about", "it" ]
[ "/* open the file */", "/* extract movie info */" ]
[ { "param": "filename", "type": "char" }, { "param": "info", "type": "movie_info" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "filename", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "info", "type": "movie_info", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6c4cc14d3b372a0ea4f950d034b9311217f4c3f4
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/ldverify.c
[ "Unlicense" ]
C
read_avi
int
static int read_avi(void *file, int frame, bitmap_t *bitmap, INT16 *lsound, INT16 *rsound, int *samples) { const avi_movie_info *aviinfo = avi_get_movie_info((avi_file *)file); UINT32 firstsample = ((UINT64)aviinfo->audio_samplerate * (UINT64)frame * (UINT64)aviinfo->video_sampletime + aviinfo->video_timescale - 1) / (UINT64)aviinfo->video_timescale; UINT32 lastsample = ((UINT64)aviinfo->audio_samplerate * (UINT64)(frame + 1) * (UINT64)aviinfo->video_sampletime + aviinfo->video_timescale - 1) / (UINT64)aviinfo->video_timescale; avi_error avierr; /* read the frame */ avierr = avi_read_video_frame_yuy16((avi_file *)file, frame, bitmap); if (avierr != AVIERR_NONE) return FALSE; /* read the samples */ avierr = avi_read_sound_samples((avi_file *)file, 0, firstsample, lastsample - firstsample, lsound); avierr = avi_read_sound_samples((avi_file *)file, 1, firstsample, lastsample - firstsample, rsound); if (avierr != AVIERR_NONE) return FALSE; *samples = lastsample - firstsample; return TRUE; }
/*------------------------------------------------- read_avi - read a frame from an AVI file -------------------------------------------------*/
read a frame from an AVI file
[ "read", "a", "frame", "from", "an", "AVI", "file" ]
static int read_avi(void *file, int frame, bitmap_t *bitmap, INT16 *lsound, INT16 *rsound, int *samples) { const avi_movie_info *aviinfo = avi_get_movie_info((avi_file *)file); UINT32 firstsample = ((UINT64)aviinfo->audio_samplerate * (UINT64)frame * (UINT64)aviinfo->video_sampletime + aviinfo->video_timescale - 1) / (UINT64)aviinfo->video_timescale; UINT32 lastsample = ((UINT64)aviinfo->audio_samplerate * (UINT64)(frame + 1) * (UINT64)aviinfo->video_sampletime + aviinfo->video_timescale - 1) / (UINT64)aviinfo->video_timescale; avi_error avierr; avierr = avi_read_video_frame_yuy16((avi_file *)file, frame, bitmap); if (avierr != AVIERR_NONE) return FALSE; avierr = avi_read_sound_samples((avi_file *)file, 0, firstsample, lastsample - firstsample, lsound); avierr = avi_read_sound_samples((avi_file *)file, 1, firstsample, lastsample - firstsample, rsound); if (avierr != AVIERR_NONE) return FALSE; *samples = lastsample - firstsample; return TRUE; }
[ "static", "int", "read_avi", "(", "void", "*", "file", ",", "int", "frame", ",", "bitmap_t", "*", "bitmap", ",", "INT16", "*", "lsound", ",", "INT16", "*", "rsound", ",", "int", "*", "samples", ")", "{", "const", "avi_movie_info", "*", "aviinfo", "=", "avi_get_movie_info", "(", "(", "avi_file", "*", ")", "file", ")", ";", "UINT32", "firstsample", "=", "(", "(", "UINT64", ")", "aviinfo", "->", "audio_samplerate", "*", "(", "UINT64", ")", "frame", "*", "(", "UINT64", ")", "aviinfo", "->", "video_sampletime", "+", "aviinfo", "->", "video_timescale", "-", "1", ")", "/", "(", "UINT64", ")", "aviinfo", "->", "video_timescale", ";", "UINT32", "lastsample", "=", "(", "(", "UINT64", ")", "aviinfo", "->", "audio_samplerate", "*", "(", "UINT64", ")", "(", "frame", "+", "1", ")", "*", "(", "UINT64", ")", "aviinfo", "->", "video_sampletime", "+", "aviinfo", "->", "video_timescale", "-", "1", ")", "/", "(", "UINT64", ")", "aviinfo", "->", "video_timescale", ";", "avi_error", "avierr", ";", "avierr", "=", "avi_read_video_frame_yuy16", "(", "(", "avi_file", "*", ")", "file", ",", "frame", ",", "bitmap", ")", ";", "if", "(", "avierr", "!=", "AVIERR_NONE", ")", "return", "FALSE", ";", "avierr", "=", "avi_read_sound_samples", "(", "(", "avi_file", "*", ")", "file", ",", "0", ",", "firstsample", ",", "lastsample", "-", "firstsample", ",", "lsound", ")", ";", "avierr", "=", "avi_read_sound_samples", "(", "(", "avi_file", "*", ")", "file", ",", "1", ",", "firstsample", ",", "lastsample", "-", "firstsample", ",", "rsound", ")", ";", "if", "(", "avierr", "!=", "AVIERR_NONE", ")", "return", "FALSE", ";", "*", "samples", "=", "lastsample", "-", "firstsample", ";", "return", "TRUE", ";", "}" ]
read_avi - read a frame from an AVI file
[ "read_avi", "-", "read", "a", "frame", "from", "an", "AVI", "file" ]
[ "/* read the frame */", "/* read the samples */" ]
[ { "param": "file", "type": "void" }, { "param": "frame", "type": "int" }, { "param": "bitmap", "type": "bitmap_t" }, { "param": "lsound", "type": "INT16" }, { "param": "rsound", "type": "INT16" }, { "param": "samples", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "file", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "frame", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bitmap", "type": "bitmap_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lsound", "type": "INT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rsound", "type": "INT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "samples", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6c4cc14d3b372a0ea4f950d034b9311217f4c3f4
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/ldverify.c
[ "Unlicense" ]
C
open_chd
void
static void *open_chd(const char *filename, movie_info *info) { int fps, fpsfrac, width, height, interlaced, channels, rate; char metadata[256]; chd_error chderr; chd_file *chd; /* open the file */ chderr = chd_open(filename, CHD_OPEN_READ, NULL, &chd); if (chderr != CHDERR_NONE) { fprintf(stderr, "Error opening CHD file: %s\n", chd_error_string(chderr)); return NULL; } /* get the metadata */ chderr = chd_get_metadata(chd, AV_METADATA_TAG, 0, metadata, sizeof(metadata), NULL, NULL, NULL); if (chderr != CHDERR_NONE) { fprintf(stderr, "Error getting A/V metadata: %s\n", chd_error_string(chderr)); chd_close(chd); return NULL; } /* extract the info */ if (sscanf(metadata, AV_METADATA_FORMAT, &fps, &fpsfrac, &width, &height, &interlaced, &channels, &rate) != 7) { fprintf(stderr, "Improperly formatted metadata\n"); chd_close(chd); return NULL; } /* extract movie info */ info->framerate = (fps * 1000000 + fpsfrac) / 1000000.0; info->numframes = chd_get_header(chd)->totalhunks; info->width = width; info->height = height; info->samplerate = rate; info->channels = channels; /* convert to an interlaced frame */ chdinterlaced = interlaced; if (interlaced) { info->framerate /= 2; info->numframes = (info->numframes + 1) / 2; info->height *= 2; } return chd; }
/*------------------------------------------------- open_chd - open a CHD file and return information about it -------------------------------------------------*/
open a CHD file and return information about it
[ "open", "a", "CHD", "file", "and", "return", "information", "about", "it" ]
static void *open_chd(const char *filename, movie_info *info) { int fps, fpsfrac, width, height, interlaced, channels, rate; char metadata[256]; chd_error chderr; chd_file *chd; chderr = chd_open(filename, CHD_OPEN_READ, NULL, &chd); if (chderr != CHDERR_NONE) { fprintf(stderr, "Error opening CHD file: %s\n", chd_error_string(chderr)); return NULL; } chderr = chd_get_metadata(chd, AV_METADATA_TAG, 0, metadata, sizeof(metadata), NULL, NULL, NULL); if (chderr != CHDERR_NONE) { fprintf(stderr, "Error getting A/V metadata: %s\n", chd_error_string(chderr)); chd_close(chd); return NULL; } if (sscanf(metadata, AV_METADATA_FORMAT, &fps, &fpsfrac, &width, &height, &interlaced, &channels, &rate) != 7) { fprintf(stderr, "Improperly formatted metadata\n"); chd_close(chd); return NULL; } info->framerate = (fps * 1000000 + fpsfrac) / 1000000.0; info->numframes = chd_get_header(chd)->totalhunks; info->width = width; info->height = height; info->samplerate = rate; info->channels = channels; chdinterlaced = interlaced; if (interlaced) { info->framerate /= 2; info->numframes = (info->numframes + 1) / 2; info->height *= 2; } return chd; }
[ "static", "void", "*", "open_chd", "(", "const", "char", "*", "filename", ",", "movie_info", "*", "info", ")", "{", "int", "fps", ",", "fpsfrac", ",", "width", ",", "height", ",", "interlaced", ",", "channels", ",", "rate", ";", "char", "metadata", "[", "256", "]", ";", "chd_error", "chderr", ";", "chd_file", "*", "chd", ";", "chderr", "=", "chd_open", "(", "filename", ",", "CHD_OPEN_READ", ",", "NULL", ",", "&", "chd", ")", ";", "if", "(", "chderr", "!=", "CHDERR_NONE", ")", "{", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "chd_error_string", "(", "chderr", ")", ")", ";", "return", "NULL", ";", "}", "chderr", "=", "chd_get_metadata", "(", "chd", ",", "AV_METADATA_TAG", ",", "0", ",", "metadata", ",", "sizeof", "(", "metadata", ")", ",", "NULL", ",", "NULL", ",", "NULL", ")", ";", "if", "(", "chderr", "!=", "CHDERR_NONE", ")", "{", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "chd_error_string", "(", "chderr", ")", ")", ";", "chd_close", "(", "chd", ")", ";", "return", "NULL", ";", "}", "if", "(", "sscanf", "(", "metadata", ",", "AV_METADATA_FORMAT", ",", "&", "fps", ",", "&", "fpsfrac", ",", "&", "width", ",", "&", "height", ",", "&", "interlaced", ",", "&", "channels", ",", "&", "rate", ")", "!=", "7", ")", "{", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ")", ";", "chd_close", "(", "chd", ")", ";", "return", "NULL", ";", "}", "info", "->", "framerate", "=", "(", "fps", "*", "1000000", "+", "fpsfrac", ")", "/", "1000000.0", ";", "info", "->", "numframes", "=", "chd_get_header", "(", "chd", ")", "->", "totalhunks", ";", "info", "->", "width", "=", "width", ";", "info", "->", "height", "=", "height", ";", "info", "->", "samplerate", "=", "rate", ";", "info", "->", "channels", "=", "channels", ";", "chdinterlaced", "=", "interlaced", ";", "if", "(", "interlaced", ")", "{", "info", "->", "framerate", "/=", "2", ";", "info", "->", "numframes", "=", "(", "info", "->", "numframes", "+", "1", ")", "/", "2", ";", "info", "->", "height", "*=", "2", ";", "}", "return", "chd", ";", "}" ]
open_chd - open a CHD file and return information about it
[ "open_chd", "-", "open", "a", "CHD", "file", "and", "return", "information", "about", "it" ]
[ "/* open the file */", "/* get the metadata */", "/* extract the info */", "/* extract movie info */", "/* convert to an interlaced frame */" ]
[ { "param": "filename", "type": "char" }, { "param": "info", "type": "movie_info" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "filename", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "info", "type": "movie_info", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6c4cc14d3b372a0ea4f950d034b9311217f4c3f4
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/ldverify.c
[ "Unlicense" ]
C
read_chd
int
static int read_chd(void *file, int frame, bitmap_t *bitmap, INT16 *lsound, INT16 *rsound, int *samples) { av_codec_decompress_config avconfig = { 0 }; int interlace_factor = chdinterlaced ? 2 : 1; bitmap_t fakebitmap; UINT32 numsamples; chd_error chderr; int fieldnum; /* loop over fields */ *samples = 0; for (fieldnum = 0; fieldnum < interlace_factor; fieldnum++) { /* make a fake bitmap for this field */ fakebitmap = *bitmap; fakebitmap.base = BITMAP_ADDR16(&fakebitmap, fieldnum, 0); fakebitmap.rowpixels *= interlace_factor; fakebitmap.height /= interlace_factor; /* configure the codec */ avconfig.video = &fakebitmap; avconfig.maxsamples = 48000; avconfig.actsamples = &numsamples; avconfig.audio[0] = &lsound[*samples]; avconfig.audio[1] = &rsound[*samples]; /* configure the decompressor for this frame */ chd_codec_config((chd_file *)file, AV_CODEC_DECOMPRESS_CONFIG, &avconfig); /* read the frame */ chderr = chd_read((chd_file *)file, frame * interlace_factor + fieldnum, NULL); if (chderr != CHDERR_NONE) return FALSE; /* account for samples read */ *samples += numsamples; } return TRUE; }
/*------------------------------------------------- read_chd - read a frame from a CHD file -------------------------------------------------*/
read a frame from a CHD file
[ "read", "a", "frame", "from", "a", "CHD", "file" ]
static int read_chd(void *file, int frame, bitmap_t *bitmap, INT16 *lsound, INT16 *rsound, int *samples) { av_codec_decompress_config avconfig = { 0 }; int interlace_factor = chdinterlaced ? 2 : 1; bitmap_t fakebitmap; UINT32 numsamples; chd_error chderr; int fieldnum; *samples = 0; for (fieldnum = 0; fieldnum < interlace_factor; fieldnum++) { fakebitmap = *bitmap; fakebitmap.base = BITMAP_ADDR16(&fakebitmap, fieldnum, 0); fakebitmap.rowpixels *= interlace_factor; fakebitmap.height /= interlace_factor; avconfig.video = &fakebitmap; avconfig.maxsamples = 48000; avconfig.actsamples = &numsamples; avconfig.audio[0] = &lsound[*samples]; avconfig.audio[1] = &rsound[*samples]; chd_codec_config((chd_file *)file, AV_CODEC_DECOMPRESS_CONFIG, &avconfig); chderr = chd_read((chd_file *)file, frame * interlace_factor + fieldnum, NULL); if (chderr != CHDERR_NONE) return FALSE; *samples += numsamples; } return TRUE; }
[ "static", "int", "read_chd", "(", "void", "*", "file", ",", "int", "frame", ",", "bitmap_t", "*", "bitmap", ",", "INT16", "*", "lsound", ",", "INT16", "*", "rsound", ",", "int", "*", "samples", ")", "{", "av_codec_decompress_config", "avconfig", "=", "{", "0", "}", ";", "int", "interlace_factor", "=", "chdinterlaced", "?", "2", ":", "1", ";", "bitmap_t", "fakebitmap", ";", "UINT32", "numsamples", ";", "chd_error", "chderr", ";", "int", "fieldnum", ";", "*", "samples", "=", "0", ";", "for", "(", "fieldnum", "=", "0", ";", "fieldnum", "<", "interlace_factor", ";", "fieldnum", "++", ")", "{", "fakebitmap", "=", "*", "bitmap", ";", "fakebitmap", ".", "base", "=", "BITMAP_ADDR16", "(", "&", "fakebitmap", ",", "fieldnum", ",", "0", ")", ";", "fakebitmap", ".", "rowpixels", "*=", "interlace_factor", ";", "fakebitmap", ".", "height", "/=", "interlace_factor", ";", "avconfig", ".", "video", "=", "&", "fakebitmap", ";", "avconfig", ".", "maxsamples", "=", "48000", ";", "avconfig", ".", "actsamples", "=", "&", "numsamples", ";", "avconfig", ".", "audio", "[", "0", "]", "=", "&", "lsound", "[", "*", "samples", "]", ";", "avconfig", ".", "audio", "[", "1", "]", "=", "&", "rsound", "[", "*", "samples", "]", ";", "chd_codec_config", "(", "(", "chd_file", "*", ")", "file", ",", "AV_CODEC_DECOMPRESS_CONFIG", ",", "&", "avconfig", ")", ";", "chderr", "=", "chd_read", "(", "(", "chd_file", "*", ")", "file", ",", "frame", "*", "interlace_factor", "+", "fieldnum", ",", "NULL", ")", ";", "if", "(", "chderr", "!=", "CHDERR_NONE", ")", "return", "FALSE", ";", "*", "samples", "+=", "numsamples", ";", "}", "return", "TRUE", ";", "}" ]
read_chd - read a frame from a CHD file
[ "read_chd", "-", "read", "a", "frame", "from", "a", "CHD", "file" ]
[ "/* loop over fields */", "/* make a fake bitmap for this field */", "/* configure the codec */", "/* configure the decompressor for this frame */", "/* read the frame */", "/* account for samples read */" ]
[ { "param": "file", "type": "void" }, { "param": "frame", "type": "int" }, { "param": "bitmap", "type": "bitmap_t" }, { "param": "lsound", "type": "INT16" }, { "param": "rsound", "type": "INT16" }, { "param": "samples", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "file", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "frame", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bitmap", "type": "bitmap_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lsound", "type": "INT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rsound", "type": "INT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "samples", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2a05d01541c752e0191cb4c4415a40e7295eba90
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/arm7/arm7core.c
[ "Unlicense" ]
C
arm7_check_irq_state
void
static void arm7_check_irq_state(arm_state *cpustate) { UINT32 cpsr = GET_CPSR; /* save current CPSR */ UINT32 pc = R15 + 4; /* save old pc (already incremented in pipeline) */; /* Exception priorities: Reset Data abort FIRQ IRQ Prefetch abort Undefined instruction Software Interrupt */ // Data Abort if (cpustate->pendingAbtD) { SwitchMode(cpustate, eARM7_MODE_ABT); /* Set ABT mode so PC is saved to correct R14 bank */ SET_REGISTER(cpustate, 14, pc); /* save PC to R14 */ SET_REGISTER(cpustate, SPSR, cpsr); /* Save current CPSR */ SET_CPSR(GET_CPSR | I_MASK); /* Mask IRQ */ SET_CPSR(GET_CPSR & ~T_MASK); R15 = 0x10; /* IRQ Vector address */ cpustate->pendingAbtD = 0; return; } // FIQ if (cpustate->pendingFiq && (cpsr & F_MASK) == 0) { SwitchMode(cpustate, eARM7_MODE_FIQ); /* Set FIQ mode so PC is saved to correct R14 bank */ SET_REGISTER(cpustate, 14, pc); /* save PC to R14 */ SET_REGISTER(cpustate, SPSR, cpsr); /* Save current CPSR */ SET_CPSR(GET_CPSR | I_MASK | F_MASK); /* Mask both IRQ & FIQ */ SET_CPSR(GET_CPSR & ~T_MASK); R15 = 0x1c; /* IRQ Vector address */ return; } // IRQ if (cpustate->pendingIrq && (cpsr & I_MASK) == 0) { SwitchMode(cpustate, eARM7_MODE_IRQ); /* Set IRQ mode so PC is saved to correct R14 bank */ SET_REGISTER(cpustate, 14, pc); /* save PC to R14 */ SET_REGISTER(cpustate, SPSR, cpsr); /* Save current CPSR */ SET_CPSR(GET_CPSR | I_MASK); /* Mask IRQ */ SET_CPSR(GET_CPSR & ~T_MASK); R15 = 0x18; /* IRQ Vector address */ return; } // Prefetch Abort if (cpustate->pendingAbtP) { SwitchMode(cpustate, eARM7_MODE_ABT); /* Set ABT mode so PC is saved to correct R14 bank */ SET_REGISTER(cpustate, 14, pc); /* save PC to R14 */ SET_REGISTER(cpustate, SPSR, cpsr); /* Save current CPSR */ SET_CPSR(GET_CPSR | I_MASK); /* Mask IRQ */ SET_CPSR(GET_CPSR & ~T_MASK); R15 = 0x0c; /* IRQ Vector address */ cpustate->pendingAbtP = 0; return; } // Undefined instruction if (cpustate->pendingUnd) { SwitchMode(cpustate, eARM7_MODE_UND); /* Set UND mode so PC is saved to correct R14 bank */ SET_REGISTER(cpustate, 14, pc); /* save PC to R14 */ SET_REGISTER(cpustate, SPSR, cpsr); /* Save current CPSR */ SET_CPSR(GET_CPSR | I_MASK); /* Mask IRQ */ SET_CPSR(GET_CPSR & ~T_MASK); R15 = 0x04; /* IRQ Vector address */ cpustate->pendingUnd = 0; return; } // Software Interrupt if (cpustate->pendingSwi) { SwitchMode(cpustate, eARM7_MODE_SVC); /* Set SVC mode so PC is saved to correct R14 bank */ // compensate for prefetch (should this also be done for normal IRQ?) if (T_IS_SET(GET_CPSR)) { SET_REGISTER(cpustate, 14, pc-2); /* save PC to R14 */ } else { SET_REGISTER(cpustate, 14, pc); /* save PC to R14 */ } SET_REGISTER(cpustate, SPSR, cpsr); /* Save current CPSR */ SET_CPSR(GET_CPSR | I_MASK); /* Mask IRQ */ SET_CPSR(GET_CPSR & ~T_MASK); /* Go to ARM mode */ R15 = 0x08; /* Jump to the SWI vector */ cpustate->pendingSwi = 0; return; } }
// CPU CHECK IRQ STATE // Note: couldn't find any exact cycle counts for most of these exceptions
CPU CHECK IRQ STATE Note: couldn't find any exact cycle counts for most of these exceptions
[ "CPU", "CHECK", "IRQ", "STATE", "Note", ":", "couldn", "'", "t", "find", "any", "exact", "cycle", "counts", "for", "most", "of", "these", "exceptions" ]
static void arm7_check_irq_state(arm_state *cpustate) { UINT32 cpsr = GET_CPSR; UINT32 pc = R15 + 4; ; if (cpustate->pendingAbtD) { SwitchMode(cpustate, eARM7_MODE_ABT); SET_REGISTER(cpustate, 14, pc); SET_REGISTER(cpustate, SPSR, cpsr); SET_CPSR(GET_CPSR | I_MASK); SET_CPSR(GET_CPSR & ~T_MASK); R15 = 0x10; cpustate->pendingAbtD = 0; return; } if (cpustate->pendingFiq && (cpsr & F_MASK) == 0) { SwitchMode(cpustate, eARM7_MODE_FIQ); SET_REGISTER(cpustate, 14, pc); SET_REGISTER(cpustate, SPSR, cpsr); SET_CPSR(GET_CPSR | I_MASK | F_MASK); SET_CPSR(GET_CPSR & ~T_MASK); R15 = 0x1c; return; } if (cpustate->pendingIrq && (cpsr & I_MASK) == 0) { SwitchMode(cpustate, eARM7_MODE_IRQ); SET_REGISTER(cpustate, 14, pc); SET_REGISTER(cpustate, SPSR, cpsr); SET_CPSR(GET_CPSR | I_MASK); SET_CPSR(GET_CPSR & ~T_MASK); R15 = 0x18; return; } if (cpustate->pendingAbtP) { SwitchMode(cpustate, eARM7_MODE_ABT); SET_REGISTER(cpustate, 14, pc); SET_REGISTER(cpustate, SPSR, cpsr); SET_CPSR(GET_CPSR | I_MASK); SET_CPSR(GET_CPSR & ~T_MASK); R15 = 0x0c; cpustate->pendingAbtP = 0; return; } if (cpustate->pendingUnd) { SwitchMode(cpustate, eARM7_MODE_UND); SET_REGISTER(cpustate, 14, pc); SET_REGISTER(cpustate, SPSR, cpsr); SET_CPSR(GET_CPSR | I_MASK); SET_CPSR(GET_CPSR & ~T_MASK); R15 = 0x04; cpustate->pendingUnd = 0; return; } if (cpustate->pendingSwi) { SwitchMode(cpustate, eARM7_MODE_SVC); if (T_IS_SET(GET_CPSR)) { SET_REGISTER(cpustate, 14, pc-2); } else { SET_REGISTER(cpustate, 14, pc); } SET_REGISTER(cpustate, SPSR, cpsr); SET_CPSR(GET_CPSR | I_MASK); SET_CPSR(GET_CPSR & ~T_MASK); R15 = 0x08; cpustate->pendingSwi = 0; return; } }
[ "static", "void", "arm7_check_irq_state", "(", "arm_state", "*", "cpustate", ")", "{", "UINT32", "cpsr", "=", "GET_CPSR", ";", "UINT32", "pc", "=", "R15", "+", "4", ";", ";", "if", "(", "cpustate", "->", "pendingAbtD", ")", "{", "SwitchMode", "(", "cpustate", ",", "eARM7_MODE_ABT", ")", ";", "SET_REGISTER", "(", "cpustate", ",", "14", ",", "pc", ")", ";", "SET_REGISTER", "(", "cpustate", ",", "SPSR", ",", "cpsr", ")", ";", "SET_CPSR", "(", "GET_CPSR", "|", "I_MASK", ")", ";", "SET_CPSR", "(", "GET_CPSR", "&", "~", "T_MASK", ")", ";", "R15", "=", "0x10", ";", "cpustate", "->", "pendingAbtD", "=", "0", ";", "return", ";", "}", "if", "(", "cpustate", "->", "pendingFiq", "&&", "(", "cpsr", "&", "F_MASK", ")", "==", "0", ")", "{", "SwitchMode", "(", "cpustate", ",", "eARM7_MODE_FIQ", ")", ";", "SET_REGISTER", "(", "cpustate", ",", "14", ",", "pc", ")", ";", "SET_REGISTER", "(", "cpustate", ",", "SPSR", ",", "cpsr", ")", ";", "SET_CPSR", "(", "GET_CPSR", "|", "I_MASK", "|", "F_MASK", ")", ";", "SET_CPSR", "(", "GET_CPSR", "&", "~", "T_MASK", ")", ";", "R15", "=", "0x1c", ";", "return", ";", "}", "if", "(", "cpustate", "->", "pendingIrq", "&&", "(", "cpsr", "&", "I_MASK", ")", "==", "0", ")", "{", "SwitchMode", "(", "cpustate", ",", "eARM7_MODE_IRQ", ")", ";", "SET_REGISTER", "(", "cpustate", ",", "14", ",", "pc", ")", ";", "SET_REGISTER", "(", "cpustate", ",", "SPSR", ",", "cpsr", ")", ";", "SET_CPSR", "(", "GET_CPSR", "|", "I_MASK", ")", ";", "SET_CPSR", "(", "GET_CPSR", "&", "~", "T_MASK", ")", ";", "R15", "=", "0x18", ";", "return", ";", "}", "if", "(", "cpustate", "->", "pendingAbtP", ")", "{", "SwitchMode", "(", "cpustate", ",", "eARM7_MODE_ABT", ")", ";", "SET_REGISTER", "(", "cpustate", ",", "14", ",", "pc", ")", ";", "SET_REGISTER", "(", "cpustate", ",", "SPSR", ",", "cpsr", ")", ";", "SET_CPSR", "(", "GET_CPSR", "|", "I_MASK", ")", ";", "SET_CPSR", "(", "GET_CPSR", "&", "~", "T_MASK", ")", ";", "R15", "=", "0x0c", ";", "cpustate", "->", "pendingAbtP", "=", "0", ";", "return", ";", "}", "if", "(", "cpustate", "->", "pendingUnd", ")", "{", "SwitchMode", "(", "cpustate", ",", "eARM7_MODE_UND", ")", ";", "SET_REGISTER", "(", "cpustate", ",", "14", ",", "pc", ")", ";", "SET_REGISTER", "(", "cpustate", ",", "SPSR", ",", "cpsr", ")", ";", "SET_CPSR", "(", "GET_CPSR", "|", "I_MASK", ")", ";", "SET_CPSR", "(", "GET_CPSR", "&", "~", "T_MASK", ")", ";", "R15", "=", "0x04", ";", "cpustate", "->", "pendingUnd", "=", "0", ";", "return", ";", "}", "if", "(", "cpustate", "->", "pendingSwi", ")", "{", "SwitchMode", "(", "cpustate", ",", "eARM7_MODE_SVC", ")", ";", "if", "(", "T_IS_SET", "(", "GET_CPSR", ")", ")", "{", "SET_REGISTER", "(", "cpustate", ",", "14", ",", "pc", "-", "2", ")", ";", "}", "else", "{", "SET_REGISTER", "(", "cpustate", ",", "14", ",", "pc", ")", ";", "}", "SET_REGISTER", "(", "cpustate", ",", "SPSR", ",", "cpsr", ")", ";", "SET_CPSR", "(", "GET_CPSR", "|", "I_MASK", ")", ";", "SET_CPSR", "(", "GET_CPSR", "&", "~", "T_MASK", ")", ";", "R15", "=", "0x08", ";", "cpustate", "->", "pendingSwi", "=", "0", ";", "return", ";", "}", "}" ]
CPU CHECK IRQ STATE Note: couldn't find any exact cycle counts for most of these exceptions
[ "CPU", "CHECK", "IRQ", "STATE", "Note", ":", "couldn", "'", "t", "find", "any", "exact", "cycle", "counts", "for", "most", "of", "these", "exceptions" ]
[ "/* save current CPSR */", "/* save old pc (already incremented in pipeline) */", "/* Exception priorities:\n\n Reset\n Data abort\n FIRQ\n IRQ\n Prefetch abort\n Undefined instruction\n Software Interrupt\n */", "// Data Abort", "/* Set ABT mode so PC is saved to correct R14 bank */", "/* save PC to R14 */", "/* Save current CPSR */", "/* Mask IRQ */", "/* IRQ Vector address */", "// FIQ", "/* Set FIQ mode so PC is saved to correct R14 bank */", "/* save PC to R14 */", "/* Save current CPSR */", "/* Mask both IRQ & FIQ */", "/* IRQ Vector address */", "// IRQ", "/* Set IRQ mode so PC is saved to correct R14 bank */", "/* save PC to R14 */", "/* Save current CPSR */", "/* Mask IRQ */", "/* IRQ Vector address */", "// Prefetch Abort", "/* Set ABT mode so PC is saved to correct R14 bank */", "/* save PC to R14 */", "/* Save current CPSR */", "/* Mask IRQ */", "/* IRQ Vector address */", "// Undefined instruction", "/* Set UND mode so PC is saved to correct R14 bank */", "/* save PC to R14 */", "/* Save current CPSR */", "/* Mask IRQ */", "/* IRQ Vector address */", "// Software Interrupt", "/* Set SVC mode so PC is saved to correct R14 bank */", "// compensate for prefetch (should this also be done for normal IRQ?)", "/* save PC to R14 */", "/* save PC to R14 */", "/* Save current CPSR */", "/* Mask IRQ */", "/* Go to ARM mode */", "/* Jump to the SWI vector */" ]
[ { "param": "cpustate", "type": "arm_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cpustate", "type": "arm_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2a05d01541c752e0191cb4c4415a40e7295eba90
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/arm7/arm7core.c
[ "Unlicense" ]
C
HandleCoProcRT
void
static void HandleCoProcRT(arm_state *cpustate, UINT32 insn) { /* xxxx 1110 oooL nnnn dddd cccc ppp1 mmmm */ // Load (MRC) data from Co-Proc to ARM7 register if (insn & 0x00100000) // Bit 20 = Load or Store { if (arm7_coproc_rt_r_callback) { UINT32 res = arm7_coproc_rt_r_callback(cpustate->device, insn, 0); // RT Read handler must parse opcode & return appropriate result SET_REGISTER(cpustate, (insn >> 12) & 0xf, res); } else LOG(("%08x: Co-Processor Register Transfer executed, but no RT Read callback defined!\n", R15)); } // Store (MCR) data from ARM7 to Co-Proc register else { if (arm7_coproc_rt_r_callback) arm7_coproc_rt_w_callback(cpustate->device, insn, GET_REGISTER(cpustate, (insn >> 12) & 0xf), 0); else LOG(("%08x: Co-Processor Register Transfer executed, but no RT Write callback defined!\n", R15)); } }
// Co-Processor Register Transfer - To/From Arm to Co-Proc
Co-Processor Register Transfer - To/From Arm to Co-Proc
[ "Co", "-", "Processor", "Register", "Transfer", "-", "To", "/", "From", "Arm", "to", "Co", "-", "Proc" ]
static void HandleCoProcRT(arm_state *cpustate, UINT32 insn) { if (insn & 0x00100000) { if (arm7_coproc_rt_r_callback) { UINT32 res = arm7_coproc_rt_r_callback(cpustate->device, insn, 0); SET_REGISTER(cpustate, (insn >> 12) & 0xf, res); } else LOG(("%08x: Co-Processor Register Transfer executed, but no RT Read callback defined!\n", R15)); } else { if (arm7_coproc_rt_r_callback) arm7_coproc_rt_w_callback(cpustate->device, insn, GET_REGISTER(cpustate, (insn >> 12) & 0xf), 0); else LOG(("%08x: Co-Processor Register Transfer executed, but no RT Write callback defined!\n", R15)); } }
[ "static", "void", "HandleCoProcRT", "(", "arm_state", "*", "cpustate", ",", "UINT32", "insn", ")", "{", "if", "(", "insn", "&", "0x00100000", ")", "{", "if", "(", "arm7_coproc_rt_r_callback", ")", "{", "UINT32", "res", "=", "arm7_coproc_rt_r_callback", "(", "cpustate", "->", "device", ",", "insn", ",", "0", ")", ";", "SET_REGISTER", "(", "cpustate", ",", "(", "insn", ">>", "12", ")", "&", "0xf", ",", "res", ")", ";", "}", "else", "LOG", "(", "(", "\"", "\\n", "\"", ",", "R15", ")", ")", ";", "}", "else", "{", "if", "(", "arm7_coproc_rt_r_callback", ")", "arm7_coproc_rt_w_callback", "(", "cpustate", "->", "device", ",", "insn", ",", "GET_REGISTER", "(", "cpustate", ",", "(", "insn", ">>", "12", ")", "&", "0xf", ")", ",", "0", ")", ";", "else", "LOG", "(", "(", "\"", "\\n", "\"", ",", "R15", ")", ")", ";", "}", "}" ]
Co-Processor Register Transfer - To/From Arm to Co-Proc
[ "Co", "-", "Processor", "Register", "Transfer", "-", "To", "/", "From", "Arm", "to", "Co", "-", "Proc" ]
[ "/* xxxx 1110 oooL nnnn dddd cccc ppp1 mmmm */", "// Load (MRC) data from Co-Proc to ARM7 register", "// Bit 20 = Load or Store", "// RT Read handler must parse opcode & return appropriate result", "// Store (MCR) data from ARM7 to Co-Proc register" ]
[ { "param": "cpustate", "type": "arm_state" }, { "param": "insn", "type": "UINT32" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cpustate", "type": "arm_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "insn", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1de6278ab60a0a4613c6ba1335a2a22611d33237
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/video/dbz.c
[ "Unlicense" ]
C
sortlayers
void
static void sortlayers(int *layer, int *pri) { #define SWAP(a,b) \ if (pri[a] <= pri[b]) \ { \ int t; \ t = pri[a]; pri[a] = pri[b]; pri[b] = t; \ t = layer[a]; layer[a] = layer[b]; layer[b] = t; \ } SWAP(0, 1) SWAP(0, 2) SWAP(0, 3) SWAP(0, 4) SWAP(1, 2) SWAP(1, 3) SWAP(1, 4) SWAP(2, 3) SWAP(2, 4) SWAP(3, 4) }
/* useful function to sort the four tile layers by priority order */
useful function to sort the four tile layers by priority order
[ "useful", "function", "to", "sort", "the", "four", "tile", "layers", "by", "priority", "order" ]
static void sortlayers(int *layer, int *pri) { #define SWAP(a,b) \ if (pri[a] <= pri[b]) \ { \ int t; \ t = pri[a]; pri[a] = pri[b]; pri[b] = t; \ t = layer[a]; layer[a] = layer[b]; layer[b] = t; \ } SWAP(0, 1) SWAP(0, 2) SWAP(0, 3) SWAP(0, 4) SWAP(1, 2) SWAP(1, 3) SWAP(1, 4) SWAP(2, 3) SWAP(2, 4) SWAP(3, 4) }
[ "static", "void", "sortlayers", "(", "int", "*", "layer", ",", "int", "*", "pri", ")", "{", "#define", "SWAP", "(", "a", ",", "b", ")", " \\\n\tif (pri[a] <= pri[b]) \\\n\t{ \\\n\t\tint t; \\\n\t\tt = pri[a]; pri[a] = pri[b]; pri[b] = t; \\\n\t\tt = layer[a]; layer[a] = layer[b]; layer[b] = t; \\\n\t}", "\n\n", "SWAP", "(", "0", ",", "1", ")", "", "SWAP", "(", "0", ",", "2", ")", "", "SWAP", "(", "0", ",", "3", ")", "", "SWAP", "(", "0", ",", "4", ")", "", "SWAP", "(", "1", ",", "2", ")", "", "SWAP", "(", "1", ",", "3", ")", "", "SWAP", "(", "1", ",", "4", ")", "", "SWAP", "(", "2", ",", "3", ")", "", "SWAP", "(", "2", ",", "4", ")", "", "SWAP", "(", "3", ",", "4", ")", "", "}" ]
useful function to sort the four tile layers by priority order
[ "useful", "function", "to", "sort", "the", "four", "tile", "layers", "by", "priority", "order" ]
[]
[ { "param": "layer", "type": "int" }, { "param": "pri", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "layer", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pri", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
511ed6dd9f28520a3ba772bb3c134e0579971032
lofunz/mieme
Reloaded/trunk/src/osd/droid-ios/wiimote.c
[ "Unlicense" ]
C
wiimote_status
void
void wiimote_status(struct wiimote_t* wm) { byte buf = 0; if (!wm || !WIIMOTE_IS_CONNECTED(wm)) return; if(WIIMOTE_DBG)printf("Requested wiimote status.\n"); wiimote_send(wm, WM_CMD_CTRL_STATUS, &buf, 1); }
/** * @brief Request the wiimote controller status. * * @param wm Pointer to a wiimote_t structure. * * Controller status includes: battery level, LED status, expansions */
@brief Request the wiimote controller status. @param wm Pointer to a wiimote_t structure. Controller status includes: battery level, LED status, expansions
[ "@brief", "Request", "the", "wiimote", "controller", "status", ".", "@param", "wm", "Pointer", "to", "a", "wiimote_t", "structure", ".", "Controller", "status", "includes", ":", "battery", "level", "LED", "status", "expansions" ]
void wiimote_status(struct wiimote_t* wm) { byte buf = 0; if (!wm || !WIIMOTE_IS_CONNECTED(wm)) return; if(WIIMOTE_DBG)printf("Requested wiimote status.\n"); wiimote_send(wm, WM_CMD_CTRL_STATUS, &buf, 1); }
[ "void", "wiimote_status", "(", "struct", "wiimote_t", "*", "wm", ")", "{", "byte", "buf", "=", "0", ";", "if", "(", "!", "wm", "||", "!", "WIIMOTE_IS_CONNECTED", "(", "wm", ")", ")", "return", ";", "if", "(", "WIIMOTE_DBG", ")", "printf", "(", "\"", "\\n", "\"", ")", ";", "wiimote_send", "(", "wm", ",", "WM_CMD_CTRL_STATUS", ",", "&", "buf", ",", "1", ")", ";", "}" ]
@brief Request the wiimote controller status.
[ "@brief", "Request", "the", "wiimote", "controller", "status", "." ]
[]
[ { "param": "wm", "type": "struct wiimote_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "wm", "type": "struct wiimote_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
511ed6dd9f28520a3ba772bb3c134e0579971032
lofunz/mieme
Reloaded/trunk/src/osd/droid-ios/wiimote.c
[ "Unlicense" ]
C
wiimote_pressed_buttons
void
void wiimote_pressed_buttons(struct wiimote_t* wm, byte* msg) { short now; /* convert to big endian */ now = BIG_ENDIAN_SHORT(*(short*)msg) & WIIMOTE_BUTTON_ALL; /* buttons pressed now */ wm->btns = now; }
/** * @brief Find what buttons are pressed. * * @param wm Pointer to a wiimote_t structure. * @param msg The message specified in the event packet. */
@brief Find what buttons are pressed. @param wm Pointer to a wiimote_t structure. @param msg The message specified in the event packet.
[ "@brief", "Find", "what", "buttons", "are", "pressed", ".", "@param", "wm", "Pointer", "to", "a", "wiimote_t", "structure", ".", "@param", "msg", "The", "message", "specified", "in", "the", "event", "packet", "." ]
void wiimote_pressed_buttons(struct wiimote_t* wm, byte* msg) { short now; now = BIG_ENDIAN_SHORT(*(short*)msg) & WIIMOTE_BUTTON_ALL; wm->btns = now; }
[ "void", "wiimote_pressed_buttons", "(", "struct", "wiimote_t", "*", "wm", ",", "byte", "*", "msg", ")", "{", "short", "now", ";", "now", "=", "BIG_ENDIAN_SHORT", "(", "*", "(", "short", "*", ")", "msg", ")", "&", "WIIMOTE_BUTTON_ALL", ";", "wm", "->", "btns", "=", "now", ";", "}" ]
@brief Find what buttons are pressed.
[ "@brief", "Find", "what", "buttons", "are", "pressed", "." ]
[ "/* convert to big endian */", "/* buttons pressed now */" ]
[ { "param": "wm", "type": "struct wiimote_t" }, { "param": "msg", "type": "byte" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "wm", "type": "struct wiimote_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "msg", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
511ed6dd9f28520a3ba772bb3c134e0579971032
lofunz/mieme
Reloaded/trunk/src/osd/droid-ios/wiimote.c
[ "Unlicense" ]
C
wiimote_handle_expansion
void
void wiimote_handle_expansion(struct wiimote_t* wm, byte* msg) { switch (wm->exp.type) { case EXP_CLASSIC: classic_ctrl_event(&wm->exp.classic, msg); break; default: break; } }
/** * @brief Handle data from the expansion. * * @param wm A pointer to a wiimote_t structure. * @param msg The message specified in the event packet for the expansion. */
@brief Handle data from the expansion. @param wm A pointer to a wiimote_t structure. @param msg The message specified in the event packet for the expansion.
[ "@brief", "Handle", "data", "from", "the", "expansion", ".", "@param", "wm", "A", "pointer", "to", "a", "wiimote_t", "structure", ".", "@param", "msg", "The", "message", "specified", "in", "the", "event", "packet", "for", "the", "expansion", "." ]
void wiimote_handle_expansion(struct wiimote_t* wm, byte* msg) { switch (wm->exp.type) { case EXP_CLASSIC: classic_ctrl_event(&wm->exp.classic, msg); break; default: break; } }
[ "void", "wiimote_handle_expansion", "(", "struct", "wiimote_t", "*", "wm", ",", "byte", "*", "msg", ")", "{", "switch", "(", "wm", "->", "exp", ".", "type", ")", "{", "case", "EXP_CLASSIC", ":", "classic_ctrl_event", "(", "&", "wm", "->", "exp", ".", "classic", ",", "msg", ")", ";", "break", ";", "default", ":", "break", ";", "}", "}" ]
@brief Handle data from the expansion.
[ "@brief", "Handle", "data", "from", "the", "expansion", "." ]
[]
[ { "param": "wm", "type": "struct wiimote_t" }, { "param": "msg", "type": "byte" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "wm", "type": "struct wiimote_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "msg", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
511ed6dd9f28520a3ba772bb3c134e0579971032
lofunz/mieme
Reloaded/trunk/src/osd/droid-ios/wiimote.c
[ "Unlicense" ]
C
wiimote_read_data
int
int wiimote_read_data(struct wiimote_t* wm, unsigned int addr, unsigned short len) { //No puden ser mas de 16 lo leido o vendra en trozos! if (!wm || !WIIMOTE_IS_CONNECTED(wm)) return 0; if (!len /*|| len > 16*/) return 0; byte buf[6]; /* the offset is in big endian */ *(int*)(buf) = BIG_ENDIAN_LONG(addr); /* the length is in big endian */ *(short*)(buf + 4) = BIG_ENDIAN_SHORT(len); if(WIIMOTE_DBG)printf("Request read at address: 0x%x length: %i", addr, len); wiimote_send(wm, WM_CMD_READ_DATA, buf, 6); return 1; }
/** * @brief Read data from the wiimote (event version). * * @param wm Pointer to a wiimote_t structure. * @param addr The address of wiimote memory to read from. * @param len The length of the block to be read. * * The library can only handle one data read request at a time * because it must keep track of the buffer and other * events that are specific to that request. So if a request * has already been made, subsequent requests will be added * to a pending list and be sent out when the previous * finishes. */
@brief Read data from the wiimote (event version). @param wm Pointer to a wiimote_t structure. @param addr The address of wiimote memory to read from. @param len The length of the block to be read. The library can only handle one data read request at a time because it must keep track of the buffer and other events that are specific to that request. So if a request has already been made, subsequent requests will be added to a pending list and be sent out when the previous finishes.
[ "@brief", "Read", "data", "from", "the", "wiimote", "(", "event", "version", ")", ".", "@param", "wm", "Pointer", "to", "a", "wiimote_t", "structure", ".", "@param", "addr", "The", "address", "of", "wiimote", "memory", "to", "read", "from", ".", "@param", "len", "The", "length", "of", "the", "block", "to", "be", "read", ".", "The", "library", "can", "only", "handle", "one", "data", "read", "request", "at", "a", "time", "because", "it", "must", "keep", "track", "of", "the", "buffer", "and", "other", "events", "that", "are", "specific", "to", "that", "request", ".", "So", "if", "a", "request", "has", "already", "been", "made", "subsequent", "requests", "will", "be", "added", "to", "a", "pending", "list", "and", "be", "sent", "out", "when", "the", "previous", "finishes", "." ]
int wiimote_read_data(struct wiimote_t* wm, unsigned int addr, unsigned short len) { if (!wm || !WIIMOTE_IS_CONNECTED(wm)) return 0; if (!len ) return 0; byte buf[6]; *(int*)(buf) = BIG_ENDIAN_LONG(addr); *(short*)(buf + 4) = BIG_ENDIAN_SHORT(len); if(WIIMOTE_DBG)printf("Request read at address: 0x%x length: %i", addr, len); wiimote_send(wm, WM_CMD_READ_DATA, buf, 6); return 1; }
[ "int", "wiimote_read_data", "(", "struct", "wiimote_t", "*", "wm", ",", "unsigned", "int", "addr", ",", "unsigned", "short", "len", ")", "{", "if", "(", "!", "wm", "||", "!", "WIIMOTE_IS_CONNECTED", "(", "wm", ")", ")", "return", "0", ";", "if", "(", "!", "len", ")", "return", "0", ";", "byte", "buf", "[", "6", "]", ";", "*", "(", "int", "*", ")", "(", "buf", ")", "=", "BIG_ENDIAN_LONG", "(", "addr", ")", ";", "*", "(", "short", "*", ")", "(", "buf", "+", "4", ")", "=", "BIG_ENDIAN_SHORT", "(", "len", ")", ";", "if", "(", "WIIMOTE_DBG", ")", "printf", "(", "\"", "\"", ",", "addr", ",", "len", ")", ";", "wiimote_send", "(", "wm", ",", "WM_CMD_READ_DATA", ",", "buf", ",", "6", ")", ";", "return", "1", ";", "}" ]
@brief Read data from the wiimote (event version).
[ "@brief", "Read", "data", "from", "the", "wiimote", "(", "event", "version", ")", "." ]
[ "//No puden ser mas de 16 lo leido o vendra en trozos!", "/*|| len > 16*/", "/* the offset is in big endian */", "/* the length is in big endian */" ]
[ { "param": "wm", "type": "struct wiimote_t" }, { "param": "addr", "type": "unsigned int" }, { "param": "len", "type": "unsigned short" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "wm", "type": "struct wiimote_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "addr", "type": "unsigned int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "len", "type": "unsigned short", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
511ed6dd9f28520a3ba772bb3c134e0579971032
lofunz/mieme
Reloaded/trunk/src/osd/droid-ios/wiimote.c
[ "Unlicense" ]
C
wiimote_write_data
int
int wiimote_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte len) { byte buf[21] = {0}; /* the payload is always 23 */ if (!wm || !WIIMOTE_IS_CONNECTED(wm)) return 0; if (!data || !len) return 0; if(WIIMOTE_DBG)printf("Writing %i bytes to memory location 0x%x...\n", len, addr); if(WIIMOTE_DBG) { int i = 0; printf("Write data is: "); for (; i < len; ++i) printf("%x ", data[i]); printf("\n"); } /* the offset is in big endian */ *(int*)(buf) = BIG_ENDIAN_LONG(addr); /* length */ *(byte*)(buf + 4) = len; /* data */ memcpy(buf + 5, data, len); wiimote_send(wm, WM_CMD_WRITE_DATA, buf, 21); return 1; }
/** * @brief Write data to the wiimote. * * @param wm Pointer to a wiimote_t structure. * @param addr The address to write to. * @param data The data to be written to the memory location. * @param len The length of the block to be written. */
@brief Write data to the wiimote. @param wm Pointer to a wiimote_t structure. @param addr The address to write to. @param data The data to be written to the memory location. @param len The length of the block to be written.
[ "@brief", "Write", "data", "to", "the", "wiimote", ".", "@param", "wm", "Pointer", "to", "a", "wiimote_t", "structure", ".", "@param", "addr", "The", "address", "to", "write", "to", ".", "@param", "data", "The", "data", "to", "be", "written", "to", "the", "memory", "location", ".", "@param", "len", "The", "length", "of", "the", "block", "to", "be", "written", "." ]
int wiimote_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte len) { byte buf[21] = {0}; if (!wm || !WIIMOTE_IS_CONNECTED(wm)) return 0; if (!data || !len) return 0; if(WIIMOTE_DBG)printf("Writing %i bytes to memory location 0x%x...\n", len, addr); if(WIIMOTE_DBG) { int i = 0; printf("Write data is: "); for (; i < len; ++i) printf("%x ", data[i]); printf("\n"); } *(int*)(buf) = BIG_ENDIAN_LONG(addr); *(byte*)(buf + 4) = len; memcpy(buf + 5, data, len); wiimote_send(wm, WM_CMD_WRITE_DATA, buf, 21); return 1; }
[ "int", "wiimote_write_data", "(", "struct", "wiimote_t", "*", "wm", ",", "unsigned", "int", "addr", ",", "byte", "*", "data", ",", "byte", "len", ")", "{", "byte", "buf", "[", "21", "]", "=", "{", "0", "}", ";", "if", "(", "!", "wm", "||", "!", "WIIMOTE_IS_CONNECTED", "(", "wm", ")", ")", "return", "0", ";", "if", "(", "!", "data", "||", "!", "len", ")", "return", "0", ";", "if", "(", "WIIMOTE_DBG", ")", "printf", "(", "\"", "\\n", "\"", ",", "len", ",", "addr", ")", ";", "if", "(", "WIIMOTE_DBG", ")", "{", "int", "i", "=", "0", ";", "printf", "(", "\"", "\"", ")", ";", "for", "(", ";", "i", "<", "len", ";", "++", "i", ")", "printf", "(", "\"", "\"", ",", "data", "[", "i", "]", ")", ";", "printf", "(", "\"", "\\n", "\"", ")", ";", "}", "*", "(", "int", "*", ")", "(", "buf", ")", "=", "BIG_ENDIAN_LONG", "(", "addr", ")", ";", "*", "(", "byte", "*", ")", "(", "buf", "+", "4", ")", "=", "len", ";", "memcpy", "(", "buf", "+", "5", ",", "data", ",", "len", ")", ";", "wiimote_send", "(", "wm", ",", "WM_CMD_WRITE_DATA", ",", "buf", ",", "21", ")", ";", "return", "1", ";", "}" ]
@brief Write data to the wiimote.
[ "@brief", "Write", "data", "to", "the", "wiimote", "." ]
[ "/* the payload is always 23 */", "/* the offset is in big endian */", "/* length */", "/* data */" ]
[ { "param": "wm", "type": "struct wiimote_t" }, { "param": "addr", "type": "unsigned int" }, { "param": "data", "type": "byte" }, { "param": "len", "type": "byte" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "wm", "type": "struct wiimote_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "addr", "type": "unsigned int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "len", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
511ed6dd9f28520a3ba772bb3c134e0579971032
lofunz/mieme
Reloaded/trunk/src/osd/droid-ios/wiimote.c
[ "Unlicense" ]
C
classic_ctrl_handshake
int
int classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, byte* data, unsigned short len) { int offset = 0; cc->btns = 0; cc->r_shoulder = 0; cc->l_shoulder = 0; /* decrypt data */ /* for (i = 0; i < len; ++i) data[i] = (data[i] ^ 0x17) + 0x17; */ if(WIIMOTE_DBG) { int x = 0; printf("[DECRIPTED]"); for (; x < len; x++) printf("%.2x ", data[x]); printf("\n"); } /* if (data[offset] == 0xFF) { return 0;//ERROR! } */ /* joystick stuff */ if (data[offset] != 0xFF && data[offset] != 0x00) { cc->ljs.max.x = data[0 + offset] / 4; cc->ljs.min.x = data[1 + offset] / 4; cc->ljs.center.x = data[2 + offset] / 4; cc->ljs.max.y = data[3 + offset] / 4; cc->ljs.min.y = data[4 + offset] / 4; cc->ljs.center.y = data[5 + offset] / 4; cc->rjs.max.x = data[6 + offset] / 8; cc->rjs.min.x = data[7 + offset] / 8; cc->rjs.center.x = data[8 + offset] / 8; cc->rjs.max.y = data[9 + offset] / 8; cc->rjs.min.y = data[10 + offset] / 8; cc->rjs.center.y = data[11 + offset] / 8; } else { cc->ljs.max.x = 55; cc->ljs.min.x = 5; cc->ljs.center.x = 30; cc->ljs.max.y = 55; cc->ljs.min.y = 5; cc->ljs.center.y = 30; cc->rjs.max.x = 30; cc->rjs.min.x = 0; cc->rjs.center.x = 15; cc->rjs.max.y = 30; cc->rjs.min.y = 0; cc->rjs.center.y = 15; } /* handshake done */ wm->exp.type = EXP_CLASSIC; return 1; }
/** * @brief Handle the handshake data from the classic controller. * * @param cc A pointer to a classic_ctrl_t structure. * @param data The data read in from the device. * @param len The length of the data block, in bytes. * * @return Returns 1 if handshake was successful, 0 if not. */
@brief Handle the handshake data from the classic controller. @param cc A pointer to a classic_ctrl_t structure. @param data The data read in from the device. @param len The length of the data block, in bytes. @return Returns 1 if handshake was successful, 0 if not.
[ "@brief", "Handle", "the", "handshake", "data", "from", "the", "classic", "controller", ".", "@param", "cc", "A", "pointer", "to", "a", "classic_ctrl_t", "structure", ".", "@param", "data", "The", "data", "read", "in", "from", "the", "device", ".", "@param", "len", "The", "length", "of", "the", "data", "block", "in", "bytes", ".", "@return", "Returns", "1", "if", "handshake", "was", "successful", "0", "if", "not", "." ]
int classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, byte* data, unsigned short len) { int offset = 0; cc->btns = 0; cc->r_shoulder = 0; cc->l_shoulder = 0; if(WIIMOTE_DBG) { int x = 0; printf("[DECRIPTED]"); for (; x < len; x++) printf("%.2x ", data[x]); printf("\n"); } if (data[offset] != 0xFF && data[offset] != 0x00) { cc->ljs.max.x = data[0 + offset] / 4; cc->ljs.min.x = data[1 + offset] / 4; cc->ljs.center.x = data[2 + offset] / 4; cc->ljs.max.y = data[3 + offset] / 4; cc->ljs.min.y = data[4 + offset] / 4; cc->ljs.center.y = data[5 + offset] / 4; cc->rjs.max.x = data[6 + offset] / 8; cc->rjs.min.x = data[7 + offset] / 8; cc->rjs.center.x = data[8 + offset] / 8; cc->rjs.max.y = data[9 + offset] / 8; cc->rjs.min.y = data[10 + offset] / 8; cc->rjs.center.y = data[11 + offset] / 8; } else { cc->ljs.max.x = 55; cc->ljs.min.x = 5; cc->ljs.center.x = 30; cc->ljs.max.y = 55; cc->ljs.min.y = 5; cc->ljs.center.y = 30; cc->rjs.max.x = 30; cc->rjs.min.x = 0; cc->rjs.center.x = 15; cc->rjs.max.y = 30; cc->rjs.min.y = 0; cc->rjs.center.y = 15; } wm->exp.type = EXP_CLASSIC; return 1; }
[ "int", "classic_ctrl_handshake", "(", "struct", "wiimote_t", "*", "wm", ",", "struct", "classic_ctrl_t", "*", "cc", ",", "byte", "*", "data", ",", "unsigned", "short", "len", ")", "{", "int", "offset", "=", "0", ";", "cc", "->", "btns", "=", "0", ";", "cc", "->", "r_shoulder", "=", "0", ";", "cc", "->", "l_shoulder", "=", "0", ";", "if", "(", "WIIMOTE_DBG", ")", "{", "int", "x", "=", "0", ";", "printf", "(", "\"", "\"", ")", ";", "for", "(", ";", "x", "<", "len", ";", "x", "++", ")", "printf", "(", "\"", "\"", ",", "data", "[", "x", "]", ")", ";", "printf", "(", "\"", "\\n", "\"", ")", ";", "}", "if", "(", "data", "[", "offset", "]", "!=", "0xFF", "&&", "data", "[", "offset", "]", "!=", "0x00", ")", "{", "cc", "->", "ljs", ".", "max", ".", "x", "=", "data", "[", "0", "+", "offset", "]", "/", "4", ";", "cc", "->", "ljs", ".", "min", ".", "x", "=", "data", "[", "1", "+", "offset", "]", "/", "4", ";", "cc", "->", "ljs", ".", "center", ".", "x", "=", "data", "[", "2", "+", "offset", "]", "/", "4", ";", "cc", "->", "ljs", ".", "max", ".", "y", "=", "data", "[", "3", "+", "offset", "]", "/", "4", ";", "cc", "->", "ljs", ".", "min", ".", "y", "=", "data", "[", "4", "+", "offset", "]", "/", "4", ";", "cc", "->", "ljs", ".", "center", ".", "y", "=", "data", "[", "5", "+", "offset", "]", "/", "4", ";", "cc", "->", "rjs", ".", "max", ".", "x", "=", "data", "[", "6", "+", "offset", "]", "/", "8", ";", "cc", "->", "rjs", ".", "min", ".", "x", "=", "data", "[", "7", "+", "offset", "]", "/", "8", ";", "cc", "->", "rjs", ".", "center", ".", "x", "=", "data", "[", "8", "+", "offset", "]", "/", "8", ";", "cc", "->", "rjs", ".", "max", ".", "y", "=", "data", "[", "9", "+", "offset", "]", "/", "8", ";", "cc", "->", "rjs", ".", "min", ".", "y", "=", "data", "[", "10", "+", "offset", "]", "/", "8", ";", "cc", "->", "rjs", ".", "center", ".", "y", "=", "data", "[", "11", "+", "offset", "]", "/", "8", ";", "}", "else", "{", "cc", "->", "ljs", ".", "max", ".", "x", "=", "55", ";", "cc", "->", "ljs", ".", "min", ".", "x", "=", "5", ";", "cc", "->", "ljs", ".", "center", ".", "x", "=", "30", ";", "cc", "->", "ljs", ".", "max", ".", "y", "=", "55", ";", "cc", "->", "ljs", ".", "min", ".", "y", "=", "5", ";", "cc", "->", "ljs", ".", "center", ".", "y", "=", "30", ";", "cc", "->", "rjs", ".", "max", ".", "x", "=", "30", ";", "cc", "->", "rjs", ".", "min", ".", "x", "=", "0", ";", "cc", "->", "rjs", ".", "center", ".", "x", "=", "15", ";", "cc", "->", "rjs", ".", "max", ".", "y", "=", "30", ";", "cc", "->", "rjs", ".", "min", ".", "y", "=", "0", ";", "cc", "->", "rjs", ".", "center", ".", "y", "=", "15", ";", "}", "wm", "->", "exp", ".", "type", "=", "EXP_CLASSIC", ";", "return", "1", ";", "}" ]
@brief Handle the handshake data from the classic controller.
[ "@brief", "Handle", "the", "handshake", "data", "from", "the", "classic", "controller", "." ]
[ "/* decrypt data */", "/*\n\tfor (i = 0; i < len; ++i)\n\t\tdata[i] = (data[i] ^ 0x17) + 0x17;\n\t*/", "/*\n\tif (data[offset] == 0xFF)\n\t{\n\t\treturn 0;//ERROR!\n\t}\n*/", "/* joystick stuff */", "/* handshake done */" ]
[ { "param": "wm", "type": "struct wiimote_t" }, { "param": "cc", "type": "struct classic_ctrl_t" }, { "param": "data", "type": "byte" }, { "param": "len", "type": "unsigned short" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "wm", "type": "struct wiimote_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cc", "type": "struct classic_ctrl_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "len", "type": "unsigned short", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
511ed6dd9f28520a3ba772bb3c134e0579971032
lofunz/mieme
Reloaded/trunk/src/osd/droid-ios/wiimote.c
[ "Unlicense" ]
C
classic_ctrl_event
void
void classic_ctrl_event(struct classic_ctrl_t* cc, byte* msg) { int lx, ly, rx, ry; byte l, r; /* decrypt data */ /* for (i = 0; i < 6; ++i) msg[i] = (msg[i] ^ 0x17) + 0x17; */ classic_ctrl_pressed_buttons(cc, BIG_ENDIAN_SHORT(*(short*)(msg + 4))); /* left/right buttons */ l = (((msg[2] & 0x60) >> 2) | ((msg[3] & 0xE0) >> 5)); r = (msg[3] & 0x1F); /* * TODO - LR range hardcoded from 0x00 to 0x1F. * This is probably in the calibration somewhere. */ cc->r_shoulder = ((float)r / 0x1F); cc->l_shoulder = ((float)l / 0x1F); /* calculate joystick orientation */ lx = (msg[0] & 0x3F); ly = (msg[1] & 0x3F); rx = ((msg[0] & 0xC0) >> 3) | ((msg[1] & 0xC0) >> 5) | ((msg[2] & 0x80) >> 7); ry = (msg[2] & 0x1F); if(WIIMOTE_DBG) printf("lx ly rx ry %d %d %d %d\n",lx,ly,rx,ry); calc_joystick_state(&cc->ljs, lx, ly); calc_joystick_state(&cc->rjs, rx, ry); /* printf("classic L button pressed: %f\n", cc->l_shoulder); printf("classic R button pressed: %f\n", cc->r_shoulder); printf("classic left joystick angle: %f\n", cc->ljs.ang); printf("classic left joystick magnitude: %f\n", cc->ljs.mag); printf("classic right joystick angle: %f\n", cc->rjs.ang); printf("classic right joystick magnitude: %f\n", cc->rjs.mag); */ }
/** * @brief Handle classic controller event. * * @param cc A pointer to a classic_ctrl_t structure. * @param msg The message specified in the event packet. */
@brief Handle classic controller event. @param cc A pointer to a classic_ctrl_t structure. @param msg The message specified in the event packet.
[ "@brief", "Handle", "classic", "controller", "event", ".", "@param", "cc", "A", "pointer", "to", "a", "classic_ctrl_t", "structure", ".", "@param", "msg", "The", "message", "specified", "in", "the", "event", "packet", "." ]
void classic_ctrl_event(struct classic_ctrl_t* cc, byte* msg) { int lx, ly, rx, ry; byte l, r; classic_ctrl_pressed_buttons(cc, BIG_ENDIAN_SHORT(*(short*)(msg + 4))); l = (((msg[2] & 0x60) >> 2) | ((msg[3] & 0xE0) >> 5)); r = (msg[3] & 0x1F); cc->r_shoulder = ((float)r / 0x1F); cc->l_shoulder = ((float)l / 0x1F); lx = (msg[0] & 0x3F); ly = (msg[1] & 0x3F); rx = ((msg[0] & 0xC0) >> 3) | ((msg[1] & 0xC0) >> 5) | ((msg[2] & 0x80) >> 7); ry = (msg[2] & 0x1F); if(WIIMOTE_DBG) printf("lx ly rx ry %d %d %d %d\n",lx,ly,rx,ry); calc_joystick_state(&cc->ljs, lx, ly); calc_joystick_state(&cc->rjs, rx, ry); }
[ "void", "classic_ctrl_event", "(", "struct", "classic_ctrl_t", "*", "cc", ",", "byte", "*", "msg", ")", "{", "int", "lx", ",", "ly", ",", "rx", ",", "ry", ";", "byte", "l", ",", "r", ";", "classic_ctrl_pressed_buttons", "(", "cc", ",", "BIG_ENDIAN_SHORT", "(", "*", "(", "short", "*", ")", "(", "msg", "+", "4", ")", ")", ")", ";", "l", "=", "(", "(", "(", "msg", "[", "2", "]", "&", "0x60", ")", ">>", "2", ")", "|", "(", "(", "msg", "[", "3", "]", "&", "0xE0", ")", ">>", "5", ")", ")", ";", "r", "=", "(", "msg", "[", "3", "]", "&", "0x1F", ")", ";", "cc", "->", "r_shoulder", "=", "(", "(", "float", ")", "r", "/", "0x1F", ")", ";", "cc", "->", "l_shoulder", "=", "(", "(", "float", ")", "l", "/", "0x1F", ")", ";", "lx", "=", "(", "msg", "[", "0", "]", "&", "0x3F", ")", ";", "ly", "=", "(", "msg", "[", "1", "]", "&", "0x3F", ")", ";", "rx", "=", "(", "(", "msg", "[", "0", "]", "&", "0xC0", ")", ">>", "3", ")", "|", "(", "(", "msg", "[", "1", "]", "&", "0xC0", ")", ">>", "5", ")", "|", "(", "(", "msg", "[", "2", "]", "&", "0x80", ")", ">>", "7", ")", ";", "ry", "=", "(", "msg", "[", "2", "]", "&", "0x1F", ")", ";", "if", "(", "WIIMOTE_DBG", ")", "printf", "(", "\"", "\\n", "\"", ",", "lx", ",", "ly", ",", "rx", ",", "ry", ")", ";", "calc_joystick_state", "(", "&", "cc", "->", "ljs", ",", "lx", ",", "ly", ")", ";", "calc_joystick_state", "(", "&", "cc", "->", "rjs", ",", "rx", ",", "ry", ")", ";", "}" ]
@brief Handle classic controller event.
[ "@brief", "Handle", "classic", "controller", "event", "." ]
[ "/* decrypt data */", "/*\n\tfor (i = 0; i < 6; ++i)\n\t\tmsg[i] = (msg[i] ^ 0x17) + 0x17;\n */", "/* left/right buttons */", "/*\n\t *\tTODO - LR range hardcoded from 0x00 to 0x1F.\n\t *\tThis is probably in the calibration somewhere.\n\t */", "/* calculate joystick orientation */", "/*\n\tprintf(\"classic L button pressed: %f\\n\", cc->l_shoulder);\n\tprintf(\"classic R button pressed: %f\\n\", cc->r_shoulder);\n\tprintf(\"classic left joystick angle: %f\\n\", cc->ljs.ang);\n\tprintf(\"classic left joystick magnitude: %f\\n\", cc->ljs.mag);\n\tprintf(\"classic right joystick angle: %f\\n\", cc->rjs.ang);\n\tprintf(\"classic right joystick magnitude: %f\\n\", cc->rjs.mag);\n\t*/" ]
[ { "param": "cc", "type": "struct classic_ctrl_t" }, { "param": "msg", "type": "byte" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cc", "type": "struct classic_ctrl_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "msg", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
511ed6dd9f28520a3ba772bb3c134e0579971032
lofunz/mieme
Reloaded/trunk/src/osd/droid-ios/wiimote.c
[ "Unlicense" ]
C
classic_ctrl_pressed_buttons
void
static void classic_ctrl_pressed_buttons(struct classic_ctrl_t* cc, short now) { /* message is inverted (0 is active, 1 is inactive) */ now = ~now & CLASSIC_CTRL_BUTTON_ALL; /* buttons pressed now */ cc->btns = now; }
/** * @brief Find what buttons are pressed. * * @param cc A pointer to a classic_ctrl_t structure. * @param msg The message byte specified in the event packet. */
@brief Find what buttons are pressed. @param cc A pointer to a classic_ctrl_t structure. @param msg The message byte specified in the event packet.
[ "@brief", "Find", "what", "buttons", "are", "pressed", ".", "@param", "cc", "A", "pointer", "to", "a", "classic_ctrl_t", "structure", ".", "@param", "msg", "The", "message", "byte", "specified", "in", "the", "event", "packet", "." ]
static void classic_ctrl_pressed_buttons(struct classic_ctrl_t* cc, short now) { now = ~now & CLASSIC_CTRL_BUTTON_ALL; cc->btns = now; }
[ "static", "void", "classic_ctrl_pressed_buttons", "(", "struct", "classic_ctrl_t", "*", "cc", ",", "short", "now", ")", "{", "now", "=", "~", "now", "&", "CLASSIC_CTRL_BUTTON_ALL", ";", "cc", "->", "btns", "=", "now", ";", "}" ]
@brief Find what buttons are pressed.
[ "@brief", "Find", "what", "buttons", "are", "pressed", "." ]
[ "/* message is inverted (0 is active, 1 is inactive) */", "/* buttons pressed now */" ]
[ { "param": "cc", "type": "struct classic_ctrl_t" }, { "param": "now", "type": "short" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cc", "type": "struct classic_ctrl_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "now", "type": "short", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
405e64eb8ccf8f2575c2f803a8e2a5d041c141ba
lofunz/mieme
Reloaded/trunk/src/mame/video/kingobox.c
[ "Unlicense" ]
C
palette_init_common
void
static void palette_init_common( running_machine *machine, const UINT8 *color_prom, void (*get_rgb_data)(const UINT8 *, int, int *, int *, int *) ) { static const int resistances[4] = { 1500, 750, 360, 180 }; static const int resistances_fg[1] = { 51 }; double rweights[4], gweights[4], bweights[4]; double rweights_fg[1], gweights_fg[1], bweights_fg[1]; int i; /* compute the color output resistor weights */ double scale = compute_resistor_weights(0, 255, -1.0, 1, resistances_fg, rweights_fg, 0, 0, 1, resistances_fg, gweights_fg, 0, 0, 1, resistances_fg, bweights_fg, 0, 0); compute_resistor_weights(0, 255, scale, 4, resistances, rweights, 470, 0, 4, resistances, gweights, 470, 0, 4, resistances, bweights, 470, 0); /* allocate the colortable */ machine->colortable = colortable_alloc(machine, 0x108); for (i = 0; i < 0x100; i++) { int r_data, g_data, b_data; int bit0, bit1, bit2, bit3; int r, g, b; get_rgb_data(color_prom, i, &r_data, &g_data, &b_data); /* red component */ bit0 = (r_data >> 0) & 0x01; bit1 = (r_data >> 1) & 0x01; bit2 = (r_data >> 2) & 0x01; bit3 = (r_data >> 3) & 0x01; r = combine_4_weights(rweights, bit0, bit1, bit2, bit3); /* green component */ bit0 = (g_data >> 0) & 0x01; bit1 = (g_data >> 1) & 0x01; bit2 = (g_data >> 2) & 0x01; bit3 = (g_data >> 3) & 0x01; g = combine_4_weights(gweights, bit0, bit1, bit2, bit3); /* blue component */ bit0 = (b_data >> 0) & 0x01; bit1 = (b_data >> 1) & 0x01; bit2 = (b_data >> 2) & 0x01; bit3 = (b_data >> 3) & 0x01; b = combine_4_weights(bweights, bit0, bit1, bit2, bit3); colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b)); } /* the foreground chars directly map to primary colors */ for (i = 0x100; i < 0x108; i++) { int r, g, b; /* red component */ r = (((i - 0x100) >> 2) & 0x01) * rweights_fg[0]; /* green component */ g = (((i - 0x100) >> 1) & 0x01) * gweights_fg[0]; /* blue component */ b = (((i - 0x100) >> 0) & 0x01) * bweights_fg[0]; colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b)); } for (i = 0; i < 0x100; i++) colortable_entry_set_value(machine->colortable, i, i); for (i = 0x101; i < 0x110; i += 2) { UINT16 ctabentry = ((i - 0x101) >> 1) | 0x100; colortable_entry_set_value(machine->colortable, i, ctabentry); } }
/*************************************************************************** Convert the color PROMs into a more useable format. King of Boxer has three 256x4 palette PROMs, connected to the RGB output this way: bit 3 -- 180 ohm resistor -- RED/GREEN/BLUE -- 360 ohm resistor -- RED/GREEN/BLUE -- 750 ohm resistor -- RED/GREEN/BLUE bit 0 -- 1.5kohm resistor -- RED/GREEN/BLUE The foreground color code directly goes to the RGB output, this way: bit 5 -- 51 ohm resistor -- RED bit 4 -- 51 ohm resistor -- GREEN bit 3 -- 51 ohm resistor -- BLUE ***************************************************************************/
Convert the color PROMs into a more useable format. King of Boxer has three 256x4 palette PROMs, connected to the RGB output this way. The foreground color code directly goes to the RGB output, this way.
[ "Convert", "the", "color", "PROMs", "into", "a", "more", "useable", "format", ".", "King", "of", "Boxer", "has", "three", "256x4", "palette", "PROMs", "connected", "to", "the", "RGB", "output", "this", "way", ".", "The", "foreground", "color", "code", "directly", "goes", "to", "the", "RGB", "output", "this", "way", "." ]
static void palette_init_common( running_machine *machine, const UINT8 *color_prom, void (*get_rgb_data)(const UINT8 *, int, int *, int *, int *) ) { static const int resistances[4] = { 1500, 750, 360, 180 }; static const int resistances_fg[1] = { 51 }; double rweights[4], gweights[4], bweights[4]; double rweights_fg[1], gweights_fg[1], bweights_fg[1]; int i; double scale = compute_resistor_weights(0, 255, -1.0, 1, resistances_fg, rweights_fg, 0, 0, 1, resistances_fg, gweights_fg, 0, 0, 1, resistances_fg, bweights_fg, 0, 0); compute_resistor_weights(0, 255, scale, 4, resistances, rweights, 470, 0, 4, resistances, gweights, 470, 0, 4, resistances, bweights, 470, 0); machine->colortable = colortable_alloc(machine, 0x108); for (i = 0; i < 0x100; i++) { int r_data, g_data, b_data; int bit0, bit1, bit2, bit3; int r, g, b; get_rgb_data(color_prom, i, &r_data, &g_data, &b_data); bit0 = (r_data >> 0) & 0x01; bit1 = (r_data >> 1) & 0x01; bit2 = (r_data >> 2) & 0x01; bit3 = (r_data >> 3) & 0x01; r = combine_4_weights(rweights, bit0, bit1, bit2, bit3); bit0 = (g_data >> 0) & 0x01; bit1 = (g_data >> 1) & 0x01; bit2 = (g_data >> 2) & 0x01; bit3 = (g_data >> 3) & 0x01; g = combine_4_weights(gweights, bit0, bit1, bit2, bit3); bit0 = (b_data >> 0) & 0x01; bit1 = (b_data >> 1) & 0x01; bit2 = (b_data >> 2) & 0x01; bit3 = (b_data >> 3) & 0x01; b = combine_4_weights(bweights, bit0, bit1, bit2, bit3); colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b)); } for (i = 0x100; i < 0x108; i++) { int r, g, b; r = (((i - 0x100) >> 2) & 0x01) * rweights_fg[0]; g = (((i - 0x100) >> 1) & 0x01) * gweights_fg[0]; b = (((i - 0x100) >> 0) & 0x01) * bweights_fg[0]; colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b)); } for (i = 0; i < 0x100; i++) colortable_entry_set_value(machine->colortable, i, i); for (i = 0x101; i < 0x110; i += 2) { UINT16 ctabentry = ((i - 0x101) >> 1) | 0x100; colortable_entry_set_value(machine->colortable, i, ctabentry); } }
[ "static", "void", "palette_init_common", "(", "running_machine", "*", "machine", ",", "const", "UINT8", "*", "color_prom", ",", "void", "(", "*", "get_rgb_data", ")", "(", "const", "UINT8", "*", ",", "int", ",", "int", "*", ",", "int", "*", ",", "int", "*", ")", ")", "{", "static", "const", "int", "resistances", "[", "4", "]", "=", "{", "1500", ",", "750", ",", "360", ",", "180", "}", ";", "static", "const", "int", "resistances_fg", "[", "1", "]", "=", "{", "51", "}", ";", "double", "rweights", "[", "4", "]", ",", "gweights", "[", "4", "]", ",", "bweights", "[", "4", "]", ";", "double", "rweights_fg", "[", "1", "]", ",", "gweights_fg", "[", "1", "]", ",", "bweights_fg", "[", "1", "]", ";", "int", "i", ";", "double", "scale", "=", "compute_resistor_weights", "(", "0", ",", "255", ",", "-1.0", ",", "1", ",", "resistances_fg", ",", "rweights_fg", ",", "0", ",", "0", ",", "1", ",", "resistances_fg", ",", "gweights_fg", ",", "0", ",", "0", ",", "1", ",", "resistances_fg", ",", "bweights_fg", ",", "0", ",", "0", ")", ";", "compute_resistor_weights", "(", "0", ",", "255", ",", "scale", ",", "4", ",", "resistances", ",", "rweights", ",", "470", ",", "0", ",", "4", ",", "resistances", ",", "gweights", ",", "470", ",", "0", ",", "4", ",", "resistances", ",", "bweights", ",", "470", ",", "0", ")", ";", "machine", "->", "colortable", "=", "colortable_alloc", "(", "machine", ",", "0x108", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "0x100", ";", "i", "++", ")", "{", "int", "r_data", ",", "g_data", ",", "b_data", ";", "int", "bit0", ",", "bit1", ",", "bit2", ",", "bit3", ";", "int", "r", ",", "g", ",", "b", ";", "get_rgb_data", "(", "color_prom", ",", "i", ",", "&", "r_data", ",", "&", "g_data", ",", "&", "b_data", ")", ";", "bit0", "=", "(", "r_data", ">>", "0", ")", "&", "0x01", ";", "bit1", "=", "(", "r_data", ">>", "1", ")", "&", "0x01", ";", "bit2", "=", "(", "r_data", ">>", "2", ")", "&", "0x01", ";", "bit3", "=", "(", "r_data", ">>", "3", ")", "&", "0x01", ";", "r", "=", "combine_4_weights", "(", "rweights", ",", "bit0", ",", "bit1", ",", "bit2", ",", "bit3", ")", ";", "bit0", "=", "(", "g_data", ">>", "0", ")", "&", "0x01", ";", "bit1", "=", "(", "g_data", ">>", "1", ")", "&", "0x01", ";", "bit2", "=", "(", "g_data", ">>", "2", ")", "&", "0x01", ";", "bit3", "=", "(", "g_data", ">>", "3", ")", "&", "0x01", ";", "g", "=", "combine_4_weights", "(", "gweights", ",", "bit0", ",", "bit1", ",", "bit2", ",", "bit3", ")", ";", "bit0", "=", "(", "b_data", ">>", "0", ")", "&", "0x01", ";", "bit1", "=", "(", "b_data", ">>", "1", ")", "&", "0x01", ";", "bit2", "=", "(", "b_data", ">>", "2", ")", "&", "0x01", ";", "bit3", "=", "(", "b_data", ">>", "3", ")", "&", "0x01", ";", "b", "=", "combine_4_weights", "(", "bweights", ",", "bit0", ",", "bit1", ",", "bit2", ",", "bit3", ")", ";", "colortable_palette_set_color", "(", "machine", "->", "colortable", ",", "i", ",", "MAKE_RGB", "(", "r", ",", "g", ",", "b", ")", ")", ";", "}", "for", "(", "i", "=", "0x100", ";", "i", "<", "0x108", ";", "i", "++", ")", "{", "int", "r", ",", "g", ",", "b", ";", "r", "=", "(", "(", "(", "i", "-", "0x100", ")", ">>", "2", ")", "&", "0x01", ")", "*", "rweights_fg", "[", "0", "]", ";", "g", "=", "(", "(", "(", "i", "-", "0x100", ")", ">>", "1", ")", "&", "0x01", ")", "*", "gweights_fg", "[", "0", "]", ";", "b", "=", "(", "(", "(", "i", "-", "0x100", ")", ">>", "0", ")", "&", "0x01", ")", "*", "bweights_fg", "[", "0", "]", ";", "colortable_palette_set_color", "(", "machine", "->", "colortable", ",", "i", ",", "MAKE_RGB", "(", "r", ",", "g", ",", "b", ")", ")", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "0x100", ";", "i", "++", ")", "colortable_entry_set_value", "(", "machine", "->", "colortable", ",", "i", ",", "i", ")", ";", "for", "(", "i", "=", "0x101", ";", "i", "<", "0x110", ";", "i", "+=", "2", ")", "{", "UINT16", "ctabentry", "=", "(", "(", "i", "-", "0x101", ")", ">>", "1", ")", "|", "0x100", ";", "colortable_entry_set_value", "(", "machine", "->", "colortable", ",", "i", ",", "ctabentry", ")", ";", "}", "}" ]
Convert the color PROMs into a more useable format.
[ "Convert", "the", "color", "PROMs", "into", "a", "more", "useable", "format", "." ]
[ "/* compute the color output resistor weights */", "/* allocate the colortable */", "/* red component */", "/* green component */", "/* blue component */", "/* the foreground chars directly map to primary colors */", "/* red component */", "/* green component */", "/* blue component */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "color_prom", "type": "UINT8" }, { "param": "get_rgb_data", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "color_prom", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "get_rgb_data", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
61229dab92c0d40938b633af4078905c002b97c9
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/neoboot.c
[ "Unlicense" ]
C
neogeo_bootleg_cx_decrypt
void
void neogeo_bootleg_cx_decrypt( running_machine *machine ) { int i; int cx_size = memory_region_length( machine, "sprites" ); UINT8 *rom = memory_region( machine, "sprites" ); UINT8 *buf = alloc_array_or_die(UINT8, cx_size ); memcpy( buf, rom, cx_size ); for( i = 0; i < cx_size / 0x40; i++ ){ memcpy( &rom[ i * 0x40 ], &buf[ (i ^ 1) * 0x40 ], 0x40 ); } free( buf ); }
/* General Bootleg Functions - used by more than 1 game */
General Bootleg Functions - used by more than 1 game
[ "General", "Bootleg", "Functions", "-", "used", "by", "more", "than", "1", "game" ]
void neogeo_bootleg_cx_decrypt( running_machine *machine ) { int i; int cx_size = memory_region_length( machine, "sprites" ); UINT8 *rom = memory_region( machine, "sprites" ); UINT8 *buf = alloc_array_or_die(UINT8, cx_size ); memcpy( buf, rom, cx_size ); for( i = 0; i < cx_size / 0x40; i++ ){ memcpy( &rom[ i * 0x40 ], &buf[ (i ^ 1) * 0x40 ], 0x40 ); } free( buf ); }
[ "void", "neogeo_bootleg_cx_decrypt", "(", "running_machine", "*", "machine", ")", "{", "int", "i", ";", "int", "cx_size", "=", "memory_region_length", "(", "machine", ",", "\"", "\"", ")", ";", "UINT8", "*", "rom", "=", "memory_region", "(", "machine", ",", "\"", "\"", ")", ";", "UINT8", "*", "buf", "=", "alloc_array_or_die", "(", "UINT8", ",", "cx_size", ")", ";", "memcpy", "(", "buf", ",", "rom", ",", "cx_size", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "cx_size", "/", "0x40", ";", "i", "++", ")", "{", "memcpy", "(", "&", "rom", "[", "i", "*", "0x40", "]", ",", "&", "buf", "[", "(", "i", "^", "1", ")", "*", "0x40", "]", ",", "0x40", ")", ";", "}", "free", "(", "buf", ")", ";", "}" ]
General Bootleg Functions - used by more than 1 game
[ "General", "Bootleg", "Functions", "-", "used", "by", "more", "than", "1", "game" ]
[]
[ { "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": [] }
61229dab92c0d40938b633af4078905c002b97c9
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/neoboot.c
[ "Unlicense" ]
C
kog_px_decrypt
void
void kog_px_decrypt( running_machine *machine ) { /* the protection chip does some *very* strange things to the rom */ UINT8 *src = memory_region(machine, "maincpu"); UINT8 *dst = alloc_array_or_die(UINT8, 0x600000 ); UINT16 *rom = (UINT16 *)memory_region(machine, "maincpu"); int i; static const int sec[] = { 0x3, 0x8, 0x7, 0xC, 0x1, 0xA, 0x6, 0xD }; for (i = 0; i < 8; i++){ memcpy (dst + i * 0x20000, src + sec[i] * 0x20000, 0x20000); } memcpy (dst + 0x0007A6, src + 0x0407A6, 0x000006); memcpy (dst + 0x0007C6, src + 0x0407C6, 0x000006); memcpy (dst + 0x0007E6, src + 0x0407E6, 0x000006); memcpy (dst + 0x090000, src + 0x040000, 0x004000); memcpy (dst + 0x100000, src + 0x200000, 0x400000); memcpy (src, dst, 0x600000); free (dst); for (i = 0x90000/2; i < 0x94000/2; i++){ if (((rom[i]&0xFFBF) == 0x4EB9 || rom[i] == 0x43F9) && !rom[i + 1]) rom[i + 1] = 0x0009; if (rom[i] == 0x4EB8) rom[i] = 0x6100; } rom[0x007A8/2] = 0x0009; rom[0x007C8/2] = 0x0009; rom[0x007E8/2] = 0x0009; rom[0x93408/2] = 0xF168; rom[0x9340C/2] = 0xFB7A; rom[0x924AC/2] = 0x0009; rom[0x9251C/2] = 0x0009; rom[0x93966/2] = 0xFFDA; rom[0x93974/2] = 0xFFCC; rom[0x93982/2] = 0xFFBE; rom[0x93990/2] = 0xFFB0; rom[0x9399E/2] = 0xFFA2; rom[0x939AC/2] = 0xFF94; rom[0x939BA/2] = 0xFF86; rom[0x939C8/2] = 0xFF78; rom[0x939D4/2] = 0xFA5C; rom[0x939E0/2] = 0xFA50; rom[0x939EC/2] = 0xFA44; rom[0x939F8/2] = 0xFA38; rom[0x93A04/2] = 0xFA2C; rom[0x93A10/2] = 0xFA20; rom[0x93A1C/2] = 0xFA14; rom[0x93A28/2] = 0xFA08; rom[0x93A34/2] = 0xF9FC; rom[0x93A40/2] = 0xF9F0; rom[0x93A4C/2] = 0xFD14; rom[0x93A58/2] = 0xFD08; rom[0x93A66/2] = 0xF9CA; rom[0x93A72/2] = 0xF9BE; }
/* The protection patching here may be incomplete Thanks to Razoola for the info */
The protection patching here may be incomplete Thanks to Razoola for the info
[ "The", "protection", "patching", "here", "may", "be", "incomplete", "Thanks", "to", "Razoola", "for", "the", "info" ]
void kog_px_decrypt( running_machine *machine ) { UINT8 *src = memory_region(machine, "maincpu"); UINT8 *dst = alloc_array_or_die(UINT8, 0x600000 ); UINT16 *rom = (UINT16 *)memory_region(machine, "maincpu"); int i; static const int sec[] = { 0x3, 0x8, 0x7, 0xC, 0x1, 0xA, 0x6, 0xD }; for (i = 0; i < 8; i++){ memcpy (dst + i * 0x20000, src + sec[i] * 0x20000, 0x20000); } memcpy (dst + 0x0007A6, src + 0x0407A6, 0x000006); memcpy (dst + 0x0007C6, src + 0x0407C6, 0x000006); memcpy (dst + 0x0007E6, src + 0x0407E6, 0x000006); memcpy (dst + 0x090000, src + 0x040000, 0x004000); memcpy (dst + 0x100000, src + 0x200000, 0x400000); memcpy (src, dst, 0x600000); free (dst); for (i = 0x90000/2; i < 0x94000/2; i++){ if (((rom[i]&0xFFBF) == 0x4EB9 || rom[i] == 0x43F9) && !rom[i + 1]) rom[i + 1] = 0x0009; if (rom[i] == 0x4EB8) rom[i] = 0x6100; } rom[0x007A8/2] = 0x0009; rom[0x007C8/2] = 0x0009; rom[0x007E8/2] = 0x0009; rom[0x93408/2] = 0xF168; rom[0x9340C/2] = 0xFB7A; rom[0x924AC/2] = 0x0009; rom[0x9251C/2] = 0x0009; rom[0x93966/2] = 0xFFDA; rom[0x93974/2] = 0xFFCC; rom[0x93982/2] = 0xFFBE; rom[0x93990/2] = 0xFFB0; rom[0x9399E/2] = 0xFFA2; rom[0x939AC/2] = 0xFF94; rom[0x939BA/2] = 0xFF86; rom[0x939C8/2] = 0xFF78; rom[0x939D4/2] = 0xFA5C; rom[0x939E0/2] = 0xFA50; rom[0x939EC/2] = 0xFA44; rom[0x939F8/2] = 0xFA38; rom[0x93A04/2] = 0xFA2C; rom[0x93A10/2] = 0xFA20; rom[0x93A1C/2] = 0xFA14; rom[0x93A28/2] = 0xFA08; rom[0x93A34/2] = 0xF9FC; rom[0x93A40/2] = 0xF9F0; rom[0x93A4C/2] = 0xFD14; rom[0x93A58/2] = 0xFD08; rom[0x93A66/2] = 0xF9CA; rom[0x93A72/2] = 0xF9BE; }
[ "void", "kog_px_decrypt", "(", "running_machine", "*", "machine", ")", "{", "UINT8", "*", "src", "=", "memory_region", "(", "machine", ",", "\"", "\"", ")", ";", "UINT8", "*", "dst", "=", "alloc_array_or_die", "(", "UINT8", ",", "0x600000", ")", ";", "UINT16", "*", "rom", "=", "(", "UINT16", "*", ")", "memory_region", "(", "machine", ",", "\"", "\"", ")", ";", "int", "i", ";", "static", "const", "int", "sec", "[", "]", "=", "{", "0x3", ",", "0x8", ",", "0x7", ",", "0xC", ",", "0x1", ",", "0xA", ",", "0x6", ",", "0xD", "}", ";", "for", "(", "i", "=", "0", ";", "i", "<", "8", ";", "i", "++", ")", "{", "memcpy", "(", "dst", "+", "i", "*", "0x20000", ",", "src", "+", "sec", "[", "i", "]", "*", "0x20000", ",", "0x20000", ")", ";", "}", "memcpy", "(", "dst", "+", "0x0007A6", ",", "src", "+", "0x0407A6", ",", "0x000006", ")", ";", "memcpy", "(", "dst", "+", "0x0007C6", ",", "src", "+", "0x0407C6", ",", "0x000006", ")", ";", "memcpy", "(", "dst", "+", "0x0007E6", ",", "src", "+", "0x0407E6", ",", "0x000006", ")", ";", "memcpy", "(", "dst", "+", "0x090000", ",", "src", "+", "0x040000", ",", "0x004000", ")", ";", "memcpy", "(", "dst", "+", "0x100000", ",", "src", "+", "0x200000", ",", "0x400000", ")", ";", "memcpy", "(", "src", ",", "dst", ",", "0x600000", ")", ";", "free", "(", "dst", ")", ";", "for", "(", "i", "=", "0x90000", "/", "2", ";", "i", "<", "0x94000", "/", "2", ";", "i", "++", ")", "{", "if", "(", "(", "(", "rom", "[", "i", "]", "&", "0xFFBF", ")", "==", "0x4EB9", "||", "rom", "[", "i", "]", "==", "0x43F9", ")", "&&", "!", "rom", "[", "i", "+", "1", "]", ")", "rom", "[", "i", "+", "1", "]", "=", "0x0009", ";", "if", "(", "rom", "[", "i", "]", "==", "0x4EB8", ")", "rom", "[", "i", "]", "=", "0x6100", ";", "}", "rom", "[", "0x007A8", "/", "2", "]", "=", "0x0009", ";", "rom", "[", "0x007C8", "/", "2", "]", "=", "0x0009", ";", "rom", "[", "0x007E8", "/", "2", "]", "=", "0x0009", ";", "rom", "[", "0x93408", "/", "2", "]", "=", "0xF168", ";", "rom", "[", "0x9340C", "/", "2", "]", "=", "0xFB7A", ";", "rom", "[", "0x924AC", "/", "2", "]", "=", "0x0009", ";", "rom", "[", "0x9251C", "/", "2", "]", "=", "0x0009", ";", "rom", "[", "0x93966", "/", "2", "]", "=", "0xFFDA", ";", "rom", "[", "0x93974", "/", "2", "]", "=", "0xFFCC", ";", "rom", "[", "0x93982", "/", "2", "]", "=", "0xFFBE", ";", "rom", "[", "0x93990", "/", "2", "]", "=", "0xFFB0", ";", "rom", "[", "0x9399E", "/", "2", "]", "=", "0xFFA2", ";", "rom", "[", "0x939AC", "/", "2", "]", "=", "0xFF94", ";", "rom", "[", "0x939BA", "/", "2", "]", "=", "0xFF86", ";", "rom", "[", "0x939C8", "/", "2", "]", "=", "0xFF78", ";", "rom", "[", "0x939D4", "/", "2", "]", "=", "0xFA5C", ";", "rom", "[", "0x939E0", "/", "2", "]", "=", "0xFA50", ";", "rom", "[", "0x939EC", "/", "2", "]", "=", "0xFA44", ";", "rom", "[", "0x939F8", "/", "2", "]", "=", "0xFA38", ";", "rom", "[", "0x93A04", "/", "2", "]", "=", "0xFA2C", ";", "rom", "[", "0x93A10", "/", "2", "]", "=", "0xFA20", ";", "rom", "[", "0x93A1C", "/", "2", "]", "=", "0xFA14", ";", "rom", "[", "0x93A28", "/", "2", "]", "=", "0xFA08", ";", "rom", "[", "0x93A34", "/", "2", "]", "=", "0xF9FC", ";", "rom", "[", "0x93A40", "/", "2", "]", "=", "0xF9F0", ";", "rom", "[", "0x93A4C", "/", "2", "]", "=", "0xFD14", ";", "rom", "[", "0x93A58", "/", "2", "]", "=", "0xFD08", ";", "rom", "[", "0x93A66", "/", "2", "]", "=", "0xF9CA", ";", "rom", "[", "0x93A72", "/", "2", "]", "=", "0xF9BE", ";", "}" ]
The protection patching here may be incomplete Thanks to Razoola for the info
[ "The", "protection", "patching", "here", "may", "be", "incomplete", "Thanks", "to", "Razoola", "for", "the", "info" ]
[ "/* the protection chip does some *very* strange things to the rom */" ]
[ { "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": [] }
61229dab92c0d40938b633af4078905c002b97c9
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/neoboot.c
[ "Unlicense" ]
C
decrypt_kf10thep
void
void decrypt_kf10thep(running_machine *machine) { int i; UINT16 *rom = (UINT16*)memory_region(machine, "maincpu"); UINT8 *src = memory_region(machine, "maincpu"); UINT16 *buf = (UINT16*)memory_region(machine, "audiocrypt"); UINT8 *srom = (UINT8*)memory_region(machine, "fixed"); UINT8 *sbuf = alloc_array_or_die(UINT8, 0x20000); UINT8 *dst = alloc_array_or_die(UINT8, 0x200000); memcpy(dst,buf,0x200000); memcpy(src+0x000000,dst+0x060000,0x20000); memcpy(src+0x020000,dst+0x100000,0x20000); memcpy(src+0x040000,dst+0x0e0000,0x20000); memcpy(src+0x060000,dst+0x180000,0x20000); memcpy(src+0x080000,dst+0x020000,0x20000); memcpy(src+0x0a0000,dst+0x140000,0x20000); memcpy(src+0x0c0000,dst+0x0c0000,0x20000); memcpy(src+0x0e0000,dst+0x1a0000,0x20000); memcpy(src+0x0002e0,dst+0x0402e0,0x6a); // copy banked code to a new memory region memcpy(src+0x0f92bc,dst+0x0492bc,0xb9e); // copy banked code to a new memory region for (i=0xf92bc/2;i < 0xf9e58/2 ;i++) { if (rom[i+0] == 0x4eb9 && rom[i+1] == 0x0000) rom[i+1] = 0x000F; // correct JSR in moved code if (rom[i+0] == 0x4ef9 && rom[i+1] == 0x0000) rom[i+1] = 0x000F; // correct JMP in moved code } rom[0x00342/2] = 0x000f; free(dst); for (i=0;i<0x20000;i++) sbuf[i]=srom[i^0x8]; memcpy(srom,sbuf,0x20000); free(sbuf); }
/* The King of Fighters 10th Anniversary Extra Plus (The King of Fighters 2002 bootleg) */
The King of Fighters 10th Anniversary Extra Plus (The King of Fighters 2002 bootleg)
[ "The", "King", "of", "Fighters", "10th", "Anniversary", "Extra", "Plus", "(", "The", "King", "of", "Fighters", "2002", "bootleg", ")" ]
void decrypt_kf10thep(running_machine *machine) { int i; UINT16 *rom = (UINT16*)memory_region(machine, "maincpu"); UINT8 *src = memory_region(machine, "maincpu"); UINT16 *buf = (UINT16*)memory_region(machine, "audiocrypt"); UINT8 *srom = (UINT8*)memory_region(machine, "fixed"); UINT8 *sbuf = alloc_array_or_die(UINT8, 0x20000); UINT8 *dst = alloc_array_or_die(UINT8, 0x200000); memcpy(dst,buf,0x200000); memcpy(src+0x000000,dst+0x060000,0x20000); memcpy(src+0x020000,dst+0x100000,0x20000); memcpy(src+0x040000,dst+0x0e0000,0x20000); memcpy(src+0x060000,dst+0x180000,0x20000); memcpy(src+0x080000,dst+0x020000,0x20000); memcpy(src+0x0a0000,dst+0x140000,0x20000); memcpy(src+0x0c0000,dst+0x0c0000,0x20000); memcpy(src+0x0e0000,dst+0x1a0000,0x20000); memcpy(src+0x0002e0,dst+0x0402e0,0x6a); memcpy(src+0x0f92bc,dst+0x0492bc,0xb9e); for (i=0xf92bc/2;i < 0xf9e58/2 ;i++) { if (rom[i+0] == 0x4eb9 && rom[i+1] == 0x0000) rom[i+1] = 0x000F; if (rom[i+0] == 0x4ef9 && rom[i+1] == 0x0000) rom[i+1] = 0x000F; } rom[0x00342/2] = 0x000f; free(dst); for (i=0;i<0x20000;i++) sbuf[i]=srom[i^0x8]; memcpy(srom,sbuf,0x20000); free(sbuf); }
[ "void", "decrypt_kf10thep", "(", "running_machine", "*", "machine", ")", "{", "int", "i", ";", "UINT16", "*", "rom", "=", "(", "UINT16", "*", ")", "memory_region", "(", "machine", ",", "\"", "\"", ")", ";", "UINT8", "*", "src", "=", "memory_region", "(", "machine", ",", "\"", "\"", ")", ";", "UINT16", "*", "buf", "=", "(", "UINT16", "*", ")", "memory_region", "(", "machine", ",", "\"", "\"", ")", ";", "UINT8", "*", "srom", "=", "(", "UINT8", "*", ")", "memory_region", "(", "machine", ",", "\"", "\"", ")", ";", "UINT8", "*", "sbuf", "=", "alloc_array_or_die", "(", "UINT8", ",", "0x20000", ")", ";", "UINT8", "*", "dst", "=", "alloc_array_or_die", "(", "UINT8", ",", "0x200000", ")", ";", "memcpy", "(", "dst", ",", "buf", ",", "0x200000", ")", ";", "memcpy", "(", "src", "+", "0x000000", ",", "dst", "+", "0x060000", ",", "0x20000", ")", ";", "memcpy", "(", "src", "+", "0x020000", ",", "dst", "+", "0x100000", ",", "0x20000", ")", ";", "memcpy", "(", "src", "+", "0x040000", ",", "dst", "+", "0x0e0000", ",", "0x20000", ")", ";", "memcpy", "(", "src", "+", "0x060000", ",", "dst", "+", "0x180000", ",", "0x20000", ")", ";", "memcpy", "(", "src", "+", "0x080000", ",", "dst", "+", "0x020000", ",", "0x20000", ")", ";", "memcpy", "(", "src", "+", "0x0a0000", ",", "dst", "+", "0x140000", ",", "0x20000", ")", ";", "memcpy", "(", "src", "+", "0x0c0000", ",", "dst", "+", "0x0c0000", ",", "0x20000", ")", ";", "memcpy", "(", "src", "+", "0x0e0000", ",", "dst", "+", "0x1a0000", ",", "0x20000", ")", ";", "memcpy", "(", "src", "+", "0x0002e0", ",", "dst", "+", "0x0402e0", ",", "0x6a", ")", ";", "memcpy", "(", "src", "+", "0x0f92bc", ",", "dst", "+", "0x0492bc", ",", "0xb9e", ")", ";", "for", "(", "i", "=", "0xf92bc", "/", "2", ";", "i", "<", "0xf9e58", "/", "2", ";", "i", "++", ")", "{", "if", "(", "rom", "[", "i", "+", "0", "]", "==", "0x4eb9", "&&", "rom", "[", "i", "+", "1", "]", "==", "0x0000", ")", "rom", "[", "i", "+", "1", "]", "=", "0x000F", ";", "if", "(", "rom", "[", "i", "+", "0", "]", "==", "0x4ef9", "&&", "rom", "[", "i", "+", "1", "]", "==", "0x0000", ")", "rom", "[", "i", "+", "1", "]", "=", "0x000F", ";", "}", "rom", "[", "0x00342", "/", "2", "]", "=", "0x000f", ";", "free", "(", "dst", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "0x20000", ";", "i", "++", ")", "sbuf", "[", "i", "]", "=", "srom", "[", "i", "^", "0x8", "]", ";", "memcpy", "(", "srom", ",", "sbuf", ",", "0x20000", ")", ";", "free", "(", "sbuf", ")", ";", "}" ]
The King of Fighters 10th Anniversary Extra Plus (The King of Fighters 2002 bootleg)
[ "The", "King", "of", "Fighters", "10th", "Anniversary", "Extra", "Plus", "(", "The", "King", "of", "Fighters", "2002", "bootleg", ")" ]
[ "// copy banked code to a new memory region", "// copy banked code to a new memory region", "// correct JSR in moved code", "// correct JMP in moved code" ]
[ { "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": [] }
61229dab92c0d40938b633af4078905c002b97c9
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/neoboot.c
[ "Unlicense" ]
C
kf2k5uni_px_decrypt
void
static void kf2k5uni_px_decrypt( running_machine *machine ) { int i, j, ofst; UINT8 *src = memory_region( machine, "maincpu" ); UINT8 *dst = alloc_array_or_die(UINT8, 0x80); for (i = 0; i < 0x800000; i+=0x80) { for (j = 0; j < 0x80; j+=2) { ofst = BITSWAP8(j, 0, 3, 4, 5, 6, 1, 2, 7); memcpy(dst + j, src + i + ofst, 2); } memcpy(src + i, dst, 0x80); } free(dst); memcpy(src, src + 0x600000, 0x100000); // Seems to be the same as kof10th }
/* The King of Fighters 10th Anniversary 2005 Unique (The King of Fighters 2002 bootleg) */
The King of Fighters 10th Anniversary 2005 Unique (The King of Fighters 2002 bootleg)
[ "The", "King", "of", "Fighters", "10th", "Anniversary", "2005", "Unique", "(", "The", "King", "of", "Fighters", "2002", "bootleg", ")" ]
static void kf2k5uni_px_decrypt( running_machine *machine ) { int i, j, ofst; UINT8 *src = memory_region( machine, "maincpu" ); UINT8 *dst = alloc_array_or_die(UINT8, 0x80); for (i = 0; i < 0x800000; i+=0x80) { for (j = 0; j < 0x80; j+=2) { ofst = BITSWAP8(j, 0, 3, 4, 5, 6, 1, 2, 7); memcpy(dst + j, src + i + ofst, 2); } memcpy(src + i, dst, 0x80); } free(dst); memcpy(src, src + 0x600000, 0x100000); }
[ "static", "void", "kf2k5uni_px_decrypt", "(", "running_machine", "*", "machine", ")", "{", "int", "i", ",", "j", ",", "ofst", ";", "UINT8", "*", "src", "=", "memory_region", "(", "machine", ",", "\"", "\"", ")", ";", "UINT8", "*", "dst", "=", "alloc_array_or_die", "(", "UINT8", ",", "0x80", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "0x800000", ";", "i", "+=", "0x80", ")", "{", "for", "(", "j", "=", "0", ";", "j", "<", "0x80", ";", "j", "+=", "2", ")", "{", "ofst", "=", "BITSWAP8", "(", "j", ",", "0", ",", "3", ",", "4", ",", "5", ",", "6", ",", "1", ",", "2", ",", "7", ")", ";", "memcpy", "(", "dst", "+", "j", ",", "src", "+", "i", "+", "ofst", ",", "2", ")", ";", "}", "memcpy", "(", "src", "+", "i", ",", "dst", ",", "0x80", ")", ";", "}", "free", "(", "dst", ")", ";", "memcpy", "(", "src", ",", "src", "+", "0x600000", ",", "0x100000", ")", ";", "}" ]
The King of Fighters 10th Anniversary 2005 Unique (The King of Fighters 2002 bootleg)
[ "The", "King", "of", "Fighters", "10th", "Anniversary", "2005", "Unique", "(", "The", "King", "of", "Fighters", "2002", "bootleg", ")" ]
[ "// Seems to be the same as kof10th" ]
[ { "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": [] }
61229dab92c0d40938b633af4078905c002b97c9
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/neoboot.c
[ "Unlicense" ]
C
kof2002b_gfx_decrypt
void
void kof2002b_gfx_decrypt(running_machine *machine, UINT8 *src, int size) { int i, j; int t[ 8 ][ 10 ] = { { 0, 8, 7, 3, 4, 5, 6, 2, 1 }, { 1, 0, 8, 4, 5, 3, 7, 6, 2 }, { 2, 1, 0, 3, 4, 5, 8, 7, 6 }, { 6, 2, 1, 5, 3, 4, 0, 8, 7 }, { 7, 6, 2, 5, 3, 4, 1, 0, 8 }, { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, { 2, 1, 0, 4, 5, 3, 6, 7, 8 }, { 8, 0, 7, 3, 4, 5, 6, 2, 1 }, }; UINT8 *dst = alloc_array_or_die(UINT8, 0x10000 ); for ( i = 0; i < size; i+=0x10000 ) { memcpy( dst, src+i, 0x10000 ); for ( j = 0; j < 0x200; j++ ) { int n = (( j % 0x40) / 8 ); int ofst = BITSWAP16(j, 15, 14, 13, 12, 11, 10, 9, t[n][0], t[n][1], t[n][2], t[n][3], t[n][4], t[n][5], t[n][6], t[n][7], t[n][8]); memcpy( src+i+ofst*128, dst+j*128, 128 ); } } free( dst ); }
// Thanks to IQ_132 for the info
Thanks to IQ_132 for the info
[ "Thanks", "to", "IQ_132", "for", "the", "info" ]
void kof2002b_gfx_decrypt(running_machine *machine, UINT8 *src, int size) { int i, j; int t[ 8 ][ 10 ] = { { 0, 8, 7, 3, 4, 5, 6, 2, 1 }, { 1, 0, 8, 4, 5, 3, 7, 6, 2 }, { 2, 1, 0, 3, 4, 5, 8, 7, 6 }, { 6, 2, 1, 5, 3, 4, 0, 8, 7 }, { 7, 6, 2, 5, 3, 4, 1, 0, 8 }, { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, { 2, 1, 0, 4, 5, 3, 6, 7, 8 }, { 8, 0, 7, 3, 4, 5, 6, 2, 1 }, }; UINT8 *dst = alloc_array_or_die(UINT8, 0x10000 ); for ( i = 0; i < size; i+=0x10000 ) { memcpy( dst, src+i, 0x10000 ); for ( j = 0; j < 0x200; j++ ) { int n = (( j % 0x40) / 8 ); int ofst = BITSWAP16(j, 15, 14, 13, 12, 11, 10, 9, t[n][0], t[n][1], t[n][2], t[n][3], t[n][4], t[n][5], t[n][6], t[n][7], t[n][8]); memcpy( src+i+ofst*128, dst+j*128, 128 ); } } free( dst ); }
[ "void", "kof2002b_gfx_decrypt", "(", "running_machine", "*", "machine", ",", "UINT8", "*", "src", ",", "int", "size", ")", "{", "int", "i", ",", "j", ";", "int", "t", "[", "8", "]", "[", "10", "]", "=", "{", "{", "0", ",", "8", ",", "7", ",", "3", ",", "4", ",", "5", ",", "6", ",", "2", ",", "1", "}", ",", "{", "1", ",", "0", ",", "8", ",", "4", ",", "5", ",", "3", ",", "7", ",", "6", ",", "2", "}", ",", "{", "2", ",", "1", ",", "0", ",", "3", ",", "4", ",", "5", ",", "8", ",", "7", ",", "6", "}", ",", "{", "6", ",", "2", ",", "1", ",", "5", ",", "3", ",", "4", ",", "0", ",", "8", ",", "7", "}", ",", "{", "7", ",", "6", ",", "2", ",", "5", ",", "3", ",", "4", ",", "1", ",", "0", ",", "8", "}", ",", "{", "0", ",", "1", ",", "2", ",", "3", ",", "4", ",", "5", ",", "6", ",", "7", ",", "8", "}", ",", "{", "2", ",", "1", ",", "0", ",", "4", ",", "5", ",", "3", ",", "6", ",", "7", ",", "8", "}", ",", "{", "8", ",", "0", ",", "7", ",", "3", ",", "4", ",", "5", ",", "6", ",", "2", ",", "1", "}", ",", "}", ";", "UINT8", "*", "dst", "=", "alloc_array_or_die", "(", "UINT8", ",", "0x10000", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "size", ";", "i", "+=", "0x10000", ")", "{", "memcpy", "(", "dst", ",", "src", "+", "i", ",", "0x10000", ")", ";", "for", "(", "j", "=", "0", ";", "j", "<", "0x200", ";", "j", "++", ")", "{", "int", "n", "=", "(", "(", "j", "%", "0x40", ")", "/", "8", ")", ";", "int", "ofst", "=", "BITSWAP16", "(", "j", ",", "15", ",", "14", ",", "13", ",", "12", ",", "11", ",", "10", ",", "9", ",", "t", "[", "n", "]", "[", "0", "]", ",", "t", "[", "n", "]", "[", "1", "]", ",", "t", "[", "n", "]", "[", "2", "]", ",", "t", "[", "n", "]", "[", "3", "]", ",", "t", "[", "n", "]", "[", "4", "]", ",", "t", "[", "n", "]", "[", "5", "]", ",", "t", "[", "n", "]", "[", "6", "]", ",", "t", "[", "n", "]", "[", "7", "]", ",", "t", "[", "n", "]", "[", "8", "]", ")", ";", "memcpy", "(", "src", "+", "i", "+", "ofst", "*", "128", ",", "dst", "+", "j", "*", "128", ",", "128", ")", ";", "}", "}", "free", "(", "dst", ")", ";", "}" ]
Thanks to IQ_132 for the info
[ "Thanks", "to", "IQ_132", "for", "the", "info" ]
[]
[ { "param": "machine", "type": "running_machine" }, { "param": "src", "type": "UINT8" }, { "param": "size", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "src", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
61229dab92c0d40938b633af4078905c002b97c9
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/neoboot.c
[ "Unlicense" ]
C
decrypt_kof2k4se_68k
void
void decrypt_kof2k4se_68k( running_machine *machine ) { UINT8 *src = memory_region(machine, "maincpu")+0x100000; UINT8 *dst = alloc_array_or_die(UINT8, 0x400000); int i; static const int sec[] = {0x300000,0x200000,0x100000,0x000000}; memcpy(dst,src,0x400000); for(i = 0; i < 4; ++i) { memcpy(src+i*0x100000,dst+sec[i],0x100000); } free(dst); }
/* King of Fighters Special Edition 2004 (bootleg of King of Fighters 2002) */
King of Fighters Special Edition 2004 (bootleg of King of Fighters 2002)
[ "King", "of", "Fighters", "Special", "Edition", "2004", "(", "bootleg", "of", "King", "of", "Fighters", "2002", ")" ]
void decrypt_kof2k4se_68k( running_machine *machine ) { UINT8 *src = memory_region(machine, "maincpu")+0x100000; UINT8 *dst = alloc_array_or_die(UINT8, 0x400000); int i; static const int sec[] = {0x300000,0x200000,0x100000,0x000000}; memcpy(dst,src,0x400000); for(i = 0; i < 4; ++i) { memcpy(src+i*0x100000,dst+sec[i],0x100000); } free(dst); }
[ "void", "decrypt_kof2k4se_68k", "(", "running_machine", "*", "machine", ")", "{", "UINT8", "*", "src", "=", "memory_region", "(", "machine", ",", "\"", "\"", ")", "+", "0x100000", ";", "UINT8", "*", "dst", "=", "alloc_array_or_die", "(", "UINT8", ",", "0x400000", ")", ";", "int", "i", ";", "static", "const", "int", "sec", "[", "]", "=", "{", "0x300000", ",", "0x200000", ",", "0x100000", ",", "0x000000", "}", ";", "memcpy", "(", "dst", ",", "src", ",", "0x400000", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "4", ";", "++", "i", ")", "{", "memcpy", "(", "src", "+", "i", "*", "0x100000", ",", "dst", "+", "sec", "[", "i", "]", ",", "0x100000", ")", ";", "}", "free", "(", "dst", ")", ";", "}" ]
King of Fighters Special Edition 2004 (bootleg of King of Fighters 2002)
[ "King", "of", "Fighters", "Special", "Edition", "2004", "(", "bootleg", "of", "King", "of", "Fighters", "2002", ")" ]
[]
[ { "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": [] }
61229dab92c0d40938b633af4078905c002b97c9
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/neoboot.c
[ "Unlicense" ]
C
lans2004_vx_decrypt
void
void lans2004_vx_decrypt( running_machine *machine ) { int i; UINT8 *rom = memory_region( machine, "ym" ); for (i = 0; i < 0xA00000; i++) rom[i] = BITSWAP8(rom[i], 0, 1, 5, 4, 3, 2, 6, 7); }
/* Lansquenet 2004 (Shock Troopers - 2nd Squad bootleg) */
Lansquenet 2004 (Shock Troopers - 2nd Squad bootleg)
[ "Lansquenet", "2004", "(", "Shock", "Troopers", "-", "2nd", "Squad", "bootleg", ")" ]
void lans2004_vx_decrypt( running_machine *machine ) { int i; UINT8 *rom = memory_region( machine, "ym" ); for (i = 0; i < 0xA00000; i++) rom[i] = BITSWAP8(rom[i], 0, 1, 5, 4, 3, 2, 6, 7); }
[ "void", "lans2004_vx_decrypt", "(", "running_machine", "*", "machine", ")", "{", "int", "i", ";", "UINT8", "*", "rom", "=", "memory_region", "(", "machine", ",", "\"", "\"", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "0xA00000", ";", "i", "++", ")", "rom", "[", "i", "]", "=", "BITSWAP8", "(", "rom", "[", "i", "]", ",", "0", ",", "1", ",", "5", ",", "4", ",", "3", ",", "2", ",", "6", ",", "7", ")", ";", "}" ]
Lansquenet 2004 (Shock Troopers - 2nd Squad bootleg)
[ "Lansquenet", "2004", "(", "Shock", "Troopers", "-", "2nd", "Squad", "bootleg", ")" ]
[]
[ { "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": [] }
61229dab92c0d40938b633af4078905c002b97c9
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/neoboot.c
[ "Unlicense" ]
C
svcplus_px_decrypt
void
void svcplus_px_decrypt( running_machine *machine ) { static const int sec[] = { 0x00, 0x03, 0x02, 0x05, 0x04, 0x01 }; int size = memory_region_length( machine, "maincpu" ); UINT8 *src = memory_region( machine, "maincpu" ); UINT8 *dst = alloc_array_or_die(UINT8, size ); int i; int ofst; memcpy( dst, src, size ); for( i = 0; i < size / 2; i++ ){ ofst = BITSWAP24( (i & 0xfffff), 0x17, 0x16, 0x15, 0x14, 0x13, 0x00, 0x01, 0x02, 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x10, 0x11, 0x12 ); ofst ^= 0x0f0007; ofst += (i & 0xff00000); memcpy( &src[ i * 0x02 ], &dst[ ofst * 0x02 ], 0x02 ); } memcpy( dst, src, size ); for( i = 0; i < 6; i++ ){ memcpy( &src[ i * 0x100000 ], &dst[ sec[ i ] * 0x100000 ], 0x100000 ); } free( dst ); }
/* SNK vs. CAPCOM SVC CHAOS Plus (bootleg set 1) */
SNK vs. CAPCOM SVC CHAOS Plus (bootleg set 1)
[ "SNK", "vs", ".", "CAPCOM", "SVC", "CHAOS", "Plus", "(", "bootleg", "set", "1", ")" ]
void svcplus_px_decrypt( running_machine *machine ) { static const int sec[] = { 0x00, 0x03, 0x02, 0x05, 0x04, 0x01 }; int size = memory_region_length( machine, "maincpu" ); UINT8 *src = memory_region( machine, "maincpu" ); UINT8 *dst = alloc_array_or_die(UINT8, size ); int i; int ofst; memcpy( dst, src, size ); for( i = 0; i < size / 2; i++ ){ ofst = BITSWAP24( (i & 0xfffff), 0x17, 0x16, 0x15, 0x14, 0x13, 0x00, 0x01, 0x02, 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x10, 0x11, 0x12 ); ofst ^= 0x0f0007; ofst += (i & 0xff00000); memcpy( &src[ i * 0x02 ], &dst[ ofst * 0x02 ], 0x02 ); } memcpy( dst, src, size ); for( i = 0; i < 6; i++ ){ memcpy( &src[ i * 0x100000 ], &dst[ sec[ i ] * 0x100000 ], 0x100000 ); } free( dst ); }
[ "void", "svcplus_px_decrypt", "(", "running_machine", "*", "machine", ")", "{", "static", "const", "int", "sec", "[", "]", "=", "{", "0x00", ",", "0x03", ",", "0x02", ",", "0x05", ",", "0x04", ",", "0x01", "}", ";", "int", "size", "=", "memory_region_length", "(", "machine", ",", "\"", "\"", ")", ";", "UINT8", "*", "src", "=", "memory_region", "(", "machine", ",", "\"", "\"", ")", ";", "UINT8", "*", "dst", "=", "alloc_array_or_die", "(", "UINT8", ",", "size", ")", ";", "int", "i", ";", "int", "ofst", ";", "memcpy", "(", "dst", ",", "src", ",", "size", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "size", "/", "2", ";", "i", "++", ")", "{", "ofst", "=", "BITSWAP24", "(", "(", "i", "&", "0xfffff", ")", ",", "0x17", ",", "0x16", ",", "0x15", ",", "0x14", ",", "0x13", ",", "0x00", ",", "0x01", ",", "0x02", ",", "0x0f", ",", "0x0e", ",", "0x0d", ",", "0x0c", ",", "0x0b", ",", "0x0a", ",", "0x09", ",", "0x08", ",", "0x07", ",", "0x06", ",", "0x05", ",", "0x04", ",", "0x03", ",", "0x10", ",", "0x11", ",", "0x12", ")", ";", "ofst", "^=", "0x0f0007", ";", "ofst", "+=", "(", "i", "&", "0xff00000", ")", ";", "memcpy", "(", "&", "src", "[", "i", "*", "0x02", "]", ",", "&", "dst", "[", "ofst", "*", "0x02", "]", ",", "0x02", ")", ";", "}", "memcpy", "(", "dst", ",", "src", ",", "size", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "6", ";", "i", "++", ")", "{", "memcpy", "(", "&", "src", "[", "i", "*", "0x100000", "]", ",", "&", "dst", "[", "sec", "[", "i", "]", "*", "0x100000", "]", ",", "0x100000", ")", ";", "}", "free", "(", "dst", ")", ";", "}" ]
SNK vs. CAPCOM SVC CHAOS Plus (bootleg set 1)
[ "SNK", "vs", ".", "CAPCOM", "SVC", "CHAOS", "Plus", "(", "bootleg", "set", "1", ")" ]
[]
[ { "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": [] }
61229dab92c0d40938b633af4078905c002b97c9
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/neoboot.c
[ "Unlicense" ]
C
svcplusa_px_decrypt
void
void svcplusa_px_decrypt( running_machine *machine ) { int i; static const int sec[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x00 }; int size = memory_region_length( machine, "maincpu" ); UINT8 *src = memory_region( machine, "maincpu" ); UINT8 *dst = alloc_array_or_die(UINT8, size ); memcpy( dst, src, size ); for( i = 0; i < 6; i++ ){ memcpy( &src[ i * 0x100000 ], &dst[ sec[ i ] * 0x100000 ], 0x100000 ); } free( dst ); }
/* SNK vs. CAPCOM SVC CHAOS Plus (bootleg set 2) */
SNK vs. CAPCOM SVC CHAOS Plus (bootleg set 2)
[ "SNK", "vs", ".", "CAPCOM", "SVC", "CHAOS", "Plus", "(", "bootleg", "set", "2", ")" ]
void svcplusa_px_decrypt( running_machine *machine ) { int i; static const int sec[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x00 }; int size = memory_region_length( machine, "maincpu" ); UINT8 *src = memory_region( machine, "maincpu" ); UINT8 *dst = alloc_array_or_die(UINT8, size ); memcpy( dst, src, size ); for( i = 0; i < 6; i++ ){ memcpy( &src[ i * 0x100000 ], &dst[ sec[ i ] * 0x100000 ], 0x100000 ); } free( dst ); }
[ "void", "svcplusa_px_decrypt", "(", "running_machine", "*", "machine", ")", "{", "int", "i", ";", "static", "const", "int", "sec", "[", "]", "=", "{", "0x01", ",", "0x02", ",", "0x03", ",", "0x04", ",", "0x05", ",", "0x00", "}", ";", "int", "size", "=", "memory_region_length", "(", "machine", ",", "\"", "\"", ")", ";", "UINT8", "*", "src", "=", "memory_region", "(", "machine", ",", "\"", "\"", ")", ";", "UINT8", "*", "dst", "=", "alloc_array_or_die", "(", "UINT8", ",", "size", ")", ";", "memcpy", "(", "dst", ",", "src", ",", "size", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "6", ";", "i", "++", ")", "{", "memcpy", "(", "&", "src", "[", "i", "*", "0x100000", "]", ",", "&", "dst", "[", "sec", "[", "i", "]", "*", "0x100000", "]", ",", "0x100000", ")", ";", "}", "free", "(", "dst", ")", ";", "}" ]
SNK vs. CAPCOM SVC CHAOS Plus (bootleg set 2)
[ "SNK", "vs", ".", "CAPCOM", "SVC", "CHAOS", "Plus", "(", "bootleg", "set", "2", ")" ]
[]
[ { "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": [] }
61229dab92c0d40938b633af4078905c002b97c9
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/neoboot.c
[ "Unlicense" ]
C
svcsplus_px_decrypt
void
void svcsplus_px_decrypt( running_machine *machine ) { static const int sec[] = { 0x06, 0x07, 0x01, 0x02, 0x03, 0x04, 0x05, 0x00 }; int size = memory_region_length( machine, "maincpu" ); UINT8 *src = memory_region( machine, "maincpu" ); UINT8 *dst = alloc_array_or_die(UINT8, size ); int i; int ofst; memcpy( dst, src, size ); for( i = 0; i < size / 2; i++ ){ ofst = BITSWAP16( (i & 0x007fff), 0x0f, 0x00, 0x08, 0x09, 0x0b, 0x0a, 0x0c, 0x0d, 0x04, 0x03, 0x01, 0x07, 0x06, 0x02, 0x05, 0x0e ); ofst += (i & 0x078000); ofst += sec[ (i & 0xf80000) >> 19 ] << 19; memcpy( &src[ i * 2 ], &dst[ ofst * 2 ], 0x02 ); } free( dst ); }
/* SNK vs. CAPCOM SVC CHAOS Super Plus (bootleg) */
SNK vs. CAPCOM SVC CHAOS Super Plus (bootleg)
[ "SNK", "vs", ".", "CAPCOM", "SVC", "CHAOS", "Super", "Plus", "(", "bootleg", ")" ]
void svcsplus_px_decrypt( running_machine *machine ) { static const int sec[] = { 0x06, 0x07, 0x01, 0x02, 0x03, 0x04, 0x05, 0x00 }; int size = memory_region_length( machine, "maincpu" ); UINT8 *src = memory_region( machine, "maincpu" ); UINT8 *dst = alloc_array_or_die(UINT8, size ); int i; int ofst; memcpy( dst, src, size ); for( i = 0; i < size / 2; i++ ){ ofst = BITSWAP16( (i & 0x007fff), 0x0f, 0x00, 0x08, 0x09, 0x0b, 0x0a, 0x0c, 0x0d, 0x04, 0x03, 0x01, 0x07, 0x06, 0x02, 0x05, 0x0e ); ofst += (i & 0x078000); ofst += sec[ (i & 0xf80000) >> 19 ] << 19; memcpy( &src[ i * 2 ], &dst[ ofst * 2 ], 0x02 ); } free( dst ); }
[ "void", "svcsplus_px_decrypt", "(", "running_machine", "*", "machine", ")", "{", "static", "const", "int", "sec", "[", "]", "=", "{", "0x06", ",", "0x07", ",", "0x01", ",", "0x02", ",", "0x03", ",", "0x04", ",", "0x05", ",", "0x00", "}", ";", "int", "size", "=", "memory_region_length", "(", "machine", ",", "\"", "\"", ")", ";", "UINT8", "*", "src", "=", "memory_region", "(", "machine", ",", "\"", "\"", ")", ";", "UINT8", "*", "dst", "=", "alloc_array_or_die", "(", "UINT8", ",", "size", ")", ";", "int", "i", ";", "int", "ofst", ";", "memcpy", "(", "dst", ",", "src", ",", "size", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "size", "/", "2", ";", "i", "++", ")", "{", "ofst", "=", "BITSWAP16", "(", "(", "i", "&", "0x007fff", ")", ",", "0x0f", ",", "0x00", ",", "0x08", ",", "0x09", ",", "0x0b", ",", "0x0a", ",", "0x0c", ",", "0x0d", ",", "0x04", ",", "0x03", ",", "0x01", ",", "0x07", ",", "0x06", ",", "0x02", ",", "0x05", ",", "0x0e", ")", ";", "ofst", "+=", "(", "i", "&", "0x078000", ")", ";", "ofst", "+=", "sec", "[", "(", "i", "&", "0xf80000", ")", ">>", "19", "]", "<<", "19", ";", "memcpy", "(", "&", "src", "[", "i", "*", "2", "]", ",", "&", "dst", "[", "ofst", "*", "2", "]", ",", "0x02", ")", ";", "}", "free", "(", "dst", ")", ";", "}" ]
SNK vs. CAPCOM SVC CHAOS Super Plus (bootleg)
[ "SNK", "vs", ".", "CAPCOM", "SVC", "CHAOS", "Super", "Plus", "(", "bootleg", ")" ]
[]
[ { "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": [] }
61229dab92c0d40938b633af4078905c002b97c9
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/neoboot.c
[ "Unlicense" ]
C
kf2k3upl_px_decrypt
void
void kf2k3upl_px_decrypt( running_machine *machine ) { { UINT8 *src = memory_region(machine, "maincpu"); memmove(src+0x100000, src, 0x600000); memmove(src, src+0x700000, 0x100000); } { int ofst; int i; UINT8 *rom = memory_region( machine, "maincpu" ) + 0xfe000; UINT8 *buf = memory_region( machine, "maincpu" ) + 0xd0610; for( i = 0; i < 0x2000 / 2; i++ ){ ofst = (i & 0xff00) + BITSWAP8( (i & 0x00ff), 7, 6, 0, 4, 3, 2, 1, 5 ); memcpy( &rom[ i * 2 ], &buf[ ofst * 2 ], 2 ); } } }
/* The King of Fighters 2004 Ultra Plus (The King of Fighters 2003 bootleg) */
The King of Fighters 2004 Ultra Plus (The King of Fighters 2003 bootleg)
[ "The", "King", "of", "Fighters", "2004", "Ultra", "Plus", "(", "The", "King", "of", "Fighters", "2003", "bootleg", ")" ]
void kf2k3upl_px_decrypt( running_machine *machine ) { { UINT8 *src = memory_region(machine, "maincpu"); memmove(src+0x100000, src, 0x600000); memmove(src, src+0x700000, 0x100000); } { int ofst; int i; UINT8 *rom = memory_region( machine, "maincpu" ) + 0xfe000; UINT8 *buf = memory_region( machine, "maincpu" ) + 0xd0610; for( i = 0; i < 0x2000 / 2; i++ ){ ofst = (i & 0xff00) + BITSWAP8( (i & 0x00ff), 7, 6, 0, 4, 3, 2, 1, 5 ); memcpy( &rom[ i * 2 ], &buf[ ofst * 2 ], 2 ); } } }
[ "void", "kf2k3upl_px_decrypt", "(", "running_machine", "*", "machine", ")", "{", "{", "UINT8", "*", "src", "=", "memory_region", "(", "machine", ",", "\"", "\"", ")", ";", "memmove", "(", "src", "+", "0x100000", ",", "src", ",", "0x600000", ")", ";", "memmove", "(", "src", ",", "src", "+", "0x700000", ",", "0x100000", ")", ";", "}", "{", "int", "ofst", ";", "int", "i", ";", "UINT8", "*", "rom", "=", "memory_region", "(", "machine", ",", "\"", "\"", ")", "+", "0xfe000", ";", "UINT8", "*", "buf", "=", "memory_region", "(", "machine", ",", "\"", "\"", ")", "+", "0xd0610", ";", "for", "(", "i", "=", "0", ";", "i", "<", "0x2000", "/", "2", ";", "i", "++", ")", "{", "ofst", "=", "(", "i", "&", "0xff00", ")", "+", "BITSWAP8", "(", "(", "i", "&", "0x00ff", ")", ",", "7", ",", "6", ",", "0", ",", "4", ",", "3", ",", "2", ",", "1", ",", "5", ")", ";", "memcpy", "(", "&", "rom", "[", "i", "*", "2", "]", ",", "&", "buf", "[", "ofst", "*", "2", "]", ",", "2", ")", ";", "}", "}", "}" ]
The King of Fighters 2004 Ultra Plus (The King of Fighters 2003 bootleg)
[ "The", "King", "of", "Fighters", "2004", "Ultra", "Plus", "(", "The", "King", "of", "Fighters", "2003", "bootleg", ")" ]
[]
[ { "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": [] }
61229dab92c0d40938b633af4078905c002b97c9
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/machine/neoboot.c
[ "Unlicense" ]
C
samsho5b_px_decrypt
void
void samsho5b_px_decrypt( running_machine *machine ) { int px_size = memory_region_length( machine, "maincpu" ); UINT8 *rom = memory_region( machine, "maincpu" ); UINT8 *buf = alloc_array_or_die(UINT8, px_size ); int ofst; int i; memcpy( buf, rom, px_size ); for( i = 0; i < px_size / 2; i++ ){ ofst = BITSWAP8( (i & 0x000ff), 7, 6, 5, 4, 3, 0, 1, 2 ); ofst += (i & 0xfffff00); ofst ^= 0x060005; memcpy( &rom[ i * 2 ], &buf[ ofst * 2 ], 0x02 ); } memcpy( buf, rom, px_size ); memcpy( &rom[ 0x000000 ], &buf[ 0x700000 ], 0x100000 ); memcpy( &rom[ 0x100000 ], &buf[ 0x000000 ], 0x700000 ); free( buf ); }
/* Samurai Shodown V / Samurai Spirits Zero (bootleg) */
Samurai Shodown V / Samurai Spirits Zero (bootleg)
[ "Samurai", "Shodown", "V", "/", "Samurai", "Spirits", "Zero", "(", "bootleg", ")" ]
void samsho5b_px_decrypt( running_machine *machine ) { int px_size = memory_region_length( machine, "maincpu" ); UINT8 *rom = memory_region( machine, "maincpu" ); UINT8 *buf = alloc_array_or_die(UINT8, px_size ); int ofst; int i; memcpy( buf, rom, px_size ); for( i = 0; i < px_size / 2; i++ ){ ofst = BITSWAP8( (i & 0x000ff), 7, 6, 5, 4, 3, 0, 1, 2 ); ofst += (i & 0xfffff00); ofst ^= 0x060005; memcpy( &rom[ i * 2 ], &buf[ ofst * 2 ], 0x02 ); } memcpy( buf, rom, px_size ); memcpy( &rom[ 0x000000 ], &buf[ 0x700000 ], 0x100000 ); memcpy( &rom[ 0x100000 ], &buf[ 0x000000 ], 0x700000 ); free( buf ); }
[ "void", "samsho5b_px_decrypt", "(", "running_machine", "*", "machine", ")", "{", "int", "px_size", "=", "memory_region_length", "(", "machine", ",", "\"", "\"", ")", ";", "UINT8", "*", "rom", "=", "memory_region", "(", "machine", ",", "\"", "\"", ")", ";", "UINT8", "*", "buf", "=", "alloc_array_or_die", "(", "UINT8", ",", "px_size", ")", ";", "int", "ofst", ";", "int", "i", ";", "memcpy", "(", "buf", ",", "rom", ",", "px_size", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "px_size", "/", "2", ";", "i", "++", ")", "{", "ofst", "=", "BITSWAP8", "(", "(", "i", "&", "0x000ff", ")", ",", "7", ",", "6", ",", "5", ",", "4", ",", "3", ",", "0", ",", "1", ",", "2", ")", ";", "ofst", "+=", "(", "i", "&", "0xfffff00", ")", ";", "ofst", "^=", "0x060005", ";", "memcpy", "(", "&", "rom", "[", "i", "*", "2", "]", ",", "&", "buf", "[", "ofst", "*", "2", "]", ",", "0x02", ")", ";", "}", "memcpy", "(", "buf", ",", "rom", ",", "px_size", ")", ";", "memcpy", "(", "&", "rom", "[", "0x000000", "]", ",", "&", "buf", "[", "0x700000", "]", ",", "0x100000", ")", ";", "memcpy", "(", "&", "rom", "[", "0x100000", "]", ",", "&", "buf", "[", "0x000000", "]", ",", "0x700000", ")", ";", "free", "(", "buf", ")", ";", "}" ]
Samurai Shodown V / Samurai Spirits Zero (bootleg)
[ "Samurai", "Shodown", "V", "/", "Samurai", "Spirits", "Zero", "(", "bootleg", ")" ]
[]
[ { "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": [] }
612bae9f912bf2501143484d4179568700a1b17d
lofunz/mieme
Reloaded/trunk/src/emu/cpu/mips/mips3drc.c
[ "Unlicense" ]
C
code_flush_cache
void
static void code_flush_cache(mips3_state *mips3) { int mode; /* empty the transient cache contents */ drcuml_reset(mips3->impstate->drcuml); /* generate the entry point and out-of-cycles handlers */ static_generate_entry_point(mips3); static_generate_nocode_handler(mips3); static_generate_out_of_cycles(mips3); static_generate_tlb_mismatch(mips3); /* append exception handlers for various types */ static_generate_exception(mips3, EXCEPTION_INTERRUPT, TRUE, "exception_interrupt"); static_generate_exception(mips3, EXCEPTION_INTERRUPT, FALSE, "exception_interrupt_norecover"); static_generate_exception(mips3, EXCEPTION_TLBMOD, TRUE, "exception_tlbmod"); static_generate_exception(mips3, EXCEPTION_TLBLOAD, TRUE, "exception_tlbload"); static_generate_exception(mips3, EXCEPTION_TLBSTORE, TRUE, "exception_tlbstore"); static_generate_exception(mips3, EXCEPTION_TLBLOAD_FILL, TRUE, "exception_tlbload_fill"); static_generate_exception(mips3, EXCEPTION_TLBSTORE_FILL, TRUE, "exception_tlbstore_fill"); static_generate_exception(mips3, EXCEPTION_ADDRLOAD, TRUE, "exception_addrload"); static_generate_exception(mips3, EXCEPTION_ADDRSTORE, TRUE, "exception_addrstore"); static_generate_exception(mips3, EXCEPTION_SYSCALL, TRUE, "exception_syscall"); static_generate_exception(mips3, EXCEPTION_BREAK, TRUE, "exception_break"); static_generate_exception(mips3, EXCEPTION_INVALIDOP, TRUE, "exception_invalidop"); static_generate_exception(mips3, EXCEPTION_BADCOP, TRUE, "exception_badcop"); static_generate_exception(mips3, EXCEPTION_OVERFLOW, TRUE, "exception_overflow"); static_generate_exception(mips3, EXCEPTION_TRAP, TRUE, "exception_trap"); /* add subroutines for memory accesses */ for (mode = 0; mode < 3; mode++) { static_generate_memory_accessor(mips3, mode, 1, FALSE, FALSE, "read8", &mips3->impstate->read8[mode]); static_generate_memory_accessor(mips3, mode, 1, TRUE, FALSE, "write8", &mips3->impstate->write8[mode]); static_generate_memory_accessor(mips3, mode, 2, FALSE, FALSE, "read16", &mips3->impstate->read16[mode]); static_generate_memory_accessor(mips3, mode, 2, TRUE, FALSE, "write16", &mips3->impstate->write16[mode]); static_generate_memory_accessor(mips3, mode, 4, FALSE, FALSE, "read32", &mips3->impstate->read32[mode]); static_generate_memory_accessor(mips3, mode, 4, FALSE, TRUE, "read32mask", &mips3->impstate->read32mask[mode]); static_generate_memory_accessor(mips3, mode, 4, TRUE, FALSE, "write32", &mips3->impstate->write32[mode]); static_generate_memory_accessor(mips3, mode, 4, TRUE, TRUE, "write32mask", &mips3->impstate->write32mask[mode]); static_generate_memory_accessor(mips3, mode, 8, FALSE, FALSE, "read64", &mips3->impstate->read64[mode]); static_generate_memory_accessor(mips3, mode, 8, FALSE, TRUE, "read64mask", &mips3->impstate->read64mask[mode]); static_generate_memory_accessor(mips3, mode, 8, TRUE, FALSE, "write64", &mips3->impstate->write64[mode]); static_generate_memory_accessor(mips3, mode, 8, TRUE, TRUE, "write64mask", &mips3->impstate->write64mask[mode]); } }
/*------------------------------------------------- code_flush_cache - flush the cache and regenerate static code -------------------------------------------------*/
flush the cache and regenerate static code
[ "flush", "the", "cache", "and", "regenerate", "static", "code" ]
static void code_flush_cache(mips3_state *mips3) { int mode; drcuml_reset(mips3->impstate->drcuml); static_generate_entry_point(mips3); static_generate_nocode_handler(mips3); static_generate_out_of_cycles(mips3); static_generate_tlb_mismatch(mips3); static_generate_exception(mips3, EXCEPTION_INTERRUPT, TRUE, "exception_interrupt"); static_generate_exception(mips3, EXCEPTION_INTERRUPT, FALSE, "exception_interrupt_norecover"); static_generate_exception(mips3, EXCEPTION_TLBMOD, TRUE, "exception_tlbmod"); static_generate_exception(mips3, EXCEPTION_TLBLOAD, TRUE, "exception_tlbload"); static_generate_exception(mips3, EXCEPTION_TLBSTORE, TRUE, "exception_tlbstore"); static_generate_exception(mips3, EXCEPTION_TLBLOAD_FILL, TRUE, "exception_tlbload_fill"); static_generate_exception(mips3, EXCEPTION_TLBSTORE_FILL, TRUE, "exception_tlbstore_fill"); static_generate_exception(mips3, EXCEPTION_ADDRLOAD, TRUE, "exception_addrload"); static_generate_exception(mips3, EXCEPTION_ADDRSTORE, TRUE, "exception_addrstore"); static_generate_exception(mips3, EXCEPTION_SYSCALL, TRUE, "exception_syscall"); static_generate_exception(mips3, EXCEPTION_BREAK, TRUE, "exception_break"); static_generate_exception(mips3, EXCEPTION_INVALIDOP, TRUE, "exception_invalidop"); static_generate_exception(mips3, EXCEPTION_BADCOP, TRUE, "exception_badcop"); static_generate_exception(mips3, EXCEPTION_OVERFLOW, TRUE, "exception_overflow"); static_generate_exception(mips3, EXCEPTION_TRAP, TRUE, "exception_trap"); for (mode = 0; mode < 3; mode++) { static_generate_memory_accessor(mips3, mode, 1, FALSE, FALSE, "read8", &mips3->impstate->read8[mode]); static_generate_memory_accessor(mips3, mode, 1, TRUE, FALSE, "write8", &mips3->impstate->write8[mode]); static_generate_memory_accessor(mips3, mode, 2, FALSE, FALSE, "read16", &mips3->impstate->read16[mode]); static_generate_memory_accessor(mips3, mode, 2, TRUE, FALSE, "write16", &mips3->impstate->write16[mode]); static_generate_memory_accessor(mips3, mode, 4, FALSE, FALSE, "read32", &mips3->impstate->read32[mode]); static_generate_memory_accessor(mips3, mode, 4, FALSE, TRUE, "read32mask", &mips3->impstate->read32mask[mode]); static_generate_memory_accessor(mips3, mode, 4, TRUE, FALSE, "write32", &mips3->impstate->write32[mode]); static_generate_memory_accessor(mips3, mode, 4, TRUE, TRUE, "write32mask", &mips3->impstate->write32mask[mode]); static_generate_memory_accessor(mips3, mode, 8, FALSE, FALSE, "read64", &mips3->impstate->read64[mode]); static_generate_memory_accessor(mips3, mode, 8, FALSE, TRUE, "read64mask", &mips3->impstate->read64mask[mode]); static_generate_memory_accessor(mips3, mode, 8, TRUE, FALSE, "write64", &mips3->impstate->write64[mode]); static_generate_memory_accessor(mips3, mode, 8, TRUE, TRUE, "write64mask", &mips3->impstate->write64mask[mode]); } }
[ "static", "void", "code_flush_cache", "(", "mips3_state", "*", "mips3", ")", "{", "int", "mode", ";", "drcuml_reset", "(", "mips3", "->", "impstate", "->", "drcuml", ")", ";", "static_generate_entry_point", "(", "mips3", ")", ";", "static_generate_nocode_handler", "(", "mips3", ")", ";", "static_generate_out_of_cycles", "(", "mips3", ")", ";", "static_generate_tlb_mismatch", "(", "mips3", ")", ";", "static_generate_exception", "(", "mips3", ",", "EXCEPTION_INTERRUPT", ",", "TRUE", ",", "\"", "\"", ")", ";", "static_generate_exception", "(", "mips3", ",", "EXCEPTION_INTERRUPT", ",", "FALSE", ",", "\"", "\"", ")", ";", "static_generate_exception", "(", "mips3", ",", "EXCEPTION_TLBMOD", ",", "TRUE", ",", "\"", "\"", ")", ";", "static_generate_exception", "(", "mips3", ",", "EXCEPTION_TLBLOAD", ",", "TRUE", ",", "\"", "\"", ")", ";", "static_generate_exception", "(", "mips3", ",", "EXCEPTION_TLBSTORE", ",", "TRUE", ",", "\"", "\"", ")", ";", "static_generate_exception", "(", "mips3", ",", "EXCEPTION_TLBLOAD_FILL", ",", "TRUE", ",", "\"", "\"", ")", ";", "static_generate_exception", "(", "mips3", ",", "EXCEPTION_TLBSTORE_FILL", ",", "TRUE", ",", "\"", "\"", ")", ";", "static_generate_exception", "(", "mips3", ",", "EXCEPTION_ADDRLOAD", ",", "TRUE", ",", "\"", "\"", ")", ";", "static_generate_exception", "(", "mips3", ",", "EXCEPTION_ADDRSTORE", ",", "TRUE", ",", "\"", "\"", ")", ";", "static_generate_exception", "(", "mips3", ",", "EXCEPTION_SYSCALL", ",", "TRUE", ",", "\"", "\"", ")", ";", "static_generate_exception", "(", "mips3", ",", "EXCEPTION_BREAK", ",", "TRUE", ",", "\"", "\"", ")", ";", "static_generate_exception", "(", "mips3", ",", "EXCEPTION_INVALIDOP", ",", "TRUE", ",", "\"", "\"", ")", ";", "static_generate_exception", "(", "mips3", ",", "EXCEPTION_BADCOP", ",", "TRUE", ",", "\"", "\"", ")", ";", "static_generate_exception", "(", "mips3", ",", "EXCEPTION_OVERFLOW", ",", "TRUE", ",", "\"", "\"", ")", ";", "static_generate_exception", "(", "mips3", ",", "EXCEPTION_TRAP", ",", "TRUE", ",", "\"", "\"", ")", ";", "for", "(", "mode", "=", "0", ";", "mode", "<", "3", ";", "mode", "++", ")", "{", "static_generate_memory_accessor", "(", "mips3", ",", "mode", ",", "1", ",", "FALSE", ",", "FALSE", ",", "\"", "\"", ",", "&", "mips3", "->", "impstate", "->", "read8", "[", "mode", "]", ")", ";", "static_generate_memory_accessor", "(", "mips3", ",", "mode", ",", "1", ",", "TRUE", ",", "FALSE", ",", "\"", "\"", ",", "&", "mips3", "->", "impstate", "->", "write8", "[", "mode", "]", ")", ";", "static_generate_memory_accessor", "(", "mips3", ",", "mode", ",", "2", ",", "FALSE", ",", "FALSE", ",", "\"", "\"", ",", "&", "mips3", "->", "impstate", "->", "read16", "[", "mode", "]", ")", ";", "static_generate_memory_accessor", "(", "mips3", ",", "mode", ",", "2", ",", "TRUE", ",", "FALSE", ",", "\"", "\"", ",", "&", "mips3", "->", "impstate", "->", "write16", "[", "mode", "]", ")", ";", "static_generate_memory_accessor", "(", "mips3", ",", "mode", ",", "4", ",", "FALSE", ",", "FALSE", ",", "\"", "\"", ",", "&", "mips3", "->", "impstate", "->", "read32", "[", "mode", "]", ")", ";", "static_generate_memory_accessor", "(", "mips3", ",", "mode", ",", "4", ",", "FALSE", ",", "TRUE", ",", "\"", "\"", ",", "&", "mips3", "->", "impstate", "->", "read32mask", "[", "mode", "]", ")", ";", "static_generate_memory_accessor", "(", "mips3", ",", "mode", ",", "4", ",", "TRUE", ",", "FALSE", ",", "\"", "\"", ",", "&", "mips3", "->", "impstate", "->", "write32", "[", "mode", "]", ")", ";", "static_generate_memory_accessor", "(", "mips3", ",", "mode", ",", "4", ",", "TRUE", ",", "TRUE", ",", "\"", "\"", ",", "&", "mips3", "->", "impstate", "->", "write32mask", "[", "mode", "]", ")", ";", "static_generate_memory_accessor", "(", "mips3", ",", "mode", ",", "8", ",", "FALSE", ",", "FALSE", ",", "\"", "\"", ",", "&", "mips3", "->", "impstate", "->", "read64", "[", "mode", "]", ")", ";", "static_generate_memory_accessor", "(", "mips3", ",", "mode", ",", "8", ",", "FALSE", ",", "TRUE", ",", "\"", "\"", ",", "&", "mips3", "->", "impstate", "->", "read64mask", "[", "mode", "]", ")", ";", "static_generate_memory_accessor", "(", "mips3", ",", "mode", ",", "8", ",", "TRUE", ",", "FALSE", ",", "\"", "\"", ",", "&", "mips3", "->", "impstate", "->", "write64", "[", "mode", "]", ")", ";", "static_generate_memory_accessor", "(", "mips3", ",", "mode", ",", "8", ",", "TRUE", ",", "TRUE", ",", "\"", "\"", ",", "&", "mips3", "->", "impstate", "->", "write64mask", "[", "mode", "]", ")", ";", "}", "}" ]
code_flush_cache - flush the cache and regenerate static code
[ "code_flush_cache", "-", "flush", "the", "cache", "and", "regenerate", "static", "code" ]
[ "/* empty the transient cache contents */", "/* generate the entry point and out-of-cycles handlers */", "/* append exception handlers for various types */", "/* add subroutines for memory accesses */" ]
[ { "param": "mips3", "type": "mips3_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mips3", "type": "mips3_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
612bae9f912bf2501143484d4179568700a1b17d
lofunz/mieme
Reloaded/trunk/src/emu/cpu/mips/mips3drc.c
[ "Unlicense" ]
C
code_compile_block
void
static void code_compile_block(mips3_state *mips3, UINT8 mode, offs_t pc) { drcuml_state *drcuml = mips3->impstate->drcuml; compiler_state compiler = { 0 }; const opcode_desc *seqhead, *seqlast; const opcode_desc *desclist; int override = FALSE; drcuml_block *block; jmp_buf errorbuf; profiler_mark_start(PROFILER_DRC_COMPILE); /* get a description of this sequence */ desclist = drcfe_describe_code(mips3->impstate->drcfe, pc); if (LOG_UML || LOG_NATIVE) log_opcode_desc(drcuml, desclist, 0); /* if we get an error back, flush the cache and try again */ if (setjmp(errorbuf) != 0) code_flush_cache(mips3); /* start the block */ block = drcuml_block_begin(drcuml, 4096, &errorbuf); /* loop until we get through all instruction sequences */ for (seqhead = desclist; seqhead != NULL; seqhead = seqlast->next) { const opcode_desc *curdesc; UINT32 nextpc; /* add a code log entry */ if (LOG_UML) UML_COMMENT(block, "-------------------------"); // comment /* determine the last instruction in this sequence */ for (seqlast = seqhead; seqlast != NULL; seqlast = seqlast->next) if (seqlast->flags & OPFLAG_END_SEQUENCE) break; assert(seqlast != NULL); /* if we don't have a hash for this mode/pc, or if we are overriding all, add one */ if (override || !drcuml_hash_exists(drcuml, mode, seqhead->pc)) UML_HASH(block, mode, seqhead->pc); // hash mode,pc /* if we already have a hash, and this is the first sequence, assume that we */ /* are recompiling due to being out of sync and allow future overrides */ else if (seqhead == desclist) { override = TRUE; UML_HASH(block, mode, seqhead->pc); // hash mode,pc } /* otherwise, redispatch to that fixed PC and skip the rest of the processing */ else { UML_LABEL(block, seqhead->pc | 0x80000000); // label seqhead->pc | 0x80000000 UML_HASHJMP(block, IMM(mips3->impstate->mode), IMM(seqhead->pc), mips3->impstate->nocode); // hashjmp <mode>,seqhead->pc,nocode continue; } /* validate this code block if we're not pointing into ROM */ if (memory_get_write_ptr(mips3->program, seqhead->physpc) != NULL) generate_checksum_block(mips3, block, &compiler, seqhead, seqlast); /* label this instruction, if it may be jumped to locally */ if (seqhead->flags & OPFLAG_IS_BRANCH_TARGET) UML_LABEL(block, seqhead->pc | 0x80000000); // label seqhead->pc | 0x80000000 /* iterate over instructions in the sequence and compile them */ for (curdesc = seqhead; curdesc != seqlast->next; curdesc = curdesc->next) generate_sequence_instruction(mips3, block, &compiler, curdesc); /* if we need to return to the start, do it */ if (seqlast->flags & OPFLAG_RETURN_TO_START) nextpc = pc; /* otherwise we just go to the next instruction */ else nextpc = seqlast->pc + (seqlast->skipslots + 1) * 4; /* count off cycles and go there */ generate_update_cycles(mips3, block, &compiler, IMM(nextpc), TRUE); // <subtract cycles> /* if the last instruction can change modes, use a variable mode; otherwise, assume the same mode */ if (seqlast->flags & OPFLAG_CAN_CHANGE_MODES) UML_HASHJMP(block, MEM(&mips3->impstate->mode), IMM(nextpc), mips3->impstate->nocode); // hashjmp <mode>,nextpc,nocode else if (seqlast->next == NULL || seqlast->next->pc != nextpc) UML_HASHJMP(block, IMM(mips3->impstate->mode), IMM(nextpc), mips3->impstate->nocode); // hashjmp <mode>,nextpc,nocode } /* end the sequence */ drcuml_block_end(block); profiler_mark_end(); }
/*------------------------------------------------- code_compile_block - compile a block of the given mode at the specified pc -------------------------------------------------*/
compile a block of the given mode at the specified pc
[ "compile", "a", "block", "of", "the", "given", "mode", "at", "the", "specified", "pc" ]
static void code_compile_block(mips3_state *mips3, UINT8 mode, offs_t pc) { drcuml_state *drcuml = mips3->impstate->drcuml; compiler_state compiler = { 0 }; const opcode_desc *seqhead, *seqlast; const opcode_desc *desclist; int override = FALSE; drcuml_block *block; jmp_buf errorbuf; profiler_mark_start(PROFILER_DRC_COMPILE); desclist = drcfe_describe_code(mips3->impstate->drcfe, pc); if (LOG_UML || LOG_NATIVE) log_opcode_desc(drcuml, desclist, 0); if (setjmp(errorbuf) != 0) code_flush_cache(mips3); block = drcuml_block_begin(drcuml, 4096, &errorbuf); for (seqhead = desclist; seqhead != NULL; seqhead = seqlast->next) { const opcode_desc *curdesc; UINT32 nextpc; if (LOG_UML) UML_COMMENT(block, "-------------------------"); for (seqlast = seqhead; seqlast != NULL; seqlast = seqlast->next) if (seqlast->flags & OPFLAG_END_SEQUENCE) break; assert(seqlast != NULL); if (override || !drcuml_hash_exists(drcuml, mode, seqhead->pc)) UML_HASH(block, mode, seqhead->pc); else if (seqhead == desclist) { override = TRUE; UML_HASH(block, mode, seqhead->pc); } else { UML_LABEL(block, seqhead->pc | 0x80000000); UML_HASHJMP(block, IMM(mips3->impstate->mode), IMM(seqhead->pc), mips3->impstate->nocode); continue; } if (memory_get_write_ptr(mips3->program, seqhead->physpc) != NULL) generate_checksum_block(mips3, block, &compiler, seqhead, seqlast); if (seqhead->flags & OPFLAG_IS_BRANCH_TARGET) UML_LABEL(block, seqhead->pc | 0x80000000); for (curdesc = seqhead; curdesc != seqlast->next; curdesc = curdesc->next) generate_sequence_instruction(mips3, block, &compiler, curdesc); if (seqlast->flags & OPFLAG_RETURN_TO_START) nextpc = pc; else nextpc = seqlast->pc + (seqlast->skipslots + 1) * 4; generate_update_cycles(mips3, block, &compiler, IMM(nextpc), TRUE); if (seqlast->flags & OPFLAG_CAN_CHANGE_MODES) UML_HASHJMP(block, MEM(&mips3->impstate->mode), IMM(nextpc), mips3->impstate->nocode); else if (seqlast->next == NULL || seqlast->next->pc != nextpc) UML_HASHJMP(block, IMM(mips3->impstate->mode), IMM(nextpc), mips3->impstate->nocode); } drcuml_block_end(block); profiler_mark_end(); }
[ "static", "void", "code_compile_block", "(", "mips3_state", "*", "mips3", ",", "UINT8", "mode", ",", "offs_t", "pc", ")", "{", "drcuml_state", "*", "drcuml", "=", "mips3", "->", "impstate", "->", "drcuml", ";", "compiler_state", "compiler", "=", "{", "0", "}", ";", "const", "opcode_desc", "*", "seqhead", ",", "*", "seqlast", ";", "const", "opcode_desc", "*", "desclist", ";", "int", "override", "=", "FALSE", ";", "drcuml_block", "*", "block", ";", "jmp_buf", "errorbuf", ";", "profiler_mark_start", "(", "PROFILER_DRC_COMPILE", ")", ";", "desclist", "=", "drcfe_describe_code", "(", "mips3", "->", "impstate", "->", "drcfe", ",", "pc", ")", ";", "if", "(", "LOG_UML", "||", "LOG_NATIVE", ")", "log_opcode_desc", "(", "drcuml", ",", "desclist", ",", "0", ")", ";", "if", "(", "setjmp", "(", "errorbuf", ")", "!=", "0", ")", "code_flush_cache", "(", "mips3", ")", ";", "block", "=", "drcuml_block_begin", "(", "drcuml", ",", "4096", ",", "&", "errorbuf", ")", ";", "for", "(", "seqhead", "=", "desclist", ";", "seqhead", "!=", "NULL", ";", "seqhead", "=", "seqlast", "->", "next", ")", "{", "const", "opcode_desc", "*", "curdesc", ";", "UINT32", "nextpc", ";", "if", "(", "LOG_UML", ")", "UML_COMMENT", "(", "block", ",", "\"", "\"", ")", ";", "for", "(", "seqlast", "=", "seqhead", ";", "seqlast", "!=", "NULL", ";", "seqlast", "=", "seqlast", "->", "next", ")", "if", "(", "seqlast", "->", "flags", "&", "OPFLAG_END_SEQUENCE", ")", "break", ";", "assert", "(", "seqlast", "!=", "NULL", ")", ";", "if", "(", "override", "||", "!", "drcuml_hash_exists", "(", "drcuml", ",", "mode", ",", "seqhead", "->", "pc", ")", ")", "UML_HASH", "(", "block", ",", "mode", ",", "seqhead", "->", "pc", ")", ";", "else", "if", "(", "seqhead", "==", "desclist", ")", "{", "override", "=", "TRUE", ";", "UML_HASH", "(", "block", ",", "mode", ",", "seqhead", "->", "pc", ")", ";", "}", "else", "{", "UML_LABEL", "(", "block", ",", "seqhead", "->", "pc", "|", "0x80000000", ")", ";", "UML_HASHJMP", "(", "block", ",", "IMM", "(", "mips3", "->", "impstate", "->", "mode", ")", ",", "IMM", "(", "seqhead", "->", "pc", ")", ",", "mips3", "->", "impstate", "->", "nocode", ")", ";", "continue", ";", "}", "if", "(", "memory_get_write_ptr", "(", "mips3", "->", "program", ",", "seqhead", "->", "physpc", ")", "!=", "NULL", ")", "generate_checksum_block", "(", "mips3", ",", "block", ",", "&", "compiler", ",", "seqhead", ",", "seqlast", ")", ";", "if", "(", "seqhead", "->", "flags", "&", "OPFLAG_IS_BRANCH_TARGET", ")", "UML_LABEL", "(", "block", ",", "seqhead", "->", "pc", "|", "0x80000000", ")", ";", "for", "(", "curdesc", "=", "seqhead", ";", "curdesc", "!=", "seqlast", "->", "next", ";", "curdesc", "=", "curdesc", "->", "next", ")", "generate_sequence_instruction", "(", "mips3", ",", "block", ",", "&", "compiler", ",", "curdesc", ")", ";", "if", "(", "seqlast", "->", "flags", "&", "OPFLAG_RETURN_TO_START", ")", "nextpc", "=", "pc", ";", "else", "nextpc", "=", "seqlast", "->", "pc", "+", "(", "seqlast", "->", "skipslots", "+", "1", ")", "*", "4", ";", "generate_update_cycles", "(", "mips3", ",", "block", ",", "&", "compiler", ",", "IMM", "(", "nextpc", ")", ",", "TRUE", ")", ";", "if", "(", "seqlast", "->", "flags", "&", "OPFLAG_CAN_CHANGE_MODES", ")", "UML_HASHJMP", "(", "block", ",", "MEM", "(", "&", "mips3", "->", "impstate", "->", "mode", ")", ",", "IMM", "(", "nextpc", ")", ",", "mips3", "->", "impstate", "->", "nocode", ")", ";", "else", "if", "(", "seqlast", "->", "next", "==", "NULL", "||", "seqlast", "->", "next", "->", "pc", "!=", "nextpc", ")", "UML_HASHJMP", "(", "block", ",", "IMM", "(", "mips3", "->", "impstate", "->", "mode", ")", ",", "IMM", "(", "nextpc", ")", ",", "mips3", "->", "impstate", "->", "nocode", ")", ";", "}", "drcuml_block_end", "(", "block", ")", ";", "profiler_mark_end", "(", ")", ";", "}" ]
code_compile_block - compile a block of the given mode at the specified pc
[ "code_compile_block", "-", "compile", "a", "block", "of", "the", "given", "mode", "at", "the", "specified", "pc" ]
[ "/* get a description of this sequence */", "/* if we get an error back, flush the cache and try again */", "/* start the block */", "/* loop until we get through all instruction sequences */", "/* add a code log entry */", "// comment\r", "/* determine the last instruction in this sequence */", "/* if we don't have a hash for this mode/pc, or if we are overriding all, add one */", "// hash mode,pc\r", "/* if we already have a hash, and this is the first sequence, assume that we */", "/* are recompiling due to being out of sync and allow future overrides */", "// hash mode,pc\r", "/* otherwise, redispatch to that fixed PC and skip the rest of the processing */", "// label seqhead->pc | 0x80000000\r", "// hashjmp <mode>,seqhead->pc,nocode\r", "/* validate this code block if we're not pointing into ROM */", "/* label this instruction, if it may be jumped to locally */", "// label seqhead->pc | 0x80000000\r", "/* iterate over instructions in the sequence and compile them */", "/* if we need to return to the start, do it */", "/* otherwise we just go to the next instruction */", "/* count off cycles and go there */", "// <subtract cycles>\r", "/* if the last instruction can change modes, use a variable mode; otherwise, assume the same mode */", "// hashjmp <mode>,nextpc,nocode\r", "// hashjmp <mode>,nextpc,nocode\r", "/* end the sequence */" ]
[ { "param": "mips3", "type": "mips3_state" }, { "param": "mode", "type": "UINT8" }, { "param": "pc", "type": "offs_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mips3", "type": "mips3_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mode", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pc", "type": "offs_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
612bae9f912bf2501143484d4179568700a1b17d
lofunz/mieme
Reloaded/trunk/src/emu/cpu/mips/mips3drc.c
[ "Unlicense" ]
C
cfunc_get_cycles
void
static void cfunc_get_cycles(void *param) { mips3_state *mips3 = (mips3_state *)param; mips3->impstate->numcycles = mips3->device->total_cycles(); }
/*------------------------------------------------- cfunc_get_cycles - compute the total number of cycles executed so far -------------------------------------------------*/
compute the total number of cycles executed so far
[ "compute", "the", "total", "number", "of", "cycles", "executed", "so", "far" ]
static void cfunc_get_cycles(void *param) { mips3_state *mips3 = (mips3_state *)param; mips3->impstate->numcycles = mips3->device->total_cycles(); }
[ "static", "void", "cfunc_get_cycles", "(", "void", "*", "param", ")", "{", "mips3_state", "*", "mips3", "=", "(", "mips3_state", "*", ")", "param", ";", "mips3", "->", "impstate", "->", "numcycles", "=", "mips3", "->", "device", "->", "total_cycles", "(", ")", ";", "}" ]
cfunc_get_cycles - compute the total number of cycles executed so far
[ "cfunc_get_cycles", "-", "compute", "the", "total", "number", "of", "cycles", "executed", "so", "far" ]
[]
[ { "param": "param", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "param", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
612bae9f912bf2501143484d4179568700a1b17d
lofunz/mieme
Reloaded/trunk/src/emu/cpu/mips/mips3drc.c
[ "Unlicense" ]
C
cfunc_printf_exception
void
static void cfunc_printf_exception(void *param) { mips3_state *mips3 = (mips3_state *)param; printf("Exception: EPC=%08X Cause=%08X BadVAddr=%08X Jmp=%08X\n", (UINT32)mips3->cpr[0][COP0_EPC], (UINT32)mips3->cpr[0][COP0_Cause], (UINT32)mips3->cpr[0][COP0_BadVAddr], mips3->pc); cfunc_printf_probe(mips3); }
/*------------------------------------------------- cfunc_printf_exception - log any exceptions that aren't interrupts -------------------------------------------------*/
log any exceptions that aren't interrupts
[ "log", "any", "exceptions", "that", "aren", "'", "t", "interrupts" ]
static void cfunc_printf_exception(void *param) { mips3_state *mips3 = (mips3_state *)param; printf("Exception: EPC=%08X Cause=%08X BadVAddr=%08X Jmp=%08X\n", (UINT32)mips3->cpr[0][COP0_EPC], (UINT32)mips3->cpr[0][COP0_Cause], (UINT32)mips3->cpr[0][COP0_BadVAddr], mips3->pc); cfunc_printf_probe(mips3); }
[ "static", "void", "cfunc_printf_exception", "(", "void", "*", "param", ")", "{", "mips3_state", "*", "mips3", "=", "(", "mips3_state", "*", ")", "param", ";", "printf", "(", "\"", "\\n", "\"", ",", "(", "UINT32", ")", "mips3", "->", "cpr", "[", "0", "]", "[", "COP0_EPC", "]", ",", "(", "UINT32", ")", "mips3", "->", "cpr", "[", "0", "]", "[", "COP0_Cause", "]", ",", "(", "UINT32", ")", "mips3", "->", "cpr", "[", "0", "]", "[", "COP0_BadVAddr", "]", ",", "mips3", "->", "pc", ")", ";", "cfunc_printf_probe", "(", "mips3", ")", ";", "}" ]
cfunc_printf_exception - log any exceptions that aren't interrupts
[ "cfunc_printf_exception", "-", "log", "any", "exceptions", "that", "aren", "'", "t", "interrupts" ]
[]
[ { "param": "param", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "param", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
612bae9f912bf2501143484d4179568700a1b17d
lofunz/mieme
Reloaded/trunk/src/emu/cpu/mips/mips3drc.c
[ "Unlicense" ]
C
cfunc_printf_probe
void
static void cfunc_printf_probe(void *param) { mips3_state *mips3 = (mips3_state *)param; printf(" PC=%08X r1=%08X%08X r2=%08X%08X r3=%08X%08X\n", mips3->pc, (UINT32)(mips3->r[1] >> 32), (UINT32)mips3->r[1], (UINT32)(mips3->r[2] >> 32), (UINT32)mips3->r[2], (UINT32)(mips3->r[3] >> 32), (UINT32)mips3->r[3]); printf(" r4=%08X%08X r5=%08X%08X r6=%08X%08X r7=%08X%08X\n", (UINT32)(mips3->r[4] >> 32), (UINT32)mips3->r[4], (UINT32)(mips3->r[5] >> 32), (UINT32)mips3->r[5], (UINT32)(mips3->r[6] >> 32), (UINT32)mips3->r[6], (UINT32)(mips3->r[7] >> 32), (UINT32)mips3->r[7]); printf(" r8=%08X%08X r9=%08X%08X r10=%08X%08X r11=%08X%08X\n", (UINT32)(mips3->r[8] >> 32), (UINT32)mips3->r[8], (UINT32)(mips3->r[9] >> 32), (UINT32)mips3->r[9], (UINT32)(mips3->r[10] >> 32), (UINT32)mips3->r[10], (UINT32)(mips3->r[11] >> 32), (UINT32)mips3->r[11]); printf("r12=%08X%08X r13=%08X%08X r14=%08X%08X r15=%08X%08X\n", (UINT32)(mips3->r[12] >> 32), (UINT32)mips3->r[12], (UINT32)(mips3->r[13] >> 32), (UINT32)mips3->r[13], (UINT32)(mips3->r[14] >> 32), (UINT32)mips3->r[14], (UINT32)(mips3->r[15] >> 32), (UINT32)mips3->r[15]); printf("r16=%08X%08X r17=%08X%08X r18=%08X%08X r19=%08X%08X\n", (UINT32)(mips3->r[16] >> 32), (UINT32)mips3->r[16], (UINT32)(mips3->r[17] >> 32), (UINT32)mips3->r[17], (UINT32)(mips3->r[18] >> 32), (UINT32)mips3->r[18], (UINT32)(mips3->r[19] >> 32), (UINT32)mips3->r[19]); printf("r20=%08X%08X r21=%08X%08X r22=%08X%08X r23=%08X%08X\n", (UINT32)(mips3->r[20] >> 32), (UINT32)mips3->r[20], (UINT32)(mips3->r[21] >> 32), (UINT32)mips3->r[21], (UINT32)(mips3->r[22] >> 32), (UINT32)mips3->r[22], (UINT32)(mips3->r[23] >> 32), (UINT32)mips3->r[23]); printf("r24=%08X%08X r25=%08X%08X r26=%08X%08X r27=%08X%08X\n", (UINT32)(mips3->r[24] >> 32), (UINT32)mips3->r[24], (UINT32)(mips3->r[25] >> 32), (UINT32)mips3->r[25], (UINT32)(mips3->r[26] >> 32), (UINT32)mips3->r[26], (UINT32)(mips3->r[27] >> 32), (UINT32)mips3->r[27]); printf("r28=%08X%08X r29=%08X%08X r30=%08X%08X r31=%08X%08X\n", (UINT32)(mips3->r[28] >> 32), (UINT32)mips3->r[28], (UINT32)(mips3->r[29] >> 32), (UINT32)mips3->r[29], (UINT32)(mips3->r[30] >> 32), (UINT32)mips3->r[30], (UINT32)(mips3->r[31] >> 32), (UINT32)mips3->r[31]); printf(" hi=%08X%08X lo=%08X%08X\n", (UINT32)(mips3->r[REG_HI] >> 32), (UINT32)mips3->r[REG_HI], (UINT32)(mips3->r[REG_LO] >> 32), (UINT32)mips3->r[REG_LO]); }
/*------------------------------------------------- cfunc_printf_probe - print the current CPU state and return -------------------------------------------------*/
print the current CPU state and return
[ "print", "the", "current", "CPU", "state", "and", "return" ]
static void cfunc_printf_probe(void *param) { mips3_state *mips3 = (mips3_state *)param; printf(" PC=%08X r1=%08X%08X r2=%08X%08X r3=%08X%08X\n", mips3->pc, (UINT32)(mips3->r[1] >> 32), (UINT32)mips3->r[1], (UINT32)(mips3->r[2] >> 32), (UINT32)mips3->r[2], (UINT32)(mips3->r[3] >> 32), (UINT32)mips3->r[3]); printf(" r4=%08X%08X r5=%08X%08X r6=%08X%08X r7=%08X%08X\n", (UINT32)(mips3->r[4] >> 32), (UINT32)mips3->r[4], (UINT32)(mips3->r[5] >> 32), (UINT32)mips3->r[5], (UINT32)(mips3->r[6] >> 32), (UINT32)mips3->r[6], (UINT32)(mips3->r[7] >> 32), (UINT32)mips3->r[7]); printf(" r8=%08X%08X r9=%08X%08X r10=%08X%08X r11=%08X%08X\n", (UINT32)(mips3->r[8] >> 32), (UINT32)mips3->r[8], (UINT32)(mips3->r[9] >> 32), (UINT32)mips3->r[9], (UINT32)(mips3->r[10] >> 32), (UINT32)mips3->r[10], (UINT32)(mips3->r[11] >> 32), (UINT32)mips3->r[11]); printf("r12=%08X%08X r13=%08X%08X r14=%08X%08X r15=%08X%08X\n", (UINT32)(mips3->r[12] >> 32), (UINT32)mips3->r[12], (UINT32)(mips3->r[13] >> 32), (UINT32)mips3->r[13], (UINT32)(mips3->r[14] >> 32), (UINT32)mips3->r[14], (UINT32)(mips3->r[15] >> 32), (UINT32)mips3->r[15]); printf("r16=%08X%08X r17=%08X%08X r18=%08X%08X r19=%08X%08X\n", (UINT32)(mips3->r[16] >> 32), (UINT32)mips3->r[16], (UINT32)(mips3->r[17] >> 32), (UINT32)mips3->r[17], (UINT32)(mips3->r[18] >> 32), (UINT32)mips3->r[18], (UINT32)(mips3->r[19] >> 32), (UINT32)mips3->r[19]); printf("r20=%08X%08X r21=%08X%08X r22=%08X%08X r23=%08X%08X\n", (UINT32)(mips3->r[20] >> 32), (UINT32)mips3->r[20], (UINT32)(mips3->r[21] >> 32), (UINT32)mips3->r[21], (UINT32)(mips3->r[22] >> 32), (UINT32)mips3->r[22], (UINT32)(mips3->r[23] >> 32), (UINT32)mips3->r[23]); printf("r24=%08X%08X r25=%08X%08X r26=%08X%08X r27=%08X%08X\n", (UINT32)(mips3->r[24] >> 32), (UINT32)mips3->r[24], (UINT32)(mips3->r[25] >> 32), (UINT32)mips3->r[25], (UINT32)(mips3->r[26] >> 32), (UINT32)mips3->r[26], (UINT32)(mips3->r[27] >> 32), (UINT32)mips3->r[27]); printf("r28=%08X%08X r29=%08X%08X r30=%08X%08X r31=%08X%08X\n", (UINT32)(mips3->r[28] >> 32), (UINT32)mips3->r[28], (UINT32)(mips3->r[29] >> 32), (UINT32)mips3->r[29], (UINT32)(mips3->r[30] >> 32), (UINT32)mips3->r[30], (UINT32)(mips3->r[31] >> 32), (UINT32)mips3->r[31]); printf(" hi=%08X%08X lo=%08X%08X\n", (UINT32)(mips3->r[REG_HI] >> 32), (UINT32)mips3->r[REG_HI], (UINT32)(mips3->r[REG_LO] >> 32), (UINT32)mips3->r[REG_LO]); }
[ "static", "void", "cfunc_printf_probe", "(", "void", "*", "param", ")", "{", "mips3_state", "*", "mips3", "=", "(", "mips3_state", "*", ")", "param", ";", "printf", "(", "\"", "\\n", "\"", ",", "mips3", "->", "pc", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "1", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "1", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "2", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "2", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "3", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "3", "]", ")", ";", "printf", "(", "\"", "\\n", "\"", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "4", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "4", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "5", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "5", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "6", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "6", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "7", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "7", "]", ")", ";", "printf", "(", "\"", "\\n", "\"", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "8", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "8", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "9", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "9", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "10", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "10", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "11", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "11", "]", ")", ";", "printf", "(", "\"", "\\n", "\"", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "12", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "12", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "13", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "13", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "14", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "14", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "15", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "15", "]", ")", ";", "printf", "(", "\"", "\\n", "\"", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "16", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "16", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "17", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "17", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "18", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "18", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "19", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "19", "]", ")", ";", "printf", "(", "\"", "\\n", "\"", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "20", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "20", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "21", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "21", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "22", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "22", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "23", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "23", "]", ")", ";", "printf", "(", "\"", "\\n", "\"", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "24", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "24", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "25", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "25", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "26", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "26", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "27", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "27", "]", ")", ";", "printf", "(", "\"", "\\n", "\"", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "28", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "28", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "29", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "29", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "30", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "30", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "31", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "31", "]", ")", ";", "printf", "(", "\"", "\\n", "\"", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "REG_HI", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "REG_HI", "]", ",", "(", "UINT32", ")", "(", "mips3", "->", "r", "[", "REG_LO", "]", ">>", "32", ")", ",", "(", "UINT32", ")", "mips3", "->", "r", "[", "REG_LO", "]", ")", ";", "}" ]
cfunc_printf_probe - print the current CPU state and return
[ "cfunc_printf_probe", "-", "print", "the", "current", "CPU", "state", "and", "return" ]
[]
[ { "param": "param", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "param", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
612bae9f912bf2501143484d4179568700a1b17d
lofunz/mieme
Reloaded/trunk/src/emu/cpu/mips/mips3drc.c
[ "Unlicense" ]
C
static_generate_nocode_handler
void
static void static_generate_nocode_handler(mips3_state *mips3) { drcuml_state *drcuml = mips3->impstate->drcuml; drcuml_block *block; jmp_buf errorbuf; /* if we get an error back, we're screwed */ if (setjmp(errorbuf) != 0) fatalerror("Unrecoverable error in static_generate_nocode_handler"); /* begin generating */ block = drcuml_block_begin(drcuml, 10, &errorbuf); /* generate a hash jump via the current mode and PC */ alloc_handle(drcuml, &mips3->impstate->nocode, "nocode"); UML_HANDLE(block, mips3->impstate->nocode); // handle nocode UML_GETEXP(block, IREG(0)); // getexp i0 UML_MOV(block, MEM(&mips3->pc), IREG(0)); // mov [pc],i0 save_fast_iregs(mips3, block); UML_EXIT(block, IMM(EXECUTE_MISSING_CODE)); // exit EXECUTE_MISSING_CODE drcuml_block_end(block); }
/*------------------------------------------------- static_generate_nocode_handler - generate an exception handler for "out of code" -------------------------------------------------*/
generate an exception handler for "out of code"
[ "generate", "an", "exception", "handler", "for", "\"", "out", "of", "code", "\"" ]
static void static_generate_nocode_handler(mips3_state *mips3) { drcuml_state *drcuml = mips3->impstate->drcuml; drcuml_block *block; jmp_buf errorbuf; if (setjmp(errorbuf) != 0) fatalerror("Unrecoverable error in static_generate_nocode_handler"); block = drcuml_block_begin(drcuml, 10, &errorbuf); alloc_handle(drcuml, &mips3->impstate->nocode, "nocode"); UML_HANDLE(block, mips3->impstate->nocode); UML_GETEXP(block, IREG(0)); UML_MOV(block, MEM(&mips3->pc), IREG(0)); save_fast_iregs(mips3, block); UML_EXIT(block, IMM(EXECUTE_MISSING_CODE)); drcuml_block_end(block); }
[ "static", "void", "static_generate_nocode_handler", "(", "mips3_state", "*", "mips3", ")", "{", "drcuml_state", "*", "drcuml", "=", "mips3", "->", "impstate", "->", "drcuml", ";", "drcuml_block", "*", "block", ";", "jmp_buf", "errorbuf", ";", "if", "(", "setjmp", "(", "errorbuf", ")", "!=", "0", ")", "fatalerror", "(", "\"", "\"", ")", ";", "block", "=", "drcuml_block_begin", "(", "drcuml", ",", "10", ",", "&", "errorbuf", ")", ";", "alloc_handle", "(", "drcuml", ",", "&", "mips3", "->", "impstate", "->", "nocode", ",", "\"", "\"", ")", ";", "UML_HANDLE", "(", "block", ",", "mips3", "->", "impstate", "->", "nocode", ")", ";", "UML_GETEXP", "(", "block", ",", "IREG", "(", "0", ")", ")", ";", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "mips3", "->", "pc", ")", ",", "IREG", "(", "0", ")", ")", ";", "save_fast_iregs", "(", "mips3", ",", "block", ")", ";", "UML_EXIT", "(", "block", ",", "IMM", "(", "EXECUTE_MISSING_CODE", ")", ")", ";", "drcuml_block_end", "(", "block", ")", ";", "}" ]
static_generate_nocode_handler - generate an exception handler for "out of code"
[ "static_generate_nocode_handler", "-", "generate", "an", "exception", "handler", "for", "\"", "out", "of", "code", "\"" ]
[ "/* if we get an error back, we're screwed */", "/* begin generating */", "/* generate a hash jump via the current mode and PC */", "// handle nocode\r", "// getexp i0\r", "// mov [pc],i0\r", "// exit EXECUTE_MISSING_CODE\r" ]
[ { "param": "mips3", "type": "mips3_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mips3", "type": "mips3_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
612bae9f912bf2501143484d4179568700a1b17d
lofunz/mieme
Reloaded/trunk/src/emu/cpu/mips/mips3drc.c
[ "Unlicense" ]
C
static_generate_out_of_cycles
void
static void static_generate_out_of_cycles(mips3_state *mips3) { drcuml_state *drcuml = mips3->impstate->drcuml; drcuml_block *block; jmp_buf errorbuf; /* if we get an error back, we're screwed */ if (setjmp(errorbuf) != 0) fatalerror("Unrecoverable error in static_generate_out_of_cycles"); /* begin generating */ block = drcuml_block_begin(drcuml, 10, &errorbuf); /* generate a hash jump via the current mode and PC */ alloc_handle(drcuml, &mips3->impstate->out_of_cycles, "out_of_cycles"); UML_HANDLE(block, mips3->impstate->out_of_cycles); // handle out_of_cycles UML_GETEXP(block, IREG(0)); // getexp i0 UML_MOV(block, MEM(&mips3->pc), IREG(0)); // mov <pc>,i0 save_fast_iregs(mips3, block); UML_EXIT(block, IMM(EXECUTE_OUT_OF_CYCLES)); // exit EXECUTE_OUT_OF_CYCLES drcuml_block_end(block); }
/*------------------------------------------------- static_generate_out_of_cycles - generate an out of cycles exception handler -------------------------------------------------*/
generate an out of cycles exception handler
[ "generate", "an", "out", "of", "cycles", "exception", "handler" ]
static void static_generate_out_of_cycles(mips3_state *mips3) { drcuml_state *drcuml = mips3->impstate->drcuml; drcuml_block *block; jmp_buf errorbuf; if (setjmp(errorbuf) != 0) fatalerror("Unrecoverable error in static_generate_out_of_cycles"); block = drcuml_block_begin(drcuml, 10, &errorbuf); alloc_handle(drcuml, &mips3->impstate->out_of_cycles, "out_of_cycles"); UML_HANDLE(block, mips3->impstate->out_of_cycles); UML_GETEXP(block, IREG(0)); UML_MOV(block, MEM(&mips3->pc), IREG(0)); save_fast_iregs(mips3, block); UML_EXIT(block, IMM(EXECUTE_OUT_OF_CYCLES)); drcuml_block_end(block); }
[ "static", "void", "static_generate_out_of_cycles", "(", "mips3_state", "*", "mips3", ")", "{", "drcuml_state", "*", "drcuml", "=", "mips3", "->", "impstate", "->", "drcuml", ";", "drcuml_block", "*", "block", ";", "jmp_buf", "errorbuf", ";", "if", "(", "setjmp", "(", "errorbuf", ")", "!=", "0", ")", "fatalerror", "(", "\"", "\"", ")", ";", "block", "=", "drcuml_block_begin", "(", "drcuml", ",", "10", ",", "&", "errorbuf", ")", ";", "alloc_handle", "(", "drcuml", ",", "&", "mips3", "->", "impstate", "->", "out_of_cycles", ",", "\"", "\"", ")", ";", "UML_HANDLE", "(", "block", ",", "mips3", "->", "impstate", "->", "out_of_cycles", ")", ";", "UML_GETEXP", "(", "block", ",", "IREG", "(", "0", ")", ")", ";", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "mips3", "->", "pc", ")", ",", "IREG", "(", "0", ")", ")", ";", "save_fast_iregs", "(", "mips3", ",", "block", ")", ";", "UML_EXIT", "(", "block", ",", "IMM", "(", "EXECUTE_OUT_OF_CYCLES", ")", ")", ";", "drcuml_block_end", "(", "block", ")", ";", "}" ]
static_generate_out_of_cycles - generate an out of cycles exception handler
[ "static_generate_out_of_cycles", "-", "generate", "an", "out", "of", "cycles", "exception", "handler" ]
[ "/* if we get an error back, we're screwed */", "/* begin generating */", "/* generate a hash jump via the current mode and PC */", "// handle out_of_cycles\r", "// getexp i0\r", "// mov <pc>,i0\r", "// exit EXECUTE_OUT_OF_CYCLES\r" ]
[ { "param": "mips3", "type": "mips3_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mips3", "type": "mips3_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
612bae9f912bf2501143484d4179568700a1b17d
lofunz/mieme
Reloaded/trunk/src/emu/cpu/mips/mips3drc.c
[ "Unlicense" ]
C
generate_update_mode
void
static void generate_update_mode(mips3_state *mips3, drcuml_block *block) { UML_ROLAND(block, IREG(2), IREG(0), IMM(32-2), IMM(0x06)); // roland i2,i0,32-2,0x06 UML_TEST(block, IREG(0), IMM(SR_EXL | SR_ERL)); // test i0,SR_EXL | SR_ERL UML_MOVc(block, IF_NZ, IREG(2), IMM(0)); // mov i2,0,nz UML_ROLINS(block, IREG(2), IREG(0), IMM(32-26), IMM(0x01)); // rolins i2,i0,32-26,0x01 UML_MOV(block, MEM(&mips3->impstate->mode), IREG(2)); // mov [mode],i2 }
/*------------------------------------------------- generate_update_mode - update the mode based on a new SR (in i0); trashes i2 -------------------------------------------------*/
update the mode based on a new SR (in i0); trashes i2
[ "update", "the", "mode", "based", "on", "a", "new", "SR", "(", "in", "i0", ")", ";", "trashes", "i2" ]
static void generate_update_mode(mips3_state *mips3, drcuml_block *block) { UML_ROLAND(block, IREG(2), IREG(0), IMM(32-2), IMM(0x06)); UML_TEST(block, IREG(0), IMM(SR_EXL | SR_ERL)); UML_MOVc(block, IF_NZ, IREG(2), IMM(0)); UML_ROLINS(block, IREG(2), IREG(0), IMM(32-26), IMM(0x01)); UML_MOV(block, MEM(&mips3->impstate->mode), IREG(2)); }
[ "static", "void", "generate_update_mode", "(", "mips3_state", "*", "mips3", ",", "drcuml_block", "*", "block", ")", "{", "UML_ROLAND", "(", "block", ",", "IREG", "(", "2", ")", ",", "IREG", "(", "0", ")", ",", "IMM", "(", "32", "-", "2", ")", ",", "IMM", "(", "0x06", ")", ")", ";", "UML_TEST", "(", "block", ",", "IREG", "(", "0", ")", ",", "IMM", "(", "SR_EXL", "|", "SR_ERL", ")", ")", ";", "UML_MOVc", "(", "block", ",", "IF_NZ", ",", "IREG", "(", "2", ")", ",", "IMM", "(", "0", ")", ")", ";", "UML_ROLINS", "(", "block", ",", "IREG", "(", "2", ")", ",", "IREG", "(", "0", ")", ",", "IMM", "(", "32", "-", "26", ")", ",", "IMM", "(", "0x01", ")", ")", ";", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "mips3", "->", "impstate", "->", "mode", ")", ",", "IREG", "(", "2", ")", ")", ";", "}" ]
generate_update_mode - update the mode based on a new SR (in i0); trashes i2
[ "generate_update_mode", "-", "update", "the", "mode", "based", "on", "a", "new", "SR", "(", "in", "i0", ")", ";", "trashes", "i2" ]
[ "// roland i2,i0,32-2,0x06\r", "// test i0,SR_EXL | SR_ERL\r", "// mov i2,0,nz\r", "// rolins i2,i0,32-26,0x01\r", "// mov [mode],i2\r" ]
[ { "param": "mips3", "type": "mips3_state" }, { "param": "block", "type": "drcuml_block" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mips3", "type": "mips3_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": [] }
612bae9f912bf2501143484d4179568700a1b17d
lofunz/mieme
Reloaded/trunk/src/emu/cpu/mips/mips3drc.c
[ "Unlicense" ]
C
generate_update_cycles
void
static void generate_update_cycles(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, drcuml_ptype ptype, UINT64 pvalue, int allow_exception) { /* check software interrupts if pending */ if (compiler->checksoftints) { drcuml_codelabel skip; compiler->checksoftints = FALSE; UML_AND(block, IREG(0), CPR032(COP0_Cause), CPR032(COP0_Status)); // and i0,[Cause],[Status] UML_AND(block, IREG(0), IREG(0), IMM(0x0300)); // and i0,i0,0x0300 UML_JMPc(block, IF_Z, skip = compiler->labelnum++); // jmp skip,Z UML_MOV(block, IREG(0), PARAM(ptype, pvalue)); // mov i0,nextpc UML_MOV(block, IREG(1), IMM(compiler->cycles)); // mov i1,cycles UML_CALLH(block, mips3->impstate->exception_norecover[EXCEPTION_INTERRUPT]);// callh interrupt_norecover UML_LABEL(block, skip); // skip: } /* check full interrupts if pending */ if (compiler->checkints) { drcuml_codelabel skip; compiler->checkints = FALSE; UML_AND(block, IREG(0), CPR032(COP0_Cause), CPR032(COP0_Status)); // and i0,[Cause],[Status] UML_AND(block, IREG(0), IREG(0), IMM(0xfc00)); // and i0,i0,0xfc00 UML_JMPc(block, IF_Z, skip = compiler->labelnum++); // jmp skip,Z UML_TEST(block, CPR032(COP0_Status), IMM(SR_IE)); // test [Status],SR_IE UML_JMPc(block, IF_Z, skip); // jmp skip,Z UML_TEST(block, CPR032(COP0_Status), IMM(SR_EXL | SR_ERL)); // test [Status],SR_EXL | SR_ERL UML_JMPc(block, IF_NZ, skip); // jmp skip,NZ UML_MOV(block, IREG(0), PARAM(ptype, pvalue)); // mov i0,nextpc UML_MOV(block, IREG(1), IMM(compiler->cycles)); // mov i1,cycles UML_CALLH(block, mips3->impstate->exception_norecover[EXCEPTION_INTERRUPT]);// callh interrupt_norecover UML_LABEL(block, skip); // skip: } /* account for cycles */ if (compiler->cycles > 0) { UML_SUB(block, MEM(&mips3->icount), MEM(&mips3->icount), MAPVAR_CYCLES); // sub icount,icount,cycles UML_MAPVAR(block, MAPVAR_CYCLES, 0); // mapvar cycles,0 if (allow_exception) UML_EXHc(block, IF_S, mips3->impstate->out_of_cycles, PARAM(ptype, pvalue)); // exh out_of_cycles,nextpc } compiler->cycles = 0; }
/*------------------------------------------------- generate_update_cycles - generate code to subtract cycles from the icount and generate an exception if out -------------------------------------------------*/
generate code to subtract cycles from the icount and generate an exception if out
[ "generate", "code", "to", "subtract", "cycles", "from", "the", "icount", "and", "generate", "an", "exception", "if", "out" ]
static void generate_update_cycles(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, drcuml_ptype ptype, UINT64 pvalue, int allow_exception) { if (compiler->checksoftints) { drcuml_codelabel skip; compiler->checksoftints = FALSE; UML_AND(block, IREG(0), CPR032(COP0_Cause), CPR032(COP0_Status)); UML_AND(block, IREG(0), IREG(0), IMM(0x0300)); UML_JMPc(block, IF_Z, skip = compiler->labelnum++); UML_MOV(block, IREG(0), PARAM(ptype, pvalue)); UML_MOV(block, IREG(1), IMM(compiler->cycles)); UML_CALLH(block, mips3->impstate->exception_norecover[EXCEPTION_INTERRUPT]); UML_LABEL(block, skip); } if (compiler->checkints) { drcuml_codelabel skip; compiler->checkints = FALSE; UML_AND(block, IREG(0), CPR032(COP0_Cause), CPR032(COP0_Status)); UML_AND(block, IREG(0), IREG(0), IMM(0xfc00)); UML_JMPc(block, IF_Z, skip = compiler->labelnum++); UML_TEST(block, CPR032(COP0_Status), IMM(SR_IE)); UML_JMPc(block, IF_Z, skip); UML_TEST(block, CPR032(COP0_Status), IMM(SR_EXL | SR_ERL)); UML_JMPc(block, IF_NZ, skip); UML_MOV(block, IREG(0), PARAM(ptype, pvalue)); UML_MOV(block, IREG(1), IMM(compiler->cycles)); UML_CALLH(block, mips3->impstate->exception_norecover[EXCEPTION_INTERRUPT]); UML_LABEL(block, skip); } if (compiler->cycles > 0) { UML_SUB(block, MEM(&mips3->icount), MEM(&mips3->icount), MAPVAR_CYCLES); UML_MAPVAR(block, MAPVAR_CYCLES, 0); if (allow_exception) UML_EXHc(block, IF_S, mips3->impstate->out_of_cycles, PARAM(ptype, pvalue)); } compiler->cycles = 0; }
[ "static", "void", "generate_update_cycles", "(", "mips3_state", "*", "mips3", ",", "drcuml_block", "*", "block", ",", "compiler_state", "*", "compiler", ",", "drcuml_ptype", "ptype", ",", "UINT64", "pvalue", ",", "int", "allow_exception", ")", "{", "if", "(", "compiler", "->", "checksoftints", ")", "{", "drcuml_codelabel", "skip", ";", "compiler", "->", "checksoftints", "=", "FALSE", ";", "UML_AND", "(", "block", ",", "IREG", "(", "0", ")", ",", "CPR032", "(", "COP0_Cause", ")", ",", "CPR032", "(", "COP0_Status", ")", ")", ";", "UML_AND", "(", "block", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "0", ")", ",", "IMM", "(", "0x0300", ")", ")", ";", "UML_JMPc", "(", "block", ",", "IF_Z", ",", "skip", "=", "compiler", "->", "labelnum", "++", ")", ";", "UML_MOV", "(", "block", ",", "IREG", "(", "0", ")", ",", "PARAM", "(", "ptype", ",", "pvalue", ")", ")", ";", "UML_MOV", "(", "block", ",", "IREG", "(", "1", ")", ",", "IMM", "(", "compiler", "->", "cycles", ")", ")", ";", "UML_CALLH", "(", "block", ",", "mips3", "->", "impstate", "->", "exception_norecover", "[", "EXCEPTION_INTERRUPT", "]", ")", ";", "UML_LABEL", "(", "block", ",", "skip", ")", ";", "}", "if", "(", "compiler", "->", "checkints", ")", "{", "drcuml_codelabel", "skip", ";", "compiler", "->", "checkints", "=", "FALSE", ";", "UML_AND", "(", "block", ",", "IREG", "(", "0", ")", ",", "CPR032", "(", "COP0_Cause", ")", ",", "CPR032", "(", "COP0_Status", ")", ")", ";", "UML_AND", "(", "block", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "0", ")", ",", "IMM", "(", "0xfc00", ")", ")", ";", "UML_JMPc", "(", "block", ",", "IF_Z", ",", "skip", "=", "compiler", "->", "labelnum", "++", ")", ";", "UML_TEST", "(", "block", ",", "CPR032", "(", "COP0_Status", ")", ",", "IMM", "(", "SR_IE", ")", ")", ";", "UML_JMPc", "(", "block", ",", "IF_Z", ",", "skip", ")", ";", "UML_TEST", "(", "block", ",", "CPR032", "(", "COP0_Status", ")", ",", "IMM", "(", "SR_EXL", "|", "SR_ERL", ")", ")", ";", "UML_JMPc", "(", "block", ",", "IF_NZ", ",", "skip", ")", ";", "UML_MOV", "(", "block", ",", "IREG", "(", "0", ")", ",", "PARAM", "(", "ptype", ",", "pvalue", ")", ")", ";", "UML_MOV", "(", "block", ",", "IREG", "(", "1", ")", ",", "IMM", "(", "compiler", "->", "cycles", ")", ")", ";", "UML_CALLH", "(", "block", ",", "mips3", "->", "impstate", "->", "exception_norecover", "[", "EXCEPTION_INTERRUPT", "]", ")", ";", "UML_LABEL", "(", "block", ",", "skip", ")", ";", "}", "if", "(", "compiler", "->", "cycles", ">", "0", ")", "{", "UML_SUB", "(", "block", ",", "MEM", "(", "&", "mips3", "->", "icount", ")", ",", "MEM", "(", "&", "mips3", "->", "icount", ")", ",", "MAPVAR_CYCLES", ")", ";", "UML_MAPVAR", "(", "block", ",", "MAPVAR_CYCLES", ",", "0", ")", ";", "if", "(", "allow_exception", ")", "UML_EXHc", "(", "block", ",", "IF_S", ",", "mips3", "->", "impstate", "->", "out_of_cycles", ",", "PARAM", "(", "ptype", ",", "pvalue", ")", ")", ";", "}", "compiler", "->", "cycles", "=", "0", ";", "}" ]
generate_update_cycles - generate code to subtract cycles from the icount and generate an exception if out
[ "generate_update_cycles", "-", "generate", "code", "to", "subtract", "cycles", "from", "the", "icount", "and", "generate", "an", "exception", "if", "out" ]
[ "/* check software interrupts if pending */", "// and i0,[Cause],[Status]\r", "// and i0,i0,0x0300\r", "// jmp skip,Z\r", "// mov i0,nextpc\r", "// mov i1,cycles\r", "// callh interrupt_norecover\r", "// skip:\r", "/* check full interrupts if pending */", "// and i0,[Cause],[Status]\r", "// and i0,i0,0xfc00\r", "// jmp skip,Z\r", "// test [Status],SR_IE\r", "// jmp skip,Z\r", "// test [Status],SR_EXL | SR_ERL\r", "// jmp skip,NZ\r", "// mov i0,nextpc\r", "// mov i1,cycles\r", "// callh interrupt_norecover\r", "// skip:\r", "/* account for cycles */", "// sub icount,icount,cycles\r", "// mapvar cycles,0\r", "// exh out_of_cycles,nextpc\r" ]
[ { "param": "mips3", "type": "mips3_state" }, { "param": "block", "type": "drcuml_block" }, { "param": "compiler", "type": "compiler_state" }, { "param": "ptype", "type": "drcuml_ptype" }, { "param": "pvalue", "type": "UINT64" }, { "param": "allow_exception", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mips3", "type": "mips3_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "compiler", "type": "compiler_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ptype", "type": "drcuml_ptype", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pvalue", "type": "UINT64", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "allow_exception", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
612bae9f912bf2501143484d4179568700a1b17d
lofunz/mieme
Reloaded/trunk/src/emu/cpu/mips/mips3drc.c
[ "Unlicense" ]
C
generate_checksum_block
void
static void generate_checksum_block(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *seqhead, const opcode_desc *seqlast) { const opcode_desc *curdesc; if (LOG_UML) UML_COMMENT(block, "[Validation for %08X]", seqhead->pc); // comment /* loose verify or single instruction: just compare and fail */ if (!(mips3->impstate->drcoptions & MIPS3DRC_STRICT_VERIFY) || seqhead->next == NULL) { if (!(seqhead->flags & OPFLAG_VIRTUAL_NOOP)) { void *base = memory_decrypted_read_ptr(mips3->program, seqhead->physpc); UML_LOAD(block, IREG(0), base, IMM(0), DWORD); // load i0,base,0,dword UML_CMP(block, IREG(0), IMM(seqhead->opptr.l[0])); // cmp i0,opptr[0] UML_EXHc(block, IF_NE, mips3->impstate->nocode, IMM(epc(seqhead))); // exne nocode,seqhead->pc } } /* full verification; sum up everything */ else { #if 0 for (curdesc = seqhead->next; curdesc != seqlast->next; curdesc = curdesc->next) if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP)) { void *base = memory_decrypted_read_ptr(mips3->program, seqhead->physpc); UML_LOAD(block, IREG(0), base, IMM(0), DWORD); // load i0,base,0,dword UML_CMP(block, IREG(0), IMM(curdesc->opptr.l[0])); // cmp i0,opptr[0] UML_EXHc(block, IF_NE, mips3->impstate->nocode, IMM(epc(seqhead))); // exne nocode,seqhead->pc } #else UINT32 sum = 0; void *base = memory_decrypted_read_ptr(mips3->program, seqhead->physpc); UML_LOAD(block, IREG(0), base, IMM(0), DWORD); // load i0,base,0,dword sum += seqhead->opptr.l[0]; for (curdesc = seqhead->next; curdesc != seqlast->next; curdesc = curdesc->next) if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP)) { base = memory_decrypted_read_ptr(mips3->program, curdesc->physpc); UML_LOAD(block, IREG(1), base, IMM(0), DWORD); // load i1,base,dword UML_ADD(block, IREG(0), IREG(0), IREG(1)); // add i0,i0,i1 sum += curdesc->opptr.l[0]; } UML_CMP(block, IREG(0), IMM(sum)); // cmp i0,sum UML_EXHc(block, IF_NE, mips3->impstate->nocode, IMM(epc(seqhead))); // exne nocode,seqhead->pc #endif } }
/*------------------------------------------------- generate_checksum_block - generate code to validate a sequence of opcodes -------------------------------------------------*/
generate code to validate a sequence of opcodes
[ "generate", "code", "to", "validate", "a", "sequence", "of", "opcodes" ]
static void generate_checksum_block(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *seqhead, const opcode_desc *seqlast) { const opcode_desc *curdesc; if (LOG_UML) UML_COMMENT(block, "[Validation for %08X]", seqhead->pc); if (!(mips3->impstate->drcoptions & MIPS3DRC_STRICT_VERIFY) || seqhead->next == NULL) { if (!(seqhead->flags & OPFLAG_VIRTUAL_NOOP)) { void *base = memory_decrypted_read_ptr(mips3->program, seqhead->physpc); UML_LOAD(block, IREG(0), base, IMM(0), DWORD); UML_CMP(block, IREG(0), IMM(seqhead->opptr.l[0])); UML_EXHc(block, IF_NE, mips3->impstate->nocode, IMM(epc(seqhead))); } } else { #if 0 for (curdesc = seqhead->next; curdesc != seqlast->next; curdesc = curdesc->next) if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP)) { void *base = memory_decrypted_read_ptr(mips3->program, seqhead->physpc); UML_LOAD(block, IREG(0), base, IMM(0), DWORD); UML_CMP(block, IREG(0), IMM(curdesc->opptr.l[0])); UML_EXHc(block, IF_NE, mips3->impstate->nocode, IMM(epc(seqhead))); } #else UINT32 sum = 0; void *base = memory_decrypted_read_ptr(mips3->program, seqhead->physpc); UML_LOAD(block, IREG(0), base, IMM(0), DWORD); sum += seqhead->opptr.l[0]; for (curdesc = seqhead->next; curdesc != seqlast->next; curdesc = curdesc->next) if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP)) { base = memory_decrypted_read_ptr(mips3->program, curdesc->physpc); UML_LOAD(block, IREG(1), base, IMM(0), DWORD); UML_ADD(block, IREG(0), IREG(0), IREG(1)); sum += curdesc->opptr.l[0]; } UML_CMP(block, IREG(0), IMM(sum)); UML_EXHc(block, IF_NE, mips3->impstate->nocode, IMM(epc(seqhead))); #endif } }
[ "static", "void", "generate_checksum_block", "(", "mips3_state", "*", "mips3", ",", "drcuml_block", "*", "block", ",", "compiler_state", "*", "compiler", ",", "const", "opcode_desc", "*", "seqhead", ",", "const", "opcode_desc", "*", "seqlast", ")", "{", "const", "opcode_desc", "*", "curdesc", ";", "if", "(", "LOG_UML", ")", "UML_COMMENT", "(", "block", ",", "\"", "\"", ",", "seqhead", "->", "pc", ")", ";", "if", "(", "!", "(", "mips3", "->", "impstate", "->", "drcoptions", "&", "MIPS3DRC_STRICT_VERIFY", ")", "||", "seqhead", "->", "next", "==", "NULL", ")", "{", "if", "(", "!", "(", "seqhead", "->", "flags", "&", "OPFLAG_VIRTUAL_NOOP", ")", ")", "{", "void", "*", "base", "=", "memory_decrypted_read_ptr", "(", "mips3", "->", "program", ",", "seqhead", "->", "physpc", ")", ";", "UML_LOAD", "(", "block", ",", "IREG", "(", "0", ")", ",", "base", ",", "IMM", "(", "0", ")", ",", "DWORD", ")", ";", "UML_CMP", "(", "block", ",", "IREG", "(", "0", ")", ",", "IMM", "(", "seqhead", "->", "opptr", ".", "l", "[", "0", "]", ")", ")", ";", "UML_EXHc", "(", "block", ",", "IF_NE", ",", "mips3", "->", "impstate", "->", "nocode", ",", "IMM", "(", "epc", "(", "seqhead", ")", ")", ")", ";", "}", "}", "else", "{", "#if", "0", "\n", "for", "(", "curdesc", "=", "seqhead", "->", "next", ";", "curdesc", "!=", "seqlast", "->", "next", ";", "curdesc", "=", "curdesc", "->", "next", ")", "if", "(", "!", "(", "curdesc", "->", "flags", "&", "OPFLAG_VIRTUAL_NOOP", ")", ")", "{", "void", "*", "base", "=", "memory_decrypted_read_ptr", "(", "mips3", "->", "program", ",", "seqhead", "->", "physpc", ")", ";", "UML_LOAD", "(", "block", ",", "IREG", "(", "0", ")", ",", "base", ",", "IMM", "(", "0", ")", ",", "DWORD", ")", ";", "UML_CMP", "(", "block", ",", "IREG", "(", "0", ")", ",", "IMM", "(", "curdesc", "->", "opptr", ".", "l", "[", "0", "]", ")", ")", ";", "UML_EXHc", "(", "block", ",", "IF_NE", ",", "mips3", "->", "impstate", "->", "nocode", ",", "IMM", "(", "epc", "(", "seqhead", ")", ")", ")", ";", "}", "#else", "UINT32", "sum", "=", "0", ";", "void", "*", "base", "=", "memory_decrypted_read_ptr", "(", "mips3", "->", "program", ",", "seqhead", "->", "physpc", ")", ";", "UML_LOAD", "(", "block", ",", "IREG", "(", "0", ")", ",", "base", ",", "IMM", "(", "0", ")", ",", "DWORD", ")", ";", "sum", "+=", "seqhead", "->", "opptr", ".", "l", "[", "0", "]", ";", "for", "(", "curdesc", "=", "seqhead", "->", "next", ";", "curdesc", "!=", "seqlast", "->", "next", ";", "curdesc", "=", "curdesc", "->", "next", ")", "if", "(", "!", "(", "curdesc", "->", "flags", "&", "OPFLAG_VIRTUAL_NOOP", ")", ")", "{", "base", "=", "memory_decrypted_read_ptr", "(", "mips3", "->", "program", ",", "curdesc", "->", "physpc", ")", ";", "UML_LOAD", "(", "block", ",", "IREG", "(", "1", ")", ",", "base", ",", "IMM", "(", "0", ")", ",", "DWORD", ")", ";", "UML_ADD", "(", "block", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "1", ")", ")", ";", "sum", "+=", "curdesc", "->", "opptr", ".", "l", "[", "0", "]", ";", "}", "UML_CMP", "(", "block", ",", "IREG", "(", "0", ")", ",", "IMM", "(", "sum", ")", ")", ";", "UML_EXHc", "(", "block", ",", "IF_NE", ",", "mips3", "->", "impstate", "->", "nocode", ",", "IMM", "(", "epc", "(", "seqhead", ")", ")", ")", ";", "#endif", "}", "}" ]
generate_checksum_block - generate code to validate a sequence of opcodes
[ "generate_checksum_block", "-", "generate", "code", "to", "validate", "a", "sequence", "of", "opcodes" ]
[ "// comment\r", "/* loose verify or single instruction: just compare and fail */", "// load i0,base,0,dword\r", "// cmp i0,opptr[0]\r", "// exne nocode,seqhead->pc\r", "/* full verification; sum up everything */", "// load i0,base,0,dword\r", "// cmp i0,opptr[0]\r", "// exne nocode,seqhead->pc\r", "// load i0,base,0,dword\r", "// load i1,base,dword\r", "// add i0,i0,i1\r", "// cmp i0,sum\r", "// exne nocode,seqhead->pc\r" ]
[ { "param": "mips3", "type": "mips3_state" }, { "param": "block", "type": "drcuml_block" }, { "param": "compiler", "type": "compiler_state" }, { "param": "seqhead", "type": "opcode_desc" }, { "param": "seqlast", "type": "opcode_desc" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mips3", "type": "mips3_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "compiler", "type": "compiler_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "seqhead", "type": "opcode_desc", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "seqlast", "type": "opcode_desc", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
612bae9f912bf2501143484d4179568700a1b17d
lofunz/mieme
Reloaded/trunk/src/emu/cpu/mips/mips3drc.c
[ "Unlicense" ]
C
generate_sequence_instruction
void
static void generate_sequence_instruction(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) { offs_t expc; int hotnum; /* add an entry for the log */ if (LOG_UML && !(desc->flags & OPFLAG_VIRTUAL_NOOP)) log_add_disasm_comment(mips3, block, desc->pc, desc->opptr.l[0]); /* set the PC map variable */ expc = (desc->flags & OPFLAG_IN_DELAY_SLOT) ? desc->pc - 3 : desc->pc; UML_MAPVAR(block, MAPVAR_PC, expc); // mapvar PC,expc /* accumulate total cycles */ compiler->cycles += desc->cycles; /* is this a hotspot? */ for (hotnum = 0; hotnum < MIPS3_MAX_HOTSPOTS; hotnum++) if (mips3->impstate->hotspot[hotnum].pc != 0 && desc->pc == mips3->impstate->hotspot[hotnum].pc && desc->opptr.l[0] == mips3->impstate->hotspot[hotnum].opcode) { compiler->cycles += mips3->impstate->hotspot[hotnum].cycles; break; } /* update the icount map variable */ UML_MAPVAR(block, MAPVAR_CYCLES, compiler->cycles); // mapvar CYCLES,compiler->cycles /* if we want a probe, add it here */ if (desc->pc == PROBE_ADDRESS) { UML_MOV(block, MEM(&mips3->pc), IMM(desc->pc)); // mov [pc],desc->pc UML_CALLC(block, cfunc_printf_probe, mips3); // callc cfunc_printf_probe,mips3 } /* if we are debugging, call the debugger */ if ((mips3->device->machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) { UML_MOV(block, MEM(&mips3->pc), IMM(desc->pc)); // mov [pc],desc->pc save_fast_iregs(mips3, block); UML_DEBUG(block, IMM(desc->pc)); // debug desc->pc } /* if we hit an unmapped address, fatal error */ if (desc->flags & OPFLAG_COMPILER_UNMAPPED) { UML_MOV(block, MEM(&mips3->pc), IMM(desc->pc)); // mov [pc],desc->pc save_fast_iregs(mips3, block); UML_EXIT(block, IMM(EXECUTE_UNMAPPED_CODE)); // exit EXECUTE_UNMAPPED_CODE } /* if we hit a compiler page fault, it's just like a TLB mismatch */ if (desc->flags & OPFLAG_COMPILER_PAGE_FAULT) { if (PRINTF_MMU) { static const char text[] = "Compiler page fault @ %08X"; UML_MOV(block, MEM(&mips3->impstate->format), IMM((FPTR)text)); // mov [format],text UML_MOV(block, MEM(&mips3->impstate->arg0), IMM(desc->pc)); // mov [arg0],desc->pc UML_CALLC(block, cfunc_printf_debug, mips3); // callc printf_debug } UML_EXH(block, mips3->impstate->tlb_mismatch, IMM(0)); // exh tlb_mismatch,0 } /* validate our TLB entry at this PC; if we fail, we need to handle it */ if ((desc->flags & OPFLAG_VALIDATE_TLB) && (desc->pc < 0x80000000 || desc->pc >= 0xc0000000)) { const vtlb_entry *tlbtable = vtlb_table(mips3->vtlb); /* if we currently have a valid TLB read entry, we just verify */ if (tlbtable[desc->pc >> 12] & VTLB_FETCH_ALLOWED) { if (PRINTF_MMU) { static const char text[] = "Checking TLB at @ %08X\n"; UML_MOV(block, MEM(&mips3->impstate->format), IMM((FPTR)text)); // mov [format],text UML_MOV(block, MEM(&mips3->impstate->arg0), IMM(desc->pc)); // mov [arg0],desc->pc UML_CALLC(block, cfunc_printf_debug, mips3); // callc printf_debug } UML_LOAD(block, IREG(0), &tlbtable[desc->pc >> 12], IMM(0), DWORD); // load i0,tlbtable[desc->pc >> 12],0,dword UML_CMP(block, IREG(0), IMM(tlbtable[desc->pc >> 12])); // cmp i0,*tlbentry UML_EXHc(block, IF_NE, mips3->impstate->tlb_mismatch, IMM(0)); // exh tlb_mismatch,0,NE } /* otherwise, we generate an unconditional exception */ else { if (PRINTF_MMU) { static const char text[] = "No valid TLB @ %08X\n"; UML_MOV(block, MEM(&mips3->impstate->format), IMM((FPTR)text)); // mov [format],text UML_MOV(block, MEM(&mips3->impstate->arg0), IMM(desc->pc)); // mov [arg0],desc->pc UML_CALLC(block, cfunc_printf_debug, mips3); // callc printf_debug } UML_EXH(block, mips3->impstate->tlb_mismatch, IMM(0)); // exh tlb_mismatch,0 } } /* if this is an invalid opcode, generate the exception now */ if (desc->flags & OPFLAG_INVALID_OPCODE) UML_EXH(block, mips3->impstate->exception[EXCEPTION_INVALIDOP], IMM(0)); // exh invalidop,0 /* otherwise, unless this is a virtual no-op, it's a regular instruction */ else if (!(desc->flags & OPFLAG_VIRTUAL_NOOP)) { /* compile the instruction */ if (!generate_opcode(mips3, block, compiler, desc)) { UML_MOV(block, MEM(&mips3->pc), IMM(desc->pc)); // mov [pc],desc->pc UML_MOV(block, MEM(&mips3->impstate->arg0), IMM(desc->opptr.l[0])); // mov [arg0],desc->opptr.l UML_CALLC(block, cfunc_unimplemented, mips3); // callc cfunc_unimplemented } } }
/*------------------------------------------------- generate_sequence_instruction - generate code for a single instruction in a sequence -------------------------------------------------*/
generate code for a single instruction in a sequence
[ "generate", "code", "for", "a", "single", "instruction", "in", "a", "sequence" ]
static void generate_sequence_instruction(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) { offs_t expc; int hotnum; if (LOG_UML && !(desc->flags & OPFLAG_VIRTUAL_NOOP)) log_add_disasm_comment(mips3, block, desc->pc, desc->opptr.l[0]); expc = (desc->flags & OPFLAG_IN_DELAY_SLOT) ? desc->pc - 3 : desc->pc; UML_MAPVAR(block, MAPVAR_PC, expc); compiler->cycles += desc->cycles; for (hotnum = 0; hotnum < MIPS3_MAX_HOTSPOTS; hotnum++) if (mips3->impstate->hotspot[hotnum].pc != 0 && desc->pc == mips3->impstate->hotspot[hotnum].pc && desc->opptr.l[0] == mips3->impstate->hotspot[hotnum].opcode) { compiler->cycles += mips3->impstate->hotspot[hotnum].cycles; break; } UML_MAPVAR(block, MAPVAR_CYCLES, compiler->cycles); if (desc->pc == PROBE_ADDRESS) { UML_MOV(block, MEM(&mips3->pc), IMM(desc->pc)); UML_CALLC(block, cfunc_printf_probe, mips3); } if ((mips3->device->machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) { UML_MOV(block, MEM(&mips3->pc), IMM(desc->pc)); save_fast_iregs(mips3, block); UML_DEBUG(block, IMM(desc->pc)); } if (desc->flags & OPFLAG_COMPILER_UNMAPPED) { UML_MOV(block, MEM(&mips3->pc), IMM(desc->pc)); save_fast_iregs(mips3, block); UML_EXIT(block, IMM(EXECUTE_UNMAPPED_CODE)); } if (desc->flags & OPFLAG_COMPILER_PAGE_FAULT) { if (PRINTF_MMU) { static const char text[] = "Compiler page fault @ %08X"; UML_MOV(block, MEM(&mips3->impstate->format), IMM((FPTR)text)); UML_MOV(block, MEM(&mips3->impstate->arg0), IMM(desc->pc)); UML_CALLC(block, cfunc_printf_debug, mips3); } UML_EXH(block, mips3->impstate->tlb_mismatch, IMM(0)); } if ((desc->flags & OPFLAG_VALIDATE_TLB) && (desc->pc < 0x80000000 || desc->pc >= 0xc0000000)) { const vtlb_entry *tlbtable = vtlb_table(mips3->vtlb); if (tlbtable[desc->pc >> 12] & VTLB_FETCH_ALLOWED) { if (PRINTF_MMU) { static const char text[] = "Checking TLB at @ %08X\n"; UML_MOV(block, MEM(&mips3->impstate->format), IMM((FPTR)text)); UML_MOV(block, MEM(&mips3->impstate->arg0), IMM(desc->pc)); UML_CALLC(block, cfunc_printf_debug, mips3); } UML_LOAD(block, IREG(0), &tlbtable[desc->pc >> 12], IMM(0), DWORD); UML_CMP(block, IREG(0), IMM(tlbtable[desc->pc >> 12])); UML_EXHc(block, IF_NE, mips3->impstate->tlb_mismatch, IMM(0)); } else { if (PRINTF_MMU) { static const char text[] = "No valid TLB @ %08X\n"; UML_MOV(block, MEM(&mips3->impstate->format), IMM((FPTR)text)); UML_MOV(block, MEM(&mips3->impstate->arg0), IMM(desc->pc)); UML_CALLC(block, cfunc_printf_debug, mips3); } UML_EXH(block, mips3->impstate->tlb_mismatch, IMM(0)); } } if (desc->flags & OPFLAG_INVALID_OPCODE) UML_EXH(block, mips3->impstate->exception[EXCEPTION_INVALIDOP], IMM(0)); else if (!(desc->flags & OPFLAG_VIRTUAL_NOOP)) { if (!generate_opcode(mips3, block, compiler, desc)) { UML_MOV(block, MEM(&mips3->pc), IMM(desc->pc)); UML_MOV(block, MEM(&mips3->impstate->arg0), IMM(desc->opptr.l[0])); UML_CALLC(block, cfunc_unimplemented, mips3); } } }
[ "static", "void", "generate_sequence_instruction", "(", "mips3_state", "*", "mips3", ",", "drcuml_block", "*", "block", ",", "compiler_state", "*", "compiler", ",", "const", "opcode_desc", "*", "desc", ")", "{", "offs_t", "expc", ";", "int", "hotnum", ";", "if", "(", "LOG_UML", "&&", "!", "(", "desc", "->", "flags", "&", "OPFLAG_VIRTUAL_NOOP", ")", ")", "log_add_disasm_comment", "(", "mips3", ",", "block", ",", "desc", "->", "pc", ",", "desc", "->", "opptr", ".", "l", "[", "0", "]", ")", ";", "expc", "=", "(", "desc", "->", "flags", "&", "OPFLAG_IN_DELAY_SLOT", ")", "?", "desc", "->", "pc", "-", "3", ":", "desc", "->", "pc", ";", "UML_MAPVAR", "(", "block", ",", "MAPVAR_PC", ",", "expc", ")", ";", "compiler", "->", "cycles", "+=", "desc", "->", "cycles", ";", "for", "(", "hotnum", "=", "0", ";", "hotnum", "<", "MIPS3_MAX_HOTSPOTS", ";", "hotnum", "++", ")", "if", "(", "mips3", "->", "impstate", "->", "hotspot", "[", "hotnum", "]", ".", "pc", "!=", "0", "&&", "desc", "->", "pc", "==", "mips3", "->", "impstate", "->", "hotspot", "[", "hotnum", "]", ".", "pc", "&&", "desc", "->", "opptr", ".", "l", "[", "0", "]", "==", "mips3", "->", "impstate", "->", "hotspot", "[", "hotnum", "]", ".", "opcode", ")", "{", "compiler", "->", "cycles", "+=", "mips3", "->", "impstate", "->", "hotspot", "[", "hotnum", "]", ".", "cycles", ";", "break", ";", "}", "UML_MAPVAR", "(", "block", ",", "MAPVAR_CYCLES", ",", "compiler", "->", "cycles", ")", ";", "if", "(", "desc", "->", "pc", "==", "PROBE_ADDRESS", ")", "{", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "mips3", "->", "pc", ")", ",", "IMM", "(", "desc", "->", "pc", ")", ")", ";", "UML_CALLC", "(", "block", ",", "cfunc_printf_probe", ",", "mips3", ")", ";", "}", "if", "(", "(", "mips3", "->", "device", "->", "machine", "->", "debug_flags", "&", "DEBUG_FLAG_ENABLED", ")", "!=", "0", ")", "{", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "mips3", "->", "pc", ")", ",", "IMM", "(", "desc", "->", "pc", ")", ")", ";", "save_fast_iregs", "(", "mips3", ",", "block", ")", ";", "UML_DEBUG", "(", "block", ",", "IMM", "(", "desc", "->", "pc", ")", ")", ";", "}", "if", "(", "desc", "->", "flags", "&", "OPFLAG_COMPILER_UNMAPPED", ")", "{", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "mips3", "->", "pc", ")", ",", "IMM", "(", "desc", "->", "pc", ")", ")", ";", "save_fast_iregs", "(", "mips3", ",", "block", ")", ";", "UML_EXIT", "(", "block", ",", "IMM", "(", "EXECUTE_UNMAPPED_CODE", ")", ")", ";", "}", "if", "(", "desc", "->", "flags", "&", "OPFLAG_COMPILER_PAGE_FAULT", ")", "{", "if", "(", "PRINTF_MMU", ")", "{", "static", "const", "char", "text", "[", "]", "=", "\"", "\"", ";", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "mips3", "->", "impstate", "->", "format", ")", ",", "IMM", "(", "(", "FPTR", ")", "text", ")", ")", ";", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "mips3", "->", "impstate", "->", "arg0", ")", ",", "IMM", "(", "desc", "->", "pc", ")", ")", ";", "UML_CALLC", "(", "block", ",", "cfunc_printf_debug", ",", "mips3", ")", ";", "}", "UML_EXH", "(", "block", ",", "mips3", "->", "impstate", "->", "tlb_mismatch", ",", "IMM", "(", "0", ")", ")", ";", "}", "if", "(", "(", "desc", "->", "flags", "&", "OPFLAG_VALIDATE_TLB", ")", "&&", "(", "desc", "->", "pc", "<", "0x80000000", "||", "desc", "->", "pc", ">=", "0xc0000000", ")", ")", "{", "const", "vtlb_entry", "*", "tlbtable", "=", "vtlb_table", "(", "mips3", "->", "vtlb", ")", ";", "if", "(", "tlbtable", "[", "desc", "->", "pc", ">>", "12", "]", "&", "VTLB_FETCH_ALLOWED", ")", "{", "if", "(", "PRINTF_MMU", ")", "{", "static", "const", "char", "text", "[", "]", "=", "\"", "\\n", "\"", ";", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "mips3", "->", "impstate", "->", "format", ")", ",", "IMM", "(", "(", "FPTR", ")", "text", ")", ")", ";", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "mips3", "->", "impstate", "->", "arg0", ")", ",", "IMM", "(", "desc", "->", "pc", ")", ")", ";", "UML_CALLC", "(", "block", ",", "cfunc_printf_debug", ",", "mips3", ")", ";", "}", "UML_LOAD", "(", "block", ",", "IREG", "(", "0", ")", ",", "&", "tlbtable", "[", "desc", "->", "pc", ">>", "12", "]", ",", "IMM", "(", "0", ")", ",", "DWORD", ")", ";", "UML_CMP", "(", "block", ",", "IREG", "(", "0", ")", ",", "IMM", "(", "tlbtable", "[", "desc", "->", "pc", ">>", "12", "]", ")", ")", ";", "UML_EXHc", "(", "block", ",", "IF_NE", ",", "mips3", "->", "impstate", "->", "tlb_mismatch", ",", "IMM", "(", "0", ")", ")", ";", "}", "else", "{", "if", "(", "PRINTF_MMU", ")", "{", "static", "const", "char", "text", "[", "]", "=", "\"", "\\n", "\"", ";", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "mips3", "->", "impstate", "->", "format", ")", ",", "IMM", "(", "(", "FPTR", ")", "text", ")", ")", ";", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "mips3", "->", "impstate", "->", "arg0", ")", ",", "IMM", "(", "desc", "->", "pc", ")", ")", ";", "UML_CALLC", "(", "block", ",", "cfunc_printf_debug", ",", "mips3", ")", ";", "}", "UML_EXH", "(", "block", ",", "mips3", "->", "impstate", "->", "tlb_mismatch", ",", "IMM", "(", "0", ")", ")", ";", "}", "}", "if", "(", "desc", "->", "flags", "&", "OPFLAG_INVALID_OPCODE", ")", "UML_EXH", "(", "block", ",", "mips3", "->", "impstate", "->", "exception", "[", "EXCEPTION_INVALIDOP", "]", ",", "IMM", "(", "0", ")", ")", ";", "else", "if", "(", "!", "(", "desc", "->", "flags", "&", "OPFLAG_VIRTUAL_NOOP", ")", ")", "{", "if", "(", "!", "generate_opcode", "(", "mips3", ",", "block", ",", "compiler", ",", "desc", ")", ")", "{", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "mips3", "->", "pc", ")", ",", "IMM", "(", "desc", "->", "pc", ")", ")", ";", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "mips3", "->", "impstate", "->", "arg0", ")", ",", "IMM", "(", "desc", "->", "opptr", ".", "l", "[", "0", "]", ")", ")", ";", "UML_CALLC", "(", "block", ",", "cfunc_unimplemented", ",", "mips3", ")", ";", "}", "}", "}" ]
generate_sequence_instruction - generate code for a single instruction in a sequence
[ "generate_sequence_instruction", "-", "generate", "code", "for", "a", "single", "instruction", "in", "a", "sequence" ]
[ "/* add an entry for the log */", "/* set the PC map variable */", "// mapvar PC,expc\r", "/* accumulate total cycles */", "/* is this a hotspot? */", "/* update the icount map variable */", "// mapvar CYCLES,compiler->cycles\r", "/* if we want a probe, add it here */", "// mov [pc],desc->pc\r", "// callc cfunc_printf_probe,mips3\r", "/* if we are debugging, call the debugger */", "// mov [pc],desc->pc\r", "// debug desc->pc\r", "/* if we hit an unmapped address, fatal error */", "// mov [pc],desc->pc\r", "// exit EXECUTE_UNMAPPED_CODE\r", "/* if we hit a compiler page fault, it's just like a TLB mismatch */", "// mov [format],text\r", "// mov [arg0],desc->pc\r", "// callc printf_debug\r", "// exh tlb_mismatch,0\r", "/* validate our TLB entry at this PC; if we fail, we need to handle it */", "/* if we currently have a valid TLB read entry, we just verify */", "// mov [format],text\r", "// mov [arg0],desc->pc\r", "// callc printf_debug\r", "// load i0,tlbtable[desc->pc >> 12],0,dword\r", "// cmp i0,*tlbentry\r", "// exh tlb_mismatch,0,NE\r", "/* otherwise, we generate an unconditional exception */", "// mov [format],text\r", "// mov [arg0],desc->pc\r", "// callc printf_debug\r", "// exh tlb_mismatch,0\r", "/* if this is an invalid opcode, generate the exception now */", "// exh invalidop,0\r", "/* otherwise, unless this is a virtual no-op, it's a regular instruction */", "/* compile the instruction */", "// mov [pc],desc->pc\r", "// mov [arg0],desc->opptr.l\r", "// callc cfunc_unimplemented\r" ]
[ { "param": "mips3", "type": "mips3_state" }, { "param": "block", "type": "drcuml_block" }, { "param": "compiler", "type": "compiler_state" }, { "param": "desc", "type": "opcode_desc" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mips3", "type": "mips3_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "compiler", "type": "compiler_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "desc", "type": "opcode_desc", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
612bae9f912bf2501143484d4179568700a1b17d
lofunz/mieme
Reloaded/trunk/src/emu/cpu/mips/mips3drc.c
[ "Unlicense" ]
C
generate_regimm
int
static int generate_regimm(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) { UINT32 op = desc->opptr.l[0]; UINT8 opswitch = RTREG; drcuml_codelabel skip; switch (opswitch) { case 0x00: /* BLTZ */ case 0x02: /* BLTZL */ case 0x10: /* BLTZAL */ case 0x12: /* BLTZALL */ if (RSREG != 0) { UML_DCMP(block, R64(RSREG), IMM(0)); // dcmp <rsreg>,0 UML_JMPc(block, IF_GE, skip = compiler->labelnum++); // jmp skip,GE generate_delay_slot_and_branch(mips3, block, compiler, desc, (opswitch & 0x10) ? 31 : 0); // <next instruction + hashjmp> UML_LABEL(block, skip); // skip: } return TRUE; case 0x01: /* BGEZ */ case 0x03: /* BGEZL */ case 0x11: /* BGEZAL */ case 0x13: /* BGEZALL */ if (RSREG != 0) { UML_DCMP(block, R64(RSREG), IMM(0)); // dcmp <rsreg>,0 UML_JMPc(block, IF_L, skip = compiler->labelnum++); // jmp skip,L generate_delay_slot_and_branch(mips3, block, compiler, desc, (opswitch & 0x10) ? 31 : 0); // <next instruction + hashjmp> UML_LABEL(block, skip); // skip: } else generate_delay_slot_and_branch(mips3, block, compiler, desc, (opswitch & 0x10) ? 31 : 0); // <next instruction + hashjmp> return TRUE; case 0x08: /* TGEI */ UML_DCMP(block, R64(RSREG), IMM(SIMMVAL)); // dcmp <rsreg>,SIMMVAL UML_EXHc(block, IF_GE, mips3->impstate->exception[EXCEPTION_TRAP], IMM(0));// exh trap,0,GE return TRUE; case 0x09: /* TGEIU */ UML_DCMP(block, R64(RSREG), IMM(SIMMVAL)); // dcmp <rsreg>,SIMMVAL UML_EXHc(block, IF_AE, mips3->impstate->exception[EXCEPTION_TRAP], IMM(0));// exh trap,0,AE return TRUE; case 0x0a: /* TLTI */ UML_DCMP(block, R64(RSREG), IMM(SIMMVAL)); // dcmp <rsreg>,SIMMVAL UML_EXHc(block, IF_L, mips3->impstate->exception[EXCEPTION_TRAP], IMM(0));// exh trap,0,L return TRUE; case 0x0b: /* TLTIU */ UML_DCMP(block, R64(RSREG), IMM(SIMMVAL)); // dcmp <rsreg>,SIMMVAL UML_EXHc(block, IF_B, mips3->impstate->exception[EXCEPTION_TRAP], IMM(0));// exh trap,0,B return TRUE; case 0x0c: /* TEQI */ UML_DCMP(block, R64(RSREG), IMM(SIMMVAL)); // dcmp <rsreg>,SIMMVAL UML_EXHc(block, IF_E, mips3->impstate->exception[EXCEPTION_TRAP], IMM(0));// exh trap,0,E return TRUE; case 0x0e: /* TNEI */ UML_DCMP(block, R64(RSREG), IMM(SIMMVAL)); // dcmp <rsreg>,SIMMVAL UML_EXHc(block, IF_NE, mips3->impstate->exception[EXCEPTION_TRAP], IMM(0));// exh trap,0,NE return TRUE; } return FALSE; }
/*------------------------------------------------- generate_regimm - compile opcodes in the 'REGIMM' group -------------------------------------------------*/
compile opcodes in the 'REGIMM' group
[ "compile", "opcodes", "in", "the", "'", "REGIMM", "'", "group" ]
static int generate_regimm(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) { UINT32 op = desc->opptr.l[0]; UINT8 opswitch = RTREG; drcuml_codelabel skip; switch (opswitch) { case 0x00: case 0x02: case 0x10: case 0x12: if (RSREG != 0) { UML_DCMP(block, R64(RSREG), IMM(0)); UML_JMPc(block, IF_GE, skip = compiler->labelnum++); generate_delay_slot_and_branch(mips3, block, compiler, desc, (opswitch & 0x10) ? 31 : 0); UML_LABEL(block, skip); } return TRUE; case 0x01: case 0x03: case 0x11: case 0x13: if (RSREG != 0) { UML_DCMP(block, R64(RSREG), IMM(0)); UML_JMPc(block, IF_L, skip = compiler->labelnum++); generate_delay_slot_and_branch(mips3, block, compiler, desc, (opswitch & 0x10) ? 31 : 0); UML_LABEL(block, skip); } else generate_delay_slot_and_branch(mips3, block, compiler, desc, (opswitch & 0x10) ? 31 : 0); return TRUE; case 0x08: UML_DCMP(block, R64(RSREG), IMM(SIMMVAL)); UML_EXHc(block, IF_GE, mips3->impstate->exception[EXCEPTION_TRAP], IMM(0)); return TRUE; case 0x09: UML_DCMP(block, R64(RSREG), IMM(SIMMVAL)); UML_EXHc(block, IF_AE, mips3->impstate->exception[EXCEPTION_TRAP], IMM(0)); return TRUE; case 0x0a: UML_DCMP(block, R64(RSREG), IMM(SIMMVAL)); UML_EXHc(block, IF_L, mips3->impstate->exception[EXCEPTION_TRAP], IMM(0)); return TRUE; case 0x0b: UML_DCMP(block, R64(RSREG), IMM(SIMMVAL)); UML_EXHc(block, IF_B, mips3->impstate->exception[EXCEPTION_TRAP], IMM(0)); return TRUE; case 0x0c: UML_DCMP(block, R64(RSREG), IMM(SIMMVAL)); UML_EXHc(block, IF_E, mips3->impstate->exception[EXCEPTION_TRAP], IMM(0)); return TRUE; case 0x0e: UML_DCMP(block, R64(RSREG), IMM(SIMMVAL)); UML_EXHc(block, IF_NE, mips3->impstate->exception[EXCEPTION_TRAP], IMM(0)); return TRUE; } return FALSE; }
[ "static", "int", "generate_regimm", "(", "mips3_state", "*", "mips3", ",", "drcuml_block", "*", "block", ",", "compiler_state", "*", "compiler", ",", "const", "opcode_desc", "*", "desc", ")", "{", "UINT32", "op", "=", "desc", "->", "opptr", ".", "l", "[", "0", "]", ";", "UINT8", "opswitch", "=", "RTREG", ";", "drcuml_codelabel", "skip", ";", "switch", "(", "opswitch", ")", "{", "case", "0x00", ":", "case", "0x02", ":", "case", "0x10", ":", "case", "0x12", ":", "if", "(", "RSREG", "!=", "0", ")", "{", "UML_DCMP", "(", "block", ",", "R64", "(", "RSREG", ")", ",", "IMM", "(", "0", ")", ")", ";", "UML_JMPc", "(", "block", ",", "IF_GE", ",", "skip", "=", "compiler", "->", "labelnum", "++", ")", ";", "generate_delay_slot_and_branch", "(", "mips3", ",", "block", ",", "compiler", ",", "desc", ",", "(", "opswitch", "&", "0x10", ")", "?", "31", ":", "0", ")", ";", "UML_LABEL", "(", "block", ",", "skip", ")", ";", "}", "return", "TRUE", ";", "case", "0x01", ":", "case", "0x03", ":", "case", "0x11", ":", "case", "0x13", ":", "if", "(", "RSREG", "!=", "0", ")", "{", "UML_DCMP", "(", "block", ",", "R64", "(", "RSREG", ")", ",", "IMM", "(", "0", ")", ")", ";", "UML_JMPc", "(", "block", ",", "IF_L", ",", "skip", "=", "compiler", "->", "labelnum", "++", ")", ";", "generate_delay_slot_and_branch", "(", "mips3", ",", "block", ",", "compiler", ",", "desc", ",", "(", "opswitch", "&", "0x10", ")", "?", "31", ":", "0", ")", ";", "UML_LABEL", "(", "block", ",", "skip", ")", ";", "}", "else", "generate_delay_slot_and_branch", "(", "mips3", ",", "block", ",", "compiler", ",", "desc", ",", "(", "opswitch", "&", "0x10", ")", "?", "31", ":", "0", ")", ";", "return", "TRUE", ";", "case", "0x08", ":", "UML_DCMP", "(", "block", ",", "R64", "(", "RSREG", ")", ",", "IMM", "(", "SIMMVAL", ")", ")", ";", "UML_EXHc", "(", "block", ",", "IF_GE", ",", "mips3", "->", "impstate", "->", "exception", "[", "EXCEPTION_TRAP", "]", ",", "IMM", "(", "0", ")", ")", ";", "return", "TRUE", ";", "case", "0x09", ":", "UML_DCMP", "(", "block", ",", "R64", "(", "RSREG", ")", ",", "IMM", "(", "SIMMVAL", ")", ")", ";", "UML_EXHc", "(", "block", ",", "IF_AE", ",", "mips3", "->", "impstate", "->", "exception", "[", "EXCEPTION_TRAP", "]", ",", "IMM", "(", "0", ")", ")", ";", "return", "TRUE", ";", "case", "0x0a", ":", "UML_DCMP", "(", "block", ",", "R64", "(", "RSREG", ")", ",", "IMM", "(", "SIMMVAL", ")", ")", ";", "UML_EXHc", "(", "block", ",", "IF_L", ",", "mips3", "->", "impstate", "->", "exception", "[", "EXCEPTION_TRAP", "]", ",", "IMM", "(", "0", ")", ")", ";", "return", "TRUE", ";", "case", "0x0b", ":", "UML_DCMP", "(", "block", ",", "R64", "(", "RSREG", ")", ",", "IMM", "(", "SIMMVAL", ")", ")", ";", "UML_EXHc", "(", "block", ",", "IF_B", ",", "mips3", "->", "impstate", "->", "exception", "[", "EXCEPTION_TRAP", "]", ",", "IMM", "(", "0", ")", ")", ";", "return", "TRUE", ";", "case", "0x0c", ":", "UML_DCMP", "(", "block", ",", "R64", "(", "RSREG", ")", ",", "IMM", "(", "SIMMVAL", ")", ")", ";", "UML_EXHc", "(", "block", ",", "IF_E", ",", "mips3", "->", "impstate", "->", "exception", "[", "EXCEPTION_TRAP", "]", ",", "IMM", "(", "0", ")", ")", ";", "return", "TRUE", ";", "case", "0x0e", ":", "UML_DCMP", "(", "block", ",", "R64", "(", "RSREG", ")", ",", "IMM", "(", "SIMMVAL", ")", ")", ";", "UML_EXHc", "(", "block", ",", "IF_NE", ",", "mips3", "->", "impstate", "->", "exception", "[", "EXCEPTION_TRAP", "]", ",", "IMM", "(", "0", ")", ")", ";", "return", "TRUE", ";", "}", "return", "FALSE", ";", "}" ]
generate_regimm - compile opcodes in the 'REGIMM' group
[ "generate_regimm", "-", "compile", "opcodes", "in", "the", "'", "REGIMM", "'", "group" ]
[ "/* BLTZ */", "/* BLTZL */", "/* BLTZAL */", "/* BLTZALL */", "// dcmp <rsreg>,0\r", "// jmp skip,GE\r", "// <next instruction + hashjmp>\r", "// skip:\r", "/* BGEZ */", "/* BGEZL */", "/* BGEZAL */", "/* BGEZALL */", "// dcmp <rsreg>,0\r", "// jmp skip,L\r", "// <next instruction + hashjmp>\r", "// skip:\r", "// <next instruction + hashjmp>\r", "/* TGEI */", "// dcmp <rsreg>,SIMMVAL\r", "// exh trap,0,GE\r", "/* TGEIU */", "// dcmp <rsreg>,SIMMVAL\r", "// exh trap,0,AE\r", "/* TLTI */", "// dcmp <rsreg>,SIMMVAL\r", "// exh trap,0,L\r", "/* TLTIU */", "// dcmp <rsreg>,SIMMVAL\r", "// exh trap,0,B\r", "/* TEQI */", "// dcmp <rsreg>,SIMMVAL\r", "// exh trap,0,E\r", "/* TNEI */", "// dcmp <rsreg>,SIMMVAL\r", "// exh trap,0,NE\r" ]
[ { "param": "mips3", "type": "mips3_state" }, { "param": "block", "type": "drcuml_block" }, { "param": "compiler", "type": "compiler_state" }, { "param": "desc", "type": "opcode_desc" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mips3", "type": "mips3_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "compiler", "type": "compiler_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "desc", "type": "opcode_desc", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
612bae9f912bf2501143484d4179568700a1b17d
lofunz/mieme
Reloaded/trunk/src/emu/cpu/mips/mips3drc.c
[ "Unlicense" ]
C
generate_idt
int
static int generate_idt(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) { UINT32 op = desc->opptr.l[0]; UINT8 opswitch = op & 0x1f; /* only enabled on IDT processors */ if (mips3->flavor != MIPS3_TYPE_R4650) return FALSE; switch (opswitch) { case 0: /* MAD */ if (RSREG != 0 && RTREG != 0) { UML_MULS(block, IREG(0), IREG(1), R32(RSREG), R32(RTREG)); // muls i0,i1,rsreg,rtreg UML_ADD(block, IREG(0), IREG(0), LO32); // add i0,i0,lo UML_ADDC(block, IREG(1), IREG(1), HI32); // addc i1,i1,hi UML_DSEXT(block, LO64, IREG(0), DWORD); // dsext lo,i0,dword UML_DSEXT(block, HI64, IREG(1), DWORD); // dsext hi,i1,dword } return TRUE; case 1: /* MADU */ if (RSREG != 0 && RTREG != 0) { UML_MULU(block, IREG(0), IREG(1), R32(RSREG), R32(RTREG)); // mulu i0,i1,rsreg,rtreg UML_ADD(block, IREG(0), IREG(0), LO32); // add i0,i0,lo UML_ADDC(block, IREG(1), IREG(1), HI32); // addc i1,i1,hi UML_DSEXT(block, LO64, IREG(0), DWORD); // dsext lo,i0,dword UML_DSEXT(block, HI64, IREG(1), DWORD); // dsext hi,i1,dword } return TRUE; case 2: /* MUL */ if (RDREG != 0) { UML_MULS(block, IREG(0), IREG(0), R32(RSREG), R32(RTREG)); // muls i0,i0,rsreg,rtreg UML_DSEXT(block, R64(RDREG), IREG(0), DWORD); // dsext rdreg,i0,dword } return TRUE; } return FALSE; }
/*------------------------------------------------- generate_idt - compile opcodes in the IDT- specific group -------------------------------------------------*/
compile opcodes in the IDT specific group
[ "compile", "opcodes", "in", "the", "IDT", "specific", "group" ]
static int generate_idt(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) { UINT32 op = desc->opptr.l[0]; UINT8 opswitch = op & 0x1f; if (mips3->flavor != MIPS3_TYPE_R4650) return FALSE; switch (opswitch) { case 0: if (RSREG != 0 && RTREG != 0) { UML_MULS(block, IREG(0), IREG(1), R32(RSREG), R32(RTREG)); UML_ADD(block, IREG(0), IREG(0), LO32); UML_ADDC(block, IREG(1), IREG(1), HI32); UML_DSEXT(block, LO64, IREG(0), DWORD); UML_DSEXT(block, HI64, IREG(1), DWORD); } return TRUE; case 1: if (RSREG != 0 && RTREG != 0) { UML_MULU(block, IREG(0), IREG(1), R32(RSREG), R32(RTREG)); UML_ADD(block, IREG(0), IREG(0), LO32); UML_ADDC(block, IREG(1), IREG(1), HI32); UML_DSEXT(block, LO64, IREG(0), DWORD); UML_DSEXT(block, HI64, IREG(1), DWORD); } return TRUE; case 2: if (RDREG != 0) { UML_MULS(block, IREG(0), IREG(0), R32(RSREG), R32(RTREG)); UML_DSEXT(block, R64(RDREG), IREG(0), DWORD); } return TRUE; } return FALSE; }
[ "static", "int", "generate_idt", "(", "mips3_state", "*", "mips3", ",", "drcuml_block", "*", "block", ",", "compiler_state", "*", "compiler", ",", "const", "opcode_desc", "*", "desc", ")", "{", "UINT32", "op", "=", "desc", "->", "opptr", ".", "l", "[", "0", "]", ";", "UINT8", "opswitch", "=", "op", "&", "0x1f", ";", "if", "(", "mips3", "->", "flavor", "!=", "MIPS3_TYPE_R4650", ")", "return", "FALSE", ";", "switch", "(", "opswitch", ")", "{", "case", "0", ":", "if", "(", "RSREG", "!=", "0", "&&", "RTREG", "!=", "0", ")", "{", "UML_MULS", "(", "block", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "1", ")", ",", "R32", "(", "RSREG", ")", ",", "R32", "(", "RTREG", ")", ")", ";", "UML_ADD", "(", "block", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "0", ")", ",", "LO32", ")", ";", "UML_ADDC", "(", "block", ",", "IREG", "(", "1", ")", ",", "IREG", "(", "1", ")", ",", "HI32", ")", ";", "UML_DSEXT", "(", "block", ",", "LO64", ",", "IREG", "(", "0", ")", ",", "DWORD", ")", ";", "UML_DSEXT", "(", "block", ",", "HI64", ",", "IREG", "(", "1", ")", ",", "DWORD", ")", ";", "}", "return", "TRUE", ";", "case", "1", ":", "if", "(", "RSREG", "!=", "0", "&&", "RTREG", "!=", "0", ")", "{", "UML_MULU", "(", "block", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "1", ")", ",", "R32", "(", "RSREG", ")", ",", "R32", "(", "RTREG", ")", ")", ";", "UML_ADD", "(", "block", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "0", ")", ",", "LO32", ")", ";", "UML_ADDC", "(", "block", ",", "IREG", "(", "1", ")", ",", "IREG", "(", "1", ")", ",", "HI32", ")", ";", "UML_DSEXT", "(", "block", ",", "LO64", ",", "IREG", "(", "0", ")", ",", "DWORD", ")", ";", "UML_DSEXT", "(", "block", ",", "HI64", ",", "IREG", "(", "1", ")", ",", "DWORD", ")", ";", "}", "return", "TRUE", ";", "case", "2", ":", "if", "(", "RDREG", "!=", "0", ")", "{", "UML_MULS", "(", "block", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "0", ")", ",", "R32", "(", "RSREG", ")", ",", "R32", "(", "RTREG", ")", ")", ";", "UML_DSEXT", "(", "block", ",", "R64", "(", "RDREG", ")", ",", "IREG", "(", "0", ")", ",", "DWORD", ")", ";", "}", "return", "TRUE", ";", "}", "return", "FALSE", ";", "}" ]
generate_idt - compile opcodes in the IDT specific group
[ "generate_idt", "-", "compile", "opcodes", "in", "the", "IDT", "specific", "group" ]
[ "/* only enabled on IDT processors */", "/* MAD */", "// muls i0,i1,rsreg,rtreg\r", "// add i0,i0,lo\r", "// addc i1,i1,hi\r", "// dsext lo,i0,dword\r", "// dsext hi,i1,dword\r", "/* MADU */", "// mulu i0,i1,rsreg,rtreg\r", "// add i0,i0,lo\r", "// addc i1,i1,hi\r", "// dsext lo,i0,dword\r", "// dsext hi,i1,dword\r", "/* MUL */", "// muls i0,i0,rsreg,rtreg\r", "// dsext rdreg,i0,dword\r" ]
[ { "param": "mips3", "type": "mips3_state" }, { "param": "block", "type": "drcuml_block" }, { "param": "compiler", "type": "compiler_state" }, { "param": "desc", "type": "opcode_desc" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mips3", "type": "mips3_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "compiler", "type": "compiler_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "desc", "type": "opcode_desc", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
612bae9f912bf2501143484d4179568700a1b17d
lofunz/mieme
Reloaded/trunk/src/emu/cpu/mips/mips3drc.c
[ "Unlicense" ]
C
generate_set_cop0_reg
int
static int generate_set_cop0_reg(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc, UINT8 reg) { int in_delay_slot = ((desc->flags & OPFLAG_IN_DELAY_SLOT) != 0); drcuml_codelabel link; switch (reg) { case COP0_Cause: UML_ROLINS(block, CPR032(COP0_Cause), IREG(0), IMM(0), IMM(~0xfc00)); // rolins [Cause],i0,0,~0xfc00 compiler->checksoftints = TRUE; if (!in_delay_slot) generate_update_cycles(mips3, block, compiler, IMM(desc->pc + 4), TRUE); return TRUE; case COP0_Status: generate_update_cycles(mips3, block, compiler, IMM(desc->pc), !in_delay_slot); // <subtract cycles> UML_MOV(block, IREG(1), CPR032(COP0_Status)); // mov i1,[Status] UML_MOV(block, CPR032(COP0_Status), IREG(0)); // mov [Status],i0 generate_update_mode(mips3, block); // <update mode> UML_XOR(block, IREG(0), IREG(0), IREG(1)); // xor i0,i0,i1 UML_TEST(block, IREG(0), IMM(0x8000)); // test i0,0x8000 UML_CALLCc(block, IF_NZ, mips3com_update_cycle_counting, mips3); // callc mips3com_update_cycle_counting,mips.core,NZ compiler->checkints = TRUE; if (!in_delay_slot) generate_update_cycles(mips3, block, compiler, IMM(desc->pc + 4), TRUE); return TRUE; case COP0_Count: generate_update_cycles(mips3, block, compiler, IMM(desc->pc), !in_delay_slot); // <subtract cycles> UML_MOV(block, CPR032(COP0_Count), IREG(0)); // mov [Count],i0 UML_CALLC(block, cfunc_get_cycles, mips3); // callc cfunc_get_cycles,mips3 UML_DAND(block, IREG(0), IREG(0), IMM(0xffffffff)); // and i0,i0,0xffffffff UML_DADD(block, IREG(0), IREG(0), IREG(0)); // dadd i0,i0,i0 UML_DSUB(block, MEM(&mips3->count_zero_time), MEM(&mips3->impstate->numcycles), IREG(0)); // dsub [count_zero_time],[mips3->impstate->numcycles],i0 UML_CALLC(block, mips3com_update_cycle_counting, mips3); // callc mips3com_update_cycle_counting,mips.core return TRUE; case COP0_Compare: UML_MOV(block, MEM(&mips3->compare_armed), IMM(1)); // mov [compare_armed],1 generate_update_cycles(mips3, block, compiler, IMM(desc->pc), !in_delay_slot); // <subtract cycles> UML_MOV(block, CPR032(COP0_Compare), IREG(0)); // mov [Compare],i0 UML_AND(block, CPR032(COP0_Cause), CPR032(COP0_Cause), IMM(~0x8000)); // and [Cause],[Cause],~0x8000 UML_CALLC(block, mips3com_update_cycle_counting, mips3); // callc mips3com_update_cycle_counting,mips.core return TRUE; case COP0_PRId: return TRUE; case COP0_Config: UML_ROLINS(block, CPR032(COP0_Config), IREG(0), IMM(0), IMM(0x0007)); // rolins [Config],i0,0,0x0007 return TRUE; case COP0_EntryHi: UML_XOR(block, IREG(1), IREG(0), CPR032(reg)); // xor i1,i0,cpr0[reg] UML_MOV(block, CPR032(reg), IREG(0)); // mov cpr0[reg],i0 UML_TEST(block, IREG(1), IMM(0xff)); // test i1,0xff UML_JMPc(block, IF_Z, link = compiler->labelnum++); // jmp link,z UML_CALLC(block, mips3com_asid_changed, mips3); // callc mips3com_asid_changed UML_LABEL(block, link); // link: return TRUE; default: UML_MOV(block, CPR032(reg), IREG(0)); // mov cpr0[reg],i0 return TRUE; } }
/*------------------------------------------------- generate_set_cop0_reg - generate code to handle special COP0 registers -------------------------------------------------*/
generate code to handle special COP0 registers
[ "generate", "code", "to", "handle", "special", "COP0", "registers" ]
static int generate_set_cop0_reg(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc, UINT8 reg) { int in_delay_slot = ((desc->flags & OPFLAG_IN_DELAY_SLOT) != 0); drcuml_codelabel link; switch (reg) { case COP0_Cause: UML_ROLINS(block, CPR032(COP0_Cause), IREG(0), IMM(0), IMM(~0xfc00)); compiler->checksoftints = TRUE; if (!in_delay_slot) generate_update_cycles(mips3, block, compiler, IMM(desc->pc + 4), TRUE); return TRUE; case COP0_Status: generate_update_cycles(mips3, block, compiler, IMM(desc->pc), !in_delay_slot); UML_MOV(block, IREG(1), CPR032(COP0_Status)); UML_MOV(block, CPR032(COP0_Status), IREG(0)); generate_update_mode(mips3, block); UML_XOR(block, IREG(0), IREG(0), IREG(1)); UML_TEST(block, IREG(0), IMM(0x8000)); UML_CALLCc(block, IF_NZ, mips3com_update_cycle_counting, mips3); compiler->checkints = TRUE; if (!in_delay_slot) generate_update_cycles(mips3, block, compiler, IMM(desc->pc + 4), TRUE); return TRUE; case COP0_Count: generate_update_cycles(mips3, block, compiler, IMM(desc->pc), !in_delay_slot); UML_MOV(block, CPR032(COP0_Count), IREG(0)); UML_CALLC(block, cfunc_get_cycles, mips3); UML_DAND(block, IREG(0), IREG(0), IMM(0xffffffff)); UML_DADD(block, IREG(0), IREG(0), IREG(0)); UML_DSUB(block, MEM(&mips3->count_zero_time), MEM(&mips3->impstate->numcycles), IREG(0)); UML_CALLC(block, mips3com_update_cycle_counting, mips3); return TRUE; case COP0_Compare: UML_MOV(block, MEM(&mips3->compare_armed), IMM(1)); generate_update_cycles(mips3, block, compiler, IMM(desc->pc), !in_delay_slot); UML_MOV(block, CPR032(COP0_Compare), IREG(0)); UML_AND(block, CPR032(COP0_Cause), CPR032(COP0_Cause), IMM(~0x8000)); UML_CALLC(block, mips3com_update_cycle_counting, mips3); return TRUE; case COP0_PRId: return TRUE; case COP0_Config: UML_ROLINS(block, CPR032(COP0_Config), IREG(0), IMM(0), IMM(0x0007)); return TRUE; case COP0_EntryHi: UML_XOR(block, IREG(1), IREG(0), CPR032(reg)); UML_MOV(block, CPR032(reg), IREG(0)); UML_TEST(block, IREG(1), IMM(0xff)); UML_JMPc(block, IF_Z, link = compiler->labelnum++); UML_CALLC(block, mips3com_asid_changed, mips3); UML_LABEL(block, link); return TRUE; default: UML_MOV(block, CPR032(reg), IREG(0)); return TRUE; } }
[ "static", "int", "generate_set_cop0_reg", "(", "mips3_state", "*", "mips3", ",", "drcuml_block", "*", "block", ",", "compiler_state", "*", "compiler", ",", "const", "opcode_desc", "*", "desc", ",", "UINT8", "reg", ")", "{", "int", "in_delay_slot", "=", "(", "(", "desc", "->", "flags", "&", "OPFLAG_IN_DELAY_SLOT", ")", "!=", "0", ")", ";", "drcuml_codelabel", "link", ";", "switch", "(", "reg", ")", "{", "case", "COP0_Cause", ":", "UML_ROLINS", "(", "block", ",", "CPR032", "(", "COP0_Cause", ")", ",", "IREG", "(", "0", ")", ",", "IMM", "(", "0", ")", ",", "IMM", "(", "~", "0xfc00", ")", ")", ";", "compiler", "->", "checksoftints", "=", "TRUE", ";", "if", "(", "!", "in_delay_slot", ")", "generate_update_cycles", "(", "mips3", ",", "block", ",", "compiler", ",", "IMM", "(", "desc", "->", "pc", "+", "4", ")", ",", "TRUE", ")", ";", "return", "TRUE", ";", "case", "COP0_Status", ":", "generate_update_cycles", "(", "mips3", ",", "block", ",", "compiler", ",", "IMM", "(", "desc", "->", "pc", ")", ",", "!", "in_delay_slot", ")", ";", "UML_MOV", "(", "block", ",", "IREG", "(", "1", ")", ",", "CPR032", "(", "COP0_Status", ")", ")", ";", "UML_MOV", "(", "block", ",", "CPR032", "(", "COP0_Status", ")", ",", "IREG", "(", "0", ")", ")", ";", "generate_update_mode", "(", "mips3", ",", "block", ")", ";", "UML_XOR", "(", "block", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "1", ")", ")", ";", "UML_TEST", "(", "block", ",", "IREG", "(", "0", ")", ",", "IMM", "(", "0x8000", ")", ")", ";", "UML_CALLCc", "(", "block", ",", "IF_NZ", ",", "mips3com_update_cycle_counting", ",", "mips3", ")", ";", "compiler", "->", "checkints", "=", "TRUE", ";", "if", "(", "!", "in_delay_slot", ")", "generate_update_cycles", "(", "mips3", ",", "block", ",", "compiler", ",", "IMM", "(", "desc", "->", "pc", "+", "4", ")", ",", "TRUE", ")", ";", "return", "TRUE", ";", "case", "COP0_Count", ":", "generate_update_cycles", "(", "mips3", ",", "block", ",", "compiler", ",", "IMM", "(", "desc", "->", "pc", ")", ",", "!", "in_delay_slot", ")", ";", "UML_MOV", "(", "block", ",", "CPR032", "(", "COP0_Count", ")", ",", "IREG", "(", "0", ")", ")", ";", "UML_CALLC", "(", "block", ",", "cfunc_get_cycles", ",", "mips3", ")", ";", "UML_DAND", "(", "block", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "0", ")", ",", "IMM", "(", "0xffffffff", ")", ")", ";", "UML_DADD", "(", "block", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "0", ")", ")", ";", "UML_DSUB", "(", "block", ",", "MEM", "(", "&", "mips3", "->", "count_zero_time", ")", ",", "MEM", "(", "&", "mips3", "->", "impstate", "->", "numcycles", ")", ",", "IREG", "(", "0", ")", ")", ";", "UML_CALLC", "(", "block", ",", "mips3com_update_cycle_counting", ",", "mips3", ")", ";", "return", "TRUE", ";", "case", "COP0_Compare", ":", "UML_MOV", "(", "block", ",", "MEM", "(", "&", "mips3", "->", "compare_armed", ")", ",", "IMM", "(", "1", ")", ")", ";", "generate_update_cycles", "(", "mips3", ",", "block", ",", "compiler", ",", "IMM", "(", "desc", "->", "pc", ")", ",", "!", "in_delay_slot", ")", ";", "UML_MOV", "(", "block", ",", "CPR032", "(", "COP0_Compare", ")", ",", "IREG", "(", "0", ")", ")", ";", "UML_AND", "(", "block", ",", "CPR032", "(", "COP0_Cause", ")", ",", "CPR032", "(", "COP0_Cause", ")", ",", "IMM", "(", "~", "0x8000", ")", ")", ";", "UML_CALLC", "(", "block", ",", "mips3com_update_cycle_counting", ",", "mips3", ")", ";", "return", "TRUE", ";", "case", "COP0_PRId", ":", "return", "TRUE", ";", "case", "COP0_Config", ":", "UML_ROLINS", "(", "block", ",", "CPR032", "(", "COP0_Config", ")", ",", "IREG", "(", "0", ")", ",", "IMM", "(", "0", ")", ",", "IMM", "(", "0x0007", ")", ")", ";", "return", "TRUE", ";", "case", "COP0_EntryHi", ":", "UML_XOR", "(", "block", ",", "IREG", "(", "1", ")", ",", "IREG", "(", "0", ")", ",", "CPR032", "(", "reg", ")", ")", ";", "UML_MOV", "(", "block", ",", "CPR032", "(", "reg", ")", ",", "IREG", "(", "0", ")", ")", ";", "UML_TEST", "(", "block", ",", "IREG", "(", "1", ")", ",", "IMM", "(", "0xff", ")", ")", ";", "UML_JMPc", "(", "block", ",", "IF_Z", ",", "link", "=", "compiler", "->", "labelnum", "++", ")", ";", "UML_CALLC", "(", "block", ",", "mips3com_asid_changed", ",", "mips3", ")", ";", "UML_LABEL", "(", "block", ",", "link", ")", ";", "return", "TRUE", ";", "default", ":", "UML_MOV", "(", "block", ",", "CPR032", "(", "reg", ")", ",", "IREG", "(", "0", ")", ")", ";", "return", "TRUE", ";", "}", "}" ]
generate_set_cop0_reg - generate code to handle special COP0 registers
[ "generate_set_cop0_reg", "-", "generate", "code", "to", "handle", "special", "COP0", "registers" ]
[ "// rolins [Cause],i0,0,~0xfc00\r", "// <subtract cycles>\r", "// mov i1,[Status]\r", "// mov [Status],i0\r", "// <update mode>\r", "// xor i0,i0,i1\r", "// test i0,0x8000\r", "// callc mips3com_update_cycle_counting,mips.core,NZ\r", "// <subtract cycles>\r", "// mov [Count],i0\r", "// callc cfunc_get_cycles,mips3\r", "// and i0,i0,0xffffffff\r", "// dadd i0,i0,i0\r", "// dsub [count_zero_time],[mips3->impstate->numcycles],i0\r", "// callc mips3com_update_cycle_counting,mips.core\r", "// mov [compare_armed],1\r", "// <subtract cycles>\r", "// mov [Compare],i0\r", "// and [Cause],[Cause],~0x8000\r", "// callc mips3com_update_cycle_counting,mips.core\r", "// rolins [Config],i0,0,0x0007\r", "// xor i1,i0,cpr0[reg]\r", "// mov cpr0[reg],i0\r", "// test i1,0xff\r", "// jmp link,z\r", "// callc mips3com_asid_changed\r", "// link:\r", "// mov cpr0[reg],i0\r" ]
[ { "param": "mips3", "type": "mips3_state" }, { "param": "block", "type": "drcuml_block" }, { "param": "compiler", "type": "compiler_state" }, { "param": "desc", "type": "opcode_desc" }, { "param": "reg", "type": "UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mips3", "type": "mips3_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "compiler", "type": "compiler_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "desc", "type": "opcode_desc", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reg", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
612bae9f912bf2501143484d4179568700a1b17d
lofunz/mieme
Reloaded/trunk/src/emu/cpu/mips/mips3drc.c
[ "Unlicense" ]
C
generate_get_cop0_reg
int
static int generate_get_cop0_reg(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc, UINT8 reg) { drcuml_codelabel link1, link2; switch (reg) { case COP0_Count: generate_update_cycles(mips3, block, compiler, IMM(desc->pc), FALSE); // <subtract cycles> UML_CALLC(block, cfunc_get_cycles, mips3); // callc cfunc_get_cycles,mips3 UML_DSUB(block, IREG(0), MEM(&mips3->impstate->numcycles), MEM(&mips3->count_zero_time)); // dsub i0,[numcycles],[count_zero_time] UML_DSHR(block, IREG(0), IREG(0), IMM(1)); // dshr i0,i0,1 UML_DSEXT(block, IREG(0), IREG(0), DWORD); // dsext i0,i0,dword return TRUE; case COP0_Random: generate_update_cycles(mips3, block, compiler, IMM(desc->pc), FALSE); // <subtract cycles> UML_CALLC(block, cfunc_get_cycles, mips3); // callc cfunc_get_cycles,mips3 UML_DSUB(block, IREG(0), MEM(&mips3->impstate->numcycles), MEM(&mips3->count_zero_time)); // dsub i0,[numcycles],[count_zero_time] UML_AND(block, IREG(1), CPR032(COP0_Wired), IMM(0x3f)); // and i1,[Wired],0x3f UML_SUB(block, IREG(2), IMM(48), IREG(1)); // sub i2,48,i1 UML_JMPc(block, IF_BE, link1 = compiler->labelnum++); // jmp link1,BE UML_DAND(block, IREG(2), IREG(2), IMM(0xffffffff)); // dand i2,i2,0xffffffff UML_DDIVU(block, IREG(0), IREG(2), IREG(0), IREG(2)); // ddivu i0,i2,i0,i2 UML_ADD(block, IREG(0), IREG(2), IREG(1)); // add i0,i2,i1 UML_DAND(block, IREG(0), IREG(0), IMM(0x3f)); // dand i0,i0,0x3f UML_JMP(block, link2 = compiler->labelnum++); // jmp link2 UML_LABEL(block, link1); // link1: UML_DMOV(block, IREG(0), IMM(47)); // dmov i0,47 UML_LABEL(block, link2); // link2: return TRUE; default: UML_DSEXT(block, IREG(0), CPR032(reg), DWORD); // dsext i0,cpr0[reg],dword return TRUE; } }
/*------------------------------------------------- generate_get_cop0_reg - generate code to read special COP0 registers -------------------------------------------------*/
generate code to read special COP0 registers
[ "generate", "code", "to", "read", "special", "COP0", "registers" ]
static int generate_get_cop0_reg(mips3_state *mips3, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc, UINT8 reg) { drcuml_codelabel link1, link2; switch (reg) { case COP0_Count: generate_update_cycles(mips3, block, compiler, IMM(desc->pc), FALSE); UML_CALLC(block, cfunc_get_cycles, mips3); UML_DSUB(block, IREG(0), MEM(&mips3->impstate->numcycles), MEM(&mips3->count_zero_time)); UML_DSHR(block, IREG(0), IREG(0), IMM(1)); UML_DSEXT(block, IREG(0), IREG(0), DWORD); return TRUE; case COP0_Random: generate_update_cycles(mips3, block, compiler, IMM(desc->pc), FALSE); UML_CALLC(block, cfunc_get_cycles, mips3); UML_DSUB(block, IREG(0), MEM(&mips3->impstate->numcycles), MEM(&mips3->count_zero_time)); UML_AND(block, IREG(1), CPR032(COP0_Wired), IMM(0x3f)); UML_SUB(block, IREG(2), IMM(48), IREG(1)); UML_JMPc(block, IF_BE, link1 = compiler->labelnum++); UML_DAND(block, IREG(2), IREG(2), IMM(0xffffffff)); UML_DDIVU(block, IREG(0), IREG(2), IREG(0), IREG(2)); UML_ADD(block, IREG(0), IREG(2), IREG(1)); UML_DAND(block, IREG(0), IREG(0), IMM(0x3f)); UML_JMP(block, link2 = compiler->labelnum++); UML_LABEL(block, link1); UML_DMOV(block, IREG(0), IMM(47)); UML_LABEL(block, link2); return TRUE; default: UML_DSEXT(block, IREG(0), CPR032(reg), DWORD); return TRUE; } }
[ "static", "int", "generate_get_cop0_reg", "(", "mips3_state", "*", "mips3", ",", "drcuml_block", "*", "block", ",", "compiler_state", "*", "compiler", ",", "const", "opcode_desc", "*", "desc", ",", "UINT8", "reg", ")", "{", "drcuml_codelabel", "link1", ",", "link2", ";", "switch", "(", "reg", ")", "{", "case", "COP0_Count", ":", "generate_update_cycles", "(", "mips3", ",", "block", ",", "compiler", ",", "IMM", "(", "desc", "->", "pc", ")", ",", "FALSE", ")", ";", "UML_CALLC", "(", "block", ",", "cfunc_get_cycles", ",", "mips3", ")", ";", "UML_DSUB", "(", "block", ",", "IREG", "(", "0", ")", ",", "MEM", "(", "&", "mips3", "->", "impstate", "->", "numcycles", ")", ",", "MEM", "(", "&", "mips3", "->", "count_zero_time", ")", ")", ";", "UML_DSHR", "(", "block", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "0", ")", ",", "IMM", "(", "1", ")", ")", ";", "UML_DSEXT", "(", "block", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "0", ")", ",", "DWORD", ")", ";", "return", "TRUE", ";", "case", "COP0_Random", ":", "generate_update_cycles", "(", "mips3", ",", "block", ",", "compiler", ",", "IMM", "(", "desc", "->", "pc", ")", ",", "FALSE", ")", ";", "UML_CALLC", "(", "block", ",", "cfunc_get_cycles", ",", "mips3", ")", ";", "UML_DSUB", "(", "block", ",", "IREG", "(", "0", ")", ",", "MEM", "(", "&", "mips3", "->", "impstate", "->", "numcycles", ")", ",", "MEM", "(", "&", "mips3", "->", "count_zero_time", ")", ")", ";", "UML_AND", "(", "block", ",", "IREG", "(", "1", ")", ",", "CPR032", "(", "COP0_Wired", ")", ",", "IMM", "(", "0x3f", ")", ")", ";", "UML_SUB", "(", "block", ",", "IREG", "(", "2", ")", ",", "IMM", "(", "48", ")", ",", "IREG", "(", "1", ")", ")", ";", "UML_JMPc", "(", "block", ",", "IF_BE", ",", "link1", "=", "compiler", "->", "labelnum", "++", ")", ";", "UML_DAND", "(", "block", ",", "IREG", "(", "2", ")", ",", "IREG", "(", "2", ")", ",", "IMM", "(", "0xffffffff", ")", ")", ";", "UML_DDIVU", "(", "block", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "2", ")", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "2", ")", ")", ";", "UML_ADD", "(", "block", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "2", ")", ",", "IREG", "(", "1", ")", ")", ";", "UML_DAND", "(", "block", ",", "IREG", "(", "0", ")", ",", "IREG", "(", "0", ")", ",", "IMM", "(", "0x3f", ")", ")", ";", "UML_JMP", "(", "block", ",", "link2", "=", "compiler", "->", "labelnum", "++", ")", ";", "UML_LABEL", "(", "block", ",", "link1", ")", ";", "UML_DMOV", "(", "block", ",", "IREG", "(", "0", ")", ",", "IMM", "(", "47", ")", ")", ";", "UML_LABEL", "(", "block", ",", "link2", ")", ";", "return", "TRUE", ";", "default", ":", "UML_DSEXT", "(", "block", ",", "IREG", "(", "0", ")", ",", "CPR032", "(", "reg", ")", ",", "DWORD", ")", ";", "return", "TRUE", ";", "}", "}" ]
generate_get_cop0_reg - generate code to read special COP0 registers
[ "generate_get_cop0_reg", "-", "generate", "code", "to", "read", "special", "COP0", "registers" ]
[ "// <subtract cycles>\r", "// callc cfunc_get_cycles,mips3\r", "// dsub i0,[numcycles],[count_zero_time]\r", "// dshr i0,i0,1\r", "// dsext i0,i0,dword\r", "// <subtract cycles>\r", "// callc cfunc_get_cycles,mips3\r", "// dsub i0,[numcycles],[count_zero_time]\r", "// and i1,[Wired],0x3f\r", "// sub i2,48,i1\r", "// jmp link1,BE\r", "// dand i2,i2,0xffffffff\r", "// ddivu i0,i2,i0,i2\r", "// add i0,i2,i1\r", "// dand i0,i0,0x3f\r", "// jmp link2\r", "// link1:\r", "// dmov i0,47\r", "// link2:\r", "// dsext i0,cpr0[reg],dword\r" ]
[ { "param": "mips3", "type": "mips3_state" }, { "param": "block", "type": "drcuml_block" }, { "param": "compiler", "type": "compiler_state" }, { "param": "desc", "type": "opcode_desc" }, { "param": "reg", "type": "UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mips3", "type": "mips3_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "compiler", "type": "compiler_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "desc", "type": "opcode_desc", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reg", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
612bae9f912bf2501143484d4179568700a1b17d
lofunz/mieme
Reloaded/trunk/src/emu/cpu/mips/mips3drc.c
[ "Unlicense" ]
C
log_add_disasm_comment
void
static void log_add_disasm_comment(mips3_state *mips3, drcuml_block *block, UINT32 pc, UINT32 op) { #if (LOG_UML) char buffer[100]; dasmmips3(buffer, pc, op); UML_COMMENT(block, "%08X: %s", pc, buffer); // comment #endif }
/*------------------------------------------------- log_add_disasm_comment - add a comment including disassembly of a MIPS instruction -------------------------------------------------*/
add a comment including disassembly of a MIPS instruction
[ "add", "a", "comment", "including", "disassembly", "of", "a", "MIPS", "instruction" ]
static void log_add_disasm_comment(mips3_state *mips3, drcuml_block *block, UINT32 pc, UINT32 op) { #if (LOG_UML) char buffer[100]; dasmmips3(buffer, pc, op); UML_COMMENT(block, "%08X: %s", pc, buffer); #endif }
[ "static", "void", "log_add_disasm_comment", "(", "mips3_state", "*", "mips3", ",", "drcuml_block", "*", "block", ",", "UINT32", "pc", ",", "UINT32", "op", ")", "{", "#if", "(", "LOG_UML", ")", "\n", "char", "buffer", "[", "100", "]", ";", "dasmmips3", "(", "buffer", ",", "pc", ",", "op", ")", ";", "UML_COMMENT", "(", "block", ",", "\"", "\"", ",", "pc", ",", "buffer", ")", ";", "#endif", "}" ]
log_add_disasm_comment - add a comment including disassembly of a MIPS instruction
[ "log_add_disasm_comment", "-", "add", "a", "comment", "including", "disassembly", "of", "a", "MIPS", "instruction" ]
[ "// comment\r" ]
[ { "param": "mips3", "type": "mips3_state" }, { "param": "block", "type": "drcuml_block" }, { "param": "pc", "type": "UINT32" }, { "param": "op", "type": "UINT32" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mips3", "type": "mips3_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pc", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "op", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
612bae9f912bf2501143484d4179568700a1b17d
lofunz/mieme
Reloaded/trunk/src/emu/cpu/mips/mips3drc.c
[ "Unlicense" ]
C
log_register_list
void
static void log_register_list(drcuml_state *drcuml, const char *string, const UINT32 *reglist, const UINT32 *regnostarlist) { int count = 0; int regnum; /* skip if nothing */ if (reglist[0] == 0 && reglist[1] == 0 && reglist[2] == 0) return; drcuml_log_printf(drcuml, "[%s:", string); for (regnum = 1; regnum < 32; regnum++) if (reglist[0] & REGFLAG_R(regnum)) { drcuml_log_printf(drcuml, "%sr%d", (count++ == 0) ? "" : ",", regnum); if (regnostarlist != NULL && !(regnostarlist[0] & REGFLAG_R(regnum))) drcuml_log_printf(drcuml, "*"); } for (regnum = 0; regnum < 32; regnum++) if (reglist[1] & REGFLAG_CPR1(regnum)) { drcuml_log_printf(drcuml, "%sfr%d", (count++ == 0) ? "" : ",", regnum); if (regnostarlist != NULL && !(regnostarlist[1] & REGFLAG_CPR1(regnum))) drcuml_log_printf(drcuml, "*"); } if (reglist[2] & REGFLAG_LO) { drcuml_log_printf(drcuml, "%slo", (count++ == 0) ? "" : ","); if (regnostarlist != NULL && !(regnostarlist[2] & REGFLAG_LO)) drcuml_log_printf(drcuml, "*"); } if (reglist[2] & REGFLAG_HI) { drcuml_log_printf(drcuml, "%shi", (count++ == 0) ? "" : ","); if (regnostarlist != NULL && !(regnostarlist[2] & REGFLAG_HI)) drcuml_log_printf(drcuml, "*"); } if (reglist[2] & REGFLAG_FCC) { drcuml_log_printf(drcuml, "%sfcc", (count++ == 0) ? "" : ","); if (regnostarlist != NULL && !(regnostarlist[2] & REGFLAG_FCC)) drcuml_log_printf(drcuml, "*"); } drcuml_log_printf(drcuml, "] "); }
/*------------------------------------------------- log_register_list - log a list of GPR registers -------------------------------------------------*/
log a list of GPR registers
[ "log", "a", "list", "of", "GPR", "registers" ]
static void log_register_list(drcuml_state *drcuml, const char *string, const UINT32 *reglist, const UINT32 *regnostarlist) { int count = 0; int regnum; if (reglist[0] == 0 && reglist[1] == 0 && reglist[2] == 0) return; drcuml_log_printf(drcuml, "[%s:", string); for (regnum = 1; regnum < 32; regnum++) if (reglist[0] & REGFLAG_R(regnum)) { drcuml_log_printf(drcuml, "%sr%d", (count++ == 0) ? "" : ",", regnum); if (regnostarlist != NULL && !(regnostarlist[0] & REGFLAG_R(regnum))) drcuml_log_printf(drcuml, "*"); } for (regnum = 0; regnum < 32; regnum++) if (reglist[1] & REGFLAG_CPR1(regnum)) { drcuml_log_printf(drcuml, "%sfr%d", (count++ == 0) ? "" : ",", regnum); if (regnostarlist != NULL && !(regnostarlist[1] & REGFLAG_CPR1(regnum))) drcuml_log_printf(drcuml, "*"); } if (reglist[2] & REGFLAG_LO) { drcuml_log_printf(drcuml, "%slo", (count++ == 0) ? "" : ","); if (regnostarlist != NULL && !(regnostarlist[2] & REGFLAG_LO)) drcuml_log_printf(drcuml, "*"); } if (reglist[2] & REGFLAG_HI) { drcuml_log_printf(drcuml, "%shi", (count++ == 0) ? "" : ","); if (regnostarlist != NULL && !(regnostarlist[2] & REGFLAG_HI)) drcuml_log_printf(drcuml, "*"); } if (reglist[2] & REGFLAG_FCC) { drcuml_log_printf(drcuml, "%sfcc", (count++ == 0) ? "" : ","); if (regnostarlist != NULL && !(regnostarlist[2] & REGFLAG_FCC)) drcuml_log_printf(drcuml, "*"); } drcuml_log_printf(drcuml, "] "); }
[ "static", "void", "log_register_list", "(", "drcuml_state", "*", "drcuml", ",", "const", "char", "*", "string", ",", "const", "UINT32", "*", "reglist", ",", "const", "UINT32", "*", "regnostarlist", ")", "{", "int", "count", "=", "0", ";", "int", "regnum", ";", "if", "(", "reglist", "[", "0", "]", "==", "0", "&&", "reglist", "[", "1", "]", "==", "0", "&&", "reglist", "[", "2", "]", "==", "0", ")", "return", ";", "drcuml_log_printf", "(", "drcuml", ",", "\"", "\"", ",", "string", ")", ";", "for", "(", "regnum", "=", "1", ";", "regnum", "<", "32", ";", "regnum", "++", ")", "if", "(", "reglist", "[", "0", "]", "&", "REGFLAG_R", "(", "regnum", ")", ")", "{", "drcuml_log_printf", "(", "drcuml", ",", "\"", "\"", ",", "(", "count", "++", "==", "0", ")", "?", "\"", "\"", ":", "\"", "\"", ",", "regnum", ")", ";", "if", "(", "regnostarlist", "!=", "NULL", "&&", "!", "(", "regnostarlist", "[", "0", "]", "&", "REGFLAG_R", "(", "regnum", ")", ")", ")", "drcuml_log_printf", "(", "drcuml", ",", "\"", "\"", ")", ";", "}", "for", "(", "regnum", "=", "0", ";", "regnum", "<", "32", ";", "regnum", "++", ")", "if", "(", "reglist", "[", "1", "]", "&", "REGFLAG_CPR1", "(", "regnum", ")", ")", "{", "drcuml_log_printf", "(", "drcuml", ",", "\"", "\"", ",", "(", "count", "++", "==", "0", ")", "?", "\"", "\"", ":", "\"", "\"", ",", "regnum", ")", ";", "if", "(", "regnostarlist", "!=", "NULL", "&&", "!", "(", "regnostarlist", "[", "1", "]", "&", "REGFLAG_CPR1", "(", "regnum", ")", ")", ")", "drcuml_log_printf", "(", "drcuml", ",", "\"", "\"", ")", ";", "}", "if", "(", "reglist", "[", "2", "]", "&", "REGFLAG_LO", ")", "{", "drcuml_log_printf", "(", "drcuml", ",", "\"", "\"", ",", "(", "count", "++", "==", "0", ")", "?", "\"", "\"", ":", "\"", "\"", ")", ";", "if", "(", "regnostarlist", "!=", "NULL", "&&", "!", "(", "regnostarlist", "[", "2", "]", "&", "REGFLAG_LO", ")", ")", "drcuml_log_printf", "(", "drcuml", ",", "\"", "\"", ")", ";", "}", "if", "(", "reglist", "[", "2", "]", "&", "REGFLAG_HI", ")", "{", "drcuml_log_printf", "(", "drcuml", ",", "\"", "\"", ",", "(", "count", "++", "==", "0", ")", "?", "\"", "\"", ":", "\"", "\"", ")", ";", "if", "(", "regnostarlist", "!=", "NULL", "&&", "!", "(", "regnostarlist", "[", "2", "]", "&", "REGFLAG_HI", ")", ")", "drcuml_log_printf", "(", "drcuml", ",", "\"", "\"", ")", ";", "}", "if", "(", "reglist", "[", "2", "]", "&", "REGFLAG_FCC", ")", "{", "drcuml_log_printf", "(", "drcuml", ",", "\"", "\"", ",", "(", "count", "++", "==", "0", ")", "?", "\"", "\"", ":", "\"", "\"", ")", ";", "if", "(", "regnostarlist", "!=", "NULL", "&&", "!", "(", "regnostarlist", "[", "2", "]", "&", "REGFLAG_FCC", ")", ")", "drcuml_log_printf", "(", "drcuml", ",", "\"", "\"", ")", ";", "}", "drcuml_log_printf", "(", "drcuml", ",", "\"", "\"", ")", ";", "}" ]
log_register_list - log a list of GPR registers
[ "log_register_list", "-", "log", "a", "list", "of", "GPR", "registers" ]
[ "/* skip if nothing */" ]
[ { "param": "drcuml", "type": "drcuml_state" }, { "param": "string", "type": "char" }, { "param": "reglist", "type": "UINT32" }, { "param": "regnostarlist", "type": "UINT32" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "drcuml", "type": "drcuml_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "string", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reglist", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "regnostarlist", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
debug_cpu_init
void
void debug_cpu_init(running_machine *machine) { screen_device *first_screen = screen_first(*machine); debugcpu_private *global; int regnum; /* allocate and reset globals */ machine->debugcpu_data = global = auto_alloc_clear(machine, debugcpu_private); global->execution_state = EXECUTION_STATE_STOPPED; global->bpindex = 1; global->wpindex = 1; /* create a global symbol table */ global->symtable = symtable_alloc(NULL, machine); /* add "wpaddr", "wpdata", "cycles", "cpunum", "logunmap" to the global symbol table */ symtable_add_register(global->symtable, "wpaddr", NULL, get_wpaddr, NULL); symtable_add_register(global->symtable, "wpdata", NULL, get_wpdata, NULL); symtable_add_register(global->symtable, "cpunum", NULL, get_cpunum, NULL); symtable_add_register(global->symtable, "beamx", (void *)first_screen, get_beamx, NULL); symtable_add_register(global->symtable, "beamy", (void *)first_screen, get_beamy, NULL); symtable_add_register(global->symtable, "frame", (void *)first_screen, get_frame, NULL); /* add the temporary variables to the global symbol table */ for (regnum = 0; regnum < NUM_TEMP_VARIABLES; regnum++) { char symname[10]; sprintf(symname, "temp%d", regnum); symtable_add_register(global->symtable, symname, &global->tempvar[regnum], get_tempvar, set_tempvar); } /* loop over devices and build up their info */ for (device_t *device = machine->m_devicelist.first(); device != NULL; device = device->next()) device->set_debug(*auto_alloc(machine, device_debug(*device, global->symtable))); /* first CPU is visible by default */ global->visiblecpu = machine->firstcpu; /* add callback for breaking on VBLANK */ if (machine->primary_screen != NULL) machine->primary_screen->register_vblank_callback(on_vblank, NULL); machine->add_notifier(MACHINE_NOTIFY_EXIT, debug_cpu_exit); }
/*------------------------------------------------- debug_cpu_init - initialize the CPU information for debugging -------------------------------------------------*/
initialize the CPU information for debugging
[ "initialize", "the", "CPU", "information", "for", "debugging" ]
void debug_cpu_init(running_machine *machine) { screen_device *first_screen = screen_first(*machine); debugcpu_private *global; int regnum; machine->debugcpu_data = global = auto_alloc_clear(machine, debugcpu_private); global->execution_state = EXECUTION_STATE_STOPPED; global->bpindex = 1; global->wpindex = 1; global->symtable = symtable_alloc(NULL, machine); symtable_add_register(global->symtable, "wpaddr", NULL, get_wpaddr, NULL); symtable_add_register(global->symtable, "wpdata", NULL, get_wpdata, NULL); symtable_add_register(global->symtable, "cpunum", NULL, get_cpunum, NULL); symtable_add_register(global->symtable, "beamx", (void *)first_screen, get_beamx, NULL); symtable_add_register(global->symtable, "beamy", (void *)first_screen, get_beamy, NULL); symtable_add_register(global->symtable, "frame", (void *)first_screen, get_frame, NULL); for (regnum = 0; regnum < NUM_TEMP_VARIABLES; regnum++) { char symname[10]; sprintf(symname, "temp%d", regnum); symtable_add_register(global->symtable, symname, &global->tempvar[regnum], get_tempvar, set_tempvar); } for (device_t *device = machine->m_devicelist.first(); device != NULL; device = device->next()) device->set_debug(*auto_alloc(machine, device_debug(*device, global->symtable))); global->visiblecpu = machine->firstcpu; if (machine->primary_screen != NULL) machine->primary_screen->register_vblank_callback(on_vblank, NULL); machine->add_notifier(MACHINE_NOTIFY_EXIT, debug_cpu_exit); }
[ "void", "debug_cpu_init", "(", "running_machine", "*", "machine", ")", "{", "screen_device", "*", "first_screen", "=", "screen_first", "(", "*", "machine", ")", ";", "debugcpu_private", "*", "global", ";", "int", "regnum", ";", "machine", "->", "debugcpu_data", "=", "global", "=", "auto_alloc_clear", "(", "machine", ",", "debugcpu_private", ")", ";", "global", "->", "execution_state", "=", "EXECUTION_STATE_STOPPED", ";", "global", "->", "bpindex", "=", "1", ";", "global", "->", "wpindex", "=", "1", ";", "global", "->", "symtable", "=", "symtable_alloc", "(", "NULL", ",", "machine", ")", ";", "symtable_add_register", "(", "global", "->", "symtable", ",", "\"", "\"", ",", "NULL", ",", "get_wpaddr", ",", "NULL", ")", ";", "symtable_add_register", "(", "global", "->", "symtable", ",", "\"", "\"", ",", "NULL", ",", "get_wpdata", ",", "NULL", ")", ";", "symtable_add_register", "(", "global", "->", "symtable", ",", "\"", "\"", ",", "NULL", ",", "get_cpunum", ",", "NULL", ")", ";", "symtable_add_register", "(", "global", "->", "symtable", ",", "\"", "\"", ",", "(", "void", "*", ")", "first_screen", ",", "get_beamx", ",", "NULL", ")", ";", "symtable_add_register", "(", "global", "->", "symtable", ",", "\"", "\"", ",", "(", "void", "*", ")", "first_screen", ",", "get_beamy", ",", "NULL", ")", ";", "symtable_add_register", "(", "global", "->", "symtable", ",", "\"", "\"", ",", "(", "void", "*", ")", "first_screen", ",", "get_frame", ",", "NULL", ")", ";", "for", "(", "regnum", "=", "0", ";", "regnum", "<", "NUM_TEMP_VARIABLES", ";", "regnum", "++", ")", "{", "char", "symname", "[", "10", "]", ";", "sprintf", "(", "symname", ",", "\"", "\"", ",", "regnum", ")", ";", "symtable_add_register", "(", "global", "->", "symtable", ",", "symname", ",", "&", "global", "->", "tempvar", "[", "regnum", "]", ",", "get_tempvar", ",", "set_tempvar", ")", ";", "}", "for", "(", "device_t", "*", "device", "=", "machine", "->", "m_devicelist", ".", "first", "(", ")", ";", "device", "!=", "NULL", ";", "device", "=", "device", "->", "next", "(", ")", ")", "device", "->", "set_debug", "(", "*", "auto_alloc", "(", "machine", ",", "device_debug", "(", "*", "device", ",", "global", "->", "symtable", ")", ")", ")", ";", "global", "->", "visiblecpu", "=", "machine", "->", "firstcpu", ";", "if", "(", "machine", "->", "primary_screen", "!=", "NULL", ")", "machine", "->", "primary_screen", "->", "register_vblank_callback", "(", "on_vblank", ",", "NULL", ")", ";", "machine", "->", "add_notifier", "(", "MACHINE_NOTIFY_EXIT", ",", "debug_cpu_exit", ")", ";", "}" ]
debug_cpu_init - initialize the CPU information for debugging
[ "debug_cpu_init", "-", "initialize", "the", "CPU", "information", "for", "debugging" ]
[ "/* allocate and reset globals */", "/* create a global symbol table */", "/* add \"wpaddr\", \"wpdata\", \"cycles\", \"cpunum\", \"logunmap\" to the global symbol table */", "/* add the temporary variables to the global symbol table */", "/* loop over devices and build up their info */", "/* first CPU is visible by default */", "/* add callback for breaking on VBLANK */" ]
[ { "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": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
debug_cpu_flush_traces
void
void debug_cpu_flush_traces(running_machine *machine) { /* this can be called on exit even when no debugging is enabled, so make sure the devdebug is valid before proceeding */ for (device_t *device = machine->m_devicelist.first(); device != NULL; device = device->next()) if (device->debug() != NULL) device->debug()->trace_flush(); }
/*------------------------------------------------- debug_cpu_flush_traces - flushes all traces; this is useful if a trace is going on when we fatalerror -------------------------------------------------*/
flushes all traces; this is useful if a trace is going on when we fatalerror
[ "flushes", "all", "traces", ";", "this", "is", "useful", "if", "a", "trace", "is", "going", "on", "when", "we", "fatalerror" ]
void debug_cpu_flush_traces(running_machine *machine) { for (device_t *device = machine->m_devicelist.first(); device != NULL; device = device->next()) if (device->debug() != NULL) device->debug()->trace_flush(); }
[ "void", "debug_cpu_flush_traces", "(", "running_machine", "*", "machine", ")", "{", "for", "(", "device_t", "*", "device", "=", "machine", "->", "m_devicelist", ".", "first", "(", ")", ";", "device", "!=", "NULL", ";", "device", "=", "device", "->", "next", "(", ")", ")", "if", "(", "device", "->", "debug", "(", ")", "!=", "NULL", ")", "device", "->", "debug", "(", ")", "->", "trace_flush", "(", ")", ";", "}" ]
debug_cpu_flush_traces - flushes all traces; this is useful if a trace is going on when we fatalerror
[ "debug_cpu_flush_traces", "-", "flushes", "all", "traces", ";", "this", "is", "useful", "if", "a", "trace", "is", "going", "on", "when", "we", "fatalerror" ]
[ "/* this can be called on exit even when no debugging is enabled, so\r\n make sure the devdebug is valid before proceeding */" ]
[ { "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": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
debug_cpu_is_stopped
int
int debug_cpu_is_stopped(running_machine *machine) { debugcpu_private *global = machine->debugcpu_data; return (global != NULL) ? (global->execution_state == EXECUTION_STATE_STOPPED) : FALSE; }
/*------------------------------------------------- debug_cpu_is_stopped - return TRUE if the current execution state is stopped -------------------------------------------------*/
return TRUE if the current execution state is stopped
[ "return", "TRUE", "if", "the", "current", "execution", "state", "is", "stopped" ]
int debug_cpu_is_stopped(running_machine *machine) { debugcpu_private *global = machine->debugcpu_data; return (global != NULL) ? (global->execution_state == EXECUTION_STATE_STOPPED) : FALSE; }
[ "int", "debug_cpu_is_stopped", "(", "running_machine", "*", "machine", ")", "{", "debugcpu_private", "*", "global", "=", "machine", "->", "debugcpu_data", ";", "return", "(", "global", "!=", "NULL", ")", "?", "(", "global", "->", "execution_state", "==", "EXECUTION_STATE_STOPPED", ")", ":", "FALSE", ";", "}" ]
debug_cpu_is_stopped - return TRUE if the current execution state is stopped
[ "debug_cpu_is_stopped", "-", "return", "TRUE", "if", "the", "current", "execution", "state", "is", "stopped" ]
[]
[ { "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": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
debug_cpu_source_script
void
void debug_cpu_source_script(running_machine *machine, const char *file) { debugcpu_private *global = machine->debugcpu_data; /* close any existing source file */ if (global->source_file != NULL) { fclose(global->source_file); global->source_file = NULL; } /* open a new one if requested */ if (file != NULL) { global->source_file = fopen(file, "r"); if (!global->source_file) { if (machine->phase() == MACHINE_PHASE_RUNNING) debug_console_printf(machine, "Cannot open command file '%s'\n", file); else fatalerror("Cannot open command file '%s'", file); } } }
/*------------------------------------------------- debug_cpu_source_script - specifies a debug command script to execute -------------------------------------------------*/
specifies a debug command script to execute
[ "specifies", "a", "debug", "command", "script", "to", "execute" ]
void debug_cpu_source_script(running_machine *machine, const char *file) { debugcpu_private *global = machine->debugcpu_data; if (global->source_file != NULL) { fclose(global->source_file); global->source_file = NULL; } if (file != NULL) { global->source_file = fopen(file, "r"); if (!global->source_file) { if (machine->phase() == MACHINE_PHASE_RUNNING) debug_console_printf(machine, "Cannot open command file '%s'\n", file); else fatalerror("Cannot open command file '%s'", file); } } }
[ "void", "debug_cpu_source_script", "(", "running_machine", "*", "machine", ",", "const", "char", "*", "file", ")", "{", "debugcpu_private", "*", "global", "=", "machine", "->", "debugcpu_data", ";", "if", "(", "global", "->", "source_file", "!=", "NULL", ")", "{", "fclose", "(", "global", "->", "source_file", ")", ";", "global", "->", "source_file", "=", "NULL", ";", "}", "if", "(", "file", "!=", "NULL", ")", "{", "global", "->", "source_file", "=", "fopen", "(", "file", ",", "\"", "\"", ")", ";", "if", "(", "!", "global", "->", "source_file", ")", "{", "if", "(", "machine", "->", "phase", "(", ")", "==", "MACHINE_PHASE_RUNNING", ")", "debug_console_printf", "(", "machine", ",", "\"", "\\n", "\"", ",", "file", ")", ";", "else", "fatalerror", "(", "\"", "\"", ",", "file", ")", ";", "}", "}", "}" ]
debug_cpu_source_script - specifies a debug command script to execute
[ "debug_cpu_source_script", "-", "specifies", "a", "debug", "command", "script", "to", "execute" ]
[ "/* close any existing source file */", "/* open a new one if requested */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "file", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "file", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
debug_read_byte
UINT8
UINT8 debug_read_byte(const address_space *space, offs_t address, int apply_translation) { debugcpu_private *global = space->machine->debugcpu_data; UINT64 custom; UINT8 result; /* mask against the logical byte mask */ address &= space->logbytemask; /* all accesses from this point on are for the debugger */ memory_set_debugger_access(space, global->debugger_access = TRUE); /* translate if necessary; if not mapped, return 0xff */ if (apply_translation && !debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address)) result = 0xff; /* if there is a custom read handler, and it returns TRUE, use that value */ else if (device_memory(space->cpu)->read(space->spacenum, address, 1, custom)) result = custom; /* otherwise, call the byte reading function for the translated address */ else result = memory_read_byte(space, address); /* no longer accessing via the debugger */ memory_set_debugger_access(space, global->debugger_access = FALSE); return result; }
/*------------------------------------------------- debug_read_byte - return a byte from the the specified memory space -------------------------------------------------*/
return a byte from the the specified memory space
[ "return", "a", "byte", "from", "the", "the", "specified", "memory", "space" ]
UINT8 debug_read_byte(const address_space *space, offs_t address, int apply_translation) { debugcpu_private *global = space->machine->debugcpu_data; UINT64 custom; UINT8 result; address &= space->logbytemask; memory_set_debugger_access(space, global->debugger_access = TRUE); if (apply_translation && !debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address)) result = 0xff; else if (device_memory(space->cpu)->read(space->spacenum, address, 1, custom)) result = custom; else result = memory_read_byte(space, address); memory_set_debugger_access(space, global->debugger_access = FALSE); return result; }
[ "UINT8", "debug_read_byte", "(", "const", "address_space", "*", "space", ",", "offs_t", "address", ",", "int", "apply_translation", ")", "{", "debugcpu_private", "*", "global", "=", "space", "->", "machine", "->", "debugcpu_data", ";", "UINT64", "custom", ";", "UINT8", "result", ";", "address", "&=", "space", "->", "logbytemask", ";", "memory_set_debugger_access", "(", "space", ",", "global", "->", "debugger_access", "=", "TRUE", ")", ";", "if", "(", "apply_translation", "&&", "!", "debug_cpu_translate", "(", "space", ",", "TRANSLATE_READ_DEBUG", ",", "&", "address", ")", ")", "result", "=", "0xff", ";", "else", "if", "(", "device_memory", "(", "space", "->", "cpu", ")", "->", "read", "(", "space", "->", "spacenum", ",", "address", ",", "1", ",", "custom", ")", ")", "result", "=", "custom", ";", "else", "result", "=", "memory_read_byte", "(", "space", ",", "address", ")", ";", "memory_set_debugger_access", "(", "space", ",", "global", "->", "debugger_access", "=", "FALSE", ")", ";", "return", "result", ";", "}" ]
debug_read_byte - return a byte from the the specified memory space
[ "debug_read_byte", "-", "return", "a", "byte", "from", "the", "the", "specified", "memory", "space" ]
[ "/* mask against the logical byte mask */", "/* all accesses from this point on are for the debugger */", "/* translate if necessary; if not mapped, return 0xff */", "/* if there is a custom read handler, and it returns TRUE, use that value */", "/* otherwise, call the byte reading function for the translated address */", "/* no longer accessing via the debugger */" ]
[ { "param": "space", "type": "address_space" }, { "param": "address", "type": "offs_t" }, { "param": "apply_translation", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "space", "type": "address_space", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "offs_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "apply_translation", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
debug_read_word
UINT16
UINT16 debug_read_word(const address_space *space, offs_t address, int apply_translation) { debugcpu_private *global = space->machine->debugcpu_data; UINT16 result; /* mask against the logical byte mask */ address &= space->logbytemask; /* if this is misaligned read, or if there are no word readers, just read two bytes */ if ((address & 1) != 0) { UINT8 byte0 = debug_read_byte(space, address + 0, apply_translation); UINT8 byte1 = debug_read_byte(space, address + 1, apply_translation); /* based on the endianness, the result is assembled differently */ if (space->endianness == ENDIANNESS_LITTLE) result = byte0 | (byte1 << 8); else result = byte1 | (byte0 << 8); } /* otherwise, this proceeds like the byte case */ else { UINT64 custom; /* all accesses from this point on are for the debugger */ memory_set_debugger_access(space, global->debugger_access = TRUE); /* translate if necessary; if not mapped, return 0xffff */ if (apply_translation && !debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address)) result = 0xffff; /* if there is a custom read handler, and it returns TRUE, use that value */ else if (device_memory(space->cpu)->read(space->spacenum, address, 2, custom)) result = custom; /* otherwise, call the byte reading function for the translated address */ else result = memory_read_word(space, address); /* no longer accessing via the debugger */ memory_set_debugger_access(space, global->debugger_access = FALSE); } return result; }
/*------------------------------------------------- debug_read_word - return a word from the specified memory space -------------------------------------------------*/
return a word from the specified memory space
[ "return", "a", "word", "from", "the", "specified", "memory", "space" ]
UINT16 debug_read_word(const address_space *space, offs_t address, int apply_translation) { debugcpu_private *global = space->machine->debugcpu_data; UINT16 result; address &= space->logbytemask; if ((address & 1) != 0) { UINT8 byte0 = debug_read_byte(space, address + 0, apply_translation); UINT8 byte1 = debug_read_byte(space, address + 1, apply_translation); if (space->endianness == ENDIANNESS_LITTLE) result = byte0 | (byte1 << 8); else result = byte1 | (byte0 << 8); } else { UINT64 custom; memory_set_debugger_access(space, global->debugger_access = TRUE); if (apply_translation && !debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address)) result = 0xffff; else if (device_memory(space->cpu)->read(space->spacenum, address, 2, custom)) result = custom; else result = memory_read_word(space, address); memory_set_debugger_access(space, global->debugger_access = FALSE); } return result; }
[ "UINT16", "debug_read_word", "(", "const", "address_space", "*", "space", ",", "offs_t", "address", ",", "int", "apply_translation", ")", "{", "debugcpu_private", "*", "global", "=", "space", "->", "machine", "->", "debugcpu_data", ";", "UINT16", "result", ";", "address", "&=", "space", "->", "logbytemask", ";", "if", "(", "(", "address", "&", "1", ")", "!=", "0", ")", "{", "UINT8", "byte0", "=", "debug_read_byte", "(", "space", ",", "address", "+", "0", ",", "apply_translation", ")", ";", "UINT8", "byte1", "=", "debug_read_byte", "(", "space", ",", "address", "+", "1", ",", "apply_translation", ")", ";", "if", "(", "space", "->", "endianness", "==", "ENDIANNESS_LITTLE", ")", "result", "=", "byte0", "|", "(", "byte1", "<<", "8", ")", ";", "else", "result", "=", "byte1", "|", "(", "byte0", "<<", "8", ")", ";", "}", "else", "{", "UINT64", "custom", ";", "memory_set_debugger_access", "(", "space", ",", "global", "->", "debugger_access", "=", "TRUE", ")", ";", "if", "(", "apply_translation", "&&", "!", "debug_cpu_translate", "(", "space", ",", "TRANSLATE_READ_DEBUG", ",", "&", "address", ")", ")", "result", "=", "0xffff", ";", "else", "if", "(", "device_memory", "(", "space", "->", "cpu", ")", "->", "read", "(", "space", "->", "spacenum", ",", "address", ",", "2", ",", "custom", ")", ")", "result", "=", "custom", ";", "else", "result", "=", "memory_read_word", "(", "space", ",", "address", ")", ";", "memory_set_debugger_access", "(", "space", ",", "global", "->", "debugger_access", "=", "FALSE", ")", ";", "}", "return", "result", ";", "}" ]
debug_read_word - return a word from the specified memory space
[ "debug_read_word", "-", "return", "a", "word", "from", "the", "specified", "memory", "space" ]
[ "/* mask against the logical byte mask */", "/* if this is misaligned read, or if there are no word readers, just read two bytes */", "/* based on the endianness, the result is assembled differently */", "/* otherwise, this proceeds like the byte case */", "/* all accesses from this point on are for the debugger */", "/* translate if necessary; if not mapped, return 0xffff */", "/* if there is a custom read handler, and it returns TRUE, use that value */", "/* otherwise, call the byte reading function for the translated address */", "/* no longer accessing via the debugger */" ]
[ { "param": "space", "type": "address_space" }, { "param": "address", "type": "offs_t" }, { "param": "apply_translation", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "space", "type": "address_space", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "offs_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "apply_translation", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
debug_read_dword
UINT32
UINT32 debug_read_dword(const address_space *space, offs_t address, int apply_translation) { debugcpu_private *global = space->machine->debugcpu_data; UINT32 result; /* mask against the logical byte mask */ address &= space->logbytemask; /* if this is misaligned read, or if there are no dword readers, just read two words */ if ((address & 3) != 0) { UINT16 word0 = debug_read_word(space, address + 0, apply_translation); UINT16 word1 = debug_read_word(space, address + 2, apply_translation); /* based on the endianness, the result is assembled differently */ if (space->endianness == ENDIANNESS_LITTLE) result = word0 | (word1 << 16); else result = word1 | (word0 << 16); } /* otherwise, this proceeds like the byte case */ else { UINT64 custom; /* all accesses from this point on are for the debugger */ memory_set_debugger_access(space, global->debugger_access = TRUE); /* translate if necessary; if not mapped, return 0xffffffff */ if (apply_translation && !debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address)) result = 0xffffffff; /* if there is a custom read handler, and it returns TRUE, use that value */ else if (device_memory(space->cpu)->read(space->spacenum, address, 4, custom)) result = custom; /* otherwise, call the byte reading function for the translated address */ else result = memory_read_dword(space, address); /* no longer accessing via the debugger */ memory_set_debugger_access(space, global->debugger_access = FALSE); } return result; }
/*------------------------------------------------- debug_read_dword - return a dword from the specified memory space -------------------------------------------------*/
return a dword from the specified memory space
[ "return", "a", "dword", "from", "the", "specified", "memory", "space" ]
UINT32 debug_read_dword(const address_space *space, offs_t address, int apply_translation) { debugcpu_private *global = space->machine->debugcpu_data; UINT32 result; address &= space->logbytemask; if ((address & 3) != 0) { UINT16 word0 = debug_read_word(space, address + 0, apply_translation); UINT16 word1 = debug_read_word(space, address + 2, apply_translation); if (space->endianness == ENDIANNESS_LITTLE) result = word0 | (word1 << 16); else result = word1 | (word0 << 16); } else { UINT64 custom; memory_set_debugger_access(space, global->debugger_access = TRUE); if (apply_translation && !debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address)) result = 0xffffffff; else if (device_memory(space->cpu)->read(space->spacenum, address, 4, custom)) result = custom; else result = memory_read_dword(space, address); memory_set_debugger_access(space, global->debugger_access = FALSE); } return result; }
[ "UINT32", "debug_read_dword", "(", "const", "address_space", "*", "space", ",", "offs_t", "address", ",", "int", "apply_translation", ")", "{", "debugcpu_private", "*", "global", "=", "space", "->", "machine", "->", "debugcpu_data", ";", "UINT32", "result", ";", "address", "&=", "space", "->", "logbytemask", ";", "if", "(", "(", "address", "&", "3", ")", "!=", "0", ")", "{", "UINT16", "word0", "=", "debug_read_word", "(", "space", ",", "address", "+", "0", ",", "apply_translation", ")", ";", "UINT16", "word1", "=", "debug_read_word", "(", "space", ",", "address", "+", "2", ",", "apply_translation", ")", ";", "if", "(", "space", "->", "endianness", "==", "ENDIANNESS_LITTLE", ")", "result", "=", "word0", "|", "(", "word1", "<<", "16", ")", ";", "else", "result", "=", "word1", "|", "(", "word0", "<<", "16", ")", ";", "}", "else", "{", "UINT64", "custom", ";", "memory_set_debugger_access", "(", "space", ",", "global", "->", "debugger_access", "=", "TRUE", ")", ";", "if", "(", "apply_translation", "&&", "!", "debug_cpu_translate", "(", "space", ",", "TRANSLATE_READ_DEBUG", ",", "&", "address", ")", ")", "result", "=", "0xffffffff", ";", "else", "if", "(", "device_memory", "(", "space", "->", "cpu", ")", "->", "read", "(", "space", "->", "spacenum", ",", "address", ",", "4", ",", "custom", ")", ")", "result", "=", "custom", ";", "else", "result", "=", "memory_read_dword", "(", "space", ",", "address", ")", ";", "memory_set_debugger_access", "(", "space", ",", "global", "->", "debugger_access", "=", "FALSE", ")", ";", "}", "return", "result", ";", "}" ]
debug_read_dword - return a dword from the specified memory space
[ "debug_read_dword", "-", "return", "a", "dword", "from", "the", "specified", "memory", "space" ]
[ "/* mask against the logical byte mask */", "/* if this is misaligned read, or if there are no dword readers, just read two words */", "/* based on the endianness, the result is assembled differently */", "/* otherwise, this proceeds like the byte case */", "/* all accesses from this point on are for the debugger */", "/* translate if necessary; if not mapped, return 0xffffffff */", "/* if there is a custom read handler, and it returns TRUE, use that value */", "/* otherwise, call the byte reading function for the translated address */", "/* no longer accessing via the debugger */" ]
[ { "param": "space", "type": "address_space" }, { "param": "address", "type": "offs_t" }, { "param": "apply_translation", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "space", "type": "address_space", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "offs_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "apply_translation", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
debug_read_qword
UINT64
UINT64 debug_read_qword(const address_space *space, offs_t address, int apply_translation) { debugcpu_private *global = space->machine->debugcpu_data; UINT64 result; /* mask against the logical byte mask */ address &= space->logbytemask; /* if this is misaligned read, or if there are no qword readers, just read two dwords */ if ((address & 7) != 0) { UINT32 dword0 = debug_read_dword(space, address + 0, apply_translation); UINT32 dword1 = debug_read_dword(space, address + 4, apply_translation); /* based on the endianness, the result is assembled differently */ if (space->endianness == ENDIANNESS_LITTLE) result = dword0 | ((UINT64)dword1 << 32); else result = dword1 | ((UINT64)dword0 << 32); } /* otherwise, this proceeds like the byte case */ else { UINT64 custom; /* all accesses from this point on are for the debugger */ memory_set_debugger_access(space, global->debugger_access = TRUE); /* translate if necessary; if not mapped, return 0xffffffffffffffff */ if (apply_translation && !debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address)) result = ~(UINT64)0; /* if there is a custom read handler, and it returns TRUE, use that value */ else if (device_memory(space->cpu)->read(space->spacenum, address, 8, custom)) result = custom; /* otherwise, call the byte reading function for the translated address */ else result = memory_read_qword(space, address); /* no longer accessing via the debugger */ memory_set_debugger_access(space, global->debugger_access = FALSE); } return result; }
/*------------------------------------------------- debug_read_qword - return a qword from the specified memory space -------------------------------------------------*/
return a qword from the specified memory space
[ "return", "a", "qword", "from", "the", "specified", "memory", "space" ]
UINT64 debug_read_qword(const address_space *space, offs_t address, int apply_translation) { debugcpu_private *global = space->machine->debugcpu_data; UINT64 result; address &= space->logbytemask; if ((address & 7) != 0) { UINT32 dword0 = debug_read_dword(space, address + 0, apply_translation); UINT32 dword1 = debug_read_dword(space, address + 4, apply_translation); if (space->endianness == ENDIANNESS_LITTLE) result = dword0 | ((UINT64)dword1 << 32); else result = dword1 | ((UINT64)dword0 << 32); } else { UINT64 custom; memory_set_debugger_access(space, global->debugger_access = TRUE); if (apply_translation && !debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address)) result = ~(UINT64)0; else if (device_memory(space->cpu)->read(space->spacenum, address, 8, custom)) result = custom; else result = memory_read_qword(space, address); memory_set_debugger_access(space, global->debugger_access = FALSE); } return result; }
[ "UINT64", "debug_read_qword", "(", "const", "address_space", "*", "space", ",", "offs_t", "address", ",", "int", "apply_translation", ")", "{", "debugcpu_private", "*", "global", "=", "space", "->", "machine", "->", "debugcpu_data", ";", "UINT64", "result", ";", "address", "&=", "space", "->", "logbytemask", ";", "if", "(", "(", "address", "&", "7", ")", "!=", "0", ")", "{", "UINT32", "dword0", "=", "debug_read_dword", "(", "space", ",", "address", "+", "0", ",", "apply_translation", ")", ";", "UINT32", "dword1", "=", "debug_read_dword", "(", "space", ",", "address", "+", "4", ",", "apply_translation", ")", ";", "if", "(", "space", "->", "endianness", "==", "ENDIANNESS_LITTLE", ")", "result", "=", "dword0", "|", "(", "(", "UINT64", ")", "dword1", "<<", "32", ")", ";", "else", "result", "=", "dword1", "|", "(", "(", "UINT64", ")", "dword0", "<<", "32", ")", ";", "}", "else", "{", "UINT64", "custom", ";", "memory_set_debugger_access", "(", "space", ",", "global", "->", "debugger_access", "=", "TRUE", ")", ";", "if", "(", "apply_translation", "&&", "!", "debug_cpu_translate", "(", "space", ",", "TRANSLATE_READ_DEBUG", ",", "&", "address", ")", ")", "result", "=", "~", "(", "UINT64", ")", "0", ";", "else", "if", "(", "device_memory", "(", "space", "->", "cpu", ")", "->", "read", "(", "space", "->", "spacenum", ",", "address", ",", "8", ",", "custom", ")", ")", "result", "=", "custom", ";", "else", "result", "=", "memory_read_qword", "(", "space", ",", "address", ")", ";", "memory_set_debugger_access", "(", "space", ",", "global", "->", "debugger_access", "=", "FALSE", ")", ";", "}", "return", "result", ";", "}" ]
debug_read_qword - return a qword from the specified memory space
[ "debug_read_qword", "-", "return", "a", "qword", "from", "the", "specified", "memory", "space" ]
[ "/* mask against the logical byte mask */", "/* if this is misaligned read, or if there are no qword readers, just read two dwords */", "/* based on the endianness, the result is assembled differently */", "/* otherwise, this proceeds like the byte case */", "/* all accesses from this point on are for the debugger */", "/* translate if necessary; if not mapped, return 0xffffffffffffffff */", "/* if there is a custom read handler, and it returns TRUE, use that value */", "/* otherwise, call the byte reading function for the translated address */", "/* no longer accessing via the debugger */" ]
[ { "param": "space", "type": "address_space" }, { "param": "address", "type": "offs_t" }, { "param": "apply_translation", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "space", "type": "address_space", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "offs_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "apply_translation", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
debug_read_memory
UINT64
UINT64 debug_read_memory(const address_space *space, offs_t address, int size, int apply_translation) { UINT64 result = ~(UINT64)0 >> (64 - 8*size); switch (size) { case 1: result = debug_read_byte(space, address, apply_translation); break; case 2: result = debug_read_word(space, address, apply_translation); break; case 4: result = debug_read_dword(space, address, apply_translation); break; case 8: result = debug_read_qword(space, address, apply_translation); break; } return result; }
/*------------------------------------------------- debug_read_memory - return 1,2,4 or 8 bytes from the specified memory space -------------------------------------------------*/
return 1,2,4 or 8 bytes from the specified memory space
[ "return", "1", "2", "4", "or", "8", "bytes", "from", "the", "specified", "memory", "space" ]
UINT64 debug_read_memory(const address_space *space, offs_t address, int size, int apply_translation) { UINT64 result = ~(UINT64)0 >> (64 - 8*size); switch (size) { case 1: result = debug_read_byte(space, address, apply_translation); break; case 2: result = debug_read_word(space, address, apply_translation); break; case 4: result = debug_read_dword(space, address, apply_translation); break; case 8: result = debug_read_qword(space, address, apply_translation); break; } return result; }
[ "UINT64", "debug_read_memory", "(", "const", "address_space", "*", "space", ",", "offs_t", "address", ",", "int", "size", ",", "int", "apply_translation", ")", "{", "UINT64", "result", "=", "~", "(", "UINT64", ")", "0", ">>", "(", "64", "-", "8", "*", "size", ")", ";", "switch", "(", "size", ")", "{", "case", "1", ":", "result", "=", "debug_read_byte", "(", "space", ",", "address", ",", "apply_translation", ")", ";", "break", ";", "case", "2", ":", "result", "=", "debug_read_word", "(", "space", ",", "address", ",", "apply_translation", ")", ";", "break", ";", "case", "4", ":", "result", "=", "debug_read_dword", "(", "space", ",", "address", ",", "apply_translation", ")", ";", "break", ";", "case", "8", ":", "result", "=", "debug_read_qword", "(", "space", ",", "address", ",", "apply_translation", ")", ";", "break", ";", "}", "return", "result", ";", "}" ]
debug_read_memory - return 1,2,4 or 8 bytes from the specified memory space
[ "debug_read_memory", "-", "return", "1", "2", "4", "or", "8", "bytes", "from", "the", "specified", "memory", "space" ]
[]
[ { "param": "space", "type": "address_space" }, { "param": "address", "type": "offs_t" }, { "param": "size", "type": "int" }, { "param": "apply_translation", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "space", "type": "address_space", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "offs_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "apply_translation", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
debug_write_byte
void
void debug_write_byte(const address_space *space, offs_t address, UINT8 data, int apply_translation) { debugcpu_private *global = space->machine->debugcpu_data; /* mask against the logical byte mask */ address &= space->logbytemask; /* all accesses from this point on are for the debugger */ memory_set_debugger_access(space, global->debugger_access = TRUE); /* translate if necessary; if not mapped, we're done */ if (apply_translation && !debug_cpu_translate(space, TRANSLATE_WRITE_DEBUG, &address)) ; /* if there is a custom write handler, and it returns TRUE, use that */ else if (device_memory(space->cpu)->write(space->spacenum, address, 1, data)) ; /* otherwise, call the byte reading function for the translated address */ else memory_write_byte(space, address, data); /* no longer accessing via the debugger */ memory_set_debugger_access(space, global->debugger_access = FALSE); global->memory_modified = TRUE; }
/*------------------------------------------------- debug_write_byte - write a byte to the specified memory space -------------------------------------------------*/
write a byte to the specified memory space
[ "write", "a", "byte", "to", "the", "specified", "memory", "space" ]
void debug_write_byte(const address_space *space, offs_t address, UINT8 data, int apply_translation) { debugcpu_private *global = space->machine->debugcpu_data; address &= space->logbytemask; memory_set_debugger_access(space, global->debugger_access = TRUE); if (apply_translation && !debug_cpu_translate(space, TRANSLATE_WRITE_DEBUG, &address)) ; else if (device_memory(space->cpu)->write(space->spacenum, address, 1, data)) ; else memory_write_byte(space, address, data); memory_set_debugger_access(space, global->debugger_access = FALSE); global->memory_modified = TRUE; }
[ "void", "debug_write_byte", "(", "const", "address_space", "*", "space", ",", "offs_t", "address", ",", "UINT8", "data", ",", "int", "apply_translation", ")", "{", "debugcpu_private", "*", "global", "=", "space", "->", "machine", "->", "debugcpu_data", ";", "address", "&=", "space", "->", "logbytemask", ";", "memory_set_debugger_access", "(", "space", ",", "global", "->", "debugger_access", "=", "TRUE", ")", ";", "if", "(", "apply_translation", "&&", "!", "debug_cpu_translate", "(", "space", ",", "TRANSLATE_WRITE_DEBUG", ",", "&", "address", ")", ")", ";", "else", "if", "(", "device_memory", "(", "space", "->", "cpu", ")", "->", "write", "(", "space", "->", "spacenum", ",", "address", ",", "1", ",", "data", ")", ")", ";", "else", "memory_write_byte", "(", "space", ",", "address", ",", "data", ")", ";", "memory_set_debugger_access", "(", "space", ",", "global", "->", "debugger_access", "=", "FALSE", ")", ";", "global", "->", "memory_modified", "=", "TRUE", ";", "}" ]
debug_write_byte - write a byte to the specified memory space
[ "debug_write_byte", "-", "write", "a", "byte", "to", "the", "specified", "memory", "space" ]
[ "/* mask against the logical byte mask */", "/* all accesses from this point on are for the debugger */", "/* translate if necessary; if not mapped, we're done */", "/* if there is a custom write handler, and it returns TRUE, use that */", "/* otherwise, call the byte reading function for the translated address */", "/* no longer accessing via the debugger */" ]
[ { "param": "space", "type": "address_space" }, { "param": "address", "type": "offs_t" }, { "param": "data", "type": "UINT8" }, { "param": "apply_translation", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "space", "type": "address_space", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "offs_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "apply_translation", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
debug_write_word
void
void debug_write_word(const address_space *space, offs_t address, UINT16 data, int apply_translation) { debugcpu_private *global = space->machine->debugcpu_data; /* mask against the logical byte mask */ address &= space->logbytemask; /* if this is a misaligned write, or if there are no word writers, just read two bytes */ if ((address & 1) != 0) { if (space->endianness == ENDIANNESS_LITTLE) { debug_write_byte(space, address + 0, data >> 0, apply_translation); debug_write_byte(space, address + 1, data >> 8, apply_translation); } else { debug_write_byte(space, address + 0, data >> 8, apply_translation); debug_write_byte(space, address + 1, data >> 0, apply_translation); } } /* otherwise, this proceeds like the byte case */ else { /* all accesses from this point on are for the debugger */ memory_set_debugger_access(space, global->debugger_access = TRUE); /* translate if necessary; if not mapped, we're done */ if (apply_translation && !debug_cpu_translate(space, TRANSLATE_WRITE_DEBUG, &address)) ; /* if there is a custom write handler, and it returns TRUE, use that */ else if (device_memory(space->cpu)->write(space->spacenum, address, 2, data)) ; /* otherwise, call the byte reading function for the translated address */ else memory_write_word(space, address, data); /* no longer accessing via the debugger */ memory_set_debugger_access(space, global->debugger_access = FALSE); global->memory_modified = TRUE; } }
/*------------------------------------------------- debug_write_word - write a word to the specified memory space -------------------------------------------------*/
write a word to the specified memory space
[ "write", "a", "word", "to", "the", "specified", "memory", "space" ]
void debug_write_word(const address_space *space, offs_t address, UINT16 data, int apply_translation) { debugcpu_private *global = space->machine->debugcpu_data; address &= space->logbytemask; if ((address & 1) != 0) { if (space->endianness == ENDIANNESS_LITTLE) { debug_write_byte(space, address + 0, data >> 0, apply_translation); debug_write_byte(space, address + 1, data >> 8, apply_translation); } else { debug_write_byte(space, address + 0, data >> 8, apply_translation); debug_write_byte(space, address + 1, data >> 0, apply_translation); } } else { memory_set_debugger_access(space, global->debugger_access = TRUE); if (apply_translation && !debug_cpu_translate(space, TRANSLATE_WRITE_DEBUG, &address)) ; else if (device_memory(space->cpu)->write(space->spacenum, address, 2, data)) ; else memory_write_word(space, address, data); memory_set_debugger_access(space, global->debugger_access = FALSE); global->memory_modified = TRUE; } }
[ "void", "debug_write_word", "(", "const", "address_space", "*", "space", ",", "offs_t", "address", ",", "UINT16", "data", ",", "int", "apply_translation", ")", "{", "debugcpu_private", "*", "global", "=", "space", "->", "machine", "->", "debugcpu_data", ";", "address", "&=", "space", "->", "logbytemask", ";", "if", "(", "(", "address", "&", "1", ")", "!=", "0", ")", "{", "if", "(", "space", "->", "endianness", "==", "ENDIANNESS_LITTLE", ")", "{", "debug_write_byte", "(", "space", ",", "address", "+", "0", ",", "data", ">>", "0", ",", "apply_translation", ")", ";", "debug_write_byte", "(", "space", ",", "address", "+", "1", ",", "data", ">>", "8", ",", "apply_translation", ")", ";", "}", "else", "{", "debug_write_byte", "(", "space", ",", "address", "+", "0", ",", "data", ">>", "8", ",", "apply_translation", ")", ";", "debug_write_byte", "(", "space", ",", "address", "+", "1", ",", "data", ">>", "0", ",", "apply_translation", ")", ";", "}", "}", "else", "{", "memory_set_debugger_access", "(", "space", ",", "global", "->", "debugger_access", "=", "TRUE", ")", ";", "if", "(", "apply_translation", "&&", "!", "debug_cpu_translate", "(", "space", ",", "TRANSLATE_WRITE_DEBUG", ",", "&", "address", ")", ")", ";", "else", "if", "(", "device_memory", "(", "space", "->", "cpu", ")", "->", "write", "(", "space", "->", "spacenum", ",", "address", ",", "2", ",", "data", ")", ")", ";", "else", "memory_write_word", "(", "space", ",", "address", ",", "data", ")", ";", "memory_set_debugger_access", "(", "space", ",", "global", "->", "debugger_access", "=", "FALSE", ")", ";", "global", "->", "memory_modified", "=", "TRUE", ";", "}", "}" ]
debug_write_word - write a word to the specified memory space
[ "debug_write_word", "-", "write", "a", "word", "to", "the", "specified", "memory", "space" ]
[ "/* mask against the logical byte mask */", "/* if this is a misaligned write, or if there are no word writers, just read two bytes */", "/* otherwise, this proceeds like the byte case */", "/* all accesses from this point on are for the debugger */", "/* translate if necessary; if not mapped, we're done */", "/* if there is a custom write handler, and it returns TRUE, use that */", "/* otherwise, call the byte reading function for the translated address */", "/* no longer accessing via the debugger */" ]
[ { "param": "space", "type": "address_space" }, { "param": "address", "type": "offs_t" }, { "param": "data", "type": "UINT16" }, { "param": "apply_translation", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "space", "type": "address_space", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "offs_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "UINT16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "apply_translation", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
debug_write_dword
void
void debug_write_dword(const address_space *space, offs_t address, UINT32 data, int apply_translation) { debugcpu_private *global = space->machine->debugcpu_data; /* mask against the logical byte mask */ address &= space->logbytemask; /* if this is a misaligned write, or if there are no dword writers, just read two words */ if ((address & 3) != 0) { if (space->endianness == ENDIANNESS_LITTLE) { debug_write_word(space, address + 0, data >> 0, apply_translation); debug_write_word(space, address + 2, data >> 16, apply_translation); } else { debug_write_word(space, address + 0, data >> 16, apply_translation); debug_write_word(space, address + 2, data >> 0, apply_translation); } } /* otherwise, this proceeds like the byte case */ else { /* all accesses from this point on are for the debugger */ memory_set_debugger_access(space, global->debugger_access = TRUE); /* translate if necessary; if not mapped, we're done */ if (apply_translation && !debug_cpu_translate(space, TRANSLATE_WRITE_DEBUG, &address)) ; /* if there is a custom write handler, and it returns TRUE, use that */ else if (device_memory(space->cpu)->write(space->spacenum, address, 4, data)) ; /* otherwise, call the byte reading function for the translated address */ else memory_write_dword(space, address, data); /* no longer accessing via the debugger */ memory_set_debugger_access(space, global->debugger_access = FALSE); global->memory_modified = TRUE; } }
/*------------------------------------------------- debug_write_dword - write a dword to the specified memory space -------------------------------------------------*/
write a dword to the specified memory space
[ "write", "a", "dword", "to", "the", "specified", "memory", "space" ]
void debug_write_dword(const address_space *space, offs_t address, UINT32 data, int apply_translation) { debugcpu_private *global = space->machine->debugcpu_data; address &= space->logbytemask; if ((address & 3) != 0) { if (space->endianness == ENDIANNESS_LITTLE) { debug_write_word(space, address + 0, data >> 0, apply_translation); debug_write_word(space, address + 2, data >> 16, apply_translation); } else { debug_write_word(space, address + 0, data >> 16, apply_translation); debug_write_word(space, address + 2, data >> 0, apply_translation); } } else { memory_set_debugger_access(space, global->debugger_access = TRUE); if (apply_translation && !debug_cpu_translate(space, TRANSLATE_WRITE_DEBUG, &address)) ; else if (device_memory(space->cpu)->write(space->spacenum, address, 4, data)) ; else memory_write_dword(space, address, data); memory_set_debugger_access(space, global->debugger_access = FALSE); global->memory_modified = TRUE; } }
[ "void", "debug_write_dword", "(", "const", "address_space", "*", "space", ",", "offs_t", "address", ",", "UINT32", "data", ",", "int", "apply_translation", ")", "{", "debugcpu_private", "*", "global", "=", "space", "->", "machine", "->", "debugcpu_data", ";", "address", "&=", "space", "->", "logbytemask", ";", "if", "(", "(", "address", "&", "3", ")", "!=", "0", ")", "{", "if", "(", "space", "->", "endianness", "==", "ENDIANNESS_LITTLE", ")", "{", "debug_write_word", "(", "space", ",", "address", "+", "0", ",", "data", ">>", "0", ",", "apply_translation", ")", ";", "debug_write_word", "(", "space", ",", "address", "+", "2", ",", "data", ">>", "16", ",", "apply_translation", ")", ";", "}", "else", "{", "debug_write_word", "(", "space", ",", "address", "+", "0", ",", "data", ">>", "16", ",", "apply_translation", ")", ";", "debug_write_word", "(", "space", ",", "address", "+", "2", ",", "data", ">>", "0", ",", "apply_translation", ")", ";", "}", "}", "else", "{", "memory_set_debugger_access", "(", "space", ",", "global", "->", "debugger_access", "=", "TRUE", ")", ";", "if", "(", "apply_translation", "&&", "!", "debug_cpu_translate", "(", "space", ",", "TRANSLATE_WRITE_DEBUG", ",", "&", "address", ")", ")", ";", "else", "if", "(", "device_memory", "(", "space", "->", "cpu", ")", "->", "write", "(", "space", "->", "spacenum", ",", "address", ",", "4", ",", "data", ")", ")", ";", "else", "memory_write_dword", "(", "space", ",", "address", ",", "data", ")", ";", "memory_set_debugger_access", "(", "space", ",", "global", "->", "debugger_access", "=", "FALSE", ")", ";", "global", "->", "memory_modified", "=", "TRUE", ";", "}", "}" ]
debug_write_dword - write a dword to the specified memory space
[ "debug_write_dword", "-", "write", "a", "dword", "to", "the", "specified", "memory", "space" ]
[ "/* mask against the logical byte mask */", "/* if this is a misaligned write, or if there are no dword writers, just read two words */", "/* otherwise, this proceeds like the byte case */", "/* all accesses from this point on are for the debugger */", "/* translate if necessary; if not mapped, we're done */", "/* if there is a custom write handler, and it returns TRUE, use that */", "/* otherwise, call the byte reading function for the translated address */", "/* no longer accessing via the debugger */" ]
[ { "param": "space", "type": "address_space" }, { "param": "address", "type": "offs_t" }, { "param": "data", "type": "UINT32" }, { "param": "apply_translation", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "space", "type": "address_space", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "offs_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "apply_translation", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
debug_write_qword
void
void debug_write_qword(const address_space *space, offs_t address, UINT64 data, int apply_translation) { debugcpu_private *global = space->machine->debugcpu_data; /* mask against the logical byte mask */ address &= space->logbytemask; /* if this is a misaligned write, or if there are no qword writers, just read two dwords */ if ((address & 7) != 0) { if (space->endianness == ENDIANNESS_LITTLE) { debug_write_dword(space, address + 0, data >> 0, apply_translation); debug_write_dword(space, address + 4, data >> 32, apply_translation); } else { debug_write_dword(space, address + 0, data >> 32, apply_translation); debug_write_dword(space, address + 4, data >> 0, apply_translation); } } /* otherwise, this proceeds like the byte case */ else { /* all accesses from this point on are for the debugger */ memory_set_debugger_access(space, global->debugger_access = TRUE); /* translate if necessary; if not mapped, we're done */ if (apply_translation && !debug_cpu_translate(space, TRANSLATE_WRITE_DEBUG, &address)) ; /* if there is a custom write handler, and it returns TRUE, use that */ else if (device_memory(space->cpu)->write(space->spacenum, address, 8, data)) ; /* otherwise, call the byte reading function for the translated address */ else memory_write_qword(space, address, data); /* no longer accessing via the debugger */ memory_set_debugger_access(space, global->debugger_access = FALSE); global->memory_modified = TRUE; } }
/*------------------------------------------------- debug_write_qword - write a qword to the specified memory space -------------------------------------------------*/
write a qword to the specified memory space
[ "write", "a", "qword", "to", "the", "specified", "memory", "space" ]
void debug_write_qword(const address_space *space, offs_t address, UINT64 data, int apply_translation) { debugcpu_private *global = space->machine->debugcpu_data; address &= space->logbytemask; if ((address & 7) != 0) { if (space->endianness == ENDIANNESS_LITTLE) { debug_write_dword(space, address + 0, data >> 0, apply_translation); debug_write_dword(space, address + 4, data >> 32, apply_translation); } else { debug_write_dword(space, address + 0, data >> 32, apply_translation); debug_write_dword(space, address + 4, data >> 0, apply_translation); } } else { memory_set_debugger_access(space, global->debugger_access = TRUE); if (apply_translation && !debug_cpu_translate(space, TRANSLATE_WRITE_DEBUG, &address)) ; else if (device_memory(space->cpu)->write(space->spacenum, address, 8, data)) ; else memory_write_qword(space, address, data); memory_set_debugger_access(space, global->debugger_access = FALSE); global->memory_modified = TRUE; } }
[ "void", "debug_write_qword", "(", "const", "address_space", "*", "space", ",", "offs_t", "address", ",", "UINT64", "data", ",", "int", "apply_translation", ")", "{", "debugcpu_private", "*", "global", "=", "space", "->", "machine", "->", "debugcpu_data", ";", "address", "&=", "space", "->", "logbytemask", ";", "if", "(", "(", "address", "&", "7", ")", "!=", "0", ")", "{", "if", "(", "space", "->", "endianness", "==", "ENDIANNESS_LITTLE", ")", "{", "debug_write_dword", "(", "space", ",", "address", "+", "0", ",", "data", ">>", "0", ",", "apply_translation", ")", ";", "debug_write_dword", "(", "space", ",", "address", "+", "4", ",", "data", ">>", "32", ",", "apply_translation", ")", ";", "}", "else", "{", "debug_write_dword", "(", "space", ",", "address", "+", "0", ",", "data", ">>", "32", ",", "apply_translation", ")", ";", "debug_write_dword", "(", "space", ",", "address", "+", "4", ",", "data", ">>", "0", ",", "apply_translation", ")", ";", "}", "}", "else", "{", "memory_set_debugger_access", "(", "space", ",", "global", "->", "debugger_access", "=", "TRUE", ")", ";", "if", "(", "apply_translation", "&&", "!", "debug_cpu_translate", "(", "space", ",", "TRANSLATE_WRITE_DEBUG", ",", "&", "address", ")", ")", ";", "else", "if", "(", "device_memory", "(", "space", "->", "cpu", ")", "->", "write", "(", "space", "->", "spacenum", ",", "address", ",", "8", ",", "data", ")", ")", ";", "else", "memory_write_qword", "(", "space", ",", "address", ",", "data", ")", ";", "memory_set_debugger_access", "(", "space", ",", "global", "->", "debugger_access", "=", "FALSE", ")", ";", "global", "->", "memory_modified", "=", "TRUE", ";", "}", "}" ]
debug_write_qword - write a qword to the specified memory space
[ "debug_write_qword", "-", "write", "a", "qword", "to", "the", "specified", "memory", "space" ]
[ "/* mask against the logical byte mask */", "/* if this is a misaligned write, or if there are no qword writers, just read two dwords */", "/* otherwise, this proceeds like the byte case */", "/* all accesses from this point on are for the debugger */", "/* translate if necessary; if not mapped, we're done */", "/* if there is a custom write handler, and it returns TRUE, use that */", "/* otherwise, call the byte reading function for the translated address */", "/* no longer accessing via the debugger */" ]
[ { "param": "space", "type": "address_space" }, { "param": "address", "type": "offs_t" }, { "param": "data", "type": "UINT64" }, { "param": "apply_translation", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "space", "type": "address_space", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "offs_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "UINT64", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "apply_translation", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
debug_write_memory
void
void debug_write_memory(const address_space *space, offs_t address, UINT64 data, int size, int apply_translation) { switch (size) { case 1: debug_write_byte(space, address, data, apply_translation); break; case 2: debug_write_word(space, address, data, apply_translation); break; case 4: debug_write_dword(space, address, data, apply_translation); break; case 8: debug_write_qword(space, address, data, apply_translation); break; } }
/*------------------------------------------------- debug_write_memory - write 1,2,4 or 8 bytes to the specified memory space -------------------------------------------------*/
write 1,2,4 or 8 bytes to the specified memory space
[ "write", "1", "2", "4", "or", "8", "bytes", "to", "the", "specified", "memory", "space" ]
void debug_write_memory(const address_space *space, offs_t address, UINT64 data, int size, int apply_translation) { switch (size) { case 1: debug_write_byte(space, address, data, apply_translation); break; case 2: debug_write_word(space, address, data, apply_translation); break; case 4: debug_write_dword(space, address, data, apply_translation); break; case 8: debug_write_qword(space, address, data, apply_translation); break; } }
[ "void", "debug_write_memory", "(", "const", "address_space", "*", "space", ",", "offs_t", "address", ",", "UINT64", "data", ",", "int", "size", ",", "int", "apply_translation", ")", "{", "switch", "(", "size", ")", "{", "case", "1", ":", "debug_write_byte", "(", "space", ",", "address", ",", "data", ",", "apply_translation", ")", ";", "break", ";", "case", "2", ":", "debug_write_word", "(", "space", ",", "address", ",", "data", ",", "apply_translation", ")", ";", "break", ";", "case", "4", ":", "debug_write_dword", "(", "space", ",", "address", ",", "data", ",", "apply_translation", ")", ";", "break", ";", "case", "8", ":", "debug_write_qword", "(", "space", ",", "address", ",", "data", ",", "apply_translation", ")", ";", "break", ";", "}", "}" ]
debug_write_memory - write 1,2,4 or 8 bytes to the specified memory space
[ "debug_write_memory", "-", "write", "1", "2", "4", "or", "8", "bytes", "to", "the", "specified", "memory", "space" ]
[]
[ { "param": "space", "type": "address_space" }, { "param": "address", "type": "offs_t" }, { "param": "data", "type": "UINT64" }, { "param": "size", "type": "int" }, { "param": "apply_translation", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "space", "type": "address_space", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "offs_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "UINT64", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "apply_translation", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
debug_read_opcode
UINT64
UINT64 debug_read_opcode(const address_space *space, offs_t address, int size, int arg) { UINT64 result = ~(UINT64)0 & (~(UINT64)0 >> (64 - 8*size)), result2; debugcpu_private *global = space->machine->debugcpu_data; /* keep in logical range */ address &= space->logbytemask; /* return early if we got the result directly */ memory_set_debugger_access(space, global->debugger_access = TRUE); device_memory_interface *memory; if (space->cpu->interface(memory) && memory->readop(address, size, result2)) { memory_set_debugger_access(space, global->debugger_access = FALSE); return result2; } /* if we're bigger than the address bus, break into smaller pieces */ if (size > space->dbits / 8) { int halfsize = size / 2; UINT64 r0 = debug_read_opcode(space, address + 0, halfsize, arg); UINT64 r1 = debug_read_opcode(space, address + halfsize, halfsize, arg); if (space->endianness == ENDIANNESS_LITTLE) return r0 | (r1 << (8 * halfsize)); else return r1 | (r0 << (8 * halfsize)); } /* translate to physical first */ if (!debug_cpu_translate(space, TRANSLATE_FETCH_DEBUG, &address)) return result; /* keep in physical range */ address &= space->bytemask; switch (space->dbits / 8 * 10 + size) { /* dump opcodes in bytes from a byte-sized bus */ case 11: break; /* dump opcodes in bytes from a word-sized bus */ case 21: address ^= (space->endianness == ENDIANNESS_LITTLE) ? BYTE_XOR_LE(0) : BYTE_XOR_BE(0); break; /* dump opcodes in words from a word-sized bus */ case 22: break; /* dump opcodes in bytes from a dword-sized bus */ case 41: address ^= (space->endianness == ENDIANNESS_LITTLE) ? BYTE4_XOR_LE(0) : BYTE4_XOR_BE(0); break; /* dump opcodes in words from a dword-sized bus */ case 42: address ^= (space->endianness == ENDIANNESS_LITTLE) ? WORD_XOR_LE(0) : WORD_XOR_BE(0); break; /* dump opcodes in dwords from a dword-sized bus */ case 44: break; /* dump opcodes in bytes from a qword-sized bus */ case 81: address ^= (space->endianness == ENDIANNESS_LITTLE) ? BYTE8_XOR_LE(0) : BYTE8_XOR_BE(0); break; /* dump opcodes in words from a qword-sized bus */ case 82: address ^= (space->endianness == ENDIANNESS_LITTLE) ? WORD2_XOR_LE(0) : WORD2_XOR_BE(0); break; /* dump opcodes in dwords from a qword-sized bus */ case 84: address ^= (space->endianness == ENDIANNESS_LITTLE) ? DWORD_XOR_LE(0) : DWORD_XOR_BE(0); break; /* dump opcodes in qwords from a qword-sized bus */ case 88: break; default: fatalerror("debug_read_opcode: unknown type = %d", space->dbits / 8 * 10 + size); break; } /* turn on debugger access */ if (!global->debugger_access) memory_set_debugger_access(space, global->debugger_access = TRUE); /* switch off the size and handle unaligned accesses */ switch (size) { case 1: result = (arg) ? memory_raw_read_byte(space, address) : memory_decrypted_read_byte(space, address); break; case 2: result = (arg) ? memory_raw_read_word(space, address & ~1) : memory_decrypted_read_word(space, address & ~1); if ((address & 1) != 0) { result2 = (arg) ? memory_raw_read_word(space, (address & ~1) + 2) : memory_decrypted_read_word(space, (address & ~1) + 2); if (space->endianness == ENDIANNESS_LITTLE) result = (result >> (8 * (address & 1))) | (result2 << (16 - 8 * (address & 1))); else result = (result << (8 * (address & 1))) | (result2 >> (16 - 8 * (address & 1))); result &= 0xffff; } break; case 4: result = (arg) ? memory_raw_read_dword(space, address & ~3) : memory_decrypted_read_dword(space, address & ~3); if ((address & 3) != 0) { result2 = (arg) ? memory_raw_read_dword(space, (address & ~3) + 4) : memory_decrypted_read_dword(space, (address & ~3) + 4); if (space->endianness == ENDIANNESS_LITTLE) result = (result >> (8 * (address & 3))) | (result2 << (32 - 8 * (address & 3))); else result = (result << (8 * (address & 3))) | (result2 >> (32 - 8 * (address & 3))); result &= 0xffffffff; } break; case 8: result = (arg) ? memory_raw_read_qword(space, address & ~7) : memory_decrypted_read_qword(space, address & ~7); if ((address & 7) != 0) { result2 = (arg) ? memory_raw_read_qword(space, (address & ~7) + 8) : memory_decrypted_read_qword(space, (address & ~7) + 8); if (space->endianness == ENDIANNESS_LITTLE) result = (result >> (8 * (address & 7))) | (result2 << (64 - 8 * (address & 7))); else result = (result << (8 * (address & 7))) | (result2 >> (64 - 8 * (address & 7))); } break; } /* no longer accessing via the debugger */ memory_set_debugger_access(space, global->debugger_access = FALSE); return result; }
/*------------------------------------------------- debug_read_opcode - read 1,2,4 or 8 bytes at the given offset from opcode space -------------------------------------------------*/
read 1,2,4 or 8 bytes at the given offset from opcode space
[ "read", "1", "2", "4", "or", "8", "bytes", "at", "the", "given", "offset", "from", "opcode", "space" ]
UINT64 debug_read_opcode(const address_space *space, offs_t address, int size, int arg) { UINT64 result = ~(UINT64)0 & (~(UINT64)0 >> (64 - 8*size)), result2; debugcpu_private *global = space->machine->debugcpu_data; address &= space->logbytemask; memory_set_debugger_access(space, global->debugger_access = TRUE); device_memory_interface *memory; if (space->cpu->interface(memory) && memory->readop(address, size, result2)) { memory_set_debugger_access(space, global->debugger_access = FALSE); return result2; } if (size > space->dbits / 8) { int halfsize = size / 2; UINT64 r0 = debug_read_opcode(space, address + 0, halfsize, arg); UINT64 r1 = debug_read_opcode(space, address + halfsize, halfsize, arg); if (space->endianness == ENDIANNESS_LITTLE) return r0 | (r1 << (8 * halfsize)); else return r1 | (r0 << (8 * halfsize)); } if (!debug_cpu_translate(space, TRANSLATE_FETCH_DEBUG, &address)) return result; address &= space->bytemask; switch (space->dbits / 8 * 10 + size) { case 11: break; case 21: address ^= (space->endianness == ENDIANNESS_LITTLE) ? BYTE_XOR_LE(0) : BYTE_XOR_BE(0); break; case 22: break; case 41: address ^= (space->endianness == ENDIANNESS_LITTLE) ? BYTE4_XOR_LE(0) : BYTE4_XOR_BE(0); break; case 42: address ^= (space->endianness == ENDIANNESS_LITTLE) ? WORD_XOR_LE(0) : WORD_XOR_BE(0); break; case 44: break; case 81: address ^= (space->endianness == ENDIANNESS_LITTLE) ? BYTE8_XOR_LE(0) : BYTE8_XOR_BE(0); break; case 82: address ^= (space->endianness == ENDIANNESS_LITTLE) ? WORD2_XOR_LE(0) : WORD2_XOR_BE(0); break; case 84: address ^= (space->endianness == ENDIANNESS_LITTLE) ? DWORD_XOR_LE(0) : DWORD_XOR_BE(0); break; case 88: break; default: fatalerror("debug_read_opcode: unknown type = %d", space->dbits / 8 * 10 + size); break; } if (!global->debugger_access) memory_set_debugger_access(space, global->debugger_access = TRUE); switch (size) { case 1: result = (arg) ? memory_raw_read_byte(space, address) : memory_decrypted_read_byte(space, address); break; case 2: result = (arg) ? memory_raw_read_word(space, address & ~1) : memory_decrypted_read_word(space, address & ~1); if ((address & 1) != 0) { result2 = (arg) ? memory_raw_read_word(space, (address & ~1) + 2) : memory_decrypted_read_word(space, (address & ~1) + 2); if (space->endianness == ENDIANNESS_LITTLE) result = (result >> (8 * (address & 1))) | (result2 << (16 - 8 * (address & 1))); else result = (result << (8 * (address & 1))) | (result2 >> (16 - 8 * (address & 1))); result &= 0xffff; } break; case 4: result = (arg) ? memory_raw_read_dword(space, address & ~3) : memory_decrypted_read_dword(space, address & ~3); if ((address & 3) != 0) { result2 = (arg) ? memory_raw_read_dword(space, (address & ~3) + 4) : memory_decrypted_read_dword(space, (address & ~3) + 4); if (space->endianness == ENDIANNESS_LITTLE) result = (result >> (8 * (address & 3))) | (result2 << (32 - 8 * (address & 3))); else result = (result << (8 * (address & 3))) | (result2 >> (32 - 8 * (address & 3))); result &= 0xffffffff; } break; case 8: result = (arg) ? memory_raw_read_qword(space, address & ~7) : memory_decrypted_read_qword(space, address & ~7); if ((address & 7) != 0) { result2 = (arg) ? memory_raw_read_qword(space, (address & ~7) + 8) : memory_decrypted_read_qword(space, (address & ~7) + 8); if (space->endianness == ENDIANNESS_LITTLE) result = (result >> (8 * (address & 7))) | (result2 << (64 - 8 * (address & 7))); else result = (result << (8 * (address & 7))) | (result2 >> (64 - 8 * (address & 7))); } break; } memory_set_debugger_access(space, global->debugger_access = FALSE); return result; }
[ "UINT64", "debug_read_opcode", "(", "const", "address_space", "*", "space", ",", "offs_t", "address", ",", "int", "size", ",", "int", "arg", ")", "{", "UINT64", "result", "=", "~", "(", "UINT64", ")", "0", "&", "(", "~", "(", "UINT64", ")", "0", ">>", "(", "64", "-", "8", "*", "size", ")", ")", ",", "result2", ";", "debugcpu_private", "*", "global", "=", "space", "->", "machine", "->", "debugcpu_data", ";", "address", "&=", "space", "->", "logbytemask", ";", "memory_set_debugger_access", "(", "space", ",", "global", "->", "debugger_access", "=", "TRUE", ")", ";", "device_memory_interface", "*", "memory", ";", "if", "(", "space", "->", "cpu", "->", "interface", "(", "memory", ")", "&&", "memory", "->", "readop", "(", "address", ",", "size", ",", "result2", ")", ")", "{", "memory_set_debugger_access", "(", "space", ",", "global", "->", "debugger_access", "=", "FALSE", ")", ";", "return", "result2", ";", "}", "if", "(", "size", ">", "space", "->", "dbits", "/", "8", ")", "{", "int", "halfsize", "=", "size", "/", "2", ";", "UINT64", "r0", "=", "debug_read_opcode", "(", "space", ",", "address", "+", "0", ",", "halfsize", ",", "arg", ")", ";", "UINT64", "r1", "=", "debug_read_opcode", "(", "space", ",", "address", "+", "halfsize", ",", "halfsize", ",", "arg", ")", ";", "if", "(", "space", "->", "endianness", "==", "ENDIANNESS_LITTLE", ")", "return", "r0", "|", "(", "r1", "<<", "(", "8", "*", "halfsize", ")", ")", ";", "else", "return", "r1", "|", "(", "r0", "<<", "(", "8", "*", "halfsize", ")", ")", ";", "}", "if", "(", "!", "debug_cpu_translate", "(", "space", ",", "TRANSLATE_FETCH_DEBUG", ",", "&", "address", ")", ")", "return", "result", ";", "address", "&=", "space", "->", "bytemask", ";", "switch", "(", "space", "->", "dbits", "/", "8", "*", "10", "+", "size", ")", "{", "case", "11", ":", "break", ";", "case", "21", ":", "address", "^=", "(", "space", "->", "endianness", "==", "ENDIANNESS_LITTLE", ")", "?", "BYTE_XOR_LE", "(", "0", ")", ":", "BYTE_XOR_BE", "(", "0", ")", ";", "break", ";", "case", "22", ":", "break", ";", "case", "41", ":", "address", "^=", "(", "space", "->", "endianness", "==", "ENDIANNESS_LITTLE", ")", "?", "BYTE4_XOR_LE", "(", "0", ")", ":", "BYTE4_XOR_BE", "(", "0", ")", ";", "break", ";", "case", "42", ":", "address", "^=", "(", "space", "->", "endianness", "==", "ENDIANNESS_LITTLE", ")", "?", "WORD_XOR_LE", "(", "0", ")", ":", "WORD_XOR_BE", "(", "0", ")", ";", "break", ";", "case", "44", ":", "break", ";", "case", "81", ":", "address", "^=", "(", "space", "->", "endianness", "==", "ENDIANNESS_LITTLE", ")", "?", "BYTE8_XOR_LE", "(", "0", ")", ":", "BYTE8_XOR_BE", "(", "0", ")", ";", "break", ";", "case", "82", ":", "address", "^=", "(", "space", "->", "endianness", "==", "ENDIANNESS_LITTLE", ")", "?", "WORD2_XOR_LE", "(", "0", ")", ":", "WORD2_XOR_BE", "(", "0", ")", ";", "break", ";", "case", "84", ":", "address", "^=", "(", "space", "->", "endianness", "==", "ENDIANNESS_LITTLE", ")", "?", "DWORD_XOR_LE", "(", "0", ")", ":", "DWORD_XOR_BE", "(", "0", ")", ";", "break", ";", "case", "88", ":", "break", ";", "default", ":", "fatalerror", "(", "\"", "\"", ",", "space", "->", "dbits", "/", "8", "*", "10", "+", "size", ")", ";", "break", ";", "}", "if", "(", "!", "global", "->", "debugger_access", ")", "memory_set_debugger_access", "(", "space", ",", "global", "->", "debugger_access", "=", "TRUE", ")", ";", "switch", "(", "size", ")", "{", "case", "1", ":", "result", "=", "(", "arg", ")", "?", "memory_raw_read_byte", "(", "space", ",", "address", ")", ":", "memory_decrypted_read_byte", "(", "space", ",", "address", ")", ";", "break", ";", "case", "2", ":", "result", "=", "(", "arg", ")", "?", "memory_raw_read_word", "(", "space", ",", "address", "&", "~", "1", ")", ":", "memory_decrypted_read_word", "(", "space", ",", "address", "&", "~", "1", ")", ";", "if", "(", "(", "address", "&", "1", ")", "!=", "0", ")", "{", "result2", "=", "(", "arg", ")", "?", "memory_raw_read_word", "(", "space", ",", "(", "address", "&", "~", "1", ")", "+", "2", ")", ":", "memory_decrypted_read_word", "(", "space", ",", "(", "address", "&", "~", "1", ")", "+", "2", ")", ";", "if", "(", "space", "->", "endianness", "==", "ENDIANNESS_LITTLE", ")", "result", "=", "(", "result", ">>", "(", "8", "*", "(", "address", "&", "1", ")", ")", ")", "|", "(", "result2", "<<", "(", "16", "-", "8", "*", "(", "address", "&", "1", ")", ")", ")", ";", "else", "result", "=", "(", "result", "<<", "(", "8", "*", "(", "address", "&", "1", ")", ")", ")", "|", "(", "result2", ">>", "(", "16", "-", "8", "*", "(", "address", "&", "1", ")", ")", ")", ";", "result", "&=", "0xffff", ";", "}", "break", ";", "case", "4", ":", "result", "=", "(", "arg", ")", "?", "memory_raw_read_dword", "(", "space", ",", "address", "&", "~", "3", ")", ":", "memory_decrypted_read_dword", "(", "space", ",", "address", "&", "~", "3", ")", ";", "if", "(", "(", "address", "&", "3", ")", "!=", "0", ")", "{", "result2", "=", "(", "arg", ")", "?", "memory_raw_read_dword", "(", "space", ",", "(", "address", "&", "~", "3", ")", "+", "4", ")", ":", "memory_decrypted_read_dword", "(", "space", ",", "(", "address", "&", "~", "3", ")", "+", "4", ")", ";", "if", "(", "space", "->", "endianness", "==", "ENDIANNESS_LITTLE", ")", "result", "=", "(", "result", ">>", "(", "8", "*", "(", "address", "&", "3", ")", ")", ")", "|", "(", "result2", "<<", "(", "32", "-", "8", "*", "(", "address", "&", "3", ")", ")", ")", ";", "else", "result", "=", "(", "result", "<<", "(", "8", "*", "(", "address", "&", "3", ")", ")", ")", "|", "(", "result2", ">>", "(", "32", "-", "8", "*", "(", "address", "&", "3", ")", ")", ")", ";", "result", "&=", "0xffffffff", ";", "}", "break", ";", "case", "8", ":", "result", "=", "(", "arg", ")", "?", "memory_raw_read_qword", "(", "space", ",", "address", "&", "~", "7", ")", ":", "memory_decrypted_read_qword", "(", "space", ",", "address", "&", "~", "7", ")", ";", "if", "(", "(", "address", "&", "7", ")", "!=", "0", ")", "{", "result2", "=", "(", "arg", ")", "?", "memory_raw_read_qword", "(", "space", ",", "(", "address", "&", "~", "7", ")", "+", "8", ")", ":", "memory_decrypted_read_qword", "(", "space", ",", "(", "address", "&", "~", "7", ")", "+", "8", ")", ";", "if", "(", "space", "->", "endianness", "==", "ENDIANNESS_LITTLE", ")", "result", "=", "(", "result", ">>", "(", "8", "*", "(", "address", "&", "7", ")", ")", ")", "|", "(", "result2", "<<", "(", "64", "-", "8", "*", "(", "address", "&", "7", ")", ")", ")", ";", "else", "result", "=", "(", "result", "<<", "(", "8", "*", "(", "address", "&", "7", ")", ")", ")", "|", "(", "result2", ">>", "(", "64", "-", "8", "*", "(", "address", "&", "7", ")", ")", ")", ";", "}", "break", ";", "}", "memory_set_debugger_access", "(", "space", ",", "global", "->", "debugger_access", "=", "FALSE", ")", ";", "return", "result", ";", "}" ]
debug_read_opcode - read 1,2,4 or 8 bytes at the given offset from opcode space
[ "debug_read_opcode", "-", "read", "1", "2", "4", "or", "8", "bytes", "at", "the", "given", "offset", "from", "opcode", "space" ]
[ "/* keep in logical range */", "/* return early if we got the result directly */", "/* if we're bigger than the address bus, break into smaller pieces */", "/* translate to physical first */", "/* keep in physical range */", "/* dump opcodes in bytes from a byte-sized bus */", "/* dump opcodes in bytes from a word-sized bus */", "/* dump opcodes in words from a word-sized bus */", "/* dump opcodes in bytes from a dword-sized bus */", "/* dump opcodes in words from a dword-sized bus */", "/* dump opcodes in dwords from a dword-sized bus */", "/* dump opcodes in bytes from a qword-sized bus */", "/* dump opcodes in words from a qword-sized bus */", "/* dump opcodes in dwords from a qword-sized bus */", "/* dump opcodes in qwords from a qword-sized bus */", "/* turn on debugger access */", "/* switch off the size and handle unaligned accesses */", "/* no longer accessing via the debugger */" ]
[ { "param": "space", "type": "address_space" }, { "param": "address", "type": "offs_t" }, { "param": "size", "type": "int" }, { "param": "arg", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "space", "type": "address_space", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "offs_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "arg", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
process_source_file
void
static void process_source_file(running_machine *machine) { debugcpu_private *global = machine->debugcpu_data; /* loop until the file is exhausted or until we are executing again */ while (global->source_file != NULL && global->execution_state == EXECUTION_STATE_STOPPED) { char buf[512]; int i; char *s; /* stop at the end of file */ if (feof(global->source_file)) { fclose(global->source_file); global->source_file = NULL; return; } /* fetch the next line */ memset(buf, 0, sizeof(buf)); fgets(buf, sizeof(buf), global->source_file); /* strip out comments (text after '//') */ s = strstr(buf, "//"); if (s) *s = '\0'; /* strip whitespace */ i = (int)strlen(buf); while((i > 0) && (isspace((UINT8)buf[i-1]))) buf[--i] = '\0'; /* execute the command */ if (buf[0]) debug_console_execute_command(machine, buf, 1); } }
/*------------------------------------------------- process_source_file - executes commands from a source file -------------------------------------------------*/
executes commands from a source file
[ "executes", "commands", "from", "a", "source", "file" ]
static void process_source_file(running_machine *machine) { debugcpu_private *global = machine->debugcpu_data; while (global->source_file != NULL && global->execution_state == EXECUTION_STATE_STOPPED) { char buf[512]; int i; char *s; if (feof(global->source_file)) { fclose(global->source_file); global->source_file = NULL; return; } memset(buf, 0, sizeof(buf)); fgets(buf, sizeof(buf), global->source_file); s = strstr(buf, "//"); if (s) *s = '\0'; i = (int)strlen(buf); while((i > 0) && (isspace((UINT8)buf[i-1]))) buf[--i] = '\0'; if (buf[0]) debug_console_execute_command(machine, buf, 1); } }
[ "static", "void", "process_source_file", "(", "running_machine", "*", "machine", ")", "{", "debugcpu_private", "*", "global", "=", "machine", "->", "debugcpu_data", ";", "while", "(", "global", "->", "source_file", "!=", "NULL", "&&", "global", "->", "execution_state", "==", "EXECUTION_STATE_STOPPED", ")", "{", "char", "buf", "[", "512", "]", ";", "int", "i", ";", "char", "*", "s", ";", "if", "(", "feof", "(", "global", "->", "source_file", ")", ")", "{", "fclose", "(", "global", "->", "source_file", ")", ";", "global", "->", "source_file", "=", "NULL", ";", "return", ";", "}", "memset", "(", "buf", ",", "0", ",", "sizeof", "(", "buf", ")", ")", ";", "fgets", "(", "buf", ",", "sizeof", "(", "buf", ")", ",", "global", "->", "source_file", ")", ";", "s", "=", "strstr", "(", "buf", ",", "\"", "\"", ")", ";", "if", "(", "s", ")", "*", "s", "=", "'", "\\0", "'", ";", "i", "=", "(", "int", ")", "strlen", "(", "buf", ")", ";", "while", "(", "(", "i", ">", "0", ")", "&&", "(", "isspace", "(", "(", "UINT8", ")", "buf", "[", "i", "-", "1", "]", ")", ")", ")", "buf", "[", "--", "i", "]", "=", "'", "\\0", "'", ";", "if", "(", "buf", "[", "0", "]", ")", "debug_console_execute_command", "(", "machine", ",", "buf", ",", "1", ")", ";", "}", "}" ]
process_source_file - executes commands from a source file
[ "process_source_file", "-", "executes", "commands", "from", "a", "source", "file" ]
[ "/* loop until the file is exhausted or until we are executing again */", "/* stop at the end of file */", "/* fetch the next line */", "/* strip out comments (text after '//') */", "/* strip whitespace */", "/* execute the command */" ]
[ { "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": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
expression_get_device
device_t
static device_t *expression_get_device(running_machine *machine, const char *tag) { device_t *device; for (device = machine->m_devicelist.first(); device != NULL; device = device->next()) if (mame_stricmp(device->tag(), tag) == 0) return device; return NULL; }
/*------------------------------------------------- expression_get_device - return a device based on a case insensitive tag search -------------------------------------------------*/
return a device based on a case insensitive tag search
[ "return", "a", "device", "based", "on", "a", "case", "insensitive", "tag", "search" ]
static device_t *expression_get_device(running_machine *machine, const char *tag) { device_t *device; for (device = machine->m_devicelist.first(); device != NULL; device = device->next()) if (mame_stricmp(device->tag(), tag) == 0) return device; return NULL; }
[ "static", "device_t", "*", "expression_get_device", "(", "running_machine", "*", "machine", ",", "const", "char", "*", "tag", ")", "{", "device_t", "*", "device", ";", "for", "(", "device", "=", "machine", "->", "m_devicelist", ".", "first", "(", ")", ";", "device", "!=", "NULL", ";", "device", "=", "device", "->", "next", "(", ")", ")", "if", "(", "mame_stricmp", "(", "device", "->", "tag", "(", ")", ",", "tag", ")", "==", "0", ")", "return", "device", ";", "return", "NULL", ";", "}" ]
expression_get_device - return a device based on a case insensitive tag search
[ "expression_get_device", "-", "return", "a", "device", "based", "on", "a", "case", "insensitive", "tag", "search" ]
[]
[ { "param": "machine", "type": "running_machine" }, { "param": "tag", "type": "char" } ]
{ "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 } ], "outlier_params": [], "others": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
expression_read_memory
UINT64
static UINT64 expression_read_memory(void *param, const char *name, int spacenum, UINT32 address, int size) { running_machine *machine = (running_machine *)param; UINT64 result = ~(UINT64)0 >> (64 - 8*size); device_t *device = NULL; const address_space *space; switch (spacenum) { case EXPSPACE_PROGRAM_LOGICAL: case EXPSPACE_DATA_LOGICAL: case EXPSPACE_IO_LOGICAL: case EXPSPACE_SPACE3_LOGICAL: if (name != NULL) device = expression_get_device(machine, name); if (device == NULL) device = debug_cpu_get_visible_cpu(machine); space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM + (spacenum - EXPSPACE_PROGRAM_LOGICAL)); if (space != NULL) result = debug_read_memory(space, memory_address_to_byte(space, address), size, TRUE); break; case EXPSPACE_PROGRAM_PHYSICAL: case EXPSPACE_DATA_PHYSICAL: case EXPSPACE_IO_PHYSICAL: case EXPSPACE_SPACE3_PHYSICAL: if (name != NULL) device = expression_get_device(machine, name); if (device == NULL) device = debug_cpu_get_visible_cpu(machine); space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM + (spacenum - EXPSPACE_PROGRAM_PHYSICAL)); if (space != NULL) result = debug_read_memory(space, memory_address_to_byte(space, address), size, FALSE); break; case EXPSPACE_OPCODE: case EXPSPACE_RAMWRITE: if (name != NULL) device = expression_get_device(machine, name); if (device == NULL) device = debug_cpu_get_visible_cpu(machine); result = expression_read_program_direct(cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM), (spacenum == EXPSPACE_OPCODE), address, size); break; case EXPSPACE_REGION: if (name == NULL) break; result = expression_read_memory_region(machine, name, address, size); break; } return result; }
/*------------------------------------------------- expression_read_memory - read 1,2,4 or 8 bytes at the given offset in the given address space -------------------------------------------------*/
read 1,2,4 or 8 bytes at the given offset in the given address space
[ "read", "1", "2", "4", "or", "8", "bytes", "at", "the", "given", "offset", "in", "the", "given", "address", "space" ]
static UINT64 expression_read_memory(void *param, const char *name, int spacenum, UINT32 address, int size) { running_machine *machine = (running_machine *)param; UINT64 result = ~(UINT64)0 >> (64 - 8*size); device_t *device = NULL; const address_space *space; switch (spacenum) { case EXPSPACE_PROGRAM_LOGICAL: case EXPSPACE_DATA_LOGICAL: case EXPSPACE_IO_LOGICAL: case EXPSPACE_SPACE3_LOGICAL: if (name != NULL) device = expression_get_device(machine, name); if (device == NULL) device = debug_cpu_get_visible_cpu(machine); space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM + (spacenum - EXPSPACE_PROGRAM_LOGICAL)); if (space != NULL) result = debug_read_memory(space, memory_address_to_byte(space, address), size, TRUE); break; case EXPSPACE_PROGRAM_PHYSICAL: case EXPSPACE_DATA_PHYSICAL: case EXPSPACE_IO_PHYSICAL: case EXPSPACE_SPACE3_PHYSICAL: if (name != NULL) device = expression_get_device(machine, name); if (device == NULL) device = debug_cpu_get_visible_cpu(machine); space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM + (spacenum - EXPSPACE_PROGRAM_PHYSICAL)); if (space != NULL) result = debug_read_memory(space, memory_address_to_byte(space, address), size, FALSE); break; case EXPSPACE_OPCODE: case EXPSPACE_RAMWRITE: if (name != NULL) device = expression_get_device(machine, name); if (device == NULL) device = debug_cpu_get_visible_cpu(machine); result = expression_read_program_direct(cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM), (spacenum == EXPSPACE_OPCODE), address, size); break; case EXPSPACE_REGION: if (name == NULL) break; result = expression_read_memory_region(machine, name, address, size); break; } return result; }
[ "static", "UINT64", "expression_read_memory", "(", "void", "*", "param", ",", "const", "char", "*", "name", ",", "int", "spacenum", ",", "UINT32", "address", ",", "int", "size", ")", "{", "running_machine", "*", "machine", "=", "(", "running_machine", "*", ")", "param", ";", "UINT64", "result", "=", "~", "(", "UINT64", ")", "0", ">>", "(", "64", "-", "8", "*", "size", ")", ";", "device_t", "*", "device", "=", "NULL", ";", "const", "address_space", "*", "space", ";", "switch", "(", "spacenum", ")", "{", "case", "EXPSPACE_PROGRAM_LOGICAL", ":", "case", "EXPSPACE_DATA_LOGICAL", ":", "case", "EXPSPACE_IO_LOGICAL", ":", "case", "EXPSPACE_SPACE3_LOGICAL", ":", "if", "(", "name", "!=", "NULL", ")", "device", "=", "expression_get_device", "(", "machine", ",", "name", ")", ";", "if", "(", "device", "==", "NULL", ")", "device", "=", "debug_cpu_get_visible_cpu", "(", "machine", ")", ";", "space", "=", "cpu_get_address_space", "(", "device", ",", "ADDRESS_SPACE_PROGRAM", "+", "(", "spacenum", "-", "EXPSPACE_PROGRAM_LOGICAL", ")", ")", ";", "if", "(", "space", "!=", "NULL", ")", "result", "=", "debug_read_memory", "(", "space", ",", "memory_address_to_byte", "(", "space", ",", "address", ")", ",", "size", ",", "TRUE", ")", ";", "break", ";", "case", "EXPSPACE_PROGRAM_PHYSICAL", ":", "case", "EXPSPACE_DATA_PHYSICAL", ":", "case", "EXPSPACE_IO_PHYSICAL", ":", "case", "EXPSPACE_SPACE3_PHYSICAL", ":", "if", "(", "name", "!=", "NULL", ")", "device", "=", "expression_get_device", "(", "machine", ",", "name", ")", ";", "if", "(", "device", "==", "NULL", ")", "device", "=", "debug_cpu_get_visible_cpu", "(", "machine", ")", ";", "space", "=", "cpu_get_address_space", "(", "device", ",", "ADDRESS_SPACE_PROGRAM", "+", "(", "spacenum", "-", "EXPSPACE_PROGRAM_PHYSICAL", ")", ")", ";", "if", "(", "space", "!=", "NULL", ")", "result", "=", "debug_read_memory", "(", "space", ",", "memory_address_to_byte", "(", "space", ",", "address", ")", ",", "size", ",", "FALSE", ")", ";", "break", ";", "case", "EXPSPACE_OPCODE", ":", "case", "EXPSPACE_RAMWRITE", ":", "if", "(", "name", "!=", "NULL", ")", "device", "=", "expression_get_device", "(", "machine", ",", "name", ")", ";", "if", "(", "device", "==", "NULL", ")", "device", "=", "debug_cpu_get_visible_cpu", "(", "machine", ")", ";", "result", "=", "expression_read_program_direct", "(", "cpu_get_address_space", "(", "device", ",", "ADDRESS_SPACE_PROGRAM", ")", ",", "(", "spacenum", "==", "EXPSPACE_OPCODE", ")", ",", "address", ",", "size", ")", ";", "break", ";", "case", "EXPSPACE_REGION", ":", "if", "(", "name", "==", "NULL", ")", "break", ";", "result", "=", "expression_read_memory_region", "(", "machine", ",", "name", ",", "address", ",", "size", ")", ";", "break", ";", "}", "return", "result", ";", "}" ]
expression_read_memory - read 1,2,4 or 8 bytes at the given offset in the given address space
[ "expression_read_memory", "-", "read", "1", "2", "4", "or", "8", "bytes", "at", "the", "given", "offset", "in", "the", "given", "address", "space" ]
[]
[ { "param": "param", "type": "void" }, { "param": "name", "type": "char" }, { "param": "spacenum", "type": "int" }, { "param": "address", "type": "UINT32" }, { "param": "size", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "param", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "name", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "spacenum", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
expression_read_program_direct
UINT64
static UINT64 expression_read_program_direct(const address_space *space, int opcode, offs_t address, int size) { UINT64 result = ~(UINT64)0 >> (64 - 8*size); if (space != NULL) { UINT8 *base; /* adjust the address into a byte address, but not if being called recursively */ if ((opcode & 2) == 0) address = memory_address_to_byte(space, address); /* call ourself recursively until we are byte-sized */ if (size > 1) { int halfsize = size / 2; UINT64 r0, r1; /* read each half, from lower address to upper address */ r0 = expression_read_program_direct(space, opcode | 2, address + 0, halfsize); r1 = expression_read_program_direct(space, opcode | 2, address + halfsize, halfsize); /* assemble based on the target endianness */ if (space->endianness == ENDIANNESS_LITTLE) result = r0 | (r1 << (8 * halfsize)); else result = r1 | (r0 << (8 * halfsize)); } /* handle the byte-sized final requests */ else { /* lowmask specified which address bits are within the databus width */ offs_t lowmask = space->dbits / 8 - 1; /* get the base of memory, aligned to the address minus the lowbits */ if (opcode & 1) base = (UINT8 *)memory_decrypted_read_ptr(space, address & ~lowmask); else base = (UINT8 *)memory_get_read_ptr(space, address & ~lowmask); /* if we have a valid base, return the appropriate byte */ if (base != NULL) { if (space->endianness == ENDIANNESS_LITTLE) result = base[BYTE8_XOR_LE(address) & lowmask]; else result = base[BYTE8_XOR_BE(address) & lowmask]; } } } return result; }
/*------------------------------------------------- expression_read_program_direct - read memory directly from an opcode or RAM pointer -------------------------------------------------*/
read memory directly from an opcode or RAM pointer
[ "read", "memory", "directly", "from", "an", "opcode", "or", "RAM", "pointer" ]
static UINT64 expression_read_program_direct(const address_space *space, int opcode, offs_t address, int size) { UINT64 result = ~(UINT64)0 >> (64 - 8*size); if (space != NULL) { UINT8 *base; if ((opcode & 2) == 0) address = memory_address_to_byte(space, address); if (size > 1) { int halfsize = size / 2; UINT64 r0, r1; r0 = expression_read_program_direct(space, opcode | 2, address + 0, halfsize); r1 = expression_read_program_direct(space, opcode | 2, address + halfsize, halfsize); if (space->endianness == ENDIANNESS_LITTLE) result = r0 | (r1 << (8 * halfsize)); else result = r1 | (r0 << (8 * halfsize)); } else { offs_t lowmask = space->dbits / 8 - 1; if (opcode & 1) base = (UINT8 *)memory_decrypted_read_ptr(space, address & ~lowmask); else base = (UINT8 *)memory_get_read_ptr(space, address & ~lowmask); if (base != NULL) { if (space->endianness == ENDIANNESS_LITTLE) result = base[BYTE8_XOR_LE(address) & lowmask]; else result = base[BYTE8_XOR_BE(address) & lowmask]; } } } return result; }
[ "static", "UINT64", "expression_read_program_direct", "(", "const", "address_space", "*", "space", ",", "int", "opcode", ",", "offs_t", "address", ",", "int", "size", ")", "{", "UINT64", "result", "=", "~", "(", "UINT64", ")", "0", ">>", "(", "64", "-", "8", "*", "size", ")", ";", "if", "(", "space", "!=", "NULL", ")", "{", "UINT8", "*", "base", ";", "if", "(", "(", "opcode", "&", "2", ")", "==", "0", ")", "address", "=", "memory_address_to_byte", "(", "space", ",", "address", ")", ";", "if", "(", "size", ">", "1", ")", "{", "int", "halfsize", "=", "size", "/", "2", ";", "UINT64", "r0", ",", "r1", ";", "r0", "=", "expression_read_program_direct", "(", "space", ",", "opcode", "|", "2", ",", "address", "+", "0", ",", "halfsize", ")", ";", "r1", "=", "expression_read_program_direct", "(", "space", ",", "opcode", "|", "2", ",", "address", "+", "halfsize", ",", "halfsize", ")", ";", "if", "(", "space", "->", "endianness", "==", "ENDIANNESS_LITTLE", ")", "result", "=", "r0", "|", "(", "r1", "<<", "(", "8", "*", "halfsize", ")", ")", ";", "else", "result", "=", "r1", "|", "(", "r0", "<<", "(", "8", "*", "halfsize", ")", ")", ";", "}", "else", "{", "offs_t", "lowmask", "=", "space", "->", "dbits", "/", "8", "-", "1", ";", "if", "(", "opcode", "&", "1", ")", "base", "=", "(", "UINT8", "*", ")", "memory_decrypted_read_ptr", "(", "space", ",", "address", "&", "~", "lowmask", ")", ";", "else", "base", "=", "(", "UINT8", "*", ")", "memory_get_read_ptr", "(", "space", ",", "address", "&", "~", "lowmask", ")", ";", "if", "(", "base", "!=", "NULL", ")", "{", "if", "(", "space", "->", "endianness", "==", "ENDIANNESS_LITTLE", ")", "result", "=", "base", "[", "BYTE8_XOR_LE", "(", "address", ")", "&", "lowmask", "]", ";", "else", "result", "=", "base", "[", "BYTE8_XOR_BE", "(", "address", ")", "&", "lowmask", "]", ";", "}", "}", "}", "return", "result", ";", "}" ]
expression_read_program_direct - read memory directly from an opcode or RAM pointer
[ "expression_read_program_direct", "-", "read", "memory", "directly", "from", "an", "opcode", "or", "RAM", "pointer" ]
[ "/* adjust the address into a byte address, but not if being called recursively */", "/* call ourself recursively until we are byte-sized */", "/* read each half, from lower address to upper address */", "/* assemble based on the target endianness */", "/* handle the byte-sized final requests */", "/* lowmask specified which address bits are within the databus width */", "/* get the base of memory, aligned to the address minus the lowbits */", "/* if we have a valid base, return the appropriate byte */" ]
[ { "param": "space", "type": "address_space" }, { "param": "opcode", "type": "int" }, { "param": "address", "type": "offs_t" }, { "param": "size", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "space", "type": "address_space", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "opcode", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "offs_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
expression_read_memory_region
UINT64
static UINT64 expression_read_memory_region(running_machine *machine, const char *rgntag, offs_t address, int size) { const region_info *region = machine->region(rgntag); UINT64 result = ~(UINT64)0 >> (64 - 8*size); /* make sure we get a valid base before proceeding */ if (region != NULL) { /* call ourself recursively until we are byte-sized */ if (size > 1) { int halfsize = size / 2; UINT64 r0, r1; /* read each half, from lower address to upper address */ r0 = expression_read_memory_region(machine, rgntag, address + 0, halfsize); r1 = expression_read_memory_region(machine, rgntag, address + halfsize, halfsize); /* assemble based on the target endianness */ if (region->endianness() == ENDIANNESS_LITTLE) result = r0 | (r1 << (8 * halfsize)); else result = r1 | (r0 << (8 * halfsize)); } /* only process if we're within range */ else if (address < region->bytes()) { /* lowmask specified which address bits are within the databus width */ UINT32 lowmask = region->width() - 1; UINT8 *base = region->base() + (address & ~lowmask); /* if we have a valid base, return the appropriate byte */ if (region->endianness() == ENDIANNESS_LITTLE) result = base[BYTE8_XOR_LE(address) & lowmask]; else result = base[BYTE8_XOR_BE(address) & lowmask]; } } return result; }
/*------------------------------------------------- expression_read_memory_region - read memory from a memory region -------------------------------------------------*/
read memory from a memory region
[ "read", "memory", "from", "a", "memory", "region" ]
static UINT64 expression_read_memory_region(running_machine *machine, const char *rgntag, offs_t address, int size) { const region_info *region = machine->region(rgntag); UINT64 result = ~(UINT64)0 >> (64 - 8*size); if (region != NULL) { if (size > 1) { int halfsize = size / 2; UINT64 r0, r1; r0 = expression_read_memory_region(machine, rgntag, address + 0, halfsize); r1 = expression_read_memory_region(machine, rgntag, address + halfsize, halfsize); if (region->endianness() == ENDIANNESS_LITTLE) result = r0 | (r1 << (8 * halfsize)); else result = r1 | (r0 << (8 * halfsize)); } else if (address < region->bytes()) { UINT32 lowmask = region->width() - 1; UINT8 *base = region->base() + (address & ~lowmask); if (region->endianness() == ENDIANNESS_LITTLE) result = base[BYTE8_XOR_LE(address) & lowmask]; else result = base[BYTE8_XOR_BE(address) & lowmask]; } } return result; }
[ "static", "UINT64", "expression_read_memory_region", "(", "running_machine", "*", "machine", ",", "const", "char", "*", "rgntag", ",", "offs_t", "address", ",", "int", "size", ")", "{", "const", "region_info", "*", "region", "=", "machine", "->", "region", "(", "rgntag", ")", ";", "UINT64", "result", "=", "~", "(", "UINT64", ")", "0", ">>", "(", "64", "-", "8", "*", "size", ")", ";", "if", "(", "region", "!=", "NULL", ")", "{", "if", "(", "size", ">", "1", ")", "{", "int", "halfsize", "=", "size", "/", "2", ";", "UINT64", "r0", ",", "r1", ";", "r0", "=", "expression_read_memory_region", "(", "machine", ",", "rgntag", ",", "address", "+", "0", ",", "halfsize", ")", ";", "r1", "=", "expression_read_memory_region", "(", "machine", ",", "rgntag", ",", "address", "+", "halfsize", ",", "halfsize", ")", ";", "if", "(", "region", "->", "endianness", "(", ")", "==", "ENDIANNESS_LITTLE", ")", "result", "=", "r0", "|", "(", "r1", "<<", "(", "8", "*", "halfsize", ")", ")", ";", "else", "result", "=", "r1", "|", "(", "r0", "<<", "(", "8", "*", "halfsize", ")", ")", ";", "}", "else", "if", "(", "address", "<", "region", "->", "bytes", "(", ")", ")", "{", "UINT32", "lowmask", "=", "region", "->", "width", "(", ")", "-", "1", ";", "UINT8", "*", "base", "=", "region", "->", "base", "(", ")", "+", "(", "address", "&", "~", "lowmask", ")", ";", "if", "(", "region", "->", "endianness", "(", ")", "==", "ENDIANNESS_LITTLE", ")", "result", "=", "base", "[", "BYTE8_XOR_LE", "(", "address", ")", "&", "lowmask", "]", ";", "else", "result", "=", "base", "[", "BYTE8_XOR_BE", "(", "address", ")", "&", "lowmask", "]", ";", "}", "}", "return", "result", ";", "}" ]
expression_read_memory_region - read memory from a memory region
[ "expression_read_memory_region", "-", "read", "memory", "from", "a", "memory", "region" ]
[ "/* make sure we get a valid base before proceeding */", "/* call ourself recursively until we are byte-sized */", "/* read each half, from lower address to upper address */", "/* assemble based on the target endianness */", "/* only process if we're within range */", "/* lowmask specified which address bits are within the databus width */", "/* if we have a valid base, return the appropriate byte */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "rgntag", "type": "char" }, { "param": "address", "type": "offs_t" }, { "param": "size", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rgntag", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "offs_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
expression_write_memory
void
static void expression_write_memory(void *param, const char *name, int spacenum, UINT32 address, int size, UINT64 data) { running_machine *machine = (running_machine *)param; device_t *device = NULL; const address_space *space; switch (spacenum) { case EXPSPACE_PROGRAM_LOGICAL: case EXPSPACE_DATA_LOGICAL: case EXPSPACE_IO_LOGICAL: case EXPSPACE_SPACE3_LOGICAL: if (name != NULL) device = expression_get_device(machine, name); if (device == NULL) device = debug_cpu_get_visible_cpu(machine); space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM + (spacenum - EXPSPACE_PROGRAM_LOGICAL)); if (space != NULL) debug_write_memory(space, memory_address_to_byte(space, address), data, size, TRUE); break; case EXPSPACE_PROGRAM_PHYSICAL: case EXPSPACE_DATA_PHYSICAL: case EXPSPACE_IO_PHYSICAL: case EXPSPACE_SPACE3_PHYSICAL: if (name != NULL) device = expression_get_device(machine, name); if (device == NULL) device = debug_cpu_get_visible_cpu(machine); space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM + (spacenum - EXPSPACE_PROGRAM_PHYSICAL)); if (space != NULL) debug_write_memory(space, memory_address_to_byte(space, address), data, size, FALSE); break; case EXPSPACE_OPCODE: case EXPSPACE_RAMWRITE: if (name != NULL) device = expression_get_device(machine, name); if (device == NULL) device = debug_cpu_get_visible_cpu(machine); expression_write_program_direct(cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM), (spacenum == EXPSPACE_OPCODE), address, size, data); break; case EXPSPACE_REGION: if (name == NULL) break; expression_write_memory_region(machine, name, address, size, data); break; } }
/*------------------------------------------------- expression_write_memory - write 1,2,4 or 8 bytes at the given offset in the given address space -------------------------------------------------*/
write 1,2,4 or 8 bytes at the given offset in the given address space
[ "write", "1", "2", "4", "or", "8", "bytes", "at", "the", "given", "offset", "in", "the", "given", "address", "space" ]
static void expression_write_memory(void *param, const char *name, int spacenum, UINT32 address, int size, UINT64 data) { running_machine *machine = (running_machine *)param; device_t *device = NULL; const address_space *space; switch (spacenum) { case EXPSPACE_PROGRAM_LOGICAL: case EXPSPACE_DATA_LOGICAL: case EXPSPACE_IO_LOGICAL: case EXPSPACE_SPACE3_LOGICAL: if (name != NULL) device = expression_get_device(machine, name); if (device == NULL) device = debug_cpu_get_visible_cpu(machine); space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM + (spacenum - EXPSPACE_PROGRAM_LOGICAL)); if (space != NULL) debug_write_memory(space, memory_address_to_byte(space, address), data, size, TRUE); break; case EXPSPACE_PROGRAM_PHYSICAL: case EXPSPACE_DATA_PHYSICAL: case EXPSPACE_IO_PHYSICAL: case EXPSPACE_SPACE3_PHYSICAL: if (name != NULL) device = expression_get_device(machine, name); if (device == NULL) device = debug_cpu_get_visible_cpu(machine); space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM + (spacenum - EXPSPACE_PROGRAM_PHYSICAL)); if (space != NULL) debug_write_memory(space, memory_address_to_byte(space, address), data, size, FALSE); break; case EXPSPACE_OPCODE: case EXPSPACE_RAMWRITE: if (name != NULL) device = expression_get_device(machine, name); if (device == NULL) device = debug_cpu_get_visible_cpu(machine); expression_write_program_direct(cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM), (spacenum == EXPSPACE_OPCODE), address, size, data); break; case EXPSPACE_REGION: if (name == NULL) break; expression_write_memory_region(machine, name, address, size, data); break; } }
[ "static", "void", "expression_write_memory", "(", "void", "*", "param", ",", "const", "char", "*", "name", ",", "int", "spacenum", ",", "UINT32", "address", ",", "int", "size", ",", "UINT64", "data", ")", "{", "running_machine", "*", "machine", "=", "(", "running_machine", "*", ")", "param", ";", "device_t", "*", "device", "=", "NULL", ";", "const", "address_space", "*", "space", ";", "switch", "(", "spacenum", ")", "{", "case", "EXPSPACE_PROGRAM_LOGICAL", ":", "case", "EXPSPACE_DATA_LOGICAL", ":", "case", "EXPSPACE_IO_LOGICAL", ":", "case", "EXPSPACE_SPACE3_LOGICAL", ":", "if", "(", "name", "!=", "NULL", ")", "device", "=", "expression_get_device", "(", "machine", ",", "name", ")", ";", "if", "(", "device", "==", "NULL", ")", "device", "=", "debug_cpu_get_visible_cpu", "(", "machine", ")", ";", "space", "=", "cpu_get_address_space", "(", "device", ",", "ADDRESS_SPACE_PROGRAM", "+", "(", "spacenum", "-", "EXPSPACE_PROGRAM_LOGICAL", ")", ")", ";", "if", "(", "space", "!=", "NULL", ")", "debug_write_memory", "(", "space", ",", "memory_address_to_byte", "(", "space", ",", "address", ")", ",", "data", ",", "size", ",", "TRUE", ")", ";", "break", ";", "case", "EXPSPACE_PROGRAM_PHYSICAL", ":", "case", "EXPSPACE_DATA_PHYSICAL", ":", "case", "EXPSPACE_IO_PHYSICAL", ":", "case", "EXPSPACE_SPACE3_PHYSICAL", ":", "if", "(", "name", "!=", "NULL", ")", "device", "=", "expression_get_device", "(", "machine", ",", "name", ")", ";", "if", "(", "device", "==", "NULL", ")", "device", "=", "debug_cpu_get_visible_cpu", "(", "machine", ")", ";", "space", "=", "cpu_get_address_space", "(", "device", ",", "ADDRESS_SPACE_PROGRAM", "+", "(", "spacenum", "-", "EXPSPACE_PROGRAM_PHYSICAL", ")", ")", ";", "if", "(", "space", "!=", "NULL", ")", "debug_write_memory", "(", "space", ",", "memory_address_to_byte", "(", "space", ",", "address", ")", ",", "data", ",", "size", ",", "FALSE", ")", ";", "break", ";", "case", "EXPSPACE_OPCODE", ":", "case", "EXPSPACE_RAMWRITE", ":", "if", "(", "name", "!=", "NULL", ")", "device", "=", "expression_get_device", "(", "machine", ",", "name", ")", ";", "if", "(", "device", "==", "NULL", ")", "device", "=", "debug_cpu_get_visible_cpu", "(", "machine", ")", ";", "expression_write_program_direct", "(", "cpu_get_address_space", "(", "device", ",", "ADDRESS_SPACE_PROGRAM", ")", ",", "(", "spacenum", "==", "EXPSPACE_OPCODE", ")", ",", "address", ",", "size", ",", "data", ")", ";", "break", ";", "case", "EXPSPACE_REGION", ":", "if", "(", "name", "==", "NULL", ")", "break", ";", "expression_write_memory_region", "(", "machine", ",", "name", ",", "address", ",", "size", ",", "data", ")", ";", "break", ";", "}", "}" ]
expression_write_memory - write 1,2,4 or 8 bytes at the given offset in the given address space
[ "expression_write_memory", "-", "write", "1", "2", "4", "or", "8", "bytes", "at", "the", "given", "offset", "in", "the", "given", "address", "space" ]
[]
[ { "param": "param", "type": "void" }, { "param": "name", "type": "char" }, { "param": "spacenum", "type": "int" }, { "param": "address", "type": "UINT32" }, { "param": "size", "type": "int" }, { "param": "data", "type": "UINT64" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "param", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "name", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "spacenum", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "UINT64", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
expression_write_program_direct
void
static void expression_write_program_direct(const address_space *space, int opcode, offs_t address, int size, UINT64 data) { if (space != NULL) { debugcpu_private *global = space->machine->debugcpu_data; UINT8 *base; /* adjust the address into a byte address, but not if being called recursively */ if ((opcode & 2) == 0) address = memory_address_to_byte(space, address); /* call ourself recursively until we are byte-sized */ if (size > 1) { int halfsize = size / 2; UINT64 r0, r1, halfmask; /* break apart based on the target endianness */ halfmask = ~(UINT64)0 >> (64 - 8 * halfsize); if (space->endianness == ENDIANNESS_LITTLE) { r0 = data & halfmask; r1 = (data >> (8 * halfsize)) & halfmask; } else { r0 = (data >> (8 * halfsize)) & halfmask; r1 = data & halfmask; } /* write each half, from lower address to upper address */ expression_write_program_direct(space, opcode | 2, address + 0, halfsize, r0); expression_write_program_direct(space, opcode | 2, address + halfsize, halfsize, r1); } /* handle the byte-sized final case */ else { /* lowmask specified which address bits are within the databus width */ offs_t lowmask = space->dbits / 8 - 1; /* get the base of memory, aligned to the address minus the lowbits */ if (opcode & 1) base = (UINT8 *)memory_decrypted_read_ptr(space, address & ~lowmask); else base = (UINT8 *)memory_get_read_ptr(space, address & ~lowmask); /* if we have a valid base, write the appropriate byte */ if (base != NULL) { if (space->endianness == ENDIANNESS_LITTLE) base[BYTE8_XOR_LE(address) & lowmask] = data; else base[BYTE8_XOR_BE(address) & lowmask] = data; global->memory_modified = TRUE; } } } }
/*------------------------------------------------- expression_write_program_direct - write memory directly to an opcode or RAM pointer -------------------------------------------------*/
write memory directly to an opcode or RAM pointer
[ "write", "memory", "directly", "to", "an", "opcode", "or", "RAM", "pointer" ]
static void expression_write_program_direct(const address_space *space, int opcode, offs_t address, int size, UINT64 data) { if (space != NULL) { debugcpu_private *global = space->machine->debugcpu_data; UINT8 *base; if ((opcode & 2) == 0) address = memory_address_to_byte(space, address); if (size > 1) { int halfsize = size / 2; UINT64 r0, r1, halfmask; halfmask = ~(UINT64)0 >> (64 - 8 * halfsize); if (space->endianness == ENDIANNESS_LITTLE) { r0 = data & halfmask; r1 = (data >> (8 * halfsize)) & halfmask; } else { r0 = (data >> (8 * halfsize)) & halfmask; r1 = data & halfmask; } expression_write_program_direct(space, opcode | 2, address + 0, halfsize, r0); expression_write_program_direct(space, opcode | 2, address + halfsize, halfsize, r1); } else { offs_t lowmask = space->dbits / 8 - 1; if (opcode & 1) base = (UINT8 *)memory_decrypted_read_ptr(space, address & ~lowmask); else base = (UINT8 *)memory_get_read_ptr(space, address & ~lowmask); if (base != NULL) { if (space->endianness == ENDIANNESS_LITTLE) base[BYTE8_XOR_LE(address) & lowmask] = data; else base[BYTE8_XOR_BE(address) & lowmask] = data; global->memory_modified = TRUE; } } } }
[ "static", "void", "expression_write_program_direct", "(", "const", "address_space", "*", "space", ",", "int", "opcode", ",", "offs_t", "address", ",", "int", "size", ",", "UINT64", "data", ")", "{", "if", "(", "space", "!=", "NULL", ")", "{", "debugcpu_private", "*", "global", "=", "space", "->", "machine", "->", "debugcpu_data", ";", "UINT8", "*", "base", ";", "if", "(", "(", "opcode", "&", "2", ")", "==", "0", ")", "address", "=", "memory_address_to_byte", "(", "space", ",", "address", ")", ";", "if", "(", "size", ">", "1", ")", "{", "int", "halfsize", "=", "size", "/", "2", ";", "UINT64", "r0", ",", "r1", ",", "halfmask", ";", "halfmask", "=", "~", "(", "UINT64", ")", "0", ">>", "(", "64", "-", "8", "*", "halfsize", ")", ";", "if", "(", "space", "->", "endianness", "==", "ENDIANNESS_LITTLE", ")", "{", "r0", "=", "data", "&", "halfmask", ";", "r1", "=", "(", "data", ">>", "(", "8", "*", "halfsize", ")", ")", "&", "halfmask", ";", "}", "else", "{", "r0", "=", "(", "data", ">>", "(", "8", "*", "halfsize", ")", ")", "&", "halfmask", ";", "r1", "=", "data", "&", "halfmask", ";", "}", "expression_write_program_direct", "(", "space", ",", "opcode", "|", "2", ",", "address", "+", "0", ",", "halfsize", ",", "r0", ")", ";", "expression_write_program_direct", "(", "space", ",", "opcode", "|", "2", ",", "address", "+", "halfsize", ",", "halfsize", ",", "r1", ")", ";", "}", "else", "{", "offs_t", "lowmask", "=", "space", "->", "dbits", "/", "8", "-", "1", ";", "if", "(", "opcode", "&", "1", ")", "base", "=", "(", "UINT8", "*", ")", "memory_decrypted_read_ptr", "(", "space", ",", "address", "&", "~", "lowmask", ")", ";", "else", "base", "=", "(", "UINT8", "*", ")", "memory_get_read_ptr", "(", "space", ",", "address", "&", "~", "lowmask", ")", ";", "if", "(", "base", "!=", "NULL", ")", "{", "if", "(", "space", "->", "endianness", "==", "ENDIANNESS_LITTLE", ")", "base", "[", "BYTE8_XOR_LE", "(", "address", ")", "&", "lowmask", "]", "=", "data", ";", "else", "base", "[", "BYTE8_XOR_BE", "(", "address", ")", "&", "lowmask", "]", "=", "data", ";", "global", "->", "memory_modified", "=", "TRUE", ";", "}", "}", "}", "}" ]
expression_write_program_direct - write memory directly to an opcode or RAM pointer
[ "expression_write_program_direct", "-", "write", "memory", "directly", "to", "an", "opcode", "or", "RAM", "pointer" ]
[ "/* adjust the address into a byte address, but not if being called recursively */", "/* call ourself recursively until we are byte-sized */", "/* break apart based on the target endianness */", "/* write each half, from lower address to upper address */", "/* handle the byte-sized final case */", "/* lowmask specified which address bits are within the databus width */", "/* get the base of memory, aligned to the address minus the lowbits */", "/* if we have a valid base, write the appropriate byte */" ]
[ { "param": "space", "type": "address_space" }, { "param": "opcode", "type": "int" }, { "param": "address", "type": "offs_t" }, { "param": "size", "type": "int" }, { "param": "data", "type": "UINT64" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "space", "type": "address_space", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "opcode", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "offs_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "UINT64", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
expression_write_memory_region
void
static void expression_write_memory_region(running_machine *machine, const char *rgntag, offs_t address, int size, UINT64 data) { debugcpu_private *global = machine->debugcpu_data; const region_info *region = machine->region(rgntag); /* make sure we get a valid base before proceeding */ if (region != NULL) { /* call ourself recursively until we are byte-sized */ if (size > 1) { int halfsize = size / 2; UINT64 r0, r1, halfmask; /* break apart based on the target endianness */ halfmask = ~(UINT64)0 >> (64 - 8 * halfsize); if (region->endianness() == ENDIANNESS_LITTLE) { r0 = data & halfmask; r1 = (data >> (8 * halfsize)) & halfmask; } else { r0 = (data >> (8 * halfsize)) & halfmask; r1 = data & halfmask; } /* write each half, from lower address to upper address */ expression_write_memory_region(machine, rgntag, address + 0, halfsize, r0); expression_write_memory_region(machine, rgntag, address + halfsize, halfsize, r1); } /* only process if we're within range */ else if (address < region->bytes()) { /* lowmask specified which address bits are within the databus width */ UINT32 lowmask = region->width() - 1; UINT8 *base = region->base() + (address & ~lowmask); /* if we have a valid base, set the appropriate byte */ if (region->endianness() == ENDIANNESS_LITTLE) base[BYTE8_XOR_LE(address) & lowmask] = data; else base[BYTE8_XOR_BE(address) & lowmask] = data; global->memory_modified = TRUE; } } }
/*------------------------------------------------- expression_write_memory_region - write memory from a memory region -------------------------------------------------*/
write memory from a memory region
[ "write", "memory", "from", "a", "memory", "region" ]
static void expression_write_memory_region(running_machine *machine, const char *rgntag, offs_t address, int size, UINT64 data) { debugcpu_private *global = machine->debugcpu_data; const region_info *region = machine->region(rgntag); if (region != NULL) { if (size > 1) { int halfsize = size / 2; UINT64 r0, r1, halfmask; halfmask = ~(UINT64)0 >> (64 - 8 * halfsize); if (region->endianness() == ENDIANNESS_LITTLE) { r0 = data & halfmask; r1 = (data >> (8 * halfsize)) & halfmask; } else { r0 = (data >> (8 * halfsize)) & halfmask; r1 = data & halfmask; } expression_write_memory_region(machine, rgntag, address + 0, halfsize, r0); expression_write_memory_region(machine, rgntag, address + halfsize, halfsize, r1); } else if (address < region->bytes()) { UINT32 lowmask = region->width() - 1; UINT8 *base = region->base() + (address & ~lowmask); if (region->endianness() == ENDIANNESS_LITTLE) base[BYTE8_XOR_LE(address) & lowmask] = data; else base[BYTE8_XOR_BE(address) & lowmask] = data; global->memory_modified = TRUE; } } }
[ "static", "void", "expression_write_memory_region", "(", "running_machine", "*", "machine", ",", "const", "char", "*", "rgntag", ",", "offs_t", "address", ",", "int", "size", ",", "UINT64", "data", ")", "{", "debugcpu_private", "*", "global", "=", "machine", "->", "debugcpu_data", ";", "const", "region_info", "*", "region", "=", "machine", "->", "region", "(", "rgntag", ")", ";", "if", "(", "region", "!=", "NULL", ")", "{", "if", "(", "size", ">", "1", ")", "{", "int", "halfsize", "=", "size", "/", "2", ";", "UINT64", "r0", ",", "r1", ",", "halfmask", ";", "halfmask", "=", "~", "(", "UINT64", ")", "0", ">>", "(", "64", "-", "8", "*", "halfsize", ")", ";", "if", "(", "region", "->", "endianness", "(", ")", "==", "ENDIANNESS_LITTLE", ")", "{", "r0", "=", "data", "&", "halfmask", ";", "r1", "=", "(", "data", ">>", "(", "8", "*", "halfsize", ")", ")", "&", "halfmask", ";", "}", "else", "{", "r0", "=", "(", "data", ">>", "(", "8", "*", "halfsize", ")", ")", "&", "halfmask", ";", "r1", "=", "data", "&", "halfmask", ";", "}", "expression_write_memory_region", "(", "machine", ",", "rgntag", ",", "address", "+", "0", ",", "halfsize", ",", "r0", ")", ";", "expression_write_memory_region", "(", "machine", ",", "rgntag", ",", "address", "+", "halfsize", ",", "halfsize", ",", "r1", ")", ";", "}", "else", "if", "(", "address", "<", "region", "->", "bytes", "(", ")", ")", "{", "UINT32", "lowmask", "=", "region", "->", "width", "(", ")", "-", "1", ";", "UINT8", "*", "base", "=", "region", "->", "base", "(", ")", "+", "(", "address", "&", "~", "lowmask", ")", ";", "if", "(", "region", "->", "endianness", "(", ")", "==", "ENDIANNESS_LITTLE", ")", "base", "[", "BYTE8_XOR_LE", "(", "address", ")", "&", "lowmask", "]", "=", "data", ";", "else", "base", "[", "BYTE8_XOR_BE", "(", "address", ")", "&", "lowmask", "]", "=", "data", ";", "global", "->", "memory_modified", "=", "TRUE", ";", "}", "}", "}" ]
expression_write_memory_region - write memory from a memory region
[ "expression_write_memory_region", "-", "write", "memory", "from", "a", "memory", "region" ]
[ "/* make sure we get a valid base before proceeding */", "/* call ourself recursively until we are byte-sized */", "/* break apart based on the target endianness */", "/* write each half, from lower address to upper address */", "/* only process if we're within range */", "/* lowmask specified which address bits are within the databus width */", "/* if we have a valid base, set the appropriate byte */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "rgntag", "type": "char" }, { "param": "address", "type": "offs_t" }, { "param": "size", "type": "int" }, { "param": "data", "type": "UINT64" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rgntag", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "offs_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "UINT64", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
39cbe132f1ee9f4cda68811c21a81e3b90382797
lofunz/mieme
Reloaded/trunk/src/emu/debug/debugcpu.c
[ "Unlicense" ]
C
expression_validate
EXPRERR
static EXPRERR expression_validate(void *param, const char *name, int space) { running_machine *machine = (running_machine *)param; device_t *device = NULL; switch (space) { case EXPSPACE_PROGRAM_LOGICAL: case EXPSPACE_DATA_LOGICAL: case EXPSPACE_IO_LOGICAL: case EXPSPACE_SPACE3_LOGICAL: if (name != NULL) { device = expression_get_device(machine, name); if (device == NULL) return EXPRERR_INVALID_MEMORY_NAME; } if (device == NULL) device = debug_cpu_get_visible_cpu(machine); if (cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM + (space - EXPSPACE_PROGRAM_LOGICAL)) == NULL) return EXPRERR_NO_SUCH_MEMORY_SPACE; break; case EXPSPACE_PROGRAM_PHYSICAL: case EXPSPACE_DATA_PHYSICAL: case EXPSPACE_IO_PHYSICAL: case EXPSPACE_SPACE3_PHYSICAL: if (name != NULL) { device = expression_get_device(machine, name); if (device == NULL) return EXPRERR_INVALID_MEMORY_NAME; } if (device == NULL) device = debug_cpu_get_visible_cpu(machine); if (cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM + (space - EXPSPACE_PROGRAM_PHYSICAL)) == NULL) return EXPRERR_NO_SUCH_MEMORY_SPACE; break; case EXPSPACE_OPCODE: case EXPSPACE_RAMWRITE: if (name != NULL) { device = expression_get_device(machine, name); if (device == NULL) return EXPRERR_INVALID_MEMORY_NAME; } if (device == NULL) device = debug_cpu_get_visible_cpu(machine); if (cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM) == NULL) return EXPRERR_NO_SUCH_MEMORY_SPACE; break; case EXPSPACE_REGION: if (name == NULL) return EXPRERR_MISSING_MEMORY_NAME; if (memory_region(machine, name) == NULL) return EXPRERR_INVALID_MEMORY_NAME; break; } return EXPRERR_NONE; }
/*------------------------------------------------- expression_validate - validate that the provided expression references an appropriate name -------------------------------------------------*/
validate that the provided expression references an appropriate name
[ "validate", "that", "the", "provided", "expression", "references", "an", "appropriate", "name" ]
static EXPRERR expression_validate(void *param, const char *name, int space) { running_machine *machine = (running_machine *)param; device_t *device = NULL; switch (space) { case EXPSPACE_PROGRAM_LOGICAL: case EXPSPACE_DATA_LOGICAL: case EXPSPACE_IO_LOGICAL: case EXPSPACE_SPACE3_LOGICAL: if (name != NULL) { device = expression_get_device(machine, name); if (device == NULL) return EXPRERR_INVALID_MEMORY_NAME; } if (device == NULL) device = debug_cpu_get_visible_cpu(machine); if (cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM + (space - EXPSPACE_PROGRAM_LOGICAL)) == NULL) return EXPRERR_NO_SUCH_MEMORY_SPACE; break; case EXPSPACE_PROGRAM_PHYSICAL: case EXPSPACE_DATA_PHYSICAL: case EXPSPACE_IO_PHYSICAL: case EXPSPACE_SPACE3_PHYSICAL: if (name != NULL) { device = expression_get_device(machine, name); if (device == NULL) return EXPRERR_INVALID_MEMORY_NAME; } if (device == NULL) device = debug_cpu_get_visible_cpu(machine); if (cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM + (space - EXPSPACE_PROGRAM_PHYSICAL)) == NULL) return EXPRERR_NO_SUCH_MEMORY_SPACE; break; case EXPSPACE_OPCODE: case EXPSPACE_RAMWRITE: if (name != NULL) { device = expression_get_device(machine, name); if (device == NULL) return EXPRERR_INVALID_MEMORY_NAME; } if (device == NULL) device = debug_cpu_get_visible_cpu(machine); if (cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM) == NULL) return EXPRERR_NO_SUCH_MEMORY_SPACE; break; case EXPSPACE_REGION: if (name == NULL) return EXPRERR_MISSING_MEMORY_NAME; if (memory_region(machine, name) == NULL) return EXPRERR_INVALID_MEMORY_NAME; break; } return EXPRERR_NONE; }
[ "static", "EXPRERR", "expression_validate", "(", "void", "*", "param", ",", "const", "char", "*", "name", ",", "int", "space", ")", "{", "running_machine", "*", "machine", "=", "(", "running_machine", "*", ")", "param", ";", "device_t", "*", "device", "=", "NULL", ";", "switch", "(", "space", ")", "{", "case", "EXPSPACE_PROGRAM_LOGICAL", ":", "case", "EXPSPACE_DATA_LOGICAL", ":", "case", "EXPSPACE_IO_LOGICAL", ":", "case", "EXPSPACE_SPACE3_LOGICAL", ":", "if", "(", "name", "!=", "NULL", ")", "{", "device", "=", "expression_get_device", "(", "machine", ",", "name", ")", ";", "if", "(", "device", "==", "NULL", ")", "return", "EXPRERR_INVALID_MEMORY_NAME", ";", "}", "if", "(", "device", "==", "NULL", ")", "device", "=", "debug_cpu_get_visible_cpu", "(", "machine", ")", ";", "if", "(", "cpu_get_address_space", "(", "device", ",", "ADDRESS_SPACE_PROGRAM", "+", "(", "space", "-", "EXPSPACE_PROGRAM_LOGICAL", ")", ")", "==", "NULL", ")", "return", "EXPRERR_NO_SUCH_MEMORY_SPACE", ";", "break", ";", "case", "EXPSPACE_PROGRAM_PHYSICAL", ":", "case", "EXPSPACE_DATA_PHYSICAL", ":", "case", "EXPSPACE_IO_PHYSICAL", ":", "case", "EXPSPACE_SPACE3_PHYSICAL", ":", "if", "(", "name", "!=", "NULL", ")", "{", "device", "=", "expression_get_device", "(", "machine", ",", "name", ")", ";", "if", "(", "device", "==", "NULL", ")", "return", "EXPRERR_INVALID_MEMORY_NAME", ";", "}", "if", "(", "device", "==", "NULL", ")", "device", "=", "debug_cpu_get_visible_cpu", "(", "machine", ")", ";", "if", "(", "cpu_get_address_space", "(", "device", ",", "ADDRESS_SPACE_PROGRAM", "+", "(", "space", "-", "EXPSPACE_PROGRAM_PHYSICAL", ")", ")", "==", "NULL", ")", "return", "EXPRERR_NO_SUCH_MEMORY_SPACE", ";", "break", ";", "case", "EXPSPACE_OPCODE", ":", "case", "EXPSPACE_RAMWRITE", ":", "if", "(", "name", "!=", "NULL", ")", "{", "device", "=", "expression_get_device", "(", "machine", ",", "name", ")", ";", "if", "(", "device", "==", "NULL", ")", "return", "EXPRERR_INVALID_MEMORY_NAME", ";", "}", "if", "(", "device", "==", "NULL", ")", "device", "=", "debug_cpu_get_visible_cpu", "(", "machine", ")", ";", "if", "(", "cpu_get_address_space", "(", "device", ",", "ADDRESS_SPACE_PROGRAM", ")", "==", "NULL", ")", "return", "EXPRERR_NO_SUCH_MEMORY_SPACE", ";", "break", ";", "case", "EXPSPACE_REGION", ":", "if", "(", "name", "==", "NULL", ")", "return", "EXPRERR_MISSING_MEMORY_NAME", ";", "if", "(", "memory_region", "(", "machine", ",", "name", ")", "==", "NULL", ")", "return", "EXPRERR_INVALID_MEMORY_NAME", ";", "break", ";", "}", "return", "EXPRERR_NONE", ";", "}" ]
expression_validate - validate that the provided expression references an appropriate name
[ "expression_validate", "-", "validate", "that", "the", "provided", "expression", "references", "an", "appropriate", "name" ]
[]
[ { "param": "param", "type": "void" }, { "param": "name", "type": "char" }, { "param": "space", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "param", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "name", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "space", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1d410051ebe84bb0463eabe8cfc6dbd58d07487b
lofunz/mieme
Reloaded/trunk/src/tools/jedutil.c
[ "Unlicense" ]
C
read_source_file
int
static int read_source_file(const char *srcfile) { size_t bytes; FILE *file; /* open the source file */ file = fopen(srcfile, "rb"); if (!file) { fprintf(stderr, "Unable to open source file '%s'!\n", srcfile); return 1; } /* allocate memory for the data */ fseek(file, 0, SEEK_END); srcbuflen = ftell(file); fseek(file, 0, SEEK_SET); srcbuf = (UINT8 *)malloc(srcbuflen); if (!srcbuf) { fprintf(stderr, "Unable to allocate %d bytes for the source!\n", (int)srcbuflen); fclose(file); return 1; } /* read the data */ bytes = fread(srcbuf, 1, srcbuflen, file); if (bytes != srcbuflen) { fprintf(stderr, "Error reading %d bytes from the source!\n", (int)srcbuflen); free(srcbuf); fclose(file); return 1; } /* close up shop */ fclose(file); return 0; }
/*------------------------------------------------- read_source_file - read a raw source file into an allocated memory buffer -------------------------------------------------*/
read a raw source file into an allocated memory buffer
[ "read", "a", "raw", "source", "file", "into", "an", "allocated", "memory", "buffer" ]
static int read_source_file(const char *srcfile) { size_t bytes; FILE *file; file = fopen(srcfile, "rb"); if (!file) { fprintf(stderr, "Unable to open source file '%s'!\n", srcfile); return 1; } fseek(file, 0, SEEK_END); srcbuflen = ftell(file); fseek(file, 0, SEEK_SET); srcbuf = (UINT8 *)malloc(srcbuflen); if (!srcbuf) { fprintf(stderr, "Unable to allocate %d bytes for the source!\n", (int)srcbuflen); fclose(file); return 1; } bytes = fread(srcbuf, 1, srcbuflen, file); if (bytes != srcbuflen) { fprintf(stderr, "Error reading %d bytes from the source!\n", (int)srcbuflen); free(srcbuf); fclose(file); return 1; } fclose(file); return 0; }
[ "static", "int", "read_source_file", "(", "const", "char", "*", "srcfile", ")", "{", "size_t", "bytes", ";", "FILE", "*", "file", ";", "file", "=", "fopen", "(", "srcfile", ",", "\"", "\"", ")", ";", "if", "(", "!", "file", ")", "{", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "srcfile", ")", ";", "return", "1", ";", "}", "fseek", "(", "file", ",", "0", ",", "SEEK_END", ")", ";", "srcbuflen", "=", "ftell", "(", "file", ")", ";", "fseek", "(", "file", ",", "0", ",", "SEEK_SET", ")", ";", "srcbuf", "=", "(", "UINT8", "*", ")", "malloc", "(", "srcbuflen", ")", ";", "if", "(", "!", "srcbuf", ")", "{", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "(", "int", ")", "srcbuflen", ")", ";", "fclose", "(", "file", ")", ";", "return", "1", ";", "}", "bytes", "=", "fread", "(", "srcbuf", ",", "1", ",", "srcbuflen", ",", "file", ")", ";", "if", "(", "bytes", "!=", "srcbuflen", ")", "{", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "(", "int", ")", "srcbuflen", ")", ";", "free", "(", "srcbuf", ")", ";", "fclose", "(", "file", ")", ";", "return", "1", ";", "}", "fclose", "(", "file", ")", ";", "return", "0", ";", "}" ]
read_source_file - read a raw source file into an allocated memory buffer
[ "read_source_file", "-", "read", "a", "raw", "source", "file", "into", "an", "allocated", "memory", "buffer" ]
[ "/* open the source file */", "/* allocate memory for the data */", "/* read the data */", "/* close up shop */" ]
[ { "param": "srcfile", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "srcfile", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1d410051ebe84bb0463eabe8cfc6dbd58d07487b
lofunz/mieme
Reloaded/trunk/src/tools/jedutil.c
[ "Unlicense" ]
C
write_dest_file
int
static int write_dest_file(const char *dstfile) { size_t bytes; FILE *file; /* open the source file */ file = fopen(dstfile, "wb"); if (!file) { fprintf(stderr, "Unable to open target file '%s'!\n", dstfile); return 1; } /* write the data */ bytes = fwrite(dstbuf, 1, dstbuflen, file); if (bytes != dstbuflen) { fprintf(stderr, "Error writing %d bytes to the target!\n", (int)dstbuflen); fclose(file); return 1; } /* close up shop */ fclose(file); return 0; }
/*------------------------------------------------- write_dest_file - write a memory buffer raw into a desintation file -------------------------------------------------*/
write a memory buffer raw into a desintation file
[ "write", "a", "memory", "buffer", "raw", "into", "a", "desintation", "file" ]
static int write_dest_file(const char *dstfile) { size_t bytes; FILE *file; file = fopen(dstfile, "wb"); if (!file) { fprintf(stderr, "Unable to open target file '%s'!\n", dstfile); return 1; } bytes = fwrite(dstbuf, 1, dstbuflen, file); if (bytes != dstbuflen) { fprintf(stderr, "Error writing %d bytes to the target!\n", (int)dstbuflen); fclose(file); return 1; } fclose(file); return 0; }
[ "static", "int", "write_dest_file", "(", "const", "char", "*", "dstfile", ")", "{", "size_t", "bytes", ";", "FILE", "*", "file", ";", "file", "=", "fopen", "(", "dstfile", ",", "\"", "\"", ")", ";", "if", "(", "!", "file", ")", "{", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "dstfile", ")", ";", "return", "1", ";", "}", "bytes", "=", "fwrite", "(", "dstbuf", ",", "1", ",", "dstbuflen", ",", "file", ")", ";", "if", "(", "bytes", "!=", "dstbuflen", ")", "{", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "(", "int", ")", "dstbuflen", ")", ";", "fclose", "(", "file", ")", ";", "return", "1", ";", "}", "fclose", "(", "file", ")", ";", "return", "0", ";", "}" ]
write_dest_file - write a memory buffer raw into a desintation file
[ "write_dest_file", "-", "write", "a", "memory", "buffer", "raw", "into", "a", "desintation", "file" ]
[ "/* open the source file */", "/* write the data */", "/* close up shop */" ]
[ { "param": "dstfile", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dstfile", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
53c12b91397618a2d97e3ec5a751dd9f6f8d599b
lofunz/mieme
Reloaded/trunk/src/mame/video/irobot.c
[ "Unlicense" ]
C
draw_line
void
static void draw_line (UINT8 *polybitmap, int x1, int y1, int x2, int y2, int col) { int dx,dy,sx,sy,cx,cy; dx = abs(x1-x2); dy = abs(y1-y2); sx = (x1 <= x2) ? 1: -1; sy = (y1 <= y2) ? 1: -1; cx = dx/2; cy = dy/2; if (dx>=dy) { for (;;) { if (x1 >= ir_xmin && x1 < ir_xmax && y1 >= ir_ymin && y1 < ir_ymax) draw_pixel (x1, y1, col); if (x1 == x2) break; x1 += sx; cx -= dy; if (cx < 0) { y1 += sy; cx += dx; } } } else { for (;;) { if (x1 >= ir_xmin && x1 < ir_xmax && y1 >= ir_ymin && y1 < ir_ymax) draw_pixel (x1, y1, col); if (y1 == y2) break; y1 += sy; cy -= dx; if (cy < 0) { x1 += sx; cy += dy; } } } }
/* Line draw routine modified from a routine written by Andrew Caldwell */
Line draw routine modified from a routine written by Andrew Caldwell
[ "Line", "draw", "routine", "modified", "from", "a", "routine", "written", "by", "Andrew", "Caldwell" ]
static void draw_line (UINT8 *polybitmap, int x1, int y1, int x2, int y2, int col) { int dx,dy,sx,sy,cx,cy; dx = abs(x1-x2); dy = abs(y1-y2); sx = (x1 <= x2) ? 1: -1; sy = (y1 <= y2) ? 1: -1; cx = dx/2; cy = dy/2; if (dx>=dy) { for (;;) { if (x1 >= ir_xmin && x1 < ir_xmax && y1 >= ir_ymin && y1 < ir_ymax) draw_pixel (x1, y1, col); if (x1 == x2) break; x1 += sx; cx -= dy; if (cx < 0) { y1 += sy; cx += dx; } } } else { for (;;) { if (x1 >= ir_xmin && x1 < ir_xmax && y1 >= ir_ymin && y1 < ir_ymax) draw_pixel (x1, y1, col); if (y1 == y2) break; y1 += sy; cy -= dx; if (cy < 0) { x1 += sx; cy += dy; } } } }
[ "static", "void", "draw_line", "(", "UINT8", "*", "polybitmap", ",", "int", "x1", ",", "int", "y1", ",", "int", "x2", ",", "int", "y2", ",", "int", "col", ")", "{", "int", "dx", ",", "dy", ",", "sx", ",", "sy", ",", "cx", ",", "cy", ";", "dx", "=", "abs", "(", "x1", "-", "x2", ")", ";", "dy", "=", "abs", "(", "y1", "-", "y2", ")", ";", "sx", "=", "(", "x1", "<=", "x2", ")", "?", "1", ":", "-1", ";", "sy", "=", "(", "y1", "<=", "y2", ")", "?", "1", ":", "-1", ";", "cx", "=", "dx", "/", "2", ";", "cy", "=", "dy", "/", "2", ";", "if", "(", "dx", ">=", "dy", ")", "{", "for", "(", ";", ";", ")", "{", "if", "(", "x1", ">=", "ir_xmin", "&&", "x1", "<", "ir_xmax", "&&", "y1", ">=", "ir_ymin", "&&", "y1", "<", "ir_ymax", ")", "draw_pixel", "(", "x1", ",", "y1", ",", "col", ")", ";", "if", "(", "x1", "==", "x2", ")", "break", ";", "x1", "+=", "sx", ";", "cx", "-=", "dy", ";", "if", "(", "cx", "<", "0", ")", "{", "y1", "+=", "sy", ";", "cx", "+=", "dx", ";", "}", "}", "}", "else", "{", "for", "(", ";", ";", ")", "{", "if", "(", "x1", ">=", "ir_xmin", "&&", "x1", "<", "ir_xmax", "&&", "y1", ">=", "ir_ymin", "&&", "y1", "<", "ir_ymax", ")", "draw_pixel", "(", "x1", ",", "y1", ",", "col", ")", ";", "if", "(", "y1", "==", "y2", ")", "break", ";", "y1", "+=", "sy", ";", "cy", "-=", "dx", ";", "if", "(", "cy", "<", "0", ")", "{", "x1", "+=", "sx", ";", "cy", "+=", "dy", ";", "}", "}", "}", "}" ]
Line draw routine modified from a routine written by Andrew Caldwell
[ "Line", "draw", "routine", "modified", "from", "a", "routine", "written", "by", "Andrew", "Caldwell" ]
[]
[ { "param": "polybitmap", "type": "UINT8" }, { "param": "x1", "type": "int" }, { "param": "y1", "type": "int" }, { "param": "x2", "type": "int" }, { "param": "y2", "type": "int" }, { "param": "col", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "polybitmap", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x1", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y1", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x2", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y2", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "col", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
40759911a39202e1e2b6a91a216a08e18c36b374
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/powerpc/drc_ops.c
[ "Unlicense" ]
C
append_set_cr0
void
static void append_set_cr0(drc_core *drc) { emit_xor_r32_r32(DRCTOP, REG_EBX, REG_EBX); emit_xor_r32_r32(DRCTOP, REG_EAX, REG_EAX); emit_cmp_r32_imm(DRCTOP, REG_EDX, 0); /* _lahf(); _shr_r32_imm(REG_EAX, 14); _add_r32_imm(REG_EAX, &condition_table); _mov_r8_m8bd(REG_BL, REG_EAX, 0); */ emit_setcc_r8(DRCTOP, COND_Z, REG_AL); emit_setcc_r8(DRCTOP, COND_L, REG_AH); emit_setcc_r8(DRCTOP, COND_G, REG_BL); emit_shl_r8_imm(DRCTOP, REG_AL, 1); emit_shl_r8_imm(DRCTOP, REG_AH, 3); emit_shl_r8_imm(DRCTOP, REG_BL, 2); emit_or_r8_r8(DRCTOP, REG_BL, REG_AH); emit_or_r8_r8(DRCTOP, REG_BL, REG_AL); emit_bt_m32_imm(DRCTOP, MABS(&XER), 31); // set XER SO bit to carry emit_adc_r32_imm(DRCTOP, REG_EBX, 0); // effectively sets bit 0 to carry emit_mov_m8_r8(DRCTOP, MABS(&ppc.cr[0]), REG_BL); }
// expects the result value in EDX!!!
expects the result value in EDX
[ "expects", "the", "result", "value", "in", "EDX" ]
static void append_set_cr0(drc_core *drc) { emit_xor_r32_r32(DRCTOP, REG_EBX, REG_EBX); emit_xor_r32_r32(DRCTOP, REG_EAX, REG_EAX); emit_cmp_r32_imm(DRCTOP, REG_EDX, 0); emit_setcc_r8(DRCTOP, COND_Z, REG_AL); emit_setcc_r8(DRCTOP, COND_L, REG_AH); emit_setcc_r8(DRCTOP, COND_G, REG_BL); emit_shl_r8_imm(DRCTOP, REG_AL, 1); emit_shl_r8_imm(DRCTOP, REG_AH, 3); emit_shl_r8_imm(DRCTOP, REG_BL, 2); emit_or_r8_r8(DRCTOP, REG_BL, REG_AH); emit_or_r8_r8(DRCTOP, REG_BL, REG_AL); emit_bt_m32_imm(DRCTOP, MABS(&XER), 31); emit_adc_r32_imm(DRCTOP, REG_EBX, 0); emit_mov_m8_r8(DRCTOP, MABS(&ppc.cr[0]), REG_BL); }
[ "static", "void", "append_set_cr0", "(", "drc_core", "*", "drc", ")", "{", "emit_xor_r32_r32", "(", "DRCTOP", ",", "REG_EBX", ",", "REG_EBX", ")", ";", "emit_xor_r32_r32", "(", "DRCTOP", ",", "REG_EAX", ",", "REG_EAX", ")", ";", "emit_cmp_r32_imm", "(", "DRCTOP", ",", "REG_EDX", ",", "0", ")", ";", "emit_setcc_r8", "(", "DRCTOP", ",", "COND_Z", ",", "REG_AL", ")", ";", "emit_setcc_r8", "(", "DRCTOP", ",", "COND_L", ",", "REG_AH", ")", ";", "emit_setcc_r8", "(", "DRCTOP", ",", "COND_G", ",", "REG_BL", ")", ";", "emit_shl_r8_imm", "(", "DRCTOP", ",", "REG_AL", ",", "1", ")", ";", "emit_shl_r8_imm", "(", "DRCTOP", ",", "REG_AH", ",", "3", ")", ";", "emit_shl_r8_imm", "(", "DRCTOP", ",", "REG_BL", ",", "2", ")", ";", "emit_or_r8_r8", "(", "DRCTOP", ",", "REG_BL", ",", "REG_AH", ")", ";", "emit_or_r8_r8", "(", "DRCTOP", ",", "REG_BL", ",", "REG_AL", ")", ";", "emit_bt_m32_imm", "(", "DRCTOP", ",", "MABS", "(", "&", "XER", ")", ",", "31", ")", ";", "emit_adc_r32_imm", "(", "DRCTOP", ",", "REG_EBX", ",", "0", ")", ";", "emit_mov_m8_r8", "(", "DRCTOP", ",", "MABS", "(", "&", "ppc", ".", "cr", "[", "0", "]", ")", ",", "REG_BL", ")", ";", "}" ]
expects the result value in EDX!!
[ "expects", "the", "result", "value", "in", "EDX!!" ]
[ "/*\n _lahf();\n\n _shr_r32_imm(REG_EAX, 14);\n\n _add_r32_imm(REG_EAX, &condition_table);\n _mov_r8_m8bd(REG_BL, REG_EAX, 0);\n*/", "// set XER SO bit to carry", "// effectively sets bit 0 to carry" ]
[ { "param": "drc", "type": "drc_core" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "drc", "type": "drc_core", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7d77502090100dcce1a589cf4766b9dbcbe16deb
lofunz/mieme
Reloaded/trunk/src/mame/drivers/littlerb.c
[ "Unlicense" ]
C
littlerb_recalc_regs
void
static void littlerb_recalc_regs(void) { littlerb_vdp_address_low = littlerb_write_address&0xffff; littlerb_vdp_address_high = (littlerb_write_address>>16)&0xffff; }
/* end VDP device to give us our own memory map */
end VDP device to give us our own memory map
[ "end", "VDP", "device", "to", "give", "us", "our", "own", "memory", "map" ]
static void littlerb_recalc_regs(void) { littlerb_vdp_address_low = littlerb_write_address&0xffff; littlerb_vdp_address_high = (littlerb_write_address>>16)&0xffff; }
[ "static", "void", "littlerb_recalc_regs", "(", "void", ")", "{", "littlerb_vdp_address_low", "=", "littlerb_write_address", "&", "0xffff", ";", "littlerb_vdp_address_high", "=", "(", "littlerb_write_address", ">>", "16", ")", "&", "0xffff", ";", "}" ]
end VDP device to give us our own memory map
[ "end", "VDP", "device", "to", "give", "us", "our", "own", "memory", "map" ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
750e710aceb547cee62fe144cb81f7ca4317c3f0
lofunz/mieme
Reloaded/tags/MAME4iOS 1.3.1Reloaded/src/osd/droid-ios/wiimote.c
[ "Unlicense" ]
C
wiimote_get_by_source_cid
null
struct wiimote_t* wiimote_get_by_source_cid(uint16_t source_cid){ int i = 0; for (; i < myosd_num_of_joys; ++i) { if(WIIMOTE_DBG)printf("0x%02x 0x%02x\n",joys[i].i_source_cid,source_cid); if (joys[i].i_source_cid == source_cid) return &joys[i]; } return NULL; }
/** * @brief Find a wiimote_t structure by its source_cid. * * @param wm Pointer to a wiimote_t structure. * @param wiimotes The number of wiimote_t structures in \a wm. * @param unid The unique identifier to search for. * * @return Pointer to a wiimote_t structure, or NULL if not found. */
@brief Find a wiimote_t structure by its source_cid. @param wm Pointer to a wiimote_t structure. @param wiimotes The number of wiimote_t structures in \a wm. @param unid The unique identifier to search for. @return Pointer to a wiimote_t structure, or NULL if not found.
[ "@brief", "Find", "a", "wiimote_t", "structure", "by", "its", "source_cid", ".", "@param", "wm", "Pointer", "to", "a", "wiimote_t", "structure", ".", "@param", "wiimotes", "The", "number", "of", "wiimote_t", "structures", "in", "\\", "a", "wm", ".", "@param", "unid", "The", "unique", "identifier", "to", "search", "for", ".", "@return", "Pointer", "to", "a", "wiimote_t", "structure", "or", "NULL", "if", "not", "found", "." ]
struct wiimote_t* wiimote_get_by_source_cid(uint16_t source_cid){ int i = 0; for (; i < myosd_num_of_joys; ++i) { if(WIIMOTE_DBG)printf("0x%02x 0x%02x\n",joys[i].i_source_cid,source_cid); if (joys[i].i_source_cid == source_cid) return &joys[i]; } return NULL; }
[ "struct", "wiimote_t", "*", "wiimote_get_by_source_cid", "(", "uint16_t", "source_cid", ")", "{", "int", "i", "=", "0", ";", "for", "(", ";", "i", "<", "myosd_num_of_joys", ";", "++", "i", ")", "{", "if", "(", "WIIMOTE_DBG", ")", "printf", "(", "\"", "\\n", "\"", ",", "joys", "[", "i", "]", ".", "i_source_cid", ",", "source_cid", ")", ";", "if", "(", "joys", "[", "i", "]", ".", "i_source_cid", "==", "source_cid", ")", "return", "&", "joys", "[", "i", "]", ";", "}", "return", "NULL", ";", "}" ]
@brief Find a wiimote_t structure by its source_cid.
[ "@brief", "Find", "a", "wiimote_t", "structure", "by", "its", "source_cid", "." ]
[]
[ { "param": "source_cid", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "source_cid", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
750e710aceb547cee62fe144cb81f7ca4317c3f0
lofunz/mieme
Reloaded/tags/MAME4iOS 1.3.1Reloaded/src/osd/droid-ios/wiimote.c
[ "Unlicense" ]
C
classic_ctrl_handshake
int
int classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, byte* data, unsigned short len) { int i; int offset = 0; cc->btns = 0; cc->r_shoulder = 0; cc->l_shoulder = 0; /* decrypt data */ /* for (i = 0; i < len; ++i) data[i] = (data[i] ^ 0x17) + 0x17; */ if(WIIMOTE_DBG) { int x = 0; printf("[DECRIPTED]"); for (; x < len; x++) printf("%.2x ", data[x]); printf("\n"); } /* if (data[offset] == 0xFF) { return 0;//ERROR! } */ /* joystick stuff */ if (data[offset] != 0xFF && data[offset] != 0x00) { cc->ljs.max.x = data[0 + offset] / 4; cc->ljs.min.x = data[1 + offset] / 4; cc->ljs.center.x = data[2 + offset] / 4; cc->ljs.max.y = data[3 + offset] / 4; cc->ljs.min.y = data[4 + offset] / 4; cc->ljs.center.y = data[5 + offset] / 4; cc->rjs.max.x = data[6 + offset] / 8; cc->rjs.min.x = data[7 + offset] / 8; cc->rjs.center.x = data[8 + offset] / 8; cc->rjs.max.y = data[9 + offset] / 8; cc->rjs.min.y = data[10 + offset] / 8; cc->rjs.center.y = data[11 + offset] / 8; } else { cc->ljs.max.x = 55; cc->ljs.min.x = 5; cc->ljs.center.x = 30; cc->ljs.max.y = 55; cc->ljs.min.y = 5; cc->ljs.center.y = 30; cc->rjs.max.x = 30; cc->rjs.min.x = 0; cc->rjs.center.x = 15; cc->rjs.max.y = 30; cc->rjs.min.y = 0; cc->rjs.center.y = 15; } /* handshake done */ wm->exp.type = EXP_CLASSIC; return 1; }
/** * @brief Handle the handshake data from the classic controller. * * @param cc A pointer to a classic_ctrl_t structure. * @param data The data read in from the device. * @param len The length of the data block, in bytes. * * @return Returns 1 if handshake was successful, 0 if not. */
@brief Handle the handshake data from the classic controller. @param cc A pointer to a classic_ctrl_t structure. @param data The data read in from the device. @param len The length of the data block, in bytes. @return Returns 1 if handshake was successful, 0 if not.
[ "@brief", "Handle", "the", "handshake", "data", "from", "the", "classic", "controller", ".", "@param", "cc", "A", "pointer", "to", "a", "classic_ctrl_t", "structure", ".", "@param", "data", "The", "data", "read", "in", "from", "the", "device", ".", "@param", "len", "The", "length", "of", "the", "data", "block", "in", "bytes", ".", "@return", "Returns", "1", "if", "handshake", "was", "successful", "0", "if", "not", "." ]
int classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, byte* data, unsigned short len) { int i; int offset = 0; cc->btns = 0; cc->r_shoulder = 0; cc->l_shoulder = 0; if(WIIMOTE_DBG) { int x = 0; printf("[DECRIPTED]"); for (; x < len; x++) printf("%.2x ", data[x]); printf("\n"); } if (data[offset] != 0xFF && data[offset] != 0x00) { cc->ljs.max.x = data[0 + offset] / 4; cc->ljs.min.x = data[1 + offset] / 4; cc->ljs.center.x = data[2 + offset] / 4; cc->ljs.max.y = data[3 + offset] / 4; cc->ljs.min.y = data[4 + offset] / 4; cc->ljs.center.y = data[5 + offset] / 4; cc->rjs.max.x = data[6 + offset] / 8; cc->rjs.min.x = data[7 + offset] / 8; cc->rjs.center.x = data[8 + offset] / 8; cc->rjs.max.y = data[9 + offset] / 8; cc->rjs.min.y = data[10 + offset] / 8; cc->rjs.center.y = data[11 + offset] / 8; } else { cc->ljs.max.x = 55; cc->ljs.min.x = 5; cc->ljs.center.x = 30; cc->ljs.max.y = 55; cc->ljs.min.y = 5; cc->ljs.center.y = 30; cc->rjs.max.x = 30; cc->rjs.min.x = 0; cc->rjs.center.x = 15; cc->rjs.max.y = 30; cc->rjs.min.y = 0; cc->rjs.center.y = 15; } wm->exp.type = EXP_CLASSIC; return 1; }
[ "int", "classic_ctrl_handshake", "(", "struct", "wiimote_t", "*", "wm", ",", "struct", "classic_ctrl_t", "*", "cc", ",", "byte", "*", "data", ",", "unsigned", "short", "len", ")", "{", "int", "i", ";", "int", "offset", "=", "0", ";", "cc", "->", "btns", "=", "0", ";", "cc", "->", "r_shoulder", "=", "0", ";", "cc", "->", "l_shoulder", "=", "0", ";", "if", "(", "WIIMOTE_DBG", ")", "{", "int", "x", "=", "0", ";", "printf", "(", "\"", "\"", ")", ";", "for", "(", ";", "x", "<", "len", ";", "x", "++", ")", "printf", "(", "\"", "\"", ",", "data", "[", "x", "]", ")", ";", "printf", "(", "\"", "\\n", "\"", ")", ";", "}", "if", "(", "data", "[", "offset", "]", "!=", "0xFF", "&&", "data", "[", "offset", "]", "!=", "0x00", ")", "{", "cc", "->", "ljs", ".", "max", ".", "x", "=", "data", "[", "0", "+", "offset", "]", "/", "4", ";", "cc", "->", "ljs", ".", "min", ".", "x", "=", "data", "[", "1", "+", "offset", "]", "/", "4", ";", "cc", "->", "ljs", ".", "center", ".", "x", "=", "data", "[", "2", "+", "offset", "]", "/", "4", ";", "cc", "->", "ljs", ".", "max", ".", "y", "=", "data", "[", "3", "+", "offset", "]", "/", "4", ";", "cc", "->", "ljs", ".", "min", ".", "y", "=", "data", "[", "4", "+", "offset", "]", "/", "4", ";", "cc", "->", "ljs", ".", "center", ".", "y", "=", "data", "[", "5", "+", "offset", "]", "/", "4", ";", "cc", "->", "rjs", ".", "max", ".", "x", "=", "data", "[", "6", "+", "offset", "]", "/", "8", ";", "cc", "->", "rjs", ".", "min", ".", "x", "=", "data", "[", "7", "+", "offset", "]", "/", "8", ";", "cc", "->", "rjs", ".", "center", ".", "x", "=", "data", "[", "8", "+", "offset", "]", "/", "8", ";", "cc", "->", "rjs", ".", "max", ".", "y", "=", "data", "[", "9", "+", "offset", "]", "/", "8", ";", "cc", "->", "rjs", ".", "min", ".", "y", "=", "data", "[", "10", "+", "offset", "]", "/", "8", ";", "cc", "->", "rjs", ".", "center", ".", "y", "=", "data", "[", "11", "+", "offset", "]", "/", "8", ";", "}", "else", "{", "cc", "->", "ljs", ".", "max", ".", "x", "=", "55", ";", "cc", "->", "ljs", ".", "min", ".", "x", "=", "5", ";", "cc", "->", "ljs", ".", "center", ".", "x", "=", "30", ";", "cc", "->", "ljs", ".", "max", ".", "y", "=", "55", ";", "cc", "->", "ljs", ".", "min", ".", "y", "=", "5", ";", "cc", "->", "ljs", ".", "center", ".", "y", "=", "30", ";", "cc", "->", "rjs", ".", "max", ".", "x", "=", "30", ";", "cc", "->", "rjs", ".", "min", ".", "x", "=", "0", ";", "cc", "->", "rjs", ".", "center", ".", "x", "=", "15", ";", "cc", "->", "rjs", ".", "max", ".", "y", "=", "30", ";", "cc", "->", "rjs", ".", "min", ".", "y", "=", "0", ";", "cc", "->", "rjs", ".", "center", ".", "y", "=", "15", ";", "}", "wm", "->", "exp", ".", "type", "=", "EXP_CLASSIC", ";", "return", "1", ";", "}" ]
@brief Handle the handshake data from the classic controller.
[ "@brief", "Handle", "the", "handshake", "data", "from", "the", "classic", "controller", "." ]
[ "/* decrypt data */", "/*\n\tfor (i = 0; i < len; ++i)\n\t\tdata[i] = (data[i] ^ 0x17) + 0x17;\n\t*/", "/*\n\tif (data[offset] == 0xFF)\n\t{\n\t\treturn 0;//ERROR!\n\t}\n*/", "/* joystick stuff */", "/* handshake done */" ]
[ { "param": "wm", "type": "struct wiimote_t" }, { "param": "cc", "type": "struct classic_ctrl_t" }, { "param": "data", "type": "byte" }, { "param": "len", "type": "unsigned short" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "wm", "type": "struct wiimote_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cc", "type": "struct classic_ctrl_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "len", "type": "unsigned short", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
750e710aceb547cee62fe144cb81f7ca4317c3f0
lofunz/mieme
Reloaded/tags/MAME4iOS 1.3.1Reloaded/src/osd/droid-ios/wiimote.c
[ "Unlicense" ]
C
classic_ctrl_event
void
void classic_ctrl_event(struct classic_ctrl_t* cc, byte* msg) { int i, lx, ly, rx, ry; byte l, r; /* decrypt data */ /* for (i = 0; i < 6; ++i) msg[i] = (msg[i] ^ 0x17) + 0x17; */ classic_ctrl_pressed_buttons(cc, BIG_ENDIAN_SHORT(*(short*)(msg + 4))); /* left/right buttons */ l = (((msg[2] & 0x60) >> 2) | ((msg[3] & 0xE0) >> 5)); r = (msg[3] & 0x1F); /* * TODO - LR range hardcoded from 0x00 to 0x1F. * This is probably in the calibration somewhere. */ cc->r_shoulder = ((float)r / 0x1F); cc->l_shoulder = ((float)l / 0x1F); /* calculate joystick orientation */ lx = (msg[0] & 0x3F); ly = (msg[1] & 0x3F); rx = ((msg[0] & 0xC0) >> 3) | ((msg[1] & 0xC0) >> 5) | ((msg[2] & 0x80) >> 7); ry = (msg[2] & 0x1F); if(WIIMOTE_DBG) printf("lx ly rx ry %d %d %d %d\n",lx,ly,rx,ry); calc_joystick_state(&cc->ljs, lx, ly); calc_joystick_state(&cc->rjs, rx, ry); /* printf("classic L button pressed: %f\n", cc->l_shoulder); printf("classic R button pressed: %f\n", cc->r_shoulder); printf("classic left joystick angle: %f\n", cc->ljs.ang); printf("classic left joystick magnitude: %f\n", cc->ljs.mag); printf("classic right joystick angle: %f\n", cc->rjs.ang); printf("classic right joystick magnitude: %f\n", cc->rjs.mag); */ }
/** * @brief Handle classic controller event. * * @param cc A pointer to a classic_ctrl_t structure. * @param msg The message specified in the event packet. */
@brief Handle classic controller event. @param cc A pointer to a classic_ctrl_t structure. @param msg The message specified in the event packet.
[ "@brief", "Handle", "classic", "controller", "event", ".", "@param", "cc", "A", "pointer", "to", "a", "classic_ctrl_t", "structure", ".", "@param", "msg", "The", "message", "specified", "in", "the", "event", "packet", "." ]
void classic_ctrl_event(struct classic_ctrl_t* cc, byte* msg) { int i, lx, ly, rx, ry; byte l, r; classic_ctrl_pressed_buttons(cc, BIG_ENDIAN_SHORT(*(short*)(msg + 4))); l = (((msg[2] & 0x60) >> 2) | ((msg[3] & 0xE0) >> 5)); r = (msg[3] & 0x1F); cc->r_shoulder = ((float)r / 0x1F); cc->l_shoulder = ((float)l / 0x1F); lx = (msg[0] & 0x3F); ly = (msg[1] & 0x3F); rx = ((msg[0] & 0xC0) >> 3) | ((msg[1] & 0xC0) >> 5) | ((msg[2] & 0x80) >> 7); ry = (msg[2] & 0x1F); if(WIIMOTE_DBG) printf("lx ly rx ry %d %d %d %d\n",lx,ly,rx,ry); calc_joystick_state(&cc->ljs, lx, ly); calc_joystick_state(&cc->rjs, rx, ry); }
[ "void", "classic_ctrl_event", "(", "struct", "classic_ctrl_t", "*", "cc", ",", "byte", "*", "msg", ")", "{", "int", "i", ",", "lx", ",", "ly", ",", "rx", ",", "ry", ";", "byte", "l", ",", "r", ";", "classic_ctrl_pressed_buttons", "(", "cc", ",", "BIG_ENDIAN_SHORT", "(", "*", "(", "short", "*", ")", "(", "msg", "+", "4", ")", ")", ")", ";", "l", "=", "(", "(", "(", "msg", "[", "2", "]", "&", "0x60", ")", ">>", "2", ")", "|", "(", "(", "msg", "[", "3", "]", "&", "0xE0", ")", ">>", "5", ")", ")", ";", "r", "=", "(", "msg", "[", "3", "]", "&", "0x1F", ")", ";", "cc", "->", "r_shoulder", "=", "(", "(", "float", ")", "r", "/", "0x1F", ")", ";", "cc", "->", "l_shoulder", "=", "(", "(", "float", ")", "l", "/", "0x1F", ")", ";", "lx", "=", "(", "msg", "[", "0", "]", "&", "0x3F", ")", ";", "ly", "=", "(", "msg", "[", "1", "]", "&", "0x3F", ")", ";", "rx", "=", "(", "(", "msg", "[", "0", "]", "&", "0xC0", ")", ">>", "3", ")", "|", "(", "(", "msg", "[", "1", "]", "&", "0xC0", ")", ">>", "5", ")", "|", "(", "(", "msg", "[", "2", "]", "&", "0x80", ")", ">>", "7", ")", ";", "ry", "=", "(", "msg", "[", "2", "]", "&", "0x1F", ")", ";", "if", "(", "WIIMOTE_DBG", ")", "printf", "(", "\"", "\\n", "\"", ",", "lx", ",", "ly", ",", "rx", ",", "ry", ")", ";", "calc_joystick_state", "(", "&", "cc", "->", "ljs", ",", "lx", ",", "ly", ")", ";", "calc_joystick_state", "(", "&", "cc", "->", "rjs", ",", "rx", ",", "ry", ")", ";", "}" ]
@brief Handle classic controller event.
[ "@brief", "Handle", "classic", "controller", "event", "." ]
[ "/* decrypt data */", "/*\n\tfor (i = 0; i < 6; ++i)\n\t\tmsg[i] = (msg[i] ^ 0x17) + 0x17;\n */", "/* left/right buttons */", "/*\n\t *\tTODO - LR range hardcoded from 0x00 to 0x1F.\n\t *\tThis is probably in the calibration somewhere.\n\t */", "/* calculate joystick orientation */", "/*\n\tprintf(\"classic L button pressed: %f\\n\", cc->l_shoulder);\n\tprintf(\"classic R button pressed: %f\\n\", cc->r_shoulder);\n\tprintf(\"classic left joystick angle: %f\\n\", cc->ljs.ang);\n\tprintf(\"classic left joystick magnitude: %f\\n\", cc->ljs.mag);\n\tprintf(\"classic right joystick angle: %f\\n\", cc->rjs.ang);\n\tprintf(\"classic right joystick magnitude: %f\\n\", cc->rjs.mag);\n\t*/" ]
[ { "param": "cc", "type": "struct classic_ctrl_t" }, { "param": "msg", "type": "byte" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cc", "type": "struct classic_ctrl_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "msg", "type": "byte", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2cf080af7101ebdb5ee77d08b103dd573f690fdd
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/video/liberatr.c
[ "Unlicense" ]
C
liberatr_init_planet
void
static void liberatr_init_planet(running_machine *machine, planet *liberatr_planet, UINT8 *planet_rom) { UINT16 longitude; const UINT8 *latitude_scale = memory_region(machine, "user1"); const UINT8 *longitude_scale = memory_region(machine, "user2"); /* for each starting longitude */ for (longitude = 0; longitude < 0x100; longitude++) { UINT8 i, latitude, start_segment, segment_count; UINT8 *buffer; planet_frame frame; planet_frame_line *line = 0; UINT16 total_segment_count = 0; /* for each latitude */ for (latitude = 0; latitude < 0x80; latitude++) { UINT8 segment, longitude_scale_factor, latitude_scale_factor, color, x=0; UINT8 x_array[32], color_array[32], visible_array[32]; /* point to the structure which will hold the data for this line */ line = &frame.lines[latitude]; latitude_scale_factor = latitude_scale[latitude]; /* for this latitude, load the 32 segments into the arrays */ for (segment = 0; segment < 0x20; segment++) { UINT16 length, planet_data, address; /* read the planet picture ROM and get the latitude and longitude scaled from the scaling PROMS */ address = (latitude << 5) + segment; planet_data = (planet_rom[address] << 8) | planet_rom[address + 0x1000]; color = (planet_data >> 8) & 0x0f; length = ((planet_data << 1) & 0x1fe) + ((planet_data >> 15) & 0x01); /* scale the longitude limit (adding the starting longitude) */ address = longitude + ( length >> 1 ) + ( length & 1 ); /* shift with rounding */ visible_array[segment] = (( address & 0x100 ) ? 1 : 0); if (address & 0x80) { longitude_scale_factor = 0xff; } else { address = ((address & 0x7f) << 1) + (((length & 1) || visible_array[segment]) ? 0 : 1); longitude_scale_factor = longitude_scale[address]; } x_array[segment] = (((UINT16)latitude_scale_factor * (UINT16)longitude_scale_factor) + 0x80) >> 8; /* round it */ color_array[segment] = color; } /* determine which segment is the western horizon and leave 'segment' indexing it. */ for (segment = 0; segment < 0x1f; segment++) /* if not found, 'segment' = 0x1f */ if (visible_array[segment]) break; /* transfer from the temporary arrays to the structure */ line->max_x = (latitude_scale_factor * 0xc0) >> 8; if (line->max_x & 1) line->max_x += 1; /* make it even */ /* as part of the quest to reduce memory usage (and to a lesser degree execution time), stitch together segments that have the same color */ segment_count = 0; i = 0; start_segment = segment; do { color = color_array[segment]; while (color == color_array[segment]) { x = x_array[segment]; segment = (segment+1) & 0x1f; if (segment == start_segment) break; } line->color_array[i] = color; line->x_array[i] = (x > line->max_x) ? line->max_x : x; i++; segment_count++; } while ((i < 32) && (x <= line->max_x)); total_segment_count += segment_count; line->segment_count = segment_count; } /* now that the all the lines have been processed, and we know how many segments it will take to store the description, allocate the space for it and copy the data to it. */ buffer = auto_alloc_array(machine, UINT8, 2*(128 + total_segment_count)); liberatr_planet->frames[longitude] = buffer; for (latitude = 0; latitude < 0x80; latitude++) { UINT8 last_x; line = &frame.lines[latitude]; segment_count = line->segment_count; *buffer++ = segment_count; last_x = 0; /* calculate the bitmap's x coordinate for the western horizon center of bitmap - (the number of planet pixels) / 4 */ *buffer++ = (video_screen_get_width(machine->primary_screen) / 2) - ((line->max_x + 2) / 4); for (i = 0; i < segment_count; i++) { UINT8 current_x = (line->x_array[i] + 1) / 2; *buffer++ = line->color_array[i]; *buffer++ = current_x - last_x; last_x = current_x; } } } }
/******************************************************************************************** liberatr_init_planet() The data for the planet is stored in ROM using a run-length type of encoding. This function does the conversion to the above structures and then a smaller structure which is quicker to use in real time. Its a multi-step process, reflecting the history of the code. Not quite as efficient as it might be, but this is not realtime stuff, so who cares... ********************************************************************************************/
liberatr_init_planet() The data for the planet is stored in ROM using a run-length type of encoding. This function does the conversion to the above structures and then a smaller structure which is quicker to use in real time. Its a multi-step process, reflecting the history of the code. Not quite as efficient as it might be, but this is not realtime stuff, so who cares
[ "liberatr_init_planet", "()", "The", "data", "for", "the", "planet", "is", "stored", "in", "ROM", "using", "a", "run", "-", "length", "type", "of", "encoding", ".", "This", "function", "does", "the", "conversion", "to", "the", "above", "structures", "and", "then", "a", "smaller", "structure", "which", "is", "quicker", "to", "use", "in", "real", "time", ".", "Its", "a", "multi", "-", "step", "process", "reflecting", "the", "history", "of", "the", "code", ".", "Not", "quite", "as", "efficient", "as", "it", "might", "be", "but", "this", "is", "not", "realtime", "stuff", "so", "who", "cares" ]
static void liberatr_init_planet(running_machine *machine, planet *liberatr_planet, UINT8 *planet_rom) { UINT16 longitude; const UINT8 *latitude_scale = memory_region(machine, "user1"); const UINT8 *longitude_scale = memory_region(machine, "user2"); for (longitude = 0; longitude < 0x100; longitude++) { UINT8 i, latitude, start_segment, segment_count; UINT8 *buffer; planet_frame frame; planet_frame_line *line = 0; UINT16 total_segment_count = 0; for (latitude = 0; latitude < 0x80; latitude++) { UINT8 segment, longitude_scale_factor, latitude_scale_factor, color, x=0; UINT8 x_array[32], color_array[32], visible_array[32]; line = &frame.lines[latitude]; latitude_scale_factor = latitude_scale[latitude]; for (segment = 0; segment < 0x20; segment++) { UINT16 length, planet_data, address; address = (latitude << 5) + segment; planet_data = (planet_rom[address] << 8) | planet_rom[address + 0x1000]; color = (planet_data >> 8) & 0x0f; length = ((planet_data << 1) & 0x1fe) + ((planet_data >> 15) & 0x01); address = longitude + ( length >> 1 ) + ( length & 1 ); visible_array[segment] = (( address & 0x100 ) ? 1 : 0); if (address & 0x80) { longitude_scale_factor = 0xff; } else { address = ((address & 0x7f) << 1) + (((length & 1) || visible_array[segment]) ? 0 : 1); longitude_scale_factor = longitude_scale[address]; } x_array[segment] = (((UINT16)latitude_scale_factor * (UINT16)longitude_scale_factor) + 0x80) >> 8; color_array[segment] = color; } for (segment = 0; segment < 0x1f; segment++) if (visible_array[segment]) break; line->max_x = (latitude_scale_factor * 0xc0) >> 8; if (line->max_x & 1) line->max_x += 1; segment_count = 0; i = 0; start_segment = segment; do { color = color_array[segment]; while (color == color_array[segment]) { x = x_array[segment]; segment = (segment+1) & 0x1f; if (segment == start_segment) break; } line->color_array[i] = color; line->x_array[i] = (x > line->max_x) ? line->max_x : x; i++; segment_count++; } while ((i < 32) && (x <= line->max_x)); total_segment_count += segment_count; line->segment_count = segment_count; } buffer = auto_alloc_array(machine, UINT8, 2*(128 + total_segment_count)); liberatr_planet->frames[longitude] = buffer; for (latitude = 0; latitude < 0x80; latitude++) { UINT8 last_x; line = &frame.lines[latitude]; segment_count = line->segment_count; *buffer++ = segment_count; last_x = 0; *buffer++ = (video_screen_get_width(machine->primary_screen) / 2) - ((line->max_x + 2) / 4); for (i = 0; i < segment_count; i++) { UINT8 current_x = (line->x_array[i] + 1) / 2; *buffer++ = line->color_array[i]; *buffer++ = current_x - last_x; last_x = current_x; } } } }
[ "static", "void", "liberatr_init_planet", "(", "running_machine", "*", "machine", ",", "planet", "*", "liberatr_planet", ",", "UINT8", "*", "planet_rom", ")", "{", "UINT16", "longitude", ";", "const", "UINT8", "*", "latitude_scale", "=", "memory_region", "(", "machine", ",", "\"", "\"", ")", ";", "const", "UINT8", "*", "longitude_scale", "=", "memory_region", "(", "machine", ",", "\"", "\"", ")", ";", "for", "(", "longitude", "=", "0", ";", "longitude", "<", "0x100", ";", "longitude", "++", ")", "{", "UINT8", "i", ",", "latitude", ",", "start_segment", ",", "segment_count", ";", "UINT8", "*", "buffer", ";", "planet_frame", "frame", ";", "planet_frame_line", "*", "line", "=", "0", ";", "UINT16", "total_segment_count", "=", "0", ";", "for", "(", "latitude", "=", "0", ";", "latitude", "<", "0x80", ";", "latitude", "++", ")", "{", "UINT8", "segment", ",", "longitude_scale_factor", ",", "latitude_scale_factor", ",", "color", ",", "x", "=", "0", ";", "UINT8", "x_array", "[", "32", "]", ",", "color_array", "[", "32", "]", ",", "visible_array", "[", "32", "]", ";", "line", "=", "&", "frame", ".", "lines", "[", "latitude", "]", ";", "latitude_scale_factor", "=", "latitude_scale", "[", "latitude", "]", ";", "for", "(", "segment", "=", "0", ";", "segment", "<", "0x20", ";", "segment", "++", ")", "{", "UINT16", "length", ",", "planet_data", ",", "address", ";", "address", "=", "(", "latitude", "<<", "5", ")", "+", "segment", ";", "planet_data", "=", "(", "planet_rom", "[", "address", "]", "<<", "8", ")", "|", "planet_rom", "[", "address", "+", "0x1000", "]", ";", "color", "=", "(", "planet_data", ">>", "8", ")", "&", "0x0f", ";", "length", "=", "(", "(", "planet_data", "<<", "1", ")", "&", "0x1fe", ")", "+", "(", "(", "planet_data", ">>", "15", ")", "&", "0x01", ")", ";", "address", "=", "longitude", "+", "(", "length", ">>", "1", ")", "+", "(", "length", "&", "1", ")", ";", "visible_array", "[", "segment", "]", "=", "(", "(", "address", "&", "0x100", ")", "?", "1", ":", "0", ")", ";", "if", "(", "address", "&", "0x80", ")", "{", "longitude_scale_factor", "=", "0xff", ";", "}", "else", "{", "address", "=", "(", "(", "address", "&", "0x7f", ")", "<<", "1", ")", "+", "(", "(", "(", "length", "&", "1", ")", "||", "visible_array", "[", "segment", "]", ")", "?", "0", ":", "1", ")", ";", "longitude_scale_factor", "=", "longitude_scale", "[", "address", "]", ";", "}", "x_array", "[", "segment", "]", "=", "(", "(", "(", "UINT16", ")", "latitude_scale_factor", "*", "(", "UINT16", ")", "longitude_scale_factor", ")", "+", "0x80", ")", ">>", "8", ";", "color_array", "[", "segment", "]", "=", "color", ";", "}", "for", "(", "segment", "=", "0", ";", "segment", "<", "0x1f", ";", "segment", "++", ")", "if", "(", "visible_array", "[", "segment", "]", ")", "break", ";", "line", "->", "max_x", "=", "(", "latitude_scale_factor", "*", "0xc0", ")", ">>", "8", ";", "if", "(", "line", "->", "max_x", "&", "1", ")", "line", "->", "max_x", "+=", "1", ";", "segment_count", "=", "0", ";", "i", "=", "0", ";", "start_segment", "=", "segment", ";", "do", "{", "color", "=", "color_array", "[", "segment", "]", ";", "while", "(", "color", "==", "color_array", "[", "segment", "]", ")", "{", "x", "=", "x_array", "[", "segment", "]", ";", "segment", "=", "(", "segment", "+", "1", ")", "&", "0x1f", ";", "if", "(", "segment", "==", "start_segment", ")", "break", ";", "}", "line", "->", "color_array", "[", "i", "]", "=", "color", ";", "line", "->", "x_array", "[", "i", "]", "=", "(", "x", ">", "line", "->", "max_x", ")", "?", "line", "->", "max_x", ":", "x", ";", "i", "++", ";", "segment_count", "++", ";", "}", "while", "(", "(", "i", "<", "32", ")", "&&", "(", "x", "<=", "line", "->", "max_x", ")", ")", ";", "total_segment_count", "+=", "segment_count", ";", "line", "->", "segment_count", "=", "segment_count", ";", "}", "buffer", "=", "auto_alloc_array", "(", "machine", ",", "UINT8", ",", "2", "*", "(", "128", "+", "total_segment_count", ")", ")", ";", "liberatr_planet", "->", "frames", "[", "longitude", "]", "=", "buffer", ";", "for", "(", "latitude", "=", "0", ";", "latitude", "<", "0x80", ";", "latitude", "++", ")", "{", "UINT8", "last_x", ";", "line", "=", "&", "frame", ".", "lines", "[", "latitude", "]", ";", "segment_count", "=", "line", "->", "segment_count", ";", "*", "buffer", "++", "=", "segment_count", ";", "last_x", "=", "0", ";", "*", "buffer", "++", "=", "(", "video_screen_get_width", "(", "machine", "->", "primary_screen", ")", "/", "2", ")", "-", "(", "(", "line", "->", "max_x", "+", "2", ")", "/", "4", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "segment_count", ";", "i", "++", ")", "{", "UINT8", "current_x", "=", "(", "line", "->", "x_array", "[", "i", "]", "+", "1", ")", "/", "2", ";", "*", "buffer", "++", "=", "line", "->", "color_array", "[", "i", "]", ";", "*", "buffer", "++", "=", "current_x", "-", "last_x", ";", "last_x", "=", "current_x", ";", "}", "}", "}", "}" ]
liberatr_init_planet() The data for the planet is stored in ROM using a run-length type of encoding.
[ "liberatr_init_planet", "()", "The", "data", "for", "the", "planet", "is", "stored", "in", "ROM", "using", "a", "run", "-", "length", "type", "of", "encoding", "." ]
[ "/* for each starting longitude */", "/* for each latitude */", "/* point to the structure which will hold the data for this line */", "/* for this latitude, load the 32 segments into the arrays */", "/*\n read the planet picture ROM and get the\n latitude and longitude scaled from the scaling PROMS\n */", "/* scale the longitude limit (adding the starting longitude) */", "/* shift with rounding */", "/* round it */", "/*\n determine which segment is the western horizon and\n leave 'segment' indexing it.\n */", "/* if not found, 'segment' = 0x1f */", "/* transfer from the temporary arrays to the structure */", "/* make it even */", "/*\n as part of the quest to reduce memory usage (and to a lesser degree\n execution time), stitch together segments that have the same color\n */", "/* now that the all the lines have been processed, and we know how\n many segments it will take to store the description, allocate the\n space for it and copy the data to it.\n */", "/* calculate the bitmap's x coordinate for the western horizon\n center of bitmap - (the number of planet pixels) / 4 */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "liberatr_planet", "type": "planet" }, { "param": "planet_rom", "type": "UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "liberatr_planet", "type": "planet", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "planet_rom", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7d80e369b462594058cef4bdfdedb9a68ce994f2
lofunz/mieme
Reloaded/trunk/src/mame/drivers/taito_z.c
[ "Unlicense" ]
C
irqhandlerb
void
static void irqhandlerb(running_device *device, int irq) { // DG: this is probably specific to Z80 and wrong? // taitoz_state *state = device->machine->driver_data<taitoz_state>(); // cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE); }
/* handler called by the YM2610 emulator when the internal timers cause an IRQ */
handler called by the YM2610 emulator when the internal timers cause an IRQ
[ "handler", "called", "by", "the", "YM2610", "emulator", "when", "the", "internal", "timers", "cause", "an", "IRQ" ]
static void irqhandlerb(running_device *device, int irq) { }
[ "static", "void", "irqhandlerb", "(", "running_device", "*", "device", ",", "int", "irq", ")", "{", "}" ]
handler called by the YM2610 emulator when the internal timers cause an IRQ
[ "handler", "called", "by", "the", "YM2610", "emulator", "when", "the", "internal", "timers", "cause", "an", "IRQ" ]
[ "// DG: this is probably specific to Z80 and wrong?\r", "// taitoz_state *state = device->machine->driver_data<taitoz_state>();\r", "// cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE);\r" ]
[ { "param": "device", "type": "running_device" }, { "param": "irq", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "device", "type": "running_device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "irq", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }