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
194d723f1212a451f0e213d187d207ea44e12563
lofunz/mieme
Reloaded/trunk/src/mame/video/wwfwfest.c
[ "Unlicense" ]
C
draw_sprites
void
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) { /*- SPR RAM Format -** 16 bytes per sprite ---- ---- yyyy yyyy ---- ---- lllF fXYE ---- ---- nnnn nnnn ---- ---- NNNN NNNN ---- ---- ---- CCCC ---- ---- xxxx xxxx ---- ---- ---- ---- ---- ---- ---- ---- Yy = sprite Y Position Xx = sprite X Position C = colour bank f = flip Y F = flip X l = chain sprite E = sprite enable Nn = Sprite Number other bits unused **- End of Comments -*/ UINT16 *buffered_spriteram16 = machine->generic.buffered_spriteram.u16; const gfx_element *gfx = machine->gfx[1]; UINT16 *source = buffered_spriteram16; UINT16 *finish = source + 0x2000/2; while( source<finish ) { int xpos, ypos, colourbank, flipx, flipy, chain, enable, number, count; enable = (source[1] & 0x0001); if (enable) { xpos = +(source[5] & 0x00ff) | (source[1] & 0x0004) << 6; if (xpos>512-16) xpos -=512; xpos += sprite_xoff; ypos = (source[0] & 0x00ff) | (source[1] & 0x0002) << 7; ypos = (256 - ypos) & 0x1ff; ypos -= 16 ; flipx = (source[1] & 0x0010) >> 4; flipy = (source[1] & 0x0008) >> 3; chain = (source[1] & 0x00e0) >> 5; chain += 1; number = (source[2] & 0x00ff) | (source[3] & 0x00ff) << 8; colourbank = (source[4] & 0x000f); if (flip_screen_get(machine)) { if (flipy) flipy=0; else flipy=1; if (flipx) flipx=0; else flipx=1; ypos=240-ypos-sprite_xoff; xpos=304-xpos; } for (count=0;count<chain;count++) { if (flip_screen_get(machine)) { if (!flipy) { drawgfx_transpen(bitmap,cliprect,gfx,number+count,colourbank,flipx,flipy,xpos,ypos+(16*(chain-1))-(16*count),0); } else { drawgfx_transpen(bitmap,cliprect,gfx,number+count,colourbank,flipx,flipy,xpos,ypos+16*count,0); } } else { if (flipy) { drawgfx_transpen(bitmap,cliprect,gfx,number+count,colourbank,flipx,flipy,xpos,ypos-(16*(chain-1))+(16*count),0); } else { drawgfx_transpen(bitmap,cliprect,gfx,number+count,colourbank,flipx,flipy,xpos,ypos-16*count,0); } } } } source+=8; } }
/******************************************************************************* Sprite Related Functions ******************************************************************************** sprite drawing could probably be improved a bit *******************************************************************************/
Sprite Related Functions sprite drawing could probably be improved a bit
[ "Sprite", "Related", "Functions", "sprite", "drawing", "could", "probably", "be", "improved", "a", "bit" ]
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) { UINT16 *buffered_spriteram16 = machine->generic.buffered_spriteram.u16; const gfx_element *gfx = machine->gfx[1]; UINT16 *source = buffered_spriteram16; UINT16 *finish = source + 0x2000/2; while( source<finish ) { int xpos, ypos, colourbank, flipx, flipy, chain, enable, number, count; enable = (source[1] & 0x0001); if (enable) { xpos = +(source[5] & 0x00ff) | (source[1] & 0x0004) << 6; if (xpos>512-16) xpos -=512; xpos += sprite_xoff; ypos = (source[0] & 0x00ff) | (source[1] & 0x0002) << 7; ypos = (256 - ypos) & 0x1ff; ypos -= 16 ; flipx = (source[1] & 0x0010) >> 4; flipy = (source[1] & 0x0008) >> 3; chain = (source[1] & 0x00e0) >> 5; chain += 1; number = (source[2] & 0x00ff) | (source[3] & 0x00ff) << 8; colourbank = (source[4] & 0x000f); if (flip_screen_get(machine)) { if (flipy) flipy=0; else flipy=1; if (flipx) flipx=0; else flipx=1; ypos=240-ypos-sprite_xoff; xpos=304-xpos; } for (count=0;count<chain;count++) { if (flip_screen_get(machine)) { if (!flipy) { drawgfx_transpen(bitmap,cliprect,gfx,number+count,colourbank,flipx,flipy,xpos,ypos+(16*(chain-1))-(16*count),0); } else { drawgfx_transpen(bitmap,cliprect,gfx,number+count,colourbank,flipx,flipy,xpos,ypos+16*count,0); } } else { if (flipy) { drawgfx_transpen(bitmap,cliprect,gfx,number+count,colourbank,flipx,flipy,xpos,ypos-(16*(chain-1))+(16*count),0); } else { drawgfx_transpen(bitmap,cliprect,gfx,number+count,colourbank,flipx,flipy,xpos,ypos-16*count,0); } } } } source+=8; } }
[ "static", "void", "draw_sprites", "(", "running_machine", "*", "machine", ",", "bitmap_t", "*", "bitmap", ",", "const", "rectangle", "*", "cliprect", ")", "{", "UINT16", "*", "buffered_spriteram16", "=", "machine", "->", "generic", ".", "buffered_spriteram", ".", "u16", ";", "const", "gfx_element", "*", "gfx", "=", "machine", "->", "gfx", "[", "1", "]", ";", "UINT16", "*", "source", "=", "buffered_spriteram16", ";", "UINT16", "*", "finish", "=", "source", "+", "0x2000", "/", "2", ";", "while", "(", "source", "<", "finish", ")", "{", "int", "xpos", ",", "ypos", ",", "colourbank", ",", "flipx", ",", "flipy", ",", "chain", ",", "enable", ",", "number", ",", "count", ";", "enable", "=", "(", "source", "[", "1", "]", "&", "0x0001", ")", ";", "if", "(", "enable", ")", "{", "xpos", "=", "+", "(", "source", "[", "5", "]", "&", "0x00ff", ")", "|", "(", "source", "[", "1", "]", "&", "0x0004", ")", "<<", "6", ";", "if", "(", "xpos", ">", "512", "-", "16", ")", "xpos", "-=", "512", ";", "xpos", "+=", "sprite_xoff", ";", "ypos", "=", "(", "source", "[", "0", "]", "&", "0x00ff", ")", "|", "(", "source", "[", "1", "]", "&", "0x0002", ")", "<<", "7", ";", "ypos", "=", "(", "256", "-", "ypos", ")", "&", "0x1ff", ";", "ypos", "-=", "16", ";", "flipx", "=", "(", "source", "[", "1", "]", "&", "0x0010", ")", ">>", "4", ";", "flipy", "=", "(", "source", "[", "1", "]", "&", "0x0008", ")", ">>", "3", ";", "chain", "=", "(", "source", "[", "1", "]", "&", "0x00e0", ")", ">>", "5", ";", "chain", "+=", "1", ";", "number", "=", "(", "source", "[", "2", "]", "&", "0x00ff", ")", "|", "(", "source", "[", "3", "]", "&", "0x00ff", ")", "<<", "8", ";", "colourbank", "=", "(", "source", "[", "4", "]", "&", "0x000f", ")", ";", "if", "(", "flip_screen_get", "(", "machine", ")", ")", "{", "if", "(", "flipy", ")", "flipy", "=", "0", ";", "else", "flipy", "=", "1", ";", "if", "(", "flipx", ")", "flipx", "=", "0", ";", "else", "flipx", "=", "1", ";", "ypos", "=", "240", "-", "ypos", "-", "sprite_xoff", ";", "xpos", "=", "304", "-", "xpos", ";", "}", "for", "(", "count", "=", "0", ";", "count", "<", "chain", ";", "count", "++", ")", "{", "if", "(", "flip_screen_get", "(", "machine", ")", ")", "{", "if", "(", "!", "flipy", ")", "{", "drawgfx_transpen", "(", "bitmap", ",", "cliprect", ",", "gfx", ",", "number", "+", "count", ",", "colourbank", ",", "flipx", ",", "flipy", ",", "xpos", ",", "ypos", "+", "(", "16", "*", "(", "chain", "-", "1", ")", ")", "-", "(", "16", "*", "count", ")", ",", "0", ")", ";", "}", "else", "{", "drawgfx_transpen", "(", "bitmap", ",", "cliprect", ",", "gfx", ",", "number", "+", "count", ",", "colourbank", ",", "flipx", ",", "flipy", ",", "xpos", ",", "ypos", "+", "16", "*", "count", ",", "0", ")", ";", "}", "}", "else", "{", "if", "(", "flipy", ")", "{", "drawgfx_transpen", "(", "bitmap", ",", "cliprect", ",", "gfx", ",", "number", "+", "count", ",", "colourbank", ",", "flipx", ",", "flipy", ",", "xpos", ",", "ypos", "-", "(", "16", "*", "(", "chain", "-", "1", ")", ")", "+", "(", "16", "*", "count", ")", ",", "0", ")", ";", "}", "else", "{", "drawgfx_transpen", "(", "bitmap", ",", "cliprect", ",", "gfx", ",", "number", "+", "count", ",", "colourbank", ",", "flipx", ",", "flipy", ",", "xpos", ",", "ypos", "-", "16", "*", "count", ",", "0", ")", ";", "}", "}", "}", "}", "source", "+=", "8", ";", "}", "}" ]
Sprite Related Functions sprite drawing could probably be improved a bit
[ "Sprite", "Related", "Functions", "sprite", "drawing", "could", "probably", "be", "improved", "a", "bit" ]
[ "/*- SPR RAM Format -**\r\n\r\n 16 bytes per sprite\r\n\r\n ---- ---- yyyy yyyy ---- ---- lllF fXYE ---- ---- nnnn nnnn ---- ---- NNNN NNNN\r\n ---- ---- ---- CCCC ---- ---- xxxx xxxx ---- ---- ---- ---- ---- ---- ---- ----\r\n\r\n Yy = sprite Y Position\r\n Xx = sprite X Position\r\n C = colour bank\r\n f = flip Y\r\n F = flip X\r\n l = chain sprite\r\n E = sprite enable\r\n Nn = Sprite Number\r\n\r\n other bits unused\r\n\r\n **- End of Comments -*/" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "bitmap", "type": "bitmap_t" }, { "param": "cliprect", "type": "rectangle" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bitmap", "type": "bitmap_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cliprect", "type": "rectangle", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
drcuml_alloc
drcuml_state
drcuml_state *drcuml_alloc(running_device *device, drccache *cache, UINT32 flags, int modes, int addrbits, int ignorebits) { drcuml_state *drcuml; int opnum; /* allocate state */ drcuml = (drcuml_state *)drccache_memory_alloc(cache, sizeof(*drcuml)); if (drcuml == NULL) return NULL; memset(drcuml, 0, sizeof(*drcuml)); /* initialize the state */ drcuml->device = device; drcuml->cache = cache; drcuml->beintf = (flags & DRCUML_OPTION_USE_C) ? &drcbe_c_be_interface : &NATIVE_DRC; drcuml->symtailptr = &drcuml->symlist; /* if we're to log, create the logfile */ if (flags & DRCUML_OPTION_LOG_UML) drcuml->umllog = fopen("drcuml.asm", "w"); /* allocate the back-end */ drcuml->bestate = (*drcuml->beintf->be_alloc)(drcuml, cache, device, flags, modes, addrbits, ignorebits); if (drcuml->bestate == NULL) { drcuml_free(drcuml); return NULL; } /* update the valid opcode table */ for (opnum = 0; opnum < ARRAY_LENGTH(opcode_info_source); opnum++) opcode_info_table[opcode_info_source[opnum].opcode] = &opcode_info_source[opnum]; return drcuml; }
/*------------------------------------------------- drcuml_alloc - allocate state for the code generator and initialize the back-end -------------------------------------------------*/
allocate state for the code generator and initialize the back-end
[ "allocate", "state", "for", "the", "code", "generator", "and", "initialize", "the", "back", "-", "end" ]
drcuml_state *drcuml_alloc(running_device *device, drccache *cache, UINT32 flags, int modes, int addrbits, int ignorebits) { drcuml_state *drcuml; int opnum; drcuml = (drcuml_state *)drccache_memory_alloc(cache, sizeof(*drcuml)); if (drcuml == NULL) return NULL; memset(drcuml, 0, sizeof(*drcuml)); drcuml->device = device; drcuml->cache = cache; drcuml->beintf = (flags & DRCUML_OPTION_USE_C) ? &drcbe_c_be_interface : &NATIVE_DRC; drcuml->symtailptr = &drcuml->symlist; if (flags & DRCUML_OPTION_LOG_UML) drcuml->umllog = fopen("drcuml.asm", "w"); drcuml->bestate = (*drcuml->beintf->be_alloc)(drcuml, cache, device, flags, modes, addrbits, ignorebits); if (drcuml->bestate == NULL) { drcuml_free(drcuml); return NULL; } for (opnum = 0; opnum < ARRAY_LENGTH(opcode_info_source); opnum++) opcode_info_table[opcode_info_source[opnum].opcode] = &opcode_info_source[opnum]; return drcuml; }
[ "drcuml_state", "*", "drcuml_alloc", "(", "running_device", "*", "device", ",", "drccache", "*", "cache", ",", "UINT32", "flags", ",", "int", "modes", ",", "int", "addrbits", ",", "int", "ignorebits", ")", "{", "drcuml_state", "*", "drcuml", ";", "int", "opnum", ";", "drcuml", "=", "(", "drcuml_state", "*", ")", "drccache_memory_alloc", "(", "cache", ",", "sizeof", "(", "*", "drcuml", ")", ")", ";", "if", "(", "drcuml", "==", "NULL", ")", "return", "NULL", ";", "memset", "(", "drcuml", ",", "0", ",", "sizeof", "(", "*", "drcuml", ")", ")", ";", "drcuml", "->", "device", "=", "device", ";", "drcuml", "->", "cache", "=", "cache", ";", "drcuml", "->", "beintf", "=", "(", "flags", "&", "DRCUML_OPTION_USE_C", ")", "?", "&", "drcbe_c_be_interface", ":", "&", "NATIVE_DRC", ";", "drcuml", "->", "symtailptr", "=", "&", "drcuml", "->", "symlist", ";", "if", "(", "flags", "&", "DRCUML_OPTION_LOG_UML", ")", "drcuml", "->", "umllog", "=", "fopen", "(", "\"", "\"", ",", "\"", "\"", ")", ";", "drcuml", "->", "bestate", "=", "(", "*", "drcuml", "->", "beintf", "->", "be_alloc", ")", "(", "drcuml", ",", "cache", ",", "device", ",", "flags", ",", "modes", ",", "addrbits", ",", "ignorebits", ")", ";", "if", "(", "drcuml", "->", "bestate", "==", "NULL", ")", "{", "drcuml_free", "(", "drcuml", ")", ";", "return", "NULL", ";", "}", "for", "(", "opnum", "=", "0", ";", "opnum", "<", "ARRAY_LENGTH", "(", "opcode_info_source", ")", ";", "opnum", "++", ")", "opcode_info_table", "[", "opcode_info_source", "[", "opnum", "]", ".", "opcode", "]", "=", "&", "opcode_info_source", "[", "opnum", "]", ";", "return", "drcuml", ";", "}" ]
drcuml_alloc - allocate state for the code generator and initialize the back-end
[ "drcuml_alloc", "-", "allocate", "state", "for", "the", "code", "generator", "and", "initialize", "the", "back", "-", "end" ]
[ "/* allocate state */", "/* initialize the state */", "/* if we're to log, create the logfile */", "/* allocate the back-end */", "/* update the valid opcode table */" ]
[ { "param": "device", "type": "running_device" }, { "param": "cache", "type": "drccache" }, { "param": "flags", "type": "UINT32" }, { "param": "modes", "type": "int" }, { "param": "addrbits", "type": "int" }, { "param": "ignorebits", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "device", "type": "running_device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cache", "type": "drccache", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "flags", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "modes", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "addrbits", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ignorebits", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
drcuml_reset
void
void drcuml_reset(drcuml_state *drcuml) { drcuml_codehandle *handle; jmp_buf errorbuf; /* flush the cache */ drccache_flush(drcuml->cache); /* if we error here, we are screwed */ if (setjmp(errorbuf) != 0) fatalerror("Out of cache space in drcuml_reset"); /* reset all handle code pointers */ for (handle = drcuml->handlelist; handle != NULL; handle = handle->next) handle->code = NULL; /* call the backend to reset */ (*drcuml->beintf->be_reset)(drcuml->bestate); /* do a one-time validation if requested */ if (VALIDATE_BACKEND) { static int validated = FALSE; if (!validated) { validated = TRUE; validate_backend(drcuml); } } }
/*------------------------------------------------- drcuml_reset - reset the state completely, flushing the cache and all information -------------------------------------------------*/
reset the state completely, flushing the cache and all information
[ "reset", "the", "state", "completely", "flushing", "the", "cache", "and", "all", "information" ]
void drcuml_reset(drcuml_state *drcuml) { drcuml_codehandle *handle; jmp_buf errorbuf; drccache_flush(drcuml->cache); if (setjmp(errorbuf) != 0) fatalerror("Out of cache space in drcuml_reset"); for (handle = drcuml->handlelist; handle != NULL; handle = handle->next) handle->code = NULL; (*drcuml->beintf->be_reset)(drcuml->bestate); if (VALIDATE_BACKEND) { static int validated = FALSE; if (!validated) { validated = TRUE; validate_backend(drcuml); } } }
[ "void", "drcuml_reset", "(", "drcuml_state", "*", "drcuml", ")", "{", "drcuml_codehandle", "*", "handle", ";", "jmp_buf", "errorbuf", ";", "drccache_flush", "(", "drcuml", "->", "cache", ")", ";", "if", "(", "setjmp", "(", "errorbuf", ")", "!=", "0", ")", "fatalerror", "(", "\"", "\"", ")", ";", "for", "(", "handle", "=", "drcuml", "->", "handlelist", ";", "handle", "!=", "NULL", ";", "handle", "=", "handle", "->", "next", ")", "handle", "->", "code", "=", "NULL", ";", "(", "*", "drcuml", "->", "beintf", "->", "be_reset", ")", "(", "drcuml", "->", "bestate", ")", ";", "if", "(", "VALIDATE_BACKEND", ")", "{", "static", "int", "validated", "=", "FALSE", ";", "if", "(", "!", "validated", ")", "{", "validated", "=", "TRUE", ";", "validate_backend", "(", "drcuml", ")", ";", "}", "}", "}" ]
drcuml_reset - reset the state completely, flushing the cache and all information
[ "drcuml_reset", "-", "reset", "the", "state", "completely", "flushing", "the", "cache", "and", "all", "information" ]
[ "/* flush the cache */", "/* if we error here, we are screwed */", "/* reset all handle code pointers */", "/* call the backend to reset */", "/* do a one-time validation if requested */" ]
[ { "param": "drcuml", "type": "drcuml_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "drcuml", "type": "drcuml_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
drcuml_free
void
void drcuml_free(drcuml_state *drcuml) { /* free the back-end */ if (drcuml->bestate != NULL) (*drcuml->beintf->be_free)(drcuml->bestate); /* free all the blocks */ while (drcuml->blocklist != NULL) { drcuml_block *block = drcuml->blocklist; /* remove the item from the list */ drcuml->blocklist = block->next; /* free memory */ if (block->inst != NULL) auto_free(drcuml->device->machine, block->inst); auto_free(drcuml->device->machine, block); } /* free all the symbols */ while (drcuml->symlist != NULL) { drcuml_symbol *sym = drcuml->symlist; drcuml->symlist = sym->next; auto_free(drcuml->device->machine, sym); } /* close any files */ if (drcuml->umllog != NULL) fclose(drcuml->umllog); }
/*------------------------------------------------- drcuml_free - free state for the code generator and the back-end -------------------------------------------------*/
free state for the code generator and the back-end
[ "free", "state", "for", "the", "code", "generator", "and", "the", "back", "-", "end" ]
void drcuml_free(drcuml_state *drcuml) { if (drcuml->bestate != NULL) (*drcuml->beintf->be_free)(drcuml->bestate); while (drcuml->blocklist != NULL) { drcuml_block *block = drcuml->blocklist; drcuml->blocklist = block->next; if (block->inst != NULL) auto_free(drcuml->device->machine, block->inst); auto_free(drcuml->device->machine, block); } while (drcuml->symlist != NULL) { drcuml_symbol *sym = drcuml->symlist; drcuml->symlist = sym->next; auto_free(drcuml->device->machine, sym); } if (drcuml->umllog != NULL) fclose(drcuml->umllog); }
[ "void", "drcuml_free", "(", "drcuml_state", "*", "drcuml", ")", "{", "if", "(", "drcuml", "->", "bestate", "!=", "NULL", ")", "(", "*", "drcuml", "->", "beintf", "->", "be_free", ")", "(", "drcuml", "->", "bestate", ")", ";", "while", "(", "drcuml", "->", "blocklist", "!=", "NULL", ")", "{", "drcuml_block", "*", "block", "=", "drcuml", "->", "blocklist", ";", "drcuml", "->", "blocklist", "=", "block", "->", "next", ";", "if", "(", "block", "->", "inst", "!=", "NULL", ")", "auto_free", "(", "drcuml", "->", "device", "->", "machine", ",", "block", "->", "inst", ")", ";", "auto_free", "(", "drcuml", "->", "device", "->", "machine", ",", "block", ")", ";", "}", "while", "(", "drcuml", "->", "symlist", "!=", "NULL", ")", "{", "drcuml_symbol", "*", "sym", "=", "drcuml", "->", "symlist", ";", "drcuml", "->", "symlist", "=", "sym", "->", "next", ";", "auto_free", "(", "drcuml", "->", "device", "->", "machine", ",", "sym", ")", ";", "}", "if", "(", "drcuml", "->", "umllog", "!=", "NULL", ")", "fclose", "(", "drcuml", "->", "umllog", ")", ";", "}" ]
drcuml_free - free state for the code generator and the back-end
[ "drcuml_free", "-", "free", "state", "for", "the", "code", "generator", "and", "the", "back", "-", "end" ]
[ "/* free the back-end */", "/* free all the blocks */", "/* remove the item from the list */", "/* free memory */", "/* free all the symbols */", "/* close any files */" ]
[ { "param": "drcuml", "type": "drcuml_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "drcuml", "type": "drcuml_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
drcuml_block_append_0
void
void drcuml_block_append_0(drcuml_block *block, drcuml_opcode op, UINT8 size, UINT8 condition) { drcuml_instruction *inst = &block->inst[block->nextinst++]; assert(block->inuse); /* get a pointer to the next instruction */ if (block->nextinst > block->maxinst) fatalerror("Overran maxinst in drcuml_block_append"); /* fill in the instruction */ inst->opcode = (drcuml_opcode)(UINT8)op; inst->size = size; inst->condition = condition; inst->flags = 0; inst->numparams = 0; /* validation */ validate_instruction(block, inst); }
/*------------------------------------------------- drcuml_block_append_0 - append an opcode with 0 parameters to the block -------------------------------------------------*/
append an opcode with 0 parameters to the block
[ "append", "an", "opcode", "with", "0", "parameters", "to", "the", "block" ]
void drcuml_block_append_0(drcuml_block *block, drcuml_opcode op, UINT8 size, UINT8 condition) { drcuml_instruction *inst = &block->inst[block->nextinst++]; assert(block->inuse); if (block->nextinst > block->maxinst) fatalerror("Overran maxinst in drcuml_block_append"); inst->opcode = (drcuml_opcode)(UINT8)op; inst->size = size; inst->condition = condition; inst->flags = 0; inst->numparams = 0; validate_instruction(block, inst); }
[ "void", "drcuml_block_append_0", "(", "drcuml_block", "*", "block", ",", "drcuml_opcode", "op", ",", "UINT8", "size", ",", "UINT8", "condition", ")", "{", "drcuml_instruction", "*", "inst", "=", "&", "block", "->", "inst", "[", "block", "->", "nextinst", "++", "]", ";", "assert", "(", "block", "->", "inuse", ")", ";", "if", "(", "block", "->", "nextinst", ">", "block", "->", "maxinst", ")", "fatalerror", "(", "\"", "\"", ")", ";", "inst", "->", "opcode", "=", "(", "drcuml_opcode", ")", "(", "UINT8", ")", "op", ";", "inst", "->", "size", "=", "size", ";", "inst", "->", "condition", "=", "condition", ";", "inst", "->", "flags", "=", "0", ";", "inst", "->", "numparams", "=", "0", ";", "validate_instruction", "(", "block", ",", "inst", ")", ";", "}" ]
drcuml_block_append_0 - append an opcode with 0 parameters to the block
[ "drcuml_block_append_0", "-", "append", "an", "opcode", "with", "0", "parameters", "to", "the", "block" ]
[ "/* get a pointer to the next instruction */", "/* fill in the instruction */", "/* validation */" ]
[ { "param": "block", "type": "drcuml_block" }, { "param": "op", "type": "drcuml_opcode" }, { "param": "size", "type": "UINT8" }, { "param": "condition", "type": "UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "op", "type": "drcuml_opcode", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "condition", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
drcuml_block_append_1
void
void drcuml_block_append_1(drcuml_block *block, drcuml_opcode op, UINT8 size, UINT8 condition, drcuml_ptype p0type, drcuml_pvalue p0value) { drcuml_instruction *inst = &block->inst[block->nextinst++]; assert(block->inuse); /* get a pointer to the next instruction */ if (block->nextinst > block->maxinst) fatalerror("Overran maxinst in drcuml_block_append"); /* fill in the instruction */ inst->opcode = (drcuml_opcode)(UINT8)op; inst->size = size; inst->condition = condition; inst->flags = 0; inst->numparams = 1; inst->param[0].type = p0type; inst->param[0].value = p0value; /* validation */ validate_instruction(block, inst); }
/*------------------------------------------------- drcuml_block_append_1 - append an opcode with 1 parameter to the block -------------------------------------------------*/
append an opcode with 1 parameter to the block
[ "append", "an", "opcode", "with", "1", "parameter", "to", "the", "block" ]
void drcuml_block_append_1(drcuml_block *block, drcuml_opcode op, UINT8 size, UINT8 condition, drcuml_ptype p0type, drcuml_pvalue p0value) { drcuml_instruction *inst = &block->inst[block->nextinst++]; assert(block->inuse); if (block->nextinst > block->maxinst) fatalerror("Overran maxinst in drcuml_block_append"); inst->opcode = (drcuml_opcode)(UINT8)op; inst->size = size; inst->condition = condition; inst->flags = 0; inst->numparams = 1; inst->param[0].type = p0type; inst->param[0].value = p0value; validate_instruction(block, inst); }
[ "void", "drcuml_block_append_1", "(", "drcuml_block", "*", "block", ",", "drcuml_opcode", "op", ",", "UINT8", "size", ",", "UINT8", "condition", ",", "drcuml_ptype", "p0type", ",", "drcuml_pvalue", "p0value", ")", "{", "drcuml_instruction", "*", "inst", "=", "&", "block", "->", "inst", "[", "block", "->", "nextinst", "++", "]", ";", "assert", "(", "block", "->", "inuse", ")", ";", "if", "(", "block", "->", "nextinst", ">", "block", "->", "maxinst", ")", "fatalerror", "(", "\"", "\"", ")", ";", "inst", "->", "opcode", "=", "(", "drcuml_opcode", ")", "(", "UINT8", ")", "op", ";", "inst", "->", "size", "=", "size", ";", "inst", "->", "condition", "=", "condition", ";", "inst", "->", "flags", "=", "0", ";", "inst", "->", "numparams", "=", "1", ";", "inst", "->", "param", "[", "0", "]", ".", "type", "=", "p0type", ";", "inst", "->", "param", "[", "0", "]", ".", "value", "=", "p0value", ";", "validate_instruction", "(", "block", ",", "inst", ")", ";", "}" ]
drcuml_block_append_1 - append an opcode with 1 parameter to the block
[ "drcuml_block_append_1", "-", "append", "an", "opcode", "with", "1", "parameter", "to", "the", "block" ]
[ "/* get a pointer to the next instruction */", "/* fill in the instruction */", "/* validation */" ]
[ { "param": "block", "type": "drcuml_block" }, { "param": "op", "type": "drcuml_opcode" }, { "param": "size", "type": "UINT8" }, { "param": "condition", "type": "UINT8" }, { "param": "p0type", "type": "drcuml_ptype" }, { "param": "p0value", "type": "drcuml_pvalue" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "op", "type": "drcuml_opcode", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "condition", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p0type", "type": "drcuml_ptype", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p0value", "type": "drcuml_pvalue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
drcuml_block_append_2
void
void drcuml_block_append_2(drcuml_block *block, drcuml_opcode op, UINT8 size, UINT8 condition, drcuml_ptype p0type, drcuml_pvalue p0value, drcuml_ptype p1type, drcuml_pvalue p1value) { drcuml_instruction *inst = &block->inst[block->nextinst++]; assert(block->inuse); /* get a pointer to the next instruction */ if (block->nextinst > block->maxinst) fatalerror("Overran maxinst in drcuml_block_append"); /* fill in the instruction */ inst->opcode = (drcuml_opcode)(UINT8)op; inst->size = size; inst->condition = condition; inst->flags = 0; inst->numparams = 2; inst->param[0].type = p0type; inst->param[0].value = p0value; inst->param[1].type = p1type; inst->param[1].value = p1value; /* validation */ validate_instruction(block, inst); }
/*------------------------------------------------- drcuml_block_append_2 - append an opcode with 2 parameters to the block -------------------------------------------------*/
append an opcode with 2 parameters to the block
[ "append", "an", "opcode", "with", "2", "parameters", "to", "the", "block" ]
void drcuml_block_append_2(drcuml_block *block, drcuml_opcode op, UINT8 size, UINT8 condition, drcuml_ptype p0type, drcuml_pvalue p0value, drcuml_ptype p1type, drcuml_pvalue p1value) { drcuml_instruction *inst = &block->inst[block->nextinst++]; assert(block->inuse); if (block->nextinst > block->maxinst) fatalerror("Overran maxinst in drcuml_block_append"); inst->opcode = (drcuml_opcode)(UINT8)op; inst->size = size; inst->condition = condition; inst->flags = 0; inst->numparams = 2; inst->param[0].type = p0type; inst->param[0].value = p0value; inst->param[1].type = p1type; inst->param[1].value = p1value; validate_instruction(block, inst); }
[ "void", "drcuml_block_append_2", "(", "drcuml_block", "*", "block", ",", "drcuml_opcode", "op", ",", "UINT8", "size", ",", "UINT8", "condition", ",", "drcuml_ptype", "p0type", ",", "drcuml_pvalue", "p0value", ",", "drcuml_ptype", "p1type", ",", "drcuml_pvalue", "p1value", ")", "{", "drcuml_instruction", "*", "inst", "=", "&", "block", "->", "inst", "[", "block", "->", "nextinst", "++", "]", ";", "assert", "(", "block", "->", "inuse", ")", ";", "if", "(", "block", "->", "nextinst", ">", "block", "->", "maxinst", ")", "fatalerror", "(", "\"", "\"", ")", ";", "inst", "->", "opcode", "=", "(", "drcuml_opcode", ")", "(", "UINT8", ")", "op", ";", "inst", "->", "size", "=", "size", ";", "inst", "->", "condition", "=", "condition", ";", "inst", "->", "flags", "=", "0", ";", "inst", "->", "numparams", "=", "2", ";", "inst", "->", "param", "[", "0", "]", ".", "type", "=", "p0type", ";", "inst", "->", "param", "[", "0", "]", ".", "value", "=", "p0value", ";", "inst", "->", "param", "[", "1", "]", ".", "type", "=", "p1type", ";", "inst", "->", "param", "[", "1", "]", ".", "value", "=", "p1value", ";", "validate_instruction", "(", "block", ",", "inst", ")", ";", "}" ]
drcuml_block_append_2 - append an opcode with 2 parameters to the block
[ "drcuml_block_append_2", "-", "append", "an", "opcode", "with", "2", "parameters", "to", "the", "block" ]
[ "/* get a pointer to the next instruction */", "/* fill in the instruction */", "/* validation */" ]
[ { "param": "block", "type": "drcuml_block" }, { "param": "op", "type": "drcuml_opcode" }, { "param": "size", "type": "UINT8" }, { "param": "condition", "type": "UINT8" }, { "param": "p0type", "type": "drcuml_ptype" }, { "param": "p0value", "type": "drcuml_pvalue" }, { "param": "p1type", "type": "drcuml_ptype" }, { "param": "p1value", "type": "drcuml_pvalue" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "op", "type": "drcuml_opcode", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "condition", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p0type", "type": "drcuml_ptype", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p0value", "type": "drcuml_pvalue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p1type", "type": "drcuml_ptype", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p1value", "type": "drcuml_pvalue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
drcuml_block_append_3
void
void drcuml_block_append_3(drcuml_block *block, drcuml_opcode op, UINT8 size, UINT8 condition, drcuml_ptype p0type, drcuml_pvalue p0value, drcuml_ptype p1type, drcuml_pvalue p1value, drcuml_ptype p2type, drcuml_pvalue p2value) { drcuml_instruction *inst = &block->inst[block->nextinst++]; assert(block->inuse); /* get a pointer to the next instruction */ if (block->nextinst > block->maxinst) fatalerror("Overran maxinst in drcuml_block_append"); /* fill in the instruction */ inst->opcode = (drcuml_opcode)(UINT8)op; inst->size = size; inst->condition = condition; inst->flags = 0; inst->numparams = 3; inst->param[0].type = p0type; inst->param[0].value = p0value; inst->param[1].type = p1type; inst->param[1].value = p1value; inst->param[2].type = p2type; inst->param[2].value = p2value; /* validation */ validate_instruction(block, inst); }
/*------------------------------------------------- drcuml_block_append_3 - append an opcode with 3 parameters to the block -------------------------------------------------*/
append an opcode with 3 parameters to the block
[ "append", "an", "opcode", "with", "3", "parameters", "to", "the", "block" ]
void drcuml_block_append_3(drcuml_block *block, drcuml_opcode op, UINT8 size, UINT8 condition, drcuml_ptype p0type, drcuml_pvalue p0value, drcuml_ptype p1type, drcuml_pvalue p1value, drcuml_ptype p2type, drcuml_pvalue p2value) { drcuml_instruction *inst = &block->inst[block->nextinst++]; assert(block->inuse); if (block->nextinst > block->maxinst) fatalerror("Overran maxinst in drcuml_block_append"); inst->opcode = (drcuml_opcode)(UINT8)op; inst->size = size; inst->condition = condition; inst->flags = 0; inst->numparams = 3; inst->param[0].type = p0type; inst->param[0].value = p0value; inst->param[1].type = p1type; inst->param[1].value = p1value; inst->param[2].type = p2type; inst->param[2].value = p2value; validate_instruction(block, inst); }
[ "void", "drcuml_block_append_3", "(", "drcuml_block", "*", "block", ",", "drcuml_opcode", "op", ",", "UINT8", "size", ",", "UINT8", "condition", ",", "drcuml_ptype", "p0type", ",", "drcuml_pvalue", "p0value", ",", "drcuml_ptype", "p1type", ",", "drcuml_pvalue", "p1value", ",", "drcuml_ptype", "p2type", ",", "drcuml_pvalue", "p2value", ")", "{", "drcuml_instruction", "*", "inst", "=", "&", "block", "->", "inst", "[", "block", "->", "nextinst", "++", "]", ";", "assert", "(", "block", "->", "inuse", ")", ";", "if", "(", "block", "->", "nextinst", ">", "block", "->", "maxinst", ")", "fatalerror", "(", "\"", "\"", ")", ";", "inst", "->", "opcode", "=", "(", "drcuml_opcode", ")", "(", "UINT8", ")", "op", ";", "inst", "->", "size", "=", "size", ";", "inst", "->", "condition", "=", "condition", ";", "inst", "->", "flags", "=", "0", ";", "inst", "->", "numparams", "=", "3", ";", "inst", "->", "param", "[", "0", "]", ".", "type", "=", "p0type", ";", "inst", "->", "param", "[", "0", "]", ".", "value", "=", "p0value", ";", "inst", "->", "param", "[", "1", "]", ".", "type", "=", "p1type", ";", "inst", "->", "param", "[", "1", "]", ".", "value", "=", "p1value", ";", "inst", "->", "param", "[", "2", "]", ".", "type", "=", "p2type", ";", "inst", "->", "param", "[", "2", "]", ".", "value", "=", "p2value", ";", "validate_instruction", "(", "block", ",", "inst", ")", ";", "}" ]
drcuml_block_append_3 - append an opcode with 3 parameters to the block
[ "drcuml_block_append_3", "-", "append", "an", "opcode", "with", "3", "parameters", "to", "the", "block" ]
[ "/* get a pointer to the next instruction */", "/* fill in the instruction */", "/* validation */" ]
[ { "param": "block", "type": "drcuml_block" }, { "param": "op", "type": "drcuml_opcode" }, { "param": "size", "type": "UINT8" }, { "param": "condition", "type": "UINT8" }, { "param": "p0type", "type": "drcuml_ptype" }, { "param": "p0value", "type": "drcuml_pvalue" }, { "param": "p1type", "type": "drcuml_ptype" }, { "param": "p1value", "type": "drcuml_pvalue" }, { "param": "p2type", "type": "drcuml_ptype" }, { "param": "p2value", "type": "drcuml_pvalue" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "op", "type": "drcuml_opcode", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "condition", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p0type", "type": "drcuml_ptype", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p0value", "type": "drcuml_pvalue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p1type", "type": "drcuml_ptype", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p1value", "type": "drcuml_pvalue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p2type", "type": "drcuml_ptype", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p2value", "type": "drcuml_pvalue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
drcuml_block_append_4
void
void drcuml_block_append_4(drcuml_block *block, drcuml_opcode op, UINT8 size, UINT8 condition, drcuml_ptype p0type, drcuml_pvalue p0value, drcuml_ptype p1type, drcuml_pvalue p1value, drcuml_ptype p2type, drcuml_pvalue p2value, drcuml_ptype p3type, drcuml_pvalue p3value) { drcuml_instruction *inst = &block->inst[block->nextinst++]; assert(block->inuse); /* get a pointer to the next instruction */ if (block->nextinst > block->maxinst) fatalerror("Overran maxinst in drcuml_block_append"); /* fill in the instruction */ inst->opcode = (drcuml_opcode)(UINT8)op; inst->size = size; inst->condition = condition; inst->flags = 0; inst->numparams = 4; inst->param[0].type = p0type; inst->param[0].value = p0value; inst->param[1].type = p1type; inst->param[1].value = p1value; inst->param[2].type = p2type; inst->param[2].value = p2value; inst->param[3].type = p3type; inst->param[3].value = p3value; /* validation */ validate_instruction(block, inst); }
/*------------------------------------------------- drcuml_block_append_4 - append an opcode with 4 parameters to the block -------------------------------------------------*/
append an opcode with 4 parameters to the block
[ "append", "an", "opcode", "with", "4", "parameters", "to", "the", "block" ]
void drcuml_block_append_4(drcuml_block *block, drcuml_opcode op, UINT8 size, UINT8 condition, drcuml_ptype p0type, drcuml_pvalue p0value, drcuml_ptype p1type, drcuml_pvalue p1value, drcuml_ptype p2type, drcuml_pvalue p2value, drcuml_ptype p3type, drcuml_pvalue p3value) { drcuml_instruction *inst = &block->inst[block->nextinst++]; assert(block->inuse); if (block->nextinst > block->maxinst) fatalerror("Overran maxinst in drcuml_block_append"); inst->opcode = (drcuml_opcode)(UINT8)op; inst->size = size; inst->condition = condition; inst->flags = 0; inst->numparams = 4; inst->param[0].type = p0type; inst->param[0].value = p0value; inst->param[1].type = p1type; inst->param[1].value = p1value; inst->param[2].type = p2type; inst->param[2].value = p2value; inst->param[3].type = p3type; inst->param[3].value = p3value; validate_instruction(block, inst); }
[ "void", "drcuml_block_append_4", "(", "drcuml_block", "*", "block", ",", "drcuml_opcode", "op", ",", "UINT8", "size", ",", "UINT8", "condition", ",", "drcuml_ptype", "p0type", ",", "drcuml_pvalue", "p0value", ",", "drcuml_ptype", "p1type", ",", "drcuml_pvalue", "p1value", ",", "drcuml_ptype", "p2type", ",", "drcuml_pvalue", "p2value", ",", "drcuml_ptype", "p3type", ",", "drcuml_pvalue", "p3value", ")", "{", "drcuml_instruction", "*", "inst", "=", "&", "block", "->", "inst", "[", "block", "->", "nextinst", "++", "]", ";", "assert", "(", "block", "->", "inuse", ")", ";", "if", "(", "block", "->", "nextinst", ">", "block", "->", "maxinst", ")", "fatalerror", "(", "\"", "\"", ")", ";", "inst", "->", "opcode", "=", "(", "drcuml_opcode", ")", "(", "UINT8", ")", "op", ";", "inst", "->", "size", "=", "size", ";", "inst", "->", "condition", "=", "condition", ";", "inst", "->", "flags", "=", "0", ";", "inst", "->", "numparams", "=", "4", ";", "inst", "->", "param", "[", "0", "]", ".", "type", "=", "p0type", ";", "inst", "->", "param", "[", "0", "]", ".", "value", "=", "p0value", ";", "inst", "->", "param", "[", "1", "]", ".", "type", "=", "p1type", ";", "inst", "->", "param", "[", "1", "]", ".", "value", "=", "p1value", ";", "inst", "->", "param", "[", "2", "]", ".", "type", "=", "p2type", ";", "inst", "->", "param", "[", "2", "]", ".", "value", "=", "p2value", ";", "inst", "->", "param", "[", "3", "]", ".", "type", "=", "p3type", ";", "inst", "->", "param", "[", "3", "]", ".", "value", "=", "p3value", ";", "validate_instruction", "(", "block", ",", "inst", ")", ";", "}" ]
drcuml_block_append_4 - append an opcode with 4 parameters to the block
[ "drcuml_block_append_4", "-", "append", "an", "opcode", "with", "4", "parameters", "to", "the", "block" ]
[ "/* get a pointer to the next instruction */", "/* fill in the instruction */", "/* validation */" ]
[ { "param": "block", "type": "drcuml_block" }, { "param": "op", "type": "drcuml_opcode" }, { "param": "size", "type": "UINT8" }, { "param": "condition", "type": "UINT8" }, { "param": "p0type", "type": "drcuml_ptype" }, { "param": "p0value", "type": "drcuml_pvalue" }, { "param": "p1type", "type": "drcuml_ptype" }, { "param": "p1value", "type": "drcuml_pvalue" }, { "param": "p2type", "type": "drcuml_ptype" }, { "param": "p2value", "type": "drcuml_pvalue" }, { "param": "p3type", "type": "drcuml_ptype" }, { "param": "p3value", "type": "drcuml_pvalue" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "op", "type": "drcuml_opcode", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "condition", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p0type", "type": "drcuml_ptype", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p0value", "type": "drcuml_pvalue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p1type", "type": "drcuml_ptype", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p1value", "type": "drcuml_pvalue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p2type", "type": "drcuml_ptype", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p2value", "type": "drcuml_pvalue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p3type", "type": "drcuml_ptype", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p3value", "type": "drcuml_pvalue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
drcuml_block_end
void
void drcuml_block_end(drcuml_block *block) { drcuml_state *drcuml = block->drcuml; assert(block->inuse); /* optimize the resulting code first */ optimize_block(block); /* if we have a logfile, generate a disassembly of the block */ if (drcuml->umllog != NULL) disassemble_block(block); /* generate the code via the back-end */ (*drcuml->beintf->be_generate)(drcuml->bestate, block, block->inst, block->nextinst); /* block is no longer in use */ block->inuse = FALSE; }
/*------------------------------------------------- drcuml_block_end - complete a code block and commit it to the cache via the back-end -------------------------------------------------*/
complete a code block and commit it to the cache via the back-end
[ "complete", "a", "code", "block", "and", "commit", "it", "to", "the", "cache", "via", "the", "back", "-", "end" ]
void drcuml_block_end(drcuml_block *block) { drcuml_state *drcuml = block->drcuml; assert(block->inuse); optimize_block(block); if (drcuml->umllog != NULL) disassemble_block(block); (*drcuml->beintf->be_generate)(drcuml->bestate, block, block->inst, block->nextinst); block->inuse = FALSE; }
[ "void", "drcuml_block_end", "(", "drcuml_block", "*", "block", ")", "{", "drcuml_state", "*", "drcuml", "=", "block", "->", "drcuml", ";", "assert", "(", "block", "->", "inuse", ")", ";", "optimize_block", "(", "block", ")", ";", "if", "(", "drcuml", "->", "umllog", "!=", "NULL", ")", "disassemble_block", "(", "block", ")", ";", "(", "*", "drcuml", "->", "beintf", "->", "be_generate", ")", "(", "drcuml", "->", "bestate", ",", "block", ",", "block", "->", "inst", ",", "block", "->", "nextinst", ")", ";", "block", "->", "inuse", "=", "FALSE", ";", "}" ]
drcuml_block_end - complete a code block and commit it to the cache via the back-end
[ "drcuml_block_end", "-", "complete", "a", "code", "block", "and", "commit", "it", "to", "the", "cache", "via", "the", "back", "-", "end" ]
[ "/* optimize the resulting code first */", "/* if we have a logfile, generate a disassembly of the block */", "/* generate the code via the back-end */", "/* block is no longer in use */" ]
[ { "param": "block", "type": "drcuml_block" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
drcuml_block_abort
void
void drcuml_block_abort(drcuml_block *block) { assert(block->inuse); /* block is no longer in use */ block->inuse = FALSE; /* unwind */ longjmp(*block->errorbuf, 1); }
/*------------------------------------------------- drcuml_block_abort - abort a code block in progress -------------------------------------------------*/
abort a code block in progress
[ "abort", "a", "code", "block", "in", "progress" ]
void drcuml_block_abort(drcuml_block *block) { assert(block->inuse); block->inuse = FALSE; longjmp(*block->errorbuf, 1); }
[ "void", "drcuml_block_abort", "(", "drcuml_block", "*", "block", ")", "{", "assert", "(", "block", "->", "inuse", ")", ";", "block", "->", "inuse", "=", "FALSE", ";", "longjmp", "(", "*", "block", "->", "errorbuf", ",", "1", ")", ";", "}" ]
drcuml_block_abort - abort a code block in progress
[ "drcuml_block_abort", "-", "abort", "a", "code", "block", "in", "progress" ]
[ "/* block is no longer in use */", "/* unwind */" ]
[ { "param": "block", "type": "drcuml_block" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
drcuml_handle_set_codeptr
void
void drcuml_handle_set_codeptr(drcuml_codehandle *handle, drccodeptr code) { assert(handle->code == NULL); assert_in_cache(handle->drcuml->cache, code); handle->code = code; }
/*------------------------------------------------- drcuml_handle_set_codeptr - set a codeptr associated with a handle -------------------------------------------------*/
set a codeptr associated with a handle
[ "set", "a", "codeptr", "associated", "with", "a", "handle" ]
void drcuml_handle_set_codeptr(drcuml_codehandle *handle, drccodeptr code) { assert(handle->code == NULL); assert_in_cache(handle->drcuml->cache, code); handle->code = code; }
[ "void", "drcuml_handle_set_codeptr", "(", "drcuml_codehandle", "*", "handle", ",", "drccodeptr", "code", ")", "{", "assert", "(", "handle", "->", "code", "==", "NULL", ")", ";", "assert_in_cache", "(", "handle", "->", "drcuml", "->", "cache", ",", "code", ")", ";", "handle", "->", "code", "=", "code", ";", "}" ]
drcuml_handle_set_codeptr - set a codeptr associated with a handle
[ "drcuml_handle_set_codeptr", "-", "set", "a", "codeptr", "associated", "with", "a", "handle" ]
[]
[ { "param": "handle", "type": "drcuml_codehandle" }, { "param": "code", "type": "drccodeptr" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "handle", "type": "drcuml_codehandle", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "code", "type": "drccodeptr", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
drcuml_symbol_add
void
void drcuml_symbol_add(drcuml_state *drcuml, void *base, UINT32 length, const char *name) { drcuml_symbol *symbol; /* allocate memory to hold the symbol */ symbol = (drcuml_symbol *)auto_alloc_array(drcuml->device->machine, UINT8, sizeof(*symbol) + strlen(name)); /* fill in the structure */ symbol->next = NULL; symbol->base = (drccodeptr)base; symbol->length = length; strcpy(symbol->symname, name); /* add to the tail of the list */ *drcuml->symtailptr = symbol; drcuml->symtailptr = &symbol->next; }
/*------------------------------------------------- drcuml_symbol_add - add a symbol to the internal symbol table -------------------------------------------------*/
add a symbol to the internal symbol table
[ "add", "a", "symbol", "to", "the", "internal", "symbol", "table" ]
void drcuml_symbol_add(drcuml_state *drcuml, void *base, UINT32 length, const char *name) { drcuml_symbol *symbol; symbol = (drcuml_symbol *)auto_alloc_array(drcuml->device->machine, UINT8, sizeof(*symbol) + strlen(name)); symbol->next = NULL; symbol->base = (drccodeptr)base; symbol->length = length; strcpy(symbol->symname, name); *drcuml->symtailptr = symbol; drcuml->symtailptr = &symbol->next; }
[ "void", "drcuml_symbol_add", "(", "drcuml_state", "*", "drcuml", ",", "void", "*", "base", ",", "UINT32", "length", ",", "const", "char", "*", "name", ")", "{", "drcuml_symbol", "*", "symbol", ";", "symbol", "=", "(", "drcuml_symbol", "*", ")", "auto_alloc_array", "(", "drcuml", "->", "device", "->", "machine", ",", "UINT8", ",", "sizeof", "(", "*", "symbol", ")", "+", "strlen", "(", "name", ")", ")", ";", "symbol", "->", "next", "=", "NULL", ";", "symbol", "->", "base", "=", "(", "drccodeptr", ")", "base", ";", "symbol", "->", "length", "=", "length", ";", "strcpy", "(", "symbol", "->", "symname", ",", "name", ")", ";", "*", "drcuml", "->", "symtailptr", "=", "symbol", ";", "drcuml", "->", "symtailptr", "=", "&", "symbol", "->", "next", ";", "}" ]
drcuml_symbol_add - add a symbol to the internal symbol table
[ "drcuml_symbol_add", "-", "add", "a", "symbol", "to", "the", "internal", "symbol", "table" ]
[ "/* allocate memory to hold the symbol */", "/* fill in the structure */", "/* add to the tail of the list */" ]
[ { "param": "drcuml", "type": "drcuml_state" }, { "param": "base", "type": "void" }, { "param": "length", "type": "UINT32" }, { "param": "name", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "drcuml", "type": "drcuml_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "base", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "length", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "name", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
drcuml_symbol_find
char
const char *drcuml_symbol_find(drcuml_state *drcuml, void *base, UINT32 *offset) { drccodeptr search = (drccodeptr)base; drcuml_symbol *symbol; /* simple linear search */ for (symbol = drcuml->symlist; symbol != NULL; symbol = symbol->next) if (search >= symbol->base && search < symbol->base + symbol->length) { /* if no offset pointer, only match perfectly */ if (offset == NULL && search != symbol->base) continue; /* return the offset and name */ if (offset != NULL) *offset = search - symbol->base; return symbol->symname; } /* not found; return NULL */ return NULL; }
/*------------------------------------------------- drcuml_symbol_find - look up a symbol from the internal symbol table or return NULL if not found -------------------------------------------------*/
look up a symbol from the internal symbol table or return NULL if not found
[ "look", "up", "a", "symbol", "from", "the", "internal", "symbol", "table", "or", "return", "NULL", "if", "not", "found" ]
const char *drcuml_symbol_find(drcuml_state *drcuml, void *base, UINT32 *offset) { drccodeptr search = (drccodeptr)base; drcuml_symbol *symbol; for (symbol = drcuml->symlist; symbol != NULL; symbol = symbol->next) if (search >= symbol->base && search < symbol->base + symbol->length) { if (offset == NULL && search != symbol->base) continue; if (offset != NULL) *offset = search - symbol->base; return symbol->symname; } return NULL; }
[ "const", "char", "*", "drcuml_symbol_find", "(", "drcuml_state", "*", "drcuml", ",", "void", "*", "base", ",", "UINT32", "*", "offset", ")", "{", "drccodeptr", "search", "=", "(", "drccodeptr", ")", "base", ";", "drcuml_symbol", "*", "symbol", ";", "for", "(", "symbol", "=", "drcuml", "->", "symlist", ";", "symbol", "!=", "NULL", ";", "symbol", "=", "symbol", "->", "next", ")", "if", "(", "search", ">=", "symbol", "->", "base", "&&", "search", "<", "symbol", "->", "base", "+", "symbol", "->", "length", ")", "{", "if", "(", "offset", "==", "NULL", "&&", "search", "!=", "symbol", "->", "base", ")", "continue", ";", "if", "(", "offset", "!=", "NULL", ")", "*", "offset", "=", "search", "-", "symbol", "->", "base", ";", "return", "symbol", "->", "symname", ";", "}", "return", "NULL", ";", "}" ]
drcuml_symbol_find - look up a symbol from the internal symbol table or return NULL if not found
[ "drcuml_symbol_find", "-", "look", "up", "a", "symbol", "from", "the", "internal", "symbol", "table", "or", "return", "NULL", "if", "not", "found" ]
[ "/* simple linear search */", "/* if no offset pointer, only match perfectly */", "/* return the offset and name */", "/* not found; return NULL */" ]
[ { "param": "drcuml", "type": "drcuml_state" }, { "param": "base", "type": "void" }, { "param": "offset", "type": "UINT32" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "drcuml", "type": "drcuml_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "base", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "offset", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
drcuml_log_printf
void
void drcuml_log_printf(drcuml_state *drcuml, const char *format, ...) { /* if we have a file, print to it */ if (drcuml->umllog != NULL) { va_list va; /* do the printf */ va_start(va, format); vfprintf(drcuml->umllog, format, va); va_end(va); } }
/*------------------------------------------------- drcuml_log_printf - directly printf to the UML log if generated -------------------------------------------------*/
directly printf to the UML log if generated
[ "directly", "printf", "to", "the", "UML", "log", "if", "generated" ]
void drcuml_log_printf(drcuml_state *drcuml, const char *format, ...) { if (drcuml->umllog != NULL) { va_list va; va_start(va, format); vfprintf(drcuml->umllog, format, va); va_end(va); } }
[ "void", "drcuml_log_printf", "(", "drcuml_state", "*", "drcuml", ",", "const", "char", "*", "format", ",", "...", ")", "{", "if", "(", "drcuml", "->", "umllog", "!=", "NULL", ")", "{", "va_list", "va", ";", "va_start", "(", "va", ",", "format", ")", ";", "vfprintf", "(", "drcuml", "->", "umllog", ",", "format", ",", "va", ")", ";", "va_end", "(", "va", ")", ";", "}", "}" ]
drcuml_log_printf - directly printf to the UML log if generated
[ "drcuml_log_printf", "-", "directly", "printf", "to", "the", "UML", "log", "if", "generated" ]
[ "/* if we have a file, print to it */", "/* do the printf */" ]
[ { "param": "drcuml", "type": "drcuml_state" }, { "param": "format", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "drcuml", "type": "drcuml_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "format", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
drcuml_add_comment
void
void drcuml_add_comment(drcuml_block *block, const char *format, ...) { char buffer[512]; char *comment; va_list va; assert(block->inuse); /* do the printf */ va_start(va, format); vsprintf(buffer, format, va); va_end(va); /* allocate space in the cache to hold the comment */ comment = (char *)drccache_memory_alloc_temporary(block->drcuml->cache, strlen(buffer) + 1); if (comment == NULL) return; strcpy(comment, buffer); /* add an instruction with a pointer */ drcuml_block_append_1(block, DRCUML_OP_COMMENT, 4, DRCUML_COND_ALWAYS, MEM(comment)); }
/*------------------------------------------------- drcuml_add_comment - attach a comment to the current output location in the specified block -------------------------------------------------*/
attach a comment to the current output location in the specified block
[ "attach", "a", "comment", "to", "the", "current", "output", "location", "in", "the", "specified", "block" ]
void drcuml_add_comment(drcuml_block *block, const char *format, ...) { char buffer[512]; char *comment; va_list va; assert(block->inuse); va_start(va, format); vsprintf(buffer, format, va); va_end(va); comment = (char *)drccache_memory_alloc_temporary(block->drcuml->cache, strlen(buffer) + 1); if (comment == NULL) return; strcpy(comment, buffer); drcuml_block_append_1(block, DRCUML_OP_COMMENT, 4, DRCUML_COND_ALWAYS, MEM(comment)); }
[ "void", "drcuml_add_comment", "(", "drcuml_block", "*", "block", ",", "const", "char", "*", "format", ",", "...", ")", "{", "char", "buffer", "[", "512", "]", ";", "char", "*", "comment", ";", "va_list", "va", ";", "assert", "(", "block", "->", "inuse", ")", ";", "va_start", "(", "va", ",", "format", ")", ";", "vsprintf", "(", "buffer", ",", "format", ",", "va", ")", ";", "va_end", "(", "va", ")", ";", "comment", "=", "(", "char", "*", ")", "drccache_memory_alloc_temporary", "(", "block", "->", "drcuml", "->", "cache", ",", "strlen", "(", "buffer", ")", "+", "1", ")", ";", "if", "(", "comment", "==", "NULL", ")", "return", ";", "strcpy", "(", "comment", ",", "buffer", ")", ";", "drcuml_block_append_1", "(", "block", ",", "DRCUML_OP_COMMENT", ",", "4", ",", "DRCUML_COND_ALWAYS", ",", "MEM", "(", "comment", ")", ")", ";", "}" ]
drcuml_add_comment - attach a comment to the current output location in the specified block
[ "drcuml_add_comment", "-", "attach", "a", "comment", "to", "the", "current", "output", "location", "in", "the", "specified", "block" ]
[ "/* do the printf */", "/* allocate space in the cache to hold the comment */", "/* add an instruction with a pointer */" ]
[ { "param": "block", "type": "drcuml_block" }, { "param": "format", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "format", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
optimize_block
void
static void optimize_block(drcuml_block *block) { UINT32 mapvar[DRCUML_MAPVAR_END - DRCUML_MAPVAR_M0] = { 0 }; int instnum; /* iterate over instructions */ for (instnum = 0; instnum < block->nextinst; instnum++) { drcuml_instruction *inst = &block->inst[instnum]; const drcuml_opcode_info *opinfo = opcode_info_table[inst->opcode]; UINT8 remainingflags; int scannum, pnum; /* first compute what flags we need */ inst->flags = 0; remainingflags = effective_outflags(inst, opinfo); /* scan ahead until we run out of possible remaining flags */ for (scannum = instnum + 1; remainingflags != 0 && scannum < block->nextinst; scannum++) { const drcuml_instruction *scan = &block->inst[scannum]; const drcuml_opcode_info *scaninfo = opcode_info_table[scan->opcode]; /* any input flags are required */ inst->flags |= effective_inflags(scan, scaninfo); /* if the scanahead instruction is unconditional, assume his flags are modified */ if (scan->condition == DRCUML_COND_ALWAYS) remainingflags &= ~scaninfo->modflags; } /* track mapvars */ if (inst->opcode == DRCUML_OP_MAPVAR) mapvar[inst->param[0].value - DRCUML_MAPVAR_M0] = inst->param[1].value; /* convert all mapvar parameters to immediates */ else if (inst->opcode != DRCUML_OP_RECOVER) for (pnum = 0; pnum < inst->numparams; pnum++) if (inst->param[pnum].type == DRCUML_PTYPE_MAPVAR) { inst->param[pnum].type = DRCUML_PTYPE_IMMEDIATE; inst->param[pnum].value = mapvar[inst->param[pnum].value - DRCUML_MAPVAR_M0]; } /* if we don't need any flags, then we can eliminate a lot of dumb operations */ if (inst->flags == 0) simplify_instruction_with_no_flags(block, inst); } }
/*------------------------------------------------- optimize_block - apply various optimizations to a block of code -------------------------------------------------*/
apply various optimizations to a block of code
[ "apply", "various", "optimizations", "to", "a", "block", "of", "code" ]
static void optimize_block(drcuml_block *block) { UINT32 mapvar[DRCUML_MAPVAR_END - DRCUML_MAPVAR_M0] = { 0 }; int instnum; for (instnum = 0; instnum < block->nextinst; instnum++) { drcuml_instruction *inst = &block->inst[instnum]; const drcuml_opcode_info *opinfo = opcode_info_table[inst->opcode]; UINT8 remainingflags; int scannum, pnum; inst->flags = 0; remainingflags = effective_outflags(inst, opinfo); for (scannum = instnum + 1; remainingflags != 0 && scannum < block->nextinst; scannum++) { const drcuml_instruction *scan = &block->inst[scannum]; const drcuml_opcode_info *scaninfo = opcode_info_table[scan->opcode]; inst->flags |= effective_inflags(scan, scaninfo); if (scan->condition == DRCUML_COND_ALWAYS) remainingflags &= ~scaninfo->modflags; } if (inst->opcode == DRCUML_OP_MAPVAR) mapvar[inst->param[0].value - DRCUML_MAPVAR_M0] = inst->param[1].value; else if (inst->opcode != DRCUML_OP_RECOVER) for (pnum = 0; pnum < inst->numparams; pnum++) if (inst->param[pnum].type == DRCUML_PTYPE_MAPVAR) { inst->param[pnum].type = DRCUML_PTYPE_IMMEDIATE; inst->param[pnum].value = mapvar[inst->param[pnum].value - DRCUML_MAPVAR_M0]; } if (inst->flags == 0) simplify_instruction_with_no_flags(block, inst); } }
[ "static", "void", "optimize_block", "(", "drcuml_block", "*", "block", ")", "{", "UINT32", "mapvar", "[", "DRCUML_MAPVAR_END", "-", "DRCUML_MAPVAR_M0", "]", "=", "{", "0", "}", ";", "int", "instnum", ";", "for", "(", "instnum", "=", "0", ";", "instnum", "<", "block", "->", "nextinst", ";", "instnum", "++", ")", "{", "drcuml_instruction", "*", "inst", "=", "&", "block", "->", "inst", "[", "instnum", "]", ";", "const", "drcuml_opcode_info", "*", "opinfo", "=", "opcode_info_table", "[", "inst", "->", "opcode", "]", ";", "UINT8", "remainingflags", ";", "int", "scannum", ",", "pnum", ";", "inst", "->", "flags", "=", "0", ";", "remainingflags", "=", "effective_outflags", "(", "inst", ",", "opinfo", ")", ";", "for", "(", "scannum", "=", "instnum", "+", "1", ";", "remainingflags", "!=", "0", "&&", "scannum", "<", "block", "->", "nextinst", ";", "scannum", "++", ")", "{", "const", "drcuml_instruction", "*", "scan", "=", "&", "block", "->", "inst", "[", "scannum", "]", ";", "const", "drcuml_opcode_info", "*", "scaninfo", "=", "opcode_info_table", "[", "scan", "->", "opcode", "]", ";", "inst", "->", "flags", "|=", "effective_inflags", "(", "scan", ",", "scaninfo", ")", ";", "if", "(", "scan", "->", "condition", "==", "DRCUML_COND_ALWAYS", ")", "remainingflags", "&=", "~", "scaninfo", "->", "modflags", ";", "}", "if", "(", "inst", "->", "opcode", "==", "DRCUML_OP_MAPVAR", ")", "mapvar", "[", "inst", "->", "param", "[", "0", "]", ".", "value", "-", "DRCUML_MAPVAR_M0", "]", "=", "inst", "->", "param", "[", "1", "]", ".", "value", ";", "else", "if", "(", "inst", "->", "opcode", "!=", "DRCUML_OP_RECOVER", ")", "for", "(", "pnum", "=", "0", ";", "pnum", "<", "inst", "->", "numparams", ";", "pnum", "++", ")", "if", "(", "inst", "->", "param", "[", "pnum", "]", ".", "type", "==", "DRCUML_PTYPE_MAPVAR", ")", "{", "inst", "->", "param", "[", "pnum", "]", ".", "type", "=", "DRCUML_PTYPE_IMMEDIATE", ";", "inst", "->", "param", "[", "pnum", "]", ".", "value", "=", "mapvar", "[", "inst", "->", "param", "[", "pnum", "]", ".", "value", "-", "DRCUML_MAPVAR_M0", "]", ";", "}", "if", "(", "inst", "->", "flags", "==", "0", ")", "simplify_instruction_with_no_flags", "(", "block", ",", "inst", ")", ";", "}", "}" ]
optimize_block - apply various optimizations to a block of code
[ "optimize_block", "-", "apply", "various", "optimizations", "to", "a", "block", "of", "code" ]
[ "/* iterate over instructions */", "/* first compute what flags we need */", "/* scan ahead until we run out of possible remaining flags */", "/* any input flags are required */", "/* if the scanahead instruction is unconditional, assume his flags are modified */", "/* track mapvars */", "/* convert all mapvar parameters to immediates */", "/* if we don't need any flags, then we can eliminate a lot of dumb operations */" ]
[ { "param": "block", "type": "drcuml_block" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
disassemble_block
void
static void disassemble_block(drcuml_block *block) { int firstcomment = -1; int instnum; /* iterate over instructions and output */ for (instnum = 0; instnum < block->nextinst; instnum++) { const drcuml_instruction *inst = &block->inst[instnum]; int flushcomments = FALSE; /* remember comments and mapvars for later */ if (inst->opcode == DRCUML_OP_COMMENT || inst->opcode == DRCUML_OP_MAPVAR) { if (firstcomment == -1) firstcomment = instnum; } /* print labels, handles, and hashes left justified */ else if (inst->opcode == DRCUML_OP_LABEL) drcuml_log_printf(block->drcuml, "$%X:\n", (UINT32)inst->param[0].value); else if (inst->opcode == DRCUML_OP_HANDLE) drcuml_log_printf(block->drcuml, "%s:\n", drcuml_handle_name((const drcuml_codehandle *)(FPTR)inst->param[0].value)); else if (inst->opcode == DRCUML_OP_HASH) drcuml_log_printf(block->drcuml, "(%X,%X):\n", (UINT32)inst->param[0].value, (UINT32)inst->param[1].value); /* indent everything else with a tab */ else { char dasm[256]; drcuml_disasm(&block->inst[instnum], dasm, block->drcuml); /* include the first accumulated comment with this line */ if (firstcomment != -1) { drcuml_log_printf(block->drcuml, "\t%-50.50s; %s\n", dasm, get_comment_text(&block->inst[firstcomment])); firstcomment++; flushcomments = TRUE; } else drcuml_log_printf(block->drcuml, "\t%s\n", dasm); } /* flush any comments pending */ if (firstcomment != -1 && (flushcomments || instnum == block->nextinst - 1)) { while (firstcomment <= instnum) { const char *text = get_comment_text(&block->inst[firstcomment++]); if (text != NULL) drcuml_log_printf(block->drcuml, "\t%50s; %s\n", "", text); } firstcomment = -1; } } drcuml_log_printf(block->drcuml, "\n\n"); fflush(block->drcuml->umllog); }
/*------------------------------------------------- disassemble_block - disassemble a block of instructions to the log -------------------------------------------------*/
disassemble a block of instructions to the log
[ "disassemble", "a", "block", "of", "instructions", "to", "the", "log" ]
static void disassemble_block(drcuml_block *block) { int firstcomment = -1; int instnum; for (instnum = 0; instnum < block->nextinst; instnum++) { const drcuml_instruction *inst = &block->inst[instnum]; int flushcomments = FALSE; if (inst->opcode == DRCUML_OP_COMMENT || inst->opcode == DRCUML_OP_MAPVAR) { if (firstcomment == -1) firstcomment = instnum; } else if (inst->opcode == DRCUML_OP_LABEL) drcuml_log_printf(block->drcuml, "$%X:\n", (UINT32)inst->param[0].value); else if (inst->opcode == DRCUML_OP_HANDLE) drcuml_log_printf(block->drcuml, "%s:\n", drcuml_handle_name((const drcuml_codehandle *)(FPTR)inst->param[0].value)); else if (inst->opcode == DRCUML_OP_HASH) drcuml_log_printf(block->drcuml, "(%X,%X):\n", (UINT32)inst->param[0].value, (UINT32)inst->param[1].value); else { char dasm[256]; drcuml_disasm(&block->inst[instnum], dasm, block->drcuml); if (firstcomment != -1) { drcuml_log_printf(block->drcuml, "\t%-50.50s; %s\n", dasm, get_comment_text(&block->inst[firstcomment])); firstcomment++; flushcomments = TRUE; } else drcuml_log_printf(block->drcuml, "\t%s\n", dasm); } if (firstcomment != -1 && (flushcomments || instnum == block->nextinst - 1)) { while (firstcomment <= instnum) { const char *text = get_comment_text(&block->inst[firstcomment++]); if (text != NULL) drcuml_log_printf(block->drcuml, "\t%50s; %s\n", "", text); } firstcomment = -1; } } drcuml_log_printf(block->drcuml, "\n\n"); fflush(block->drcuml->umllog); }
[ "static", "void", "disassemble_block", "(", "drcuml_block", "*", "block", ")", "{", "int", "firstcomment", "=", "-1", ";", "int", "instnum", ";", "for", "(", "instnum", "=", "0", ";", "instnum", "<", "block", "->", "nextinst", ";", "instnum", "++", ")", "{", "const", "drcuml_instruction", "*", "inst", "=", "&", "block", "->", "inst", "[", "instnum", "]", ";", "int", "flushcomments", "=", "FALSE", ";", "if", "(", "inst", "->", "opcode", "==", "DRCUML_OP_COMMENT", "||", "inst", "->", "opcode", "==", "DRCUML_OP_MAPVAR", ")", "{", "if", "(", "firstcomment", "==", "-1", ")", "firstcomment", "=", "instnum", ";", "}", "else", "if", "(", "inst", "->", "opcode", "==", "DRCUML_OP_LABEL", ")", "drcuml_log_printf", "(", "block", "->", "drcuml", ",", "\"", "\\n", "\"", ",", "(", "UINT32", ")", "inst", "->", "param", "[", "0", "]", ".", "value", ")", ";", "else", "if", "(", "inst", "->", "opcode", "==", "DRCUML_OP_HANDLE", ")", "drcuml_log_printf", "(", "block", "->", "drcuml", ",", "\"", "\\n", "\"", ",", "drcuml_handle_name", "(", "(", "const", "drcuml_codehandle", "*", ")", "(", "FPTR", ")", "inst", "->", "param", "[", "0", "]", ".", "value", ")", ")", ";", "else", "if", "(", "inst", "->", "opcode", "==", "DRCUML_OP_HASH", ")", "drcuml_log_printf", "(", "block", "->", "drcuml", ",", "\"", "\\n", "\"", ",", "(", "UINT32", ")", "inst", "->", "param", "[", "0", "]", ".", "value", ",", "(", "UINT32", ")", "inst", "->", "param", "[", "1", "]", ".", "value", ")", ";", "else", "{", "char", "dasm", "[", "256", "]", ";", "drcuml_disasm", "(", "&", "block", "->", "inst", "[", "instnum", "]", ",", "dasm", ",", "block", "->", "drcuml", ")", ";", "if", "(", "firstcomment", "!=", "-1", ")", "{", "drcuml_log_printf", "(", "block", "->", "drcuml", ",", "\"", "\\t", "\\n", "\"", ",", "dasm", ",", "get_comment_text", "(", "&", "block", "->", "inst", "[", "firstcomment", "]", ")", ")", ";", "firstcomment", "++", ";", "flushcomments", "=", "TRUE", ";", "}", "else", "drcuml_log_printf", "(", "block", "->", "drcuml", ",", "\"", "\\t", "\\n", "\"", ",", "dasm", ")", ";", "}", "if", "(", "firstcomment", "!=", "-1", "&&", "(", "flushcomments", "||", "instnum", "==", "block", "->", "nextinst", "-", "1", ")", ")", "{", "while", "(", "firstcomment", "<=", "instnum", ")", "{", "const", "char", "*", "text", "=", "get_comment_text", "(", "&", "block", "->", "inst", "[", "firstcomment", "++", "]", ")", ";", "if", "(", "text", "!=", "NULL", ")", "drcuml_log_printf", "(", "block", "->", "drcuml", ",", "\"", "\\t", "\\n", "\"", ",", "\"", "\"", ",", "text", ")", ";", "}", "firstcomment", "=", "-1", ";", "}", "}", "drcuml_log_printf", "(", "block", "->", "drcuml", ",", "\"", "\\n", "\\n", "\"", ")", ";", "fflush", "(", "block", "->", "drcuml", "->", "umllog", ")", ";", "}" ]
disassemble_block - disassemble a block of instructions to the log
[ "disassemble_block", "-", "disassemble", "a", "block", "of", "instructions", "to", "the", "log" ]
[ "/* iterate over instructions and output */", "/* remember comments and mapvars for later */", "/* print labels, handles, and hashes left justified */", "/* indent everything else with a tab */", "/* include the first accumulated comment with this line */", "/* flush any comments pending */" ]
[ { "param": "block", "type": "drcuml_block" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
validate_instruction
void
static void validate_instruction(drcuml_block *block, const drcuml_instruction *inst) { const drcuml_opcode_info *opinfo = opcode_info_table[inst->opcode]; int pnum; /* validate raw information */ assert(inst->opcode != DRCUML_OP_INVALID && inst->opcode < DRCUML_OP_MAX); assert(inst->size == 1 || inst->size == 2 || inst->size == 4 || inst->size == 8); /* validate against opcode limits */ assert((opinfo->sizes & inst->size) != 0); assert(inst->condition == DRCUML_COND_ALWAYS || opinfo->condition); /* validate each parameter */ for (pnum = 0; pnum < inst->numparams; pnum++) { const drcuml_parameter *param = &inst->param[pnum]; UINT16 typemask = opinfo->param[pnum].typemask; /* ensure the type is correct */ assert(param->type > DRCUML_PTYPE_NONE && param->type < DRCUML_PTYPE_MAX); assert((typemask >> param->type) & 1); /* validate various parameter types */ switch (param->type) { case DRCUML_PTYPE_MEMORY: /* most memory parameters must be in the near cache */ if (typemask != PTYPES_PTR && typemask != PTYPES_STATE && typemask != PTYPES_STR && typemask != PTYPES_CFUNC) assert_in_near_cache(block->drcuml->cache, (void *)(FPTR)param->value); break; case DRCUML_PTYPE_IMMEDIATE: /* many special parameter types are encoded as immediately; ensure they are in range */ if (typemask == PTYPES_SIZE) assert(param->value >= DRCUML_SIZE_BYTE && param->value <= DRCUML_SIZE_QWORD); else if (typemask == PTYPES_SPACE) assert(param->value >= ADDRESS_SPACE_PROGRAM && param->value <= ADDRESS_SPACE_IO); else if (typemask == PTYPES_SPSZ) { assert(param->value % 16 >= DRCUML_SIZE_BYTE && param->value % 16 <= DRCUML_SIZE_QWORD); assert(param->value / 16 >= ADDRESS_SPACE_PROGRAM && param->value / 16 <= ADDRESS_SPACE_IO); } else if (typemask == PTYPES_FMOD) assert(param->value >= DRCUML_FMOD_TRUNC && param->value <= DRCUML_FMOD_DEFAULT); break; case DRCUML_PTYPE_MAPVAR: assert(param->value >= DRCUML_MAPVAR_M0 && param->value < DRCUML_MAPVAR_END); break; case DRCUML_PTYPE_INT_REGISTER: assert(param->value >= DRCUML_REG_I0 && param->value < DRCUML_REG_I_END); break; case DRCUML_PTYPE_FLOAT_REGISTER: assert(param->value >= DRCUML_REG_F0 && param->value < DRCUML_REG_F_END); break; default: assert(FALSE); break; } } /* make sure we aren't missing any parameters */ if (inst->numparams < ARRAY_LENGTH(opinfo->param)) assert(opinfo->param[inst->numparams].typemask == 0); }
/*------------------------------------------------- validate_instruction - verify that the instruction created meets all requirements -------------------------------------------------*/
verify that the instruction created meets all requirements
[ "verify", "that", "the", "instruction", "created", "meets", "all", "requirements" ]
static void validate_instruction(drcuml_block *block, const drcuml_instruction *inst) { const drcuml_opcode_info *opinfo = opcode_info_table[inst->opcode]; int pnum; assert(inst->opcode != DRCUML_OP_INVALID && inst->opcode < DRCUML_OP_MAX); assert(inst->size == 1 || inst->size == 2 || inst->size == 4 || inst->size == 8); assert((opinfo->sizes & inst->size) != 0); assert(inst->condition == DRCUML_COND_ALWAYS || opinfo->condition); for (pnum = 0; pnum < inst->numparams; pnum++) { const drcuml_parameter *param = &inst->param[pnum]; UINT16 typemask = opinfo->param[pnum].typemask; assert(param->type > DRCUML_PTYPE_NONE && param->type < DRCUML_PTYPE_MAX); assert((typemask >> param->type) & 1); switch (param->type) { case DRCUML_PTYPE_MEMORY: if (typemask != PTYPES_PTR && typemask != PTYPES_STATE && typemask != PTYPES_STR && typemask != PTYPES_CFUNC) assert_in_near_cache(block->drcuml->cache, (void *)(FPTR)param->value); break; case DRCUML_PTYPE_IMMEDIATE: if (typemask == PTYPES_SIZE) assert(param->value >= DRCUML_SIZE_BYTE && param->value <= DRCUML_SIZE_QWORD); else if (typemask == PTYPES_SPACE) assert(param->value >= ADDRESS_SPACE_PROGRAM && param->value <= ADDRESS_SPACE_IO); else if (typemask == PTYPES_SPSZ) { assert(param->value % 16 >= DRCUML_SIZE_BYTE && param->value % 16 <= DRCUML_SIZE_QWORD); assert(param->value / 16 >= ADDRESS_SPACE_PROGRAM && param->value / 16 <= ADDRESS_SPACE_IO); } else if (typemask == PTYPES_FMOD) assert(param->value >= DRCUML_FMOD_TRUNC && param->value <= DRCUML_FMOD_DEFAULT); break; case DRCUML_PTYPE_MAPVAR: assert(param->value >= DRCUML_MAPVAR_M0 && param->value < DRCUML_MAPVAR_END); break; case DRCUML_PTYPE_INT_REGISTER: assert(param->value >= DRCUML_REG_I0 && param->value < DRCUML_REG_I_END); break; case DRCUML_PTYPE_FLOAT_REGISTER: assert(param->value >= DRCUML_REG_F0 && param->value < DRCUML_REG_F_END); break; default: assert(FALSE); break; } } if (inst->numparams < ARRAY_LENGTH(opinfo->param)) assert(opinfo->param[inst->numparams].typemask == 0); }
[ "static", "void", "validate_instruction", "(", "drcuml_block", "*", "block", ",", "const", "drcuml_instruction", "*", "inst", ")", "{", "const", "drcuml_opcode_info", "*", "opinfo", "=", "opcode_info_table", "[", "inst", "->", "opcode", "]", ";", "int", "pnum", ";", "assert", "(", "inst", "->", "opcode", "!=", "DRCUML_OP_INVALID", "&&", "inst", "->", "opcode", "<", "DRCUML_OP_MAX", ")", ";", "assert", "(", "inst", "->", "size", "==", "1", "||", "inst", "->", "size", "==", "2", "||", "inst", "->", "size", "==", "4", "||", "inst", "->", "size", "==", "8", ")", ";", "assert", "(", "(", "opinfo", "->", "sizes", "&", "inst", "->", "size", ")", "!=", "0", ")", ";", "assert", "(", "inst", "->", "condition", "==", "DRCUML_COND_ALWAYS", "||", "opinfo", "->", "condition", ")", ";", "for", "(", "pnum", "=", "0", ";", "pnum", "<", "inst", "->", "numparams", ";", "pnum", "++", ")", "{", "const", "drcuml_parameter", "*", "param", "=", "&", "inst", "->", "param", "[", "pnum", "]", ";", "UINT16", "typemask", "=", "opinfo", "->", "param", "[", "pnum", "]", ".", "typemask", ";", "assert", "(", "param", "->", "type", ">", "DRCUML_PTYPE_NONE", "&&", "param", "->", "type", "<", "DRCUML_PTYPE_MAX", ")", ";", "assert", "(", "(", "typemask", ">>", "param", "->", "type", ")", "&", "1", ")", ";", "switch", "(", "param", "->", "type", ")", "{", "case", "DRCUML_PTYPE_MEMORY", ":", "if", "(", "typemask", "!=", "PTYPES_PTR", "&&", "typemask", "!=", "PTYPES_STATE", "&&", "typemask", "!=", "PTYPES_STR", "&&", "typemask", "!=", "PTYPES_CFUNC", ")", "assert_in_near_cache", "(", "block", "->", "drcuml", "->", "cache", ",", "(", "void", "*", ")", "(", "FPTR", ")", "param", "->", "value", ")", ";", "break", ";", "case", "DRCUML_PTYPE_IMMEDIATE", ":", "if", "(", "typemask", "==", "PTYPES_SIZE", ")", "assert", "(", "param", "->", "value", ">=", "DRCUML_SIZE_BYTE", "&&", "param", "->", "value", "<=", "DRCUML_SIZE_QWORD", ")", ";", "else", "if", "(", "typemask", "==", "PTYPES_SPACE", ")", "assert", "(", "param", "->", "value", ">=", "ADDRESS_SPACE_PROGRAM", "&&", "param", "->", "value", "<=", "ADDRESS_SPACE_IO", ")", ";", "else", "if", "(", "typemask", "==", "PTYPES_SPSZ", ")", "{", "assert", "(", "param", "->", "value", "%", "16", ">=", "DRCUML_SIZE_BYTE", "&&", "param", "->", "value", "%", "16", "<=", "DRCUML_SIZE_QWORD", ")", ";", "assert", "(", "param", "->", "value", "/", "16", ">=", "ADDRESS_SPACE_PROGRAM", "&&", "param", "->", "value", "/", "16", "<=", "ADDRESS_SPACE_IO", ")", ";", "}", "else", "if", "(", "typemask", "==", "PTYPES_FMOD", ")", "assert", "(", "param", "->", "value", ">=", "DRCUML_FMOD_TRUNC", "&&", "param", "->", "value", "<=", "DRCUML_FMOD_DEFAULT", ")", ";", "break", ";", "case", "DRCUML_PTYPE_MAPVAR", ":", "assert", "(", "param", "->", "value", ">=", "DRCUML_MAPVAR_M0", "&&", "param", "->", "value", "<", "DRCUML_MAPVAR_END", ")", ";", "break", ";", "case", "DRCUML_PTYPE_INT_REGISTER", ":", "assert", "(", "param", "->", "value", ">=", "DRCUML_REG_I0", "&&", "param", "->", "value", "<", "DRCUML_REG_I_END", ")", ";", "break", ";", "case", "DRCUML_PTYPE_FLOAT_REGISTER", ":", "assert", "(", "param", "->", "value", ">=", "DRCUML_REG_F0", "&&", "param", "->", "value", "<", "DRCUML_REG_F_END", ")", ";", "break", ";", "default", ":", "assert", "(", "FALSE", ")", ";", "break", ";", "}", "}", "if", "(", "inst", "->", "numparams", "<", "ARRAY_LENGTH", "(", "opinfo", "->", "param", ")", ")", "assert", "(", "opinfo", "->", "param", "[", "inst", "->", "numparams", "]", ".", "typemask", "==", "0", ")", ";", "}" ]
validate_instruction - verify that the instruction created meets all requirements
[ "validate_instruction", "-", "verify", "that", "the", "instruction", "created", "meets", "all", "requirements" ]
[ "/* validate raw information */", "/* validate against opcode limits */", "/* validate each parameter */", "/* ensure the type is correct */", "/* validate various parameter types */", "/* most memory parameters must be in the near cache */", "/* many special parameter types are encoded as immediately; ensure they are in range */", "/* make sure we aren't missing any parameters */" ]
[ { "param": "block", "type": "drcuml_block" }, { "param": "inst", "type": "drcuml_instruction" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "inst", "type": "drcuml_instruction", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
validate_backend
void
static void validate_backend(drcuml_state *drcuml) { drcuml_codehandle *handles[3]; int tnum; /* allocate handles for the code */ handles[0] = drcuml_handle_alloc(drcuml, "test_entry"); handles[1] = drcuml_handle_alloc(drcuml, "code_start"); handles[2] = drcuml_handle_alloc(drcuml, "code_end"); /* iterate over test entries */ printf("Backend validation....\n"); for (tnum = 31; tnum < ARRAY_LENGTH(bevalidate_test_list); tnum++) { const bevalidate_test *test = &bevalidate_test_list[tnum]; drcuml_parameter param[ARRAY_LENGTH(test->param)]; char mnemonic[20], *dst; const char *src; /* progress */ dst = mnemonic; for (src = opcode_info_table[test->opcode]->mnemonic; *src != 0; src++) { if (*src == '!') { if (test->size == 8) *dst++ = 'd'; } else if (*src == '#') *dst++ = (test->size == 8) ? 'd' : 's'; else *dst++ = *src; } *dst = 0; printf("Executing test %d/%d (%s)", tnum + 1, (int)ARRAY_LENGTH(bevalidate_test_list), mnemonic); /* reset parameter list and iterate */ memset(param, 0, sizeof(param)); bevalidate_iterate_over_params(drcuml, handles, test, param, 0); printf("\n"); } fatalerror("All tests passed!"); }
/*------------------------------------------------- validate_backend - execute a number of generic tests on the backend code generator -------------------------------------------------*/
execute a number of generic tests on the backend code generator
[ "execute", "a", "number", "of", "generic", "tests", "on", "the", "backend", "code", "generator" ]
static void validate_backend(drcuml_state *drcuml) { drcuml_codehandle *handles[3]; int tnum; handles[0] = drcuml_handle_alloc(drcuml, "test_entry"); handles[1] = drcuml_handle_alloc(drcuml, "code_start"); handles[2] = drcuml_handle_alloc(drcuml, "code_end"); printf("Backend validation....\n"); for (tnum = 31; tnum < ARRAY_LENGTH(bevalidate_test_list); tnum++) { const bevalidate_test *test = &bevalidate_test_list[tnum]; drcuml_parameter param[ARRAY_LENGTH(test->param)]; char mnemonic[20], *dst; const char *src; dst = mnemonic; for (src = opcode_info_table[test->opcode]->mnemonic; *src != 0; src++) { if (*src == '!') { if (test->size == 8) *dst++ = 'd'; } else if (*src == '#') *dst++ = (test->size == 8) ? 'd' : 's'; else *dst++ = *src; } *dst = 0; printf("Executing test %d/%d (%s)", tnum + 1, (int)ARRAY_LENGTH(bevalidate_test_list), mnemonic); memset(param, 0, sizeof(param)); bevalidate_iterate_over_params(drcuml, handles, test, param, 0); printf("\n"); } fatalerror("All tests passed!"); }
[ "static", "void", "validate_backend", "(", "drcuml_state", "*", "drcuml", ")", "{", "drcuml_codehandle", "*", "handles", "[", "3", "]", ";", "int", "tnum", ";", "handles", "[", "0", "]", "=", "drcuml_handle_alloc", "(", "drcuml", ",", "\"", "\"", ")", ";", "handles", "[", "1", "]", "=", "drcuml_handle_alloc", "(", "drcuml", ",", "\"", "\"", ")", ";", "handles", "[", "2", "]", "=", "drcuml_handle_alloc", "(", "drcuml", ",", "\"", "\"", ")", ";", "printf", "(", "\"", "\\n", "\"", ")", ";", "for", "(", "tnum", "=", "31", ";", "tnum", "<", "ARRAY_LENGTH", "(", "bevalidate_test_list", ")", ";", "tnum", "++", ")", "{", "const", "bevalidate_test", "*", "test", "=", "&", "bevalidate_test_list", "[", "tnum", "]", ";", "drcuml_parameter", "param", "[", "ARRAY_LENGTH", "(", "test", "->", "param", ")", "]", ";", "char", "mnemonic", "[", "20", "]", ",", "*", "dst", ";", "const", "char", "*", "src", ";", "dst", "=", "mnemonic", ";", "for", "(", "src", "=", "opcode_info_table", "[", "test", "->", "opcode", "]", "->", "mnemonic", ";", "*", "src", "!=", "0", ";", "src", "++", ")", "{", "if", "(", "*", "src", "==", "'", "'", ")", "{", "if", "(", "test", "->", "size", "==", "8", ")", "*", "dst", "++", "=", "'", "'", ";", "}", "else", "if", "(", "*", "src", "==", "'", "'", ")", "*", "dst", "++", "=", "(", "test", "->", "size", "==", "8", ")", "?", "'", "'", ":", "'", "'", ";", "else", "*", "dst", "++", "=", "*", "src", ";", "}", "*", "dst", "=", "0", ";", "printf", "(", "\"", "\"", ",", "tnum", "+", "1", ",", "(", "int", ")", "ARRAY_LENGTH", "(", "bevalidate_test_list", ")", ",", "mnemonic", ")", ";", "memset", "(", "param", ",", "0", ",", "sizeof", "(", "param", ")", ")", ";", "bevalidate_iterate_over_params", "(", "drcuml", ",", "handles", ",", "test", ",", "param", ",", "0", ")", ";", "printf", "(", "\"", "\\n", "\"", ")", ";", "}", "fatalerror", "(", "\"", "\"", ")", ";", "}" ]
validate_backend - execute a number of generic tests on the backend code generator
[ "validate_backend", "-", "execute", "a", "number", "of", "generic", "tests", "on", "the", "backend", "code", "generator" ]
[ "/* allocate handles for the code */", "/* iterate over test entries */", "/* progress */", "/* reset parameter list and iterate */" ]
[ { "param": "drcuml", "type": "drcuml_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "drcuml", "type": "drcuml_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
bevalidate_iterate_over_params
void
static void bevalidate_iterate_over_params(drcuml_state *drcuml, drcuml_codehandle **handles, const bevalidate_test *test, drcuml_parameter *paramlist, int pnum) { const drcuml_opcode_info *opinfo = opcode_info_table[test->opcode]; drcuml_ptype ptype; /* if no parameters, execute now */ if (pnum >= ARRAY_LENGTH(opinfo->param) || opinfo->param[pnum].typemask == PTYPES_NONE) { bevalidate_iterate_over_flags(drcuml, handles, test, paramlist); return; } /* iterate over valid parameter types */ for (ptype = DRCUML_PTYPE_IMMEDIATE; ptype < DRCUML_PTYPE_MAX; ptype++) if (opinfo->param[pnum].typemask & (1 << ptype)) { int pindex, pcount; /* mapvars can only do 32-bit tests */ if (ptype == DRCUML_PTYPE_MAPVAR && effective_test_psize(opinfo, pnum, test->size, test->param) == 8) continue; /* for some parameter types, we wish to iterate over all possibilities */ switch (ptype) { case DRCUML_PTYPE_INT_REGISTER: pcount = DRCUML_REG_I_END - DRCUML_REG_I0; break; case DRCUML_PTYPE_FLOAT_REGISTER: pcount = DRCUML_REG_F_END - DRCUML_REG_F0; break; default: pcount = 1; break; } /* iterate over possibilities */ for (pindex = 0; pindex < pcount; pindex++) { int skip = FALSE; int pscannum; /* for param 0, print a dot */ if (pnum == 0) printf("."); /* can't duplicate multiple source parameters unless they are immediates */ if (ptype != DRCUML_PTYPE_IMMEDIATE && (opinfo->param[pnum].output & PIO_IN)) /* loop over all parameters we've done before; if the parameter is a source and matches us, skip this case */ for (pscannum = 0; pscannum < pnum; pscannum++) if ((opinfo->param[pscannum].output & PIO_IN) && ptype == paramlist[pscannum].type && pindex == paramlist[pscannum].value) skip = TRUE; /* can't duplicate multiple dest parameters */ if (opinfo->param[pnum].output & PIO_OUT) /* loop over all parameters we've done before; if the parameter is a source and matches us, skip this case */ for (pscannum = 0; pscannum < pnum; pscannum++) if ((opinfo->param[pscannum].output & PIO_OUT) && ptype == paramlist[pscannum].type && pindex == paramlist[pscannum].value) skip = TRUE; /* iterate over the next parameter in line */ if (!skip) { paramlist[pnum].type = ptype; paramlist[pnum].value = pindex; bevalidate_iterate_over_params(drcuml, handles, test, paramlist, pnum + 1); } } } }
/*------------------------------------------------- bevalidate_iterate_over_params - iterate over all supported types and values of a parameter and recursively hand off to the next parameter, or else move on to iterate over the flags -------------------------------------------------*/
iterate over all supported types and values of a parameter and recursively hand off to the next parameter, or else move on to iterate over the flags
[ "iterate", "over", "all", "supported", "types", "and", "values", "of", "a", "parameter", "and", "recursively", "hand", "off", "to", "the", "next", "parameter", "or", "else", "move", "on", "to", "iterate", "over", "the", "flags" ]
static void bevalidate_iterate_over_params(drcuml_state *drcuml, drcuml_codehandle **handles, const bevalidate_test *test, drcuml_parameter *paramlist, int pnum) { const drcuml_opcode_info *opinfo = opcode_info_table[test->opcode]; drcuml_ptype ptype; if (pnum >= ARRAY_LENGTH(opinfo->param) || opinfo->param[pnum].typemask == PTYPES_NONE) { bevalidate_iterate_over_flags(drcuml, handles, test, paramlist); return; } for (ptype = DRCUML_PTYPE_IMMEDIATE; ptype < DRCUML_PTYPE_MAX; ptype++) if (opinfo->param[pnum].typemask & (1 << ptype)) { int pindex, pcount; if (ptype == DRCUML_PTYPE_MAPVAR && effective_test_psize(opinfo, pnum, test->size, test->param) == 8) continue; switch (ptype) { case DRCUML_PTYPE_INT_REGISTER: pcount = DRCUML_REG_I_END - DRCUML_REG_I0; break; case DRCUML_PTYPE_FLOAT_REGISTER: pcount = DRCUML_REG_F_END - DRCUML_REG_F0; break; default: pcount = 1; break; } for (pindex = 0; pindex < pcount; pindex++) { int skip = FALSE; int pscannum; if (pnum == 0) printf("."); if (ptype != DRCUML_PTYPE_IMMEDIATE && (opinfo->param[pnum].output & PIO_IN)) for (pscannum = 0; pscannum < pnum; pscannum++) if ((opinfo->param[pscannum].output & PIO_IN) && ptype == paramlist[pscannum].type && pindex == paramlist[pscannum].value) skip = TRUE; if (opinfo->param[pnum].output & PIO_OUT) for (pscannum = 0; pscannum < pnum; pscannum++) if ((opinfo->param[pscannum].output & PIO_OUT) && ptype == paramlist[pscannum].type && pindex == paramlist[pscannum].value) skip = TRUE; if (!skip) { paramlist[pnum].type = ptype; paramlist[pnum].value = pindex; bevalidate_iterate_over_params(drcuml, handles, test, paramlist, pnum + 1); } } } }
[ "static", "void", "bevalidate_iterate_over_params", "(", "drcuml_state", "*", "drcuml", ",", "drcuml_codehandle", "*", "*", "handles", ",", "const", "bevalidate_test", "*", "test", ",", "drcuml_parameter", "*", "paramlist", ",", "int", "pnum", ")", "{", "const", "drcuml_opcode_info", "*", "opinfo", "=", "opcode_info_table", "[", "test", "->", "opcode", "]", ";", "drcuml_ptype", "ptype", ";", "if", "(", "pnum", ">=", "ARRAY_LENGTH", "(", "opinfo", "->", "param", ")", "||", "opinfo", "->", "param", "[", "pnum", "]", ".", "typemask", "==", "PTYPES_NONE", ")", "{", "bevalidate_iterate_over_flags", "(", "drcuml", ",", "handles", ",", "test", ",", "paramlist", ")", ";", "return", ";", "}", "for", "(", "ptype", "=", "DRCUML_PTYPE_IMMEDIATE", ";", "ptype", "<", "DRCUML_PTYPE_MAX", ";", "ptype", "++", ")", "if", "(", "opinfo", "->", "param", "[", "pnum", "]", ".", "typemask", "&", "(", "1", "<<", "ptype", ")", ")", "{", "int", "pindex", ",", "pcount", ";", "if", "(", "ptype", "==", "DRCUML_PTYPE_MAPVAR", "&&", "effective_test_psize", "(", "opinfo", ",", "pnum", ",", "test", "->", "size", ",", "test", "->", "param", ")", "==", "8", ")", "continue", ";", "switch", "(", "ptype", ")", "{", "case", "DRCUML_PTYPE_INT_REGISTER", ":", "pcount", "=", "DRCUML_REG_I_END", "-", "DRCUML_REG_I0", ";", "break", ";", "case", "DRCUML_PTYPE_FLOAT_REGISTER", ":", "pcount", "=", "DRCUML_REG_F_END", "-", "DRCUML_REG_F0", ";", "break", ";", "default", ":", "pcount", "=", "1", ";", "break", ";", "}", "for", "(", "pindex", "=", "0", ";", "pindex", "<", "pcount", ";", "pindex", "++", ")", "{", "int", "skip", "=", "FALSE", ";", "int", "pscannum", ";", "if", "(", "pnum", "==", "0", ")", "printf", "(", "\"", "\"", ")", ";", "if", "(", "ptype", "!=", "DRCUML_PTYPE_IMMEDIATE", "&&", "(", "opinfo", "->", "param", "[", "pnum", "]", ".", "output", "&", "PIO_IN", ")", ")", "for", "(", "pscannum", "=", "0", ";", "pscannum", "<", "pnum", ";", "pscannum", "++", ")", "if", "(", "(", "opinfo", "->", "param", "[", "pscannum", "]", ".", "output", "&", "PIO_IN", ")", "&&", "ptype", "==", "paramlist", "[", "pscannum", "]", ".", "type", "&&", "pindex", "==", "paramlist", "[", "pscannum", "]", ".", "value", ")", "skip", "=", "TRUE", ";", "if", "(", "opinfo", "->", "param", "[", "pnum", "]", ".", "output", "&", "PIO_OUT", ")", "for", "(", "pscannum", "=", "0", ";", "pscannum", "<", "pnum", ";", "pscannum", "++", ")", "if", "(", "(", "opinfo", "->", "param", "[", "pscannum", "]", ".", "output", "&", "PIO_OUT", ")", "&&", "ptype", "==", "paramlist", "[", "pscannum", "]", ".", "type", "&&", "pindex", "==", "paramlist", "[", "pscannum", "]", ".", "value", ")", "skip", "=", "TRUE", ";", "if", "(", "!", "skip", ")", "{", "paramlist", "[", "pnum", "]", ".", "type", "=", "ptype", ";", "paramlist", "[", "pnum", "]", ".", "value", "=", "pindex", ";", "bevalidate_iterate_over_params", "(", "drcuml", ",", "handles", ",", "test", ",", "paramlist", ",", "pnum", "+", "1", ")", ";", "}", "}", "}", "}" ]
bevalidate_iterate_over_params - iterate over all supported types and values of a parameter and recursively hand off to the next parameter, or else move on to iterate over the flags
[ "bevalidate_iterate_over_params", "-", "iterate", "over", "all", "supported", "types", "and", "values", "of", "a", "parameter", "and", "recursively", "hand", "off", "to", "the", "next", "parameter", "or", "else", "move", "on", "to", "iterate", "over", "the", "flags" ]
[ "/* if no parameters, execute now */", "/* iterate over valid parameter types */", "/* mapvars can only do 32-bit tests */", "/* for some parameter types, we wish to iterate over all possibilities */", "/* iterate over possibilities */", "/* for param 0, print a dot */", "/* can't duplicate multiple source parameters unless they are immediates */", "/* loop over all parameters we've done before; if the parameter is a source and matches us, skip this case */", "/* can't duplicate multiple dest parameters */", "/* loop over all parameters we've done before; if the parameter is a source and matches us, skip this case */", "/* iterate over the next parameter in line */" ]
[ { "param": "drcuml", "type": "drcuml_state" }, { "param": "handles", "type": "drcuml_codehandle" }, { "param": "test", "type": "bevalidate_test" }, { "param": "paramlist", "type": "drcuml_parameter" }, { "param": "pnum", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "drcuml", "type": "drcuml_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "handles", "type": "drcuml_codehandle", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "test", "type": "bevalidate_test", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "paramlist", "type": "drcuml_parameter", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pnum", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
bevalidate_iterate_over_flags
void
static void bevalidate_iterate_over_flags(drcuml_state *drcuml, drcuml_codehandle **handles, const bevalidate_test *test, drcuml_parameter *paramlist) { const drcuml_opcode_info *opinfo = opcode_info_table[test->opcode]; UINT8 flagmask = opinfo->outflags; UINT8 curmask; /* iterate over all possible flag combinations */ for (curmask = 0; curmask <= flagmask; curmask++) if ((curmask & flagmask) == curmask) bevalidate_execute(drcuml, handles, test, paramlist, curmask); }
/*------------------------------------------------- bevalidate_iterate_over_flags - iterate over all supported flag masks -------------------------------------------------*/
iterate over all supported flag masks
[ "iterate", "over", "all", "supported", "flag", "masks" ]
static void bevalidate_iterate_over_flags(drcuml_state *drcuml, drcuml_codehandle **handles, const bevalidate_test *test, drcuml_parameter *paramlist) { const drcuml_opcode_info *opinfo = opcode_info_table[test->opcode]; UINT8 flagmask = opinfo->outflags; UINT8 curmask; for (curmask = 0; curmask <= flagmask; curmask++) if ((curmask & flagmask) == curmask) bevalidate_execute(drcuml, handles, test, paramlist, curmask); }
[ "static", "void", "bevalidate_iterate_over_flags", "(", "drcuml_state", "*", "drcuml", ",", "drcuml_codehandle", "*", "*", "handles", ",", "const", "bevalidate_test", "*", "test", ",", "drcuml_parameter", "*", "paramlist", ")", "{", "const", "drcuml_opcode_info", "*", "opinfo", "=", "opcode_info_table", "[", "test", "->", "opcode", "]", ";", "UINT8", "flagmask", "=", "opinfo", "->", "outflags", ";", "UINT8", "curmask", ";", "for", "(", "curmask", "=", "0", ";", "curmask", "<=", "flagmask", ";", "curmask", "++", ")", "if", "(", "(", "curmask", "&", "flagmask", ")", "==", "curmask", ")", "bevalidate_execute", "(", "drcuml", ",", "handles", ",", "test", ",", "paramlist", ",", "curmask", ")", ";", "}" ]
bevalidate_iterate_over_flags - iterate over all supported flag masks
[ "bevalidate_iterate_over_flags", "-", "iterate", "over", "all", "supported", "flag", "masks" ]
[ "/* iterate over all possible flag combinations */" ]
[ { "param": "drcuml", "type": "drcuml_state" }, { "param": "handles", "type": "drcuml_codehandle" }, { "param": "test", "type": "bevalidate_test" }, { "param": "paramlist", "type": "drcuml_parameter" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "drcuml", "type": "drcuml_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "handles", "type": "drcuml_codehandle", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "test", "type": "bevalidate_test", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "paramlist", "type": "drcuml_parameter", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
bevalidate_execute
void
static void bevalidate_execute(drcuml_state *drcuml, drcuml_codehandle **handles, const bevalidate_test *test, const drcuml_parameter *paramlist, UINT8 flagmask) { drcuml_parameter params[ARRAY_LENGTH(test->param)]; drcuml_machine_state istate, fstate; drcuml_instruction testinst; drcuml_block *block; UINT64 *parammem; int numparams; /* allocate memory for parameters */ parammem = (UINT64 *)drccache_memory_alloc_near(drcuml->cache, sizeof(UINT64) * (ARRAY_LENGTH(test->param) + 1)); /* flush the cache */ drcuml_reset(drcuml); /* start a new block */ block = drcuml_block_begin(drcuml, 30, NULL); UML_HANDLE(block, handles[0]); /* set up a random initial state */ bevalidate_initialize_random_state(drcuml, block, &istate); /* then populate the state with the parameters */ numparams = bevalidate_populate_state(block, &istate, test, paramlist, params, parammem); /* generate the code */ UML_RESTORE(block, &istate); UML_HANDLE(block, handles[1]); switch (numparams) { case 0: drcuml_block_append_0(block, test->opcode, test->size, DRCUML_COND_ALWAYS); break; case 1: drcuml_block_append_1(block, test->opcode, test->size, DRCUML_COND_ALWAYS, params[0].type, params[0].value); break; case 2: drcuml_block_append_2(block, test->opcode, test->size, DRCUML_COND_ALWAYS, params[0].type, params[0].value, params[1].type, params[1].value); break; case 3: drcuml_block_append_3(block, test->opcode, test->size, DRCUML_COND_ALWAYS, params[0].type, params[0].value, params[1].type, params[1].value, params[2].type, params[2].value); break; case 4: drcuml_block_append_4(block, test->opcode, test->size, DRCUML_COND_ALWAYS, params[0].type, params[0].value, params[1].type, params[1].value, params[2].type, params[2].value, params[3].type, params[3].value); break; } testinst = block->inst[block->nextinst - 1]; UML_HANDLE(block, handles[2]); UML_GETFLGS(block, MEM(&parammem[ARRAY_LENGTH(test->param)]), flagmask); UML_SAVE(block, &fstate); UML_EXIT(block, IMM(0)); /* end the block */ drcuml_block_end(block); /* execute */ drcuml_execute(drcuml, handles[0]); /* verify the results */ bevalidate_verify_state(drcuml, &istate, &fstate, test, *(UINT32 *)&parammem[ARRAY_LENGTH(test->param)], params, &testinst, handles[1]->code, handles[2]->code, flagmask); /* free memory */ drccache_memory_free(drcuml->cache, parammem, sizeof(UINT64) * (ARRAY_LENGTH(test->param) + 1)); }
/*------------------------------------------------- bevalidate_execute - execute a single instance of a test, generating code and verifying the results -------------------------------------------------*/
execute a single instance of a test, generating code and verifying the results
[ "execute", "a", "single", "instance", "of", "a", "test", "generating", "code", "and", "verifying", "the", "results" ]
static void bevalidate_execute(drcuml_state *drcuml, drcuml_codehandle **handles, const bevalidate_test *test, const drcuml_parameter *paramlist, UINT8 flagmask) { drcuml_parameter params[ARRAY_LENGTH(test->param)]; drcuml_machine_state istate, fstate; drcuml_instruction testinst; drcuml_block *block; UINT64 *parammem; int numparams; parammem = (UINT64 *)drccache_memory_alloc_near(drcuml->cache, sizeof(UINT64) * (ARRAY_LENGTH(test->param) + 1)); drcuml_reset(drcuml); block = drcuml_block_begin(drcuml, 30, NULL); UML_HANDLE(block, handles[0]); bevalidate_initialize_random_state(drcuml, block, &istate); numparams = bevalidate_populate_state(block, &istate, test, paramlist, params, parammem); UML_RESTORE(block, &istate); UML_HANDLE(block, handles[1]); switch (numparams) { case 0: drcuml_block_append_0(block, test->opcode, test->size, DRCUML_COND_ALWAYS); break; case 1: drcuml_block_append_1(block, test->opcode, test->size, DRCUML_COND_ALWAYS, params[0].type, params[0].value); break; case 2: drcuml_block_append_2(block, test->opcode, test->size, DRCUML_COND_ALWAYS, params[0].type, params[0].value, params[1].type, params[1].value); break; case 3: drcuml_block_append_3(block, test->opcode, test->size, DRCUML_COND_ALWAYS, params[0].type, params[0].value, params[1].type, params[1].value, params[2].type, params[2].value); break; case 4: drcuml_block_append_4(block, test->opcode, test->size, DRCUML_COND_ALWAYS, params[0].type, params[0].value, params[1].type, params[1].value, params[2].type, params[2].value, params[3].type, params[3].value); break; } testinst = block->inst[block->nextinst - 1]; UML_HANDLE(block, handles[2]); UML_GETFLGS(block, MEM(&parammem[ARRAY_LENGTH(test->param)]), flagmask); UML_SAVE(block, &fstate); UML_EXIT(block, IMM(0)); drcuml_block_end(block); drcuml_execute(drcuml, handles[0]); bevalidate_verify_state(drcuml, &istate, &fstate, test, *(UINT32 *)&parammem[ARRAY_LENGTH(test->param)], params, &testinst, handles[1]->code, handles[2]->code, flagmask); drccache_memory_free(drcuml->cache, parammem, sizeof(UINT64) * (ARRAY_LENGTH(test->param) + 1)); }
[ "static", "void", "bevalidate_execute", "(", "drcuml_state", "*", "drcuml", ",", "drcuml_codehandle", "*", "*", "handles", ",", "const", "bevalidate_test", "*", "test", ",", "const", "drcuml_parameter", "*", "paramlist", ",", "UINT8", "flagmask", ")", "{", "drcuml_parameter", "params", "[", "ARRAY_LENGTH", "(", "test", "->", "param", ")", "]", ";", "drcuml_machine_state", "istate", ",", "fstate", ";", "drcuml_instruction", "testinst", ";", "drcuml_block", "*", "block", ";", "UINT64", "*", "parammem", ";", "int", "numparams", ";", "parammem", "=", "(", "UINT64", "*", ")", "drccache_memory_alloc_near", "(", "drcuml", "->", "cache", ",", "sizeof", "(", "UINT64", ")", "*", "(", "ARRAY_LENGTH", "(", "test", "->", "param", ")", "+", "1", ")", ")", ";", "drcuml_reset", "(", "drcuml", ")", ";", "block", "=", "drcuml_block_begin", "(", "drcuml", ",", "30", ",", "NULL", ")", ";", "UML_HANDLE", "(", "block", ",", "handles", "[", "0", "]", ")", ";", "bevalidate_initialize_random_state", "(", "drcuml", ",", "block", ",", "&", "istate", ")", ";", "numparams", "=", "bevalidate_populate_state", "(", "block", ",", "&", "istate", ",", "test", ",", "paramlist", ",", "params", ",", "parammem", ")", ";", "UML_RESTORE", "(", "block", ",", "&", "istate", ")", ";", "UML_HANDLE", "(", "block", ",", "handles", "[", "1", "]", ")", ";", "switch", "(", "numparams", ")", "{", "case", "0", ":", "drcuml_block_append_0", "(", "block", ",", "test", "->", "opcode", ",", "test", "->", "size", ",", "DRCUML_COND_ALWAYS", ")", ";", "break", ";", "case", "1", ":", "drcuml_block_append_1", "(", "block", ",", "test", "->", "opcode", ",", "test", "->", "size", ",", "DRCUML_COND_ALWAYS", ",", "params", "[", "0", "]", ".", "type", ",", "params", "[", "0", "]", ".", "value", ")", ";", "break", ";", "case", "2", ":", "drcuml_block_append_2", "(", "block", ",", "test", "->", "opcode", ",", "test", "->", "size", ",", "DRCUML_COND_ALWAYS", ",", "params", "[", "0", "]", ".", "type", ",", "params", "[", "0", "]", ".", "value", ",", "params", "[", "1", "]", ".", "type", ",", "params", "[", "1", "]", ".", "value", ")", ";", "break", ";", "case", "3", ":", "drcuml_block_append_3", "(", "block", ",", "test", "->", "opcode", ",", "test", "->", "size", ",", "DRCUML_COND_ALWAYS", ",", "params", "[", "0", "]", ".", "type", ",", "params", "[", "0", "]", ".", "value", ",", "params", "[", "1", "]", ".", "type", ",", "params", "[", "1", "]", ".", "value", ",", "params", "[", "2", "]", ".", "type", ",", "params", "[", "2", "]", ".", "value", ")", ";", "break", ";", "case", "4", ":", "drcuml_block_append_4", "(", "block", ",", "test", "->", "opcode", ",", "test", "->", "size", ",", "DRCUML_COND_ALWAYS", ",", "params", "[", "0", "]", ".", "type", ",", "params", "[", "0", "]", ".", "value", ",", "params", "[", "1", "]", ".", "type", ",", "params", "[", "1", "]", ".", "value", ",", "params", "[", "2", "]", ".", "type", ",", "params", "[", "2", "]", ".", "value", ",", "params", "[", "3", "]", ".", "type", ",", "params", "[", "3", "]", ".", "value", ")", ";", "break", ";", "}", "testinst", "=", "block", "->", "inst", "[", "block", "->", "nextinst", "-", "1", "]", ";", "UML_HANDLE", "(", "block", ",", "handles", "[", "2", "]", ")", ";", "UML_GETFLGS", "(", "block", ",", "MEM", "(", "&", "parammem", "[", "ARRAY_LENGTH", "(", "test", "->", "param", ")", "]", ")", ",", "flagmask", ")", ";", "UML_SAVE", "(", "block", ",", "&", "fstate", ")", ";", "UML_EXIT", "(", "block", ",", "IMM", "(", "0", ")", ")", ";", "drcuml_block_end", "(", "block", ")", ";", "drcuml_execute", "(", "drcuml", ",", "handles", "[", "0", "]", ")", ";", "bevalidate_verify_state", "(", "drcuml", ",", "&", "istate", ",", "&", "fstate", ",", "test", ",", "*", "(", "UINT32", "*", ")", "&", "parammem", "[", "ARRAY_LENGTH", "(", "test", "->", "param", ")", "]", ",", "params", ",", "&", "testinst", ",", "handles", "[", "1", "]", "->", "code", ",", "handles", "[", "2", "]", "->", "code", ",", "flagmask", ")", ";", "drccache_memory_free", "(", "drcuml", "->", "cache", ",", "parammem", ",", "sizeof", "(", "UINT64", ")", "*", "(", "ARRAY_LENGTH", "(", "test", "->", "param", ")", "+", "1", ")", ")", ";", "}" ]
bevalidate_execute - execute a single instance of a test, generating code and verifying the results
[ "bevalidate_execute", "-", "execute", "a", "single", "instance", "of", "a", "test", "generating", "code", "and", "verifying", "the", "results" ]
[ "/* allocate memory for parameters */", "/* flush the cache */", "/* start a new block */", "/* set up a random initial state */", "/* then populate the state with the parameters */", "/* generate the code */", "/* end the block */", "/* execute */", "/* verify the results */", "/* free memory */" ]
[ { "param": "drcuml", "type": "drcuml_state" }, { "param": "handles", "type": "drcuml_codehandle" }, { "param": "test", "type": "bevalidate_test" }, { "param": "paramlist", "type": "drcuml_parameter" }, { "param": "flagmask", "type": "UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "drcuml", "type": "drcuml_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "handles", "type": "drcuml_codehandle", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "test", "type": "bevalidate_test", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "paramlist", "type": "drcuml_parameter", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "flagmask", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
bevalidate_initialize_random_state
void
static void bevalidate_initialize_random_state(drcuml_state *drcuml, drcuml_block *block, drcuml_machine_state *state) { running_machine *machine = drcuml->device->machine; int regnum; /* initialize core state to random values */ state->fmod = mame_rand(machine) & 0x03; state->flags = mame_rand(machine) & 0x1f; state->exp = mame_rand(machine); /* initialize integer registers to random values */ for (regnum = 0; regnum < ARRAY_LENGTH(state->r); regnum++) { state->r[regnum].w.h = mame_rand(machine); state->r[regnum].w.l = mame_rand(machine); } /* initialize float registers to random values */ for (regnum = 0; regnum < ARRAY_LENGTH(state->f); regnum++) { *(UINT32 *)&state->f[regnum].s.h = mame_rand(machine); *(UINT32 *)&state->f[regnum].s.l = mame_rand(machine); } /* initialize map variables to random values */ for (regnum = 0; regnum < DRCUML_MAPVAR_END - DRCUML_MAPVAR_M0; regnum++) UML_MAPVAR(block, MVAR(regnum), mame_rand(machine)); }
/*------------------------------------------------- bevalidate_initialize_random_state - initialize the machine state to randomness -------------------------------------------------*/
bevalidate_initialize_random_state initialize the machine state to randomness
[ "bevalidate_initialize_random_state", "initialize", "the", "machine", "state", "to", "randomness" ]
static void bevalidate_initialize_random_state(drcuml_state *drcuml, drcuml_block *block, drcuml_machine_state *state) { running_machine *machine = drcuml->device->machine; int regnum; state->fmod = mame_rand(machine) & 0x03; state->flags = mame_rand(machine) & 0x1f; state->exp = mame_rand(machine); for (regnum = 0; regnum < ARRAY_LENGTH(state->r); regnum++) { state->r[regnum].w.h = mame_rand(machine); state->r[regnum].w.l = mame_rand(machine); } for (regnum = 0; regnum < ARRAY_LENGTH(state->f); regnum++) { *(UINT32 *)&state->f[regnum].s.h = mame_rand(machine); *(UINT32 *)&state->f[regnum].s.l = mame_rand(machine); } for (regnum = 0; regnum < DRCUML_MAPVAR_END - DRCUML_MAPVAR_M0; regnum++) UML_MAPVAR(block, MVAR(regnum), mame_rand(machine)); }
[ "static", "void", "bevalidate_initialize_random_state", "(", "drcuml_state", "*", "drcuml", ",", "drcuml_block", "*", "block", ",", "drcuml_machine_state", "*", "state", ")", "{", "running_machine", "*", "machine", "=", "drcuml", "->", "device", "->", "machine", ";", "int", "regnum", ";", "state", "->", "fmod", "=", "mame_rand", "(", "machine", ")", "&", "0x03", ";", "state", "->", "flags", "=", "mame_rand", "(", "machine", ")", "&", "0x1f", ";", "state", "->", "exp", "=", "mame_rand", "(", "machine", ")", ";", "for", "(", "regnum", "=", "0", ";", "regnum", "<", "ARRAY_LENGTH", "(", "state", "->", "r", ")", ";", "regnum", "++", ")", "{", "state", "->", "r", "[", "regnum", "]", ".", "w", ".", "h", "=", "mame_rand", "(", "machine", ")", ";", "state", "->", "r", "[", "regnum", "]", ".", "w", ".", "l", "=", "mame_rand", "(", "machine", ")", ";", "}", "for", "(", "regnum", "=", "0", ";", "regnum", "<", "ARRAY_LENGTH", "(", "state", "->", "f", ")", ";", "regnum", "++", ")", "{", "*", "(", "UINT32", "*", ")", "&", "state", "->", "f", "[", "regnum", "]", ".", "s", ".", "h", "=", "mame_rand", "(", "machine", ")", ";", "*", "(", "UINT32", "*", ")", "&", "state", "->", "f", "[", "regnum", "]", ".", "s", ".", "l", "=", "mame_rand", "(", "machine", ")", ";", "}", "for", "(", "regnum", "=", "0", ";", "regnum", "<", "DRCUML_MAPVAR_END", "-", "DRCUML_MAPVAR_M0", ";", "regnum", "++", ")", "UML_MAPVAR", "(", "block", ",", "MVAR", "(", "regnum", ")", ",", "mame_rand", "(", "machine", ")", ")", ";", "}" ]
bevalidate_initialize_random_state initialize the machine state to randomness
[ "bevalidate_initialize_random_state", "initialize", "the", "machine", "state", "to", "randomness" ]
[ "/* initialize core state to random values */", "/* initialize integer registers to random values */", "/* initialize float registers to random values */", "/* initialize map variables to random values */" ]
[ { "param": "drcuml", "type": "drcuml_state" }, { "param": "block", "type": "drcuml_block" }, { "param": "state", "type": "drcuml_machine_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "drcuml", "type": "drcuml_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": "state", "type": "drcuml_machine_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc817159ad5bd5530abc7b8c3e40bdd32d81f57a
lofunz/mieme
Reloaded/trunk/src/emu/cpu/drcuml.c
[ "Unlicense" ]
C
bevalidate_populate_state
int
static int bevalidate_populate_state(drcuml_block *block, drcuml_machine_state *state, const bevalidate_test *test, const drcuml_parameter *paramlist, drcuml_parameter *params, UINT64 *parammem) { const drcuml_opcode_info *opinfo = opcode_info_table[test->opcode]; int numparams = ARRAY_LENGTH(test->param); int pnum; /* copy flags as-is */ state->flags = test->iflags; /* iterate over parameters */ for (pnum = 0; pnum < ARRAY_LENGTH(test->param); pnum++) { int psize = effective_test_psize(opinfo, pnum, test->size, test->param); drcuml_parameter *curparam = &params[pnum]; /* start with a copy of the parameter from the list */ *curparam = paramlist[pnum]; /* switch off the type */ switch (curparam->type) { /* immediate parameters: take the value from the test entry */ case DRCUML_PTYPE_IMMEDIATE: curparam->value = test->param[pnum]; break; /* register parameters: set the register value in the state and set the parameter value to the register index */ case DRCUML_PTYPE_INT_REGISTER: state->r[curparam->value].d = test->param[pnum]; curparam->value += DRCUML_REG_I0; break; /* register parameters: set the register value in the state and set the parameter value to the register index */ case DRCUML_PTYPE_FLOAT_REGISTER: state->f[curparam->value].d = test->param[pnum]; curparam->value += DRCUML_REG_F0; break; /* memory parameters: set the memory value in the parameter space and set the parameter value to point to it */ case DRCUML_PTYPE_MEMORY: curparam->value = (FPTR)&parammem[pnum]; if (psize == 4) *(UINT32 *)(FPTR)curparam->value = test->param[pnum]; else *(UINT64 *)(FPTR)curparam->value = test->param[pnum]; break; /* map variables: issue a MAPVAR instruction to set the value and set the parameter value to the mapvar index */ case DRCUML_PTYPE_MAPVAR: UML_MAPVAR(block, MVAR(curparam->value), test->param[pnum]); curparam->value += DRCUML_MAPVAR_M0; break; /* use anything else to count the number of parameters */ default: numparams = MIN(numparams, pnum); break; } } /* return the total number of parameters */ return numparams; }
/*------------------------------------------------- bevalidate_populate_state - populate the machine state with the proper values prior to executing a test -------------------------------------------------*/
populate the machine state with the proper values prior to executing a test
[ "populate", "the", "machine", "state", "with", "the", "proper", "values", "prior", "to", "executing", "a", "test" ]
static int bevalidate_populate_state(drcuml_block *block, drcuml_machine_state *state, const bevalidate_test *test, const drcuml_parameter *paramlist, drcuml_parameter *params, UINT64 *parammem) { const drcuml_opcode_info *opinfo = opcode_info_table[test->opcode]; int numparams = ARRAY_LENGTH(test->param); int pnum; state->flags = test->iflags; for (pnum = 0; pnum < ARRAY_LENGTH(test->param); pnum++) { int psize = effective_test_psize(opinfo, pnum, test->size, test->param); drcuml_parameter *curparam = &params[pnum]; *curparam = paramlist[pnum]; switch (curparam->type) { case DRCUML_PTYPE_IMMEDIATE: curparam->value = test->param[pnum]; break; case DRCUML_PTYPE_INT_REGISTER: state->r[curparam->value].d = test->param[pnum]; curparam->value += DRCUML_REG_I0; break; case DRCUML_PTYPE_FLOAT_REGISTER: state->f[curparam->value].d = test->param[pnum]; curparam->value += DRCUML_REG_F0; break; case DRCUML_PTYPE_MEMORY: curparam->value = (FPTR)&parammem[pnum]; if (psize == 4) *(UINT32 *)(FPTR)curparam->value = test->param[pnum]; else *(UINT64 *)(FPTR)curparam->value = test->param[pnum]; break; case DRCUML_PTYPE_MAPVAR: UML_MAPVAR(block, MVAR(curparam->value), test->param[pnum]); curparam->value += DRCUML_MAPVAR_M0; break; default: numparams = MIN(numparams, pnum); break; } } return numparams; }
[ "static", "int", "bevalidate_populate_state", "(", "drcuml_block", "*", "block", ",", "drcuml_machine_state", "*", "state", ",", "const", "bevalidate_test", "*", "test", ",", "const", "drcuml_parameter", "*", "paramlist", ",", "drcuml_parameter", "*", "params", ",", "UINT64", "*", "parammem", ")", "{", "const", "drcuml_opcode_info", "*", "opinfo", "=", "opcode_info_table", "[", "test", "->", "opcode", "]", ";", "int", "numparams", "=", "ARRAY_LENGTH", "(", "test", "->", "param", ")", ";", "int", "pnum", ";", "state", "->", "flags", "=", "test", "->", "iflags", ";", "for", "(", "pnum", "=", "0", ";", "pnum", "<", "ARRAY_LENGTH", "(", "test", "->", "param", ")", ";", "pnum", "++", ")", "{", "int", "psize", "=", "effective_test_psize", "(", "opinfo", ",", "pnum", ",", "test", "->", "size", ",", "test", "->", "param", ")", ";", "drcuml_parameter", "*", "curparam", "=", "&", "params", "[", "pnum", "]", ";", "*", "curparam", "=", "paramlist", "[", "pnum", "]", ";", "switch", "(", "curparam", "->", "type", ")", "{", "case", "DRCUML_PTYPE_IMMEDIATE", ":", "curparam", "->", "value", "=", "test", "->", "param", "[", "pnum", "]", ";", "break", ";", "case", "DRCUML_PTYPE_INT_REGISTER", ":", "state", "->", "r", "[", "curparam", "->", "value", "]", ".", "d", "=", "test", "->", "param", "[", "pnum", "]", ";", "curparam", "->", "value", "+=", "DRCUML_REG_I0", ";", "break", ";", "case", "DRCUML_PTYPE_FLOAT_REGISTER", ":", "state", "->", "f", "[", "curparam", "->", "value", "]", ".", "d", "=", "test", "->", "param", "[", "pnum", "]", ";", "curparam", "->", "value", "+=", "DRCUML_REG_F0", ";", "break", ";", "case", "DRCUML_PTYPE_MEMORY", ":", "curparam", "->", "value", "=", "(", "FPTR", ")", "&", "parammem", "[", "pnum", "]", ";", "if", "(", "psize", "==", "4", ")", "*", "(", "UINT32", "*", ")", "(", "FPTR", ")", "curparam", "->", "value", "=", "test", "->", "param", "[", "pnum", "]", ";", "else", "*", "(", "UINT64", "*", ")", "(", "FPTR", ")", "curparam", "->", "value", "=", "test", "->", "param", "[", "pnum", "]", ";", "break", ";", "case", "DRCUML_PTYPE_MAPVAR", ":", "UML_MAPVAR", "(", "block", ",", "MVAR", "(", "curparam", "->", "value", ")", ",", "test", "->", "param", "[", "pnum", "]", ")", ";", "curparam", "->", "value", "+=", "DRCUML_MAPVAR_M0", ";", "break", ";", "default", ":", "numparams", "=", "MIN", "(", "numparams", ",", "pnum", ")", ";", "break", ";", "}", "}", "return", "numparams", ";", "}" ]
bevalidate_populate_state - populate the machine state with the proper values prior to executing a test
[ "bevalidate_populate_state", "-", "populate", "the", "machine", "state", "with", "the", "proper", "values", "prior", "to", "executing", "a", "test" ]
[ "/* copy flags as-is */", "/* iterate over parameters */", "/* start with a copy of the parameter from the list */", "/* switch off the type */", "/* immediate parameters: take the value from the test entry */", "/* register parameters: set the register value in the state and set the parameter value to the register index */", "/* register parameters: set the register value in the state and set the parameter value to the register index */", "/* memory parameters: set the memory value in the parameter space and set the parameter value to point to it */", "/* map variables: issue a MAPVAR instruction to set the value and set the parameter value to the mapvar index */", "/* use anything else to count the number of parameters */", "/* return the total number of parameters */" ]
[ { "param": "block", "type": "drcuml_block" }, { "param": "state", "type": "drcuml_machine_state" }, { "param": "test", "type": "bevalidate_test" }, { "param": "paramlist", "type": "drcuml_parameter" }, { "param": "params", "type": "drcuml_parameter" }, { "param": "parammem", "type": "UINT64" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "block", "type": "drcuml_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "state", "type": "drcuml_machine_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "test", "type": "bevalidate_test", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "paramlist", "type": "drcuml_parameter", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "params", "type": "drcuml_parameter", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "parammem", "type": "UINT64", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
88c6c04a6fcc207c97d3ada8814214f2f26e6606
lofunz/mieme
Reloaded/trunk/src/mame/video/jedi.c
[ "Unlicense" ]
C
draw_background_and_text
void
static void draw_background_and_text(running_machine *machine, jedi_state *state, bitmap_t *bitmap, const rectangle *cliprect) { int y; int background_line_buffer[0x200]; /* RAM chip at 2A */ UINT8 *tx_gfx = memory_region(machine, "gfx1"); UINT8 *bg_gfx = memory_region(machine, "gfx2"); UINT8 *prom1 = &memory_region(machine, "proms")[0x0000 | ((*state->smoothing_table & 0x03) << 8)]; UINT8 *prom2 = &memory_region(machine, "proms")[0x0800 | ((*state->smoothing_table & 0x03) << 8)]; int vscroll = state->vscroll; int hscroll = state->hscroll; int tx_bank = *state->foreground_bank; UINT8 *tx_ram = state->foregroundram; UINT8 *bg_ram = state->backgroundram; memset(background_line_buffer, 0, 0x200 * sizeof(int)); for (y = cliprect->min_y; y <= cliprect->max_y; y++) { int x; int bg_last_col = 0; for (x = cliprect->min_x; x <= cliprect->max_x; x += 2) { int tx_col1, tx_col2, bg_col; int bg_tempcol; offs_t tx_gfx_offs, bg_gfx_offs; int tx_data, bg_data1, bg_data2; int sy = y + vscroll; int sx = x + hscroll; /* determine offsets into video memory */ offs_t tx_offs = ((y & 0xf8) << 3) | (x >> 3); offs_t bg_offs = ((sy & 0x1f0) << 1) | ((sx & 0x1f0) >> 4); /* get the character codes */ int tx_code = ((tx_bank & 0x80) << 1) | tx_ram[tx_offs]; int bg_bank = bg_ram[0x0400 | bg_offs]; int bg_code = bg_ram[0x0000 | bg_offs] | ((bg_bank & 0x01) << 8) | ((bg_bank & 0x08) << 6) | ((bg_bank & 0x02) << 9); /* background flip X */ if (bg_bank & 0x04) sx = sx ^ 0x0f; /* calculate the address of the gfx data */ tx_gfx_offs = (tx_code << 4) | ((y & 0x07) << 1) | ((( x & 0x04) >> 2)); bg_gfx_offs = (bg_code << 4) | (sy & 0x0e) | (((sx & 0x08) >> 3)); /* get the gfx data */ tx_data = tx_gfx[ tx_gfx_offs]; bg_data1 = bg_gfx[0x0000 | bg_gfx_offs]; bg_data2 = bg_gfx[0x8000 | bg_gfx_offs]; /* the text layer pixel determines pen address bits A8 and A9 */ if (x & 0x02) { tx_col1 = ((tx_data & 0x0c) << 6); tx_col2 = ((tx_data & 0x03) << 8); } else { tx_col1 = ((tx_data & 0xc0) << 2); tx_col2 = ((tx_data & 0x30) << 4); } /* the background pixel determines pen address bits A0-A3 */ switch (sx & 0x06) { case 0x00: bg_col = ((bg_data1 & 0x80) >> 4) | ((bg_data1 & 0x08) >> 1) | ((bg_data2 & 0x80) >> 6) | ((bg_data2 & 0x08) >> 3); break; case 0x02: bg_col = ((bg_data1 & 0x40) >> 3) | ((bg_data1 & 0x04) >> 0) | ((bg_data2 & 0x40) >> 5) | ((bg_data2 & 0x04) >> 2); break; case 0x04: bg_col = ((bg_data1 & 0x20) >> 2) | ((bg_data1 & 0x02) << 1) | ((bg_data2 & 0x20) >> 4) | ((bg_data2 & 0x02) >> 1); break; default: bg_col = ((bg_data1 & 0x10) >> 1) | ((bg_data1 & 0x01) << 2) | ((bg_data2 & 0x10) >> 3) | ((bg_data2 & 0x01) >> 0); break; } /* the first pixel is smoothed via a lookup using the current and last pixel value - the next pixel just uses the current value directly. After we done with a pixel save it for later in the line buffer RAM */ bg_tempcol = prom1[(bg_last_col << 4) | bg_col]; *BITMAP_ADDR32(bitmap, y, x + 0) = tx_col1 | prom2[(background_line_buffer[x + 0] << 4) | bg_tempcol]; *BITMAP_ADDR32(bitmap, y, x + 1) = tx_col2 | prom2[(background_line_buffer[x + 1] << 4) | bg_col]; background_line_buffer[x + 0] = bg_tempcol; background_line_buffer[x + 1] = bg_col; bg_last_col = bg_col; } } }
/************************************* * * Background/text layer drawing * with smoothing * *************************************/
Background/text layer drawing with smoothing
[ "Background", "/", "text", "layer", "drawing", "with", "smoothing" ]
static void draw_background_and_text(running_machine *machine, jedi_state *state, bitmap_t *bitmap, const rectangle *cliprect) { int y; int background_line_buffer[0x200]; UINT8 *tx_gfx = memory_region(machine, "gfx1"); UINT8 *bg_gfx = memory_region(machine, "gfx2"); UINT8 *prom1 = &memory_region(machine, "proms")[0x0000 | ((*state->smoothing_table & 0x03) << 8)]; UINT8 *prom2 = &memory_region(machine, "proms")[0x0800 | ((*state->smoothing_table & 0x03) << 8)]; int vscroll = state->vscroll; int hscroll = state->hscroll; int tx_bank = *state->foreground_bank; UINT8 *tx_ram = state->foregroundram; UINT8 *bg_ram = state->backgroundram; memset(background_line_buffer, 0, 0x200 * sizeof(int)); for (y = cliprect->min_y; y <= cliprect->max_y; y++) { int x; int bg_last_col = 0; for (x = cliprect->min_x; x <= cliprect->max_x; x += 2) { int tx_col1, tx_col2, bg_col; int bg_tempcol; offs_t tx_gfx_offs, bg_gfx_offs; int tx_data, bg_data1, bg_data2; int sy = y + vscroll; int sx = x + hscroll; offs_t tx_offs = ((y & 0xf8) << 3) | (x >> 3); offs_t bg_offs = ((sy & 0x1f0) << 1) | ((sx & 0x1f0) >> 4); int tx_code = ((tx_bank & 0x80) << 1) | tx_ram[tx_offs]; int bg_bank = bg_ram[0x0400 | bg_offs]; int bg_code = bg_ram[0x0000 | bg_offs] | ((bg_bank & 0x01) << 8) | ((bg_bank & 0x08) << 6) | ((bg_bank & 0x02) << 9); if (bg_bank & 0x04) sx = sx ^ 0x0f; tx_gfx_offs = (tx_code << 4) | ((y & 0x07) << 1) | ((( x & 0x04) >> 2)); bg_gfx_offs = (bg_code << 4) | (sy & 0x0e) | (((sx & 0x08) >> 3)); tx_data = tx_gfx[ tx_gfx_offs]; bg_data1 = bg_gfx[0x0000 | bg_gfx_offs]; bg_data2 = bg_gfx[0x8000 | bg_gfx_offs]; if (x & 0x02) { tx_col1 = ((tx_data & 0x0c) << 6); tx_col2 = ((tx_data & 0x03) << 8); } else { tx_col1 = ((tx_data & 0xc0) << 2); tx_col2 = ((tx_data & 0x30) << 4); } switch (sx & 0x06) { case 0x00: bg_col = ((bg_data1 & 0x80) >> 4) | ((bg_data1 & 0x08) >> 1) | ((bg_data2 & 0x80) >> 6) | ((bg_data2 & 0x08) >> 3); break; case 0x02: bg_col = ((bg_data1 & 0x40) >> 3) | ((bg_data1 & 0x04) >> 0) | ((bg_data2 & 0x40) >> 5) | ((bg_data2 & 0x04) >> 2); break; case 0x04: bg_col = ((bg_data1 & 0x20) >> 2) | ((bg_data1 & 0x02) << 1) | ((bg_data2 & 0x20) >> 4) | ((bg_data2 & 0x02) >> 1); break; default: bg_col = ((bg_data1 & 0x10) >> 1) | ((bg_data1 & 0x01) << 2) | ((bg_data2 & 0x10) >> 3) | ((bg_data2 & 0x01) >> 0); break; } bg_tempcol = prom1[(bg_last_col << 4) | bg_col]; *BITMAP_ADDR32(bitmap, y, x + 0) = tx_col1 | prom2[(background_line_buffer[x + 0] << 4) | bg_tempcol]; *BITMAP_ADDR32(bitmap, y, x + 1) = tx_col2 | prom2[(background_line_buffer[x + 1] << 4) | bg_col]; background_line_buffer[x + 0] = bg_tempcol; background_line_buffer[x + 1] = bg_col; bg_last_col = bg_col; } } }
[ "static", "void", "draw_background_and_text", "(", "running_machine", "*", "machine", ",", "jedi_state", "*", "state", ",", "bitmap_t", "*", "bitmap", ",", "const", "rectangle", "*", "cliprect", ")", "{", "int", "y", ";", "int", "background_line_buffer", "[", "0x200", "]", ";", "UINT8", "*", "tx_gfx", "=", "memory_region", "(", "machine", ",", "\"", "\"", ")", ";", "UINT8", "*", "bg_gfx", "=", "memory_region", "(", "machine", ",", "\"", "\"", ")", ";", "UINT8", "*", "prom1", "=", "&", "memory_region", "(", "machine", ",", "\"", "\"", ")", "[", "0x0000", "|", "(", "(", "*", "state", "->", "smoothing_table", "&", "0x03", ")", "<<", "8", ")", "]", ";", "UINT8", "*", "prom2", "=", "&", "memory_region", "(", "machine", ",", "\"", "\"", ")", "[", "0x0800", "|", "(", "(", "*", "state", "->", "smoothing_table", "&", "0x03", ")", "<<", "8", ")", "]", ";", "int", "vscroll", "=", "state", "->", "vscroll", ";", "int", "hscroll", "=", "state", "->", "hscroll", ";", "int", "tx_bank", "=", "*", "state", "->", "foreground_bank", ";", "UINT8", "*", "tx_ram", "=", "state", "->", "foregroundram", ";", "UINT8", "*", "bg_ram", "=", "state", "->", "backgroundram", ";", "memset", "(", "background_line_buffer", ",", "0", ",", "0x200", "*", "sizeof", "(", "int", ")", ")", ";", "for", "(", "y", "=", "cliprect", "->", "min_y", ";", "y", "<=", "cliprect", "->", "max_y", ";", "y", "++", ")", "{", "int", "x", ";", "int", "bg_last_col", "=", "0", ";", "for", "(", "x", "=", "cliprect", "->", "min_x", ";", "x", "<=", "cliprect", "->", "max_x", ";", "x", "+=", "2", ")", "{", "int", "tx_col1", ",", "tx_col2", ",", "bg_col", ";", "int", "bg_tempcol", ";", "offs_t", "tx_gfx_offs", ",", "bg_gfx_offs", ";", "int", "tx_data", ",", "bg_data1", ",", "bg_data2", ";", "int", "sy", "=", "y", "+", "vscroll", ";", "int", "sx", "=", "x", "+", "hscroll", ";", "offs_t", "tx_offs", "=", "(", "(", "y", "&", "0xf8", ")", "<<", "3", ")", "|", "(", "x", ">>", "3", ")", ";", "offs_t", "bg_offs", "=", "(", "(", "sy", "&", "0x1f0", ")", "<<", "1", ")", "|", "(", "(", "sx", "&", "0x1f0", ")", ">>", "4", ")", ";", "int", "tx_code", "=", "(", "(", "tx_bank", "&", "0x80", ")", "<<", "1", ")", "|", "tx_ram", "[", "tx_offs", "]", ";", "int", "bg_bank", "=", "bg_ram", "[", "0x0400", "|", "bg_offs", "]", ";", "int", "bg_code", "=", "bg_ram", "[", "0x0000", "|", "bg_offs", "]", "|", "(", "(", "bg_bank", "&", "0x01", ")", "<<", "8", ")", "|", "(", "(", "bg_bank", "&", "0x08", ")", "<<", "6", ")", "|", "(", "(", "bg_bank", "&", "0x02", ")", "<<", "9", ")", ";", "if", "(", "bg_bank", "&", "0x04", ")", "sx", "=", "sx", "^", "0x0f", ";", "tx_gfx_offs", "=", "(", "tx_code", "<<", "4", ")", "|", "(", "(", "y", "&", "0x07", ")", "<<", "1", ")", "|", "(", "(", "(", "x", "&", "0x04", ")", ">>", "2", ")", ")", ";", "bg_gfx_offs", "=", "(", "bg_code", "<<", "4", ")", "|", "(", "sy", "&", "0x0e", ")", "|", "(", "(", "(", "sx", "&", "0x08", ")", ">>", "3", ")", ")", ";", "tx_data", "=", "tx_gfx", "[", "tx_gfx_offs", "]", ";", "bg_data1", "=", "bg_gfx", "[", "0x0000", "|", "bg_gfx_offs", "]", ";", "bg_data2", "=", "bg_gfx", "[", "0x8000", "|", "bg_gfx_offs", "]", ";", "if", "(", "x", "&", "0x02", ")", "{", "tx_col1", "=", "(", "(", "tx_data", "&", "0x0c", ")", "<<", "6", ")", ";", "tx_col2", "=", "(", "(", "tx_data", "&", "0x03", ")", "<<", "8", ")", ";", "}", "else", "{", "tx_col1", "=", "(", "(", "tx_data", "&", "0xc0", ")", "<<", "2", ")", ";", "tx_col2", "=", "(", "(", "tx_data", "&", "0x30", ")", "<<", "4", ")", ";", "}", "switch", "(", "sx", "&", "0x06", ")", "{", "case", "0x00", ":", "bg_col", "=", "(", "(", "bg_data1", "&", "0x80", ")", ">>", "4", ")", "|", "(", "(", "bg_data1", "&", "0x08", ")", ">>", "1", ")", "|", "(", "(", "bg_data2", "&", "0x80", ")", ">>", "6", ")", "|", "(", "(", "bg_data2", "&", "0x08", ")", ">>", "3", ")", ";", "break", ";", "case", "0x02", ":", "bg_col", "=", "(", "(", "bg_data1", "&", "0x40", ")", ">>", "3", ")", "|", "(", "(", "bg_data1", "&", "0x04", ")", ">>", "0", ")", "|", "(", "(", "bg_data2", "&", "0x40", ")", ">>", "5", ")", "|", "(", "(", "bg_data2", "&", "0x04", ")", ">>", "2", ")", ";", "break", ";", "case", "0x04", ":", "bg_col", "=", "(", "(", "bg_data1", "&", "0x20", ")", ">>", "2", ")", "|", "(", "(", "bg_data1", "&", "0x02", ")", "<<", "1", ")", "|", "(", "(", "bg_data2", "&", "0x20", ")", ">>", "4", ")", "|", "(", "(", "bg_data2", "&", "0x02", ")", ">>", "1", ")", ";", "break", ";", "default", ":", "bg_col", "=", "(", "(", "bg_data1", "&", "0x10", ")", ">>", "1", ")", "|", "(", "(", "bg_data1", "&", "0x01", ")", "<<", "2", ")", "|", "(", "(", "bg_data2", "&", "0x10", ")", ">>", "3", ")", "|", "(", "(", "bg_data2", "&", "0x01", ")", ">>", "0", ")", ";", "break", ";", "}", "bg_tempcol", "=", "prom1", "[", "(", "bg_last_col", "<<", "4", ")", "|", "bg_col", "]", ";", "*", "BITMAP_ADDR32", "(", "bitmap", ",", "y", ",", "x", "+", "0", ")", "=", "tx_col1", "|", "prom2", "[", "(", "background_line_buffer", "[", "x", "+", "0", "]", "<<", "4", ")", "|", "bg_tempcol", "]", ";", "*", "BITMAP_ADDR32", "(", "bitmap", ",", "y", ",", "x", "+", "1", ")", "=", "tx_col2", "|", "prom2", "[", "(", "background_line_buffer", "[", "x", "+", "1", "]", "<<", "4", ")", "|", "bg_col", "]", ";", "background_line_buffer", "[", "x", "+", "0", "]", "=", "bg_tempcol", ";", "background_line_buffer", "[", "x", "+", "1", "]", "=", "bg_col", ";", "bg_last_col", "=", "bg_col", ";", "}", "}", "}" ]
Background/text layer drawing with smoothing
[ "Background", "/", "text", "layer", "drawing", "with", "smoothing" ]
[ "/* RAM chip at 2A */", "/* determine offsets into video memory */", "/* get the character codes */", "/* background flip X */", "/* calculate the address of the gfx data */", "/* get the gfx data */", "/* the text layer pixel determines pen address bits A8 and A9 */", "/* the background pixel determines pen address bits A0-A3 */", "/* the first pixel is smoothed via a lookup using the current and last pixel value -\r\n the next pixel just uses the current value directly. After we done with a pixel\r\n save it for later in the line buffer RAM */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "state", "type": "jedi_state" }, { "param": "bitmap", "type": "bitmap_t" }, { "param": "cliprect", "type": "rectangle" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "state", "type": "jedi_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bitmap", "type": "bitmap_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cliprect", "type": "rectangle", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2261cbfd5fbac39942473a4fbe9e17ef8e7566cd
lofunz/mieme
Reloaded/trunk/src/lib/util/astring.c
[ "Unlicense" ]
C
astring_cpych
astring
astring *astring_cpych(astring *dst, const char *src, int count) { /* make room; if we fail or if dst is the dummy, do nothing */ if (!ensure_room(dst, count)) return dst; /* copy the raw data and NULL-terminate */ if (count > 0) memcpy(dst->text, src, count); dst->text[count] = 0; return dst; }
/*------------------------------------------------- astring_cpych - copy a character array into an astring -------------------------------------------------*/
copy a character array into an astring
[ "copy", "a", "character", "array", "into", "an", "astring" ]
astring *astring_cpych(astring *dst, const char *src, int count) { if (!ensure_room(dst, count)) return dst; if (count > 0) memcpy(dst->text, src, count); dst->text[count] = 0; return dst; }
[ "astring", "*", "astring_cpych", "(", "astring", "*", "dst", ",", "const", "char", "*", "src", ",", "int", "count", ")", "{", "if", "(", "!", "ensure_room", "(", "dst", ",", "count", ")", ")", "return", "dst", ";", "if", "(", "count", ">", "0", ")", "memcpy", "(", "dst", "->", "text", ",", "src", ",", "count", ")", ";", "dst", "->", "text", "[", "count", "]", "=", "0", ";", "return", "dst", ";", "}" ]
astring_cpych - copy a character array into an astring
[ "astring_cpych", "-", "copy", "a", "character", "array", "into", "an", "astring" ]
[ "/* make room; if we fail or if dst is the dummy, do nothing */", "/* copy the raw data and NULL-terminate */" ]
[ { "param": "dst", "type": "astring" }, { "param": "src", "type": "char" }, { "param": "count", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dst", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "src", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "count", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2261cbfd5fbac39942473a4fbe9e17ef8e7566cd
lofunz/mieme
Reloaded/trunk/src/lib/util/astring.c
[ "Unlicense" ]
C
astring_cpysubstr
astring
astring *astring_cpysubstr(astring *dst, const astring *src, int start, int count) { normalize_substr(&start, &count, strlen(src->text)); return astring_cpych(dst, src->text + start, count); }
/*------------------------------------------------- astring_cpysubstr - copy a substring of one string to another -------------------------------------------------*/
copy a substring of one string to another
[ "copy", "a", "substring", "of", "one", "string", "to", "another" ]
astring *astring_cpysubstr(astring *dst, const astring *src, int start, int count) { normalize_substr(&start, &count, strlen(src->text)); return astring_cpych(dst, src->text + start, count); }
[ "astring", "*", "astring_cpysubstr", "(", "astring", "*", "dst", ",", "const", "astring", "*", "src", ",", "int", "start", ",", "int", "count", ")", "{", "normalize_substr", "(", "&", "start", ",", "&", "count", ",", "strlen", "(", "src", "->", "text", ")", ")", ";", "return", "astring_cpych", "(", "dst", ",", "src", "->", "text", "+", "start", ",", "count", ")", ";", "}" ]
astring_cpysubstr - copy a substring of one string to another
[ "astring_cpysubstr", "-", "copy", "a", "substring", "of", "one", "string", "to", "another" ]
[]
[ { "param": "dst", "type": "astring" }, { "param": "src", "type": "astring" }, { "param": "start", "type": "int" }, { "param": "count", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dst", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "src", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "start", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "count", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2261cbfd5fbac39942473a4fbe9e17ef8e7566cd
lofunz/mieme
Reloaded/trunk/src/lib/util/astring.c
[ "Unlicense" ]
C
astring_insch
astring
astring *astring_insch(astring *dst, int insbefore, const char *src, int count) { int dstlength = strlen(dst->text); /* make room; if we fail or if dst is the dummy, do nothing */ if (!ensure_room(dst, dstlength + count)) return dst; /* adjust insbefore to be logical */ if (insbefore < 0 || insbefore > dstlength) insbefore = dstlength; /* copy the data an NULL-terminate */ if (insbefore < dstlength) memmove(dst->text + insbefore + count, dst->text + insbefore, dstlength - insbefore); memcpy(dst->text + insbefore, src, count); dst->text[dstlength + count] = 0; return dst; }
/*------------------------------------------------- astring_insch - insert a character array into an astring -------------------------------------------------*/
insert a character array into an astring
[ "insert", "a", "character", "array", "into", "an", "astring" ]
astring *astring_insch(astring *dst, int insbefore, const char *src, int count) { int dstlength = strlen(dst->text); if (!ensure_room(dst, dstlength + count)) return dst; if (insbefore < 0 || insbefore > dstlength) insbefore = dstlength; if (insbefore < dstlength) memmove(dst->text + insbefore + count, dst->text + insbefore, dstlength - insbefore); memcpy(dst->text + insbefore, src, count); dst->text[dstlength + count] = 0; return dst; }
[ "astring", "*", "astring_insch", "(", "astring", "*", "dst", ",", "int", "insbefore", ",", "const", "char", "*", "src", ",", "int", "count", ")", "{", "int", "dstlength", "=", "strlen", "(", "dst", "->", "text", ")", ";", "if", "(", "!", "ensure_room", "(", "dst", ",", "dstlength", "+", "count", ")", ")", "return", "dst", ";", "if", "(", "insbefore", "<", "0", "||", "insbefore", ">", "dstlength", ")", "insbefore", "=", "dstlength", ";", "if", "(", "insbefore", "<", "dstlength", ")", "memmove", "(", "dst", "->", "text", "+", "insbefore", "+", "count", ",", "dst", "->", "text", "+", "insbefore", ",", "dstlength", "-", "insbefore", ")", ";", "memcpy", "(", "dst", "->", "text", "+", "insbefore", ",", "src", ",", "count", ")", ";", "dst", "->", "text", "[", "dstlength", "+", "count", "]", "=", "0", ";", "return", "dst", ";", "}" ]
astring_insch - insert a character array into an astring
[ "astring_insch", "-", "insert", "a", "character", "array", "into", "an", "astring" ]
[ "/* make room; if we fail or if dst is the dummy, do nothing */", "/* adjust insbefore to be logical */", "/* copy the data an NULL-terminate */" ]
[ { "param": "dst", "type": "astring" }, { "param": "insbefore", "type": "int" }, { "param": "src", "type": "char" }, { "param": "count", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dst", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "insbefore", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "src", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "count", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2261cbfd5fbac39942473a4fbe9e17ef8e7566cd
lofunz/mieme
Reloaded/trunk/src/lib/util/astring.c
[ "Unlicense" ]
C
astring_inssubstr
astring
astring *astring_inssubstr(astring *dst, int insbefore, const astring *src, int start, int count) { normalize_substr(&start, &count, strlen(src->text)); return astring_insch(dst, insbefore, src->text + start, count); }
/*------------------------------------------------- astring_inssubstr - insert a substring of one string to another -------------------------------------------------*/
insert a substring of one string to another
[ "insert", "a", "substring", "of", "one", "string", "to", "another" ]
astring *astring_inssubstr(astring *dst, int insbefore, const astring *src, int start, int count) { normalize_substr(&start, &count, strlen(src->text)); return astring_insch(dst, insbefore, src->text + start, count); }
[ "astring", "*", "astring_inssubstr", "(", "astring", "*", "dst", ",", "int", "insbefore", ",", "const", "astring", "*", "src", ",", "int", "start", ",", "int", "count", ")", "{", "normalize_substr", "(", "&", "start", ",", "&", "count", ",", "strlen", "(", "src", "->", "text", ")", ")", ";", "return", "astring_insch", "(", "dst", ",", "insbefore", ",", "src", "->", "text", "+", "start", ",", "count", ")", ";", "}" ]
astring_inssubstr - insert a substring of one string to another
[ "astring_inssubstr", "-", "insert", "a", "substring", "of", "one", "string", "to", "another" ]
[]
[ { "param": "dst", "type": "astring" }, { "param": "insbefore", "type": "int" }, { "param": "src", "type": "astring" }, { "param": "start", "type": "int" }, { "param": "count", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dst", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "insbefore", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "src", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "start", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "count", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2261cbfd5fbac39942473a4fbe9e17ef8e7566cd
lofunz/mieme
Reloaded/trunk/src/lib/util/astring.c
[ "Unlicense" ]
C
astring_substr
astring
astring *astring_substr(astring *str, int start, int count) { /* ignore attempts to do this on the dummy */ if (str == &dummy_astring) return str; /* normalize parameters */ normalize_substr(&start, &count, strlen(str->text)); /* move the data and NULL-terminate */ if (count > 0 && start > 0) memmove(str->text, str->text + start, count); str->text[count] = 0; return str; }
/*------------------------------------------------- astring_substr - extract a substring of ourself, removing everything else -------------------------------------------------*/
extract a substring of ourself, removing everything else
[ "extract", "a", "substring", "of", "ourself", "removing", "everything", "else" ]
astring *astring_substr(astring *str, int start, int count) { if (str == &dummy_astring) return str; normalize_substr(&start, &count, strlen(str->text)); if (count > 0 && start > 0) memmove(str->text, str->text + start, count); str->text[count] = 0; return str; }
[ "astring", "*", "astring_substr", "(", "astring", "*", "str", ",", "int", "start", ",", "int", "count", ")", "{", "if", "(", "str", "==", "&", "dummy_astring", ")", "return", "str", ";", "normalize_substr", "(", "&", "start", ",", "&", "count", ",", "strlen", "(", "str", "->", "text", ")", ")", ";", "if", "(", "count", ">", "0", "&&", "start", ">", "0", ")", "memmove", "(", "str", "->", "text", ",", "str", "->", "text", "+", "start", ",", "count", ")", ";", "str", "->", "text", "[", "count", "]", "=", "0", ";", "return", "str", ";", "}" ]
astring_substr - extract a substring of ourself, removing everything else
[ "astring_substr", "-", "extract", "a", "substring", "of", "ourself", "removing", "everything", "else" ]
[ "/* ignore attempts to do this on the dummy */", "/* normalize parameters */", "/* move the data and NULL-terminate */" ]
[ { "param": "str", "type": "astring" }, { "param": "start", "type": "int" }, { "param": "count", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "str", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "start", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "count", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2261cbfd5fbac39942473a4fbe9e17ef8e7566cd
lofunz/mieme
Reloaded/trunk/src/lib/util/astring.c
[ "Unlicense" ]
C
astring_del
astring
astring *astring_del(astring *str, int start, int count) { int strlength = strlen(str->text); /* ignore attempts to do this on the dummy */ if (str == &dummy_astring) return str; /* normalize parameters */ normalize_substr(&start, &count, strlength); /* move the data and NULL-terminate */ if (count > 0) memmove(str->text + start, str->text + start + count, strlength - (start + count)); str->text[strlength - count] = 0; return str; }
/*------------------------------------------------- astring_del - delete a substring of ourself, keeping everything else -------------------------------------------------*/
delete a substring of ourself, keeping everything else
[ "delete", "a", "substring", "of", "ourself", "keeping", "everything", "else" ]
astring *astring_del(astring *str, int start, int count) { int strlength = strlen(str->text); if (str == &dummy_astring) return str; normalize_substr(&start, &count, strlength); if (count > 0) memmove(str->text + start, str->text + start + count, strlength - (start + count)); str->text[strlength - count] = 0; return str; }
[ "astring", "*", "astring_del", "(", "astring", "*", "str", ",", "int", "start", ",", "int", "count", ")", "{", "int", "strlength", "=", "strlen", "(", "str", "->", "text", ")", ";", "if", "(", "str", "==", "&", "dummy_astring", ")", "return", "str", ";", "normalize_substr", "(", "&", "start", ",", "&", "count", ",", "strlength", ")", ";", "if", "(", "count", ">", "0", ")", "memmove", "(", "str", "->", "text", "+", "start", ",", "str", "->", "text", "+", "start", "+", "count", ",", "strlength", "-", "(", "start", "+", "count", ")", ")", ";", "str", "->", "text", "[", "strlength", "-", "count", "]", "=", "0", ";", "return", "str", ";", "}" ]
astring_del - delete a substring of ourself, keeping everything else
[ "astring_del", "-", "delete", "a", "substring", "of", "ourself", "keeping", "everything", "else" ]
[ "/* ignore attempts to do this on the dummy */", "/* normalize parameters */", "/* move the data and NULL-terminate */" ]
[ { "param": "str", "type": "astring" }, { "param": "start", "type": "int" }, { "param": "count", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "str", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "start", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "count", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2261cbfd5fbac39942473a4fbe9e17ef8e7566cd
lofunz/mieme
Reloaded/trunk/src/lib/util/astring.c
[ "Unlicense" ]
C
astring_catprintf
int
int astring_catprintf(astring *dst, const char *format, ...) { char tempbuf[4096]; va_list args; int result; /* sprintf into the temporary buffer */ va_start(args, format); result = vsprintf(tempbuf, format, args); va_end(args); /* append the result */ astring_catc(dst, tempbuf); return result; }
/*------------------------------------------------- astring_catprintf - formatted printf to the end of an astring -------------------------------------------------*/
formatted printf to the end of an astring
[ "formatted", "printf", "to", "the", "end", "of", "an", "astring" ]
int astring_catprintf(astring *dst, const char *format, ...) { char tempbuf[4096]; va_list args; int result; va_start(args, format); result = vsprintf(tempbuf, format, args); va_end(args); astring_catc(dst, tempbuf); return result; }
[ "int", "astring_catprintf", "(", "astring", "*", "dst", ",", "const", "char", "*", "format", ",", "...", ")", "{", "char", "tempbuf", "[", "4096", "]", ";", "va_list", "args", ";", "int", "result", ";", "va_start", "(", "args", ",", "format", ")", ";", "result", "=", "vsprintf", "(", "tempbuf", ",", "format", ",", "args", ")", ";", "va_end", "(", "args", ")", ";", "astring_catc", "(", "dst", ",", "tempbuf", ")", ";", "return", "result", ";", "}" ]
astring_catprintf - formatted printf to the end of an astring
[ "astring_catprintf", "-", "formatted", "printf", "to", "the", "end", "of", "an", "astring" ]
[ "/* sprintf into the temporary buffer */", "/* append the result */" ]
[ { "param": "dst", "type": "astring" }, { "param": "format", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dst", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "format", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2261cbfd5fbac39942473a4fbe9e17ef8e7566cd
lofunz/mieme
Reloaded/trunk/src/lib/util/astring.c
[ "Unlicense" ]
C
astring_catvprintf
int
int astring_catvprintf(astring *dst, const char *format, va_list args) { char tempbuf[4096]; int result; /* sprintf into the temporary buffer */ result = vsprintf(tempbuf, format, args); /* append the result */ astring_catc(dst, tempbuf); return result; }
/*------------------------------------------------- astring_catprintf - formatted vprintf to the end of an astring -------------------------------------------------*/
formatted vprintf to the end of an astring
[ "formatted", "vprintf", "to", "the", "end", "of", "an", "astring" ]
int astring_catvprintf(astring *dst, const char *format, va_list args) { char tempbuf[4096]; int result; result = vsprintf(tempbuf, format, args); astring_catc(dst, tempbuf); return result; }
[ "int", "astring_catvprintf", "(", "astring", "*", "dst", ",", "const", "char", "*", "format", ",", "va_list", "args", ")", "{", "char", "tempbuf", "[", "4096", "]", ";", "int", "result", ";", "result", "=", "vsprintf", "(", "tempbuf", ",", "format", ",", "args", ")", ";", "astring_catc", "(", "dst", ",", "tempbuf", ")", ";", "return", "result", ";", "}" ]
astring_catprintf - formatted vprintf to the end of an astring
[ "astring_catprintf", "-", "formatted", "vprintf", "to", "the", "end", "of", "an", "astring" ]
[ "/* sprintf into the temporary buffer */", "/* append the result */" ]
[ { "param": "dst", "type": "astring" }, { "param": "format", "type": "char" }, { "param": "args", "type": "va_list" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dst", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "format", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "args", "type": "va_list", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2261cbfd5fbac39942473a4fbe9e17ef8e7566cd
lofunz/mieme
Reloaded/trunk/src/lib/util/astring.c
[ "Unlicense" ]
C
astring_cmpc
int
int astring_cmpc(const astring *str1, const char *str2) { const char *s1 = str1->text; /* loop while equal until we hit the end of strings */ while (*s1 != 0 && *str2 != 0 && *s1 == *str2) s1++, str2++; return *s1 - *str2; }
/*------------------------------------------------- astring_cmpc - compare a C string to an astring -------------------------------------------------*/
compare a C string to an astring
[ "compare", "a", "C", "string", "to", "an", "astring" ]
int astring_cmpc(const astring *str1, const char *str2) { const char *s1 = str1->text; while (*s1 != 0 && *str2 != 0 && *s1 == *str2) s1++, str2++; return *s1 - *str2; }
[ "int", "astring_cmpc", "(", "const", "astring", "*", "str1", ",", "const", "char", "*", "str2", ")", "{", "const", "char", "*", "s1", "=", "str1", "->", "text", ";", "while", "(", "*", "s1", "!=", "0", "&&", "*", "str2", "!=", "0", "&&", "*", "s1", "==", "*", "str2", ")", "s1", "++", ",", "str2", "++", ";", "return", "*", "s1", "-", "*", "str2", ";", "}" ]
astring_cmpc - compare a C string to an astring
[ "astring_cmpc", "-", "compare", "a", "C", "string", "to", "an", "astring" ]
[ "/* loop while equal until we hit the end of strings */" ]
[ { "param": "str1", "type": "astring" }, { "param": "str2", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "str1", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "str2", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2261cbfd5fbac39942473a4fbe9e17ef8e7566cd
lofunz/mieme
Reloaded/trunk/src/lib/util/astring.c
[ "Unlicense" ]
C
astring_cmpch
int
int astring_cmpch(const astring *str1, const char *str2, int count) { const char *s1 = str1->text; int result; /* loop while equal until we hit the end of strings */ while (count-- > 0 && *s1 != 0 && *str2 != 0 && *s1 == *str2) s1++, str2++; result = (count == -1) ? 0 : *s1 - *str2; if (result == 0 && *s1 != 0) result = 1; return result; }
/*------------------------------------------------- astring_cmpch - compare a character array to an astring -------------------------------------------------*/
compare a character array to an astring
[ "compare", "a", "character", "array", "to", "an", "astring" ]
int astring_cmpch(const astring *str1, const char *str2, int count) { const char *s1 = str1->text; int result; while (count-- > 0 && *s1 != 0 && *str2 != 0 && *s1 == *str2) s1++, str2++; result = (count == -1) ? 0 : *s1 - *str2; if (result == 0 && *s1 != 0) result = 1; return result; }
[ "int", "astring_cmpch", "(", "const", "astring", "*", "str1", ",", "const", "char", "*", "str2", ",", "int", "count", ")", "{", "const", "char", "*", "s1", "=", "str1", "->", "text", ";", "int", "result", ";", "while", "(", "count", "--", ">", "0", "&&", "*", "s1", "!=", "0", "&&", "*", "str2", "!=", "0", "&&", "*", "s1", "==", "*", "str2", ")", "s1", "++", ",", "str2", "++", ";", "result", "=", "(", "count", "==", "-1", ")", "?", "0", ":", "*", "s1", "-", "*", "str2", ";", "if", "(", "result", "==", "0", "&&", "*", "s1", "!=", "0", ")", "result", "=", "1", ";", "return", "result", ";", "}" ]
astring_cmpch - compare a character array to an astring
[ "astring_cmpch", "-", "compare", "a", "character", "array", "to", "an", "astring" ]
[ "/* loop while equal until we hit the end of strings */" ]
[ { "param": "str1", "type": "astring" }, { "param": "str2", "type": "char" }, { "param": "count", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "str1", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "str2", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "count", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2261cbfd5fbac39942473a4fbe9e17ef8e7566cd
lofunz/mieme
Reloaded/trunk/src/lib/util/astring.c
[ "Unlicense" ]
C
astring_cmpsubstr
int
int astring_cmpsubstr(const astring *str1, const astring *str2, int start, int count) { normalize_substr(&start, &count, strlen(str2->text)); return astring_cmpch(str1, str2->text + start, count); }
/*------------------------------------------------- astring_cmpsubstr - compare a substring to an astring -------------------------------------------------*/
compare a substring to an astring
[ "compare", "a", "substring", "to", "an", "astring" ]
int astring_cmpsubstr(const astring *str1, const astring *str2, int start, int count) { normalize_substr(&start, &count, strlen(str2->text)); return astring_cmpch(str1, str2->text + start, count); }
[ "int", "astring_cmpsubstr", "(", "const", "astring", "*", "str1", ",", "const", "astring", "*", "str2", ",", "int", "start", ",", "int", "count", ")", "{", "normalize_substr", "(", "&", "start", ",", "&", "count", ",", "strlen", "(", "str2", "->", "text", ")", ")", ";", "return", "astring_cmpch", "(", "str1", ",", "str2", "->", "text", "+", "start", ",", "count", ")", ";", "}" ]
astring_cmpsubstr - compare a substring to an astring
[ "astring_cmpsubstr", "-", "compare", "a", "substring", "to", "an", "astring" ]
[]
[ { "param": "str1", "type": "astring" }, { "param": "str2", "type": "astring" }, { "param": "start", "type": "int" }, { "param": "count", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "str1", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "str2", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "start", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "count", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2261cbfd5fbac39942473a4fbe9e17ef8e7566cd
lofunz/mieme
Reloaded/trunk/src/lib/util/astring.c
[ "Unlicense" ]
C
astring_icmpc
int
int astring_icmpc(const astring *str1, const char *str2) { const char *s1 = str1->text; /* loop while equal until we hit the end of strings */ while (*s1 != 0 && *str2 != 0 && tolower((UINT8)*s1) == tolower((UINT8)*str2)) s1++, str2++; return tolower((UINT8)*s1) - tolower((UINT8)*str2); }
/*------------------------------------------------- astring_icmpc - case-insenstive compare a C string to an astring -------------------------------------------------*/
case-insenstive compare a C string to an astring
[ "case", "-", "insenstive", "compare", "a", "C", "string", "to", "an", "astring" ]
int astring_icmpc(const astring *str1, const char *str2) { const char *s1 = str1->text; while (*s1 != 0 && *str2 != 0 && tolower((UINT8)*s1) == tolower((UINT8)*str2)) s1++, str2++; return tolower((UINT8)*s1) - tolower((UINT8)*str2); }
[ "int", "astring_icmpc", "(", "const", "astring", "*", "str1", ",", "const", "char", "*", "str2", ")", "{", "const", "char", "*", "s1", "=", "str1", "->", "text", ";", "while", "(", "*", "s1", "!=", "0", "&&", "*", "str2", "!=", "0", "&&", "tolower", "(", "(", "UINT8", ")", "*", "s1", ")", "==", "tolower", "(", "(", "UINT8", ")", "*", "str2", ")", ")", "s1", "++", ",", "str2", "++", ";", "return", "tolower", "(", "(", "UINT8", ")", "*", "s1", ")", "-", "tolower", "(", "(", "UINT8", ")", "*", "str2", ")", ";", "}" ]
astring_icmpc - case-insenstive compare a C string to an astring
[ "astring_icmpc", "-", "case", "-", "insenstive", "compare", "a", "C", "string", "to", "an", "astring" ]
[ "/* loop while equal until we hit the end of strings */" ]
[ { "param": "str1", "type": "astring" }, { "param": "str2", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "str1", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "str2", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2261cbfd5fbac39942473a4fbe9e17ef8e7566cd
lofunz/mieme
Reloaded/trunk/src/lib/util/astring.c
[ "Unlicense" ]
C
astring_icmpch
int
int astring_icmpch(const astring *str1, const char *str2, int count) { const char *s1 = str1->text; int result; /* loop while equal until we hit the end of strings */ while (count-- > 0 && *s1 != 0 && *str2 != 0 && tolower((UINT8)*s1) == tolower((UINT8)*str2)) s1++, str2++; result = (count == -1) ? 0 : tolower((UINT8)*s1) - tolower((UINT8)*str2); if (result == 0 && *s1 != 0) result = 1; return result; }
/*------------------------------------------------- astring_icmpch - case-insenstive compare a character array to an astring -------------------------------------------------*/
case-insenstive compare a character array to an astring
[ "case", "-", "insenstive", "compare", "a", "character", "array", "to", "an", "astring" ]
int astring_icmpch(const astring *str1, const char *str2, int count) { const char *s1 = str1->text; int result; while (count-- > 0 && *s1 != 0 && *str2 != 0 && tolower((UINT8)*s1) == tolower((UINT8)*str2)) s1++, str2++; result = (count == -1) ? 0 : tolower((UINT8)*s1) - tolower((UINT8)*str2); if (result == 0 && *s1 != 0) result = 1; return result; }
[ "int", "astring_icmpch", "(", "const", "astring", "*", "str1", ",", "const", "char", "*", "str2", ",", "int", "count", ")", "{", "const", "char", "*", "s1", "=", "str1", "->", "text", ";", "int", "result", ";", "while", "(", "count", "--", ">", "0", "&&", "*", "s1", "!=", "0", "&&", "*", "str2", "!=", "0", "&&", "tolower", "(", "(", "UINT8", ")", "*", "s1", ")", "==", "tolower", "(", "(", "UINT8", ")", "*", "str2", ")", ")", "s1", "++", ",", "str2", "++", ";", "result", "=", "(", "count", "==", "-1", ")", "?", "0", ":", "tolower", "(", "(", "UINT8", ")", "*", "s1", ")", "-", "tolower", "(", "(", "UINT8", ")", "*", "str2", ")", ";", "if", "(", "result", "==", "0", "&&", "*", "s1", "!=", "0", ")", "result", "=", "1", ";", "return", "result", ";", "}" ]
astring_icmpch - case-insenstive compare a character array to an astring
[ "astring_icmpch", "-", "case", "-", "insenstive", "compare", "a", "character", "array", "to", "an", "astring" ]
[ "/* loop while equal until we hit the end of strings */" ]
[ { "param": "str1", "type": "astring" }, { "param": "str2", "type": "char" }, { "param": "count", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "str1", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "str2", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "count", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2261cbfd5fbac39942473a4fbe9e17ef8e7566cd
lofunz/mieme
Reloaded/trunk/src/lib/util/astring.c
[ "Unlicense" ]
C
astring_icmpsubstr
int
int astring_icmpsubstr(const astring *str1, const astring *str2, int start, int count) { normalize_substr(&start, &count, strlen(str2->text)); return astring_icmpch(str1, str2->text + start, count); }
/*------------------------------------------------- astring_icmpsubstr - case-insenstive compare a substring to an astring -------------------------------------------------*/
case-insenstive compare a substring to an astring
[ "case", "-", "insenstive", "compare", "a", "substring", "to", "an", "astring" ]
int astring_icmpsubstr(const astring *str1, const astring *str2, int start, int count) { normalize_substr(&start, &count, strlen(str2->text)); return astring_icmpch(str1, str2->text + start, count); }
[ "int", "astring_icmpsubstr", "(", "const", "astring", "*", "str1", ",", "const", "astring", "*", "str2", ",", "int", "start", ",", "int", "count", ")", "{", "normalize_substr", "(", "&", "start", ",", "&", "count", ",", "strlen", "(", "str2", "->", "text", ")", ")", ";", "return", "astring_icmpch", "(", "str1", ",", "str2", "->", "text", "+", "start", ",", "count", ")", ";", "}" ]
astring_icmpsubstr - case-insenstive compare a substring to an astring
[ "astring_icmpsubstr", "-", "case", "-", "insenstive", "compare", "a", "substring", "to", "an", "astring" ]
[]
[ { "param": "str1", "type": "astring" }, { "param": "str2", "type": "astring" }, { "param": "start", "type": "int" }, { "param": "count", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "str1", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "str2", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "start", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "count", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2261cbfd5fbac39942473a4fbe9e17ef8e7566cd
lofunz/mieme
Reloaded/trunk/src/lib/util/astring.c
[ "Unlicense" ]
C
astring_chr
int
int astring_chr(const astring *str, int start, int ch) { char *result = strchr(safe_string_base(str->text, start), ch); return (result != NULL) ? (result - str->text) : -1; }
/*------------------------------------------------- astring_chr - return the index of a character in an astring -------------------------------------------------*/
return the index of a character in an astring
[ "return", "the", "index", "of", "a", "character", "in", "an", "astring" ]
int astring_chr(const astring *str, int start, int ch) { char *result = strchr(safe_string_base(str->text, start), ch); return (result != NULL) ? (result - str->text) : -1; }
[ "int", "astring_chr", "(", "const", "astring", "*", "str", ",", "int", "start", ",", "int", "ch", ")", "{", "char", "*", "result", "=", "strchr", "(", "safe_string_base", "(", "str", "->", "text", ",", "start", ")", ",", "ch", ")", ";", "return", "(", "result", "!=", "NULL", ")", "?", "(", "result", "-", "str", "->", "text", ")", ":", "-1", ";", "}" ]
astring_chr - return the index of a character in an astring
[ "astring_chr", "-", "return", "the", "index", "of", "a", "character", "in", "an", "astring" ]
[]
[ { "param": "str", "type": "astring" }, { "param": "start", "type": "int" }, { "param": "ch", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "str", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "start", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ch", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2261cbfd5fbac39942473a4fbe9e17ef8e7566cd
lofunz/mieme
Reloaded/trunk/src/lib/util/astring.c
[ "Unlicense" ]
C
astring_rchr
int
int astring_rchr(const astring *str, int start, int ch) { char *result = strrchr(safe_string_base(str->text, start), ch); return (result != NULL) ? (result - str->text) : -1; }
/*------------------------------------------------- astring_rchr - return the index of a character in an astring, searching from the end -------------------------------------------------*/
return the index of a character in an astring, searching from the end
[ "return", "the", "index", "of", "a", "character", "in", "an", "astring", "searching", "from", "the", "end" ]
int astring_rchr(const astring *str, int start, int ch) { char *result = strrchr(safe_string_base(str->text, start), ch); return (result != NULL) ? (result - str->text) : -1; }
[ "int", "astring_rchr", "(", "const", "astring", "*", "str", ",", "int", "start", ",", "int", "ch", ")", "{", "char", "*", "result", "=", "strrchr", "(", "safe_string_base", "(", "str", "->", "text", ",", "start", ")", ",", "ch", ")", ";", "return", "(", "result", "!=", "NULL", ")", "?", "(", "result", "-", "str", "->", "text", ")", ":", "-1", ";", "}" ]
astring_rchr - return the index of a character in an astring, searching from the end
[ "astring_rchr", "-", "return", "the", "index", "of", "a", "character", "in", "an", "astring", "searching", "from", "the", "end" ]
[]
[ { "param": "str", "type": "astring" }, { "param": "start", "type": "int" }, { "param": "ch", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "str", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "start", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ch", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2261cbfd5fbac39942473a4fbe9e17ef8e7566cd
lofunz/mieme
Reloaded/trunk/src/lib/util/astring.c
[ "Unlicense" ]
C
astring_findc
int
int astring_findc(const astring *str, int start, const char *search) { char *result = strstr(safe_string_base(str->text, start), search); return (result != NULL) ? (result - str->text) : -1; }
/*------------------------------------------------- astring_findc - find a C string in an astring -------------------------------------------------*/
find a C string in an astring
[ "find", "a", "C", "string", "in", "an", "astring" ]
int astring_findc(const astring *str, int start, const char *search) { char *result = strstr(safe_string_base(str->text, start), search); return (result != NULL) ? (result - str->text) : -1; }
[ "int", "astring_findc", "(", "const", "astring", "*", "str", ",", "int", "start", ",", "const", "char", "*", "search", ")", "{", "char", "*", "result", "=", "strstr", "(", "safe_string_base", "(", "str", "->", "text", ",", "start", ")", ",", "search", ")", ";", "return", "(", "result", "!=", "NULL", ")", "?", "(", "result", "-", "str", "->", "text", ")", ":", "-1", ";", "}" ]
astring_findc - find a C string in an astring
[ "astring_findc", "-", "find", "a", "C", "string", "in", "an", "astring" ]
[]
[ { "param": "str", "type": "astring" }, { "param": "start", "type": "int" }, { "param": "search", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "str", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "start", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "search", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2261cbfd5fbac39942473a4fbe9e17ef8e7566cd
lofunz/mieme
Reloaded/trunk/src/lib/util/astring.c
[ "Unlicense" ]
C
astring_replacec
int
int astring_replacec(astring *str, int start, const char *search, const char *replace) { int searchlen = strlen(search); int replacelen = strlen(replace); int matches = 0; int curindex; for (curindex = astring_findc(str, start, search); curindex != -1; curindex = astring_findc(str, curindex + replacelen, search)) { matches++; astring_del(str, curindex, searchlen); astring_insc(str, curindex, replace); } return matches; }
/*------------------------------------------------- astring_replacec - search in an astring for a C string, replacing all instances with another C string and returning the number of matches -------------------------------------------------*/
search in an astring for a C string, replacing all instances with another C string and returning the number of matches
[ "search", "in", "an", "astring", "for", "a", "C", "string", "replacing", "all", "instances", "with", "another", "C", "string", "and", "returning", "the", "number", "of", "matches" ]
int astring_replacec(astring *str, int start, const char *search, const char *replace) { int searchlen = strlen(search); int replacelen = strlen(replace); int matches = 0; int curindex; for (curindex = astring_findc(str, start, search); curindex != -1; curindex = astring_findc(str, curindex + replacelen, search)) { matches++; astring_del(str, curindex, searchlen); astring_insc(str, curindex, replace); } return matches; }
[ "int", "astring_replacec", "(", "astring", "*", "str", ",", "int", "start", ",", "const", "char", "*", "search", ",", "const", "char", "*", "replace", ")", "{", "int", "searchlen", "=", "strlen", "(", "search", ")", ";", "int", "replacelen", "=", "strlen", "(", "replace", ")", ";", "int", "matches", "=", "0", ";", "int", "curindex", ";", "for", "(", "curindex", "=", "astring_findc", "(", "str", ",", "start", ",", "search", ")", ";", "curindex", "!=", "-1", ";", "curindex", "=", "astring_findc", "(", "str", ",", "curindex", "+", "replacelen", ",", "search", ")", ")", "{", "matches", "++", ";", "astring_del", "(", "str", ",", "curindex", ",", "searchlen", ")", ";", "astring_insc", "(", "str", ",", "curindex", ",", "replace", ")", ";", "}", "return", "matches", ";", "}" ]
astring_replacec - search in an astring for a C string, replacing all instances with another C string and returning the number of matches
[ "astring_replacec", "-", "search", "in", "an", "astring", "for", "a", "C", "string", "replacing", "all", "instances", "with", "another", "C", "string", "and", "returning", "the", "number", "of", "matches" ]
[]
[ { "param": "str", "type": "astring" }, { "param": "start", "type": "int" }, { "param": "search", "type": "char" }, { "param": "replace", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "str", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "start", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "search", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "replace", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2261cbfd5fbac39942473a4fbe9e17ef8e7566cd
lofunz/mieme
Reloaded/trunk/src/lib/util/astring.c
[ "Unlicense" ]
C
astring_toupper
astring
astring *astring_toupper(astring *str) { char *text; /* just toupper() on all characters */ for (text = str->text; *text != 0; text++) *text = toupper((UINT8)*text); return str; }
/*------------------------------------------------- astring_toupper - convert string to all upper-case -------------------------------------------------*/
convert string to all upper-case
[ "convert", "string", "to", "all", "upper", "-", "case" ]
astring *astring_toupper(astring *str) { char *text; for (text = str->text; *text != 0; text++) *text = toupper((UINT8)*text); return str; }
[ "astring", "*", "astring_toupper", "(", "astring", "*", "str", ")", "{", "char", "*", "text", ";", "for", "(", "text", "=", "str", "->", "text", ";", "*", "text", "!=", "0", ";", "text", "++", ")", "*", "text", "=", "toupper", "(", "(", "UINT8", ")", "*", "text", ")", ";", "return", "str", ";", "}" ]
astring_toupper - convert string to all upper-case
[ "astring_toupper", "-", "convert", "string", "to", "all", "upper", "-", "case" ]
[ "/* just toupper() on all characters */" ]
[ { "param": "str", "type": "astring" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "str", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2261cbfd5fbac39942473a4fbe9e17ef8e7566cd
lofunz/mieme
Reloaded/trunk/src/lib/util/astring.c
[ "Unlicense" ]
C
astring_tolower
astring
astring *astring_tolower(astring *str) { char *text; /* just tolower() on all characters */ for (text = str->text; *text != 0; text++) *text = tolower((UINT8)*text); return str; }
/*------------------------------------------------- astring_tolower - convert string to all lower-case -------------------------------------------------*/
convert string to all lower-case
[ "convert", "string", "to", "all", "lower", "-", "case" ]
astring *astring_tolower(astring *str) { char *text; for (text = str->text; *text != 0; text++) *text = tolower((UINT8)*text); return str; }
[ "astring", "*", "astring_tolower", "(", "astring", "*", "str", ")", "{", "char", "*", "text", ";", "for", "(", "text", "=", "str", "->", "text", ";", "*", "text", "!=", "0", ";", "text", "++", ")", "*", "text", "=", "tolower", "(", "(", "UINT8", ")", "*", "text", ")", ";", "return", "str", ";", "}" ]
astring_tolower - convert string to all lower-case
[ "astring_tolower", "-", "convert", "string", "to", "all", "lower", "-", "case" ]
[ "/* just tolower() on all characters */" ]
[ { "param": "str", "type": "astring" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "str", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2261cbfd5fbac39942473a4fbe9e17ef8e7566cd
lofunz/mieme
Reloaded/trunk/src/lib/util/astring.c
[ "Unlicense" ]
C
astring_trimspace
astring
astring *astring_trimspace(astring *str) { char *ptr; /* first remove stuff from the end */ for (ptr = str->text + strlen(str->text) - 1; ptr >= str->text && (!(*ptr & 0x80) && isspace((UINT8)*ptr)); ptr--) *ptr = 0; /* then count how much to remove from the beginning */ for (ptr = str->text; *ptr != 0 && (!(*ptr & 0x80) && isspace((UINT8)*ptr)); ptr++) ; if (ptr > str->text) astring_substr(str, ptr - str->text, -1); return str; }
/*------------------------------------------------- astring_trimspace - remove all space characters from beginning/end -------------------------------------------------*/
remove all space characters from beginning/end
[ "remove", "all", "space", "characters", "from", "beginning", "/", "end" ]
astring *astring_trimspace(astring *str) { char *ptr; for (ptr = str->text + strlen(str->text) - 1; ptr >= str->text && (!(*ptr & 0x80) && isspace((UINT8)*ptr)); ptr--) *ptr = 0; for (ptr = str->text; *ptr != 0 && (!(*ptr & 0x80) && isspace((UINT8)*ptr)); ptr++) ; if (ptr > str->text) astring_substr(str, ptr - str->text, -1); return str; }
[ "astring", "*", "astring_trimspace", "(", "astring", "*", "str", ")", "{", "char", "*", "ptr", ";", "for", "(", "ptr", "=", "str", "->", "text", "+", "strlen", "(", "str", "->", "text", ")", "-", "1", ";", "ptr", ">=", "str", "->", "text", "&&", "(", "!", "(", "*", "ptr", "&", "0x80", ")", "&&", "isspace", "(", "(", "UINT8", ")", "*", "ptr", ")", ")", ";", "ptr", "--", ")", "*", "ptr", "=", "0", ";", "for", "(", "ptr", "=", "str", "->", "text", ";", "*", "ptr", "!=", "0", "&&", "(", "!", "(", "*", "ptr", "&", "0x80", ")", "&&", "isspace", "(", "(", "UINT8", ")", "*", "ptr", ")", ")", ";", "ptr", "++", ")", ";", "if", "(", "ptr", ">", "str", "->", "text", ")", "astring_substr", "(", "str", ",", "ptr", "-", "str", "->", "text", ",", "-1", ")", ";", "return", "str", ";", "}" ]
astring_trimspace - remove all space characters from beginning/end
[ "astring_trimspace", "-", "remove", "all", "space", "characters", "from", "beginning", "/", "end" ]
[ "/* first remove stuff from the end */", "/* then count how much to remove from the beginning */" ]
[ { "param": "str", "type": "astring" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "str", "type": "astring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
220bcbc29739b19f65e1b7b4522b57b4750d530d
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/video/twincobr.c
[ "Unlicense" ]
C
wardner_sprite_priority_hack
void
static void wardner_sprite_priority_hack(void) { if (fgscrollx != bgscrollx) { if ((fgscrollx==0x1c9) || (twincobr_flip_screen && (fgscrollx==0x17a))) { /* in the shop ? */ int wardner_hack = buffered_spriteram16[0x0b04/2]; /* sprite position 0x6300 to 0x8700 -- hero on shop keeper (normal) */ /* sprite position 0x3900 to 0x5e00 -- hero on shop keeper (flip) */ if ((wardner_hack > 0x3900) && (wardner_hack < 0x8700)) { /* hero at shop keeper ? */ wardner_hack = buffered_spriteram16[0x0b02/2]; wardner_hack |= 0x0400; /* make hero top priority */ buffered_spriteram16[0x0b02/2] = wardner_hack; wardner_hack = buffered_spriteram16[0x0b0a/2]; wardner_hack |= 0x0400; buffered_spriteram16[0x0b0a/2] = wardner_hack; wardner_hack = buffered_spriteram16[0x0b12/2]; wardner_hack |= 0x0400; buffered_spriteram16[0x0b12/2] = wardner_hack; wardner_hack = buffered_spriteram16[0x0b1a/2]; wardner_hack |= 0x0400; buffered_spriteram16[0x0b1a/2] = wardner_hack; } } } }
/*************************************************************************** Ugly sprite hack for Wardner when hero is in shop ***************************************************************************/
Ugly sprite hack for Wardner when hero is in shop
[ "Ugly", "sprite", "hack", "for", "Wardner", "when", "hero", "is", "in", "shop" ]
static void wardner_sprite_priority_hack(void) { if (fgscrollx != bgscrollx) { if ((fgscrollx==0x1c9) || (twincobr_flip_screen && (fgscrollx==0x17a))) { int wardner_hack = buffered_spriteram16[0x0b04/2]; if ((wardner_hack > 0x3900) && (wardner_hack < 0x8700)) { wardner_hack = buffered_spriteram16[0x0b02/2]; wardner_hack |= 0x0400; buffered_spriteram16[0x0b02/2] = wardner_hack; wardner_hack = buffered_spriteram16[0x0b0a/2]; wardner_hack |= 0x0400; buffered_spriteram16[0x0b0a/2] = wardner_hack; wardner_hack = buffered_spriteram16[0x0b12/2]; wardner_hack |= 0x0400; buffered_spriteram16[0x0b12/2] = wardner_hack; wardner_hack = buffered_spriteram16[0x0b1a/2]; wardner_hack |= 0x0400; buffered_spriteram16[0x0b1a/2] = wardner_hack; } } } }
[ "static", "void", "wardner_sprite_priority_hack", "(", "void", ")", "{", "if", "(", "fgscrollx", "!=", "bgscrollx", ")", "{", "if", "(", "(", "fgscrollx", "==", "0x1c9", ")", "||", "(", "twincobr_flip_screen", "&&", "(", "fgscrollx", "==", "0x17a", ")", ")", ")", "{", "int", "wardner_hack", "=", "buffered_spriteram16", "[", "0x0b04", "/", "2", "]", ";", "if", "(", "(", "wardner_hack", ">", "0x3900", ")", "&&", "(", "wardner_hack", "<", "0x8700", ")", ")", "{", "wardner_hack", "=", "buffered_spriteram16", "[", "0x0b02", "/", "2", "]", ";", "wardner_hack", "|=", "0x0400", ";", "buffered_spriteram16", "[", "0x0b02", "/", "2", "]", "=", "wardner_hack", ";", "wardner_hack", "=", "buffered_spriteram16", "[", "0x0b0a", "/", "2", "]", ";", "wardner_hack", "|=", "0x0400", ";", "buffered_spriteram16", "[", "0x0b0a", "/", "2", "]", "=", "wardner_hack", ";", "wardner_hack", "=", "buffered_spriteram16", "[", "0x0b12", "/", "2", "]", ";", "wardner_hack", "|=", "0x0400", ";", "buffered_spriteram16", "[", "0x0b12", "/", "2", "]", "=", "wardner_hack", ";", "wardner_hack", "=", "buffered_spriteram16", "[", "0x0b1a", "/", "2", "]", ";", "wardner_hack", "|=", "0x0400", ";", "buffered_spriteram16", "[", "0x0b1a", "/", "2", "]", "=", "wardner_hack", ";", "}", "}", "}", "}" ]
Ugly sprite hack for Wardner when hero is in shop
[ "Ugly", "sprite", "hack", "for", "Wardner", "when", "hero", "is", "in", "shop" ]
[ "/* in the shop ? */", "/* sprite position 0x6300 to 0x8700 -- hero on shop keeper (normal) */", "/* sprite position 0x3900 to 0x5e00 -- hero on shop keeper (flip) */", "/* hero at shop keeper ? */", "/* make hero top priority */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
0c67a148737a8d2a5833910cf929f01c466645e1
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/drivers/goldstar.c
[ "Unlicense" ]
C
do_blockswaps
void
static void do_blockswaps(UINT8* ROM) { int A; UINT8 *buffer; static const UINT16 cherry_swaptables[32] = { /* to align with goldstar */ 0x0800, 0x4000, 0x2800, 0x5800, 0x1800, 0x3000, 0x6800, 0x7000, 0x0000, 0x4800, 0x2000, 0x5000, 0x1000, 0x7800, 0x6000, 0x3800, /* bit below, I'm not sure, no exact match, but only the first ones matter, as the is just garbage */ 0xc000, 0xc800, 0xd000, 0xd800, 0xe000, 0xe800, 0xf000, 0xf800, 0x8000, 0x8800, 0x9000, 0x9800, 0xa000, 0xa800, 0xb000, 0xb800, }; buffer = alloc_array_or_die(UINT8, 0x10000); memcpy(buffer,ROM,0x10000); // swap some 0x800 blocks around.. for (A =0;A<32; A++) { memcpy(ROM+A*0x800,buffer+cherry_swaptables[A],0x800); } free(buffer); }
// this block swapping is the same for chry10, chrygld and cb3 // the underlying bitswaps / xors are different however
this block swapping is the same for chry10, chrygld and cb3 the underlying bitswaps / xors are different however
[ "this", "block", "swapping", "is", "the", "same", "for", "chry10", "chrygld", "and", "cb3", "the", "underlying", "bitswaps", "/", "xors", "are", "different", "however" ]
static void do_blockswaps(UINT8* ROM) { int A; UINT8 *buffer; static const UINT16 cherry_swaptables[32] = { 0x0800, 0x4000, 0x2800, 0x5800, 0x1800, 0x3000, 0x6800, 0x7000, 0x0000, 0x4800, 0x2000, 0x5000, 0x1000, 0x7800, 0x6000, 0x3800, 0xc000, 0xc800, 0xd000, 0xd800, 0xe000, 0xe800, 0xf000, 0xf800, 0x8000, 0x8800, 0x9000, 0x9800, 0xa000, 0xa800, 0xb000, 0xb800, }; buffer = alloc_array_or_die(UINT8, 0x10000); memcpy(buffer,ROM,0x10000); for (A =0;A<32; A++) { memcpy(ROM+A*0x800,buffer+cherry_swaptables[A],0x800); } free(buffer); }
[ "static", "void", "do_blockswaps", "(", "UINT8", "*", "ROM", ")", "{", "int", "A", ";", "UINT8", "*", "buffer", ";", "static", "const", "UINT16", "cherry_swaptables", "[", "32", "]", "=", "{", "0x0800", ",", "0x4000", ",", "0x2800", ",", "0x5800", ",", "0x1800", ",", "0x3000", ",", "0x6800", ",", "0x7000", ",", "0x0000", ",", "0x4800", ",", "0x2000", ",", "0x5000", ",", "0x1000", ",", "0x7800", ",", "0x6000", ",", "0x3800", ",", "0xc000", ",", "0xc800", ",", "0xd000", ",", "0xd800", ",", "0xe000", ",", "0xe800", ",", "0xf000", ",", "0xf800", ",", "0x8000", ",", "0x8800", ",", "0x9000", ",", "0x9800", ",", "0xa000", ",", "0xa800", ",", "0xb000", ",", "0xb800", ",", "}", ";", "buffer", "=", "alloc_array_or_die", "(", "UINT8", ",", "0x10000", ")", ";", "memcpy", "(", "buffer", ",", "ROM", ",", "0x10000", ")", ";", "for", "(", "A", "=", "0", ";", "A", "<", "32", ";", "A", "++", ")", "{", "memcpy", "(", "ROM", "+", "A", "*", "0x800", ",", "buffer", "+", "cherry_swaptables", "[", "A", "]", ",", "0x800", ")", ";", "}", "free", "(", "buffer", ")", ";", "}" ]
this block swapping is the same for chry10, chrygld and cb3 the underlying bitswaps / xors are different however
[ "this", "block", "swapping", "is", "the", "same", "for", "chry10", "chrygld", "and", "cb3", "the", "underlying", "bitswaps", "/", "xors", "are", "different", "however" ]
[ "/* to align with goldstar */", "/* bit below, I'm not sure, no exact match, but only the first ones matter,\n as the is just garbage */", "// swap some 0x800 blocks around.." ]
[ { "param": "ROM", "type": "UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ROM", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
02ef7c1e23c92b1c9592f45f56c79a2ef704d7cb
lofunz/mieme
Reloaded/trunk/src/mame/machine/subs.c
[ "Unlicense" ]
C
subs_steering_1
int
static int subs_steering_1(running_machine *machine) { static int last_val=0; int this_val; int delta; this_val=input_port_read(machine, "DIAL2"); delta=this_val-last_val; last_val=this_val; if (delta>128) delta-=256; else if (delta<-128) delta+=256; /* Divide by four to make our steering less sensitive */ subs_steering_buf1+=(delta/4); if (subs_steering_buf1>0) { subs_steering_buf1--; subs_steering_val1=0xC0; } else if (subs_steering_buf1<0) { subs_steering_buf1++; subs_steering_val1=0x80; } return subs_steering_val1; }
/*************************************************************************** Steering When D7 is high, the steering wheel has moved. If D6 is high, it moved left. If D6 is low, it moved right. Be sure to keep returning a direction until steer_reset is called. ***************************************************************************/
Steering When D7 is high, the steering wheel has moved. If D6 is high, it moved left. If D6 is low, it moved right. Be sure to keep returning a direction until steer_reset is called.
[ "Steering", "When", "D7", "is", "high", "the", "steering", "wheel", "has", "moved", ".", "If", "D6", "is", "high", "it", "moved", "left", ".", "If", "D6", "is", "low", "it", "moved", "right", ".", "Be", "sure", "to", "keep", "returning", "a", "direction", "until", "steer_reset", "is", "called", "." ]
static int subs_steering_1(running_machine *machine) { static int last_val=0; int this_val; int delta; this_val=input_port_read(machine, "DIAL2"); delta=this_val-last_val; last_val=this_val; if (delta>128) delta-=256; else if (delta<-128) delta+=256; subs_steering_buf1+=(delta/4); if (subs_steering_buf1>0) { subs_steering_buf1--; subs_steering_val1=0xC0; } else if (subs_steering_buf1<0) { subs_steering_buf1++; subs_steering_val1=0x80; } return subs_steering_val1; }
[ "static", "int", "subs_steering_1", "(", "running_machine", "*", "machine", ")", "{", "static", "int", "last_val", "=", "0", ";", "int", "this_val", ";", "int", "delta", ";", "this_val", "=", "input_port_read", "(", "machine", ",", "\"", "\"", ")", ";", "delta", "=", "this_val", "-", "last_val", ";", "last_val", "=", "this_val", ";", "if", "(", "delta", ">", "128", ")", "delta", "-=", "256", ";", "else", "if", "(", "delta", "<", "-128", ")", "delta", "+=", "256", ";", "subs_steering_buf1", "+=", "(", "delta", "/", "4", ")", ";", "if", "(", "subs_steering_buf1", ">", "0", ")", "{", "subs_steering_buf1", "--", ";", "subs_steering_val1", "=", "0xC0", ";", "}", "else", "if", "(", "subs_steering_buf1", "<", "0", ")", "{", "subs_steering_buf1", "++", ";", "subs_steering_val1", "=", "0x80", ";", "}", "return", "subs_steering_val1", ";", "}" ]
Steering When D7 is high, the steering wheel has moved.
[ "Steering", "When", "D7", "is", "high", "the", "steering", "wheel", "has", "moved", "." ]
[ "/* Divide by four to make our steering less sensitive */" ]
[ { "param": "machine", "type": "running_machine" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7aaa9b7c5a550a43c9cc15cc78e19c1a18249009
lofunz/mieme
Reloaded/trunk/src/emu/cpu/mcs48/mcs48.c
[ "Unlicense" ]
C
burn_cycles
void
static void burn_cycles(mcs48_state *cpustate, int count) { int timerover = FALSE; /* if the timer is enabled, accumulate prescaler cycles */ if (cpustate->timecount_enabled & TIMER_ENABLED) { UINT8 oldtimer = cpustate->timer; cpustate->prescaler += count; cpustate->timer += cpustate->prescaler >> 5; cpustate->prescaler &= 0x1f; timerover = (oldtimer != 0 && cpustate->timer == 0); } /* if the counter is enabled, poll the T1 test input once for each cycle */ else if (cpustate->timecount_enabled & COUNTER_ENABLED) for ( ; count > 0; count--) { cpustate->t1_history = (cpustate->t1_history << 1) | (test_r(1) & 1); if ((cpustate->t1_history & 3) == 2) timerover = (++cpustate->timer == 0); } /* if either source caused a timer overflow, set the flags and check IRQs */ if (timerover) { cpustate->timer_flag = TRUE; /* according to the docs, if an overflow occurs with interrupts disabled, the overflow is not stored */ if (cpustate->tirq_enabled) { cpustate->timer_overflow = TRUE; check_irqs(cpustate); } } }
/*------------------------------------------------- burn_cycles - burn cycles, processing timers and counters -------------------------------------------------*/
burn cycles, processing timers and counters
[ "burn", "cycles", "processing", "timers", "and", "counters" ]
static void burn_cycles(mcs48_state *cpustate, int count) { int timerover = FALSE; if (cpustate->timecount_enabled & TIMER_ENABLED) { UINT8 oldtimer = cpustate->timer; cpustate->prescaler += count; cpustate->timer += cpustate->prescaler >> 5; cpustate->prescaler &= 0x1f; timerover = (oldtimer != 0 && cpustate->timer == 0); } else if (cpustate->timecount_enabled & COUNTER_ENABLED) for ( ; count > 0; count--) { cpustate->t1_history = (cpustate->t1_history << 1) | (test_r(1) & 1); if ((cpustate->t1_history & 3) == 2) timerover = (++cpustate->timer == 0); } if (timerover) { cpustate->timer_flag = TRUE; if (cpustate->tirq_enabled) { cpustate->timer_overflow = TRUE; check_irqs(cpustate); } } }
[ "static", "void", "burn_cycles", "(", "mcs48_state", "*", "cpustate", ",", "int", "count", ")", "{", "int", "timerover", "=", "FALSE", ";", "if", "(", "cpustate", "->", "timecount_enabled", "&", "TIMER_ENABLED", ")", "{", "UINT8", "oldtimer", "=", "cpustate", "->", "timer", ";", "cpustate", "->", "prescaler", "+=", "count", ";", "cpustate", "->", "timer", "+=", "cpustate", "->", "prescaler", ">>", "5", ";", "cpustate", "->", "prescaler", "&=", "0x1f", ";", "timerover", "=", "(", "oldtimer", "!=", "0", "&&", "cpustate", "->", "timer", "==", "0", ")", ";", "}", "else", "if", "(", "cpustate", "->", "timecount_enabled", "&", "COUNTER_ENABLED", ")", "for", "(", ";", "count", ">", "0", ";", "count", "--", ")", "{", "cpustate", "->", "t1_history", "=", "(", "cpustate", "->", "t1_history", "<<", "1", ")", "|", "(", "test_r", "(", "1", ")", "&", "1", ")", ";", "if", "(", "(", "cpustate", "->", "t1_history", "&", "3", ")", "==", "2", ")", "timerover", "=", "(", "++", "cpustate", "->", "timer", "==", "0", ")", ";", "}", "if", "(", "timerover", ")", "{", "cpustate", "->", "timer_flag", "=", "TRUE", ";", "if", "(", "cpustate", "->", "tirq_enabled", ")", "{", "cpustate", "->", "timer_overflow", "=", "TRUE", ";", "check_irqs", "(", "cpustate", ")", ";", "}", "}", "}" ]
burn_cycles - burn cycles, processing timers and counters
[ "burn_cycles", "-", "burn", "cycles", "processing", "timers", "and", "counters" ]
[ "/* if the timer is enabled, accumulate prescaler cycles */", "/* if the counter is enabled, poll the T1 test input once for each cycle */", "/* if either source caused a timer overflow, set the flags and check IRQs */", "/* according to the docs, if an overflow occurs with interrupts disabled, the overflow is not stored */" ]
[ { "param": "cpustate", "type": "mcs48_state" }, { "param": "count", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cpustate", "type": "mcs48_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "count", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7aaa9b7c5a550a43c9cc15cc78e19c1a18249009
lofunz/mieme
Reloaded/trunk/src/emu/cpu/mcs48/mcs48.c
[ "Unlicense" ]
C
upi41_master_r
UINT8
UINT8 upi41_master_r(running_device *device, UINT8 a0) { mcs48_state *cpustate = get_safe_token(device); /* if just reading the status, return it */ if ((a0 & 1) != 0) return cpustate->sts; /* if the output buffer was full, it gets cleared now */ if (cpustate->sts & STS_OBF) { cpustate->sts &= ~STS_OBF; if (cpustate->flags_enabled) port_w(2, cpustate->p2 &= ~P2_OBF); } return cpustate->dbbo; }
/*------------------------------------------------- upi41_master_r - master CPU data/status read -------------------------------------------------*/
master CPU data/status read
[ "master", "CPU", "data", "/", "status", "read" ]
UINT8 upi41_master_r(running_device *device, UINT8 a0) { mcs48_state *cpustate = get_safe_token(device); if ((a0 & 1) != 0) return cpustate->sts; if (cpustate->sts & STS_OBF) { cpustate->sts &= ~STS_OBF; if (cpustate->flags_enabled) port_w(2, cpustate->p2 &= ~P2_OBF); } return cpustate->dbbo; }
[ "UINT8", "upi41_master_r", "(", "running_device", "*", "device", ",", "UINT8", "a0", ")", "{", "mcs48_state", "*", "cpustate", "=", "get_safe_token", "(", "device", ")", ";", "if", "(", "(", "a0", "&", "1", ")", "!=", "0", ")", "return", "cpustate", "->", "sts", ";", "if", "(", "cpustate", "->", "sts", "&", "STS_OBF", ")", "{", "cpustate", "->", "sts", "&=", "~", "STS_OBF", ";", "if", "(", "cpustate", "->", "flags_enabled", ")", "port_w", "(", "2", ",", "cpustate", "->", "p2", "&=", "~", "P2_OBF", ")", ";", "}", "return", "cpustate", "->", "dbbo", ";", "}" ]
upi41_master_r - master CPU data/status read
[ "upi41_master_r", "-", "master", "CPU", "data", "/", "status", "read" ]
[ "/* if just reading the status, return it */", "/* if the output buffer was full, it gets cleared now */" ]
[ { "param": "device", "type": "running_device" }, { "param": "a0", "type": "UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "device", "type": "running_device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "a0", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3de2cf025ba9916aef134b4711f68d30d1a9f4f3
lofunz/mieme
Reloaded/trunk/src/mame/video/route16.c
[ "Unlicense" ]
C
video_update_stratvox_ttmahjng
int
static int video_update_stratvox_ttmahjng(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, pen_t (*make_pen)(UINT8)) { offs_t offs; UINT8 *color_prom1 = &memory_region(machine, "proms")[0x000]; UINT8 *color_prom2 = &memory_region(machine, "proms")[0x100]; for (offs = 0; offs < route16_videoram_size; offs++) { int i; UINT8 y = offs >> 6; UINT8 x = offs << 2; UINT8 data1 = route16_videoram1[offs]; UINT8 data2 = route16_videoram2[offs]; for (i = 0; i < 4; i++) { UINT8 color1 = color_prom1[(palette_1 << 2) | ((data1 >> 3) & 0x02) | ((data1 >> 0) & 0x01)]; /* bit 7 of the 2nd color is the OR of the 1st color bits 0 and 1 (verified) */ UINT8 color2 = color_prom2[(((data1 << 3) & 0x80) | ((data1 << 7) & 0x80)) | (palette_2 << 2) | ((data2 >> 3) & 0x02) | ((data2 >> 0) & 0x01)]; /* the final color is the OR of the two colors */ UINT8 final_color = color1 | color2; pen_t pen = make_pen(final_color); if (flipscreen) *BITMAP_ADDR32(bitmap, 255 - y, 255 - x) = pen; else *BITMAP_ADDR32(bitmap, y, x) = pen; x = x + 1; data1 = data1 >> 1; data2 = data2 >> 1; } } return 0; }
/* * The Stratovox video connections have been verified from the schematics */
The Stratovox video connections have been verified from the schematics
[ "The", "Stratovox", "video", "connections", "have", "been", "verified", "from", "the", "schematics" ]
static int video_update_stratvox_ttmahjng(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, pen_t (*make_pen)(UINT8)) { offs_t offs; UINT8 *color_prom1 = &memory_region(machine, "proms")[0x000]; UINT8 *color_prom2 = &memory_region(machine, "proms")[0x100]; for (offs = 0; offs < route16_videoram_size; offs++) { int i; UINT8 y = offs >> 6; UINT8 x = offs << 2; UINT8 data1 = route16_videoram1[offs]; UINT8 data2 = route16_videoram2[offs]; for (i = 0; i < 4; i++) { UINT8 color1 = color_prom1[(palette_1 << 2) | ((data1 >> 3) & 0x02) | ((data1 >> 0) & 0x01)]; UINT8 color2 = color_prom2[(((data1 << 3) & 0x80) | ((data1 << 7) & 0x80)) | (palette_2 << 2) | ((data2 >> 3) & 0x02) | ((data2 >> 0) & 0x01)]; UINT8 final_color = color1 | color2; pen_t pen = make_pen(final_color); if (flipscreen) *BITMAP_ADDR32(bitmap, 255 - y, 255 - x) = pen; else *BITMAP_ADDR32(bitmap, y, x) = pen; x = x + 1; data1 = data1 >> 1; data2 = data2 >> 1; } } return 0; }
[ "static", "int", "video_update_stratvox_ttmahjng", "(", "running_machine", "*", "machine", ",", "bitmap_t", "*", "bitmap", ",", "const", "rectangle", "*", "cliprect", ",", "pen_t", "(", "*", "make_pen", ")", "(", "UINT8", ")", ")", "{", "offs_t", "offs", ";", "UINT8", "*", "color_prom1", "=", "&", "memory_region", "(", "machine", ",", "\"", "\"", ")", "[", "0x000", "]", ";", "UINT8", "*", "color_prom2", "=", "&", "memory_region", "(", "machine", ",", "\"", "\"", ")", "[", "0x100", "]", ";", "for", "(", "offs", "=", "0", ";", "offs", "<", "route16_videoram_size", ";", "offs", "++", ")", "{", "int", "i", ";", "UINT8", "y", "=", "offs", ">>", "6", ";", "UINT8", "x", "=", "offs", "<<", "2", ";", "UINT8", "data1", "=", "route16_videoram1", "[", "offs", "]", ";", "UINT8", "data2", "=", "route16_videoram2", "[", "offs", "]", ";", "for", "(", "i", "=", "0", ";", "i", "<", "4", ";", "i", "++", ")", "{", "UINT8", "color1", "=", "color_prom1", "[", "(", "palette_1", "<<", "2", ")", "|", "(", "(", "data1", ">>", "3", ")", "&", "0x02", ")", "|", "(", "(", "data1", ">>", "0", ")", "&", "0x01", ")", "]", ";", "UINT8", "color2", "=", "color_prom2", "[", "(", "(", "(", "data1", "<<", "3", ")", "&", "0x80", ")", "|", "(", "(", "data1", "<<", "7", ")", "&", "0x80", ")", ")", "|", "(", "palette_2", "<<", "2", ")", "|", "(", "(", "data2", ">>", "3", ")", "&", "0x02", ")", "|", "(", "(", "data2", ">>", "0", ")", "&", "0x01", ")", "]", ";", "UINT8", "final_color", "=", "color1", "|", "color2", ";", "pen_t", "pen", "=", "make_pen", "(", "final_color", ")", ";", "if", "(", "flipscreen", ")", "*", "BITMAP_ADDR32", "(", "bitmap", ",", "255", "-", "y", ",", "255", "-", "x", ")", "=", "pen", ";", "else", "*", "BITMAP_ADDR32", "(", "bitmap", ",", "y", ",", "x", ")", "=", "pen", ";", "x", "=", "x", "+", "1", ";", "data1", "=", "data1", ">>", "1", ";", "data2", "=", "data2", ">>", "1", ";", "}", "}", "return", "0", ";", "}" ]
The Stratovox video connections have been verified from the schematics
[ "The", "Stratovox", "video", "connections", "have", "been", "verified", "from", "the", "schematics" ]
[ "/* bit 7 of the 2nd color is the OR of the 1st color bits 0 and 1 (verified) */", "/* the final color is the OR of the two colors */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "bitmap", "type": "bitmap_t" }, { "param": "cliprect", "type": "rectangle" }, { "param": "make_pen", "type": "pen_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 }, { "identifier": "cliprect", "type": "rectangle", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "make_pen", "type": "pen_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9fb9c5cf4c3689ffe2d2bb3bbbdf91d2f0ecaf01
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/powerpc/ppccom.c
[ "Unlicense" ]
C
ppccom_init
void
void ppccom_init(powerpc_state *ppc, powerpc_flavor flavor, UINT8 cap, int tb_divisor, const device_config *device, cpu_irq_callback irqcallback) { const powerpc_config *config = (const powerpc_config *)device->static_config; /* initialize based on the config */ memset(ppc, 0, sizeof(*ppc)); ppc->flavor = flavor; ppc->cap = cap; ppc->cache_line_size = 32; ppc->tb_divisor = tb_divisor; ppc->cpu_clock = device->clock; ppc->irq_callback = irqcallback; ppc->device = device; ppc->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM); ppc->system_clock = (config != NULL) ? config->bus_frequency : device->clock; ppc->tb_divisor = (ppc->tb_divisor * device->clock + ppc->system_clock / 2 - 1) / ppc->system_clock; ppc->codexor = 0; if (!(cap & PPCCAP_4XX) && cpu_get_endianness(device) != ENDIANNESS_NATIVE) ppc->codexor = 4; /* allocate the virtual TLB */ ppc->vtlb = vtlb_alloc(device, ADDRESS_SPACE_PROGRAM, (cap & PPCCAP_603_MMU) ? PPC603_FIXED_TLB_ENTRIES : 0, POWERPC_TLB_ENTRIES); /* allocate a timer for the compare interrupt */ if (cap & PPCCAP_OEA) ppc->decrementer_int_timer = timer_alloc(device->machine, decrementer_int_callback, ppc); /* and for the 4XX interrupts if needed */ if (cap & PPCCAP_4XX) { ppc->fit_timer = timer_alloc(device->machine, ppc4xx_fit_callback, ppc); ppc->pit_timer = timer_alloc(device->machine, ppc4xx_pit_callback, ppc); ppc->spu.timer = timer_alloc(device->machine, ppc4xx_spu_callback, ppc); } /* register for save states */ state_save_register_device_item(device, 0, ppc->pc); state_save_register_device_item_array(device, 0, ppc->r); state_save_register_device_item_array(device, 0, ppc->f); state_save_register_device_item_array(device, 0, ppc->cr); state_save_register_device_item(device, 0, ppc->xerso); state_save_register_device_item(device, 0, ppc->fpscr); state_save_register_device_item(device, 0, ppc->msr); state_save_register_device_item_array(device, 0, ppc->sr); state_save_register_device_item_array(device, 0, ppc->spr); state_save_register_device_item_array(device, 0, ppc->dcr); if (cap & PPCCAP_4XX) { state_save_register_device_item_array(device, 0, ppc->spu.regs); state_save_register_device_item(device, 0, ppc->spu.txbuf); state_save_register_device_item(device, 0, ppc->spu.rxbuf); state_save_register_device_item_array(device, 0, ppc->spu.rxbuffer); state_save_register_device_item(device, 0, ppc->spu.rxin); state_save_register_device_item(device, 0, ppc->spu.rxout); state_save_register_device_item(device, 0, ppc->pit_reload); state_save_register_device_item(device, 0, ppc->irqstate); } if (cap & PPCCAP_603_MMU) { state_save_register_device_item(device, 0, ppc->mmu603_cmp); state_save_register_device_item_array(device, 0, ppc->mmu603_hash); state_save_register_device_item_array(device, 0, ppc->mmu603_r); } state_save_register_device_item(device, 0, ppc->irq_pending); state_save_register_device_item(device, 0, ppc->tb_zero_cycles); state_save_register_device_item(device, 0, ppc->dec_zero_cycles); }
/*------------------------------------------------- ppccom_init - initialize the powerpc_state structure based on the configured type -------------------------------------------------*/
initialize the powerpc_state structure based on the configured type
[ "initialize", "the", "powerpc_state", "structure", "based", "on", "the", "configured", "type" ]
void ppccom_init(powerpc_state *ppc, powerpc_flavor flavor, UINT8 cap, int tb_divisor, const device_config *device, cpu_irq_callback irqcallback) { const powerpc_config *config = (const powerpc_config *)device->static_config; memset(ppc, 0, sizeof(*ppc)); ppc->flavor = flavor; ppc->cap = cap; ppc->cache_line_size = 32; ppc->tb_divisor = tb_divisor; ppc->cpu_clock = device->clock; ppc->irq_callback = irqcallback; ppc->device = device; ppc->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM); ppc->system_clock = (config != NULL) ? config->bus_frequency : device->clock; ppc->tb_divisor = (ppc->tb_divisor * device->clock + ppc->system_clock / 2 - 1) / ppc->system_clock; ppc->codexor = 0; if (!(cap & PPCCAP_4XX) && cpu_get_endianness(device) != ENDIANNESS_NATIVE) ppc->codexor = 4; ppc->vtlb = vtlb_alloc(device, ADDRESS_SPACE_PROGRAM, (cap & PPCCAP_603_MMU) ? PPC603_FIXED_TLB_ENTRIES : 0, POWERPC_TLB_ENTRIES); if (cap & PPCCAP_OEA) ppc->decrementer_int_timer = timer_alloc(device->machine, decrementer_int_callback, ppc); if (cap & PPCCAP_4XX) { ppc->fit_timer = timer_alloc(device->machine, ppc4xx_fit_callback, ppc); ppc->pit_timer = timer_alloc(device->machine, ppc4xx_pit_callback, ppc); ppc->spu.timer = timer_alloc(device->machine, ppc4xx_spu_callback, ppc); } state_save_register_device_item(device, 0, ppc->pc); state_save_register_device_item_array(device, 0, ppc->r); state_save_register_device_item_array(device, 0, ppc->f); state_save_register_device_item_array(device, 0, ppc->cr); state_save_register_device_item(device, 0, ppc->xerso); state_save_register_device_item(device, 0, ppc->fpscr); state_save_register_device_item(device, 0, ppc->msr); state_save_register_device_item_array(device, 0, ppc->sr); state_save_register_device_item_array(device, 0, ppc->spr); state_save_register_device_item_array(device, 0, ppc->dcr); if (cap & PPCCAP_4XX) { state_save_register_device_item_array(device, 0, ppc->spu.regs); state_save_register_device_item(device, 0, ppc->spu.txbuf); state_save_register_device_item(device, 0, ppc->spu.rxbuf); state_save_register_device_item_array(device, 0, ppc->spu.rxbuffer); state_save_register_device_item(device, 0, ppc->spu.rxin); state_save_register_device_item(device, 0, ppc->spu.rxout); state_save_register_device_item(device, 0, ppc->pit_reload); state_save_register_device_item(device, 0, ppc->irqstate); } if (cap & PPCCAP_603_MMU) { state_save_register_device_item(device, 0, ppc->mmu603_cmp); state_save_register_device_item_array(device, 0, ppc->mmu603_hash); state_save_register_device_item_array(device, 0, ppc->mmu603_r); } state_save_register_device_item(device, 0, ppc->irq_pending); state_save_register_device_item(device, 0, ppc->tb_zero_cycles); state_save_register_device_item(device, 0, ppc->dec_zero_cycles); }
[ "void", "ppccom_init", "(", "powerpc_state", "*", "ppc", ",", "powerpc_flavor", "flavor", ",", "UINT8", "cap", ",", "int", "tb_divisor", ",", "const", "device_config", "*", "device", ",", "cpu_irq_callback", "irqcallback", ")", "{", "const", "powerpc_config", "*", "config", "=", "(", "const", "powerpc_config", "*", ")", "device", "->", "static_config", ";", "memset", "(", "ppc", ",", "0", ",", "sizeof", "(", "*", "ppc", ")", ")", ";", "ppc", "->", "flavor", "=", "flavor", ";", "ppc", "->", "cap", "=", "cap", ";", "ppc", "->", "cache_line_size", "=", "32", ";", "ppc", "->", "tb_divisor", "=", "tb_divisor", ";", "ppc", "->", "cpu_clock", "=", "device", "->", "clock", ";", "ppc", "->", "irq_callback", "=", "irqcallback", ";", "ppc", "->", "device", "=", "device", ";", "ppc", "->", "program", "=", "memory_find_address_space", "(", "device", ",", "ADDRESS_SPACE_PROGRAM", ")", ";", "ppc", "->", "system_clock", "=", "(", "config", "!=", "NULL", ")", "?", "config", "->", "bus_frequency", ":", "device", "->", "clock", ";", "ppc", "->", "tb_divisor", "=", "(", "ppc", "->", "tb_divisor", "*", "device", "->", "clock", "+", "ppc", "->", "system_clock", "/", "2", "-", "1", ")", "/", "ppc", "->", "system_clock", ";", "ppc", "->", "codexor", "=", "0", ";", "if", "(", "!", "(", "cap", "&", "PPCCAP_4XX", ")", "&&", "cpu_get_endianness", "(", "device", ")", "!=", "ENDIANNESS_NATIVE", ")", "ppc", "->", "codexor", "=", "4", ";", "ppc", "->", "vtlb", "=", "vtlb_alloc", "(", "device", ",", "ADDRESS_SPACE_PROGRAM", ",", "(", "cap", "&", "PPCCAP_603_MMU", ")", "?", "PPC603_FIXED_TLB_ENTRIES", ":", "0", ",", "POWERPC_TLB_ENTRIES", ")", ";", "if", "(", "cap", "&", "PPCCAP_OEA", ")", "ppc", "->", "decrementer_int_timer", "=", "timer_alloc", "(", "device", "->", "machine", ",", "decrementer_int_callback", ",", "ppc", ")", ";", "if", "(", "cap", "&", "PPCCAP_4XX", ")", "{", "ppc", "->", "fit_timer", "=", "timer_alloc", "(", "device", "->", "machine", ",", "ppc4xx_fit_callback", ",", "ppc", ")", ";", "ppc", "->", "pit_timer", "=", "timer_alloc", "(", "device", "->", "machine", ",", "ppc4xx_pit_callback", ",", "ppc", ")", ";", "ppc", "->", "spu", ".", "timer", "=", "timer_alloc", "(", "device", "->", "machine", ",", "ppc4xx_spu_callback", ",", "ppc", ")", ";", "}", "state_save_register_device_item", "(", "device", ",", "0", ",", "ppc", "->", "pc", ")", ";", "state_save_register_device_item_array", "(", "device", ",", "0", ",", "ppc", "->", "r", ")", ";", "state_save_register_device_item_array", "(", "device", ",", "0", ",", "ppc", "->", "f", ")", ";", "state_save_register_device_item_array", "(", "device", ",", "0", ",", "ppc", "->", "cr", ")", ";", "state_save_register_device_item", "(", "device", ",", "0", ",", "ppc", "->", "xerso", ")", ";", "state_save_register_device_item", "(", "device", ",", "0", ",", "ppc", "->", "fpscr", ")", ";", "state_save_register_device_item", "(", "device", ",", "0", ",", "ppc", "->", "msr", ")", ";", "state_save_register_device_item_array", "(", "device", ",", "0", ",", "ppc", "->", "sr", ")", ";", "state_save_register_device_item_array", "(", "device", ",", "0", ",", "ppc", "->", "spr", ")", ";", "state_save_register_device_item_array", "(", "device", ",", "0", ",", "ppc", "->", "dcr", ")", ";", "if", "(", "cap", "&", "PPCCAP_4XX", ")", "{", "state_save_register_device_item_array", "(", "device", ",", "0", ",", "ppc", "->", "spu", ".", "regs", ")", ";", "state_save_register_device_item", "(", "device", ",", "0", ",", "ppc", "->", "spu", ".", "txbuf", ")", ";", "state_save_register_device_item", "(", "device", ",", "0", ",", "ppc", "->", "spu", ".", "rxbuf", ")", ";", "state_save_register_device_item_array", "(", "device", ",", "0", ",", "ppc", "->", "spu", ".", "rxbuffer", ")", ";", "state_save_register_device_item", "(", "device", ",", "0", ",", "ppc", "->", "spu", ".", "rxin", ")", ";", "state_save_register_device_item", "(", "device", ",", "0", ",", "ppc", "->", "spu", ".", "rxout", ")", ";", "state_save_register_device_item", "(", "device", ",", "0", ",", "ppc", "->", "pit_reload", ")", ";", "state_save_register_device_item", "(", "device", ",", "0", ",", "ppc", "->", "irqstate", ")", ";", "}", "if", "(", "cap", "&", "PPCCAP_603_MMU", ")", "{", "state_save_register_device_item", "(", "device", ",", "0", ",", "ppc", "->", "mmu603_cmp", ")", ";", "state_save_register_device_item_array", "(", "device", ",", "0", ",", "ppc", "->", "mmu603_hash", ")", ";", "state_save_register_device_item_array", "(", "device", ",", "0", ",", "ppc", "->", "mmu603_r", ")", ";", "}", "state_save_register_device_item", "(", "device", ",", "0", ",", "ppc", "->", "irq_pending", ")", ";", "state_save_register_device_item", "(", "device", ",", "0", ",", "ppc", "->", "tb_zero_cycles", ")", ";", "state_save_register_device_item", "(", "device", ",", "0", ",", "ppc", "->", "dec_zero_cycles", ")", ";", "}" ]
ppccom_init - initialize the powerpc_state structure based on the configured type
[ "ppccom_init", "-", "initialize", "the", "powerpc_state", "structure", "based", "on", "the", "configured", "type" ]
[ "/* initialize based on the config */", "/* allocate the virtual TLB */", "/* allocate a timer for the compare interrupt */", "/* and for the 4XX interrupts if needed */", "/* register for save states */" ]
[ { "param": "ppc", "type": "powerpc_state" }, { "param": "flavor", "type": "powerpc_flavor" }, { "param": "cap", "type": "UINT8" }, { "param": "tb_divisor", "type": "int" }, { "param": "device", "type": "device_config" }, { "param": "irqcallback", "type": "cpu_irq_callback" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ppc", "type": "powerpc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "flavor", "type": "powerpc_flavor", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cap", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "tb_divisor", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "device", "type": "device_config", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "irqcallback", "type": "cpu_irq_callback", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9fb9c5cf4c3689ffe2d2bb3bbbdf91d2f0ecaf01
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/powerpc/ppccom.c
[ "Unlicense" ]
C
ppccom_reset
void
void ppccom_reset(powerpc_state *ppc) { int tlbindex; /* initialize the OEA state */ if (ppc->cap & PPCCAP_OEA) { /* PC to the reset vector; MSR has IP set to start */ ppc->pc = 0xfff00100; ppc->msr = MSROEA_IP; /* reset the decrementer */ ppc->dec_zero_cycles = cpu_get_total_cycles(ppc->device); decrementer_int_callback(ppc->device->machine, ppc, 0); } /* initialize the 4XX state */ if (ppc->cap & PPCCAP_4XX) { /* PC to the last word; MSR to 0 */ ppc->pc = 0xfffffffc; ppc->msr = 0; /* reset the SPU status */ ppc->spr[SPR4XX_TCR] &= ~PPC4XX_TCR_WRC_MASK; ppc->spu.regs[SPU4XX_LINE_STATUS] = 0x06; } /* initialize the 602 HID0 register */ if (ppc->flavor == PPC_MODEL_602) ppc->spr[SPR603_HID0] = 1; /* time base starts here */ ppc->tb_zero_cycles = cpu_get_total_cycles(ppc->device); /* clear interrupts */ ppc->irq_pending = 0; /* flush the TLB */ vtlb_flush_dynamic(ppc->vtlb); if (ppc->cap & PPCCAP_603_MMU) for (tlbindex = 0; tlbindex < PPC603_FIXED_TLB_ENTRIES; tlbindex++) vtlb_load(ppc->vtlb, tlbindex, 0, 0, 0); }
/*------------------------------------------------- ppccom_reset - reset the state of all the registers -------------------------------------------------*/
reset the state of all the registers
[ "reset", "the", "state", "of", "all", "the", "registers" ]
void ppccom_reset(powerpc_state *ppc) { int tlbindex; if (ppc->cap & PPCCAP_OEA) { ppc->pc = 0xfff00100; ppc->msr = MSROEA_IP; ppc->dec_zero_cycles = cpu_get_total_cycles(ppc->device); decrementer_int_callback(ppc->device->machine, ppc, 0); } if (ppc->cap & PPCCAP_4XX) { ppc->pc = 0xfffffffc; ppc->msr = 0; ppc->spr[SPR4XX_TCR] &= ~PPC4XX_TCR_WRC_MASK; ppc->spu.regs[SPU4XX_LINE_STATUS] = 0x06; } if (ppc->flavor == PPC_MODEL_602) ppc->spr[SPR603_HID0] = 1; ppc->tb_zero_cycles = cpu_get_total_cycles(ppc->device); ppc->irq_pending = 0; vtlb_flush_dynamic(ppc->vtlb); if (ppc->cap & PPCCAP_603_MMU) for (tlbindex = 0; tlbindex < PPC603_FIXED_TLB_ENTRIES; tlbindex++) vtlb_load(ppc->vtlb, tlbindex, 0, 0, 0); }
[ "void", "ppccom_reset", "(", "powerpc_state", "*", "ppc", ")", "{", "int", "tlbindex", ";", "if", "(", "ppc", "->", "cap", "&", "PPCCAP_OEA", ")", "{", "ppc", "->", "pc", "=", "0xfff00100", ";", "ppc", "->", "msr", "=", "MSROEA_IP", ";", "ppc", "->", "dec_zero_cycles", "=", "cpu_get_total_cycles", "(", "ppc", "->", "device", ")", ";", "decrementer_int_callback", "(", "ppc", "->", "device", "->", "machine", ",", "ppc", ",", "0", ")", ";", "}", "if", "(", "ppc", "->", "cap", "&", "PPCCAP_4XX", ")", "{", "ppc", "->", "pc", "=", "0xfffffffc", ";", "ppc", "->", "msr", "=", "0", ";", "ppc", "->", "spr", "[", "SPR4XX_TCR", "]", "&=", "~", "PPC4XX_TCR_WRC_MASK", ";", "ppc", "->", "spu", ".", "regs", "[", "SPU4XX_LINE_STATUS", "]", "=", "0x06", ";", "}", "if", "(", "ppc", "->", "flavor", "==", "PPC_MODEL_602", ")", "ppc", "->", "spr", "[", "SPR603_HID0", "]", "=", "1", ";", "ppc", "->", "tb_zero_cycles", "=", "cpu_get_total_cycles", "(", "ppc", "->", "device", ")", ";", "ppc", "->", "irq_pending", "=", "0", ";", "vtlb_flush_dynamic", "(", "ppc", "->", "vtlb", ")", ";", "if", "(", "ppc", "->", "cap", "&", "PPCCAP_603_MMU", ")", "for", "(", "tlbindex", "=", "0", ";", "tlbindex", "<", "PPC603_FIXED_TLB_ENTRIES", ";", "tlbindex", "++", ")", "vtlb_load", "(", "ppc", "->", "vtlb", ",", "tlbindex", ",", "0", ",", "0", ",", "0", ")", ";", "}" ]
ppccom_reset - reset the state of all the registers
[ "ppccom_reset", "-", "reset", "the", "state", "of", "all", "the", "registers" ]
[ "/* initialize the OEA state */", "/* PC to the reset vector; MSR has IP set to start */", "/* reset the decrementer */", "/* initialize the 4XX state */", "/* PC to the last word; MSR to 0 */", "/* reset the SPU status */", "/* initialize the 602 HID0 register */", "/* time base starts here */", "/* clear interrupts */", "/* flush the TLB */" ]
[ { "param": "ppc", "type": "powerpc_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ppc", "type": "powerpc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9fb9c5cf4c3689ffe2d2bb3bbbdf91d2f0ecaf01
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/powerpc/ppccom.c
[ "Unlicense" ]
C
ppccom_translate_address_internal
UINT32
static UINT32 ppccom_translate_address_internal(powerpc_state *ppc, int intention, offs_t *address) { int transpriv = ((intention & TRANSLATE_USER_MASK) == 0); int transtype = intention & TRANSLATE_TYPE_MASK; offs_t hash, hashbase, hashmask; int batbase, batnum, hashnum; UINT32 segreg; /* 4xx case: "TLB" really just caches writes and checks compare registers */ if (ppc->cap & PPCCAP_4XX) { /* we don't support the MMU of the 403GCX */ if (ppc->flavor == PPC_MODEL_403GCX && (ppc->msr & MSROEA_DR)) fatalerror("MMU enabled but not supported!"); /* only check if PE is enabled */ if (transtype == TRANSLATE_WRITE && (ppc->msr & MSR4XX_PE)) { /* are we within one of the protection ranges? */ int inrange1 = ((*address >> 12) >= (ppc->spr[SPR4XX_PBL1] >> 12) && (*address >> 12) < (ppc->spr[SPR4XX_PBU1] >> 12)); int inrange2 = ((*address >> 12) >= (ppc->spr[SPR4XX_PBL2] >> 12) && (*address >> 12) < (ppc->spr[SPR4XX_PBU2] >> 12)); /* if PX == 1, writes are only allowed OUTSIDE of the bounds */ if (((ppc->msr & MSR4XX_PX) && (inrange1 || inrange2)) || (!(ppc->msr & MSR4XX_PX) && (!inrange1 && !inrange2))) return 0x002; } *address &= 0x7fffffff; return 0x001; } /* only applies if we support the OEA */ if (!(ppc->cap & PPCCAP_OEA)) return 0x001; /* also no translation necessary if translation is disabled */ if ((transtype == TRANSLATE_FETCH && (ppc->msr & MSROEA_IR) == 0) || (transtype != TRANSLATE_FETCH && (ppc->msr & MSROEA_DR) == 0)) return 0x001; /* first scan the appropriate BAT */ batbase = (transtype == TRANSLATE_FETCH) ? SPROEA_IBAT0U : SPROEA_DBAT0U; for (batnum = 0; batnum < 4; batnum++) { UINT32 upper = ppc->spr[batbase + 2*batnum + 0]; /* check user/supervisor valid bit */ if ((upper >> transpriv) & 0x01) { UINT32 mask = (~upper << 15) & 0xfffe0000; /* check for a hit against this bucket */ if ((*address & mask) == (upper & mask)) { UINT32 lower = ppc->spr[batbase + 2*batnum + 1]; /* verify protection; if we fail, return false and indicate a protection violation */ if (!page_access_allowed(transtype, 1, lower & 3)) return DSISR_PROTECTED | ((transtype == TRANSLATE_WRITE) ? DSISR_STORE : 0); /* otherwise we're good */ *address = (lower & mask) | (*address & ~mask); return 0x001; } } } /* look up the segment register */ segreg = ppc->sr[*address >> 28]; if (transtype == TRANSLATE_FETCH && (segreg & 0x10000000)) return DSISR_PROTECTED | ((transtype == TRANSLATE_WRITE) ? DSISR_STORE : 0); /* get hash table information from SD1 */ hashbase = ppc->spr[SPROEA_SDR1] & 0xffff0000; hashmask = ((ppc->spr[SPROEA_SDR1] & 0x1ff) << 16) | 0xffff; hash = (segreg & 0x7ffff) ^ ((*address >> 12) & 0xffff); /* if we're simulating the 603 MMU, fill in the data and stop here */ if (ppc->cap & PPCCAP_603_MMU) { ppc->mmu603_cmp = 0x80000000 | ((segreg & 0xffffff) << 7) | (0 << 6) | ((*address >> 22) & 0x3f); ppc->mmu603_hash[0] = hashbase | ((hash << 6) & hashmask); ppc->mmu603_hash[1] = hashbase | ((~hash << 6) & hashmask); return DSISR_NOT_FOUND | ((transtype == TRANSLATE_WRITE) ? DSISR_STORE : 0); } /* loop twice over hashes */ for (hashnum = 0; hashnum < 2; hashnum++) { offs_t ptegaddr = hashbase | ((hash << 6) & hashmask); UINT32 *ptegptr = (UINT32 *)memory_get_read_ptr(ppc->program, ptegaddr); /* should only have valid memory here, but make sure */ if (ptegptr != NULL) { UINT32 targetupper = 0x80000000 | ((segreg & 0xffffff) << 7) | (hashnum << 6) | ((*address >> 22) & 0x3f); int ptenum; /* scan PTEs */ for (ptenum = 0; ptenum < 8; ptenum++) if (ptegptr[BYTE_XOR_BE(ptenum * 2)] == targetupper) { UINT32 pteglower = ptegptr[BYTE_XOR_BE(ptenum * 2 + 1)]; /* verify protection; if we fail, return false and indicate a protection violation */ if (!page_access_allowed(transtype, (segreg >> (29 + transpriv)) & 1, pteglower & 3)) return DSISR_PROTECTED | ((transtype == TRANSLATE_WRITE) ? DSISR_STORE : 0); /* update page table bits */ if (!(intention & TRANSLATE_DEBUG_MASK)) { pteglower |= 0x100; if (transtype == TRANSLATE_WRITE) pteglower |= 0x080; ptegptr[BYTE_XOR_BE(ptenum * 2 + 1)] = pteglower; } /* otherwise we're good */ *address = (pteglower & 0xfffff000) | (*address & 0x00000fff); return (pteglower >> 7) & 1; } } /* invert the hash after the first round */ hash = ~hash; } /* we failed to find any match: not found */ return DSISR_NOT_FOUND | ((transtype == TRANSLATE_WRITE) ? DSISR_STORE : 0); }
/*------------------------------------------------- ppccom_translate_address_internal - translate an address from logical to physical; shared between external requests and internal TLB filling -------------------------------------------------*/
translate an address from logical to physical; shared between external requests and internal TLB filling
[ "translate", "an", "address", "from", "logical", "to", "physical", ";", "shared", "between", "external", "requests", "and", "internal", "TLB", "filling" ]
static UINT32 ppccom_translate_address_internal(powerpc_state *ppc, int intention, offs_t *address) { int transpriv = ((intention & TRANSLATE_USER_MASK) == 0); int transtype = intention & TRANSLATE_TYPE_MASK; offs_t hash, hashbase, hashmask; int batbase, batnum, hashnum; UINT32 segreg; if (ppc->cap & PPCCAP_4XX) { if (ppc->flavor == PPC_MODEL_403GCX && (ppc->msr & MSROEA_DR)) fatalerror("MMU enabled but not supported!"); if (transtype == TRANSLATE_WRITE && (ppc->msr & MSR4XX_PE)) { int inrange1 = ((*address >> 12) >= (ppc->spr[SPR4XX_PBL1] >> 12) && (*address >> 12) < (ppc->spr[SPR4XX_PBU1] >> 12)); int inrange2 = ((*address >> 12) >= (ppc->spr[SPR4XX_PBL2] >> 12) && (*address >> 12) < (ppc->spr[SPR4XX_PBU2] >> 12)); if (((ppc->msr & MSR4XX_PX) && (inrange1 || inrange2)) || (!(ppc->msr & MSR4XX_PX) && (!inrange1 && !inrange2))) return 0x002; } *address &= 0x7fffffff; return 0x001; } if (!(ppc->cap & PPCCAP_OEA)) return 0x001; if ((transtype == TRANSLATE_FETCH && (ppc->msr & MSROEA_IR) == 0) || (transtype != TRANSLATE_FETCH && (ppc->msr & MSROEA_DR) == 0)) return 0x001; batbase = (transtype == TRANSLATE_FETCH) ? SPROEA_IBAT0U : SPROEA_DBAT0U; for (batnum = 0; batnum < 4; batnum++) { UINT32 upper = ppc->spr[batbase + 2*batnum + 0]; if ((upper >> transpriv) & 0x01) { UINT32 mask = (~upper << 15) & 0xfffe0000; if ((*address & mask) == (upper & mask)) { UINT32 lower = ppc->spr[batbase + 2*batnum + 1]; if (!page_access_allowed(transtype, 1, lower & 3)) return DSISR_PROTECTED | ((transtype == TRANSLATE_WRITE) ? DSISR_STORE : 0); *address = (lower & mask) | (*address & ~mask); return 0x001; } } } segreg = ppc->sr[*address >> 28]; if (transtype == TRANSLATE_FETCH && (segreg & 0x10000000)) return DSISR_PROTECTED | ((transtype == TRANSLATE_WRITE) ? DSISR_STORE : 0); hashbase = ppc->spr[SPROEA_SDR1] & 0xffff0000; hashmask = ((ppc->spr[SPROEA_SDR1] & 0x1ff) << 16) | 0xffff; hash = (segreg & 0x7ffff) ^ ((*address >> 12) & 0xffff); if (ppc->cap & PPCCAP_603_MMU) { ppc->mmu603_cmp = 0x80000000 | ((segreg & 0xffffff) << 7) | (0 << 6) | ((*address >> 22) & 0x3f); ppc->mmu603_hash[0] = hashbase | ((hash << 6) & hashmask); ppc->mmu603_hash[1] = hashbase | ((~hash << 6) & hashmask); return DSISR_NOT_FOUND | ((transtype == TRANSLATE_WRITE) ? DSISR_STORE : 0); } for (hashnum = 0; hashnum < 2; hashnum++) { offs_t ptegaddr = hashbase | ((hash << 6) & hashmask); UINT32 *ptegptr = (UINT32 *)memory_get_read_ptr(ppc->program, ptegaddr); if (ptegptr != NULL) { UINT32 targetupper = 0x80000000 | ((segreg & 0xffffff) << 7) | (hashnum << 6) | ((*address >> 22) & 0x3f); int ptenum; for (ptenum = 0; ptenum < 8; ptenum++) if (ptegptr[BYTE_XOR_BE(ptenum * 2)] == targetupper) { UINT32 pteglower = ptegptr[BYTE_XOR_BE(ptenum * 2 + 1)]; if (!page_access_allowed(transtype, (segreg >> (29 + transpriv)) & 1, pteglower & 3)) return DSISR_PROTECTED | ((transtype == TRANSLATE_WRITE) ? DSISR_STORE : 0); if (!(intention & TRANSLATE_DEBUG_MASK)) { pteglower |= 0x100; if (transtype == TRANSLATE_WRITE) pteglower |= 0x080; ptegptr[BYTE_XOR_BE(ptenum * 2 + 1)] = pteglower; } *address = (pteglower & 0xfffff000) | (*address & 0x00000fff); return (pteglower >> 7) & 1; } } hash = ~hash; } return DSISR_NOT_FOUND | ((transtype == TRANSLATE_WRITE) ? DSISR_STORE : 0); }
[ "static", "UINT32", "ppccom_translate_address_internal", "(", "powerpc_state", "*", "ppc", ",", "int", "intention", ",", "offs_t", "*", "address", ")", "{", "int", "transpriv", "=", "(", "(", "intention", "&", "TRANSLATE_USER_MASK", ")", "==", "0", ")", ";", "int", "transtype", "=", "intention", "&", "TRANSLATE_TYPE_MASK", ";", "offs_t", "hash", ",", "hashbase", ",", "hashmask", ";", "int", "batbase", ",", "batnum", ",", "hashnum", ";", "UINT32", "segreg", ";", "if", "(", "ppc", "->", "cap", "&", "PPCCAP_4XX", ")", "{", "if", "(", "ppc", "->", "flavor", "==", "PPC_MODEL_403GCX", "&&", "(", "ppc", "->", "msr", "&", "MSROEA_DR", ")", ")", "fatalerror", "(", "\"", "\"", ")", ";", "if", "(", "transtype", "==", "TRANSLATE_WRITE", "&&", "(", "ppc", "->", "msr", "&", "MSR4XX_PE", ")", ")", "{", "int", "inrange1", "=", "(", "(", "*", "address", ">>", "12", ")", ">=", "(", "ppc", "->", "spr", "[", "SPR4XX_PBL1", "]", ">>", "12", ")", "&&", "(", "*", "address", ">>", "12", ")", "<", "(", "ppc", "->", "spr", "[", "SPR4XX_PBU1", "]", ">>", "12", ")", ")", ";", "int", "inrange2", "=", "(", "(", "*", "address", ">>", "12", ")", ">=", "(", "ppc", "->", "spr", "[", "SPR4XX_PBL2", "]", ">>", "12", ")", "&&", "(", "*", "address", ">>", "12", ")", "<", "(", "ppc", "->", "spr", "[", "SPR4XX_PBU2", "]", ">>", "12", ")", ")", ";", "if", "(", "(", "(", "ppc", "->", "msr", "&", "MSR4XX_PX", ")", "&&", "(", "inrange1", "||", "inrange2", ")", ")", "||", "(", "!", "(", "ppc", "->", "msr", "&", "MSR4XX_PX", ")", "&&", "(", "!", "inrange1", "&&", "!", "inrange2", ")", ")", ")", "return", "0x002", ";", "}", "*", "address", "&=", "0x7fffffff", ";", "return", "0x001", ";", "}", "if", "(", "!", "(", "ppc", "->", "cap", "&", "PPCCAP_OEA", ")", ")", "return", "0x001", ";", "if", "(", "(", "transtype", "==", "TRANSLATE_FETCH", "&&", "(", "ppc", "->", "msr", "&", "MSROEA_IR", ")", "==", "0", ")", "||", "(", "transtype", "!=", "TRANSLATE_FETCH", "&&", "(", "ppc", "->", "msr", "&", "MSROEA_DR", ")", "==", "0", ")", ")", "return", "0x001", ";", "batbase", "=", "(", "transtype", "==", "TRANSLATE_FETCH", ")", "?", "SPROEA_IBAT0U", ":", "SPROEA_DBAT0U", ";", "for", "(", "batnum", "=", "0", ";", "batnum", "<", "4", ";", "batnum", "++", ")", "{", "UINT32", "upper", "=", "ppc", "->", "spr", "[", "batbase", "+", "2", "*", "batnum", "+", "0", "]", ";", "if", "(", "(", "upper", ">>", "transpriv", ")", "&", "0x01", ")", "{", "UINT32", "mask", "=", "(", "~", "upper", "<<", "15", ")", "&", "0xfffe0000", ";", "if", "(", "(", "*", "address", "&", "mask", ")", "==", "(", "upper", "&", "mask", ")", ")", "{", "UINT32", "lower", "=", "ppc", "->", "spr", "[", "batbase", "+", "2", "*", "batnum", "+", "1", "]", ";", "if", "(", "!", "page_access_allowed", "(", "transtype", ",", "1", ",", "lower", "&", "3", ")", ")", "return", "DSISR_PROTECTED", "|", "(", "(", "transtype", "==", "TRANSLATE_WRITE", ")", "?", "DSISR_STORE", ":", "0", ")", ";", "*", "address", "=", "(", "lower", "&", "mask", ")", "|", "(", "*", "address", "&", "~", "mask", ")", ";", "return", "0x001", ";", "}", "}", "}", "segreg", "=", "ppc", "->", "sr", "[", "*", "address", ">>", "28", "]", ";", "if", "(", "transtype", "==", "TRANSLATE_FETCH", "&&", "(", "segreg", "&", "0x10000000", ")", ")", "return", "DSISR_PROTECTED", "|", "(", "(", "transtype", "==", "TRANSLATE_WRITE", ")", "?", "DSISR_STORE", ":", "0", ")", ";", "hashbase", "=", "ppc", "->", "spr", "[", "SPROEA_SDR1", "]", "&", "0xffff0000", ";", "hashmask", "=", "(", "(", "ppc", "->", "spr", "[", "SPROEA_SDR1", "]", "&", "0x1ff", ")", "<<", "16", ")", "|", "0xffff", ";", "hash", "=", "(", "segreg", "&", "0x7ffff", ")", "^", "(", "(", "*", "address", ">>", "12", ")", "&", "0xffff", ")", ";", "if", "(", "ppc", "->", "cap", "&", "PPCCAP_603_MMU", ")", "{", "ppc", "->", "mmu603_cmp", "=", "0x80000000", "|", "(", "(", "segreg", "&", "0xffffff", ")", "<<", "7", ")", "|", "(", "0", "<<", "6", ")", "|", "(", "(", "*", "address", ">>", "22", ")", "&", "0x3f", ")", ";", "ppc", "->", "mmu603_hash", "[", "0", "]", "=", "hashbase", "|", "(", "(", "hash", "<<", "6", ")", "&", "hashmask", ")", ";", "ppc", "->", "mmu603_hash", "[", "1", "]", "=", "hashbase", "|", "(", "(", "~", "hash", "<<", "6", ")", "&", "hashmask", ")", ";", "return", "DSISR_NOT_FOUND", "|", "(", "(", "transtype", "==", "TRANSLATE_WRITE", ")", "?", "DSISR_STORE", ":", "0", ")", ";", "}", "for", "(", "hashnum", "=", "0", ";", "hashnum", "<", "2", ";", "hashnum", "++", ")", "{", "offs_t", "ptegaddr", "=", "hashbase", "|", "(", "(", "hash", "<<", "6", ")", "&", "hashmask", ")", ";", "UINT32", "*", "ptegptr", "=", "(", "UINT32", "*", ")", "memory_get_read_ptr", "(", "ppc", "->", "program", ",", "ptegaddr", ")", ";", "if", "(", "ptegptr", "!=", "NULL", ")", "{", "UINT32", "targetupper", "=", "0x80000000", "|", "(", "(", "segreg", "&", "0xffffff", ")", "<<", "7", ")", "|", "(", "hashnum", "<<", "6", ")", "|", "(", "(", "*", "address", ">>", "22", ")", "&", "0x3f", ")", ";", "int", "ptenum", ";", "for", "(", "ptenum", "=", "0", ";", "ptenum", "<", "8", ";", "ptenum", "++", ")", "if", "(", "ptegptr", "[", "BYTE_XOR_BE", "(", "ptenum", "*", "2", ")", "]", "==", "targetupper", ")", "{", "UINT32", "pteglower", "=", "ptegptr", "[", "BYTE_XOR_BE", "(", "ptenum", "*", "2", "+", "1", ")", "]", ";", "if", "(", "!", "page_access_allowed", "(", "transtype", ",", "(", "segreg", ">>", "(", "29", "+", "transpriv", ")", ")", "&", "1", ",", "pteglower", "&", "3", ")", ")", "return", "DSISR_PROTECTED", "|", "(", "(", "transtype", "==", "TRANSLATE_WRITE", ")", "?", "DSISR_STORE", ":", "0", ")", ";", "if", "(", "!", "(", "intention", "&", "TRANSLATE_DEBUG_MASK", ")", ")", "{", "pteglower", "|=", "0x100", ";", "if", "(", "transtype", "==", "TRANSLATE_WRITE", ")", "pteglower", "|=", "0x080", ";", "ptegptr", "[", "BYTE_XOR_BE", "(", "ptenum", "*", "2", "+", "1", ")", "]", "=", "pteglower", ";", "}", "*", "address", "=", "(", "pteglower", "&", "0xfffff000", ")", "|", "(", "*", "address", "&", "0x00000fff", ")", ";", "return", "(", "pteglower", ">>", "7", ")", "&", "1", ";", "}", "}", "hash", "=", "~", "hash", ";", "}", "return", "DSISR_NOT_FOUND", "|", "(", "(", "transtype", "==", "TRANSLATE_WRITE", ")", "?", "DSISR_STORE", ":", "0", ")", ";", "}" ]
ppccom_translate_address_internal - translate an address from logical to physical; shared between external requests and internal TLB filling
[ "ppccom_translate_address_internal", "-", "translate", "an", "address", "from", "logical", "to", "physical", ";", "shared", "between", "external", "requests", "and", "internal", "TLB", "filling" ]
[ "/* 4xx case: \"TLB\" really just caches writes and checks compare registers */", "/* we don't support the MMU of the 403GCX */", "/* only check if PE is enabled */", "/* are we within one of the protection ranges? */", "/* if PX == 1, writes are only allowed OUTSIDE of the bounds */", "/* only applies if we support the OEA */", "/* also no translation necessary if translation is disabled */", "/* first scan the appropriate BAT */", "/* check user/supervisor valid bit */", "/* check for a hit against this bucket */", "/* verify protection; if we fail, return false and indicate a protection violation */", "/* otherwise we're good */", "/* look up the segment register */", "/* get hash table information from SD1 */", "/* if we're simulating the 603 MMU, fill in the data and stop here */", "/* loop twice over hashes */", "/* should only have valid memory here, but make sure */", "/* scan PTEs */", "/* verify protection; if we fail, return false and indicate a protection violation */", "/* update page table bits */", "/* otherwise we're good */", "/* invert the hash after the first round */", "/* we failed to find any match: not found */" ]
[ { "param": "ppc", "type": "powerpc_state" }, { "param": "intention", "type": "int" }, { "param": "address", "type": "offs_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ppc", "type": "powerpc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "intention", "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 } ], "outlier_params": [], "others": [] }
9fb9c5cf4c3689ffe2d2bb3bbbdf91d2f0ecaf01
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/powerpc/ppccom.c
[ "Unlicense" ]
C
ppccom_translate_address
int
int ppccom_translate_address(powerpc_state *ppc, int space, int intention, offs_t *address) { /* only applies to the program address space */ if (space != ADDRESS_SPACE_PROGRAM) return TRUE; /* translation is successful if the internal routine returns 0 or 1 */ return (ppccom_translate_address_internal(ppc, intention, address) <= 1); }
/*------------------------------------------------- ppccom_translate_address - translate an address from logical to physical -------------------------------------------------*/
translate an address from logical to physical
[ "translate", "an", "address", "from", "logical", "to", "physical" ]
int ppccom_translate_address(powerpc_state *ppc, int space, int intention, offs_t *address) { if (space != ADDRESS_SPACE_PROGRAM) return TRUE; return (ppccom_translate_address_internal(ppc, intention, address) <= 1); }
[ "int", "ppccom_translate_address", "(", "powerpc_state", "*", "ppc", ",", "int", "space", ",", "int", "intention", ",", "offs_t", "*", "address", ")", "{", "if", "(", "space", "!=", "ADDRESS_SPACE_PROGRAM", ")", "return", "TRUE", ";", "return", "(", "ppccom_translate_address_internal", "(", "ppc", ",", "intention", ",", "address", ")", "<=", "1", ")", ";", "}" ]
ppccom_translate_address - translate an address from logical to physical
[ "ppccom_translate_address", "-", "translate", "an", "address", "from", "logical", "to", "physical" ]
[ "/* only applies to the program address space */", "/* translation is successful if the internal routine returns 0 or 1 */" ]
[ { "param": "ppc", "type": "powerpc_state" }, { "param": "space", "type": "int" }, { "param": "intention", "type": "int" }, { "param": "address", "type": "offs_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ppc", "type": "powerpc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "space", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "intention", "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 } ], "outlier_params": [], "others": [] }
9fb9c5cf4c3689ffe2d2bb3bbbdf91d2f0ecaf01
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/powerpc/ppccom.c
[ "Unlicense" ]
C
ppccom_execute_tlbl
void
void ppccom_execute_tlbl(powerpc_state *ppc) { UINT32 address = ppc->param0; int isitlb = ppc->param1; vtlb_entry flags = 0; int entrynum; /* determine entry number; we use rand() for associativity */ entrynum = ((address >> 12) & 0x1f) | (mame_rand(ppc->device->machine) & 0x20) | (isitlb ? 0x40 : 0); /* determine the flags */ flags = VTLB_FLAG_VALID | VTLB_READ_ALLOWED | VTLB_FETCH_ALLOWED; if (ppc->spr[SPR603_RPA] & 0x80) flags |= VTLB_WRITE_ALLOWED; if (isitlb) flags |= VTLB_FETCH_ALLOWED; /* load the entry */ vtlb_load(ppc->vtlb, entrynum, 1, address, (ppc->spr[SPR603_RPA] & 0xfffff000) | flags); }
/*------------------------------------------------- ppccom_execute_tlbl - execute a TLBLD/TLBLI instruction -------------------------------------------------*/
execute a TLBLD/TLBLI instruction
[ "execute", "a", "TLBLD", "/", "TLBLI", "instruction" ]
void ppccom_execute_tlbl(powerpc_state *ppc) { UINT32 address = ppc->param0; int isitlb = ppc->param1; vtlb_entry flags = 0; int entrynum; entrynum = ((address >> 12) & 0x1f) | (mame_rand(ppc->device->machine) & 0x20) | (isitlb ? 0x40 : 0); flags = VTLB_FLAG_VALID | VTLB_READ_ALLOWED | VTLB_FETCH_ALLOWED; if (ppc->spr[SPR603_RPA] & 0x80) flags |= VTLB_WRITE_ALLOWED; if (isitlb) flags |= VTLB_FETCH_ALLOWED; vtlb_load(ppc->vtlb, entrynum, 1, address, (ppc->spr[SPR603_RPA] & 0xfffff000) | flags); }
[ "void", "ppccom_execute_tlbl", "(", "powerpc_state", "*", "ppc", ")", "{", "UINT32", "address", "=", "ppc", "->", "param0", ";", "int", "isitlb", "=", "ppc", "->", "param1", ";", "vtlb_entry", "flags", "=", "0", ";", "int", "entrynum", ";", "entrynum", "=", "(", "(", "address", ">>", "12", ")", "&", "0x1f", ")", "|", "(", "mame_rand", "(", "ppc", "->", "device", "->", "machine", ")", "&", "0x20", ")", "|", "(", "isitlb", "?", "0x40", ":", "0", ")", ";", "flags", "=", "VTLB_FLAG_VALID", "|", "VTLB_READ_ALLOWED", "|", "VTLB_FETCH_ALLOWED", ";", "if", "(", "ppc", "->", "spr", "[", "SPR603_RPA", "]", "&", "0x80", ")", "flags", "|=", "VTLB_WRITE_ALLOWED", ";", "if", "(", "isitlb", ")", "flags", "|=", "VTLB_FETCH_ALLOWED", ";", "vtlb_load", "(", "ppc", "->", "vtlb", ",", "entrynum", ",", "1", ",", "address", ",", "(", "ppc", "->", "spr", "[", "SPR603_RPA", "]", "&", "0xfffff000", ")", "|", "flags", ")", ";", "}" ]
ppccom_execute_tlbl - execute a TLBLD/TLBLI instruction
[ "ppccom_execute_tlbl", "-", "execute", "a", "TLBLD", "/", "TLBLI", "instruction" ]
[ "/* determine entry number; we use rand() for associativity */", "/* determine the flags */", "/* load the entry */" ]
[ { "param": "ppc", "type": "powerpc_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ppc", "type": "powerpc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9fb9c5cf4c3689ffe2d2bb3bbbdf91d2f0ecaf01
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/powerpc/ppccom.c
[ "Unlicense" ]
C
ppccom_update_fprf
void
void ppccom_update_fprf(powerpc_state *ppc) { UINT32 fprf; double f = ppc->f[ppc->param0]; if (is_qnan_double(f)) { fprf = 0x11; } else if (is_infinity_double(f)) { if (sign_double(f)) /* -Infinity */ fprf = 0x09; else /* +Infinity */ fprf = 0x05; } else if (is_normalized_double(f)) { if (sign_double(f)) /* -Normalized */ fprf = 0x08; else /* +Normalized */ fprf = 0x04; } else if (is_denormalized_double(f)) { if (sign_double(f)) /* -Denormalized */ fprf = 0x18; else /* +Denormalized */ fprf = 0x14; } else { if (sign_double(f)) /* -Zero */ fprf = 0x12; else /* +Zero */ fprf = 0x02; } ppc->fpscr &= ~0x0001f000; ppc->fpscr |= fprf << 12; }
/*------------------------------------------------- ppccom_update_fprf - update the FPRF field of the FPSCR register -------------------------------------------------*/
update the FPRF field of the FPSCR register
[ "update", "the", "FPRF", "field", "of", "the", "FPSCR", "register" ]
void ppccom_update_fprf(powerpc_state *ppc) { UINT32 fprf; double f = ppc->f[ppc->param0]; if (is_qnan_double(f)) { fprf = 0x11; } else if (is_infinity_double(f)) { if (sign_double(f)) fprf = 0x09; else fprf = 0x05; } else if (is_normalized_double(f)) { if (sign_double(f)) fprf = 0x08; else fprf = 0x04; } else if (is_denormalized_double(f)) { if (sign_double(f)) fprf = 0x18; else fprf = 0x14; } else { if (sign_double(f)) fprf = 0x12; else fprf = 0x02; } ppc->fpscr &= ~0x0001f000; ppc->fpscr |= fprf << 12; }
[ "void", "ppccom_update_fprf", "(", "powerpc_state", "*", "ppc", ")", "{", "UINT32", "fprf", ";", "double", "f", "=", "ppc", "->", "f", "[", "ppc", "->", "param0", "]", ";", "if", "(", "is_qnan_double", "(", "f", ")", ")", "{", "fprf", "=", "0x11", ";", "}", "else", "if", "(", "is_infinity_double", "(", "f", ")", ")", "{", "if", "(", "sign_double", "(", "f", ")", ")", "fprf", "=", "0x09", ";", "else", "fprf", "=", "0x05", ";", "}", "else", "if", "(", "is_normalized_double", "(", "f", ")", ")", "{", "if", "(", "sign_double", "(", "f", ")", ")", "fprf", "=", "0x08", ";", "else", "fprf", "=", "0x04", ";", "}", "else", "if", "(", "is_denormalized_double", "(", "f", ")", ")", "{", "if", "(", "sign_double", "(", "f", ")", ")", "fprf", "=", "0x18", ";", "else", "fprf", "=", "0x14", ";", "}", "else", "{", "if", "(", "sign_double", "(", "f", ")", ")", "fprf", "=", "0x12", ";", "else", "fprf", "=", "0x02", ";", "}", "ppc", "->", "fpscr", "&=", "~", "0x0001f000", ";", "ppc", "->", "fpscr", "|=", "fprf", "<<", "12", ";", "}" ]
ppccom_update_fprf - update the FPRF field of the FPSCR register
[ "ppccom_update_fprf", "-", "update", "the", "FPRF", "field", "of", "the", "FPSCR", "register" ]
[ "/* -Infinity */", "/* +Infinity */", "/* -Normalized */", "/* +Normalized */", "/* -Denormalized */", "/* +Denormalized */", "/* -Zero */", "/* +Zero */" ]
[ { "param": "ppc", "type": "powerpc_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ppc", "type": "powerpc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9fb9c5cf4c3689ffe2d2bb3bbbdf91d2f0ecaf01
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/powerpc/ppccom.c
[ "Unlicense" ]
C
ppc4xx_set_irq_line
void
static void ppc4xx_set_irq_line(powerpc_state *ppc, UINT32 bitmask, int state) { UINT32 oldstate = ppc->irqstate; UINT32 levelmask; /* set or clear the appropriate bit */ if (state != CLEAR_LINE) ppc->irqstate |= bitmask; else ppc->irqstate &= ~bitmask; /* if the state changed to on, edge trigger the interrupt */ if (((ppc->irqstate ^ oldstate) & bitmask) && (ppc->irqstate & bitmask)) ppc->dcr[DCR4XX_EXISR] |= bitmask; /* pass through all level-triggered interrupts */ levelmask = PPC4XX_IRQ_BIT_CRITICAL | PPC4XX_IRQ_BIT_SPUR | PPC4XX_IRQ_BIT_SPUT; levelmask |= PPC4XX_IRQ_BIT_JTAGR | PPC4XX_IRQ_BIT_JTAGT; levelmask |= PPC4XX_IRQ_BIT_DMA0 | PPC4XX_IRQ_BIT_DMA1 | PPC4XX_IRQ_BIT_DMA2 | PPC4XX_IRQ_BIT_DMA3; if (!(ppc->dcr[DCR4XX_IOCR] & 0x80000000)) levelmask |= PPC4XX_IRQ_BIT_EXT0; if (!(ppc->dcr[DCR4XX_IOCR] & 0x20000000)) levelmask |= PPC4XX_IRQ_BIT_EXT1; if (!(ppc->dcr[DCR4XX_IOCR] & 0x08000000)) levelmask |= PPC4XX_IRQ_BIT_EXT2; if (!(ppc->dcr[DCR4XX_IOCR] & 0x02000000)) levelmask |= PPC4XX_IRQ_BIT_EXT3; if (!(ppc->dcr[DCR4XX_IOCR] & 0x00800000)) levelmask |= PPC4XX_IRQ_BIT_EXT4; ppc->dcr[DCR4XX_EXISR] = (ppc->dcr[DCR4XX_EXISR] & ~levelmask) | (ppc->irqstate & levelmask); /* update the IRQ status */ ppc->irq_pending = ((ppc->dcr[DCR4XX_EXISR] & ppc->dcr[DCR4XX_EXIER]) != 0); if ((ppc->spr[SPR4XX_TCR] & PPC4XX_TCR_FIE) && (ppc->spr[SPR4XX_TSR] & PPC4XX_TSR_FIS)) ppc->irq_pending = TRUE; if ((ppc->spr[SPR4XX_TCR] & PPC4XX_TCR_PIE) && (ppc->spr[SPR4XX_TSR] & PPC4XX_TSR_PIS)) ppc->irq_pending = TRUE; }
/*------------------------------------------------- ppc4xx_set_irq_line - PowerPC 4XX-specific IRQ line management -------------------------------------------------*/
PowerPC 4XX-specific IRQ line management
[ "PowerPC", "4XX", "-", "specific", "IRQ", "line", "management" ]
static void ppc4xx_set_irq_line(powerpc_state *ppc, UINT32 bitmask, int state) { UINT32 oldstate = ppc->irqstate; UINT32 levelmask; if (state != CLEAR_LINE) ppc->irqstate |= bitmask; else ppc->irqstate &= ~bitmask; if (((ppc->irqstate ^ oldstate) & bitmask) && (ppc->irqstate & bitmask)) ppc->dcr[DCR4XX_EXISR] |= bitmask; levelmask = PPC4XX_IRQ_BIT_CRITICAL | PPC4XX_IRQ_BIT_SPUR | PPC4XX_IRQ_BIT_SPUT; levelmask |= PPC4XX_IRQ_BIT_JTAGR | PPC4XX_IRQ_BIT_JTAGT; levelmask |= PPC4XX_IRQ_BIT_DMA0 | PPC4XX_IRQ_BIT_DMA1 | PPC4XX_IRQ_BIT_DMA2 | PPC4XX_IRQ_BIT_DMA3; if (!(ppc->dcr[DCR4XX_IOCR] & 0x80000000)) levelmask |= PPC4XX_IRQ_BIT_EXT0; if (!(ppc->dcr[DCR4XX_IOCR] & 0x20000000)) levelmask |= PPC4XX_IRQ_BIT_EXT1; if (!(ppc->dcr[DCR4XX_IOCR] & 0x08000000)) levelmask |= PPC4XX_IRQ_BIT_EXT2; if (!(ppc->dcr[DCR4XX_IOCR] & 0x02000000)) levelmask |= PPC4XX_IRQ_BIT_EXT3; if (!(ppc->dcr[DCR4XX_IOCR] & 0x00800000)) levelmask |= PPC4XX_IRQ_BIT_EXT4; ppc->dcr[DCR4XX_EXISR] = (ppc->dcr[DCR4XX_EXISR] & ~levelmask) | (ppc->irqstate & levelmask); ppc->irq_pending = ((ppc->dcr[DCR4XX_EXISR] & ppc->dcr[DCR4XX_EXIER]) != 0); if ((ppc->spr[SPR4XX_TCR] & PPC4XX_TCR_FIE) && (ppc->spr[SPR4XX_TSR] & PPC4XX_TSR_FIS)) ppc->irq_pending = TRUE; if ((ppc->spr[SPR4XX_TCR] & PPC4XX_TCR_PIE) && (ppc->spr[SPR4XX_TSR] & PPC4XX_TSR_PIS)) ppc->irq_pending = TRUE; }
[ "static", "void", "ppc4xx_set_irq_line", "(", "powerpc_state", "*", "ppc", ",", "UINT32", "bitmask", ",", "int", "state", ")", "{", "UINT32", "oldstate", "=", "ppc", "->", "irqstate", ";", "UINT32", "levelmask", ";", "if", "(", "state", "!=", "CLEAR_LINE", ")", "ppc", "->", "irqstate", "|=", "bitmask", ";", "else", "ppc", "->", "irqstate", "&=", "~", "bitmask", ";", "if", "(", "(", "(", "ppc", "->", "irqstate", "^", "oldstate", ")", "&", "bitmask", ")", "&&", "(", "ppc", "->", "irqstate", "&", "bitmask", ")", ")", "ppc", "->", "dcr", "[", "DCR4XX_EXISR", "]", "|=", "bitmask", ";", "levelmask", "=", "PPC4XX_IRQ_BIT_CRITICAL", "|", "PPC4XX_IRQ_BIT_SPUR", "|", "PPC4XX_IRQ_BIT_SPUT", ";", "levelmask", "|=", "PPC4XX_IRQ_BIT_JTAGR", "|", "PPC4XX_IRQ_BIT_JTAGT", ";", "levelmask", "|=", "PPC4XX_IRQ_BIT_DMA0", "|", "PPC4XX_IRQ_BIT_DMA1", "|", "PPC4XX_IRQ_BIT_DMA2", "|", "PPC4XX_IRQ_BIT_DMA3", ";", "if", "(", "!", "(", "ppc", "->", "dcr", "[", "DCR4XX_IOCR", "]", "&", "0x80000000", ")", ")", "levelmask", "|=", "PPC4XX_IRQ_BIT_EXT0", ";", "if", "(", "!", "(", "ppc", "->", "dcr", "[", "DCR4XX_IOCR", "]", "&", "0x20000000", ")", ")", "levelmask", "|=", "PPC4XX_IRQ_BIT_EXT1", ";", "if", "(", "!", "(", "ppc", "->", "dcr", "[", "DCR4XX_IOCR", "]", "&", "0x08000000", ")", ")", "levelmask", "|=", "PPC4XX_IRQ_BIT_EXT2", ";", "if", "(", "!", "(", "ppc", "->", "dcr", "[", "DCR4XX_IOCR", "]", "&", "0x02000000", ")", ")", "levelmask", "|=", "PPC4XX_IRQ_BIT_EXT3", ";", "if", "(", "!", "(", "ppc", "->", "dcr", "[", "DCR4XX_IOCR", "]", "&", "0x00800000", ")", ")", "levelmask", "|=", "PPC4XX_IRQ_BIT_EXT4", ";", "ppc", "->", "dcr", "[", "DCR4XX_EXISR", "]", "=", "(", "ppc", "->", "dcr", "[", "DCR4XX_EXISR", "]", "&", "~", "levelmask", ")", "|", "(", "ppc", "->", "irqstate", "&", "levelmask", ")", ";", "ppc", "->", "irq_pending", "=", "(", "(", "ppc", "->", "dcr", "[", "DCR4XX_EXISR", "]", "&", "ppc", "->", "dcr", "[", "DCR4XX_EXIER", "]", ")", "!=", "0", ")", ";", "if", "(", "(", "ppc", "->", "spr", "[", "SPR4XX_TCR", "]", "&", "PPC4XX_TCR_FIE", ")", "&&", "(", "ppc", "->", "spr", "[", "SPR4XX_TSR", "]", "&", "PPC4XX_TSR_FIS", ")", ")", "ppc", "->", "irq_pending", "=", "TRUE", ";", "if", "(", "(", "ppc", "->", "spr", "[", "SPR4XX_TCR", "]", "&", "PPC4XX_TCR_PIE", ")", "&&", "(", "ppc", "->", "spr", "[", "SPR4XX_TSR", "]", "&", "PPC4XX_TSR_PIS", ")", ")", "ppc", "->", "irq_pending", "=", "TRUE", ";", "}" ]
ppc4xx_set_irq_line - PowerPC 4XX-specific IRQ line management
[ "ppc4xx_set_irq_line", "-", "PowerPC", "4XX", "-", "specific", "IRQ", "line", "management" ]
[ "/* set or clear the appropriate bit */", "/* if the state changed to on, edge trigger the interrupt */", "/* pass through all level-triggered interrupts */", "/* update the IRQ status */" ]
[ { "param": "ppc", "type": "powerpc_state" }, { "param": "bitmask", "type": "UINT32" }, { "param": "state", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ppc", "type": "powerpc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bitmask", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "state", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9fb9c5cf4c3689ffe2d2bb3bbbdf91d2f0ecaf01
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/powerpc/ppccom.c
[ "Unlicense" ]
C
ppc4xx_dma_update_irq_states
void
static void ppc4xx_dma_update_irq_states(powerpc_state *ppc) { int dmachan; /* update the IRQ state for each DMA channel */ for (dmachan = 0; dmachan < 4; dmachan++) if ((ppc->dcr[DCR4XX_DMACR0 + 8 * dmachan] & PPC4XX_DMACR_CIE) && (ppc->dcr[DCR4XX_DMASR] & (0x11 << (27 - dmachan)))) ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_DMA(dmachan), ASSERT_LINE); else ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_DMA(dmachan), CLEAR_LINE); }
/*------------------------------------------------- ppc4xx_dma_update_irq_states - update the IRQ state for each DMA channel -------------------------------------------------*/
update the IRQ state for each DMA channel
[ "update", "the", "IRQ", "state", "for", "each", "DMA", "channel" ]
static void ppc4xx_dma_update_irq_states(powerpc_state *ppc) { int dmachan; for (dmachan = 0; dmachan < 4; dmachan++) if ((ppc->dcr[DCR4XX_DMACR0 + 8 * dmachan] & PPC4XX_DMACR_CIE) && (ppc->dcr[DCR4XX_DMASR] & (0x11 << (27 - dmachan)))) ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_DMA(dmachan), ASSERT_LINE); else ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_DMA(dmachan), CLEAR_LINE); }
[ "static", "void", "ppc4xx_dma_update_irq_states", "(", "powerpc_state", "*", "ppc", ")", "{", "int", "dmachan", ";", "for", "(", "dmachan", "=", "0", ";", "dmachan", "<", "4", ";", "dmachan", "++", ")", "if", "(", "(", "ppc", "->", "dcr", "[", "DCR4XX_DMACR0", "+", "8", "*", "dmachan", "]", "&", "PPC4XX_DMACR_CIE", ")", "&&", "(", "ppc", "->", "dcr", "[", "DCR4XX_DMASR", "]", "&", "(", "0x11", "<<", "(", "27", "-", "dmachan", ")", ")", ")", ")", "ppc4xx_set_irq_line", "(", "ppc", ",", "PPC4XX_IRQ_BIT_DMA", "(", "dmachan", ")", ",", "ASSERT_LINE", ")", ";", "else", "ppc4xx_set_irq_line", "(", "ppc", ",", "PPC4XX_IRQ_BIT_DMA", "(", "dmachan", ")", ",", "CLEAR_LINE", ")", ";", "}" ]
ppc4xx_dma_update_irq_states - update the IRQ state for each DMA channel
[ "ppc4xx_dma_update_irq_states", "-", "update", "the", "IRQ", "state", "for", "each", "DMA", "channel" ]
[ "/* update the IRQ state for each DMA channel */" ]
[ { "param": "ppc", "type": "powerpc_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ppc", "type": "powerpc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9fb9c5cf4c3689ffe2d2bb3bbbdf91d2f0ecaf01
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/powerpc/ppccom.c
[ "Unlicense" ]
C
ppc4xx_dma_decrement_count
int
static int ppc4xx_dma_decrement_count(powerpc_state *ppc, int dmachan) { UINT32 *dmaregs = &ppc->dcr[8 * dmachan]; /* decrement the counter */ dmaregs[DCR4XX_DMACT0]--; /* if non-zero, we keep going */ if ((dmaregs[DCR4XX_DMACT0] & 0xffff) != 0) return FALSE; /* set the complete bit and handle interrupts */ ppc->dcr[DCR4XX_DMASR] |= 1 << (31 - dmachan); // ppc->dcr[DCR4XX_DMASR] |= 1 << (27 - dmachan); ppc4xx_dma_update_irq_states(ppc); return TRUE; }
/*------------------------------------------------- ppc4xx_dma_decrement_count - decrement the count on a channel and interrupt if configured to do so -------------------------------------------------*/
decrement the count on a channel and interrupt if configured to do so
[ "decrement", "the", "count", "on", "a", "channel", "and", "interrupt", "if", "configured", "to", "do", "so" ]
static int ppc4xx_dma_decrement_count(powerpc_state *ppc, int dmachan) { UINT32 *dmaregs = &ppc->dcr[8 * dmachan]; dmaregs[DCR4XX_DMACT0]--; if ((dmaregs[DCR4XX_DMACT0] & 0xffff) != 0) return FALSE; ppc->dcr[DCR4XX_DMASR] |= 1 << (31 - dmachan); ppc4xx_dma_update_irq_states(ppc); return TRUE; }
[ "static", "int", "ppc4xx_dma_decrement_count", "(", "powerpc_state", "*", "ppc", ",", "int", "dmachan", ")", "{", "UINT32", "*", "dmaregs", "=", "&", "ppc", "->", "dcr", "[", "8", "*", "dmachan", "]", ";", "dmaregs", "[", "DCR4XX_DMACT0", "]", "--", ";", "if", "(", "(", "dmaregs", "[", "DCR4XX_DMACT0", "]", "&", "0xffff", ")", "!=", "0", ")", "return", "FALSE", ";", "ppc", "->", "dcr", "[", "DCR4XX_DMASR", "]", "|=", "1", "<<", "(", "31", "-", "dmachan", ")", ";", "ppc4xx_dma_update_irq_states", "(", "ppc", ")", ";", "return", "TRUE", ";", "}" ]
ppc4xx_dma_decrement_count - decrement the count on a channel and interrupt if configured to do so
[ "ppc4xx_dma_decrement_count", "-", "decrement", "the", "count", "on", "a", "channel", "and", "interrupt", "if", "configured", "to", "do", "so" ]
[ "/* decrement the counter */", "/* if non-zero, we keep going */", "/* set the complete bit and handle interrupts */", "// ppc->dcr[DCR4XX_DMASR] |= 1 << (27 - dmachan);" ]
[ { "param": "ppc", "type": "powerpc_state" }, { "param": "dmachan", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ppc", "type": "powerpc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dmachan", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9fb9c5cf4c3689ffe2d2bb3bbbdf91d2f0ecaf01
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/powerpc/ppccom.c
[ "Unlicense" ]
C
ppc4xx_dma_fetch_transmit_byte
int
static int ppc4xx_dma_fetch_transmit_byte(powerpc_state *ppc, int dmachan, UINT8 *byte) { UINT32 *dmaregs = &ppc->dcr[8 * dmachan]; /* if the channel is not enabled, fail */ if (!(dmaregs[DCR4XX_DMACR0] & PPC4XX_DMACR_CE)) return FALSE; /* if no transfers remaining, fail */ if ((dmaregs[DCR4XX_DMACT0] & 0xffff) == 0) return FALSE; /* fetch the data */ *byte = memory_read_byte(ppc->program, dmaregs[DCR4XX_DMADA0]++); ppc4xx_dma_decrement_count(ppc, dmachan); return TRUE; }
/*------------------------------------------------- ppc4xx_dma_fetch_transmit_byte - fetch a byte to send to a peripheral -------------------------------------------------*/
fetch a byte to send to a peripheral
[ "fetch", "a", "byte", "to", "send", "to", "a", "peripheral" ]
static int ppc4xx_dma_fetch_transmit_byte(powerpc_state *ppc, int dmachan, UINT8 *byte) { UINT32 *dmaregs = &ppc->dcr[8 * dmachan]; if (!(dmaregs[DCR4XX_DMACR0] & PPC4XX_DMACR_CE)) return FALSE; if ((dmaregs[DCR4XX_DMACT0] & 0xffff) == 0) return FALSE; *byte = memory_read_byte(ppc->program, dmaregs[DCR4XX_DMADA0]++); ppc4xx_dma_decrement_count(ppc, dmachan); return TRUE; }
[ "static", "int", "ppc4xx_dma_fetch_transmit_byte", "(", "powerpc_state", "*", "ppc", ",", "int", "dmachan", ",", "UINT8", "*", "byte", ")", "{", "UINT32", "*", "dmaregs", "=", "&", "ppc", "->", "dcr", "[", "8", "*", "dmachan", "]", ";", "if", "(", "!", "(", "dmaregs", "[", "DCR4XX_DMACR0", "]", "&", "PPC4XX_DMACR_CE", ")", ")", "return", "FALSE", ";", "if", "(", "(", "dmaregs", "[", "DCR4XX_DMACT0", "]", "&", "0xffff", ")", "==", "0", ")", "return", "FALSE", ";", "*", "byte", "=", "memory_read_byte", "(", "ppc", "->", "program", ",", "dmaregs", "[", "DCR4XX_DMADA0", "]", "++", ")", ";", "ppc4xx_dma_decrement_count", "(", "ppc", ",", "dmachan", ")", ";", "return", "TRUE", ";", "}" ]
ppc4xx_dma_fetch_transmit_byte - fetch a byte to send to a peripheral
[ "ppc4xx_dma_fetch_transmit_byte", "-", "fetch", "a", "byte", "to", "send", "to", "a", "peripheral" ]
[ "/* if the channel is not enabled, fail */", "/* if no transfers remaining, fail */", "/* fetch the data */" ]
[ { "param": "ppc", "type": "powerpc_state" }, { "param": "dmachan", "type": "int" }, { "param": "byte", "type": "UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ppc", "type": "powerpc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dmachan", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "byte", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9fb9c5cf4c3689ffe2d2bb3bbbdf91d2f0ecaf01
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/powerpc/ppccom.c
[ "Unlicense" ]
C
ppc4xx_dma_handle_receive_byte
int
static int ppc4xx_dma_handle_receive_byte(powerpc_state *ppc, int dmachan, UINT8 byte) { UINT32 *dmaregs = &ppc->dcr[8 * dmachan]; /* if the channel is not enabled, fail */ if (!(dmaregs[DCR4XX_DMACR0] & PPC4XX_DMACR_CE)) return FALSE; /* if no transfers remaining, fail */ if ((dmaregs[DCR4XX_DMACT0] & 0xffff) == 0) return FALSE; /* store the data */ memory_write_byte(ppc->program, dmaregs[DCR4XX_DMADA0]++, byte); ppc4xx_dma_decrement_count(ppc, dmachan); return TRUE; }
/*------------------------------------------------- ppc4xx_dma_handle_receive_byte - receive a byte transmitted by a peripheral -------------------------------------------------*/
receive a byte transmitted by a peripheral
[ "receive", "a", "byte", "transmitted", "by", "a", "peripheral" ]
static int ppc4xx_dma_handle_receive_byte(powerpc_state *ppc, int dmachan, UINT8 byte) { UINT32 *dmaregs = &ppc->dcr[8 * dmachan]; if (!(dmaregs[DCR4XX_DMACR0] & PPC4XX_DMACR_CE)) return FALSE; if ((dmaregs[DCR4XX_DMACT0] & 0xffff) == 0) return FALSE; memory_write_byte(ppc->program, dmaregs[DCR4XX_DMADA0]++, byte); ppc4xx_dma_decrement_count(ppc, dmachan); return TRUE; }
[ "static", "int", "ppc4xx_dma_handle_receive_byte", "(", "powerpc_state", "*", "ppc", ",", "int", "dmachan", ",", "UINT8", "byte", ")", "{", "UINT32", "*", "dmaregs", "=", "&", "ppc", "->", "dcr", "[", "8", "*", "dmachan", "]", ";", "if", "(", "!", "(", "dmaregs", "[", "DCR4XX_DMACR0", "]", "&", "PPC4XX_DMACR_CE", ")", ")", "return", "FALSE", ";", "if", "(", "(", "dmaregs", "[", "DCR4XX_DMACT0", "]", "&", "0xffff", ")", "==", "0", ")", "return", "FALSE", ";", "memory_write_byte", "(", "ppc", "->", "program", ",", "dmaregs", "[", "DCR4XX_DMADA0", "]", "++", ",", "byte", ")", ";", "ppc4xx_dma_decrement_count", "(", "ppc", ",", "dmachan", ")", ";", "return", "TRUE", ";", "}" ]
ppc4xx_dma_handle_receive_byte - receive a byte transmitted by a peripheral
[ "ppc4xx_dma_handle_receive_byte", "-", "receive", "a", "byte", "transmitted", "by", "a", "peripheral" ]
[ "/* if the channel is not enabled, fail */", "/* if no transfers remaining, fail */", "/* store the data */" ]
[ { "param": "ppc", "type": "powerpc_state" }, { "param": "dmachan", "type": "int" }, { "param": "byte", "type": "UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ppc", "type": "powerpc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dmachan", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "byte", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9fb9c5cf4c3689ffe2d2bb3bbbdf91d2f0ecaf01
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/powerpc/ppccom.c
[ "Unlicense" ]
C
ppc4xx_dma_exec
void
static void ppc4xx_dma_exec(powerpc_state *ppc, int dmachan) { static const UINT8 dma_transfer_width[4] = { 1, 2, 4, 16 }; UINT32 *dmaregs = &ppc->dcr[8 * dmachan]; INT32 destinc, srcinc; UINT8 width; /* skip if not enabled */ if (!(dmaregs[DCR4XX_DMACR0] & PPC4XX_DMACR_CE)) return; /* check for unsupported features */ if (!(dmaregs[DCR4XX_DMACR0] & PPC4XX_DMACR_TCE)) fatalerror("ppc4xx_dma_exec: DMA_TCE == 0"); if (dmaregs[DCR4XX_DMACR0] & PPC4XX_DMACR_CH) fatalerror("ppc4xx_dma_exec: DMA chaining not implemented"); /* transfer mode */ switch ((dmaregs[DCR4XX_DMACR0] & PPC4XX_DMACR_TM_MASK) >> 21) { /* buffered mode DMA */ case 0: /* nothing to do; this happens asynchronously and is driven by the SPU */ break; /* fly-by mode DMA */ case 1: fatalerror("ppc4xx_dma_exec: fly-by DMA not implemented"); break; /* software initiated memory-to-memory mode DMA */ case 2: width = dma_transfer_width[(dmaregs[DCR4XX_DMACR0] & PPC4XX_DMACR_PW_MASK) >> 26]; srcinc = (dmaregs[DCR4XX_DMACR0] & PPC4XX_DMACR_SAI) ? width : 0; destinc = (dmaregs[DCR4XX_DMACR0] & PPC4XX_DMACR_DAI) ? width : 0; switch (width) { /* byte transfer */ case 1: do { memory_write_byte(ppc->program, dmaregs[DCR4XX_DMADA0], memory_read_byte(ppc->program, dmaregs[DCR4XX_DMASA0])); dmaregs[DCR4XX_DMASA0] += srcinc; dmaregs[DCR4XX_DMADA0] += destinc; } while (!ppc4xx_dma_decrement_count(ppc, dmachan)); break; /* word transfer */ case 2: do { memory_write_word(ppc->program, dmaregs[DCR4XX_DMADA0], memory_read_word(ppc->program, dmaregs[DCR4XX_DMASA0])); dmaregs[DCR4XX_DMASA0] += srcinc; dmaregs[DCR4XX_DMADA0] += destinc; } while (!ppc4xx_dma_decrement_count(ppc, dmachan)); break; /* dword transfer */ case 4: do { memory_write_dword(ppc->program, dmaregs[DCR4XX_DMADA0], memory_read_dword(ppc->program, dmaregs[DCR4XX_DMASA0])); dmaregs[DCR4XX_DMASA0] += srcinc; dmaregs[DCR4XX_DMADA0] += destinc; } while (!ppc4xx_dma_decrement_count(ppc, dmachan)); break; /* 16-byte transfer */ case 16: do { memory_write_qword(ppc->program, dmaregs[DCR4XX_DMADA0], memory_read_qword(ppc->program, dmaregs[DCR4XX_DMASA0])); memory_write_qword(ppc->program, dmaregs[DCR4XX_DMADA0] + 8, memory_read_qword(ppc->program, dmaregs[DCR4XX_DMASA0] + 8)); dmaregs[DCR4XX_DMASA0] += srcinc; dmaregs[DCR4XX_DMADA0] += destinc; } while (!ppc4xx_dma_decrement_count(ppc, dmachan)); break; } break; /* hardware initiated memory-to-memory mode DMA */ case 3: fatalerror("ppc4xx_dma_exec: HW mem-to-mem DMA not implemented"); break; } }
/*------------------------------------------------- ppc4xx_dma_execute - execute a DMA operation if one is pending -------------------------------------------------*/
execute a DMA operation if one is pending
[ "execute", "a", "DMA", "operation", "if", "one", "is", "pending" ]
static void ppc4xx_dma_exec(powerpc_state *ppc, int dmachan) { static const UINT8 dma_transfer_width[4] = { 1, 2, 4, 16 }; UINT32 *dmaregs = &ppc->dcr[8 * dmachan]; INT32 destinc, srcinc; UINT8 width; if (!(dmaregs[DCR4XX_DMACR0] & PPC4XX_DMACR_CE)) return; if (!(dmaregs[DCR4XX_DMACR0] & PPC4XX_DMACR_TCE)) fatalerror("ppc4xx_dma_exec: DMA_TCE == 0"); if (dmaregs[DCR4XX_DMACR0] & PPC4XX_DMACR_CH) fatalerror("ppc4xx_dma_exec: DMA chaining not implemented"); switch ((dmaregs[DCR4XX_DMACR0] & PPC4XX_DMACR_TM_MASK) >> 21) { case 0: break; case 1: fatalerror("ppc4xx_dma_exec: fly-by DMA not implemented"); break; case 2: width = dma_transfer_width[(dmaregs[DCR4XX_DMACR0] & PPC4XX_DMACR_PW_MASK) >> 26]; srcinc = (dmaregs[DCR4XX_DMACR0] & PPC4XX_DMACR_SAI) ? width : 0; destinc = (dmaregs[DCR4XX_DMACR0] & PPC4XX_DMACR_DAI) ? width : 0; switch (width) { case 1: do { memory_write_byte(ppc->program, dmaregs[DCR4XX_DMADA0], memory_read_byte(ppc->program, dmaregs[DCR4XX_DMASA0])); dmaregs[DCR4XX_DMASA0] += srcinc; dmaregs[DCR4XX_DMADA0] += destinc; } while (!ppc4xx_dma_decrement_count(ppc, dmachan)); break; case 2: do { memory_write_word(ppc->program, dmaregs[DCR4XX_DMADA0], memory_read_word(ppc->program, dmaregs[DCR4XX_DMASA0])); dmaregs[DCR4XX_DMASA0] += srcinc; dmaregs[DCR4XX_DMADA0] += destinc; } while (!ppc4xx_dma_decrement_count(ppc, dmachan)); break; case 4: do { memory_write_dword(ppc->program, dmaregs[DCR4XX_DMADA0], memory_read_dword(ppc->program, dmaregs[DCR4XX_DMASA0])); dmaregs[DCR4XX_DMASA0] += srcinc; dmaregs[DCR4XX_DMADA0] += destinc; } while (!ppc4xx_dma_decrement_count(ppc, dmachan)); break; case 16: do { memory_write_qword(ppc->program, dmaregs[DCR4XX_DMADA0], memory_read_qword(ppc->program, dmaregs[DCR4XX_DMASA0])); memory_write_qword(ppc->program, dmaregs[DCR4XX_DMADA0] + 8, memory_read_qword(ppc->program, dmaregs[DCR4XX_DMASA0] + 8)); dmaregs[DCR4XX_DMASA0] += srcinc; dmaregs[DCR4XX_DMADA0] += destinc; } while (!ppc4xx_dma_decrement_count(ppc, dmachan)); break; } break; case 3: fatalerror("ppc4xx_dma_exec: HW mem-to-mem DMA not implemented"); break; } }
[ "static", "void", "ppc4xx_dma_exec", "(", "powerpc_state", "*", "ppc", ",", "int", "dmachan", ")", "{", "static", "const", "UINT8", "dma_transfer_width", "[", "4", "]", "=", "{", "1", ",", "2", ",", "4", ",", "16", "}", ";", "UINT32", "*", "dmaregs", "=", "&", "ppc", "->", "dcr", "[", "8", "*", "dmachan", "]", ";", "INT32", "destinc", ",", "srcinc", ";", "UINT8", "width", ";", "if", "(", "!", "(", "dmaregs", "[", "DCR4XX_DMACR0", "]", "&", "PPC4XX_DMACR_CE", ")", ")", "return", ";", "if", "(", "!", "(", "dmaregs", "[", "DCR4XX_DMACR0", "]", "&", "PPC4XX_DMACR_TCE", ")", ")", "fatalerror", "(", "\"", "\"", ")", ";", "if", "(", "dmaregs", "[", "DCR4XX_DMACR0", "]", "&", "PPC4XX_DMACR_CH", ")", "fatalerror", "(", "\"", "\"", ")", ";", "switch", "(", "(", "dmaregs", "[", "DCR4XX_DMACR0", "]", "&", "PPC4XX_DMACR_TM_MASK", ")", ">>", "21", ")", "{", "case", "0", ":", "break", ";", "case", "1", ":", "fatalerror", "(", "\"", "\"", ")", ";", "break", ";", "case", "2", ":", "width", "=", "dma_transfer_width", "[", "(", "dmaregs", "[", "DCR4XX_DMACR0", "]", "&", "PPC4XX_DMACR_PW_MASK", ")", ">>", "26", "]", ";", "srcinc", "=", "(", "dmaregs", "[", "DCR4XX_DMACR0", "]", "&", "PPC4XX_DMACR_SAI", ")", "?", "width", ":", "0", ";", "destinc", "=", "(", "dmaregs", "[", "DCR4XX_DMACR0", "]", "&", "PPC4XX_DMACR_DAI", ")", "?", "width", ":", "0", ";", "switch", "(", "width", ")", "{", "case", "1", ":", "do", "{", "memory_write_byte", "(", "ppc", "->", "program", ",", "dmaregs", "[", "DCR4XX_DMADA0", "]", ",", "memory_read_byte", "(", "ppc", "->", "program", ",", "dmaregs", "[", "DCR4XX_DMASA0", "]", ")", ")", ";", "dmaregs", "[", "DCR4XX_DMASA0", "]", "+=", "srcinc", ";", "dmaregs", "[", "DCR4XX_DMADA0", "]", "+=", "destinc", ";", "}", "while", "(", "!", "ppc4xx_dma_decrement_count", "(", "ppc", ",", "dmachan", ")", ")", ";", "break", ";", "case", "2", ":", "do", "{", "memory_write_word", "(", "ppc", "->", "program", ",", "dmaregs", "[", "DCR4XX_DMADA0", "]", ",", "memory_read_word", "(", "ppc", "->", "program", ",", "dmaregs", "[", "DCR4XX_DMASA0", "]", ")", ")", ";", "dmaregs", "[", "DCR4XX_DMASA0", "]", "+=", "srcinc", ";", "dmaregs", "[", "DCR4XX_DMADA0", "]", "+=", "destinc", ";", "}", "while", "(", "!", "ppc4xx_dma_decrement_count", "(", "ppc", ",", "dmachan", ")", ")", ";", "break", ";", "case", "4", ":", "do", "{", "memory_write_dword", "(", "ppc", "->", "program", ",", "dmaregs", "[", "DCR4XX_DMADA0", "]", ",", "memory_read_dword", "(", "ppc", "->", "program", ",", "dmaregs", "[", "DCR4XX_DMASA0", "]", ")", ")", ";", "dmaregs", "[", "DCR4XX_DMASA0", "]", "+=", "srcinc", ";", "dmaregs", "[", "DCR4XX_DMADA0", "]", "+=", "destinc", ";", "}", "while", "(", "!", "ppc4xx_dma_decrement_count", "(", "ppc", ",", "dmachan", ")", ")", ";", "break", ";", "case", "16", ":", "do", "{", "memory_write_qword", "(", "ppc", "->", "program", ",", "dmaregs", "[", "DCR4XX_DMADA0", "]", ",", "memory_read_qword", "(", "ppc", "->", "program", ",", "dmaregs", "[", "DCR4XX_DMASA0", "]", ")", ")", ";", "memory_write_qword", "(", "ppc", "->", "program", ",", "dmaregs", "[", "DCR4XX_DMADA0", "]", "+", "8", ",", "memory_read_qword", "(", "ppc", "->", "program", ",", "dmaregs", "[", "DCR4XX_DMASA0", "]", "+", "8", ")", ")", ";", "dmaregs", "[", "DCR4XX_DMASA0", "]", "+=", "srcinc", ";", "dmaregs", "[", "DCR4XX_DMADA0", "]", "+=", "destinc", ";", "}", "while", "(", "!", "ppc4xx_dma_decrement_count", "(", "ppc", ",", "dmachan", ")", ")", ";", "break", ";", "}", "break", ";", "case", "3", ":", "fatalerror", "(", "\"", "\"", ")", ";", "break", ";", "}", "}" ]
ppc4xx_dma_execute - execute a DMA operation if one is pending
[ "ppc4xx_dma_execute", "-", "execute", "a", "DMA", "operation", "if", "one", "is", "pending" ]
[ "/* skip if not enabled */", "/* check for unsupported features */", "/* transfer mode */", "/* buffered mode DMA */", "/* nothing to do; this happens asynchronously and is driven by the SPU */", "/* fly-by mode DMA */", "/* software initiated memory-to-memory mode DMA */", "/* byte transfer */", "/* word transfer */", "/* dword transfer */", "/* 16-byte transfer */", "/* hardware initiated memory-to-memory mode DMA */" ]
[ { "param": "ppc", "type": "powerpc_state" }, { "param": "dmachan", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ppc", "type": "powerpc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dmachan", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9fb9c5cf4c3689ffe2d2bb3bbbdf91d2f0ecaf01
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/powerpc/ppccom.c
[ "Unlicense" ]
C
ppc4xx_spu_update_irq_states
void
static void ppc4xx_spu_update_irq_states(powerpc_state *ppc) { /* check for receive buffer full interrupt */ if ((ppc->spu.regs[SPU4XX_RX_COMMAND] & 0x60) == 0x20 && (ppc->spu.regs[SPU4XX_LINE_STATUS] & 0x80)) ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_SPUR, ASSERT_LINE); /* check for receive error interrupt */ else if ((ppc->spu.regs[SPU4XX_RX_COMMAND] & 0x10) && (ppc->spu.regs[SPU4XX_LINE_STATUS] & 0x78)) ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_SPUR, ASSERT_LINE); /* clear otherwise */ else ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_SPUR, CLEAR_LINE); /* check for transmit buffer empty interrupt */ if ((ppc->spu.regs[SPU4XX_TX_COMMAND] & 0x60) == 0x20 && (ppc->spu.regs[SPU4XX_LINE_STATUS] & 0x04)) ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_SPUT, ASSERT_LINE); /* check for shift register empty interrupt */ else if ((ppc->spu.regs[SPU4XX_TX_COMMAND] & 0x10) && (ppc->spu.regs[SPU4XX_LINE_STATUS] & 0x02)) ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_SPUT, ASSERT_LINE); /* clear otherwise */ else ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_SPUT, CLEAR_LINE); }
/*------------------------------------------------- ppc4xx_spu_update_irq_states - update the IRQ state for the SPU -------------------------------------------------*/
update the IRQ state for the SPU
[ "update", "the", "IRQ", "state", "for", "the", "SPU" ]
static void ppc4xx_spu_update_irq_states(powerpc_state *ppc) { if ((ppc->spu.regs[SPU4XX_RX_COMMAND] & 0x60) == 0x20 && (ppc->spu.regs[SPU4XX_LINE_STATUS] & 0x80)) ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_SPUR, ASSERT_LINE); else if ((ppc->spu.regs[SPU4XX_RX_COMMAND] & 0x10) && (ppc->spu.regs[SPU4XX_LINE_STATUS] & 0x78)) ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_SPUR, ASSERT_LINE); else ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_SPUR, CLEAR_LINE); if ((ppc->spu.regs[SPU4XX_TX_COMMAND] & 0x60) == 0x20 && (ppc->spu.regs[SPU4XX_LINE_STATUS] & 0x04)) ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_SPUT, ASSERT_LINE); else if ((ppc->spu.regs[SPU4XX_TX_COMMAND] & 0x10) && (ppc->spu.regs[SPU4XX_LINE_STATUS] & 0x02)) ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_SPUT, ASSERT_LINE); else ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_SPUT, CLEAR_LINE); }
[ "static", "void", "ppc4xx_spu_update_irq_states", "(", "powerpc_state", "*", "ppc", ")", "{", "if", "(", "(", "ppc", "->", "spu", ".", "regs", "[", "SPU4XX_RX_COMMAND", "]", "&", "0x60", ")", "==", "0x20", "&&", "(", "ppc", "->", "spu", ".", "regs", "[", "SPU4XX_LINE_STATUS", "]", "&", "0x80", ")", ")", "ppc4xx_set_irq_line", "(", "ppc", ",", "PPC4XX_IRQ_BIT_SPUR", ",", "ASSERT_LINE", ")", ";", "else", "if", "(", "(", "ppc", "->", "spu", ".", "regs", "[", "SPU4XX_RX_COMMAND", "]", "&", "0x10", ")", "&&", "(", "ppc", "->", "spu", ".", "regs", "[", "SPU4XX_LINE_STATUS", "]", "&", "0x78", ")", ")", "ppc4xx_set_irq_line", "(", "ppc", ",", "PPC4XX_IRQ_BIT_SPUR", ",", "ASSERT_LINE", ")", ";", "else", "ppc4xx_set_irq_line", "(", "ppc", ",", "PPC4XX_IRQ_BIT_SPUR", ",", "CLEAR_LINE", ")", ";", "if", "(", "(", "ppc", "->", "spu", ".", "regs", "[", "SPU4XX_TX_COMMAND", "]", "&", "0x60", ")", "==", "0x20", "&&", "(", "ppc", "->", "spu", ".", "regs", "[", "SPU4XX_LINE_STATUS", "]", "&", "0x04", ")", ")", "ppc4xx_set_irq_line", "(", "ppc", ",", "PPC4XX_IRQ_BIT_SPUT", ",", "ASSERT_LINE", ")", ";", "else", "if", "(", "(", "ppc", "->", "spu", ".", "regs", "[", "SPU4XX_TX_COMMAND", "]", "&", "0x10", ")", "&&", "(", "ppc", "->", "spu", ".", "regs", "[", "SPU4XX_LINE_STATUS", "]", "&", "0x02", ")", ")", "ppc4xx_set_irq_line", "(", "ppc", ",", "PPC4XX_IRQ_BIT_SPUT", ",", "ASSERT_LINE", ")", ";", "else", "ppc4xx_set_irq_line", "(", "ppc", ",", "PPC4XX_IRQ_BIT_SPUT", ",", "CLEAR_LINE", ")", ";", "}" ]
ppc4xx_spu_update_irq_states - update the IRQ state for the SPU
[ "ppc4xx_spu_update_irq_states", "-", "update", "the", "IRQ", "state", "for", "the", "SPU" ]
[ "/* check for receive buffer full interrupt */", "/* check for receive error interrupt */", "/* clear otherwise */", "/* check for transmit buffer empty interrupt */", "/* check for shift register empty interrupt */", "/* clear otherwise */" ]
[ { "param": "ppc", "type": "powerpc_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ppc", "type": "powerpc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9fb9c5cf4c3689ffe2d2bb3bbbdf91d2f0ecaf01
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/powerpc/ppccom.c
[ "Unlicense" ]
C
ppc4xx_spu_timer_reset
void
static void ppc4xx_spu_timer_reset(powerpc_state *ppc) { UINT8 enabled = (ppc->spu.regs[SPU4XX_RX_COMMAND] | ppc->spu.regs[SPU4XX_TX_COMMAND]) & 0x80; /* if we're enabled, reset at the current baud rate */ if (enabled) { attotime clockperiod = ATTOTIME_IN_HZ((ppc->dcr[DCR4XX_IOCR] & 0x02) ? 3686400 : 33333333); int divisor = ((ppc->spu.regs[SPU4XX_BAUD_DIVISOR_H] * 256 + ppc->spu.regs[SPU4XX_BAUD_DIVISOR_L]) & 0xfff) + 1; int bpc = 7 + ((ppc->spu.regs[SPU4XX_CONTROL] & 8) >> 3) + 1 + (ppc->spu.regs[SPU4XX_CONTROL] & 1); attotime charperiod = attotime_mul(clockperiod, divisor * 16 * bpc); timer_adjust_periodic(ppc->spu.timer, charperiod, 0, charperiod); if (PRINTF_SPU) printf("ppc4xx_spu_timer_reset: baud rate = %.0f\n", ATTOSECONDS_TO_HZ(charperiod.attoseconds) * bpc); } /* otherwise, disable the timer */ else timer_adjust_oneshot(ppc->spu.timer, attotime_never, 0); }
/*------------------------------------------------- ppc4xx_spu_timer_reset - reset and recompute the transmit/receive timer -------------------------------------------------*/
reset and recompute the transmit/receive timer
[ "reset", "and", "recompute", "the", "transmit", "/", "receive", "timer" ]
static void ppc4xx_spu_timer_reset(powerpc_state *ppc) { UINT8 enabled = (ppc->spu.regs[SPU4XX_RX_COMMAND] | ppc->spu.regs[SPU4XX_TX_COMMAND]) & 0x80; if (enabled) { attotime clockperiod = ATTOTIME_IN_HZ((ppc->dcr[DCR4XX_IOCR] & 0x02) ? 3686400 : 33333333); int divisor = ((ppc->spu.regs[SPU4XX_BAUD_DIVISOR_H] * 256 + ppc->spu.regs[SPU4XX_BAUD_DIVISOR_L]) & 0xfff) + 1; int bpc = 7 + ((ppc->spu.regs[SPU4XX_CONTROL] & 8) >> 3) + 1 + (ppc->spu.regs[SPU4XX_CONTROL] & 1); attotime charperiod = attotime_mul(clockperiod, divisor * 16 * bpc); timer_adjust_periodic(ppc->spu.timer, charperiod, 0, charperiod); if (PRINTF_SPU) printf("ppc4xx_spu_timer_reset: baud rate = %.0f\n", ATTOSECONDS_TO_HZ(charperiod.attoseconds) * bpc); } else timer_adjust_oneshot(ppc->spu.timer, attotime_never, 0); }
[ "static", "void", "ppc4xx_spu_timer_reset", "(", "powerpc_state", "*", "ppc", ")", "{", "UINT8", "enabled", "=", "(", "ppc", "->", "spu", ".", "regs", "[", "SPU4XX_RX_COMMAND", "]", "|", "ppc", "->", "spu", ".", "regs", "[", "SPU4XX_TX_COMMAND", "]", ")", "&", "0x80", ";", "if", "(", "enabled", ")", "{", "attotime", "clockperiod", "=", "ATTOTIME_IN_HZ", "(", "(", "ppc", "->", "dcr", "[", "DCR4XX_IOCR", "]", "&", "0x02", ")", "?", "3686400", ":", "33333333", ")", ";", "int", "divisor", "=", "(", "(", "ppc", "->", "spu", ".", "regs", "[", "SPU4XX_BAUD_DIVISOR_H", "]", "*", "256", "+", "ppc", "->", "spu", ".", "regs", "[", "SPU4XX_BAUD_DIVISOR_L", "]", ")", "&", "0xfff", ")", "+", "1", ";", "int", "bpc", "=", "7", "+", "(", "(", "ppc", "->", "spu", ".", "regs", "[", "SPU4XX_CONTROL", "]", "&", "8", ")", ">>", "3", ")", "+", "1", "+", "(", "ppc", "->", "spu", ".", "regs", "[", "SPU4XX_CONTROL", "]", "&", "1", ")", ";", "attotime", "charperiod", "=", "attotime_mul", "(", "clockperiod", ",", "divisor", "*", "16", "*", "bpc", ")", ";", "timer_adjust_periodic", "(", "ppc", "->", "spu", ".", "timer", ",", "charperiod", ",", "0", ",", "charperiod", ")", ";", "if", "(", "PRINTF_SPU", ")", "printf", "(", "\"", "\\n", "\"", ",", "ATTOSECONDS_TO_HZ", "(", "charperiod", ".", "attoseconds", ")", "*", "bpc", ")", ";", "}", "else", "timer_adjust_oneshot", "(", "ppc", "->", "spu", ".", "timer", ",", "attotime_never", ",", "0", ")", ";", "}" ]
ppc4xx_spu_timer_reset - reset and recompute the transmit/receive timer
[ "ppc4xx_spu_timer_reset", "-", "reset", "and", "recompute", "the", "transmit", "/", "receive", "timer" ]
[ "/* if we're enabled, reset at the current baud rate */", "/* otherwise, disable the timer */" ]
[ { "param": "ppc", "type": "powerpc_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ppc", "type": "powerpc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9fb9c5cf4c3689ffe2d2bb3bbbdf91d2f0ecaf01
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/powerpc/ppccom.c
[ "Unlicense" ]
C
ppc4xx_spu_receive_byte
void
void ppc4xx_spu_receive_byte(const device_config *device, UINT8 byteval) { powerpc_state *ppc = *(powerpc_state **)device->token; ppc4xx_spu_rx_data(ppc, byteval); }
/*------------------------------------------------- ppc4xx_spu_receive_byte - PowerPC 4XX- specific serial byte receive -------------------------------------------------*/
PowerPC 4XX specific serial byte receive
[ "PowerPC", "4XX", "specific", "serial", "byte", "receive" ]
void ppc4xx_spu_receive_byte(const device_config *device, UINT8 byteval) { powerpc_state *ppc = *(powerpc_state **)device->token; ppc4xx_spu_rx_data(ppc, byteval); }
[ "void", "ppc4xx_spu_receive_byte", "(", "const", "device_config", "*", "device", ",", "UINT8", "byteval", ")", "{", "powerpc_state", "*", "ppc", "=", "*", "(", "powerpc_state", "*", "*", ")", "device", "->", "token", ";", "ppc4xx_spu_rx_data", "(", "ppc", ",", "byteval", ")", ";", "}" ]
ppc4xx_spu_receive_byte - PowerPC 4XX specific serial byte receive
[ "ppc4xx_spu_receive_byte", "-", "PowerPC", "4XX", "specific", "serial", "byte", "receive" ]
[]
[ { "param": "device", "type": "device_config" }, { "param": "byteval", "type": "UINT8" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "device", "type": "device_config", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "byteval", "type": "UINT8", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9fb9c5cf4c3689ffe2d2bb3bbbdf91d2f0ecaf01
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/powerpc/ppccom.c
[ "Unlicense" ]
C
ppc4xx_set_info
void
void ppc4xx_set_info(powerpc_state *ppc, UINT32 state, cpuinfo *info) { switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case CPUINFO_INT_INPUT_STATE + PPC_IRQ_LINE_0: ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_EXT0, info->i); break; case CPUINFO_INT_INPUT_STATE + PPC_IRQ_LINE_1: ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_EXT1, info->i); break; case CPUINFO_INT_INPUT_STATE + PPC_IRQ_LINE_2: ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_EXT2, info->i); break; case CPUINFO_INT_INPUT_STATE + PPC_IRQ_LINE_3: ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_EXT3, info->i); break; case CPUINFO_INT_INPUT_STATE + PPC_IRQ_LINE_4: ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_EXT4, info->i); break; /* --- everything else is handled generically --- */ default: ppccom_set_info(ppc, state, info); break; } }
/*------------------------------------------------- ppc4xx_set_info - PowerPC 4XX-specific information setter -------------------------------------------------*/
PowerPC 4XX-specific information setter
[ "PowerPC", "4XX", "-", "specific", "information", "setter" ]
void ppc4xx_set_info(powerpc_state *ppc, UINT32 state, cpuinfo *info) { switch (state) { case CPUINFO_INT_INPUT_STATE + PPC_IRQ_LINE_0: ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_EXT0, info->i); break; case CPUINFO_INT_INPUT_STATE + PPC_IRQ_LINE_1: ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_EXT1, info->i); break; case CPUINFO_INT_INPUT_STATE + PPC_IRQ_LINE_2: ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_EXT2, info->i); break; case CPUINFO_INT_INPUT_STATE + PPC_IRQ_LINE_3: ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_EXT3, info->i); break; case CPUINFO_INT_INPUT_STATE + PPC_IRQ_LINE_4: ppc4xx_set_irq_line(ppc, PPC4XX_IRQ_BIT_EXT4, info->i); break; default: ppccom_set_info(ppc, state, info); break; } }
[ "void", "ppc4xx_set_info", "(", "powerpc_state", "*", "ppc", ",", "UINT32", "state", ",", "cpuinfo", "*", "info", ")", "{", "switch", "(", "state", ")", "{", "case", "CPUINFO_INT_INPUT_STATE", "+", "PPC_IRQ_LINE_0", ":", "ppc4xx_set_irq_line", "(", "ppc", ",", "PPC4XX_IRQ_BIT_EXT0", ",", "info", "->", "i", ")", ";", "break", ";", "case", "CPUINFO_INT_INPUT_STATE", "+", "PPC_IRQ_LINE_1", ":", "ppc4xx_set_irq_line", "(", "ppc", ",", "PPC4XX_IRQ_BIT_EXT1", ",", "info", "->", "i", ")", ";", "break", ";", "case", "CPUINFO_INT_INPUT_STATE", "+", "PPC_IRQ_LINE_2", ":", "ppc4xx_set_irq_line", "(", "ppc", ",", "PPC4XX_IRQ_BIT_EXT2", ",", "info", "->", "i", ")", ";", "break", ";", "case", "CPUINFO_INT_INPUT_STATE", "+", "PPC_IRQ_LINE_3", ":", "ppc4xx_set_irq_line", "(", "ppc", ",", "PPC4XX_IRQ_BIT_EXT3", ",", "info", "->", "i", ")", ";", "break", ";", "case", "CPUINFO_INT_INPUT_STATE", "+", "PPC_IRQ_LINE_4", ":", "ppc4xx_set_irq_line", "(", "ppc", ",", "PPC4XX_IRQ_BIT_EXT4", ",", "info", "->", "i", ")", ";", "break", ";", "default", ":", "ppccom_set_info", "(", "ppc", ",", "state", ",", "info", ")", ";", "break", ";", "}", "}" ]
ppc4xx_set_info - PowerPC 4XX-specific information setter
[ "ppc4xx_set_info", "-", "PowerPC", "4XX", "-", "specific", "information", "setter" ]
[ "/* --- the following bits of info are returned as 64-bit signed integers --- */", "/* --- everything else is handled generically --- */" ]
[ { "param": "ppc", "type": "powerpc_state" }, { "param": "state", "type": "UINT32" }, { "param": "info", "type": "cpuinfo" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ppc", "type": "powerpc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "state", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "info", "type": "cpuinfo", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9fb9c5cf4c3689ffe2d2bb3bbbdf91d2f0ecaf01
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/cpu/powerpc/ppccom.c
[ "Unlicense" ]
C
ppc4xx_get_info
void
void ppc4xx_get_info(powerpc_state *ppc, UINT32 state, cpuinfo *info) { switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case CPUINFO_INT_INPUT_LINES: info->i = 5; break; case CPUINFO_INT_INPUT_STATE + PPC_IRQ_LINE_0: info->i = ppc4xx_get_irq_line(ppc, PPC4XX_IRQ_BIT_EXT0); break; case CPUINFO_INT_INPUT_STATE + PPC_IRQ_LINE_1: info->i = ppc4xx_get_irq_line(ppc, PPC4XX_IRQ_BIT_EXT1); break; case CPUINFO_INT_INPUT_STATE + PPC_IRQ_LINE_2: info->i = ppc4xx_get_irq_line(ppc, PPC4XX_IRQ_BIT_EXT2); break; case CPUINFO_INT_INPUT_STATE + PPC_IRQ_LINE_3: info->i = ppc4xx_get_irq_line(ppc, PPC4XX_IRQ_BIT_EXT3); break; case CPUINFO_INT_INPUT_STATE + PPC_IRQ_LINE_4: info->i = ppc4xx_get_irq_line(ppc, PPC4XX_IRQ_BIT_EXT4); break; case CPUINFO_INT_DATABUS_WIDTH_PROGRAM: info->i = 32; break; case CPUINFO_INT_ADDRBUS_WIDTH_PROGRAM: info->i = 31; break; case CPUINFO_INT_LOGADDR_WIDTH_PROGRAM: info->i = 32; break; case CPUINFO_INT_PAGE_SHIFT_PROGRAM: info->i = POWERPC_MIN_PAGE_SHIFT;break; /* --- the following bits of info are returned as pointers to data or functions --- */ case CPUINFO_FCT_INIT: /* provided per-CPU */ break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM: info->internal_map32 = ADDRESS_MAP_NAME(internal_ppc4xx); break; /* --- everything else is handled generically --- */ default: ppccom_get_info(ppc, state, info); break; } }
/*------------------------------------------------- ppc4xx_get_info - PowerPC 4XX-specific information getter -------------------------------------------------*/
PowerPC 4XX-specific information getter
[ "PowerPC", "4XX", "-", "specific", "information", "getter" ]
void ppc4xx_get_info(powerpc_state *ppc, UINT32 state, cpuinfo *info) { switch (state) { case CPUINFO_INT_INPUT_LINES: info->i = 5; break; case CPUINFO_INT_INPUT_STATE + PPC_IRQ_LINE_0: info->i = ppc4xx_get_irq_line(ppc, PPC4XX_IRQ_BIT_EXT0); break; case CPUINFO_INT_INPUT_STATE + PPC_IRQ_LINE_1: info->i = ppc4xx_get_irq_line(ppc, PPC4XX_IRQ_BIT_EXT1); break; case CPUINFO_INT_INPUT_STATE + PPC_IRQ_LINE_2: info->i = ppc4xx_get_irq_line(ppc, PPC4XX_IRQ_BIT_EXT2); break; case CPUINFO_INT_INPUT_STATE + PPC_IRQ_LINE_3: info->i = ppc4xx_get_irq_line(ppc, PPC4XX_IRQ_BIT_EXT3); break; case CPUINFO_INT_INPUT_STATE + PPC_IRQ_LINE_4: info->i = ppc4xx_get_irq_line(ppc, PPC4XX_IRQ_BIT_EXT4); break; case CPUINFO_INT_DATABUS_WIDTH_PROGRAM: info->i = 32; break; case CPUINFO_INT_ADDRBUS_WIDTH_PROGRAM: info->i = 31; break; case CPUINFO_INT_LOGADDR_WIDTH_PROGRAM: info->i = 32; break; case CPUINFO_INT_PAGE_SHIFT_PROGRAM: info->i = POWERPC_MIN_PAGE_SHIFT;break; case CPUINFO_FCT_INIT: break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM: info->internal_map32 = ADDRESS_MAP_NAME(internal_ppc4xx); break; default: ppccom_get_info(ppc, state, info); break; } }
[ "void", "ppc4xx_get_info", "(", "powerpc_state", "*", "ppc", ",", "UINT32", "state", ",", "cpuinfo", "*", "info", ")", "{", "switch", "(", "state", ")", "{", "case", "CPUINFO_INT_INPUT_LINES", ":", "info", "->", "i", "=", "5", ";", "break", ";", "case", "CPUINFO_INT_INPUT_STATE", "+", "PPC_IRQ_LINE_0", ":", "info", "->", "i", "=", "ppc4xx_get_irq_line", "(", "ppc", ",", "PPC4XX_IRQ_BIT_EXT0", ")", ";", "break", ";", "case", "CPUINFO_INT_INPUT_STATE", "+", "PPC_IRQ_LINE_1", ":", "info", "->", "i", "=", "ppc4xx_get_irq_line", "(", "ppc", ",", "PPC4XX_IRQ_BIT_EXT1", ")", ";", "break", ";", "case", "CPUINFO_INT_INPUT_STATE", "+", "PPC_IRQ_LINE_2", ":", "info", "->", "i", "=", "ppc4xx_get_irq_line", "(", "ppc", ",", "PPC4XX_IRQ_BIT_EXT2", ")", ";", "break", ";", "case", "CPUINFO_INT_INPUT_STATE", "+", "PPC_IRQ_LINE_3", ":", "info", "->", "i", "=", "ppc4xx_get_irq_line", "(", "ppc", ",", "PPC4XX_IRQ_BIT_EXT3", ")", ";", "break", ";", "case", "CPUINFO_INT_INPUT_STATE", "+", "PPC_IRQ_LINE_4", ":", "info", "->", "i", "=", "ppc4xx_get_irq_line", "(", "ppc", ",", "PPC4XX_IRQ_BIT_EXT4", ")", ";", "break", ";", "case", "CPUINFO_INT_DATABUS_WIDTH_PROGRAM", ":", "info", "->", "i", "=", "32", ";", "break", ";", "case", "CPUINFO_INT_ADDRBUS_WIDTH_PROGRAM", ":", "info", "->", "i", "=", "31", ";", "break", ";", "case", "CPUINFO_INT_LOGADDR_WIDTH_PROGRAM", ":", "info", "->", "i", "=", "32", ";", "break", ";", "case", "CPUINFO_INT_PAGE_SHIFT_PROGRAM", ":", "info", "->", "i", "=", "POWERPC_MIN_PAGE_SHIFT", ";", "break", ";", "case", "CPUINFO_FCT_INIT", ":", "break", ";", "case", "CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM", ":", "info", "->", "internal_map32", "=", "ADDRESS_MAP_NAME", "(", "internal_ppc4xx", ")", ";", "break", ";", "default", ":", "ppccom_get_info", "(", "ppc", ",", "state", ",", "info", ")", ";", "break", ";", "}", "}" ]
ppc4xx_get_info - PowerPC 4XX-specific information getter
[ "ppc4xx_get_info", "-", "PowerPC", "4XX", "-", "specific", "information", "getter" ]
[ "/* --- the following bits of info are returned as 64-bit signed integers --- */", "/* --- the following bits of info are returned as pointers to data or functions --- */", "/* provided per-CPU */", "/* --- everything else is handled generically --- */" ]
[ { "param": "ppc", "type": "powerpc_state" }, { "param": "state", "type": "UINT32" }, { "param": "info", "type": "cpuinfo" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ppc", "type": "powerpc_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "state", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "info", "type": "cpuinfo", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6d46061b83a59b43377b91ebecc851376bb984da
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/video/poly.c
[ "Unlicense" ]
C
poly_wait
void
void poly_wait(poly_manager *poly, const char *debug_reason) { osd_ticks_t time; /* remember the start time if we're logging */ if (LOG_WAITS) time = get_profile_ticks(); /* wait for all pending work items to complete */ if (poly->queue != NULL) osd_work_queue_wait(poly->queue, osd_ticks_per_second() * 100); /* if we don't have a queue, just run the whole list now */ else { int unitnum; for (unitnum = 0; unitnum < poly->unit_next; unitnum++) poly_item_callback(poly->unit[unitnum], 0); } /* log any long waits */ if (LOG_WAITS) { time = get_profile_ticks() - time; if (time > LOG_WAIT_THRESHOLD) logerror("Poly:Waited %d cycles for %s\n", (int)time, debug_reason); } /* reset the state */ poly->polygon_next = poly->unit_next = 0; memset(poly->unit_bucket, 0xff, sizeof(poly->unit_bucket)); /* we need to preserve the last extra data that was supplied */ if (poly->extra_next > 1) memcpy(poly->extra[0], poly->extra[poly->extra_next - 1], poly->extra_size); poly->extra_next = 1; }
/*------------------------------------------------- poly_wait - wait for all pending rendering to complete -------------------------------------------------*/
wait for all pending rendering to complete
[ "wait", "for", "all", "pending", "rendering", "to", "complete" ]
void poly_wait(poly_manager *poly, const char *debug_reason) { osd_ticks_t time; if (LOG_WAITS) time = get_profile_ticks(); if (poly->queue != NULL) osd_work_queue_wait(poly->queue, osd_ticks_per_second() * 100); else { int unitnum; for (unitnum = 0; unitnum < poly->unit_next; unitnum++) poly_item_callback(poly->unit[unitnum], 0); } if (LOG_WAITS) { time = get_profile_ticks() - time; if (time > LOG_WAIT_THRESHOLD) logerror("Poly:Waited %d cycles for %s\n", (int)time, debug_reason); } poly->polygon_next = poly->unit_next = 0; memset(poly->unit_bucket, 0xff, sizeof(poly->unit_bucket)); if (poly->extra_next > 1) memcpy(poly->extra[0], poly->extra[poly->extra_next - 1], poly->extra_size); poly->extra_next = 1; }
[ "void", "poly_wait", "(", "poly_manager", "*", "poly", ",", "const", "char", "*", "debug_reason", ")", "{", "osd_ticks_t", "time", ";", "if", "(", "LOG_WAITS", ")", "time", "=", "get_profile_ticks", "(", ")", ";", "if", "(", "poly", "->", "queue", "!=", "NULL", ")", "osd_work_queue_wait", "(", "poly", "->", "queue", ",", "osd_ticks_per_second", "(", ")", "*", "100", ")", ";", "else", "{", "int", "unitnum", ";", "for", "(", "unitnum", "=", "0", ";", "unitnum", "<", "poly", "->", "unit_next", ";", "unitnum", "++", ")", "poly_item_callback", "(", "poly", "->", "unit", "[", "unitnum", "]", ",", "0", ")", ";", "}", "if", "(", "LOG_WAITS", ")", "{", "time", "=", "get_profile_ticks", "(", ")", "-", "time", ";", "if", "(", "time", ">", "LOG_WAIT_THRESHOLD", ")", "logerror", "(", "\"", "\\n", "\"", ",", "(", "int", ")", "time", ",", "debug_reason", ")", ";", "}", "poly", "->", "polygon_next", "=", "poly", "->", "unit_next", "=", "0", ";", "memset", "(", "poly", "->", "unit_bucket", ",", "0xff", ",", "sizeof", "(", "poly", "->", "unit_bucket", ")", ")", ";", "if", "(", "poly", "->", "extra_next", ">", "1", ")", "memcpy", "(", "poly", "->", "extra", "[", "0", "]", ",", "poly", "->", "extra", "[", "poly", "->", "extra_next", "-", "1", "]", ",", "poly", "->", "extra_size", ")", ";", "poly", "->", "extra_next", "=", "1", ";", "}" ]
poly_wait - wait for all pending rendering to complete
[ "poly_wait", "-", "wait", "for", "all", "pending", "rendering", "to", "complete" ]
[ "/* remember the start time if we're logging */", "/* wait for all pending work items to complete */", "/* if we don't have a queue, just run the whole list now */", "/* log any long waits */", "/* reset the state */", "/* we need to preserve the last extra data that was supplied */" ]
[ { "param": "poly", "type": "poly_manager" }, { "param": "debug_reason", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "poly", "type": "poly_manager", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "debug_reason", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6d46061b83a59b43377b91ebecc851376bb984da
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/video/poly.c
[ "Unlicense" ]
C
poly_get_extra_data
void
void *poly_get_extra_data(poly_manager *poly) { /* wait for a work item if we have to */ if (poly->extra_next + 1 > poly->extra_count) { poly_wait(poly, "Out of extra data"); #if KEEP_STATISTICS poly->extra_waits++; #endif } /* return a pointer to the extra data for the next item */ #if KEEP_STATISTICS poly->extra_max = MAX(poly->extra_max, poly->extra_next + 1); #endif return poly->extra[poly->extra_next++]; }
/*------------------------------------------------- poly_get_extra_data - get a pointer to the extra data for the next polygon -------------------------------------------------*/
get a pointer to the extra data for the next polygon
[ "get", "a", "pointer", "to", "the", "extra", "data", "for", "the", "next", "polygon" ]
void *poly_get_extra_data(poly_manager *poly) { if (poly->extra_next + 1 > poly->extra_count) { poly_wait(poly, "Out of extra data"); #if KEEP_STATISTICS poly->extra_waits++; #endif } #if KEEP_STATISTICS poly->extra_max = MAX(poly->extra_max, poly->extra_next + 1); #endif return poly->extra[poly->extra_next++]; }
[ "void", "*", "poly_get_extra_data", "(", "poly_manager", "*", "poly", ")", "{", "if", "(", "poly", "->", "extra_next", "+", "1", ">", "poly", "->", "extra_count", ")", "{", "poly_wait", "(", "poly", ",", "\"", "\"", ")", ";", "#if", "KEEP_STATISTICS", "\n", "poly", "->", "extra_waits", "++", ";", "#endif", "}", "#if", "KEEP_STATISTICS", "\n", "poly", "->", "extra_max", "=", "MAX", "(", "poly", "->", "extra_max", ",", "poly", "->", "extra_next", "+", "1", ")", ";", "#endif", "return", "poly", "->", "extra", "[", "poly", "->", "extra_next", "++", "]", ";", "}" ]
poly_get_extra_data - get a pointer to the extra data for the next polygon
[ "poly_get_extra_data", "-", "get", "a", "pointer", "to", "the", "extra", "data", "for", "the", "next", "polygon" ]
[ "/* wait for a work item if we have to */", "/* return a pointer to the extra data for the next item */" ]
[ { "param": "poly", "type": "poly_manager" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "poly", "type": "poly_manager", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6d46061b83a59b43377b91ebecc851376bb984da
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/video/poly.c
[ "Unlicense" ]
C
poly_render_triangle_fan
UINT32
UINT32 poly_render_triangle_fan(poly_manager *poly, void *dest, const rectangle *cliprect, poly_draw_scanline_func callback, int paramcount, int numverts, const poly_vertex *v) { UINT32 pixels = 0; int vertnum; /* iterate over vertices */ for (vertnum = 2; vertnum < numverts; vertnum++) pixels += poly_render_triangle(poly, dest, cliprect, callback, paramcount, &v[0], &v[vertnum - 1], &v[vertnum]); return pixels; }
/*------------------------------------------------- poly_render_triangle_fan - render a set of triangles in a fan -------------------------------------------------*/
render a set of triangles in a fan
[ "render", "a", "set", "of", "triangles", "in", "a", "fan" ]
UINT32 poly_render_triangle_fan(poly_manager *poly, void *dest, const rectangle *cliprect, poly_draw_scanline_func callback, int paramcount, int numverts, const poly_vertex *v) { UINT32 pixels = 0; int vertnum; for (vertnum = 2; vertnum < numverts; vertnum++) pixels += poly_render_triangle(poly, dest, cliprect, callback, paramcount, &v[0], &v[vertnum - 1], &v[vertnum]); return pixels; }
[ "UINT32", "poly_render_triangle_fan", "(", "poly_manager", "*", "poly", ",", "void", "*", "dest", ",", "const", "rectangle", "*", "cliprect", ",", "poly_draw_scanline_func", "callback", ",", "int", "paramcount", ",", "int", "numverts", ",", "const", "poly_vertex", "*", "v", ")", "{", "UINT32", "pixels", "=", "0", ";", "int", "vertnum", ";", "for", "(", "vertnum", "=", "2", ";", "vertnum", "<", "numverts", ";", "vertnum", "++", ")", "pixels", "+=", "poly_render_triangle", "(", "poly", ",", "dest", ",", "cliprect", ",", "callback", ",", "paramcount", ",", "&", "v", "[", "0", "]", ",", "&", "v", "[", "vertnum", "-", "1", "]", ",", "&", "v", "[", "vertnum", "]", ")", ";", "return", "pixels", ";", "}" ]
poly_render_triangle_fan - render a set of triangles in a fan
[ "poly_render_triangle_fan", "-", "render", "a", "set", "of", "triangles", "in", "a", "fan" ]
[ "/* iterate over vertices */" ]
[ { "param": "poly", "type": "poly_manager" }, { "param": "dest", "type": "void" }, { "param": "cliprect", "type": "rectangle" }, { "param": "callback", "type": "poly_draw_scanline_func" }, { "param": "paramcount", "type": "int" }, { "param": "numverts", "type": "int" }, { "param": "v", "type": "poly_vertex" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "poly", "type": "poly_manager", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dest", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cliprect", "type": "rectangle", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "callback", "type": "poly_draw_scanline_func", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "paramcount", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "numverts", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "v", "type": "poly_vertex", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6d46061b83a59b43377b91ebecc851376bb984da
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/video/poly.c
[ "Unlicense" ]
C
poly_render_triangle_custom
UINT32
UINT32 poly_render_triangle_custom(poly_manager *poly, void *dest, const rectangle *cliprect, poly_draw_scanline_func callback, int startscanline, int numscanlines, const poly_extent *extents) { INT32 curscan, scaninc; polygon_info *polygon; INT32 v1yclip, v3yclip; INT32 pixels = 0; UINT32 startunit; /* clip coordinates */ if (cliprect != NULL) { v1yclip = MAX(startscanline, cliprect->min_y); v3yclip = MIN(startscanline + numscanlines, cliprect->max_y + 1); } else { v1yclip = startscanline; v3yclip = startscanline + numscanlines; } if (v3yclip - v1yclip <= 0) return 0; /* allocate a new polygon */ polygon = allocate_polygon(poly, v1yclip, v3yclip); /* fill in the polygon information */ polygon->poly = poly; polygon->dest = dest; polygon->callback = callback; polygon->extra = poly->extra[poly->extra_next - 1]; polygon->numparams = 0; polygon->numverts = 3; /* compute the X extents for each scanline */ startunit = poly->unit_next; for (curscan = v1yclip; curscan < v3yclip; curscan += scaninc) { UINT32 bucketnum = ((UINT32)curscan / SCANLINES_PER_BUCKET) % TOTAL_BUCKETS; UINT32 unit_index = poly->unit_next++; tri_work_unit *unit = &poly->unit[unit_index]->tri; int extnum; /* determine how much to advance to hit the next bucket */ scaninc = SCANLINES_PER_BUCKET - (UINT32)curscan % SCANLINES_PER_BUCKET; /* fill in the work unit basics */ unit->shared.polygon = polygon; unit->shared.count_next = MIN(v3yclip - curscan, scaninc); unit->shared.scanline = curscan; unit->shared.previtem = poly->unit_bucket[bucketnum]; poly->unit_bucket[bucketnum] = unit_index; /* iterate over extents */ for (extnum = 0; extnum < unit->shared.count_next; extnum++) { const poly_extent *extent = &extents[(curscan + extnum) - startscanline]; INT32 istartx = extent->startx, istopx = extent->stopx; /* force start < stop */ if (istartx > istopx) { INT32 temp = istartx; istartx = istopx; istopx = temp; } /* apply left/right clipping */ if (cliprect != NULL) { if (istartx < cliprect->min_x) istartx = cliprect->min_x; if (istopx > cliprect->max_x) istopx = cliprect->max_x + 1; } /* set the extent and update the total pixel count */ unit->extent[extnum].startx = istartx; unit->extent[extnum].stopx = istopx; if (istartx < istopx) pixels += istopx - istartx; } } #if KEEP_STATISTICS poly->unit_max = MAX(poly->unit_max, poly->unit_next); #endif /* enqueue the work items */ if (poly->queue != NULL) osd_work_item_queue_multiple(poly->queue, poly_item_callback, poly->unit_next - startunit, poly->unit[startunit], poly->unit_size, WORK_ITEM_FLAG_AUTO_RELEASE); /* return the total number of pixels in the object */ poly->triangles++; poly->pixels += pixels; return pixels; }
/*------------------------------------------------- poly_render_triangle_custom - perform a custom render of an object, given specific extents -------------------------------------------------*/
perform a custom render of an object, given specific extents
[ "perform", "a", "custom", "render", "of", "an", "object", "given", "specific", "extents" ]
UINT32 poly_render_triangle_custom(poly_manager *poly, void *dest, const rectangle *cliprect, poly_draw_scanline_func callback, int startscanline, int numscanlines, const poly_extent *extents) { INT32 curscan, scaninc; polygon_info *polygon; INT32 v1yclip, v3yclip; INT32 pixels = 0; UINT32 startunit; if (cliprect != NULL) { v1yclip = MAX(startscanline, cliprect->min_y); v3yclip = MIN(startscanline + numscanlines, cliprect->max_y + 1); } else { v1yclip = startscanline; v3yclip = startscanline + numscanlines; } if (v3yclip - v1yclip <= 0) return 0; polygon = allocate_polygon(poly, v1yclip, v3yclip); polygon->poly = poly; polygon->dest = dest; polygon->callback = callback; polygon->extra = poly->extra[poly->extra_next - 1]; polygon->numparams = 0; polygon->numverts = 3; startunit = poly->unit_next; for (curscan = v1yclip; curscan < v3yclip; curscan += scaninc) { UINT32 bucketnum = ((UINT32)curscan / SCANLINES_PER_BUCKET) % TOTAL_BUCKETS; UINT32 unit_index = poly->unit_next++; tri_work_unit *unit = &poly->unit[unit_index]->tri; int extnum; scaninc = SCANLINES_PER_BUCKET - (UINT32)curscan % SCANLINES_PER_BUCKET; unit->shared.polygon = polygon; unit->shared.count_next = MIN(v3yclip - curscan, scaninc); unit->shared.scanline = curscan; unit->shared.previtem = poly->unit_bucket[bucketnum]; poly->unit_bucket[bucketnum] = unit_index; for (extnum = 0; extnum < unit->shared.count_next; extnum++) { const poly_extent *extent = &extents[(curscan + extnum) - startscanline]; INT32 istartx = extent->startx, istopx = extent->stopx; if (istartx > istopx) { INT32 temp = istartx; istartx = istopx; istopx = temp; } if (cliprect != NULL) { if (istartx < cliprect->min_x) istartx = cliprect->min_x; if (istopx > cliprect->max_x) istopx = cliprect->max_x + 1; } unit->extent[extnum].startx = istartx; unit->extent[extnum].stopx = istopx; if (istartx < istopx) pixels += istopx - istartx; } } #if KEEP_STATISTICS poly->unit_max = MAX(poly->unit_max, poly->unit_next); #endif if (poly->queue != NULL) osd_work_item_queue_multiple(poly->queue, poly_item_callback, poly->unit_next - startunit, poly->unit[startunit], poly->unit_size, WORK_ITEM_FLAG_AUTO_RELEASE); poly->triangles++; poly->pixels += pixels; return pixels; }
[ "UINT32", "poly_render_triangle_custom", "(", "poly_manager", "*", "poly", ",", "void", "*", "dest", ",", "const", "rectangle", "*", "cliprect", ",", "poly_draw_scanline_func", "callback", ",", "int", "startscanline", ",", "int", "numscanlines", ",", "const", "poly_extent", "*", "extents", ")", "{", "INT32", "curscan", ",", "scaninc", ";", "polygon_info", "*", "polygon", ";", "INT32", "v1yclip", ",", "v3yclip", ";", "INT32", "pixels", "=", "0", ";", "UINT32", "startunit", ";", "if", "(", "cliprect", "!=", "NULL", ")", "{", "v1yclip", "=", "MAX", "(", "startscanline", ",", "cliprect", "->", "min_y", ")", ";", "v3yclip", "=", "MIN", "(", "startscanline", "+", "numscanlines", ",", "cliprect", "->", "max_y", "+", "1", ")", ";", "}", "else", "{", "v1yclip", "=", "startscanline", ";", "v3yclip", "=", "startscanline", "+", "numscanlines", ";", "}", "if", "(", "v3yclip", "-", "v1yclip", "<=", "0", ")", "return", "0", ";", "polygon", "=", "allocate_polygon", "(", "poly", ",", "v1yclip", ",", "v3yclip", ")", ";", "polygon", "->", "poly", "=", "poly", ";", "polygon", "->", "dest", "=", "dest", ";", "polygon", "->", "callback", "=", "callback", ";", "polygon", "->", "extra", "=", "poly", "->", "extra", "[", "poly", "->", "extra_next", "-", "1", "]", ";", "polygon", "->", "numparams", "=", "0", ";", "polygon", "->", "numverts", "=", "3", ";", "startunit", "=", "poly", "->", "unit_next", ";", "for", "(", "curscan", "=", "v1yclip", ";", "curscan", "<", "v3yclip", ";", "curscan", "+=", "scaninc", ")", "{", "UINT32", "bucketnum", "=", "(", "(", "UINT32", ")", "curscan", "/", "SCANLINES_PER_BUCKET", ")", "%", "TOTAL_BUCKETS", ";", "UINT32", "unit_index", "=", "poly", "->", "unit_next", "++", ";", "tri_work_unit", "*", "unit", "=", "&", "poly", "->", "unit", "[", "unit_index", "]", "->", "tri", ";", "int", "extnum", ";", "scaninc", "=", "SCANLINES_PER_BUCKET", "-", "(", "UINT32", ")", "curscan", "%", "SCANLINES_PER_BUCKET", ";", "unit", "->", "shared", ".", "polygon", "=", "polygon", ";", "unit", "->", "shared", ".", "count_next", "=", "MIN", "(", "v3yclip", "-", "curscan", ",", "scaninc", ")", ";", "unit", "->", "shared", ".", "scanline", "=", "curscan", ";", "unit", "->", "shared", ".", "previtem", "=", "poly", "->", "unit_bucket", "[", "bucketnum", "]", ";", "poly", "->", "unit_bucket", "[", "bucketnum", "]", "=", "unit_index", ";", "for", "(", "extnum", "=", "0", ";", "extnum", "<", "unit", "->", "shared", ".", "count_next", ";", "extnum", "++", ")", "{", "const", "poly_extent", "*", "extent", "=", "&", "extents", "[", "(", "curscan", "+", "extnum", ")", "-", "startscanline", "]", ";", "INT32", "istartx", "=", "extent", "->", "startx", ",", "istopx", "=", "extent", "->", "stopx", ";", "if", "(", "istartx", ">", "istopx", ")", "{", "INT32", "temp", "=", "istartx", ";", "istartx", "=", "istopx", ";", "istopx", "=", "temp", ";", "}", "if", "(", "cliprect", "!=", "NULL", ")", "{", "if", "(", "istartx", "<", "cliprect", "->", "min_x", ")", "istartx", "=", "cliprect", "->", "min_x", ";", "if", "(", "istopx", ">", "cliprect", "->", "max_x", ")", "istopx", "=", "cliprect", "->", "max_x", "+", "1", ";", "}", "unit", "->", "extent", "[", "extnum", "]", ".", "startx", "=", "istartx", ";", "unit", "->", "extent", "[", "extnum", "]", ".", "stopx", "=", "istopx", ";", "if", "(", "istartx", "<", "istopx", ")", "pixels", "+=", "istopx", "-", "istartx", ";", "}", "}", "#if", "KEEP_STATISTICS", "\n", "poly", "->", "unit_max", "=", "MAX", "(", "poly", "->", "unit_max", ",", "poly", "->", "unit_next", ")", ";", "#endif", "if", "(", "poly", "->", "queue", "!=", "NULL", ")", "osd_work_item_queue_multiple", "(", "poly", "->", "queue", ",", "poly_item_callback", ",", "poly", "->", "unit_next", "-", "startunit", ",", "poly", "->", "unit", "[", "startunit", "]", ",", "poly", "->", "unit_size", ",", "WORK_ITEM_FLAG_AUTO_RELEASE", ")", ";", "poly", "->", "triangles", "++", ";", "poly", "->", "pixels", "+=", "pixels", ";", "return", "pixels", ";", "}" ]
poly_render_triangle_custom - perform a custom render of an object, given specific extents
[ "poly_render_triangle_custom", "-", "perform", "a", "custom", "render", "of", "an", "object", "given", "specific", "extents" ]
[ "/* clip coordinates */", "/* allocate a new polygon */", "/* fill in the polygon information */", "/* compute the X extents for each scanline */", "/* determine how much to advance to hit the next bucket */", "/* fill in the work unit basics */", "/* iterate over extents */", "/* force start < stop */", "/* apply left/right clipping */", "/* set the extent and update the total pixel count */", "/* enqueue the work items */", "/* return the total number of pixels in the object */" ]
[ { "param": "poly", "type": "poly_manager" }, { "param": "dest", "type": "void" }, { "param": "cliprect", "type": "rectangle" }, { "param": "callback", "type": "poly_draw_scanline_func" }, { "param": "startscanline", "type": "int" }, { "param": "numscanlines", "type": "int" }, { "param": "extents", "type": "poly_extent" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "poly", "type": "poly_manager", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dest", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cliprect", "type": "rectangle", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "callback", "type": "poly_draw_scanline_func", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "startscanline", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "numscanlines", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "extents", "type": "poly_extent", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6d46061b83a59b43377b91ebecc851376bb984da
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/video/poly.c
[ "Unlicense" ]
C
poly_render_quad_fan
UINT32
UINT32 poly_render_quad_fan(poly_manager *poly, void *dest, const rectangle *cliprect, poly_draw_scanline_func callback, int paramcount, int numverts, const poly_vertex *v) { UINT32 pixels = 0; int vertnum; /* iterate over vertices */ for (vertnum = 2; vertnum < numverts; vertnum += 2) pixels += poly_render_quad(poly, dest, cliprect, callback, paramcount, &v[0], &v[vertnum - 1], &v[vertnum], &v[MIN(vertnum + 1, numverts - 1)]); return pixels; }
/*------------------------------------------------- poly_render_quad_fan - render a set of quads in a fan -------------------------------------------------*/
render a set of quads in a fan
[ "render", "a", "set", "of", "quads", "in", "a", "fan" ]
UINT32 poly_render_quad_fan(poly_manager *poly, void *dest, const rectangle *cliprect, poly_draw_scanline_func callback, int paramcount, int numverts, const poly_vertex *v) { UINT32 pixels = 0; int vertnum; for (vertnum = 2; vertnum < numverts; vertnum += 2) pixels += poly_render_quad(poly, dest, cliprect, callback, paramcount, &v[0], &v[vertnum - 1], &v[vertnum], &v[MIN(vertnum + 1, numverts - 1)]); return pixels; }
[ "UINT32", "poly_render_quad_fan", "(", "poly_manager", "*", "poly", ",", "void", "*", "dest", ",", "const", "rectangle", "*", "cliprect", ",", "poly_draw_scanline_func", "callback", ",", "int", "paramcount", ",", "int", "numverts", ",", "const", "poly_vertex", "*", "v", ")", "{", "UINT32", "pixels", "=", "0", ";", "int", "vertnum", ";", "for", "(", "vertnum", "=", "2", ";", "vertnum", "<", "numverts", ";", "vertnum", "+=", "2", ")", "pixels", "+=", "poly_render_quad", "(", "poly", ",", "dest", ",", "cliprect", ",", "callback", ",", "paramcount", ",", "&", "v", "[", "0", "]", ",", "&", "v", "[", "vertnum", "-", "1", "]", ",", "&", "v", "[", "vertnum", "]", ",", "&", "v", "[", "MIN", "(", "vertnum", "+", "1", ",", "numverts", "-", "1", ")", "]", ")", ";", "return", "pixels", ";", "}" ]
poly_render_quad_fan - render a set of quads in a fan
[ "poly_render_quad_fan", "-", "render", "a", "set", "of", "quads", "in", "a", "fan" ]
[ "/* iterate over vertices */" ]
[ { "param": "poly", "type": "poly_manager" }, { "param": "dest", "type": "void" }, { "param": "cliprect", "type": "rectangle" }, { "param": "callback", "type": "poly_draw_scanline_func" }, { "param": "paramcount", "type": "int" }, { "param": "numverts", "type": "int" }, { "param": "v", "type": "poly_vertex" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "poly", "type": "poly_manager", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dest", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cliprect", "type": "rectangle", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "callback", "type": "poly_draw_scanline_func", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "paramcount", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "numverts", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "v", "type": "poly_vertex", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6d46061b83a59b43377b91ebecc851376bb984da
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/emu/video/poly.c
[ "Unlicense" ]
C
poly_zclip_if_less
int
int poly_zclip_if_less(int numverts, const poly_vertex *v, poly_vertex *outv, int paramcount, float clipval) { int prevclipped = (v[numverts - 1].p[0] < clipval); poly_vertex *nextout = outv; int vertnum; /* iterate over vertices */ for (vertnum = 0; vertnum < numverts; vertnum++) { int thisclipped = (v[vertnum].p[0] < clipval); /* if we switched from clipped to non-clipped, interpolate a vertex */ if (thisclipped != prevclipped) interpolate_vertex(nextout++, &v[(vertnum == 0) ? (numverts - 1) : (vertnum - 1)], &v[vertnum], paramcount, clipval); /* if this vertex is not clipped, copy it in */ if (!thisclipped) copy_vertex(nextout++, &v[vertnum], paramcount); /* remember the last state */ prevclipped = thisclipped; } return nextout - outv; }
/*------------------------------------------------- poly_zclip_if_less - z clip a polygon against the given value, returning a set of clipped vertices -------------------------------------------------*/
z clip a polygon against the given value, returning a set of clipped vertices
[ "z", "clip", "a", "polygon", "against", "the", "given", "value", "returning", "a", "set", "of", "clipped", "vertices" ]
int poly_zclip_if_less(int numverts, const poly_vertex *v, poly_vertex *outv, int paramcount, float clipval) { int prevclipped = (v[numverts - 1].p[0] < clipval); poly_vertex *nextout = outv; int vertnum; for (vertnum = 0; vertnum < numverts; vertnum++) { int thisclipped = (v[vertnum].p[0] < clipval); if (thisclipped != prevclipped) interpolate_vertex(nextout++, &v[(vertnum == 0) ? (numverts - 1) : (vertnum - 1)], &v[vertnum], paramcount, clipval); if (!thisclipped) copy_vertex(nextout++, &v[vertnum], paramcount); prevclipped = thisclipped; } return nextout - outv; }
[ "int", "poly_zclip_if_less", "(", "int", "numverts", ",", "const", "poly_vertex", "*", "v", ",", "poly_vertex", "*", "outv", ",", "int", "paramcount", ",", "float", "clipval", ")", "{", "int", "prevclipped", "=", "(", "v", "[", "numverts", "-", "1", "]", ".", "p", "[", "0", "]", "<", "clipval", ")", ";", "poly_vertex", "*", "nextout", "=", "outv", ";", "int", "vertnum", ";", "for", "(", "vertnum", "=", "0", ";", "vertnum", "<", "numverts", ";", "vertnum", "++", ")", "{", "int", "thisclipped", "=", "(", "v", "[", "vertnum", "]", ".", "p", "[", "0", "]", "<", "clipval", ")", ";", "if", "(", "thisclipped", "!=", "prevclipped", ")", "interpolate_vertex", "(", "nextout", "++", ",", "&", "v", "[", "(", "vertnum", "==", "0", ")", "?", "(", "numverts", "-", "1", ")", ":", "(", "vertnum", "-", "1", ")", "]", ",", "&", "v", "[", "vertnum", "]", ",", "paramcount", ",", "clipval", ")", ";", "if", "(", "!", "thisclipped", ")", "copy_vertex", "(", "nextout", "++", ",", "&", "v", "[", "vertnum", "]", ",", "paramcount", ")", ";", "prevclipped", "=", "thisclipped", ";", "}", "return", "nextout", "-", "outv", ";", "}" ]
poly_zclip_if_less - z clip a polygon against the given value, returning a set of clipped vertices
[ "poly_zclip_if_less", "-", "z", "clip", "a", "polygon", "against", "the", "given", "value", "returning", "a", "set", "of", "clipped", "vertices" ]
[ "/* iterate over vertices */", "/* if we switched from clipped to non-clipped, interpolate a vertex */", "/* if this vertex is not clipped, copy it in */", "/* remember the last state */" ]
[ { "param": "numverts", "type": "int" }, { "param": "v", "type": "poly_vertex" }, { "param": "outv", "type": "poly_vertex" }, { "param": "paramcount", "type": "int" }, { "param": "clipval", "type": "float" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "numverts", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "v", "type": "poly_vertex", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "outv", "type": "poly_vertex", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "paramcount", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "clipval", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7fff9a74166a494e5a2f74266e3f63bba64286f5
lofunz/mieme
Reloaded/trunk/src/mame/video/ladybug.c
[ "Unlicense" ]
C
palette_init_common
void
static void palette_init_common( running_machine *machine, const UINT8 *color_prom, int colortable_size, int r_bit0, int r_bit1, int g_bit0, int g_bit1, int b_bit0, int b_bit1 ) { static const int resistances[2] = { 470, 220 }; double rweights[2], gweights[2], bweights[2]; int i; /* compute the color output resistor weights */ compute_resistor_weights(0, 255, -1.0, 2, resistances, rweights, 470, 0, 2, resistances, gweights, 470, 0, 2, resistances, bweights, 470, 0); /* allocate the colortable */ machine->colortable = colortable_alloc(machine, colortable_size); /* create a lookup table for the palette */ for (i = 0; i < 0x20; i++) { int bit0, bit1; int r, g, b; /* red component */ bit0 = (~color_prom[i] >> r_bit0) & 0x01; bit1 = (~color_prom[i] >> r_bit1) & 0x01; r = combine_2_weights(rweights, bit0, bit1); /* green component */ bit0 = (~color_prom[i] >> g_bit0) & 0x01; bit1 = (~color_prom[i] >> g_bit1) & 0x01; g = combine_2_weights(gweights, bit0, bit1); /* blue component */ bit0 = (~color_prom[i] >> b_bit0) & 0x01; bit1 = (~color_prom[i] >> b_bit1) & 0x01; b = combine_2_weights(bweights, bit0, bit1); colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b)); } /* color_prom now points to the beginning of the lookup table */ color_prom += 0x20; /* characters */ for (i = 0; i < 0x20; i++) { UINT8 ctabentry = ((i << 3) & 0x18) | ((i >> 2) & 0x07); colortable_entry_set_value(machine->colortable, i, ctabentry); } /* sprites */ for (i = 0x20; i < 0x40; i++) { UINT8 ctabentry = color_prom[(i - 0x20) >> 1]; ctabentry = BITSWAP8((color_prom[i - 0x20] >> 0) & 0x0f, 7,6,5,4,0,1,2,3); colortable_entry_set_value(machine->colortable, i + 0x00, ctabentry); ctabentry = BITSWAP8((color_prom[i - 0x20] >> 4) & 0x0f, 7,6,5,4,0,1,2,3); colortable_entry_set_value(machine->colortable, i + 0x20, ctabentry); } }
/*************************************************************************** Convert the color PROMs into a more useable format. Lady Bug has a 32 bytes palette PROM and a 32 bytes sprite color lookup table PROM. The palette PROM is connected to the RGB output this way: bit 7 -- inverter -- 220 ohm resistor -- BLUE -- inverter -- 220 ohm resistor -- GREEN -- inverter -- 220 ohm resistor -- RED -- inverter -- 470 ohm resistor -- BLUE -- unused -- inverter -- 470 ohm resistor -- GREEN -- unused bit 0 -- inverter -- 470 ohm resistor -- RED ***************************************************************************/
Convert the color PROMs into a more useable format. Lady Bug has a 32 bytes palette PROM and a 32 bytes sprite color lookup table PROM. The palette PROM is connected to the RGB output this way.
[ "Convert", "the", "color", "PROMs", "into", "a", "more", "useable", "format", ".", "Lady", "Bug", "has", "a", "32", "bytes", "palette", "PROM", "and", "a", "32", "bytes", "sprite", "color", "lookup", "table", "PROM", ".", "The", "palette", "PROM", "is", "connected", "to", "the", "RGB", "output", "this", "way", "." ]
static void palette_init_common( running_machine *machine, const UINT8 *color_prom, int colortable_size, int r_bit0, int r_bit1, int g_bit0, int g_bit1, int b_bit0, int b_bit1 ) { static const int resistances[2] = { 470, 220 }; double rweights[2], gweights[2], bweights[2]; int i; compute_resistor_weights(0, 255, -1.0, 2, resistances, rweights, 470, 0, 2, resistances, gweights, 470, 0, 2, resistances, bweights, 470, 0); machine->colortable = colortable_alloc(machine, colortable_size); for (i = 0; i < 0x20; i++) { int bit0, bit1; int r, g, b; bit0 = (~color_prom[i] >> r_bit0) & 0x01; bit1 = (~color_prom[i] >> r_bit1) & 0x01; r = combine_2_weights(rweights, bit0, bit1); bit0 = (~color_prom[i] >> g_bit0) & 0x01; bit1 = (~color_prom[i] >> g_bit1) & 0x01; g = combine_2_weights(gweights, bit0, bit1); bit0 = (~color_prom[i] >> b_bit0) & 0x01; bit1 = (~color_prom[i] >> b_bit1) & 0x01; b = combine_2_weights(bweights, bit0, bit1); colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b)); } color_prom += 0x20; for (i = 0; i < 0x20; i++) { UINT8 ctabentry = ((i << 3) & 0x18) | ((i >> 2) & 0x07); colortable_entry_set_value(machine->colortable, i, ctabentry); } for (i = 0x20; i < 0x40; i++) { UINT8 ctabentry = color_prom[(i - 0x20) >> 1]; ctabentry = BITSWAP8((color_prom[i - 0x20] >> 0) & 0x0f, 7,6,5,4,0,1,2,3); colortable_entry_set_value(machine->colortable, i + 0x00, ctabentry); ctabentry = BITSWAP8((color_prom[i - 0x20] >> 4) & 0x0f, 7,6,5,4,0,1,2,3); colortable_entry_set_value(machine->colortable, i + 0x20, ctabentry); } }
[ "static", "void", "palette_init_common", "(", "running_machine", "*", "machine", ",", "const", "UINT8", "*", "color_prom", ",", "int", "colortable_size", ",", "int", "r_bit0", ",", "int", "r_bit1", ",", "int", "g_bit0", ",", "int", "g_bit1", ",", "int", "b_bit0", ",", "int", "b_bit1", ")", "{", "static", "const", "int", "resistances", "[", "2", "]", "=", "{", "470", ",", "220", "}", ";", "double", "rweights", "[", "2", "]", ",", "gweights", "[", "2", "]", ",", "bweights", "[", "2", "]", ";", "int", "i", ";", "compute_resistor_weights", "(", "0", ",", "255", ",", "-1.0", ",", "2", ",", "resistances", ",", "rweights", ",", "470", ",", "0", ",", "2", ",", "resistances", ",", "gweights", ",", "470", ",", "0", ",", "2", ",", "resistances", ",", "bweights", ",", "470", ",", "0", ")", ";", "machine", "->", "colortable", "=", "colortable_alloc", "(", "machine", ",", "colortable_size", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "0x20", ";", "i", "++", ")", "{", "int", "bit0", ",", "bit1", ";", "int", "r", ",", "g", ",", "b", ";", "bit0", "=", "(", "~", "color_prom", "[", "i", "]", ">>", "r_bit0", ")", "&", "0x01", ";", "bit1", "=", "(", "~", "color_prom", "[", "i", "]", ">>", "r_bit1", ")", "&", "0x01", ";", "r", "=", "combine_2_weights", "(", "rweights", ",", "bit0", ",", "bit1", ")", ";", "bit0", "=", "(", "~", "color_prom", "[", "i", "]", ">>", "g_bit0", ")", "&", "0x01", ";", "bit1", "=", "(", "~", "color_prom", "[", "i", "]", ">>", "g_bit1", ")", "&", "0x01", ";", "g", "=", "combine_2_weights", "(", "gweights", ",", "bit0", ",", "bit1", ")", ";", "bit0", "=", "(", "~", "color_prom", "[", "i", "]", ">>", "b_bit0", ")", "&", "0x01", ";", "bit1", "=", "(", "~", "color_prom", "[", "i", "]", ">>", "b_bit1", ")", "&", "0x01", ";", "b", "=", "combine_2_weights", "(", "bweights", ",", "bit0", ",", "bit1", ")", ";", "colortable_palette_set_color", "(", "machine", "->", "colortable", ",", "i", ",", "MAKE_RGB", "(", "r", ",", "g", ",", "b", ")", ")", ";", "}", "color_prom", "+=", "0x20", ";", "for", "(", "i", "=", "0", ";", "i", "<", "0x20", ";", "i", "++", ")", "{", "UINT8", "ctabentry", "=", "(", "(", "i", "<<", "3", ")", "&", "0x18", ")", "|", "(", "(", "i", ">>", "2", ")", "&", "0x07", ")", ";", "colortable_entry_set_value", "(", "machine", "->", "colortable", ",", "i", ",", "ctabentry", ")", ";", "}", "for", "(", "i", "=", "0x20", ";", "i", "<", "0x40", ";", "i", "++", ")", "{", "UINT8", "ctabentry", "=", "color_prom", "[", "(", "i", "-", "0x20", ")", ">>", "1", "]", ";", "ctabentry", "=", "BITSWAP8", "(", "(", "color_prom", "[", "i", "-", "0x20", "]", ">>", "0", ")", "&", "0x0f", ",", "7", ",", "6", ",", "5", ",", "4", ",", "0", ",", "1", ",", "2", ",", "3", ")", ";", "colortable_entry_set_value", "(", "machine", "->", "colortable", ",", "i", "+", "0x00", ",", "ctabentry", ")", ";", "ctabentry", "=", "BITSWAP8", "(", "(", "color_prom", "[", "i", "-", "0x20", "]", ">>", "4", ")", "&", "0x0f", ",", "7", ",", "6", ",", "5", ",", "4", ",", "0", ",", "1", ",", "2", ",", "3", ")", ";", "colortable_entry_set_value", "(", "machine", "->", "colortable", ",", "i", "+", "0x20", ",", "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 */", "/* create a lookup table for the palette */", "/* red component */", "/* green component */", "/* blue component */", "/* color_prom now points to the beginning of the lookup table */", "/* characters */", "/* sprites */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "color_prom", "type": "UINT8" }, { "param": "colortable_size", "type": "int" }, { "param": "r_bit0", "type": "int" }, { "param": "r_bit1", "type": "int" }, { "param": "g_bit0", "type": "int" }, { "param": "g_bit1", "type": "int" }, { "param": "b_bit0", "type": "int" }, { "param": "b_bit1", "type": "int" } ]
{ "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": "colortable_size", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "r_bit0", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "r_bit1", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "g_bit0", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "g_bit1", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "b_bit0", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "b_bit1", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7f8d2ea4a85122315d5e018b90b76100f57eca6f
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/ldresample.c
[ "Unlicense" ]
C
chd_allocate_buffers
int
static int chd_allocate_buffers(movie_info *info) { /* allocate a bitmap */ info->bitmap = bitmap_alloc(info->width, info->height, BITMAP_FORMAT_YUY16); if (info->bitmap == NULL) { fprintf(stderr, "Out of memory creating %dx%d bitmap\n", info->width, info->height); return FALSE; } /* allocate sound buffers */ info->lsound = (INT16 *)malloc(info->samplerate * sizeof(*info->lsound)); info->rsound = (INT16 *)malloc(info->samplerate * sizeof(*info->rsound)); if (info->lsound == NULL || info->rsound == NULL) { fprintf(stderr, "Out of memory allocating sound buffers of %d bytes\n", (INT32)(info->samplerate * sizeof(*info->rsound))); return FALSE; } return TRUE; }
/*------------------------------------------------- chd_allocate_buffers - allocate buffers for CHD I/O -------------------------------------------------*/
allocate buffers for CHD I/O
[ "allocate", "buffers", "for", "CHD", "I", "/", "O" ]
static int chd_allocate_buffers(movie_info *info) { info->bitmap = bitmap_alloc(info->width, info->height, BITMAP_FORMAT_YUY16); if (info->bitmap == NULL) { fprintf(stderr, "Out of memory creating %dx%d bitmap\n", info->width, info->height); return FALSE; } info->lsound = (INT16 *)malloc(info->samplerate * sizeof(*info->lsound)); info->rsound = (INT16 *)malloc(info->samplerate * sizeof(*info->rsound)); if (info->lsound == NULL || info->rsound == NULL) { fprintf(stderr, "Out of memory allocating sound buffers of %d bytes\n", (INT32)(info->samplerate * sizeof(*info->rsound))); return FALSE; } return TRUE; }
[ "static", "int", "chd_allocate_buffers", "(", "movie_info", "*", "info", ")", "{", "info", "->", "bitmap", "=", "bitmap_alloc", "(", "info", "->", "width", ",", "info", "->", "height", ",", "BITMAP_FORMAT_YUY16", ")", ";", "if", "(", "info", "->", "bitmap", "==", "NULL", ")", "{", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "info", "->", "width", ",", "info", "->", "height", ")", ";", "return", "FALSE", ";", "}", "info", "->", "lsound", "=", "(", "INT16", "*", ")", "malloc", "(", "info", "->", "samplerate", "*", "sizeof", "(", "*", "info", "->", "lsound", ")", ")", ";", "info", "->", "rsound", "=", "(", "INT16", "*", ")", "malloc", "(", "info", "->", "samplerate", "*", "sizeof", "(", "*", "info", "->", "rsound", ")", ")", ";", "if", "(", "info", "->", "lsound", "==", "NULL", "||", "info", "->", "rsound", "==", "NULL", ")", "{", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "(", "INT32", ")", "(", "info", "->", "samplerate", "*", "sizeof", "(", "*", "info", "->", "rsound", ")", ")", ")", ";", "return", "FALSE", ";", "}", "return", "TRUE", ";", "}" ]
chd_allocate_buffers - allocate buffers for CHD I/O
[ "chd_allocate_buffers", "-", "allocate", "buffers", "for", "CHD", "I", "/", "O" ]
[ "/* allocate a bitmap */", "/* allocate sound buffers */" ]
[ { "param": "info", "type": "movie_info" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "info", "type": "movie_info", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7f8d2ea4a85122315d5e018b90b76100f57eca6f
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/ldresample.c
[ "Unlicense" ]
C
chd_free_buffers
void
static void chd_free_buffers(movie_info *info) { if (info->bitmap != NULL) free(info->bitmap); if (info->lsound != NULL) free(info->lsound); if (info->rsound != NULL) free(info->rsound); }
/*------------------------------------------------- chd_free_buffers - release buffers for CHD I/O -------------------------------------------------*/
release buffers for CHD I/O
[ "release", "buffers", "for", "CHD", "I", "/", "O" ]
static void chd_free_buffers(movie_info *info) { if (info->bitmap != NULL) free(info->bitmap); if (info->lsound != NULL) free(info->lsound); if (info->rsound != NULL) free(info->rsound); }
[ "static", "void", "chd_free_buffers", "(", "movie_info", "*", "info", ")", "{", "if", "(", "info", "->", "bitmap", "!=", "NULL", ")", "free", "(", "info", "->", "bitmap", ")", ";", "if", "(", "info", "->", "lsound", "!=", "NULL", ")", "free", "(", "info", "->", "lsound", ")", ";", "if", "(", "info", "->", "rsound", "!=", "NULL", ")", "free", "(", "info", "->", "rsound", ")", ";", "}" ]
chd_free_buffers - release buffers for CHD I/O
[ "chd_free_buffers", "-", "release", "buffers", "for", "CHD", "I", "/", "O" ]
[]
[ { "param": "info", "type": "movie_info" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "info", "type": "movie_info", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7f8d2ea4a85122315d5e018b90b76100f57eca6f
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/ldresample.c
[ "Unlicense" ]
C
open_chd
chd_file
static chd_file *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->iframerate = fps * 1000000 + fpsfrac; info->framerate = info->iframerate / 1000000.0; info->numfields = chd_get_header(chd)->totalhunks; info->width = width; info->height = height; info->interlaced = interlaced; info->samplerate = rate; info->channels = channels; /* allocate buffers */ if (!chd_allocate_buffers(info)) return NULL; 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 chd_file *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->iframerate = fps * 1000000 + fpsfrac; info->framerate = info->iframerate / 1000000.0; info->numfields = chd_get_header(chd)->totalhunks; info->width = width; info->height = height; info->interlaced = interlaced; info->samplerate = rate; info->channels = channels; if (!chd_allocate_buffers(info)) return NULL; return chd; }
[ "static", "chd_file", "*", "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", "->", "iframerate", "=", "fps", "*", "1000000", "+", "fpsfrac", ";", "info", "->", "framerate", "=", "info", "->", "iframerate", "/", "1000000.0", ";", "info", "->", "numfields", "=", "chd_get_header", "(", "chd", ")", "->", "totalhunks", ";", "info", "->", "width", "=", "width", ";", "info", "->", "height", "=", "height", ";", "info", "->", "interlaced", "=", "interlaced", ";", "info", "->", "samplerate", "=", "rate", ";", "info", "->", "channels", "=", "channels", ";", "if", "(", "!", "chd_allocate_buffers", "(", "info", ")", ")", "return", "NULL", ";", "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 */", "/* allocate buffers */" ]
[ { "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": [] }
7f8d2ea4a85122315d5e018b90b76100f57eca6f
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/ldresample.c
[ "Unlicense" ]
C
read_chd
int
static int read_chd(chd_file *file, UINT32 field, movie_info *info, UINT32 soundoffs) { av_codec_decompress_config avconfig = { 0 }; chd_error chderr; /* configure the codec */ avconfig.video = info->bitmap; avconfig.maxsamples = 48000; avconfig.actsamples = &info->samples; avconfig.audio[0] = info->lsound + soundoffs; avconfig.audio[1] = info->rsound + soundoffs; /* configure the decompressor for this field */ chd_codec_config(file, AV_CODEC_DECOMPRESS_CONFIG, &avconfig); /* read the field */ chderr = chd_read(file, field, NULL); if (chderr != CHDERR_NONE) return FALSE; return TRUE; }
/*------------------------------------------------- read_chd - read a field from a CHD file -------------------------------------------------*/
read a field from a CHD file
[ "read", "a", "field", "from", "a", "CHD", "file" ]
static int read_chd(chd_file *file, UINT32 field, movie_info *info, UINT32 soundoffs) { av_codec_decompress_config avconfig = { 0 }; chd_error chderr; avconfig.video = info->bitmap; avconfig.maxsamples = 48000; avconfig.actsamples = &info->samples; avconfig.audio[0] = info->lsound + soundoffs; avconfig.audio[1] = info->rsound + soundoffs; chd_codec_config(file, AV_CODEC_DECOMPRESS_CONFIG, &avconfig); chderr = chd_read(file, field, NULL); if (chderr != CHDERR_NONE) return FALSE; return TRUE; }
[ "static", "int", "read_chd", "(", "chd_file", "*", "file", ",", "UINT32", "field", ",", "movie_info", "*", "info", ",", "UINT32", "soundoffs", ")", "{", "av_codec_decompress_config", "avconfig", "=", "{", "0", "}", ";", "chd_error", "chderr", ";", "avconfig", ".", "video", "=", "info", "->", "bitmap", ";", "avconfig", ".", "maxsamples", "=", "48000", ";", "avconfig", ".", "actsamples", "=", "&", "info", "->", "samples", ";", "avconfig", ".", "audio", "[", "0", "]", "=", "info", "->", "lsound", "+", "soundoffs", ";", "avconfig", ".", "audio", "[", "1", "]", "=", "info", "->", "rsound", "+", "soundoffs", ";", "chd_codec_config", "(", "file", ",", "AV_CODEC_DECOMPRESS_CONFIG", ",", "&", "avconfig", ")", ";", "chderr", "=", "chd_read", "(", "file", ",", "field", ",", "NULL", ")", ";", "if", "(", "chderr", "!=", "CHDERR_NONE", ")", "return", "FALSE", ";", "return", "TRUE", ";", "}" ]
read_chd - read a field from a CHD file
[ "read_chd", "-", "read", "a", "field", "from", "a", "CHD", "file" ]
[ "/* configure the codec */", "/* configure the decompressor for this field */", "/* read the field */" ]
[ { "param": "file", "type": "chd_file" }, { "param": "field", "type": "UINT32" }, { "param": "info", "type": "movie_info" }, { "param": "soundoffs", "type": "UINT32" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "file", "type": "chd_file", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "field", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "info", "type": "movie_info", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "soundoffs", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7f8d2ea4a85122315d5e018b90b76100f57eca6f
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/tools/ldresample.c
[ "Unlicense" ]
C
write_chd
int
static int write_chd(chd_file *file, UINT32 field, movie_info *info) { av_codec_compress_config avconfig = { 0 }; chd_error chderr; /* configure the codec */ avconfig.video = info->bitmap; avconfig.channels = 2; avconfig.samples = info->samples; avconfig.audio[0] = info->lsound; avconfig.audio[1] = info->rsound; /* configure the decompressor for this field */ chd_codec_config(file, AV_CODEC_COMPRESS_CONFIG, &avconfig); /* read the field */ chderr = chd_compress_hunk(file, NULL, NULL); if (chderr != CHDERR_NONE) return FALSE; return TRUE; }
/*------------------------------------------------- write_chd - write a field to a CHD file -------------------------------------------------*/
write a field to a CHD file
[ "write", "a", "field", "to", "a", "CHD", "file" ]
static int write_chd(chd_file *file, UINT32 field, movie_info *info) { av_codec_compress_config avconfig = { 0 }; chd_error chderr; avconfig.video = info->bitmap; avconfig.channels = 2; avconfig.samples = info->samples; avconfig.audio[0] = info->lsound; avconfig.audio[1] = info->rsound; chd_codec_config(file, AV_CODEC_COMPRESS_CONFIG, &avconfig); chderr = chd_compress_hunk(file, NULL, NULL); if (chderr != CHDERR_NONE) return FALSE; return TRUE; }
[ "static", "int", "write_chd", "(", "chd_file", "*", "file", ",", "UINT32", "field", ",", "movie_info", "*", "info", ")", "{", "av_codec_compress_config", "avconfig", "=", "{", "0", "}", ";", "chd_error", "chderr", ";", "avconfig", ".", "video", "=", "info", "->", "bitmap", ";", "avconfig", ".", "channels", "=", "2", ";", "avconfig", ".", "samples", "=", "info", "->", "samples", ";", "avconfig", ".", "audio", "[", "0", "]", "=", "info", "->", "lsound", ";", "avconfig", ".", "audio", "[", "1", "]", "=", "info", "->", "rsound", ";", "chd_codec_config", "(", "file", ",", "AV_CODEC_COMPRESS_CONFIG", ",", "&", "avconfig", ")", ";", "chderr", "=", "chd_compress_hunk", "(", "file", ",", "NULL", ",", "NULL", ")", ";", "if", "(", "chderr", "!=", "CHDERR_NONE", ")", "return", "FALSE", ";", "return", "TRUE", ";", "}" ]
write_chd - write a field to a CHD file
[ "write_chd", "-", "write", "a", "field", "to", "a", "CHD", "file" ]
[ "/* configure the codec */", "/* configure the decompressor for this field */", "/* read the field */" ]
[ { "param": "file", "type": "chd_file" }, { "param": "field", "type": "UINT32" }, { "param": "info", "type": "movie_info" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "file", "type": "chd_file", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "field", "type": "UINT32", "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": [] }
275ee076de117417c2c846320784a7fd55321c7d
lofunz/mieme
Reloaded/trunk/src/emu/machine/6821pia.c
[ "Unlicense" ]
C
pia6821_get_output_ca2_z
int
int pia6821_get_output_ca2_z(running_device *device) { pia6821_state *p = get_token(device); p->out_ca2_needs_pulled = FALSE; // If it's an output, output the bit, if it's an input, it's // pulled up return p->out_ca2 | C2_INPUT(p->ctl_a); }
/*------------------------------------------------- pia6821_get_output_ca2_z - version of pia6821_get_output_ca2, which takes account of internal pullup resistor -------------------------------------------------*/
version of pia6821_get_output_ca2, which takes account of internal pullup resistor
[ "version", "of", "pia6821_get_output_ca2", "which", "takes", "account", "of", "internal", "pullup", "resistor" ]
int pia6821_get_output_ca2_z(running_device *device) { pia6821_state *p = get_token(device); p->out_ca2_needs_pulled = FALSE; return p->out_ca2 | C2_INPUT(p->ctl_a); }
[ "int", "pia6821_get_output_ca2_z", "(", "running_device", "*", "device", ")", "{", "pia6821_state", "*", "p", "=", "get_token", "(", "device", ")", ";", "p", "->", "out_ca2_needs_pulled", "=", "FALSE", ";", "return", "p", "->", "out_ca2", "|", "C2_INPUT", "(", "p", "->", "ctl_a", ")", ";", "}" ]
pia6821_get_output_ca2_z - version of pia6821_get_output_ca2, which takes account of internal pullup resistor
[ "pia6821_get_output_ca2_z", "-", "version", "of", "pia6821_get_output_ca2", "which", "takes", "account", "of", "internal", "pullup", "resistor" ]
[ "// If it's an output, output the bit, if it's an input, it's\r", "// pulled up\r" ]
[ { "param": "device", "type": "running_device" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "device", "type": "running_device", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0d1a66f3c60fbbb1a8cbb17793896d8460434d53
lofunz/mieme
Reloaded/trunk/src/mame/video/undrfire.c
[ "Unlicense" ]
C
draw_sprites
void
static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,const int *primasks,int x_offs,int y_offs) { UINT32 *spriteram32 = machine->generic.spriteram.u32; UINT16 *spritemap = (UINT16 *)memory_region(machine, "user1"); int offs, data, tilenum, color, flipx, flipy; int x, y, priority, dblsize, curx, cury; int sprites_flipscreen = 0; int zoomx, zoomy, zx, zy; int sprite_chunk,map_offset,code,j,k,px,py; int dimension,total_chunks,bad_chunks; /* pdrawgfx() needs us to draw sprites front to back, so we have to build a list while processing sprite ram and then draw them all at the end */ struct tempsprite *sprite_ptr = spritelist; for (offs = (machine->generic.spriteram_size/4-4);offs >= 0;offs -= 4) { data = spriteram32[offs+0]; flipx = (data & 0x00800000) >> 23; zoomx = (data & 0x007f0000) >> 16; tilenum = (data & 0x00007fff); data = spriteram32[offs+2]; priority = (data & 0x000c0000) >> 18; color = (data & 0x0003fc00) >> 10; x = (data & 0x000003ff); data = spriteram32[offs+3]; dblsize = (data & 0x00040000) >> 18; flipy = (data & 0x00020000) >> 17; zoomy = (data & 0x0001fc00) >> 10; y = (data & 0x000003ff); color |= (0x100 + (priority << 6)); /* priority bits select color bank */ color /= 2; /* as sprites are 5bpp */ flipy = !flipy; y = (-y &0x3ff); if (!tilenum) continue; flipy = !flipy; zoomx += 1; zoomy += 1; y += y_offs; /* treat coords as signed */ if (x>0x340) x -= 0x400; if (y>0x340) y -= 0x400; x -= x_offs; bad_chunks = 0; dimension = ((dblsize*2) + 2); // 2 or 4 total_chunks = ((dblsize*3) + 1) << 2; // 4 or 16 map_offset = tilenum << 2; { for (sprite_chunk=0;sprite_chunk<total_chunks;sprite_chunk++) { j = sprite_chunk / dimension; /* rows */ k = sprite_chunk % dimension; /* chunks per row */ px = k; py = j; /* pick tiles back to front for x and y flips */ if (flipx) px = dimension-1-k; if (flipy) py = dimension-1-j; code = spritemap[map_offset + px + (py<<(dblsize+1))]; if (code==0xffff) { bad_chunks += 1; continue; } curx = x + ((k*zoomx)/dimension); cury = y + ((j*zoomy)/dimension); zx= x + (((k+1)*zoomx)/dimension) - curx; zy= y + (((j+1)*zoomy)/dimension) - cury; if (sprites_flipscreen) { /* -zx/y is there to fix zoomed sprite coords in screenflip. drawgfxzoom does not know to draw from flip-side of sprites when screen is flipped; so we must correct the coords ourselves. */ curx = 320 - curx - zx; cury = 256 - cury - zy; flipx = !flipx; flipy = !flipy; } sprite_ptr->gfx = 0; sprite_ptr->code = code; sprite_ptr->color = color; sprite_ptr->flipx = !flipx; sprite_ptr->flipy = flipy; sprite_ptr->x = curx; sprite_ptr->y = cury; sprite_ptr->zoomx = zx << 12; sprite_ptr->zoomy = zy << 12; if (primasks) { sprite_ptr->primask = primasks[priority]; sprite_ptr++; } else { drawgfxzoom_transpen(bitmap,cliprect,machine->gfx[sprite_ptr->gfx], sprite_ptr->code, sprite_ptr->color, sprite_ptr->flipx,sprite_ptr->flipy, sprite_ptr->x,sprite_ptr->y, sprite_ptr->zoomx,sprite_ptr->zoomy,0); } } } if (bad_chunks) logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks); } /* this happens only if primsks != NULL */ while (sprite_ptr != spritelist) { sprite_ptr--; pdrawgfxzoom_transpen(bitmap,cliprect,machine->gfx[sprite_ptr->gfx], sprite_ptr->code, sprite_ptr->color, sprite_ptr->flipx,sprite_ptr->flipy, sprite_ptr->x,sprite_ptr->y, sprite_ptr->zoomx,sprite_ptr->zoomy, machine->priority_bitmap,sprite_ptr->primask,0); } }
/*************************************************************** SPRITE DRAW ROUTINES We draw a series of small tiles ("chunks") together to create each big sprite. The spritemap rom provides the lookup table for this. The game hardware looks up 16x16 sprite chunks from the spritemap rom, creating a 64x64 sprite like this: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 (where the number is the word offset into the spritemap rom). It can also create 32x32 sprites. NB: unused portions of the spritemap rom contain hex FF's. It is a useful coding check to warn in the log if these are being accessed. [They can be inadvertently while spriteram is being tested, take no notice of that.] Heavy use is made of sprite zooming. *** Sprite table layout (4 long words per entry) ------------------------------------------ 0 | ........ x....... ........ ........ | Flip X 0 | ........ .xxxxxxx ........ ........ | ZoomX 0 | ........ ........ .xxxxxxx xxxxxxxx | Sprite Tile | | 2 | ........ ....xx.. ........ ........ | Sprite/tile priority [*] 2 | ........ ......xx xxxxxx.. ........ | Palette bank 2 | ........ ........ ......xx xxxxxxxx | X position | | 3 | ........ .....x.. ........ ........ | Sprite size (0=32x32, 1=64x64) 3 | ........ ......x. ........ ........ | Flip Y 3 | ........ .......x xxxxxx.. ........ | ZoomY 3 | ........ ........ ......xx xxxxxxxx | Y position ------------------------------------------ [* 00=over BG0, 01=BG1, 10=BG2, 11=BG3 ] [or 00=over BG1, 01=BG2, 10=BG3, 11=BG3 ] ***************************************************************/
SPRITE DRAW ROUTINES We draw a series of small tiles ("chunks") together to create each big sprite. The spritemap rom provides the lookup table for this. The game hardware looks up 16x16 sprite chunks from the spritemap rom, creating a 64x64 sprite like this. (where the number is the word offset into the spritemap rom). It can also create 32x32 sprites. unused portions of the spritemap rom contain hex FF's. It is a useful coding check to warn in the log if these are being accessed. [They can be inadvertently while spriteram is being tested, take no notice of that.] Heavy use is made of sprite zooming. Sprite table layout (4 long words per entry)
[ "SPRITE", "DRAW", "ROUTINES", "We", "draw", "a", "series", "of", "small", "tiles", "(", "\"", "chunks", "\"", ")", "together", "to", "create", "each", "big", "sprite", ".", "The", "spritemap", "rom", "provides", "the", "lookup", "table", "for", "this", ".", "The", "game", "hardware", "looks", "up", "16x16", "sprite", "chunks", "from", "the", "spritemap", "rom", "creating", "a", "64x64", "sprite", "like", "this", ".", "(", "where", "the", "number", "is", "the", "word", "offset", "into", "the", "spritemap", "rom", ")", ".", "It", "can", "also", "create", "32x32", "sprites", ".", "unused", "portions", "of", "the", "spritemap", "rom", "contain", "hex", "FF", "'", "s", ".", "It", "is", "a", "useful", "coding", "check", "to", "warn", "in", "the", "log", "if", "these", "are", "being", "accessed", ".", "[", "They", "can", "be", "inadvertently", "while", "spriteram", "is", "being", "tested", "take", "no", "notice", "of", "that", ".", "]", "Heavy", "use", "is", "made", "of", "sprite", "zooming", ".", "Sprite", "table", "layout", "(", "4", "long", "words", "per", "entry", ")" ]
static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,const int *primasks,int x_offs,int y_offs) { UINT32 *spriteram32 = machine->generic.spriteram.u32; UINT16 *spritemap = (UINT16 *)memory_region(machine, "user1"); int offs, data, tilenum, color, flipx, flipy; int x, y, priority, dblsize, curx, cury; int sprites_flipscreen = 0; int zoomx, zoomy, zx, zy; int sprite_chunk,map_offset,code,j,k,px,py; int dimension,total_chunks,bad_chunks; struct tempsprite *sprite_ptr = spritelist; for (offs = (machine->generic.spriteram_size/4-4);offs >= 0;offs -= 4) { data = spriteram32[offs+0]; flipx = (data & 0x00800000) >> 23; zoomx = (data & 0x007f0000) >> 16; tilenum = (data & 0x00007fff); data = spriteram32[offs+2]; priority = (data & 0x000c0000) >> 18; color = (data & 0x0003fc00) >> 10; x = (data & 0x000003ff); data = spriteram32[offs+3]; dblsize = (data & 0x00040000) >> 18; flipy = (data & 0x00020000) >> 17; zoomy = (data & 0x0001fc00) >> 10; y = (data & 0x000003ff); color |= (0x100 + (priority << 6)); color /= 2; flipy = !flipy; y = (-y &0x3ff); if (!tilenum) continue; flipy = !flipy; zoomx += 1; zoomy += 1; y += y_offs; if (x>0x340) x -= 0x400; if (y>0x340) y -= 0x400; x -= x_offs; bad_chunks = 0; dimension = ((dblsize*2) + 2); total_chunks = ((dblsize*3) + 1) << 2; map_offset = tilenum << 2; { for (sprite_chunk=0;sprite_chunk<total_chunks;sprite_chunk++) { j = sprite_chunk / dimension; k = sprite_chunk % dimension; px = k; py = j; if (flipx) px = dimension-1-k; if (flipy) py = dimension-1-j; code = spritemap[map_offset + px + (py<<(dblsize+1))]; if (code==0xffff) { bad_chunks += 1; continue; } curx = x + ((k*zoomx)/dimension); cury = y + ((j*zoomy)/dimension); zx= x + (((k+1)*zoomx)/dimension) - curx; zy= y + (((j+1)*zoomy)/dimension) - cury; if (sprites_flipscreen) { curx = 320 - curx - zx; cury = 256 - cury - zy; flipx = !flipx; flipy = !flipy; } sprite_ptr->gfx = 0; sprite_ptr->code = code; sprite_ptr->color = color; sprite_ptr->flipx = !flipx; sprite_ptr->flipy = flipy; sprite_ptr->x = curx; sprite_ptr->y = cury; sprite_ptr->zoomx = zx << 12; sprite_ptr->zoomy = zy << 12; if (primasks) { sprite_ptr->primask = primasks[priority]; sprite_ptr++; } else { drawgfxzoom_transpen(bitmap,cliprect,machine->gfx[sprite_ptr->gfx], sprite_ptr->code, sprite_ptr->color, sprite_ptr->flipx,sprite_ptr->flipy, sprite_ptr->x,sprite_ptr->y, sprite_ptr->zoomx,sprite_ptr->zoomy,0); } } } if (bad_chunks) logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks); } while (sprite_ptr != spritelist) { sprite_ptr--; pdrawgfxzoom_transpen(bitmap,cliprect,machine->gfx[sprite_ptr->gfx], sprite_ptr->code, sprite_ptr->color, sprite_ptr->flipx,sprite_ptr->flipy, sprite_ptr->x,sprite_ptr->y, sprite_ptr->zoomx,sprite_ptr->zoomy, machine->priority_bitmap,sprite_ptr->primask,0); } }
[ "static", "void", "draw_sprites", "(", "running_machine", "*", "machine", ",", "bitmap_t", "*", "bitmap", ",", "const", "rectangle", "*", "cliprect", ",", "const", "int", "*", "primasks", ",", "int", "x_offs", ",", "int", "y_offs", ")", "{", "UINT32", "*", "spriteram32", "=", "machine", "->", "generic", ".", "spriteram", ".", "u32", ";", "UINT16", "*", "spritemap", "=", "(", "UINT16", "*", ")", "memory_region", "(", "machine", ",", "\"", "\"", ")", ";", "int", "offs", ",", "data", ",", "tilenum", ",", "color", ",", "flipx", ",", "flipy", ";", "int", "x", ",", "y", ",", "priority", ",", "dblsize", ",", "curx", ",", "cury", ";", "int", "sprites_flipscreen", "=", "0", ";", "int", "zoomx", ",", "zoomy", ",", "zx", ",", "zy", ";", "int", "sprite_chunk", ",", "map_offset", ",", "code", ",", "j", ",", "k", ",", "px", ",", "py", ";", "int", "dimension", ",", "total_chunks", ",", "bad_chunks", ";", "struct", "tempsprite", "*", "sprite_ptr", "=", "spritelist", ";", "for", "(", "offs", "=", "(", "machine", "->", "generic", ".", "spriteram_size", "/", "4", "-", "4", ")", ";", "offs", ">=", "0", ";", "offs", "-=", "4", ")", "{", "data", "=", "spriteram32", "[", "offs", "+", "0", "]", ";", "flipx", "=", "(", "data", "&", "0x00800000", ")", ">>", "23", ";", "zoomx", "=", "(", "data", "&", "0x007f0000", ")", ">>", "16", ";", "tilenum", "=", "(", "data", "&", "0x00007fff", ")", ";", "data", "=", "spriteram32", "[", "offs", "+", "2", "]", ";", "priority", "=", "(", "data", "&", "0x000c0000", ")", ">>", "18", ";", "color", "=", "(", "data", "&", "0x0003fc00", ")", ">>", "10", ";", "x", "=", "(", "data", "&", "0x000003ff", ")", ";", "data", "=", "spriteram32", "[", "offs", "+", "3", "]", ";", "dblsize", "=", "(", "data", "&", "0x00040000", ")", ">>", "18", ";", "flipy", "=", "(", "data", "&", "0x00020000", ")", ">>", "17", ";", "zoomy", "=", "(", "data", "&", "0x0001fc00", ")", ">>", "10", ";", "y", "=", "(", "data", "&", "0x000003ff", ")", ";", "color", "|=", "(", "0x100", "+", "(", "priority", "<<", "6", ")", ")", ";", "color", "/=", "2", ";", "flipy", "=", "!", "flipy", ";", "y", "=", "(", "-", "y", "&", "0x3ff", ")", ";", "if", "(", "!", "tilenum", ")", "continue", ";", "flipy", "=", "!", "flipy", ";", "zoomx", "+=", "1", ";", "zoomy", "+=", "1", ";", "y", "+=", "y_offs", ";", "if", "(", "x", ">", "0x340", ")", "x", "-=", "0x400", ";", "if", "(", "y", ">", "0x340", ")", "y", "-=", "0x400", ";", "x", "-=", "x_offs", ";", "bad_chunks", "=", "0", ";", "dimension", "=", "(", "(", "dblsize", "*", "2", ")", "+", "2", ")", ";", "total_chunks", "=", "(", "(", "dblsize", "*", "3", ")", "+", "1", ")", "<<", "2", ";", "map_offset", "=", "tilenum", "<<", "2", ";", "{", "for", "(", "sprite_chunk", "=", "0", ";", "sprite_chunk", "<", "total_chunks", ";", "sprite_chunk", "++", ")", "{", "j", "=", "sprite_chunk", "/", "dimension", ";", "k", "=", "sprite_chunk", "%", "dimension", ";", "px", "=", "k", ";", "py", "=", "j", ";", "if", "(", "flipx", ")", "px", "=", "dimension", "-", "1", "-", "k", ";", "if", "(", "flipy", ")", "py", "=", "dimension", "-", "1", "-", "j", ";", "code", "=", "spritemap", "[", "map_offset", "+", "px", "+", "(", "py", "<<", "(", "dblsize", "+", "1", ")", ")", "]", ";", "if", "(", "code", "==", "0xffff", ")", "{", "bad_chunks", "+=", "1", ";", "continue", ";", "}", "curx", "=", "x", "+", "(", "(", "k", "*", "zoomx", ")", "/", "dimension", ")", ";", "cury", "=", "y", "+", "(", "(", "j", "*", "zoomy", ")", "/", "dimension", ")", ";", "zx", "=", "x", "+", "(", "(", "(", "k", "+", "1", ")", "*", "zoomx", ")", "/", "dimension", ")", "-", "curx", ";", "zy", "=", "y", "+", "(", "(", "(", "j", "+", "1", ")", "*", "zoomy", ")", "/", "dimension", ")", "-", "cury", ";", "if", "(", "sprites_flipscreen", ")", "{", "curx", "=", "320", "-", "curx", "-", "zx", ";", "cury", "=", "256", "-", "cury", "-", "zy", ";", "flipx", "=", "!", "flipx", ";", "flipy", "=", "!", "flipy", ";", "}", "sprite_ptr", "->", "gfx", "=", "0", ";", "sprite_ptr", "->", "code", "=", "code", ";", "sprite_ptr", "->", "color", "=", "color", ";", "sprite_ptr", "->", "flipx", "=", "!", "flipx", ";", "sprite_ptr", "->", "flipy", "=", "flipy", ";", "sprite_ptr", "->", "x", "=", "curx", ";", "sprite_ptr", "->", "y", "=", "cury", ";", "sprite_ptr", "->", "zoomx", "=", "zx", "<<", "12", ";", "sprite_ptr", "->", "zoomy", "=", "zy", "<<", "12", ";", "if", "(", "primasks", ")", "{", "sprite_ptr", "->", "primask", "=", "primasks", "[", "priority", "]", ";", "sprite_ptr", "++", ";", "}", "else", "{", "drawgfxzoom_transpen", "(", "bitmap", ",", "cliprect", ",", "machine", "->", "gfx", "[", "sprite_ptr", "->", "gfx", "]", ",", "sprite_ptr", "->", "code", ",", "sprite_ptr", "->", "color", ",", "sprite_ptr", "->", "flipx", ",", "sprite_ptr", "->", "flipy", ",", "sprite_ptr", "->", "x", ",", "sprite_ptr", "->", "y", ",", "sprite_ptr", "->", "zoomx", ",", "sprite_ptr", "->", "zoomy", ",", "0", ")", ";", "}", "}", "}", "if", "(", "bad_chunks", ")", "logerror", "(", "\"", "\\n", "\"", ",", "tilenum", ",", "bad_chunks", ")", ";", "}", "while", "(", "sprite_ptr", "!=", "spritelist", ")", "{", "sprite_ptr", "--", ";", "pdrawgfxzoom_transpen", "(", "bitmap", ",", "cliprect", ",", "machine", "->", "gfx", "[", "sprite_ptr", "->", "gfx", "]", ",", "sprite_ptr", "->", "code", ",", "sprite_ptr", "->", "color", ",", "sprite_ptr", "->", "flipx", ",", "sprite_ptr", "->", "flipy", ",", "sprite_ptr", "->", "x", ",", "sprite_ptr", "->", "y", ",", "sprite_ptr", "->", "zoomx", ",", "sprite_ptr", "->", "zoomy", ",", "machine", "->", "priority_bitmap", ",", "sprite_ptr", "->", "primask", ",", "0", ")", ";", "}", "}" ]
SPRITE DRAW ROUTINES We draw a series of small tiles ("chunks") together to create each big sprite.
[ "SPRITE", "DRAW", "ROUTINES", "We", "draw", "a", "series", "of", "small", "tiles", "(", "\"", "chunks", "\"", ")", "together", "to", "create", "each", "big", "sprite", "." ]
[ "/* pdrawgfx() needs us to draw sprites front to back, so we have to build a list\r\n while processing sprite ram and then draw them all at the end */", "/* priority bits select color bank */", "/* as sprites are 5bpp */", "/* treat coords as signed */", "// 2 or 4\r", "// 4 or 16\r", "/* rows */", "/* chunks per row */", "/* pick tiles back to front for x and y flips */", "/* -zx/y is there to fix zoomed sprite coords in screenflip.\r\n drawgfxzoom does not know to draw from flip-side of sprites when\r\n screen is flipped; so we must correct the coords ourselves. */", "/* this happens only if primsks != NULL */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "bitmap", "type": "bitmap_t" }, { "param": "cliprect", "type": "rectangle" }, { "param": "primasks", "type": "int" }, { "param": "x_offs", "type": "int" }, { "param": "y_offs", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bitmap", "type": "bitmap_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cliprect", "type": "rectangle", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "primasks", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x_offs", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y_offs", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f4a3c22651f9dd7573e1f75caaab312df416eda3
lofunz/mieme
Reloaded/trunk/src/mame/video/toaplan1.c
[ "Unlicense" ]
C
toaplan1_draw_sprite_custom
void
static void toaplan1_draw_sprite_custom(bitmap_t *dest_bmp,const rectangle *clip,const gfx_element *gfx, UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy, int priority) { int pal_base = gfx->color_base + gfx->color_granularity * (color % gfx->total_colors); const UINT8 *source_base = gfx_element_get_data(gfx, code % gfx->total_elements); bitmap_t *priority_bitmap = gfx->machine->priority_bitmap; int sprite_screen_height = ((1<<16)*gfx->height+0x8000)>>16; int sprite_screen_width = ((1<<16)*gfx->width+0x8000)>>16; if (sprite_screen_width && sprite_screen_height) { /* compute sprite increment per screen pixel */ int dx = (gfx->width<<16)/sprite_screen_width; int dy = (gfx->height<<16)/sprite_screen_height; int ex = sx+sprite_screen_width; int ey = sy+sprite_screen_height; int x_index_base; int y_index; if( flipx ) { x_index_base = (sprite_screen_width-1)*dx; dx = -dx; } else { x_index_base = 0; } if( flipy ) { y_index = (sprite_screen_height-1)*dy; dy = -dy; } else { y_index = 0; } if( clip ) { if( sx < clip->min_x) { /* clip left */ int pixels = clip->min_x-sx; sx += pixels; x_index_base += pixels*dx; } if( sy < clip->min_y ) { /* clip top */ int pixels = clip->min_y-sy; sy += pixels; y_index += pixels*dy; } /* NS 980211 - fixed incorrect clipping */ if( ex > clip->max_x+1 ) { /* clip right */ int pixels = ex-clip->max_x-1; ex -= pixels; } if( ey > clip->max_y+1 ) { /* clip bottom */ int pixels = ey-clip->max_y-1; ey -= pixels; } } if( ex>sx ) { /* skip if inner loop doesn't draw anything */ int y; for( y=sy; y<ey; y++ ) { const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo; UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0); UINT8 *pri = BITMAP_ADDR8(priority_bitmap, y, 0); int x, x_index = x_index_base; for( x=sx; x<ex; x++ ) { int c = source[x_index>>16]; if( c != 0 ) { if (pri[x] < priority) dest[x] = pal_base+c; pri[x] = 0xff; // mark it "already drawn" } x_index += dx; } y_index += dy; } } } }
// custom function to draw a single sprite. needed to keep correct sprites - sprites and sprites - tilemaps priorities
custom function to draw a single sprite. needed to keep correct sprites - sprites and sprites - tilemaps priorities
[ "custom", "function", "to", "draw", "a", "single", "sprite", ".", "needed", "to", "keep", "correct", "sprites", "-", "sprites", "and", "sprites", "-", "tilemaps", "priorities" ]
static void toaplan1_draw_sprite_custom(bitmap_t *dest_bmp,const rectangle *clip,const gfx_element *gfx, UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy, int priority) { int pal_base = gfx->color_base + gfx->color_granularity * (color % gfx->total_colors); const UINT8 *source_base = gfx_element_get_data(gfx, code % gfx->total_elements); bitmap_t *priority_bitmap = gfx->machine->priority_bitmap; int sprite_screen_height = ((1<<16)*gfx->height+0x8000)>>16; int sprite_screen_width = ((1<<16)*gfx->width+0x8000)>>16; if (sprite_screen_width && sprite_screen_height) { int dx = (gfx->width<<16)/sprite_screen_width; int dy = (gfx->height<<16)/sprite_screen_height; int ex = sx+sprite_screen_width; int ey = sy+sprite_screen_height; int x_index_base; int y_index; if( flipx ) { x_index_base = (sprite_screen_width-1)*dx; dx = -dx; } else { x_index_base = 0; } if( flipy ) { y_index = (sprite_screen_height-1)*dy; dy = -dy; } else { y_index = 0; } if( clip ) { if( sx < clip->min_x) { int pixels = clip->min_x-sx; sx += pixels; x_index_base += pixels*dx; } if( sy < clip->min_y ) { int pixels = clip->min_y-sy; sy += pixels; y_index += pixels*dy; } if( ex > clip->max_x+1 ) { int pixels = ex-clip->max_x-1; ex -= pixels; } if( ey > clip->max_y+1 ) { int pixels = ey-clip->max_y-1; ey -= pixels; } } if( ex>sx ) { int y; for( y=sy; y<ey; y++ ) { const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo; UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0); UINT8 *pri = BITMAP_ADDR8(priority_bitmap, y, 0); int x, x_index = x_index_base; for( x=sx; x<ex; x++ ) { int c = source[x_index>>16]; if( c != 0 ) { if (pri[x] < priority) dest[x] = pal_base+c; pri[x] = 0xff; } x_index += dx; } y_index += dy; } } } }
[ "static", "void", "toaplan1_draw_sprite_custom", "(", "bitmap_t", "*", "dest_bmp", ",", "const", "rectangle", "*", "clip", ",", "const", "gfx_element", "*", "gfx", ",", "UINT32", "code", ",", "UINT32", "color", ",", "int", "flipx", ",", "int", "flipy", ",", "int", "sx", ",", "int", "sy", ",", "int", "priority", ")", "{", "int", "pal_base", "=", "gfx", "->", "color_base", "+", "gfx", "->", "color_granularity", "*", "(", "color", "%", "gfx", "->", "total_colors", ")", ";", "const", "UINT8", "*", "source_base", "=", "gfx_element_get_data", "(", "gfx", ",", "code", "%", "gfx", "->", "total_elements", ")", ";", "bitmap_t", "*", "priority_bitmap", "=", "gfx", "->", "machine", "->", "priority_bitmap", ";", "int", "sprite_screen_height", "=", "(", "(", "1", "<<", "16", ")", "*", "gfx", "->", "height", "+", "0x8000", ")", ">>", "16", ";", "int", "sprite_screen_width", "=", "(", "(", "1", "<<", "16", ")", "*", "gfx", "->", "width", "+", "0x8000", ")", ">>", "16", ";", "if", "(", "sprite_screen_width", "&&", "sprite_screen_height", ")", "{", "int", "dx", "=", "(", "gfx", "->", "width", "<<", "16", ")", "/", "sprite_screen_width", ";", "int", "dy", "=", "(", "gfx", "->", "height", "<<", "16", ")", "/", "sprite_screen_height", ";", "int", "ex", "=", "sx", "+", "sprite_screen_width", ";", "int", "ey", "=", "sy", "+", "sprite_screen_height", ";", "int", "x_index_base", ";", "int", "y_index", ";", "if", "(", "flipx", ")", "{", "x_index_base", "=", "(", "sprite_screen_width", "-", "1", ")", "*", "dx", ";", "dx", "=", "-", "dx", ";", "}", "else", "{", "x_index_base", "=", "0", ";", "}", "if", "(", "flipy", ")", "{", "y_index", "=", "(", "sprite_screen_height", "-", "1", ")", "*", "dy", ";", "dy", "=", "-", "dy", ";", "}", "else", "{", "y_index", "=", "0", ";", "}", "if", "(", "clip", ")", "{", "if", "(", "sx", "<", "clip", "->", "min_x", ")", "{", "int", "pixels", "=", "clip", "->", "min_x", "-", "sx", ";", "sx", "+=", "pixels", ";", "x_index_base", "+=", "pixels", "*", "dx", ";", "}", "if", "(", "sy", "<", "clip", "->", "min_y", ")", "{", "int", "pixels", "=", "clip", "->", "min_y", "-", "sy", ";", "sy", "+=", "pixels", ";", "y_index", "+=", "pixels", "*", "dy", ";", "}", "if", "(", "ex", ">", "clip", "->", "max_x", "+", "1", ")", "{", "int", "pixels", "=", "ex", "-", "clip", "->", "max_x", "-", "1", ";", "ex", "-=", "pixels", ";", "}", "if", "(", "ey", ">", "clip", "->", "max_y", "+", "1", ")", "{", "int", "pixels", "=", "ey", "-", "clip", "->", "max_y", "-", "1", ";", "ey", "-=", "pixels", ";", "}", "}", "if", "(", "ex", ">", "sx", ")", "{", "int", "y", ";", "for", "(", "y", "=", "sy", ";", "y", "<", "ey", ";", "y", "++", ")", "{", "const", "UINT8", "*", "source", "=", "source_base", "+", "(", "y_index", ">>", "16", ")", "*", "gfx", "->", "line_modulo", ";", "UINT16", "*", "dest", "=", "BITMAP_ADDR16", "(", "dest_bmp", ",", "y", ",", "0", ")", ";", "UINT8", "*", "pri", "=", "BITMAP_ADDR8", "(", "priority_bitmap", ",", "y", ",", "0", ")", ";", "int", "x", ",", "x_index", "=", "x_index_base", ";", "for", "(", "x", "=", "sx", ";", "x", "<", "ex", ";", "x", "++", ")", "{", "int", "c", "=", "source", "[", "x_index", ">>", "16", "]", ";", "if", "(", "c", "!=", "0", ")", "{", "if", "(", "pri", "[", "x", "]", "<", "priority", ")", "dest", "[", "x", "]", "=", "pal_base", "+", "c", ";", "pri", "[", "x", "]", "=", "0xff", ";", "}", "x_index", "+=", "dx", ";", "}", "y_index", "+=", "dy", ";", "}", "}", "}", "}" ]
custom function to draw a single sprite.
[ "custom", "function", "to", "draw", "a", "single", "sprite", "." ]
[ "/* compute sprite increment per screen pixel */", "/* clip left */", "/* clip top */", "/* NS 980211 - fixed incorrect clipping */", "/* clip right */", "/* clip bottom */", "/* skip if inner loop doesn't draw anything */", "// mark it \"already drawn\"\r" ]
[ { "param": "dest_bmp", "type": "bitmap_t" }, { "param": "clip", "type": "rectangle" }, { "param": "gfx", "type": "gfx_element" }, { "param": "code", "type": "UINT32" }, { "param": "color", "type": "UINT32" }, { "param": "flipx", "type": "int" }, { "param": "flipy", "type": "int" }, { "param": "sx", "type": "int" }, { "param": "sy", "type": "int" }, { "param": "priority", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dest_bmp", "type": "bitmap_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "clip", "type": "rectangle", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gfx", "type": "gfx_element", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "code", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "color", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "flipx", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "flipy", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sx", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sy", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "priority", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1bdabe4d93397baf824d5226da01f4b369398e87
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/video/ssv.c
[ "Unlicense" ]
C
draw_layer
void
static void draw_layer(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int nr) { int sy; for ( sy = 0; sy <= video_screen_get_visible_area(machine->primary_screen)->max_y; sy += 0x40 ) draw_row(machine, bitmap, cliprect, 0, sy, nr); }
/* Draw the "background layer" using multiple tilemap sprites */
Draw the "background layer" using multiple tilemap sprites
[ "Draw", "the", "\"", "background", "layer", "\"", "using", "multiple", "tilemap", "sprites" ]
static void draw_layer(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int nr) { int sy; for ( sy = 0; sy <= video_screen_get_visible_area(machine->primary_screen)->max_y; sy += 0x40 ) draw_row(machine, bitmap, cliprect, 0, sy, nr); }
[ "static", "void", "draw_layer", "(", "running_machine", "*", "machine", ",", "bitmap_t", "*", "bitmap", ",", "const", "rectangle", "*", "cliprect", ",", "int", "nr", ")", "{", "int", "sy", ";", "for", "(", "sy", "=", "0", ";", "sy", "<=", "video_screen_get_visible_area", "(", "machine", "->", "primary_screen", ")", "->", "max_y", ";", "sy", "+=", "0x40", ")", "draw_row", "(", "machine", ",", "bitmap", ",", "cliprect", ",", "0", ",", "sy", ",", "nr", ")", ";", "}" ]
Draw the "background layer" using multiple tilemap sprites
[ "Draw", "the", "\"", "background", "layer", "\"", "using", "multiple", "tilemap", "sprites" ]
[]
[ { "param": "machine", "type": "running_machine" }, { "param": "bitmap", "type": "bitmap_t" }, { "param": "cliprect", "type": "rectangle" }, { "param": "nr", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bitmap", "type": "bitmap_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cliprect", "type": "rectangle", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "nr", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1bdabe4d93397baf824d5226da01f4b369398e87
lofunz/mieme
Reloaded/tags/MAME4droid.Reloaded.1.0.WIP/src/mame/video/ssv.c
[ "Unlicense" ]
C
draw_sprites
void
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) { /* Sprites list */ UINT16 *s1 = spriteram16; UINT16 *end1 = spriteram16 + 0x02000/2; UINT16 *end2 = spriteram16 + 0x40000/2; UINT16 *s2; for ( ; s1 < end1; s1+=4 ) { int attr, code, color, num, sprite; int sx, x, xoffs, flipx, xnum, xstart, xend, xinc; int sy, y, yoffs, flipy, ynum, ystart, yend, yinc; int mode,global_depth,global_xnum,global_ynum; mode = s1[ 0 ]; sprite = s1[ 1 ]; xoffs = s1[ 2 ]; yoffs = s1[ 3 ]; /* Last sprite */ if (sprite & 0x8000) break; /* Single-sprite address */ s2 = &spriteram16[ (sprite & 0x7fff) * 4 ]; /* Every single sprite is offset by x & yoffs, and additionally by one of the 8 x & y offsets in the 1c0040-1c005f area */ xoffs += ssv_scroll[((mode & 0x00e0) >> 4) + 0x40/2]; yoffs += ssv_scroll[((mode & 0x00e0) >> 4) + 0x42/2]; /* Number of single-sprites (1-32) */ num = (mode & 0x001f) + 1; global_ynum = (mode & 0x0300) << 2; global_xnum = (mode & 0x0c00); global_depth = (mode & 0xf000); for( ; num > 0; num--,s2+=4 ) { int depth, local_depth, local_xnum, local_ynum; if (s2 >= end2) break; sx = s2[ 2 ]; sy = s2[ 3 ]; local_depth = sx & 0xf000; local_xnum = sx & 0x0c00; local_ynum = sy & 0x0c00; if (ssv_scroll[0x76/2] & 0x4000) { xnum = local_xnum; ynum = local_ynum; depth = local_depth; } else { xnum = global_xnum; ynum = global_ynum; depth = global_depth; } if ( s2[0] <= 7 && s2[1] == 0 && xnum == 0 && ynum == 0x0c00) { // Tilemap Sprite int scroll; scroll = s2[ 0 ]; // scroll index switch( ssv_scroll[0x7a/2] ) { case 0x4940: sy += 0x60; break; // srmp4 case 0x5940: sy -= 0x20; break; // drifto94, dynagear, eaglshot, keithlcy, mslider, stmblade case 0x5950: sy += 0xdf; break; // gdfs case 0x7940: sy -= 0x10; break; // ultrax, twineag2 } draw_row(machine, bitmap, cliprect, sx, sy, scroll); } else { // "Normal" Sprite /* hot spots: "warning" in hypreac2 has mode & 0x0100 and is not 16x16 keithlcy high scores has mode & 0x0100 and y & 0x0c00 can be 0x0c00 drifto94 "you have proved yOur".. has mode & 0x0100 and x & 0x0c00 can be 0x0c00 ultrax (begin of lev1): 100010: 6b60 4280 0016 00a0 121400: 51a0 0042 6800 0c00 needs to be a normal sprite */ int shadow, gfx; if (s2 >= end2) break; code = s2[0]; // code high bits attr = s2[1]; // code low bits + color /* Code's high bits are scrambled */ code += ssv_tile_code[(attr & 0x3c00)>>10]; flipy = (attr & 0x4000); flipx = (attr & 0x8000); color = attr; /* Select 256 or 64 color tiles */ gfx = (depth & 0x1000) ? 0 : 1; shadow = (depth & 0x8000); /* Single-sprite tile size */ xnum = 1 << (xnum >> 10); // 1, 2, 4 or 8 tiles ynum = 1 << (ynum >> 10); // 1, 2, 4 tiles (8 means tilemap sprite?) if (flipx) { xstart = xnum-1; xend = -1; xinc = -1; } else { xstart = 0; xend = xnum; xinc = +1; } if (flipy) { ystart = ynum-1; yend = -1; yinc = -1; } else { ystart = 0; yend = ynum; yinc = +1; } /* Apply global offsets */ sx += xoffs; sy += yoffs; /* Sign extend the position */ sx = (sx & 0x1ff) - (sx & 0x200); sy = (sy & 0x1ff) - (sy & 0x200); if (ssv_scroll[0x74/2] == 0x6500) // vasara sy = 0xe8 - sy; if (ssv_scroll[0x74/2] & 0x8000) // srmp7, twineag2, ultrax { if (ssv_scroll[0x76/2] & 0x4000) { // twineag2, ultrax sx = ssv_sprites_offsx + sx - (xnum-1) * 8; sy = ssv_sprites_offsy + sy - (ynum * 8) / 2; } else { // srmp7 sx = ssv_sprites_offsx + sx; sy = ssv_sprites_offsy + sy; } } else if (ssv_scroll[0x76/2] & 0x1000) // eaglshot { sx = ssv_sprites_offsx + sx - (xnum-1) * 8; sy = ssv_sprites_offsy - sy - (ynum * 8) / 2; // sy is the sprite center } else { sx = ssv_sprites_offsx + sx; sy = ssv_sprites_offsy - sy - (ynum-1) * 8; } /* Sprite code masking */ if(xnum == 2 && ynum == 4) // needed by hypreact { code &= ~7; } /* Draw the tiles */ for (x = xstart; x != xend; x += xinc) { for (y = ystart; y != yend; y += yinc) { ssv_drawgfx( bitmap, cliprect, machine->gfx[gfx], code++, color, flipx, flipy, sx + x * 16, sy + y * 8, shadow ); } } #ifdef MAME_DEBUG if (input_code_pressed(machine, KEYCODE_Z)) /* Display some info on each sprite */ { char buf[30]; sprintf(buf, "%02X",/*(s2[2] & ~0x3ff)>>8*/mode>>8); ui_draw_text(buf, sx, sy); } #endif } /* sprite type */ } /* single-sprites */ } /* sprites list */ }
/* Draw sprites in the sprites list */
Draw sprites in the sprites list
[ "Draw", "sprites", "in", "the", "sprites", "list" ]
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) { UINT16 *s1 = spriteram16; UINT16 *end1 = spriteram16 + 0x02000/2; UINT16 *end2 = spriteram16 + 0x40000/2; UINT16 *s2; for ( ; s1 < end1; s1+=4 ) { int attr, code, color, num, sprite; int sx, x, xoffs, flipx, xnum, xstart, xend, xinc; int sy, y, yoffs, flipy, ynum, ystart, yend, yinc; int mode,global_depth,global_xnum,global_ynum; mode = s1[ 0 ]; sprite = s1[ 1 ]; xoffs = s1[ 2 ]; yoffs = s1[ 3 ]; if (sprite & 0x8000) break; s2 = &spriteram16[ (sprite & 0x7fff) * 4 ]; xoffs += ssv_scroll[((mode & 0x00e0) >> 4) + 0x40/2]; yoffs += ssv_scroll[((mode & 0x00e0) >> 4) + 0x42/2]; num = (mode & 0x001f) + 1; global_ynum = (mode & 0x0300) << 2; global_xnum = (mode & 0x0c00); global_depth = (mode & 0xf000); for( ; num > 0; num--,s2+=4 ) { int depth, local_depth, local_xnum, local_ynum; if (s2 >= end2) break; sx = s2[ 2 ]; sy = s2[ 3 ]; local_depth = sx & 0xf000; local_xnum = sx & 0x0c00; local_ynum = sy & 0x0c00; if (ssv_scroll[0x76/2] & 0x4000) { xnum = local_xnum; ynum = local_ynum; depth = local_depth; } else { xnum = global_xnum; ynum = global_ynum; depth = global_depth; } if ( s2[0] <= 7 && s2[1] == 0 && xnum == 0 && ynum == 0x0c00) { int scroll; scroll = s2[ 0 ]; switch( ssv_scroll[0x7a/2] ) { case 0x4940: sy += 0x60; break; case 0x5940: sy -= 0x20; break; case 0x5950: sy += 0xdf; break; case 0x7940: sy -= 0x10; break; } draw_row(machine, bitmap, cliprect, sx, sy, scroll); } else { int shadow, gfx; if (s2 >= end2) break; code = s2[0]; attr = s2[1]; code += ssv_tile_code[(attr & 0x3c00)>>10]; flipy = (attr & 0x4000); flipx = (attr & 0x8000); color = attr; gfx = (depth & 0x1000) ? 0 : 1; shadow = (depth & 0x8000); xnum = 1 << (xnum >> 10); ynum = 1 << (ynum >> 10); if (flipx) { xstart = xnum-1; xend = -1; xinc = -1; } else { xstart = 0; xend = xnum; xinc = +1; } if (flipy) { ystart = ynum-1; yend = -1; yinc = -1; } else { ystart = 0; yend = ynum; yinc = +1; } sx += xoffs; sy += yoffs; sx = (sx & 0x1ff) - (sx & 0x200); sy = (sy & 0x1ff) - (sy & 0x200); if (ssv_scroll[0x74/2] == 0x6500) sy = 0xe8 - sy; if (ssv_scroll[0x74/2] & 0x8000) { if (ssv_scroll[0x76/2] & 0x4000) { sx = ssv_sprites_offsx + sx - (xnum-1) * 8; sy = ssv_sprites_offsy + sy - (ynum * 8) / 2; } else { sx = ssv_sprites_offsx + sx; sy = ssv_sprites_offsy + sy; } } else if (ssv_scroll[0x76/2] & 0x1000) { sx = ssv_sprites_offsx + sx - (xnum-1) * 8; sy = ssv_sprites_offsy - sy - (ynum * 8) / 2; } else { sx = ssv_sprites_offsx + sx; sy = ssv_sprites_offsy - sy - (ynum-1) * 8; } if(xnum == 2 && ynum == 4) { code &= ~7; } for (x = xstart; x != xend; x += xinc) { for (y = ystart; y != yend; y += yinc) { ssv_drawgfx( bitmap, cliprect, machine->gfx[gfx], code++, color, flipx, flipy, sx + x * 16, sy + y * 8, shadow ); } } #ifdef MAME_DEBUG if (input_code_pressed(machine, KEYCODE_Z)) { char buf[30]; sprintf(buf, "%02X",mode>>8); ui_draw_text(buf, sx, sy); } #endif } } } }
[ "static", "void", "draw_sprites", "(", "running_machine", "*", "machine", ",", "bitmap_t", "*", "bitmap", ",", "const", "rectangle", "*", "cliprect", ")", "{", "UINT16", "*", "s1", "=", "spriteram16", ";", "UINT16", "*", "end1", "=", "spriteram16", "+", "0x02000", "/", "2", ";", "UINT16", "*", "end2", "=", "spriteram16", "+", "0x40000", "/", "2", ";", "UINT16", "*", "s2", ";", "for", "(", ";", "s1", "<", "end1", ";", "s1", "+=", "4", ")", "{", "int", "attr", ",", "code", ",", "color", ",", "num", ",", "sprite", ";", "int", "sx", ",", "x", ",", "xoffs", ",", "flipx", ",", "xnum", ",", "xstart", ",", "xend", ",", "xinc", ";", "int", "sy", ",", "y", ",", "yoffs", ",", "flipy", ",", "ynum", ",", "ystart", ",", "yend", ",", "yinc", ";", "int", "mode", ",", "global_depth", ",", "global_xnum", ",", "global_ynum", ";", "mode", "=", "s1", "[", "0", "]", ";", "sprite", "=", "s1", "[", "1", "]", ";", "xoffs", "=", "s1", "[", "2", "]", ";", "yoffs", "=", "s1", "[", "3", "]", ";", "if", "(", "sprite", "&", "0x8000", ")", "break", ";", "s2", "=", "&", "spriteram16", "[", "(", "sprite", "&", "0x7fff", ")", "*", "4", "]", ";", "xoffs", "+=", "ssv_scroll", "[", "(", "(", "mode", "&", "0x00e0", ")", ">>", "4", ")", "+", "0x40", "/", "2", "]", ";", "yoffs", "+=", "ssv_scroll", "[", "(", "(", "mode", "&", "0x00e0", ")", ">>", "4", ")", "+", "0x42", "/", "2", "]", ";", "num", "=", "(", "mode", "&", "0x001f", ")", "+", "1", ";", "global_ynum", "=", "(", "mode", "&", "0x0300", ")", "<<", "2", ";", "global_xnum", "=", "(", "mode", "&", "0x0c00", ")", ";", "global_depth", "=", "(", "mode", "&", "0xf000", ")", ";", "for", "(", ";", "num", ">", "0", ";", "num", "--", ",", "s2", "+=", "4", ")", "{", "int", "depth", ",", "local_depth", ",", "local_xnum", ",", "local_ynum", ";", "if", "(", "s2", ">=", "end2", ")", "break", ";", "sx", "=", "s2", "[", "2", "]", ";", "sy", "=", "s2", "[", "3", "]", ";", "local_depth", "=", "sx", "&", "0xf000", ";", "local_xnum", "=", "sx", "&", "0x0c00", ";", "local_ynum", "=", "sy", "&", "0x0c00", ";", "if", "(", "ssv_scroll", "[", "0x76", "/", "2", "]", "&", "0x4000", ")", "{", "xnum", "=", "local_xnum", ";", "ynum", "=", "local_ynum", ";", "depth", "=", "local_depth", ";", "}", "else", "{", "xnum", "=", "global_xnum", ";", "ynum", "=", "global_ynum", ";", "depth", "=", "global_depth", ";", "}", "if", "(", "s2", "[", "0", "]", "<=", "7", "&&", "s2", "[", "1", "]", "==", "0", "&&", "xnum", "==", "0", "&&", "ynum", "==", "0x0c00", ")", "{", "int", "scroll", ";", "scroll", "=", "s2", "[", "0", "]", ";", "switch", "(", "ssv_scroll", "[", "0x7a", "/", "2", "]", ")", "{", "case", "0x4940", ":", "sy", "+=", "0x60", ";", "break", ";", "case", "0x5940", ":", "sy", "-=", "0x20", ";", "break", ";", "case", "0x5950", ":", "sy", "+=", "0xdf", ";", "break", ";", "case", "0x7940", ":", "sy", "-=", "0x10", ";", "break", ";", "}", "draw_row", "(", "machine", ",", "bitmap", ",", "cliprect", ",", "sx", ",", "sy", ",", "scroll", ")", ";", "}", "else", "{", "int", "shadow", ",", "gfx", ";", "if", "(", "s2", ">=", "end2", ")", "break", ";", "code", "=", "s2", "[", "0", "]", ";", "attr", "=", "s2", "[", "1", "]", ";", "code", "+=", "ssv_tile_code", "[", "(", "attr", "&", "0x3c00", ")", ">>", "10", "]", ";", "flipy", "=", "(", "attr", "&", "0x4000", ")", ";", "flipx", "=", "(", "attr", "&", "0x8000", ")", ";", "color", "=", "attr", ";", "gfx", "=", "(", "depth", "&", "0x1000", ")", "?", "0", ":", "1", ";", "shadow", "=", "(", "depth", "&", "0x8000", ")", ";", "xnum", "=", "1", "<<", "(", "xnum", ">>", "10", ")", ";", "ynum", "=", "1", "<<", "(", "ynum", ">>", "10", ")", ";", "if", "(", "flipx", ")", "{", "xstart", "=", "xnum", "-", "1", ";", "xend", "=", "-1", ";", "xinc", "=", "-1", ";", "}", "else", "{", "xstart", "=", "0", ";", "xend", "=", "xnum", ";", "xinc", "=", "+1", ";", "}", "if", "(", "flipy", ")", "{", "ystart", "=", "ynum", "-", "1", ";", "yend", "=", "-1", ";", "yinc", "=", "-1", ";", "}", "else", "{", "ystart", "=", "0", ";", "yend", "=", "ynum", ";", "yinc", "=", "+1", ";", "}", "sx", "+=", "xoffs", ";", "sy", "+=", "yoffs", ";", "sx", "=", "(", "sx", "&", "0x1ff", ")", "-", "(", "sx", "&", "0x200", ")", ";", "sy", "=", "(", "sy", "&", "0x1ff", ")", "-", "(", "sy", "&", "0x200", ")", ";", "if", "(", "ssv_scroll", "[", "0x74", "/", "2", "]", "==", "0x6500", ")", "sy", "=", "0xe8", "-", "sy", ";", "if", "(", "ssv_scroll", "[", "0x74", "/", "2", "]", "&", "0x8000", ")", "{", "if", "(", "ssv_scroll", "[", "0x76", "/", "2", "]", "&", "0x4000", ")", "{", "sx", "=", "ssv_sprites_offsx", "+", "sx", "-", "(", "xnum", "-", "1", ")", "*", "8", ";", "sy", "=", "ssv_sprites_offsy", "+", "sy", "-", "(", "ynum", "*", "8", ")", "/", "2", ";", "}", "else", "{", "sx", "=", "ssv_sprites_offsx", "+", "sx", ";", "sy", "=", "ssv_sprites_offsy", "+", "sy", ";", "}", "}", "else", "if", "(", "ssv_scroll", "[", "0x76", "/", "2", "]", "&", "0x1000", ")", "{", "sx", "=", "ssv_sprites_offsx", "+", "sx", "-", "(", "xnum", "-", "1", ")", "*", "8", ";", "sy", "=", "ssv_sprites_offsy", "-", "sy", "-", "(", "ynum", "*", "8", ")", "/", "2", ";", "}", "else", "{", "sx", "=", "ssv_sprites_offsx", "+", "sx", ";", "sy", "=", "ssv_sprites_offsy", "-", "sy", "-", "(", "ynum", "-", "1", ")", "*", "8", ";", "}", "if", "(", "xnum", "==", "2", "&&", "ynum", "==", "4", ")", "{", "code", "&=", "~", "7", ";", "}", "for", "(", "x", "=", "xstart", ";", "x", "!=", "xend", ";", "x", "+=", "xinc", ")", "{", "for", "(", "y", "=", "ystart", ";", "y", "!=", "yend", ";", "y", "+=", "yinc", ")", "{", "ssv_drawgfx", "(", "bitmap", ",", "cliprect", ",", "machine", "->", "gfx", "[", "gfx", "]", ",", "code", "++", ",", "color", ",", "flipx", ",", "flipy", ",", "sx", "+", "x", "*", "16", ",", "sy", "+", "y", "*", "8", ",", "shadow", ")", ";", "}", "}", "#ifdef", "MAME_DEBUG", "if", "(", "input_code_pressed", "(", "machine", ",", "KEYCODE_Z", ")", ")", "{", "char", "buf", "[", "30", "]", ";", "sprintf", "(", "buf", ",", "\"", "\"", ",", "mode", ">>", "8", ")", ";", "ui_draw_text", "(", "buf", ",", "sx", ",", "sy", ")", ";", "}", "#endif", "}", "}", "}", "}" ]
Draw sprites in the sprites list
[ "Draw", "sprites", "in", "the", "sprites", "list" ]
[ "/* Sprites list */", "/* Last sprite */", "/* Single-sprite address */", "/* Every single sprite is offset by x & yoffs, and additionally\n by one of the 8 x & y offsets in the 1c0040-1c005f area */", "/* Number of single-sprites (1-32) */", "// Tilemap Sprite", "// scroll index", "// srmp4", "// drifto94, dynagear, eaglshot, keithlcy, mslider, stmblade", "// gdfs", "// ultrax, twineag2", "// \"Normal\" Sprite", "/*\n hot spots:\n \"warning\" in hypreac2 has mode & 0x0100 and is not 16x16\n keithlcy high scores has mode & 0x0100 and y & 0x0c00 can be 0x0c00\n drifto94 \"you have proved yOur\".. has mode & 0x0100 and x & 0x0c00 can be 0x0c00\n ultrax (begin of lev1): 100010: 6b60 4280 0016 00a0\n 121400: 51a0 0042 6800 0c00 needs to be a normal sprite\n*/", "// code high bits", "// code low bits + color", "/* Code's high bits are scrambled */", "/* Select 256 or 64 color tiles */", "/* Single-sprite tile size */", "// 1, 2, 4 or 8 tiles", "// 1, 2, 4 tiles (8 means tilemap sprite?)", "/* Apply global offsets */", "/* Sign extend the position */", "// vasara", "// srmp7, twineag2, ultrax", "// twineag2, ultrax", "// srmp7", "// eaglshot", "// sy is the sprite center", "/* Sprite code masking */", "// needed by hypreact", "/* Draw the tiles */", "/* Display some info on each sprite */", "/*(s2[2] & ~0x3ff)>>8*/", "/* sprite type */", "/* single-sprites */", "/* sprites list */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "bitmap", "type": "bitmap_t" }, { "param": "cliprect", "type": "rectangle" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bitmap", "type": "bitmap_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cliprect", "type": "rectangle", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7de0cf1d6543dbb0ca390ae3d1e7188461c85b34
lofunz/mieme
Reloaded/trunk/src/mame/video/homedata.c
[ "Unlicense" ]
C
mrokumei_handleblit
void
static void mrokumei_handleblit( const address_space *space, int rom_base ) { homedata_state *state = space->machine->driver_data<homedata_state>(); int i; int dest_param; int source_addr; int dest_addr; int base_addr; int opcode, data, num_tiles; UINT8 *pBlitData = memory_region(space->machine, "user1") + rom_base; dest_param = state->blitter_param[(state->blitter_param_count - 4) & 3] * 256 + state->blitter_param[(state->blitter_param_count - 3) & 3]; source_addr = state->blitter_param[(state->blitter_param_count - 2) & 3] * 256 + state->blitter_param[(state->blitter_param_count - 1) & 3]; /* xxx-.----.----.---- not used? * ---x.----.----.---- layer * ----.xxxx.xxxx.xxxx addr */ base_addr= (dest_param & 0x1000); dest_addr= (dest_param & 0x0fff); // logerror( "[blit bank %02x src %04x dst %04x]\n", blitter_bank, source_addr, dest_param); if( state->visible_page == 0 ) { base_addr += 0x2000; } for(;;) { opcode = pBlitData[source_addr++]; /* 00xxxxxx RLE incrementing * 01xxxxxx Raw Run * 1xxxxxxx RLE constant data */ if( opcode == 0x00 ) { /* end-of-graphic */ goto finish; } data = pBlitData[source_addr++]; if (opcode & 0x80) num_tiles = 0x80 - (opcode & 0x7f); else num_tiles = 0x40 - (opcode & 0x3f); for (i = 0; i < num_tiles; i++) { if (i != 0) { switch (opcode & 0xc0) { case 0x40: // Raw Run data = pBlitData[source_addr++]; break; case 0x00: // RLE incrementing data++; break; } } /* i!=0 */ if (data) /* 00 is a nop */ mrokumei_videoram_w(space, base_addr + dest_addr, data); if (state->vreg[1] & 0x80) /* flip screen */ { dest_addr -= 2; if (dest_addr < 0) goto finish; } else { dest_addr+=2; if (dest_addr >= 0x1000) goto finish; } } /* for( i=0; i<num_tiles; i++ ) */ } /* for(;;) */ finish: cpu_set_input_line(state->maincpu, M6809_FIRQ_LINE, HOLD_LINE); }
/*************************************************************************** Blitter This is probably work done by the GX61A01 custom chip found on all boards, however the way it works is not exactly the same in all games. ***************************************************************************/
Blitter This is probably work done by the GX61A01 custom chip found on all boards, however the way it works is not exactly the same in all games.
[ "Blitter", "This", "is", "probably", "work", "done", "by", "the", "GX61A01", "custom", "chip", "found", "on", "all", "boards", "however", "the", "way", "it", "works", "is", "not", "exactly", "the", "same", "in", "all", "games", "." ]
static void mrokumei_handleblit( const address_space *space, int rom_base ) { homedata_state *state = space->machine->driver_data<homedata_state>(); int i; int dest_param; int source_addr; int dest_addr; int base_addr; int opcode, data, num_tiles; UINT8 *pBlitData = memory_region(space->machine, "user1") + rom_base; dest_param = state->blitter_param[(state->blitter_param_count - 4) & 3] * 256 + state->blitter_param[(state->blitter_param_count - 3) & 3]; source_addr = state->blitter_param[(state->blitter_param_count - 2) & 3] * 256 + state->blitter_param[(state->blitter_param_count - 1) & 3]; base_addr= (dest_param & 0x1000); dest_addr= (dest_param & 0x0fff); if( state->visible_page == 0 ) { base_addr += 0x2000; } for(;;) { opcode = pBlitData[source_addr++]; if( opcode == 0x00 ) { goto finish; } data = pBlitData[source_addr++]; if (opcode & 0x80) num_tiles = 0x80 - (opcode & 0x7f); else num_tiles = 0x40 - (opcode & 0x3f); for (i = 0; i < num_tiles; i++) { if (i != 0) { switch (opcode & 0xc0) { case 0x40: data = pBlitData[source_addr++]; break; case 0x00: data++; break; } } if (data) mrokumei_videoram_w(space, base_addr + dest_addr, data); if (state->vreg[1] & 0x80) { dest_addr -= 2; if (dest_addr < 0) goto finish; } else { dest_addr+=2; if (dest_addr >= 0x1000) goto finish; } } } finish: cpu_set_input_line(state->maincpu, M6809_FIRQ_LINE, HOLD_LINE); }
[ "static", "void", "mrokumei_handleblit", "(", "const", "address_space", "*", "space", ",", "int", "rom_base", ")", "{", "homedata_state", "*", "state", "=", "space", "->", "machine", "->", "driver_data", "<", "homedata_state", ">", "(", "", ")", ";", "int", "i", ";", "int", "dest_param", ";", "int", "source_addr", ";", "int", "dest_addr", ";", "int", "base_addr", ";", "int", "opcode", ",", "data", ",", "num_tiles", ";", "UINT8", "*", "pBlitData", "=", "memory_region", "(", "space", "->", "machine", ",", "\"", "\"", ")", "+", "rom_base", ";", "dest_param", "=", "state", "->", "blitter_param", "[", "(", "state", "->", "blitter_param_count", "-", "4", ")", "&", "3", "]", "*", "256", "+", "state", "->", "blitter_param", "[", "(", "state", "->", "blitter_param_count", "-", "3", ")", "&", "3", "]", ";", "source_addr", "=", "state", "->", "blitter_param", "[", "(", "state", "->", "blitter_param_count", "-", "2", ")", "&", "3", "]", "*", "256", "+", "state", "->", "blitter_param", "[", "(", "state", "->", "blitter_param_count", "-", "1", ")", "&", "3", "]", ";", "base_addr", "=", "(", "dest_param", "&", "0x1000", ")", ";", "dest_addr", "=", "(", "dest_param", "&", "0x0fff", ")", ";", "if", "(", "state", "->", "visible_page", "==", "0", ")", "{", "base_addr", "+=", "0x2000", ";", "}", "for", "(", ";", ";", ")", "{", "opcode", "=", "pBlitData", "[", "source_addr", "++", "]", ";", "if", "(", "opcode", "==", "0x00", ")", "{", "goto", "finish", ";", "}", "data", "=", "pBlitData", "[", "source_addr", "++", "]", ";", "if", "(", "opcode", "&", "0x80", ")", "num_tiles", "=", "0x80", "-", "(", "opcode", "&", "0x7f", ")", ";", "else", "num_tiles", "=", "0x40", "-", "(", "opcode", "&", "0x3f", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "num_tiles", ";", "i", "++", ")", "{", "if", "(", "i", "!=", "0", ")", "{", "switch", "(", "opcode", "&", "0xc0", ")", "{", "case", "0x40", ":", "data", "=", "pBlitData", "[", "source_addr", "++", "]", ";", "break", ";", "case", "0x00", ":", "data", "++", ";", "break", ";", "}", "}", "if", "(", "data", ")", "mrokumei_videoram_w", "(", "space", ",", "base_addr", "+", "dest_addr", ",", "data", ")", ";", "if", "(", "state", "->", "vreg", "[", "1", "]", "&", "0x80", ")", "{", "dest_addr", "-=", "2", ";", "if", "(", "dest_addr", "<", "0", ")", "goto", "finish", ";", "}", "else", "{", "dest_addr", "+=", "2", ";", "if", "(", "dest_addr", ">=", "0x1000", ")", "goto", "finish", ";", "}", "}", "}", "finish", ":", "cpu_set_input_line", "(", "state", "->", "maincpu", ",", "M6809_FIRQ_LINE", ",", "HOLD_LINE", ")", ";", "}" ]
Blitter This is probably work done by the GX61A01 custom chip found on all boards, however the way it works is not exactly the same in all games.
[ "Blitter", "This", "is", "probably", "work", "done", "by", "the", "GX61A01", "custom", "chip", "found", "on", "all", "boards", "however", "the", "way", "it", "works", "is", "not", "exactly", "the", "same", "in", "all", "games", "." ]
[ "/* xxx-.----.----.---- not used?\r\n * ---x.----.----.---- layer\r\n * ----.xxxx.xxxx.xxxx addr\r\n */", "// logerror( \"[blit bank %02x src %04x dst %04x]\\n\", blitter_bank, source_addr, dest_param);\r", "/* 00xxxxxx RLE incrementing\r\n * 01xxxxxx Raw Run\r\n * 1xxxxxxx RLE constant data\r\n */", "/* end-of-graphic */", "// Raw Run\r", "// RLE incrementing\r", "/* i!=0 */", "/* 00 is a nop */", "/* flip screen */", "/* for( i=0; i<num_tiles; i++ ) */", "/* for(;;) */" ]
[ { "param": "space", "type": "address_space" }, { "param": "rom_base", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "space", "type": "address_space", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rom_base", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f08d4faea9078af6cfe316fec86d7cdea6e9e3ab
lofunz/mieme
Reloaded/trunk/src/emu/render.c
[ "Unlicense" ]
C
render_init
void
void render_init(running_machine *machine) { render_container **current_container_ptr = &screen_container_list; /* make sure we clean up after ourselves */ machine->add_notifier(MACHINE_NOTIFY_EXIT, render_exit); /* set up the list of render targets */ targetlist = NULL; /* zap the free lists */ render_primitive_free_list = NULL; container_item_free_list = NULL; /* zap more variables */ ui_target = NULL; /* create a UI container */ ui_container = render_container_alloc(machine); /* create a container for each screen and determine its orientation */ for (screen_device *screendev = screen_first(*machine); screendev != NULL; screendev = screen_next(screendev)) { render_container *screen_container = render_container_alloc(machine); render_container **temp = &screen_container->next; render_container_user_settings settings; /* set the initial orientation and brightness/contrast/gamma */ render_container_get_user_settings(screen_container, &settings); settings.orientation = machine->gamedrv->flags & ORIENTATION_MASK; settings.brightness = options_get_float(machine->options(), OPTION_BRIGHTNESS); settings.contrast = options_get_float(machine->options(), OPTION_CONTRAST); settings.gamma = options_get_float(machine->options(), OPTION_GAMMA); render_container_set_user_settings(screen_container, &settings); screen_container->screen = screendev; /* link it up */ *current_container_ptr = screen_container; current_container_ptr = temp; } /* terminate list */ *current_container_ptr = NULL; /* register callbacks */ config_register(machine, "video", render_load, render_save); }
/*------------------------------------------------- render_init - allocate base structures for the rendering system -------------------------------------------------*/
allocate base structures for the rendering system
[ "allocate", "base", "structures", "for", "the", "rendering", "system" ]
void render_init(running_machine *machine) { render_container **current_container_ptr = &screen_container_list; machine->add_notifier(MACHINE_NOTIFY_EXIT, render_exit); targetlist = NULL; render_primitive_free_list = NULL; container_item_free_list = NULL; ui_target = NULL; ui_container = render_container_alloc(machine); for (screen_device *screendev = screen_first(*machine); screendev != NULL; screendev = screen_next(screendev)) { render_container *screen_container = render_container_alloc(machine); render_container **temp = &screen_container->next; render_container_user_settings settings; render_container_get_user_settings(screen_container, &settings); settings.orientation = machine->gamedrv->flags & ORIENTATION_MASK; settings.brightness = options_get_float(machine->options(), OPTION_BRIGHTNESS); settings.contrast = options_get_float(machine->options(), OPTION_CONTRAST); settings.gamma = options_get_float(machine->options(), OPTION_GAMMA); render_container_set_user_settings(screen_container, &settings); screen_container->screen = screendev; *current_container_ptr = screen_container; current_container_ptr = temp; } *current_container_ptr = NULL; config_register(machine, "video", render_load, render_save); }
[ "void", "render_init", "(", "running_machine", "*", "machine", ")", "{", "render_container", "*", "*", "current_container_ptr", "=", "&", "screen_container_list", ";", "machine", "->", "add_notifier", "(", "MACHINE_NOTIFY_EXIT", ",", "render_exit", ")", ";", "targetlist", "=", "NULL", ";", "render_primitive_free_list", "=", "NULL", ";", "container_item_free_list", "=", "NULL", ";", "ui_target", "=", "NULL", ";", "ui_container", "=", "render_container_alloc", "(", "machine", ")", ";", "for", "(", "screen_device", "*", "screendev", "=", "screen_first", "(", "*", "machine", ")", ";", "screendev", "!=", "NULL", ";", "screendev", "=", "screen_next", "(", "screendev", ")", ")", "{", "render_container", "*", "screen_container", "=", "render_container_alloc", "(", "machine", ")", ";", "render_container", "*", "*", "temp", "=", "&", "screen_container", "->", "next", ";", "render_container_user_settings", "settings", ";", "render_container_get_user_settings", "(", "screen_container", ",", "&", "settings", ")", ";", "settings", ".", "orientation", "=", "machine", "->", "gamedrv", "->", "flags", "&", "ORIENTATION_MASK", ";", "settings", ".", "brightness", "=", "options_get_float", "(", "machine", "->", "options", "(", ")", ",", "OPTION_BRIGHTNESS", ")", ";", "settings", ".", "contrast", "=", "options_get_float", "(", "machine", "->", "options", "(", ")", ",", "OPTION_CONTRAST", ")", ";", "settings", ".", "gamma", "=", "options_get_float", "(", "machine", "->", "options", "(", ")", ",", "OPTION_GAMMA", ")", ";", "render_container_set_user_settings", "(", "screen_container", ",", "&", "settings", ")", ";", "screen_container", "->", "screen", "=", "screendev", ";", "*", "current_container_ptr", "=", "screen_container", ";", "current_container_ptr", "=", "temp", ";", "}", "*", "current_container_ptr", "=", "NULL", ";", "config_register", "(", "machine", ",", "\"", "\"", ",", "render_load", ",", "render_save", ")", ";", "}" ]
render_init - allocate base structures for the rendering system
[ "render_init", "-", "allocate", "base", "structures", "for", "the", "rendering", "system" ]
[ "/* make sure we clean up after ourselves */", "/* set up the list of render targets */", "/* zap the free lists */", "/* zap more variables */", "/* create a UI container */", "/* create a container for each screen and determine its orientation */", "/* set the initial orientation and brightness/contrast/gamma */", "/* link it up */", "/* terminate list */", "/* register callbacks */" ]
[ { "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": [] }
f08d4faea9078af6cfe316fec86d7cdea6e9e3ab
lofunz/mieme
Reloaded/trunk/src/emu/render.c
[ "Unlicense" ]
C
render_load
void
static void render_load(running_machine *machine, int config_type, xml_data_node *parentnode) { xml_data_node *targetnode; xml_data_node *screennode; xml_data_node *uinode; int tmpint; /* we only care about game files */ if (config_type != CONFIG_TYPE_GAME) return; /* might not have any data */ if (parentnode == NULL) return; /* check the UI target */ uinode = xml_get_sibling(parentnode->child, "interface"); if (uinode != NULL) { render_target *target = render_target_get_indexed(xml_get_attribute_int(uinode, "target", 0)); if (target != NULL) render_set_ui_target(target); } /* iterate over target nodes */ for (targetnode = xml_get_sibling(parentnode->child, "target"); targetnode; targetnode = xml_get_sibling(targetnode->next, "target")) { render_target *target = render_target_get_indexed(xml_get_attribute_int(targetnode, "index", -1)); if (target != NULL) { const char *viewname = xml_get_attribute_string(targetnode, "view", NULL); int viewnum; /* find the view */ if (viewname != NULL) for (viewnum = 0; viewnum < 1000; viewnum++) { const char *testname = render_target_get_view_name(target, viewnum); if (testname == NULL) break; if (!strcmp(viewname, testname)) { render_target_set_view(target, viewnum); break; } } /* modify the artwork config */ tmpint = xml_get_attribute_int(targetnode, "backdrops", -1); if (tmpint == 0) render_target_set_layer_config(target, target->layerconfig & ~LAYER_CONFIG_ENABLE_BACKDROP); else if (tmpint == 1) render_target_set_layer_config(target, target->layerconfig | LAYER_CONFIG_ENABLE_BACKDROP); tmpint = xml_get_attribute_int(targetnode, "overlays", -1); if (tmpint == 0) render_target_set_layer_config(target, target->layerconfig & ~LAYER_CONFIG_ENABLE_OVERLAY); else if (tmpint == 1) render_target_set_layer_config(target, target->layerconfig | LAYER_CONFIG_ENABLE_OVERLAY); tmpint = xml_get_attribute_int(targetnode, "bezels", -1); if (tmpint == 0) render_target_set_layer_config(target, target->layerconfig & ~LAYER_CONFIG_ENABLE_BEZEL); else if (tmpint == 1) render_target_set_layer_config(target, target->layerconfig | LAYER_CONFIG_ENABLE_BEZEL); tmpint = xml_get_attribute_int(targetnode, "zoom", -1); if (tmpint == 0) render_target_set_layer_config(target, target->layerconfig & ~LAYER_CONFIG_ZOOM_TO_SCREEN); else if (tmpint == 1) render_target_set_layer_config(target, target->layerconfig | LAYER_CONFIG_ZOOM_TO_SCREEN); /* apply orientation */ tmpint = xml_get_attribute_int(targetnode, "rotate", -1); if (tmpint != -1) { if (tmpint == 90) tmpint = ROT90; else if (tmpint == 180) tmpint = ROT180; else if (tmpint == 270) tmpint = ROT270; else tmpint = ROT0; render_target_set_orientation(target, orientation_add(tmpint, target->orientation)); /* apply the opposite orientation to the UI */ if (target == render_get_ui_target()) { render_container_user_settings settings; render_container_get_user_settings(ui_container, &settings); settings.orientation = orientation_add(orientation_reverse(tmpint), settings.orientation); render_container_set_user_settings(ui_container, &settings); } } } } /* iterate over screen nodes */ for (screennode = xml_get_sibling(parentnode->child, "screen"); screennode; screennode = xml_get_sibling(screennode->next, "screen")) { int index = xml_get_attribute_int(screennode, "index", -1); render_container *container = get_screen_container_by_index(index); render_container_user_settings settings; /* fetch current settings */ render_container_get_user_settings(container, &settings); /* fetch color controls */ settings.brightness = xml_get_attribute_float(screennode, "brightness", settings.brightness); settings.contrast = xml_get_attribute_float(screennode, "contrast", settings.contrast); settings.gamma = xml_get_attribute_float(screennode, "gamma", settings.gamma); /* fetch positioning controls */ settings.xoffset = xml_get_attribute_float(screennode, "hoffset", settings.xoffset); settings.xscale = xml_get_attribute_float(screennode, "hstretch", settings.xscale); settings.yoffset = xml_get_attribute_float(screennode, "voffset", settings.yoffset); settings.yscale = xml_get_attribute_float(screennode, "vstretch", settings.yscale); /* set the new values */ render_container_set_user_settings(container, &settings); } }
/*------------------------------------------------- render_load - read and apply data from the configuration file -------------------------------------------------*/
read and apply data from the configuration file
[ "read", "and", "apply", "data", "from", "the", "configuration", "file" ]
static void render_load(running_machine *machine, int config_type, xml_data_node *parentnode) { xml_data_node *targetnode; xml_data_node *screennode; xml_data_node *uinode; int tmpint; if (config_type != CONFIG_TYPE_GAME) return; if (parentnode == NULL) return; uinode = xml_get_sibling(parentnode->child, "interface"); if (uinode != NULL) { render_target *target = render_target_get_indexed(xml_get_attribute_int(uinode, "target", 0)); if (target != NULL) render_set_ui_target(target); } for (targetnode = xml_get_sibling(parentnode->child, "target"); targetnode; targetnode = xml_get_sibling(targetnode->next, "target")) { render_target *target = render_target_get_indexed(xml_get_attribute_int(targetnode, "index", -1)); if (target != NULL) { const char *viewname = xml_get_attribute_string(targetnode, "view", NULL); int viewnum; if (viewname != NULL) for (viewnum = 0; viewnum < 1000; viewnum++) { const char *testname = render_target_get_view_name(target, viewnum); if (testname == NULL) break; if (!strcmp(viewname, testname)) { render_target_set_view(target, viewnum); break; } } tmpint = xml_get_attribute_int(targetnode, "backdrops", -1); if (tmpint == 0) render_target_set_layer_config(target, target->layerconfig & ~LAYER_CONFIG_ENABLE_BACKDROP); else if (tmpint == 1) render_target_set_layer_config(target, target->layerconfig | LAYER_CONFIG_ENABLE_BACKDROP); tmpint = xml_get_attribute_int(targetnode, "overlays", -1); if (tmpint == 0) render_target_set_layer_config(target, target->layerconfig & ~LAYER_CONFIG_ENABLE_OVERLAY); else if (tmpint == 1) render_target_set_layer_config(target, target->layerconfig | LAYER_CONFIG_ENABLE_OVERLAY); tmpint = xml_get_attribute_int(targetnode, "bezels", -1); if (tmpint == 0) render_target_set_layer_config(target, target->layerconfig & ~LAYER_CONFIG_ENABLE_BEZEL); else if (tmpint == 1) render_target_set_layer_config(target, target->layerconfig | LAYER_CONFIG_ENABLE_BEZEL); tmpint = xml_get_attribute_int(targetnode, "zoom", -1); if (tmpint == 0) render_target_set_layer_config(target, target->layerconfig & ~LAYER_CONFIG_ZOOM_TO_SCREEN); else if (tmpint == 1) render_target_set_layer_config(target, target->layerconfig | LAYER_CONFIG_ZOOM_TO_SCREEN); tmpint = xml_get_attribute_int(targetnode, "rotate", -1); if (tmpint != -1) { if (tmpint == 90) tmpint = ROT90; else if (tmpint == 180) tmpint = ROT180; else if (tmpint == 270) tmpint = ROT270; else tmpint = ROT0; render_target_set_orientation(target, orientation_add(tmpint, target->orientation)); if (target == render_get_ui_target()) { render_container_user_settings settings; render_container_get_user_settings(ui_container, &settings); settings.orientation = orientation_add(orientation_reverse(tmpint), settings.orientation); render_container_set_user_settings(ui_container, &settings); } } } } for (screennode = xml_get_sibling(parentnode->child, "screen"); screennode; screennode = xml_get_sibling(screennode->next, "screen")) { int index = xml_get_attribute_int(screennode, "index", -1); render_container *container = get_screen_container_by_index(index); render_container_user_settings settings; render_container_get_user_settings(container, &settings); settings.brightness = xml_get_attribute_float(screennode, "brightness", settings.brightness); settings.contrast = xml_get_attribute_float(screennode, "contrast", settings.contrast); settings.gamma = xml_get_attribute_float(screennode, "gamma", settings.gamma); settings.xoffset = xml_get_attribute_float(screennode, "hoffset", settings.xoffset); settings.xscale = xml_get_attribute_float(screennode, "hstretch", settings.xscale); settings.yoffset = xml_get_attribute_float(screennode, "voffset", settings.yoffset); settings.yscale = xml_get_attribute_float(screennode, "vstretch", settings.yscale); render_container_set_user_settings(container, &settings); } }
[ "static", "void", "render_load", "(", "running_machine", "*", "machine", ",", "int", "config_type", ",", "xml_data_node", "*", "parentnode", ")", "{", "xml_data_node", "*", "targetnode", ";", "xml_data_node", "*", "screennode", ";", "xml_data_node", "*", "uinode", ";", "int", "tmpint", ";", "if", "(", "config_type", "!=", "CONFIG_TYPE_GAME", ")", "return", ";", "if", "(", "parentnode", "==", "NULL", ")", "return", ";", "uinode", "=", "xml_get_sibling", "(", "parentnode", "->", "child", ",", "\"", "\"", ")", ";", "if", "(", "uinode", "!=", "NULL", ")", "{", "render_target", "*", "target", "=", "render_target_get_indexed", "(", "xml_get_attribute_int", "(", "uinode", ",", "\"", "\"", ",", "0", ")", ")", ";", "if", "(", "target", "!=", "NULL", ")", "render_set_ui_target", "(", "target", ")", ";", "}", "for", "(", "targetnode", "=", "xml_get_sibling", "(", "parentnode", "->", "child", ",", "\"", "\"", ")", ";", "targetnode", ";", "targetnode", "=", "xml_get_sibling", "(", "targetnode", "->", "next", ",", "\"", "\"", ")", ")", "{", "render_target", "*", "target", "=", "render_target_get_indexed", "(", "xml_get_attribute_int", "(", "targetnode", ",", "\"", "\"", ",", "-1", ")", ")", ";", "if", "(", "target", "!=", "NULL", ")", "{", "const", "char", "*", "viewname", "=", "xml_get_attribute_string", "(", "targetnode", ",", "\"", "\"", ",", "NULL", ")", ";", "int", "viewnum", ";", "if", "(", "viewname", "!=", "NULL", ")", "for", "(", "viewnum", "=", "0", ";", "viewnum", "<", "1000", ";", "viewnum", "++", ")", "{", "const", "char", "*", "testname", "=", "render_target_get_view_name", "(", "target", ",", "viewnum", ")", ";", "if", "(", "testname", "==", "NULL", ")", "break", ";", "if", "(", "!", "strcmp", "(", "viewname", ",", "testname", ")", ")", "{", "render_target_set_view", "(", "target", ",", "viewnum", ")", ";", "break", ";", "}", "}", "tmpint", "=", "xml_get_attribute_int", "(", "targetnode", ",", "\"", "\"", ",", "-1", ")", ";", "if", "(", "tmpint", "==", "0", ")", "render_target_set_layer_config", "(", "target", ",", "target", "->", "layerconfig", "&", "~", "LAYER_CONFIG_ENABLE_BACKDROP", ")", ";", "else", "if", "(", "tmpint", "==", "1", ")", "render_target_set_layer_config", "(", "target", ",", "target", "->", "layerconfig", "|", "LAYER_CONFIG_ENABLE_BACKDROP", ")", ";", "tmpint", "=", "xml_get_attribute_int", "(", "targetnode", ",", "\"", "\"", ",", "-1", ")", ";", "if", "(", "tmpint", "==", "0", ")", "render_target_set_layer_config", "(", "target", ",", "target", "->", "layerconfig", "&", "~", "LAYER_CONFIG_ENABLE_OVERLAY", ")", ";", "else", "if", "(", "tmpint", "==", "1", ")", "render_target_set_layer_config", "(", "target", ",", "target", "->", "layerconfig", "|", "LAYER_CONFIG_ENABLE_OVERLAY", ")", ";", "tmpint", "=", "xml_get_attribute_int", "(", "targetnode", ",", "\"", "\"", ",", "-1", ")", ";", "if", "(", "tmpint", "==", "0", ")", "render_target_set_layer_config", "(", "target", ",", "target", "->", "layerconfig", "&", "~", "LAYER_CONFIG_ENABLE_BEZEL", ")", ";", "else", "if", "(", "tmpint", "==", "1", ")", "render_target_set_layer_config", "(", "target", ",", "target", "->", "layerconfig", "|", "LAYER_CONFIG_ENABLE_BEZEL", ")", ";", "tmpint", "=", "xml_get_attribute_int", "(", "targetnode", ",", "\"", "\"", ",", "-1", ")", ";", "if", "(", "tmpint", "==", "0", ")", "render_target_set_layer_config", "(", "target", ",", "target", "->", "layerconfig", "&", "~", "LAYER_CONFIG_ZOOM_TO_SCREEN", ")", ";", "else", "if", "(", "tmpint", "==", "1", ")", "render_target_set_layer_config", "(", "target", ",", "target", "->", "layerconfig", "|", "LAYER_CONFIG_ZOOM_TO_SCREEN", ")", ";", "tmpint", "=", "xml_get_attribute_int", "(", "targetnode", ",", "\"", "\"", ",", "-1", ")", ";", "if", "(", "tmpint", "!=", "-1", ")", "{", "if", "(", "tmpint", "==", "90", ")", "tmpint", "=", "ROT90", ";", "else", "if", "(", "tmpint", "==", "180", ")", "tmpint", "=", "ROT180", ";", "else", "if", "(", "tmpint", "==", "270", ")", "tmpint", "=", "ROT270", ";", "else", "tmpint", "=", "ROT0", ";", "render_target_set_orientation", "(", "target", ",", "orientation_add", "(", "tmpint", ",", "target", "->", "orientation", ")", ")", ";", "if", "(", "target", "==", "render_get_ui_target", "(", ")", ")", "{", "render_container_user_settings", "settings", ";", "render_container_get_user_settings", "(", "ui_container", ",", "&", "settings", ")", ";", "settings", ".", "orientation", "=", "orientation_add", "(", "orientation_reverse", "(", "tmpint", ")", ",", "settings", ".", "orientation", ")", ";", "render_container_set_user_settings", "(", "ui_container", ",", "&", "settings", ")", ";", "}", "}", "}", "}", "for", "(", "screennode", "=", "xml_get_sibling", "(", "parentnode", "->", "child", ",", "\"", "\"", ")", ";", "screennode", ";", "screennode", "=", "xml_get_sibling", "(", "screennode", "->", "next", ",", "\"", "\"", ")", ")", "{", "int", "index", "=", "xml_get_attribute_int", "(", "screennode", ",", "\"", "\"", ",", "-1", ")", ";", "render_container", "*", "container", "=", "get_screen_container_by_index", "(", "index", ")", ";", "render_container_user_settings", "settings", ";", "render_container_get_user_settings", "(", "container", ",", "&", "settings", ")", ";", "settings", ".", "brightness", "=", "xml_get_attribute_float", "(", "screennode", ",", "\"", "\"", ",", "settings", ".", "brightness", ")", ";", "settings", ".", "contrast", "=", "xml_get_attribute_float", "(", "screennode", ",", "\"", "\"", ",", "settings", ".", "contrast", ")", ";", "settings", ".", "gamma", "=", "xml_get_attribute_float", "(", "screennode", ",", "\"", "\"", ",", "settings", ".", "gamma", ")", ";", "settings", ".", "xoffset", "=", "xml_get_attribute_float", "(", "screennode", ",", "\"", "\"", ",", "settings", ".", "xoffset", ")", ";", "settings", ".", "xscale", "=", "xml_get_attribute_float", "(", "screennode", ",", "\"", "\"", ",", "settings", ".", "xscale", ")", ";", "settings", ".", "yoffset", "=", "xml_get_attribute_float", "(", "screennode", ",", "\"", "\"", ",", "settings", ".", "yoffset", ")", ";", "settings", ".", "yscale", "=", "xml_get_attribute_float", "(", "screennode", ",", "\"", "\"", ",", "settings", ".", "yscale", ")", ";", "render_container_set_user_settings", "(", "container", ",", "&", "settings", ")", ";", "}", "}" ]
render_load - read and apply data from the configuration file
[ "render_load", "-", "read", "and", "apply", "data", "from", "the", "configuration", "file" ]
[ "/* we only care about game files */", "/* might not have any data */", "/* check the UI target */", "/* iterate over target nodes */", "/* find the view */", "/* modify the artwork config */", "/* apply orientation */", "/* apply the opposite orientation to the UI */", "/* iterate over screen nodes */", "/* fetch current settings */", "/* fetch color controls */", "/* fetch positioning controls */", "/* set the new values */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "config_type", "type": "int" }, { "param": "parentnode", "type": "xml_data_node" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "config_type", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "parentnode", "type": "xml_data_node", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f08d4faea9078af6cfe316fec86d7cdea6e9e3ab
lofunz/mieme
Reloaded/trunk/src/emu/render.c
[ "Unlicense" ]
C
render_save
void
static void render_save(running_machine *machine, int config_type, xml_data_node *parentnode) { render_target *target; render_container *container; int scrnum; int targetnum = 0; /* we only care about game files */ if (config_type != CONFIG_TYPE_GAME) return; /* write out the interface target */ target = render_get_ui_target(); if (target != render_target_get_indexed(0)) { xml_data_node *uinode; /* find the target index */ for (targetnum = 0; ; targetnum++) if (render_target_get_indexed(targetnum) == target) break; /* create a node for it */ uinode = xml_add_child(parentnode, "interface", NULL); if (uinode != NULL) xml_set_attribute_int(uinode, "target", targetnum); } /* iterate over targets */ for (targetnum = 0; targetnum < 1000; targetnum++) { xml_data_node *targetnode; /* get this target and break when we fail */ target = render_target_get_indexed(targetnum); if (target == NULL) break; /* create a node */ targetnode = xml_add_child(parentnode, "target", NULL); if (targetnode != NULL) { int changed = FALSE; /* output the basics */ xml_set_attribute_int(targetnode, "index", targetnum); /* output the view */ if (target->curview != target->base_view) { xml_set_attribute(targetnode, "view", target->curview->name); changed = TRUE; } /* output the layer config */ if (target->layerconfig != target->base_layerconfig) { xml_set_attribute_int(targetnode, "backdrops", (target->layerconfig & LAYER_CONFIG_ENABLE_BACKDROP) != 0); xml_set_attribute_int(targetnode, "overlays", (target->layerconfig & LAYER_CONFIG_ENABLE_OVERLAY) != 0); xml_set_attribute_int(targetnode, "bezels", (target->layerconfig & LAYER_CONFIG_ENABLE_BEZEL) != 0); xml_set_attribute_int(targetnode, "zoom", (target->layerconfig & LAYER_CONFIG_ZOOM_TO_SCREEN) != 0); changed = TRUE; } /* output rotation */ if (target->orientation != target->base_orientation) { int rotate = 0; if (orientation_add(ROT90, target->base_orientation) == target->orientation) rotate = 90; else if (orientation_add(ROT180, target->base_orientation) == target->orientation) rotate = 180; else if (orientation_add(ROT270, target->base_orientation) == target->orientation) rotate = 270; assert(rotate != 0); xml_set_attribute_int(targetnode, "rotate", rotate); changed = TRUE; } /* if nothing changed, kill the node */ if (!changed) xml_delete_node(targetnode); } } /* iterate over screen containers */ for (container = screen_container_list, scrnum = 0; container != NULL; container = container->next, scrnum++) { xml_data_node *screennode; /* create a node */ screennode = xml_add_child(parentnode, "screen", NULL); if (screennode != NULL) { int changed = FALSE; /* output the basics */ xml_set_attribute_int(screennode, "index", scrnum); /* output the color controls */ if (container->brightness != options_get_float(machine->options(), OPTION_BRIGHTNESS)) { xml_set_attribute_float(screennode, "brightness", container->brightness); changed = TRUE; } if (container->contrast != options_get_float(machine->options(), OPTION_CONTRAST)) { xml_set_attribute_float(screennode, "contrast", container->contrast); changed = TRUE; } if (container->gamma != options_get_float(machine->options(), OPTION_GAMMA)) { xml_set_attribute_float(screennode, "gamma", container->gamma); changed = TRUE; } /* output the positioning controls */ if (container->xoffset != 0.0f) { xml_set_attribute_float(screennode, "hoffset", container->xoffset); changed = TRUE; } if (container->xscale != 1.0f) { xml_set_attribute_float(screennode, "hstretch", container->xscale); changed = TRUE; } if (container->yoffset != 0.0f) { xml_set_attribute_float(screennode, "voffset", container->yoffset); changed = TRUE; } if (container->yscale != 1.0f) { xml_set_attribute_float(screennode, "vstretch", container->yscale); changed = TRUE; } /* if nothing changed, kill the node */ if (!changed) xml_delete_node(screennode); } } }
/*------------------------------------------------- render_save - save data to the configuration file -------------------------------------------------*/
save data to the configuration file
[ "save", "data", "to", "the", "configuration", "file" ]
static void render_save(running_machine *machine, int config_type, xml_data_node *parentnode) { render_target *target; render_container *container; int scrnum; int targetnum = 0; if (config_type != CONFIG_TYPE_GAME) return; target = render_get_ui_target(); if (target != render_target_get_indexed(0)) { xml_data_node *uinode; for (targetnum = 0; ; targetnum++) if (render_target_get_indexed(targetnum) == target) break; uinode = xml_add_child(parentnode, "interface", NULL); if (uinode != NULL) xml_set_attribute_int(uinode, "target", targetnum); } for (targetnum = 0; targetnum < 1000; targetnum++) { xml_data_node *targetnode; target = render_target_get_indexed(targetnum); if (target == NULL) break; targetnode = xml_add_child(parentnode, "target", NULL); if (targetnode != NULL) { int changed = FALSE; xml_set_attribute_int(targetnode, "index", targetnum); if (target->curview != target->base_view) { xml_set_attribute(targetnode, "view", target->curview->name); changed = TRUE; } if (target->layerconfig != target->base_layerconfig) { xml_set_attribute_int(targetnode, "backdrops", (target->layerconfig & LAYER_CONFIG_ENABLE_BACKDROP) != 0); xml_set_attribute_int(targetnode, "overlays", (target->layerconfig & LAYER_CONFIG_ENABLE_OVERLAY) != 0); xml_set_attribute_int(targetnode, "bezels", (target->layerconfig & LAYER_CONFIG_ENABLE_BEZEL) != 0); xml_set_attribute_int(targetnode, "zoom", (target->layerconfig & LAYER_CONFIG_ZOOM_TO_SCREEN) != 0); changed = TRUE; } if (target->orientation != target->base_orientation) { int rotate = 0; if (orientation_add(ROT90, target->base_orientation) == target->orientation) rotate = 90; else if (orientation_add(ROT180, target->base_orientation) == target->orientation) rotate = 180; else if (orientation_add(ROT270, target->base_orientation) == target->orientation) rotate = 270; assert(rotate != 0); xml_set_attribute_int(targetnode, "rotate", rotate); changed = TRUE; } if (!changed) xml_delete_node(targetnode); } } for (container = screen_container_list, scrnum = 0; container != NULL; container = container->next, scrnum++) { xml_data_node *screennode; screennode = xml_add_child(parentnode, "screen", NULL); if (screennode != NULL) { int changed = FALSE; xml_set_attribute_int(screennode, "index", scrnum); if (container->brightness != options_get_float(machine->options(), OPTION_BRIGHTNESS)) { xml_set_attribute_float(screennode, "brightness", container->brightness); changed = TRUE; } if (container->contrast != options_get_float(machine->options(), OPTION_CONTRAST)) { xml_set_attribute_float(screennode, "contrast", container->contrast); changed = TRUE; } if (container->gamma != options_get_float(machine->options(), OPTION_GAMMA)) { xml_set_attribute_float(screennode, "gamma", container->gamma); changed = TRUE; } if (container->xoffset != 0.0f) { xml_set_attribute_float(screennode, "hoffset", container->xoffset); changed = TRUE; } if (container->xscale != 1.0f) { xml_set_attribute_float(screennode, "hstretch", container->xscale); changed = TRUE; } if (container->yoffset != 0.0f) { xml_set_attribute_float(screennode, "voffset", container->yoffset); changed = TRUE; } if (container->yscale != 1.0f) { xml_set_attribute_float(screennode, "vstretch", container->yscale); changed = TRUE; } if (!changed) xml_delete_node(screennode); } } }
[ "static", "void", "render_save", "(", "running_machine", "*", "machine", ",", "int", "config_type", ",", "xml_data_node", "*", "parentnode", ")", "{", "render_target", "*", "target", ";", "render_container", "*", "container", ";", "int", "scrnum", ";", "int", "targetnum", "=", "0", ";", "if", "(", "config_type", "!=", "CONFIG_TYPE_GAME", ")", "return", ";", "target", "=", "render_get_ui_target", "(", ")", ";", "if", "(", "target", "!=", "render_target_get_indexed", "(", "0", ")", ")", "{", "xml_data_node", "*", "uinode", ";", "for", "(", "targetnum", "=", "0", ";", ";", "targetnum", "++", ")", "if", "(", "render_target_get_indexed", "(", "targetnum", ")", "==", "target", ")", "break", ";", "uinode", "=", "xml_add_child", "(", "parentnode", ",", "\"", "\"", ",", "NULL", ")", ";", "if", "(", "uinode", "!=", "NULL", ")", "xml_set_attribute_int", "(", "uinode", ",", "\"", "\"", ",", "targetnum", ")", ";", "}", "for", "(", "targetnum", "=", "0", ";", "targetnum", "<", "1000", ";", "targetnum", "++", ")", "{", "xml_data_node", "*", "targetnode", ";", "target", "=", "render_target_get_indexed", "(", "targetnum", ")", ";", "if", "(", "target", "==", "NULL", ")", "break", ";", "targetnode", "=", "xml_add_child", "(", "parentnode", ",", "\"", "\"", ",", "NULL", ")", ";", "if", "(", "targetnode", "!=", "NULL", ")", "{", "int", "changed", "=", "FALSE", ";", "xml_set_attribute_int", "(", "targetnode", ",", "\"", "\"", ",", "targetnum", ")", ";", "if", "(", "target", "->", "curview", "!=", "target", "->", "base_view", ")", "{", "xml_set_attribute", "(", "targetnode", ",", "\"", "\"", ",", "target", "->", "curview", "->", "name", ")", ";", "changed", "=", "TRUE", ";", "}", "if", "(", "target", "->", "layerconfig", "!=", "target", "->", "base_layerconfig", ")", "{", "xml_set_attribute_int", "(", "targetnode", ",", "\"", "\"", ",", "(", "target", "->", "layerconfig", "&", "LAYER_CONFIG_ENABLE_BACKDROP", ")", "!=", "0", ")", ";", "xml_set_attribute_int", "(", "targetnode", ",", "\"", "\"", ",", "(", "target", "->", "layerconfig", "&", "LAYER_CONFIG_ENABLE_OVERLAY", ")", "!=", "0", ")", ";", "xml_set_attribute_int", "(", "targetnode", ",", "\"", "\"", ",", "(", "target", "->", "layerconfig", "&", "LAYER_CONFIG_ENABLE_BEZEL", ")", "!=", "0", ")", ";", "xml_set_attribute_int", "(", "targetnode", ",", "\"", "\"", ",", "(", "target", "->", "layerconfig", "&", "LAYER_CONFIG_ZOOM_TO_SCREEN", ")", "!=", "0", ")", ";", "changed", "=", "TRUE", ";", "}", "if", "(", "target", "->", "orientation", "!=", "target", "->", "base_orientation", ")", "{", "int", "rotate", "=", "0", ";", "if", "(", "orientation_add", "(", "ROT90", ",", "target", "->", "base_orientation", ")", "==", "target", "->", "orientation", ")", "rotate", "=", "90", ";", "else", "if", "(", "orientation_add", "(", "ROT180", ",", "target", "->", "base_orientation", ")", "==", "target", "->", "orientation", ")", "rotate", "=", "180", ";", "else", "if", "(", "orientation_add", "(", "ROT270", ",", "target", "->", "base_orientation", ")", "==", "target", "->", "orientation", ")", "rotate", "=", "270", ";", "assert", "(", "rotate", "!=", "0", ")", ";", "xml_set_attribute_int", "(", "targetnode", ",", "\"", "\"", ",", "rotate", ")", ";", "changed", "=", "TRUE", ";", "}", "if", "(", "!", "changed", ")", "xml_delete_node", "(", "targetnode", ")", ";", "}", "}", "for", "(", "container", "=", "screen_container_list", ",", "scrnum", "=", "0", ";", "container", "!=", "NULL", ";", "container", "=", "container", "->", "next", ",", "scrnum", "++", ")", "{", "xml_data_node", "*", "screennode", ";", "screennode", "=", "xml_add_child", "(", "parentnode", ",", "\"", "\"", ",", "NULL", ")", ";", "if", "(", "screennode", "!=", "NULL", ")", "{", "int", "changed", "=", "FALSE", ";", "xml_set_attribute_int", "(", "screennode", ",", "\"", "\"", ",", "scrnum", ")", ";", "if", "(", "container", "->", "brightness", "!=", "options_get_float", "(", "machine", "->", "options", "(", ")", ",", "OPTION_BRIGHTNESS", ")", ")", "{", "xml_set_attribute_float", "(", "screennode", ",", "\"", "\"", ",", "container", "->", "brightness", ")", ";", "changed", "=", "TRUE", ";", "}", "if", "(", "container", "->", "contrast", "!=", "options_get_float", "(", "machine", "->", "options", "(", ")", ",", "OPTION_CONTRAST", ")", ")", "{", "xml_set_attribute_float", "(", "screennode", ",", "\"", "\"", ",", "container", "->", "contrast", ")", ";", "changed", "=", "TRUE", ";", "}", "if", "(", "container", "->", "gamma", "!=", "options_get_float", "(", "machine", "->", "options", "(", ")", ",", "OPTION_GAMMA", ")", ")", "{", "xml_set_attribute_float", "(", "screennode", ",", "\"", "\"", ",", "container", "->", "gamma", ")", ";", "changed", "=", "TRUE", ";", "}", "if", "(", "container", "->", "xoffset", "!=", "0.0f", ")", "{", "xml_set_attribute_float", "(", "screennode", ",", "\"", "\"", ",", "container", "->", "xoffset", ")", ";", "changed", "=", "TRUE", ";", "}", "if", "(", "container", "->", "xscale", "!=", "1.0f", ")", "{", "xml_set_attribute_float", "(", "screennode", ",", "\"", "\"", ",", "container", "->", "xscale", ")", ";", "changed", "=", "TRUE", ";", "}", "if", "(", "container", "->", "yoffset", "!=", "0.0f", ")", "{", "xml_set_attribute_float", "(", "screennode", ",", "\"", "\"", ",", "container", "->", "yoffset", ")", ";", "changed", "=", "TRUE", ";", "}", "if", "(", "container", "->", "yscale", "!=", "1.0f", ")", "{", "xml_set_attribute_float", "(", "screennode", ",", "\"", "\"", ",", "container", "->", "yscale", ")", ";", "changed", "=", "TRUE", ";", "}", "if", "(", "!", "changed", ")", "xml_delete_node", "(", "screennode", ")", ";", "}", "}", "}" ]
render_save - save data to the configuration file
[ "render_save", "-", "save", "data", "to", "the", "configuration", "file" ]
[ "/* we only care about game files */", "/* write out the interface target */", "/* find the target index */", "/* create a node for it */", "/* iterate over targets */", "/* get this target and break when we fail */", "/* create a node */", "/* output the basics */", "/* output the view */", "/* output the layer config */", "/* output rotation */", "/* if nothing changed, kill the node */", "/* iterate over screen containers */", "/* create a node */", "/* output the basics */", "/* output the color controls */", "/* output the positioning controls */", "/* if nothing changed, kill the node */" ]
[ { "param": "machine", "type": "running_machine" }, { "param": "config_type", "type": "int" }, { "param": "parentnode", "type": "xml_data_node" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "machine", "type": "running_machine", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "config_type", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "parentnode", "type": "xml_data_node", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f08d4faea9078af6cfe316fec86d7cdea6e9e3ab
lofunz/mieme
Reloaded/trunk/src/emu/render.c
[ "Unlicense" ]
C
render_target_free
void
void render_target_free(render_target *target) { render_target **curr; int listnum; /* remove us from the list */ for (curr = &targetlist; *curr != target; curr = &(*curr)->next) ; *curr = target->next; /* free any primitives */ for (listnum = 0; listnum < ARRAY_LENGTH(target->primlist); listnum++) { release_render_list(&target->primlist[listnum]); osd_lock_free(target->primlist[listnum].lock); } /* free the layout files */ while (target->filelist != NULL) { layout_file *temp = target->filelist; target->filelist = temp->next; layout_file_free(temp); } /* free the target itself */ global_free(target); }
/*------------------------------------------------- render_target_free - free memory for a render target -------------------------------------------------*/
free memory for a render target
[ "free", "memory", "for", "a", "render", "target" ]
void render_target_free(render_target *target) { render_target **curr; int listnum; for (curr = &targetlist; *curr != target; curr = &(*curr)->next) ; *curr = target->next; for (listnum = 0; listnum < ARRAY_LENGTH(target->primlist); listnum++) { release_render_list(&target->primlist[listnum]); osd_lock_free(target->primlist[listnum].lock); } while (target->filelist != NULL) { layout_file *temp = target->filelist; target->filelist = temp->next; layout_file_free(temp); } global_free(target); }
[ "void", "render_target_free", "(", "render_target", "*", "target", ")", "{", "render_target", "*", "*", "curr", ";", "int", "listnum", ";", "for", "(", "curr", "=", "&", "targetlist", ";", "*", "curr", "!=", "target", ";", "curr", "=", "&", "(", "*", "curr", ")", "->", "next", ")", ";", "*", "curr", "=", "target", "->", "next", ";", "for", "(", "listnum", "=", "0", ";", "listnum", "<", "ARRAY_LENGTH", "(", "target", "->", "primlist", ")", ";", "listnum", "++", ")", "{", "release_render_list", "(", "&", "target", "->", "primlist", "[", "listnum", "]", ")", ";", "osd_lock_free", "(", "target", "->", "primlist", "[", "listnum", "]", ".", "lock", ")", ";", "}", "while", "(", "target", "->", "filelist", "!=", "NULL", ")", "{", "layout_file", "*", "temp", "=", "target", "->", "filelist", ";", "target", "->", "filelist", "=", "temp", "->", "next", ";", "layout_file_free", "(", "temp", ")", ";", "}", "global_free", "(", "target", ")", ";", "}" ]
render_target_free - free memory for a render target
[ "render_target_free", "-", "free", "memory", "for", "a", "render", "target" ]
[ "/* remove us from the list */", "/* free any primitives */", "/* free the layout files */", "/* free the target itself */" ]
[ { "param": "target", "type": "render_target" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "target", "type": "render_target", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f08d4faea9078af6cfe316fec86d7cdea6e9e3ab
lofunz/mieme
Reloaded/trunk/src/emu/render.c
[ "Unlicense" ]
C
render_target_compute_visible_area
void
void render_target_compute_visible_area(render_target *target, INT32 target_width, INT32 target_height, float target_pixel_aspect, int target_orientation, INT32 *visible_width, INT32 *visible_height) { float width, height; float scale; /* constrained case */ if (target_pixel_aspect != 0.0f) { /* start with the aspect ratio of the square pixel layout */ width = ((target->layerconfig & LAYER_CONFIG_ZOOM_TO_SCREEN) && target->curview->screens > 0) ? target->curview->scraspect : target->curview->aspect; height = 1.0f; /* first apply target orientation */ if (target_orientation & ORIENTATION_SWAP_XY) FSWAP(width, height); /* apply the target pixel aspect ratio */ height *= target_pixel_aspect; /* based on the height/width ratio of the source and target, compute the scale factor */ if (width / height > (float)target_width / (float)target_height) scale = (float)target_width / width; else scale = (float)target_height / height; } /* stretch-to-fit case */ else { width = (float)target_width; height = (float)target_height; scale = 1.0f; } /* set the final width/height */ if (visible_width != NULL) *visible_width = render_round_nearest(width * scale); if (visible_height != NULL) *visible_height = render_round_nearest(height * scale); }
/*------------------------------------------------- render_target_compute_visible_area - compute the visible area for the given target with the current layout and proposed new parameters -------------------------------------------------*/
compute the visible area for the given target with the current layout and proposed new parameters
[ "compute", "the", "visible", "area", "for", "the", "given", "target", "with", "the", "current", "layout", "and", "proposed", "new", "parameters" ]
void render_target_compute_visible_area(render_target *target, INT32 target_width, INT32 target_height, float target_pixel_aspect, int target_orientation, INT32 *visible_width, INT32 *visible_height) { float width, height; float scale; if (target_pixel_aspect != 0.0f) { width = ((target->layerconfig & LAYER_CONFIG_ZOOM_TO_SCREEN) && target->curview->screens > 0) ? target->curview->scraspect : target->curview->aspect; height = 1.0f; if (target_orientation & ORIENTATION_SWAP_XY) FSWAP(width, height); height *= target_pixel_aspect; if (width / height > (float)target_width / (float)target_height) scale = (float)target_width / width; else scale = (float)target_height / height; } else { width = (float)target_width; height = (float)target_height; scale = 1.0f; } if (visible_width != NULL) *visible_width = render_round_nearest(width * scale); if (visible_height != NULL) *visible_height = render_round_nearest(height * scale); }
[ "void", "render_target_compute_visible_area", "(", "render_target", "*", "target", ",", "INT32", "target_width", ",", "INT32", "target_height", ",", "float", "target_pixel_aspect", ",", "int", "target_orientation", ",", "INT32", "*", "visible_width", ",", "INT32", "*", "visible_height", ")", "{", "float", "width", ",", "height", ";", "float", "scale", ";", "if", "(", "target_pixel_aspect", "!=", "0.0f", ")", "{", "width", "=", "(", "(", "target", "->", "layerconfig", "&", "LAYER_CONFIG_ZOOM_TO_SCREEN", ")", "&&", "target", "->", "curview", "->", "screens", ">", "0", ")", "?", "target", "->", "curview", "->", "scraspect", ":", "target", "->", "curview", "->", "aspect", ";", "height", "=", "1.0f", ";", "if", "(", "target_orientation", "&", "ORIENTATION_SWAP_XY", ")", "FSWAP", "(", "width", ",", "height", ")", ";", "height", "*=", "target_pixel_aspect", ";", "if", "(", "width", "/", "height", ">", "(", "float", ")", "target_width", "/", "(", "float", ")", "target_height", ")", "scale", "=", "(", "float", ")", "target_width", "/", "width", ";", "else", "scale", "=", "(", "float", ")", "target_height", "/", "height", ";", "}", "else", "{", "width", "=", "(", "float", ")", "target_width", ";", "height", "=", "(", "float", ")", "target_height", ";", "scale", "=", "1.0f", ";", "}", "if", "(", "visible_width", "!=", "NULL", ")", "*", "visible_width", "=", "render_round_nearest", "(", "width", "*", "scale", ")", ";", "if", "(", "visible_height", "!=", "NULL", ")", "*", "visible_height", "=", "render_round_nearest", "(", "height", "*", "scale", ")", ";", "}" ]
render_target_compute_visible_area - compute the visible area for the given target with the current layout and proposed new parameters
[ "render_target_compute_visible_area", "-", "compute", "the", "visible", "area", "for", "the", "given", "target", "with", "the", "current", "layout", "and", "proposed", "new", "parameters" ]
[ "/* constrained case */", "/* start with the aspect ratio of the square pixel layout */", "/* first apply target orientation */", "/* apply the target pixel aspect ratio */", "/* based on the height/width ratio of the source and target, compute the scale factor */", "/* stretch-to-fit case */", "/* set the final width/height */" ]
[ { "param": "target", "type": "render_target" }, { "param": "target_width", "type": "INT32" }, { "param": "target_height", "type": "INT32" }, { "param": "target_pixel_aspect", "type": "float" }, { "param": "target_orientation", "type": "int" }, { "param": "visible_width", "type": "INT32" }, { "param": "visible_height", "type": "INT32" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "target", "type": "render_target", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "target_width", "type": "INT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "target_height", "type": "INT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "target_pixel_aspect", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "target_orientation", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "visible_width", "type": "INT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "visible_height", "type": "INT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f08d4faea9078af6cfe316fec86d7cdea6e9e3ab
lofunz/mieme
Reloaded/trunk/src/emu/render.c
[ "Unlicense" ]
C
render_target_map_point_container
int
int render_target_map_point_container(render_target *target, INT32 target_x, INT32 target_y, render_container *container, float *container_x, float *container_y) { view_item *item; return render_target_map_point_internal(target, target_x, target_y, container, container_x, container_y, &item); }
/*------------------------------------------------- render_target_map_point_container - attempts to map a point on the specified render_target to the specified container, if possible -------------------------------------------------*/
attempts to map a point on the specified render_target to the specified container, if possible
[ "attempts", "to", "map", "a", "point", "on", "the", "specified", "render_target", "to", "the", "specified", "container", "if", "possible" ]
int render_target_map_point_container(render_target *target, INT32 target_x, INT32 target_y, render_container *container, float *container_x, float *container_y) { view_item *item; return render_target_map_point_internal(target, target_x, target_y, container, container_x, container_y, &item); }
[ "int", "render_target_map_point_container", "(", "render_target", "*", "target", ",", "INT32", "target_x", ",", "INT32", "target_y", ",", "render_container", "*", "container", ",", "float", "*", "container_x", ",", "float", "*", "container_y", ")", "{", "view_item", "*", "item", ";", "return", "render_target_map_point_internal", "(", "target", ",", "target_x", ",", "target_y", ",", "container", ",", "container_x", ",", "container_y", ",", "&", "item", ")", ";", "}" ]
render_target_map_point_container - attempts to map a point on the specified render_target to the specified container, if possible
[ "render_target_map_point_container", "-", "attempts", "to", "map", "a", "point", "on", "the", "specified", "render_target", "to", "the", "specified", "container", "if", "possible" ]
[]
[ { "param": "target", "type": "render_target" }, { "param": "target_x", "type": "INT32" }, { "param": "target_y", "type": "INT32" }, { "param": "container", "type": "render_container" }, { "param": "container_x", "type": "float" }, { "param": "container_y", "type": "float" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "target", "type": "render_target", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "target_x", "type": "INT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "target_y", "type": "INT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "container", "type": "render_container", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "container_x", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "container_y", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f08d4faea9078af6cfe316fec86d7cdea6e9e3ab
lofunz/mieme
Reloaded/trunk/src/emu/render.c
[ "Unlicense" ]
C
render_target_map_point_input
int
int render_target_map_point_input(render_target *target, INT32 target_x, INT32 target_y, const char **input_tag, UINT32 *input_mask, float *input_x, float *input_y) { view_item *item = NULL; int result; result = render_target_map_point_internal(target, target_x, target_y, NULL, input_x, input_y, &item); if (result && item != NULL) { *input_tag = item->input_tag; *input_mask = item->input_mask; } return result; }
/*------------------------------------------------- render_target_map_point_input - attempts to map a point on the specified render_target to the specified container, if possible -------------------------------------------------*/
attempts to map a point on the specified render_target to the specified container, if possible
[ "attempts", "to", "map", "a", "point", "on", "the", "specified", "render_target", "to", "the", "specified", "container", "if", "possible" ]
int render_target_map_point_input(render_target *target, INT32 target_x, INT32 target_y, const char **input_tag, UINT32 *input_mask, float *input_x, float *input_y) { view_item *item = NULL; int result; result = render_target_map_point_internal(target, target_x, target_y, NULL, input_x, input_y, &item); if (result && item != NULL) { *input_tag = item->input_tag; *input_mask = item->input_mask; } return result; }
[ "int", "render_target_map_point_input", "(", "render_target", "*", "target", ",", "INT32", "target_x", ",", "INT32", "target_y", ",", "const", "char", "*", "*", "input_tag", ",", "UINT32", "*", "input_mask", ",", "float", "*", "input_x", ",", "float", "*", "input_y", ")", "{", "view_item", "*", "item", "=", "NULL", ";", "int", "result", ";", "result", "=", "render_target_map_point_internal", "(", "target", ",", "target_x", ",", "target_y", ",", "NULL", ",", "input_x", ",", "input_y", ",", "&", "item", ")", ";", "if", "(", "result", "&&", "item", "!=", "NULL", ")", "{", "*", "input_tag", "=", "item", "->", "input_tag", ";", "*", "input_mask", "=", "item", "->", "input_mask", ";", "}", "return", "result", ";", "}" ]
render_target_map_point_input - attempts to map a point on the specified render_target to the specified container, if possible
[ "render_target_map_point_input", "-", "attempts", "to", "map", "a", "point", "on", "the", "specified", "render_target", "to", "the", "specified", "container", "if", "possible" ]
[]
[ { "param": "target", "type": "render_target" }, { "param": "target_x", "type": "INT32" }, { "param": "target_y", "type": "INT32" }, { "param": "input_tag", "type": "char" }, { "param": "input_mask", "type": "UINT32" }, { "param": "input_x", "type": "float" }, { "param": "input_y", "type": "float" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "target", "type": "render_target", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "target_x", "type": "INT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "target_y", "type": "INT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "input_tag", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "input_mask", "type": "UINT32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "input_x", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "input_y", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f08d4faea9078af6cfe316fec86d7cdea6e9e3ab
lofunz/mieme
Reloaded/trunk/src/emu/render.c
[ "Unlicense" ]
C
load_layout_files
int
static int load_layout_files(render_target *target, const char *layoutfile, int singlefile) { running_machine *machine = target->machine; const game_driver *gamedrv = machine->gamedrv; const machine_config *config = machine->config; const char *basename = machine->basename(); layout_file **nextfile = &target->filelist; const game_driver *cloneof; /* if there's an explicit file, load that first */ if (layoutfile != NULL) { *nextfile = layout_file_load(config, basename, layoutfile); if (*nextfile != NULL) nextfile = &(*nextfile)->next; } /* if we're only loading this file, we know our final result */ if (singlefile) return (nextfile == &target->filelist) ? 1 : 0; /* try to load a file based on the driver name */ *nextfile = layout_file_load(config, basename, gamedrv->name); if (*nextfile == NULL) *nextfile = layout_file_load(config, basename, "default"); if (*nextfile != NULL) nextfile = &(*nextfile)->next; /* if a default view has been specified, use that as a fallback */ if (gamedrv->default_layout != NULL) { *nextfile = layout_file_load(config, NULL, gamedrv->default_layout); if (*nextfile != NULL) nextfile = &(*nextfile)->next; } if (config->m_default_layout != NULL) { *nextfile = layout_file_load(config, NULL, config->m_default_layout); if (*nextfile != NULL) nextfile = &(*nextfile)->next; } /* try to load another file based on the parent driver name */ cloneof = driver_get_clone(gamedrv); if (cloneof != NULL) { *nextfile = layout_file_load(config, cloneof->name, cloneof->name); if (*nextfile == NULL) *nextfile = layout_file_load(config, cloneof->name, "default"); if (*nextfile != NULL) nextfile = &(*nextfile)->next; } /* now do the built-in layouts for single-screen games */ if (screen_count(*config) == 1) { if (gamedrv->flags & ORIENTATION_SWAP_XY) *nextfile = layout_file_load(config, NULL, layout_vertical); else *nextfile = layout_file_load(config, NULL, layout_horizont); assert_always(*nextfile != NULL, "Couldn't parse default layout??"); nextfile = &(*nextfile)->next; } return 0; }
/*------------------------------------------------- load_layout_files - load layout files for a given render target -------------------------------------------------*/
load layout files for a given render target
[ "load", "layout", "files", "for", "a", "given", "render", "target" ]
static int load_layout_files(render_target *target, const char *layoutfile, int singlefile) { running_machine *machine = target->machine; const game_driver *gamedrv = machine->gamedrv; const machine_config *config = machine->config; const char *basename = machine->basename(); layout_file **nextfile = &target->filelist; const game_driver *cloneof; if (layoutfile != NULL) { *nextfile = layout_file_load(config, basename, layoutfile); if (*nextfile != NULL) nextfile = &(*nextfile)->next; } if (singlefile) return (nextfile == &target->filelist) ? 1 : 0; *nextfile = layout_file_load(config, basename, gamedrv->name); if (*nextfile == NULL) *nextfile = layout_file_load(config, basename, "default"); if (*nextfile != NULL) nextfile = &(*nextfile)->next; if (gamedrv->default_layout != NULL) { *nextfile = layout_file_load(config, NULL, gamedrv->default_layout); if (*nextfile != NULL) nextfile = &(*nextfile)->next; } if (config->m_default_layout != NULL) { *nextfile = layout_file_load(config, NULL, config->m_default_layout); if (*nextfile != NULL) nextfile = &(*nextfile)->next; } cloneof = driver_get_clone(gamedrv); if (cloneof != NULL) { *nextfile = layout_file_load(config, cloneof->name, cloneof->name); if (*nextfile == NULL) *nextfile = layout_file_load(config, cloneof->name, "default"); if (*nextfile != NULL) nextfile = &(*nextfile)->next; } if (screen_count(*config) == 1) { if (gamedrv->flags & ORIENTATION_SWAP_XY) *nextfile = layout_file_load(config, NULL, layout_vertical); else *nextfile = layout_file_load(config, NULL, layout_horizont); assert_always(*nextfile != NULL, "Couldn't parse default layout??"); nextfile = &(*nextfile)->next; } return 0; }
[ "static", "int", "load_layout_files", "(", "render_target", "*", "target", ",", "const", "char", "*", "layoutfile", ",", "int", "singlefile", ")", "{", "running_machine", "*", "machine", "=", "target", "->", "machine", ";", "const", "game_driver", "*", "gamedrv", "=", "machine", "->", "gamedrv", ";", "const", "machine_config", "*", "config", "=", "machine", "->", "config", ";", "const", "char", "*", "basename", "=", "machine", "->", "basename", "(", ")", ";", "layout_file", "*", "*", "nextfile", "=", "&", "target", "->", "filelist", ";", "const", "game_driver", "*", "cloneof", ";", "if", "(", "layoutfile", "!=", "NULL", ")", "{", "*", "nextfile", "=", "layout_file_load", "(", "config", ",", "basename", ",", "layoutfile", ")", ";", "if", "(", "*", "nextfile", "!=", "NULL", ")", "nextfile", "=", "&", "(", "*", "nextfile", ")", "->", "next", ";", "}", "if", "(", "singlefile", ")", "return", "(", "nextfile", "==", "&", "target", "->", "filelist", ")", "?", "1", ":", "0", ";", "*", "nextfile", "=", "layout_file_load", "(", "config", ",", "basename", ",", "gamedrv", "->", "name", ")", ";", "if", "(", "*", "nextfile", "==", "NULL", ")", "*", "nextfile", "=", "layout_file_load", "(", "config", ",", "basename", ",", "\"", "\"", ")", ";", "if", "(", "*", "nextfile", "!=", "NULL", ")", "nextfile", "=", "&", "(", "*", "nextfile", ")", "->", "next", ";", "if", "(", "gamedrv", "->", "default_layout", "!=", "NULL", ")", "{", "*", "nextfile", "=", "layout_file_load", "(", "config", ",", "NULL", ",", "gamedrv", "->", "default_layout", ")", ";", "if", "(", "*", "nextfile", "!=", "NULL", ")", "nextfile", "=", "&", "(", "*", "nextfile", ")", "->", "next", ";", "}", "if", "(", "config", "->", "m_default_layout", "!=", "NULL", ")", "{", "*", "nextfile", "=", "layout_file_load", "(", "config", ",", "NULL", ",", "config", "->", "m_default_layout", ")", ";", "if", "(", "*", "nextfile", "!=", "NULL", ")", "nextfile", "=", "&", "(", "*", "nextfile", ")", "->", "next", ";", "}", "cloneof", "=", "driver_get_clone", "(", "gamedrv", ")", ";", "if", "(", "cloneof", "!=", "NULL", ")", "{", "*", "nextfile", "=", "layout_file_load", "(", "config", ",", "cloneof", "->", "name", ",", "cloneof", "->", "name", ")", ";", "if", "(", "*", "nextfile", "==", "NULL", ")", "*", "nextfile", "=", "layout_file_load", "(", "config", ",", "cloneof", "->", "name", ",", "\"", "\"", ")", ";", "if", "(", "*", "nextfile", "!=", "NULL", ")", "nextfile", "=", "&", "(", "*", "nextfile", ")", "->", "next", ";", "}", "if", "(", "screen_count", "(", "*", "config", ")", "==", "1", ")", "{", "if", "(", "gamedrv", "->", "flags", "&", "ORIENTATION_SWAP_XY", ")", "*", "nextfile", "=", "layout_file_load", "(", "config", ",", "NULL", ",", "layout_vertical", ")", ";", "else", "*", "nextfile", "=", "layout_file_load", "(", "config", ",", "NULL", ",", "layout_horizont", ")", ";", "assert_always", "(", "*", "nextfile", "!=", "NULL", ",", "\"", "\"", ")", ";", "nextfile", "=", "&", "(", "*", "nextfile", ")", "->", "next", ";", "}", "return", "0", ";", "}" ]
load_layout_files - load layout files for a given render target
[ "load_layout_files", "-", "load", "layout", "files", "for", "a", "given", "render", "target" ]
[ "/* if there's an explicit file, load that first */", "/* if we're only loading this file, we know our final result */", "/* try to load a file based on the driver name */", "/* if a default view has been specified, use that as a fallback */", "/* try to load another file based on the parent driver name */", "/* now do the built-in layouts for single-screen games */" ]
[ { "param": "target", "type": "render_target" }, { "param": "layoutfile", "type": "char" }, { "param": "singlefile", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "target", "type": "render_target", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "layoutfile", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "singlefile", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f08d4faea9078af6cfe316fec86d7cdea6e9e3ab
lofunz/mieme
Reloaded/trunk/src/emu/render.c
[ "Unlicense" ]
C
add_element_primitives
void
static void add_element_primitives(render_target *target, render_primitive_list *list, const object_transform *xform, const layout_element *element, int state, int blendmode) { INT32 width = render_round_nearest(xform->xscale); INT32 height = render_round_nearest(xform->yscale); render_texture *texture; render_bounds cliprect; int clipped = TRUE; /* if we're out of range, bail */ if (state > element->maxstate) return; if (state < 0) state = 0; /* get a pointer to the relevant texture */ texture = element->elemtex[state].texture; if (texture != NULL) { render_primitive *prim = alloc_render_primitive(RENDER_PRIMITIVE_QUAD); /* configure the basics */ prim->color = xform->color; prim->flags = PRIMFLAG_TEXORIENT(xform->orientation) | PRIMFLAG_BLENDMODE(blendmode) | PRIMFLAG_TEXFORMAT(texture->format); /* compute the bounds */ set_render_bounds_wh(&prim->bounds, render_round_nearest(xform->xoffs), render_round_nearest(xform->yoffs), (float) width, (float) height); if (xform->orientation & ORIENTATION_SWAP_XY) ISWAP(width, height); width = MIN(width, target->maxtexwidth); height = MIN(height, target->maxtexheight); /* get the scaled texture and append it */ if (texture_get_scaled(texture, width, height, &prim->texture, &list->reflist)) { /* compute the clip rect */ cliprect.x0 = render_round_nearest(xform->xoffs); cliprect.y0 = render_round_nearest(xform->yoffs); cliprect.x1 = render_round_nearest(xform->xoffs + xform->xscale); cliprect.y1 = render_round_nearest(xform->yoffs + xform->yscale); sect_render_bounds(&cliprect, &target->bounds); /* determine UV coordinates and apply clipping */ prim->texcoords = oriented_texcoords[xform->orientation]; clipped = render_clip_quad(&prim->bounds, &cliprect, &prim->texcoords); } /* add to the list or free if we're clipped out */ if (!clipped) append_render_primitive(list, prim); else free_render_primitive(prim); } }
/*------------------------------------------------- add_element_primitives - add the primitive for an element in the current state -------------------------------------------------*/
add the primitive for an element in the current state
[ "add", "the", "primitive", "for", "an", "element", "in", "the", "current", "state" ]
static void add_element_primitives(render_target *target, render_primitive_list *list, const object_transform *xform, const layout_element *element, int state, int blendmode) { INT32 width = render_round_nearest(xform->xscale); INT32 height = render_round_nearest(xform->yscale); render_texture *texture; render_bounds cliprect; int clipped = TRUE; if (state > element->maxstate) return; if (state < 0) state = 0; texture = element->elemtex[state].texture; if (texture != NULL) { render_primitive *prim = alloc_render_primitive(RENDER_PRIMITIVE_QUAD); prim->color = xform->color; prim->flags = PRIMFLAG_TEXORIENT(xform->orientation) | PRIMFLAG_BLENDMODE(blendmode) | PRIMFLAG_TEXFORMAT(texture->format); set_render_bounds_wh(&prim->bounds, render_round_nearest(xform->xoffs), render_round_nearest(xform->yoffs), (float) width, (float) height); if (xform->orientation & ORIENTATION_SWAP_XY) ISWAP(width, height); width = MIN(width, target->maxtexwidth); height = MIN(height, target->maxtexheight); if (texture_get_scaled(texture, width, height, &prim->texture, &list->reflist)) { cliprect.x0 = render_round_nearest(xform->xoffs); cliprect.y0 = render_round_nearest(xform->yoffs); cliprect.x1 = render_round_nearest(xform->xoffs + xform->xscale); cliprect.y1 = render_round_nearest(xform->yoffs + xform->yscale); sect_render_bounds(&cliprect, &target->bounds); prim->texcoords = oriented_texcoords[xform->orientation]; clipped = render_clip_quad(&prim->bounds, &cliprect, &prim->texcoords); } if (!clipped) append_render_primitive(list, prim); else free_render_primitive(prim); } }
[ "static", "void", "add_element_primitives", "(", "render_target", "*", "target", ",", "render_primitive_list", "*", "list", ",", "const", "object_transform", "*", "xform", ",", "const", "layout_element", "*", "element", ",", "int", "state", ",", "int", "blendmode", ")", "{", "INT32", "width", "=", "render_round_nearest", "(", "xform", "->", "xscale", ")", ";", "INT32", "height", "=", "render_round_nearest", "(", "xform", "->", "yscale", ")", ";", "render_texture", "*", "texture", ";", "render_bounds", "cliprect", ";", "int", "clipped", "=", "TRUE", ";", "if", "(", "state", ">", "element", "->", "maxstate", ")", "return", ";", "if", "(", "state", "<", "0", ")", "state", "=", "0", ";", "texture", "=", "element", "->", "elemtex", "[", "state", "]", ".", "texture", ";", "if", "(", "texture", "!=", "NULL", ")", "{", "render_primitive", "*", "prim", "=", "alloc_render_primitive", "(", "RENDER_PRIMITIVE_QUAD", ")", ";", "prim", "->", "color", "=", "xform", "->", "color", ";", "prim", "->", "flags", "=", "PRIMFLAG_TEXORIENT", "(", "xform", "->", "orientation", ")", "|", "PRIMFLAG_BLENDMODE", "(", "blendmode", ")", "|", "PRIMFLAG_TEXFORMAT", "(", "texture", "->", "format", ")", ";", "set_render_bounds_wh", "(", "&", "prim", "->", "bounds", ",", "render_round_nearest", "(", "xform", "->", "xoffs", ")", ",", "render_round_nearest", "(", "xform", "->", "yoffs", ")", ",", "(", "float", ")", "width", ",", "(", "float", ")", "height", ")", ";", "if", "(", "xform", "->", "orientation", "&", "ORIENTATION_SWAP_XY", ")", "ISWAP", "(", "width", ",", "height", ")", ";", "width", "=", "MIN", "(", "width", ",", "target", "->", "maxtexwidth", ")", ";", "height", "=", "MIN", "(", "height", ",", "target", "->", "maxtexheight", ")", ";", "if", "(", "texture_get_scaled", "(", "texture", ",", "width", ",", "height", ",", "&", "prim", "->", "texture", ",", "&", "list", "->", "reflist", ")", ")", "{", "cliprect", ".", "x0", "=", "render_round_nearest", "(", "xform", "->", "xoffs", ")", ";", "cliprect", ".", "y0", "=", "render_round_nearest", "(", "xform", "->", "yoffs", ")", ";", "cliprect", ".", "x1", "=", "render_round_nearest", "(", "xform", "->", "xoffs", "+", "xform", "->", "xscale", ")", ";", "cliprect", ".", "y1", "=", "render_round_nearest", "(", "xform", "->", "yoffs", "+", "xform", "->", "yscale", ")", ";", "sect_render_bounds", "(", "&", "cliprect", ",", "&", "target", "->", "bounds", ")", ";", "prim", "->", "texcoords", "=", "oriented_texcoords", "[", "xform", "->", "orientation", "]", ";", "clipped", "=", "render_clip_quad", "(", "&", "prim", "->", "bounds", ",", "&", "cliprect", ",", "&", "prim", "->", "texcoords", ")", ";", "}", "if", "(", "!", "clipped", ")", "append_render_primitive", "(", "list", ",", "prim", ")", ";", "else", "free_render_primitive", "(", "prim", ")", ";", "}", "}" ]
add_element_primitives - add the primitive for an element in the current state
[ "add_element_primitives", "-", "add", "the", "primitive", "for", "an", "element", "in", "the", "current", "state" ]
[ "/* if we're out of range, bail */", "/* get a pointer to the relevant texture */", "/* configure the basics */", "/* compute the bounds */", "/* get the scaled texture and append it */", "/* compute the clip rect */", "/* determine UV coordinates and apply clipping */", "/* add to the list or free if we're clipped out */" ]
[ { "param": "target", "type": "render_target" }, { "param": "list", "type": "render_primitive_list" }, { "param": "xform", "type": "object_transform" }, { "param": "element", "type": "layout_element" }, { "param": "state", "type": "int" }, { "param": "blendmode", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "target", "type": "render_target", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "list", "type": "render_primitive_list", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "xform", "type": "object_transform", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "element", "type": "layout_element", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "state", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "blendmode", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f08d4faea9078af6cfe316fec86d7cdea6e9e3ab
lofunz/mieme
Reloaded/trunk/src/emu/render.c
[ "Unlicense" ]
C
invalidate_all_render_ref
void
static void invalidate_all_render_ref(void *refptr) { render_target *target; int listnum; /* loop over targets */ for (target = targetlist; target != NULL; target = target->next) for (listnum = 0; listnum < ARRAY_LENGTH(target->primlist); listnum++) { render_primitive_list *list = &target->primlist[listnum]; osd_lock_acquire(list->lock); if (has_render_ref(list->reflist, refptr)) release_render_list(list); osd_lock_release(list->lock); } }
/*------------------------------------------------- invalidate_all_render_ref - remove all refs to a particular reference pointer -------------------------------------------------*/
remove all refs to a particular reference pointer
[ "remove", "all", "refs", "to", "a", "particular", "reference", "pointer" ]
static void invalidate_all_render_ref(void *refptr) { render_target *target; int listnum; for (target = targetlist; target != NULL; target = target->next) for (listnum = 0; listnum < ARRAY_LENGTH(target->primlist); listnum++) { render_primitive_list *list = &target->primlist[listnum]; osd_lock_acquire(list->lock); if (has_render_ref(list->reflist, refptr)) release_render_list(list); osd_lock_release(list->lock); } }
[ "static", "void", "invalidate_all_render_ref", "(", "void", "*", "refptr", ")", "{", "render_target", "*", "target", ";", "int", "listnum", ";", "for", "(", "target", "=", "targetlist", ";", "target", "!=", "NULL", ";", "target", "=", "target", "->", "next", ")", "for", "(", "listnum", "=", "0", ";", "listnum", "<", "ARRAY_LENGTH", "(", "target", "->", "primlist", ")", ";", "listnum", "++", ")", "{", "render_primitive_list", "*", "list", "=", "&", "target", "->", "primlist", "[", "listnum", "]", ";", "osd_lock_acquire", "(", "list", "->", "lock", ")", ";", "if", "(", "has_render_ref", "(", "list", "->", "reflist", ",", "refptr", ")", ")", "release_render_list", "(", "list", ")", ";", "osd_lock_release", "(", "list", "->", "lock", ")", ";", "}", "}" ]
invalidate_all_render_ref - remove all refs to a particular reference pointer
[ "invalidate_all_render_ref", "-", "remove", "all", "refs", "to", "a", "particular", "reference", "pointer" ]
[ "/* loop over targets */" ]
[ { "param": "refptr", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "refptr", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f08d4faea9078af6cfe316fec86d7cdea6e9e3ab
lofunz/mieme
Reloaded/trunk/src/emu/render.c
[ "Unlicense" ]
C
texture_get_adjusted_palette
rgb_t
static const rgb_t *texture_get_adjusted_palette(render_texture *texture, render_container *container) { const rgb_t *adjusted; int numentries; int index; /* override the palette with our adjusted palette */ switch (texture->format) { case TEXFORMAT_PALETTE16: case TEXFORMAT_PALETTEA16: /* if no adjustment necessary, return the raw palette */ assert(texture->palette != NULL); adjusted = palette_entry_list_adjusted(texture->palette); if (container->brightness == 1.0f && container->contrast == 1.0f && container->gamma == 1.0f) return adjusted; /* if this is the machine palette, return our precomputed adjusted palette */ if (container->palclient != NULL && palette_client_get_palette(container->palclient) == texture->palette) return container->bcglookup; /* otherwise, ensure we have memory allocated and compute the adjusted result ourself */ numentries = palette_get_num_colors(texture->palette) * palette_get_num_groups(texture->palette); if (texture->bcglookup == NULL || texture->bcglookup_entries < numentries) { rgb_t *newlookup = global_alloc_array(rgb_t, numentries); memcpy(newlookup, texture->bcglookup, texture->bcglookup_entries * sizeof(rgb_t)); global_free(texture->bcglookup); texture->bcglookup = newlookup; texture->bcglookup_entries = numentries; } for (index = 0; index < numentries; index++) { UINT8 r = apply_brightness_contrast_gamma(RGB_RED(adjusted[index]), container->brightness, container->contrast, container->gamma); UINT8 g = apply_brightness_contrast_gamma(RGB_GREEN(adjusted[index]), container->brightness, container->contrast, container->gamma); UINT8 b = apply_brightness_contrast_gamma(RGB_BLUE(adjusted[index]), container->brightness, container->contrast, container->gamma); texture->bcglookup[index] = MAKE_ARGB(RGB_ALPHA(adjusted[index]), r, g, b); } return texture->bcglookup; case TEXFORMAT_RGB15: /* if no adjustment necessary, return NULL */ if (container->brightness == 1.0f && container->contrast == 1.0f && container->gamma == 1.0f && texture->palette == NULL) return NULL; /* if no palette, return the standard lookups */ if (texture->palette == NULL) return container->bcglookup32; /* otherwise, ensure we have memory allocated and compute the adjusted result ourself */ assert(palette_get_num_colors(texture->palette) == 32); adjusted = palette_entry_list_adjusted(texture->palette); if (texture->bcglookup == NULL || texture->bcglookup_entries < 4 * 32) { rgb_t *newlookup = global_alloc_array(rgb_t, 4 * 32); memcpy(newlookup, texture->bcglookup, texture->bcglookup_entries * sizeof(rgb_t)); global_free(texture->bcglookup); texture->bcglookup = newlookup; texture->bcglookup_entries = 4 * 32; } /* otherwise, return the 32-entry BCG lookups */ for (index = 0; index < 32; index++) { UINT8 val = apply_brightness_contrast_gamma(RGB_GREEN(adjusted[index]), container->brightness, container->contrast, container->gamma); texture->bcglookup[0x00 + index] = val << 0; texture->bcglookup[0x20 + index] = val << 8; texture->bcglookup[0x40 + index] = val << 16; texture->bcglookup[0x60 + index] = val << 24; } return texture->bcglookup; case TEXFORMAT_RGB32: case TEXFORMAT_ARGB32: case TEXFORMAT_YUY16: /* if no adjustment necessary, return NULL */ if (container->brightness == 1.0f && container->contrast == 1.0f && container->gamma == 1.0f && texture->palette == NULL) return NULL; /* if no palette, return the standard lookups */ if (texture->palette == NULL) return container->bcglookup256; /* otherwise, ensure we have memory allocated and compute the adjusted result ourself */ assert(palette_get_num_colors(texture->palette) == 256); adjusted = palette_entry_list_adjusted(texture->palette); if (texture->bcglookup == NULL || texture->bcglookup_entries < 4 * 256) { rgb_t *newlookup = global_alloc_array(rgb_t, 4 * 256); memcpy(newlookup, texture->bcglookup, texture->bcglookup_entries * sizeof(rgb_t)); global_free(texture->bcglookup); texture->bcglookup = newlookup; texture->bcglookup_entries = 4 * 256; } /* otherwise, return the 32-entry BCG lookups */ for (index = 0; index < 256; index++) { UINT8 val = apply_brightness_contrast_gamma(RGB_GREEN(adjusted[index]), container->brightness, container->contrast, container->gamma); texture->bcglookup[0x000 + index] = val << 0; texture->bcglookup[0x100 + index] = val << 8; texture->bcglookup[0x200 + index] = val << 16; texture->bcglookup[0x300 + index] = val << 24; } return texture->bcglookup; default: assert(FALSE); } return NULL; }
/*------------------------------------------------- texture_get_adjusted_palette - return the adjusted palette for a texture -------------------------------------------------*/
return the adjusted palette for a texture
[ "return", "the", "adjusted", "palette", "for", "a", "texture" ]
static const rgb_t *texture_get_adjusted_palette(render_texture *texture, render_container *container) { const rgb_t *adjusted; int numentries; int index; switch (texture->format) { case TEXFORMAT_PALETTE16: case TEXFORMAT_PALETTEA16: assert(texture->palette != NULL); adjusted = palette_entry_list_adjusted(texture->palette); if (container->brightness == 1.0f && container->contrast == 1.0f && container->gamma == 1.0f) return adjusted; if (container->palclient != NULL && palette_client_get_palette(container->palclient) == texture->palette) return container->bcglookup; numentries = palette_get_num_colors(texture->palette) * palette_get_num_groups(texture->palette); if (texture->bcglookup == NULL || texture->bcglookup_entries < numentries) { rgb_t *newlookup = global_alloc_array(rgb_t, numentries); memcpy(newlookup, texture->bcglookup, texture->bcglookup_entries * sizeof(rgb_t)); global_free(texture->bcglookup); texture->bcglookup = newlookup; texture->bcglookup_entries = numentries; } for (index = 0; index < numentries; index++) { UINT8 r = apply_brightness_contrast_gamma(RGB_RED(adjusted[index]), container->brightness, container->contrast, container->gamma); UINT8 g = apply_brightness_contrast_gamma(RGB_GREEN(adjusted[index]), container->brightness, container->contrast, container->gamma); UINT8 b = apply_brightness_contrast_gamma(RGB_BLUE(adjusted[index]), container->brightness, container->contrast, container->gamma); texture->bcglookup[index] = MAKE_ARGB(RGB_ALPHA(adjusted[index]), r, g, b); } return texture->bcglookup; case TEXFORMAT_RGB15: if (container->brightness == 1.0f && container->contrast == 1.0f && container->gamma == 1.0f && texture->palette == NULL) return NULL; if (texture->palette == NULL) return container->bcglookup32; assert(palette_get_num_colors(texture->palette) == 32); adjusted = palette_entry_list_adjusted(texture->palette); if (texture->bcglookup == NULL || texture->bcglookup_entries < 4 * 32) { rgb_t *newlookup = global_alloc_array(rgb_t, 4 * 32); memcpy(newlookup, texture->bcglookup, texture->bcglookup_entries * sizeof(rgb_t)); global_free(texture->bcglookup); texture->bcglookup = newlookup; texture->bcglookup_entries = 4 * 32; } for (index = 0; index < 32; index++) { UINT8 val = apply_brightness_contrast_gamma(RGB_GREEN(adjusted[index]), container->brightness, container->contrast, container->gamma); texture->bcglookup[0x00 + index] = val << 0; texture->bcglookup[0x20 + index] = val << 8; texture->bcglookup[0x40 + index] = val << 16; texture->bcglookup[0x60 + index] = val << 24; } return texture->bcglookup; case TEXFORMAT_RGB32: case TEXFORMAT_ARGB32: case TEXFORMAT_YUY16: if (container->brightness == 1.0f && container->contrast == 1.0f && container->gamma == 1.0f && texture->palette == NULL) return NULL; if (texture->palette == NULL) return container->bcglookup256; assert(palette_get_num_colors(texture->palette) == 256); adjusted = palette_entry_list_adjusted(texture->palette); if (texture->bcglookup == NULL || texture->bcglookup_entries < 4 * 256) { rgb_t *newlookup = global_alloc_array(rgb_t, 4 * 256); memcpy(newlookup, texture->bcglookup, texture->bcglookup_entries * sizeof(rgb_t)); global_free(texture->bcglookup); texture->bcglookup = newlookup; texture->bcglookup_entries = 4 * 256; } for (index = 0; index < 256; index++) { UINT8 val = apply_brightness_contrast_gamma(RGB_GREEN(adjusted[index]), container->brightness, container->contrast, container->gamma); texture->bcglookup[0x000 + index] = val << 0; texture->bcglookup[0x100 + index] = val << 8; texture->bcglookup[0x200 + index] = val << 16; texture->bcglookup[0x300 + index] = val << 24; } return texture->bcglookup; default: assert(FALSE); } return NULL; }
[ "static", "const", "rgb_t", "*", "texture_get_adjusted_palette", "(", "render_texture", "*", "texture", ",", "render_container", "*", "container", ")", "{", "const", "rgb_t", "*", "adjusted", ";", "int", "numentries", ";", "int", "index", ";", "switch", "(", "texture", "->", "format", ")", "{", "case", "TEXFORMAT_PALETTE16", ":", "case", "TEXFORMAT_PALETTEA16", ":", "assert", "(", "texture", "->", "palette", "!=", "NULL", ")", ";", "adjusted", "=", "palette_entry_list_adjusted", "(", "texture", "->", "palette", ")", ";", "if", "(", "container", "->", "brightness", "==", "1.0f", "&&", "container", "->", "contrast", "==", "1.0f", "&&", "container", "->", "gamma", "==", "1.0f", ")", "return", "adjusted", ";", "if", "(", "container", "->", "palclient", "!=", "NULL", "&&", "palette_client_get_palette", "(", "container", "->", "palclient", ")", "==", "texture", "->", "palette", ")", "return", "container", "->", "bcglookup", ";", "numentries", "=", "palette_get_num_colors", "(", "texture", "->", "palette", ")", "*", "palette_get_num_groups", "(", "texture", "->", "palette", ")", ";", "if", "(", "texture", "->", "bcglookup", "==", "NULL", "||", "texture", "->", "bcglookup_entries", "<", "numentries", ")", "{", "rgb_t", "*", "newlookup", "=", "global_alloc_array", "(", "rgb_t", ",", "numentries", ")", ";", "memcpy", "(", "newlookup", ",", "texture", "->", "bcglookup", ",", "texture", "->", "bcglookup_entries", "*", "sizeof", "(", "rgb_t", ")", ")", ";", "global_free", "(", "texture", "->", "bcglookup", ")", ";", "texture", "->", "bcglookup", "=", "newlookup", ";", "texture", "->", "bcglookup_entries", "=", "numentries", ";", "}", "for", "(", "index", "=", "0", ";", "index", "<", "numentries", ";", "index", "++", ")", "{", "UINT8", "r", "=", "apply_brightness_contrast_gamma", "(", "RGB_RED", "(", "adjusted", "[", "index", "]", ")", ",", "container", "->", "brightness", ",", "container", "->", "contrast", ",", "container", "->", "gamma", ")", ";", "UINT8", "g", "=", "apply_brightness_contrast_gamma", "(", "RGB_GREEN", "(", "adjusted", "[", "index", "]", ")", ",", "container", "->", "brightness", ",", "container", "->", "contrast", ",", "container", "->", "gamma", ")", ";", "UINT8", "b", "=", "apply_brightness_contrast_gamma", "(", "RGB_BLUE", "(", "adjusted", "[", "index", "]", ")", ",", "container", "->", "brightness", ",", "container", "->", "contrast", ",", "container", "->", "gamma", ")", ";", "texture", "->", "bcglookup", "[", "index", "]", "=", "MAKE_ARGB", "(", "RGB_ALPHA", "(", "adjusted", "[", "index", "]", ")", ",", "r", ",", "g", ",", "b", ")", ";", "}", "return", "texture", "->", "bcglookup", ";", "case", "TEXFORMAT_RGB15", ":", "if", "(", "container", "->", "brightness", "==", "1.0f", "&&", "container", "->", "contrast", "==", "1.0f", "&&", "container", "->", "gamma", "==", "1.0f", "&&", "texture", "->", "palette", "==", "NULL", ")", "return", "NULL", ";", "if", "(", "texture", "->", "palette", "==", "NULL", ")", "return", "container", "->", "bcglookup32", ";", "assert", "(", "palette_get_num_colors", "(", "texture", "->", "palette", ")", "==", "32", ")", ";", "adjusted", "=", "palette_entry_list_adjusted", "(", "texture", "->", "palette", ")", ";", "if", "(", "texture", "->", "bcglookup", "==", "NULL", "||", "texture", "->", "bcglookup_entries", "<", "4", "*", "32", ")", "{", "rgb_t", "*", "newlookup", "=", "global_alloc_array", "(", "rgb_t", ",", "4", "*", "32", ")", ";", "memcpy", "(", "newlookup", ",", "texture", "->", "bcglookup", ",", "texture", "->", "bcglookup_entries", "*", "sizeof", "(", "rgb_t", ")", ")", ";", "global_free", "(", "texture", "->", "bcglookup", ")", ";", "texture", "->", "bcglookup", "=", "newlookup", ";", "texture", "->", "bcglookup_entries", "=", "4", "*", "32", ";", "}", "for", "(", "index", "=", "0", ";", "index", "<", "32", ";", "index", "++", ")", "{", "UINT8", "val", "=", "apply_brightness_contrast_gamma", "(", "RGB_GREEN", "(", "adjusted", "[", "index", "]", ")", ",", "container", "->", "brightness", ",", "container", "->", "contrast", ",", "container", "->", "gamma", ")", ";", "texture", "->", "bcglookup", "[", "0x00", "+", "index", "]", "=", "val", "<<", "0", ";", "texture", "->", "bcglookup", "[", "0x20", "+", "index", "]", "=", "val", "<<", "8", ";", "texture", "->", "bcglookup", "[", "0x40", "+", "index", "]", "=", "val", "<<", "16", ";", "texture", "->", "bcglookup", "[", "0x60", "+", "index", "]", "=", "val", "<<", "24", ";", "}", "return", "texture", "->", "bcglookup", ";", "case", "TEXFORMAT_RGB32", ":", "case", "TEXFORMAT_ARGB32", ":", "case", "TEXFORMAT_YUY16", ":", "if", "(", "container", "->", "brightness", "==", "1.0f", "&&", "container", "->", "contrast", "==", "1.0f", "&&", "container", "->", "gamma", "==", "1.0f", "&&", "texture", "->", "palette", "==", "NULL", ")", "return", "NULL", ";", "if", "(", "texture", "->", "palette", "==", "NULL", ")", "return", "container", "->", "bcglookup256", ";", "assert", "(", "palette_get_num_colors", "(", "texture", "->", "palette", ")", "==", "256", ")", ";", "adjusted", "=", "palette_entry_list_adjusted", "(", "texture", "->", "palette", ")", ";", "if", "(", "texture", "->", "bcglookup", "==", "NULL", "||", "texture", "->", "bcglookup_entries", "<", "4", "*", "256", ")", "{", "rgb_t", "*", "newlookup", "=", "global_alloc_array", "(", "rgb_t", ",", "4", "*", "256", ")", ";", "memcpy", "(", "newlookup", ",", "texture", "->", "bcglookup", ",", "texture", "->", "bcglookup_entries", "*", "sizeof", "(", "rgb_t", ")", ")", ";", "global_free", "(", "texture", "->", "bcglookup", ")", ";", "texture", "->", "bcglookup", "=", "newlookup", ";", "texture", "->", "bcglookup_entries", "=", "4", "*", "256", ";", "}", "for", "(", "index", "=", "0", ";", "index", "<", "256", ";", "index", "++", ")", "{", "UINT8", "val", "=", "apply_brightness_contrast_gamma", "(", "RGB_GREEN", "(", "adjusted", "[", "index", "]", ")", ",", "container", "->", "brightness", ",", "container", "->", "contrast", ",", "container", "->", "gamma", ")", ";", "texture", "->", "bcglookup", "[", "0x000", "+", "index", "]", "=", "val", "<<", "0", ";", "texture", "->", "bcglookup", "[", "0x100", "+", "index", "]", "=", "val", "<<", "8", ";", "texture", "->", "bcglookup", "[", "0x200", "+", "index", "]", "=", "val", "<<", "16", ";", "texture", "->", "bcglookup", "[", "0x300", "+", "index", "]", "=", "val", "<<", "24", ";", "}", "return", "texture", "->", "bcglookup", ";", "default", ":", "assert", "(", "FALSE", ")", ";", "}", "return", "NULL", ";", "}" ]
texture_get_adjusted_palette - return the adjusted palette for a texture
[ "texture_get_adjusted_palette", "-", "return", "the", "adjusted", "palette", "for", "a", "texture" ]
[ "/* override the palette with our adjusted palette */", "/* if no adjustment necessary, return the raw palette */", "/* if this is the machine palette, return our precomputed adjusted palette */", "/* otherwise, ensure we have memory allocated and compute the adjusted result ourself */", "/* if no adjustment necessary, return NULL */", "/* if no palette, return the standard lookups */", "/* otherwise, ensure we have memory allocated and compute the adjusted result ourself */", "/* otherwise, return the 32-entry BCG lookups */", "/* if no adjustment necessary, return NULL */", "/* if no palette, return the standard lookups */", "/* otherwise, ensure we have memory allocated and compute the adjusted result ourself */", "/* otherwise, return the 32-entry BCG lookups */" ]
[ { "param": "texture", "type": "render_texture" }, { "param": "container", "type": "render_container" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "texture", "type": "render_texture", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "container", "type": "render_container", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f08d4faea9078af6cfe316fec86d7cdea6e9e3ab
lofunz/mieme
Reloaded/trunk/src/emu/render.c
[ "Unlicense" ]
C
render_container_get_user_settings
void
void render_container_get_user_settings(render_container *container, render_container_user_settings *settings) { settings->orientation = container->orientation; settings->brightness = container->brightness; settings->contrast = container->contrast; settings->gamma = container->gamma; settings->xscale = container->xscale; settings->yscale = container->yscale; settings->xoffset = container->xoffset; settings->yoffset = container->yoffset; }
/*------------------------------------------------- render_container_get_user_settings - get the current user settings for a container -------------------------------------------------*/
get the current user settings for a container
[ "get", "the", "current", "user", "settings", "for", "a", "container" ]
void render_container_get_user_settings(render_container *container, render_container_user_settings *settings) { settings->orientation = container->orientation; settings->brightness = container->brightness; settings->contrast = container->contrast; settings->gamma = container->gamma; settings->xscale = container->xscale; settings->yscale = container->yscale; settings->xoffset = container->xoffset; settings->yoffset = container->yoffset; }
[ "void", "render_container_get_user_settings", "(", "render_container", "*", "container", ",", "render_container_user_settings", "*", "settings", ")", "{", "settings", "->", "orientation", "=", "container", "->", "orientation", ";", "settings", "->", "brightness", "=", "container", "->", "brightness", ";", "settings", "->", "contrast", "=", "container", "->", "contrast", ";", "settings", "->", "gamma", "=", "container", "->", "gamma", ";", "settings", "->", "xscale", "=", "container", "->", "xscale", ";", "settings", "->", "yscale", "=", "container", "->", "yscale", ";", "settings", "->", "xoffset", "=", "container", "->", "xoffset", ";", "settings", "->", "yoffset", "=", "container", "->", "yoffset", ";", "}" ]
render_container_get_user_settings - get the current user settings for a container
[ "render_container_get_user_settings", "-", "get", "the", "current", "user", "settings", "for", "a", "container" ]
[]
[ { "param": "container", "type": "render_container" }, { "param": "settings", "type": "render_container_user_settings" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "container", "type": "render_container", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "settings", "type": "render_container_user_settings", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }