/* Flower Video Hardware */
#include "driver.h"
static tilemap *flower_bg0_tilemap, *flower_bg1_tilemap, *flower_text_tilemap, *flower_text_right_tilemap;
UINT8 *flower_textram, *flower_bg0ram, *flower_bg1ram, *flower_bg0_scroll, *flower_bg1_scroll;
PALETTE_INIT( flower )
{
int i;
/* allocate the colortable */
machine->colortable = colortable_alloc(machine, 0x100);
/* create a lookup table for the palette */
for (i = 0; i < 0x100; i++)
{
int r = pal4bit(color_prom[i + 0x000]);
int g = pal4bit(color_prom[i + 0x100]);
int b = pal4bit(color_prom[i + 0x200]);
colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b));
}
for (i = 0;pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */// license:BSD-3-Clause
// copyright-holders:Nathan Woods
/****************************************************************************
opresolv.h
Extensible ranged option resolution handling
****************************************************************************/
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "pool.h"
#include "corestr.h"
#include "opresolv.h"
enum resolution_entry_state
{
RESOLUTION_ENTRY_STATE_UNSPECIFIED,
RESOLUTION_ENTRY_STATE_SPECIFIED
};
struct option_resolution_entry
{
const option_guide *guide_entry;
enum resolution_entry_state state;
union
{
int int_value;
const char *str_value;
} u;
};
struct option_resolution
{
object_pool *pool;
const char *specification;
size_t option_count;
struct option_resolution_entry *entries;
};
static optreserr_t resolve_single_param(const char *specification, int *param_value,
struct OptionRange *range, size_t range_count)
{
int FLAG_IN_RANGE = 0x01;
int FLAG_IN_DEFAULT = 0x02;
int FLAG_DEFAULT_SPECIFIED = 0x04;
int FLAG_HALF_RANGE = 0x08;
int last_value = 0;
int value = 0;
int flags = 0;
const char *s = specification;
while(*s && !isalpha(*s))
{
if (*s == '-')
{
/* range specifier */
if (flags & (FLAG_IN_RANGE|FLAG_IN_DEFAULT))
{
return OPTIONRESOLUTION_ERROR_SYNTAX;
}
flags |= FLAG_IN_RANGE;
s++;
if (range)
{
range->max = -1;
if ((flags & FLAG_HALF_RANGE) == 0)
{
range->min = -1;
flags |= FLAG_HALF_RANGE;
}
}
}
else if (*s == '[')
{
/* begin default value */
if (flags & (FLAG_IN_DEFAULT|FLAG_DEFAULT_SPECIFIED))
{
return OPTIONRESOLUTION_ERROR_SYNTAX;
}
flags |= FLAG_IN_DEFAULT;
s++;
}
else if (*s == ']')
{
/* end default value */
if ((flags & FLAG_IN_DEFAULT) == 0)
{
return OPTIONRESOLUTION_ERROR_SYNTAX;
}
flags &= ~FLAG_IN_DEFAULT;
flags |= FLAG_DEFAULT_SPECIFIED;
s++;
if (param_value && *param_value == -1)
*param_value = value;
}
else if (*s == '/')
{
/* value separator */
if (flags & (FLAG_IN_DEFAULT|FLAG_IN_RANGE))
{
return OPTIONRESOLUTION_ERROR_SYNTAX;
}
s++;
/* if we are spitting out ranges, complete the range */
if (range && (flags & FLAG_HALF_RANGE))
{
range++;
flags &= ~FLAG_HALF_RANGE;
if (--range_count == 0)
range = nullptr;
}
}
else if (*s == ';')
{
/* basic separator */
s++;
}
else if (isdigit(*s))
{
/* numeric value */
last_value = value;
value = 0;
do
{
value *= 10;
value += *s - '0';
s++;
}
while(isdigit(*s));
if (range)
{
if ((flags & FLAG_HALF_RANGE) == 0)
{
range->min = value;
flags |= FLAG_HALF_RANGE;
}
range->max = value;
}
/* if we have a value; check to see if it is out of range */
if (param_value && (*param_value != -1) && (*param_value != value))
{
if ((last_value < *param_value) && (*param_value < value))
{
if ((flags & FLAG_IN_RANGE) == 0)
return OPTIONRESOLUTION_ERROR_PARAMOUTOFRANGE;
}
}
flags &= ~FLAG_IN_RANGE;
}
else
{
return OPTIONRESOLUTION_ERROR_SYNTAX;
}
}
/* we can't have zero length guidelines strings */
if (s == specification)
{
return OPTIONRESOLUTION_ERROR_SYNTAX;
}
return OPTIONRESOLUTION_ERROR_SUCCESS;
}
static const char *lookup_in_specification(const char *specification, const option_guide *option)
{
const char *s;
s = strchr(specification, option->parameter);
return s ? s + 1 : nullptr;
}
option_resolution *option_resolution_create(const option_guide *guide, const char *specification)
{
option_resolution *resolution = nullptr;
const option_guide *guide_entry;
int option_count;
int opt = -1;
object_pool *pool;
assert(guide);
/* first count the number of options specified in the guide */
option_count = option_resolution_countoptions(guide, specification);
/* create a memory pool for this structure */
pool = pool_alloc_lib(nullptr);
if (!pool)
goto outofmemory;
/* allocate the main structure */
resolution = (option_resolution *)pool_malloc_lib(pool, sizeof(option_resolution));
if (!resolution)
goto outofmemory;
memset(resolution, 0, sizeof(*resolution));
resolution->pool = pool;
/* set up the entries list */
resolution->option_count = option_count;
resolution->specification = specification;
resolution->entries = (option_resolution_entry *)pool_malloc_lib(resolution->pool, sizeof(struct option_resolution_entry) * option_count);
if (!resolution->entries)
goto outofmemory;
memset(resolution->entries, 0, sizeof(struct option_resolution_entry) * option_count);
/* initialize each of the entries */
opt = 0;
guide_entry = guide;
while(guide_entry->option_type != OPTIONTYPE_END)
{
switch(guide_entry->option_type) {
case OPTIONTYPE_INT:
case OPTIONTYPE_ENUM_BEGIN:
case OPTIONTYPE_STRING:
if (lookup_in_specification(specification, guide_entry))
resolution->entries[opt++].guide_entry = guide_entry;
break;
case OPTIONTYPE_ENUM_VALUE:
break;
default:
goto unexpected;
}
guide_entry++;
}
assert(opt == option_count);
return resolution;
unexpected:
assert(FALSE);
outofmemory:
if (resolution)
option_resolution_close(resolution);
return nullptr;
}
optreserr_t option_resolution_add_param(option_resolution *resolution, const char *param, const char *value)
{
int i;
int must_resolve;
optreserr_t err;
const char *option_specification;
struct option_resolution_entry *entry = nullptr;
for (i = 0; i < resolution->option_count; i++)
{
if (!strcmp(param, resolution->entries[i].guide_entry->identifier))
{
entry = &resolution->entries[i];
break;
}
}
if (!entry)
return OPTIONRESOLUTION_ERROR_PARAMNOTFOUND;
if (entry->state != RESOLUTION_ENTRY_STATE_UNSPECIFIED)
return OPTIONRESOLUTION_ERROR_PARAMALREADYSPECIFIED;
switch(entry->guide_entry->option_type) {
case OPTIONTYPE_INT:
entry->u.int_value = atoi(value);
entry->state = RESOLUTION_ENTRY_STATE_SPECIFIED;
must_resolve = TRUE;
break;
case OPTIONTYPE_STRING:
entry->u.str_value = pool_strdup_lib(resolution->pool, value);
if (!entry->u.str_value)
{
err = OPTIONRESOLUTION_ERROR_OUTOFMEMORY;
goto done;
}
entry->state = RESOLUTION_ENTRY_STATE_SPECIFIED;
must_resolve = FALSE;
break;
case OPTIONTYPE_ENUM_BEGIN:
for (i = 1; entry->guide_entry[i].option_type == OPTIONTYPE_ENUM_VALUE; i++)
{
if (!core_stricmp(value, entry->guide_entry[i].identifier))
{
entry->u.int_value = entry->guide_entry[i].parameter;
entry->state = RESOLUTION_ENTRY_STATE_SPECIFIED;
break;
}
}
if (entry->state != RESOLUTION_ENTRY_STATE_SPECIFIED)
{
err = OPTIONRESOLUTION_ERROR_BADPARAM;
goto done;
}
must_resolve = TRUE;
break;
default:
err = OPTIONRESOLTUION_ERROR_INTERNAL;
assert(0);
goto done;
}
/* do a resolution step if necessary */
if (must_resolve)
{
option_specification = lookup_in_specification(resolution->specification, entry->guide_entry);
err = resolve_single_param(option_specification, &entry->u.int_value, nullptr, 0);
if (err)
goto done;
/* did we not get a real value? */
if (entry->u.int_value < 0)
{
err = OPTIONRESOLUTION_ERROR_PARAMNOTSPECIFIED;
goto done;
}
}
err = OPTIONRESOLUTION_ERROR_SUCCESS;
done:
return err;
}
void option_resolution_close(option_resolution *resolution)
{
pool_free_lib(resolution->pool);
}
optreserr_t option_resolution_finish(option_resolution *resolution)
{
int i;
optreserr_t err;
struct option_resolution_entry *entry;
const char *option_specification;
for (i = 0; i < resolution->option_count; i++)
{
entry = &resolution->entries[i];
if (entry->state == RESOLUTION_ENTRY_STATE_UNSPECIFIED)
{
switch(entry->guide_entry->option_type) {
case OPTIONTYPE_INT:
case OPTIONTYPE_ENUM_BEGIN:
option_specification = lookup_in_specification(resolution->specification, entry->guide_entry);
assert(option_specification);
entry->u.int_value = -1;
err = resolve_single_param(option_specification, &entry->u.int_value, nullptr, 0);
if (err)
return err;
break;
case OPTIONTYPE_STRING:
entry->u.str_value = "";
break;
default:
assert(FALSE);
return OPTIONRESOLTUION_ERROR_INTERNAL;
}
entry->state = RESOLUTION_ENTRY_STATE_SPECIFIED;
}
}
return OPTIONRESOLUTION_ERROR_SUCCESS;
}
static const struct option_resolution_entry *option_resolution_lookup_entry(option_resolution *resolution, int option_char)
{
size_t i;
const struct option_resolution_entry *entry;
for (i = 0; i < resolution->option_count; i++)
{
entry = &resolution->entries[i];
switch(entry->guide_entry->option_type) {
case OPTIONTYPE_INT:
case OPTIONTYPE_STRING:
case OPTIONTYPE_ENUM_BEGIN:
if (entry->guide_entry->parameter == option_char)
return entry;
break;
default:
assert(FALSE);
return nullptr;
}
}
return nullptr;
}
int option_resolution_lookup_int(option_resolution *resolution, int option_char)
{
const struct option_resolution_entry *entry;
entry = option_resolution_lookup_entry(resolution, option_char);
return entry ? entry->u.int_value : -1;
}
const char *option_resolution_lookup_string(option_resolution *resolution, int option_char)
{
const struct option_resolution_entry *entry;
entry = option_resolution_lookup_entry(resolution, option_char);
return entry ? entry->u.str_value : nullptr;
}
const char *option_resolution_specification(option_resolution *resolution)
{
return resolution->specification;
}
const option_guide *option_resolution_find_option(option_resolution *resolution, int option_char)
{
const struct option_resolution_entry *entry;
entry = option_resolution_lookup_entry(resolution, option_char);
return entry ? entry->guide_entry : nullptr;
}
const option_guide *option_resolution_index_option(option_resolution *resolution, int indx)
{
if ((indx < 0) || (indx >= resolution->option_count))
return nullptr;
return resolution->entries[indx].guide_entry;
}
int option_resolution_countoptions(const option_guide *guide, const char *specification)
{
int option_count = 0;
while(guide->option_type != OPTIONTYPE_END)
{
switch(guide->option_type) {
case OPTIONTYPE_INT:
case OPTIONTYPE_STRING:
case OPTIONTYPE_ENUM_BEGIN:
if (lookup_in_specification(specification, guide))
option_count++;
break;
case OPTIONTYPE_ENUM_VALUE:
break;
default:
assert(FALSE);
return 0;
}
guide++;
}
return option_count;
}
optreserr_t option_resolution_listranges(const char *specification, int option_char,
struct OptionRange *range, size_t range_count)
{
assert(range_count > 0);
/* clear out range */
memset(range, -1, sizeof(*range) * range_count);
range_count--;
specification = strchr(specification, option_char);
if (!specification)
{
return OPTIONRESOLUTION_ERROR_SYNTAX;
}
return resolve_single_param(specification + 1, nullptr, range, range_count);
}
optreserr_t option_resolution_getdefault(const char *specification, int option_char, int *val)
{
assert(val);
/* clear out default */
*val = -1;
specification = strchr(specification, option_char);
if (!specification)
{
return OPTIONRESOLUTION_ERROR_SYNTAX;
}
return resolve_single_param(specification + 1, val, nullptr, 0);
}
optreserr_t option_resolution_isvalidvalue(const char *specification, int option_char, int val)
{
optreserr_t err;
struct OptionRange ranges[256];
int i;
err = option_resolution_listranges(specification, option_char, ranges, ARRAY_LENGTH(ranges));
if (err)
return err;
for (i = 0; (ranges[i].min >= 0) && (ranges[i].max >= 0); i++)
{
if ((ranges[i].min <= val) && (ranges[i].max >= val))
return OPTIONRESOLUTION_ERROR_SUCCESS;
}
return OPTIONRESOLUTION_ERROR_PARAMOUTOFRANGE;
}
/**
* @fn int option_resolution_contains(const char *specification, int option_char)
*
* @brief Option resolution contains.
*
* @param specification The specification.
* @param option_char The option character.
*
* @return An int.
*/
int option_resolution_contains(const char *specification, int option_char)
{
return strchr(specification, option_char) != nullptr;
}
/**
* @fn const char *option_resolution_error_string(optreserr_t err)
*
* @brief Option resolution error string.
*
* @param err The error.
*
* @return null if it fails, else a char*.
*/
const char *option_resolution_error_string(optreserr_t err)
{
static const char *const errors[] =
{
"The operation completed successfully", /* OPTIONRESOLUTION_ERROR_SUCCESS */
"Out of memory", /* OPTIONRESOLUTION_ERROR_OUTOFMEMORY */
"Parameter out of range", /* OPTIONRESOLUTION_ERROR_PARAMOUTOFRANGE */
"Parameter not specified", /* OPTIONRESOLUTION_ERROR_PARAMNOTSPECIFIED */
"Unknown parameter", /* OPTIONRESOLUTION_ERROR_PARAMNOTFOUND */
"Parameter specified multiple times", /* OPTIONRESOLUTION_ERROR_PARAMALREADYSPECIFIED */
"Invalid parameter", /* OPTIONRESOLUTION_ERROR_BADPARAM */
"Syntax error", /* OPTIONRESOLUTION_ERROR_SYNTAX */
"Internal error" /* OPTIONRESOLTUION_ERROR_INTERNAL */
};
if ((err < 0) || (err >= ARRAY_LENGTH(errors)))
return nullptr;
return errors[err];
}