mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-19 01:12:33 +00:00
Bitmasking.
This commit is contained in:
parent
200d2b598b
commit
02344f9048
@ -394,6 +394,7 @@ static bool load_imports(config_file_t *conf)
|
||||
char oam_buf[64];
|
||||
char cgram_buf[64];
|
||||
char vram_buf[64];
|
||||
char mask_buf[64];
|
||||
|
||||
print_buf(semantic_buf, "%s_semantic", id);
|
||||
print_buf(wram_buf, "%s_wram", id);
|
||||
@ -401,6 +402,7 @@ static bool load_imports(config_file_t *conf)
|
||||
print_buf(oam_buf, "%s_oam", id);
|
||||
print_buf(cgram_buf, "%s_cgram", id);
|
||||
print_buf(vram_buf, "%s_vram", id);
|
||||
print_buf(mask_buf, "%s_mask", id);
|
||||
|
||||
char *semantic = NULL;
|
||||
|
||||
@ -474,10 +476,15 @@ static bool load_imports(config_file_t *conf)
|
||||
goto error;
|
||||
}
|
||||
|
||||
unsigned bitmask = 0;
|
||||
if (!config_get_hex(conf, mask_buf, &bitmask))
|
||||
bitmask = 0;
|
||||
|
||||
strlcpy(info[info_cnt].id, id, sizeof(info[info_cnt].id));
|
||||
info[info_cnt].addr = addr;
|
||||
info[info_cnt].type = tracker_type;
|
||||
info[info_cnt].ram_type = ram_type;
|
||||
info[info_cnt].mask = bitmask;
|
||||
|
||||
info_cnt++;
|
||||
free(semantic);
|
||||
|
@ -393,6 +393,7 @@ static bool get_import_value(xmlNodePtr ptr)
|
||||
xmlChar *vram = xmlGetProp(ptr, (const xmlChar*)"vram");
|
||||
xmlChar *oam = xmlGetProp(ptr, (const xmlChar*)"oam");
|
||||
xmlChar *cgram = xmlGetProp(ptr, (const xmlChar*)"cgram");
|
||||
xmlChar *bitmask = xmlGetProp(ptr, (const xmlChar*)"mask");
|
||||
|
||||
if (!semantic || !id)
|
||||
{
|
||||
@ -457,10 +458,15 @@ static bool get_import_value(xmlNodePtr ptr)
|
||||
goto error;
|
||||
}
|
||||
|
||||
unsigned mask_value = 0;
|
||||
if (bitmask)
|
||||
mask_value = strtoul((const char*)bitmask, NULL, 16);
|
||||
|
||||
strlcpy(gl_tracker_info[gl_tracker_info_cnt].id, (const char*)id, sizeof(gl_tracker_info[0].id));
|
||||
gl_tracker_info[gl_tracker_info_cnt].addr = addr;
|
||||
gl_tracker_info[gl_tracker_info_cnt].type = tracker_type;
|
||||
gl_tracker_info[gl_tracker_info_cnt].ram_type = ram_type;
|
||||
gl_tracker_info[gl_tracker_info_cnt].mask = mask_value;
|
||||
gl_tracker_info_cnt++;
|
||||
|
||||
if (id) xmlFree(id);
|
||||
@ -470,6 +476,7 @@ static bool get_import_value(xmlNodePtr ptr)
|
||||
if (vram) xmlFree(vram);
|
||||
if (oam) xmlFree(oam);
|
||||
if (cgram) xmlFree(cgram);
|
||||
if (bitmask) xmlFree(bitmask);
|
||||
return true;
|
||||
|
||||
error:
|
||||
@ -480,6 +487,7 @@ error:
|
||||
if (vram) xmlFree(vram);
|
||||
if (oam) xmlFree(oam);
|
||||
if (cgram) xmlFree(cgram);
|
||||
if (bitmask) xmlFree(bitmask);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ struct snes_tracker_internal
|
||||
|
||||
const uint8_t *ptr;
|
||||
uint32_t addr;
|
||||
uint8_t mask;
|
||||
|
||||
enum snes_tracker_type type;
|
||||
|
||||
@ -54,6 +55,7 @@ snes_tracker_t* snes_tracker_init(const struct snes_tracker_info *info)
|
||||
strlcpy(tracker->info[i].id, info->info[i].id, sizeof(tracker->info[i].id));
|
||||
tracker->info[i].addr = info->info[i].addr;
|
||||
tracker->info[i].type = info->info[i].type;
|
||||
tracker->info[i].mask = (info->info[i].mask == 0) ? 0xff : info->info[i].mask;
|
||||
|
||||
assert(info->wram && info->vram && info->cgram &&
|
||||
info->oam && info->apuram);
|
||||
@ -91,6 +93,8 @@ void snes_tracker_free(snes_tracker_t *tracker)
|
||||
free(tracker);
|
||||
}
|
||||
|
||||
#define fetch(addr) (info->ptr[info->addr] & info->mask)
|
||||
|
||||
static void update_element(
|
||||
struct snes_tracker_uniform *uniform,
|
||||
struct snes_tracker_internal *info,
|
||||
@ -101,22 +105,22 @@ static void update_element(
|
||||
switch (info->type)
|
||||
{
|
||||
case SSNES_STATE_CAPTURE:
|
||||
uniform->value = info->ptr[info->addr];
|
||||
uniform->value = fetch(addr);
|
||||
break;
|
||||
|
||||
case SSNES_STATE_CAPTURE_PREV:
|
||||
if (info->prev[0] != info->ptr[info->addr])
|
||||
if (info->prev[0] != fetch(addr))
|
||||
{
|
||||
info->prev[1] = info->prev[0];
|
||||
info->prev[0] = info->ptr[info->addr];
|
||||
info->prev[0] = fetch(addr);
|
||||
}
|
||||
uniform->value = info->prev[1];
|
||||
break;
|
||||
|
||||
case SSNES_STATE_TRANSITION:
|
||||
if (info->old_value != info->ptr[info->addr])
|
||||
if (info->old_value != fetch(addr))
|
||||
{
|
||||
info->old_value = info->ptr[info->addr];
|
||||
info->old_value = fetch(addr);
|
||||
info->frame_count = frame_count;
|
||||
}
|
||||
uniform->value = info->frame_count;
|
||||
@ -124,9 +128,9 @@ static void update_element(
|
||||
break;
|
||||
|
||||
case SSNES_STATE_TRANSITION_PREV:
|
||||
if (info->prev[0] != info->ptr[info->addr])
|
||||
if (info->prev[0] != fetch(addr))
|
||||
{
|
||||
info->old_value = info->ptr[info->addr];
|
||||
info->old_value = fetch(addr);
|
||||
info->prev[1] = info->prev[0];
|
||||
info->prev[0] = frame_count;
|
||||
info->frame_count = frame_count;
|
||||
@ -140,6 +144,8 @@ static void update_element(
|
||||
}
|
||||
}
|
||||
|
||||
#undef fetch
|
||||
|
||||
unsigned snes_get_uniform(snes_tracker_t *tracker, struct snes_tracker_uniform *uniforms, unsigned elem, unsigned frame_count)
|
||||
{
|
||||
unsigned elems = tracker->info_elem < elem ? tracker->info_elem : elem;
|
||||
|
@ -43,6 +43,7 @@ struct snes_tracker_uniform_info
|
||||
uint32_t addr;
|
||||
enum snes_tracker_type type;
|
||||
enum snes_ram_type ram_type;
|
||||
uint8_t mask;
|
||||
};
|
||||
|
||||
struct snes_tracker_info
|
||||
|
Loading…
x
Reference in New Issue
Block a user