19.05.2010

parent 1de3885c
......@@ -1720,6 +1720,18 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, char *option, char *valu
return 1;
#endif
if (cfgfile_strval (option, value, "chipset_compatible", &p->cs_compatible, cscompa, 0)
|| cfgfile_strval (option, value, "rtc", &p->cs_rtc, rtctype, 0)
|| cfgfile_strval (option, value, "ciaatod", &p->cs_ciaatod, ciaatodmode, 0)
|| cfgfile_strval (option, value, "ide", &p->cs_ide, idemode, 0)
|| cfgfile_strval (option, value, "scsi", &p->scsi, scsimode, 0)
|| cfgfile_strval (option, value, "comp_trustword", &p->comptrustword, compmode, 0)
|| cfgfile_strval (option, value, "comp_trustlong", &p->comptrustlong, compmode, 0)
|| cfgfile_strval (option, value, "comp_trustnaddr", &p->comptrustnaddr, compmode, 0)
|| cfgfile_strval (option, value, "collision_level", &p->collision_level, collmode, 0)
|| cfgfile_strval (option, value, "parallel_matrix_emulation", &p->parallel_matrix_emulation, epsonprinter, 0))
return 1;
if (cfgfile_string (option, value, "kickstart_rom_file", p->romfile, sizeof p->romfile / sizeof (char))
|| cfgfile_string (option, value, "kickstart_ext_rom_file", p->romextfile, sizeof p->romextfile / sizeof (char))
|| cfgfile_string (option, value, "amax_rom_file", p->amaxromfile, sizeof p->amaxromfile / sizeof (char))
......@@ -1858,8 +1870,25 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, char *option, char *valu
return 1;
}
if (strcasecmp (option, "quickstart") == 0) {
int model = 0;
TCHAR *tmpp = _tcschr (value, ',');
if (tmpp) {
*tmpp++ = 0;
TCHAR *tmpp2 = _tcschr (value, ',');
if (tmpp2)
*tmpp2 = 0;
cfgfile_strval (option, value, option, &model, qsmodes, 0);
if (model >= 0) {
int config = _tstol (tmpp);
built_in_prefs (p, model, config, 0, 0);
}
}
return 1;
}
for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) {
char tmp[100];
TCHAR tmp[100];
_stprintf (tmp, "uaehf%d", i);
if (_tcscmp (option, tmp) == 0)
return 1;
......@@ -1867,11 +1896,12 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, char *option, char *valu
if (_tcscmp (option, "filesystem") == 0
|| _tcscmp (option, "hardfile") == 0)
{
int secs, heads, reserved, bs, ro;
char *aname, *root;
char *tmpp = _tcschr (value, ',');
char *str;
{
int secs, heads, reserved, bs;
bool ro;
TCHAR *aname, *root;
TCHAR *tmpp = _tcschr (value, ',');
TCHAR *str;
if (config_newfilesystem)
return 1;
......@@ -1883,13 +1913,13 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, char *option, char *valu
if (strcmp (value, "1") == 0 || strcasecmp (value, "ro") == 0
|| strcasecmp (value, "readonly") == 0
|| strcasecmp (value, "read-only") == 0)
ro = 1;
ro = true;
else if (strcmp (value, "0") == 0 || strcasecmp (value, "rw") == 0
|| strcasecmp (value, "readwrite") == 0
|| strcasecmp (value, "read-write") == 0)
ro = 0;
ro = false;
else
goto invalid_fs;
goto invalid_fs;
secs = 0; heads = 0; reserved = 0; bs = 0;
value = tmpp;
......@@ -1935,21 +1965,22 @@ add_filesys_unit (struct uaedev_mount_info *mountinfo, const char *devname, cons
if (_tcscmp (option, "filesystem2") == 0
|| _tcscmp (option, "hardfile2") == 0)
{
int secs, heads, reserved, bs, ro, bp, hdcv;
char *dname = NULL, *aname = "", *root = NULL, *fs = NULL, *hdc;
char *tmpp = _tcschr (value, ',');
char *str = NULL;
{
int secs, heads, reserved, bs, bp, hdcv;
bool ro;
TCHAR *dname = NULL, *aname = "", *root = NULL, *fs = NULL, *hdc;
TCHAR *tmpp = _tcschr (value, ',');
TCHAR *str = NULL;
config_newfilesystem = 1;
if (tmpp == 0)
goto invalid_fs;
goto invalid_fs;
*tmpp++ = '\0';
if (strcasecmp (value, "ro") == 0)
ro = 1;
ro = true;
else if (strcasecmp (value, "rw") == 0)
ro = 0;
ro = false;
else
goto invalid_fs;
secs = 0; heads = 0; reserved = 0; bs = 0; bp = 0;
......@@ -1974,7 +2005,7 @@ add_filesys_unit (struct uaedev_mount_info *mountinfo, const char *devname, cons
*tmpp++ = 0;
if (! getintval (&tmpp, &bp, 0))
goto empty_fs;
} else {
} else {
tmpp = _tcschr (value, ':');
if (tmpp == 0)
goto invalid_fs;
......@@ -2101,7 +2132,7 @@ static int cfgfile_separate_linea (char *line, char *line1b, char *line2b)
static int cfgfile_separate_line (char *line, char *line1b, char *line2b)
{
char *line1, *line2;
TCHAR *line1, *line2;
int i;
line1 = line;
......@@ -2127,7 +2158,7 @@ static int cfgfile_separate_line (char *line, char *line1b, char *line2b)
_tcscpy (line1b, line);
if (line2b[0] == '"' || line2b[0] == '\"') {
char c = line2b[0];
TCHAR c = line2b[0];
int i = 0;
memmove (line2b, line2b + 1, (_tcslen (line2b) + 1) * sizeof (char));
while (line2b[i] != 0 && line2b[i] != c)
......@@ -2142,14 +2173,14 @@ static int cfgfile_separate_line (char *line, char *line1b, char *line2b)
static int isobsolete (char *s)
{
int i = 0;
while (obsolete[i]) {
if (!strcasecmp (s, obsolete[i])) {
int i = 0;
while (obsolete[i]) {
if (!strcasecmp (s, obsolete[i])) {
write_log ("obsolete config entry '%s'\n", s);
return 1;
return 1;
}
i++;
}
i++;
}
if (strlen (s) >= 10 && !memcmp (s, "gfx_opengl", 10)) {
write_log ("obsolete config entry '%s\n", s);
return 1;
......@@ -2163,13 +2194,13 @@ static int isobsolete (char *s)
static void cfgfile_parse_separated_line (struct uae_prefs *p, char *line1b, char *line2b, int type)
{
char line3b[CONFIG_BLEN], line4b[CONFIG_BLEN];
struct strlist *sl;
int ret;
TCHAR line3b[CONFIG_BLEN], line4b[CONFIG_BLEN];
struct strlist *sl;
int ret;
_tcscpy (line3b, line1b);
_tcscpy (line4b, line2b);
ret = cfgfile_parse_option (p, line1b, line2b, type);
ret = cfgfile_parse_option (p, line1b, line2b, type);
if (!isobsolete (line3b)) {
for (sl = p->all_lines; sl; sl = sl->next) {
if (sl->option && !strcasecmp (line1b, sl->option)) break;
......@@ -2183,103 +2214,104 @@ static void cfgfile_parse_separated_line (struct uae_prefs *p, char *line1b, cha
if (!ret) {
u->unknown = 1;
write_log ("unknown config entry: '%s=%s'\n", u->option, u->value);
}
}
}
}
}
}
void cfgfile_parse_line (struct uae_prefs *p, char *line, int type)
void cfgfile_parse_line (struct uae_prefs *p, TCHAR *line, int type)
{
char line1b[CONFIG_BLEN], line2b[CONFIG_BLEN];
TCHAR line1b[CONFIG_BLEN], line2b[CONFIG_BLEN];
if (!cfgfile_separate_line (line, line1b, line2b))
if (!cfgfile_separate_line (line, line1b, line2b))
return;
cfgfile_parse_separated_line (p, line1b, line2b, type);
return;
cfgfile_parse_separated_line (p, line1b, line2b, type);
return;
}
static void subst (const char *p, char *f, int n)
static void subst (TCHAR *p, TCHAR *f, int n)
{
char *str = cfgfile_subst_path (UNEXPANDED, p, f);
strncpy (f, str, n - 1);
f[n - 1] = '\0';
free (str);
TCHAR *str = cfgfile_subst_path (UNEXPANDED, p, f);
_tcsncpy (f, str, n - 1);
f[n - 1] = '\0';
free (str);
}
static char *cfg_fgets (char *line, int max, FILE *fh)
{
#ifdef SINGLEFILE
extern char singlefile_config[];
static char *sfile_ptr;
char *p;
extern TCHAR singlefile_config[];
static TCHAR *sfile_ptr;
TCHAR *p;
#endif
if (fh)
if (fh)
return fgets (line, max, fh);
#ifdef SINGLEFILE
if (sfile_ptr == 0) {
sfile_ptr = singlefile_config;
if (*sfile_ptr) {
if (sfile_ptr == 0) {
sfile_ptr = singlefile_config;
if (*sfile_ptr) {
write_log ("singlefile config found\n");
while (*sfile_ptr++);
while (*sfile_ptr++);
}
}
}
if (*sfile_ptr == 0) {
sfile_ptr = singlefile_config;
return 0;
}
p = sfile_ptr;
while (*p != 13 && *p != 10 && *p != 0) p++;
memset (line, 0, max);
memcpy (line, sfile_ptr, p - sfile_ptr);
sfile_ptr = p + 1;
if (*sfile_ptr == 13)
sfile_ptr++;
if (*sfile_ptr == 10)
sfile_ptr++;
return line;
if (*sfile_ptr == 0) {
sfile_ptr = singlefile_config;
return 0;
}
p = sfile_ptr;
while (*p != 13 && *p != 10 && *p != 0) p++;
memset (line, 0, max);
memcpy (line, sfile_ptr, (p - sfile_ptr) * sizeof (TCHAR));
sfile_ptr = p + 1;
if (*sfile_ptr == 13)
sfile_ptr++;
if (*sfile_ptr == 10)
sfile_ptr++;
return line;
#endif
return 0;
}
static int cfgfile_load_2 (struct uae_prefs *p, const char *filename, int real, int *type)
{
int i;
int i;
FILE *fh;
char linea[CONFIG_BLEN];
char line[CONFIG_BLEN], line1b[CONFIG_BLEN], line2b[CONFIG_BLEN];
struct strlist *sl;
int type1 = 0, type2 = 0, askedtype = 0;
TCHAR line[CONFIG_BLEN], line1b[CONFIG_BLEN], line2b[CONFIG_BLEN];
struct strlist *sl;
bool type1 = false, type2 = false;
int askedtype = 0;
if (type) {
if (type) {
askedtype = *type;
*type = 0;
}
if (real) {
}
if (real) {
p->config_version = 0;
config_newfilesystem = 0;
reset_inputdevice_config (p);
}
//reset_inputdevice_config (p);
}
write_log ("Opening cfgfile '%s': ", filename);
fh = fopen (filename, "r");
#ifndef SINGLEFILE
if (! fh) {
if (! fh) {
write_log ("failed\n");
return 0;
}
}
#endif
write_log ("okay.\n");
while (cfg_fgets (linea, sizeof (linea), fh) != 0) {
while (cfg_fgets (linea, sizeof (linea), fh) != 0) {
trimwsa (linea);
//write_log ("%s\n",linea);
if (strlen (linea) > 0) {
if (linea[0] == '#' || linea[0] == ';')
if (linea[0] == '#' || linea[0] == ';')
continue;
if (!cfgfile_separate_linea (linea, line1b, line2b))
if (!cfgfile_separate_linea (linea, line1b, line2b))
continue;
type1 = type2 = 0;
type1 = type2 = 0;
if (cfgfile_yesno (line1b, line2b, "config_hardware", &type1) ||
cfgfile_yesno (line1b, line2b, "config_host", &type2)) {
if (type1 && type)
......@@ -2288,28 +2320,28 @@ static int cfgfile_load_2 (struct uae_prefs *p, const char *filename, int real,
*type |= CONFIG_TYPE_HOST;
continue;
}
if (real) {
if (real) {
cfgfile_parse_separated_line (p, line1b, line2b, askedtype);
} else {
} else {
cfgfile_string (line1b, line2b, "config_description", p->description, sizeof p->description / sizeof (char));
cfgfile_string (line1b, line2b, "config_hardware_path", p->config_hardware_path, sizeof p->config_hardware_path / sizeof (char));
cfgfile_string (line1b, line2b, "config_host_path", p->config_host_path, sizeof p->config_host_path / sizeof (char));
}
}
}
}
}
if (type && *type == 0)
if (type && *type == 0)
*type = CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST;
if (fh)
fclose (fh);
if (!real)
if (!real)
return 1;
for (sl = temp_lines; sl; sl = sl->next) {
for (sl = temp_lines; sl; sl = sl->next) {
sprintf (line, "%s=%s", sl->option, sl->value);
cfgfile_parse_line (p, line, 0);
}
}
for (i = 0; i < 4; i++)
subst (prefs_get_attr("floppy_path"), p->df[i], sizeof p->df[i]);
......@@ -2330,25 +2362,25 @@ int cfgfile_save (const struct uae_prefs *p, const char *filename, int type)
{
FILE *fh = fopen (filename, "w");
write_log ("save config '%s'\n", filename);
if (! fh)
return 0;
if (! fh)
return 0;
if (!type)
type = CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST;
cfgfile_save_options (fh, p, type);
if (!type)
type = CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST;
cfgfile_save_options (fh, p, type);
fclose (fh);
return 1;
return 1;
}
int cfgfile_get_description (const char *filename, char *description, char *hostlink, char *hardwarelink, int *type)
{
int result = 0;
struct uae_prefs *p = xmalloc (struct uae_prefs, 1);
int result = 0;
struct uae_prefs *p = xmalloc (struct uae_prefs, 1);
p->description[0] = 0;
p->description[0] = 0;
p->config_host_path[0] = 0;
p->config_hardware_path[0] = 0;
if (cfgfile_load_2 (p, filename, 0, type)) {
if (cfgfile_load_2 (p, filename, 0, type)) {
result = 1;
if (description)
strcpy (description, p->description);
......@@ -2356,9 +2388,9 @@ int cfgfile_get_description (const char *filename, char *description, char *host
strcpy (hostlink, p->config_host_path);
if (hardwarelink)
strcpy (hardwarelink, p->config_hardware_path);
}
}
xfree (p);
return result;
return result;
}
int cfgfile_configuration_change (int v)
......@@ -2374,7 +2406,7 @@ void cfgfile_show_usage (void)
unsigned int i;
write_log ("UAE Configuration Help:\n" \
"=======================\n");
for (i = 0; i < sizeof opttable / sizeof *opttable; i++)
for (i = 0; i < sizeof opttable / sizeof *opttable; i++)
write_log ("%s: %s\n", opttable[i].config_label, opttable[i].config_help);
}
......@@ -2384,16 +2416,16 @@ void cfgfile_show_usage (void)
is far less annoying to use. */
static void parse_gfx_specs (struct uae_prefs *p, char *spec)
{
char *x0 = my_strdup (spec);
char *x1, *x2;
TCHAR *x0 = my_strdup (spec);
TCHAR *x1, *x2;
x1 = strchr (x0, ':');
if (x1 == 0)
x1 = _tcschr (x0, ':');
if (x1 == 0)
goto argh;
x2 = strchr (x1+1, ':');
if (x2 == 0)
x2 = _tcschr (x1+1, ':');
if (x2 == 0)
goto argh;
*x1++ = 0; *x2++ = 0;
*x1++ = 0; *x2++ = 0;
p->gfx_width_win = p->gfx_width_fs = atoi (x0);
p->gfx_height_win = p->gfx_height_fs = atoi (x1);
......@@ -2407,24 +2439,24 @@ static void parse_gfx_specs (struct uae_prefs *p, char *spec)
p->gfx_afullscreen = strchr (x2, 'a') != 0;
p->gfx_pfullscreen = strchr (x2, 'p') != 0;
if (p->gfx_linedbl == 3) {
if (p->gfx_linedbl == 3) {
write_log ("You can't use both 'd' and 'D' modifiers in the display mode specification.\n");
}
}
free (x0);
return;
free (x0);
return;
argh:
argh:
write_log ("Bad display mode specification.\n");
write_log ("The format to use is: \"width:height:modifiers\"\n");
write_log ("Type \"uae -h\" for detailed help.\n");
free (x0);
free (x0);
}
static void parse_sound_spec (struct uae_prefs *p, char *spec)
{
char *x0 = my_strdup (spec);
char *x1, *x2 = NULL, *x3 = NULL, *x4 = NULL, *x5 = NULL;
TCHAR *x0 = my_strdup (spec);
TCHAR *x1, *x2 = NULL, *x3 = NULL, *x4 = NULL, *x5 = NULL;
x1 = _tcschr (x0, ':');
if (x1 != NULL) {
......@@ -2465,33 +2497,33 @@ static void parse_sound_spec (struct uae_prefs *p, char *spec)
static void parse_joy_spec (struct uae_prefs *p, char *spec)
{
int v0 = 2, v1 = 0;
int v0 = 2, v1 = 0;
if (_tcslen(spec) != 2)
goto bad;
switch (spec[0]) {
case '0': v0 = JSEM_JOYS; break;
case '1': v0 = JSEM_JOYS + 1; break;
case 'M': case 'm': v0 = JSEM_MICE; break;
case 'A': case 'a': v0 = JSEM_KBDLAYOUT; break;
case 'B': case 'b': v0 = JSEM_KBDLAYOUT + 1; break;
case 'C': case 'c': v0 = JSEM_KBDLAYOUT + 2; break;
default: goto bad;
}
switch (spec[0]) {
case '0': v0 = JSEM_JOYS; break;
case '1': v0 = JSEM_JOYS + 1; break;
case 'M': case 'm': v0 = JSEM_MICE; break;
case 'A': case 'a': v0 = JSEM_KBDLAYOUT; break;
case 'B': case 'b': v0 = JSEM_KBDLAYOUT + 1; break;
case 'C': case 'c': v0 = JSEM_KBDLAYOUT + 2; break;
default: goto bad;
}
switch (spec[1]) {
case '0': v1 = JSEM_JOYS; break;
case '1': v1 = JSEM_JOYS + 1; break;
case 'M': case 'm': v1 = JSEM_MICE; break;
case 'A': case 'a': v1 = JSEM_KBDLAYOUT; break;
case 'B': case 'b': v1 = JSEM_KBDLAYOUT + 1; break;
case 'C': case 'c': v1 = JSEM_KBDLAYOUT + 2; break;
default: goto bad;
}
if (v0 == v1)
goto bad;
/* Let's scare Pascal programmers */
if (0)
switch (spec[1]) {
case '0': v1 = JSEM_JOYS; break;
case '1': v1 = JSEM_JOYS + 1; break;
case 'M': case 'm': v1 = JSEM_MICE; break;
case 'A': case 'a': v1 = JSEM_KBDLAYOUT; break;
case 'B': case 'b': v1 = JSEM_KBDLAYOUT + 1; break;
case 'C': case 'c': v1 = JSEM_KBDLAYOUT + 2; break;
default: goto bad;
}
if (v0 == v1)
goto bad;
/* Let's scare Pascal programmers */
if (0)
bad:
write_log ("Bad joystick mode specification. Use -J xy, where x and y\n"
"can be 0 for joystick 0, 1 for joystick 1, M for mouse, and\n"
......@@ -2503,8 +2535,8 @@ bad:
static void parse_filesys_spec (int readonly, const char *spec)
{
char buf[256];
char *s2;
TCHAR buf[256];
TCHAR *s2;
_tcsncpy (buf, spec, 255); buf[255] = 0;
s2 = _tcschr (buf, ':');
......@@ -2541,8 +2573,8 @@ add_filesys_unit (struct uaedev_mount_info *mountinfo, const char *devname, cons
static void parse_hardfile_spec (char *spec)
{
char *x0 = my_strdup (spec);
char *x1, *x2, *x3, *x4;
TCHAR *x0 = my_strdup (spec);
TCHAR *x1, *x2, *x3, *x4;
x1 = _tcschr (x0, ':');
if (x1 == NULL)
......@@ -2575,13 +2607,13 @@ add_filesys_unit (struct uaedev_mount_info *mountinfo, const char *devname, cons
write_log ("%s\n", err_msg);
}
#endif
free (x0);
return;
free (x0);
return;
argh:
free (x0);
argh:
free (x0);
write_log ("Bad hardfile parameter specified - type \"uae -h\" for help.\n");
return;
return;
}
static void parse_cpu_specs (struct uae_prefs *p, char *spec)
......@@ -2589,11 +2621,11 @@ static void parse_cpu_specs (struct uae_prefs *p, char *spec)
if (*spec < '0' || *spec > '4') {
write_log ("CPU parameter string must begin with '0', '1', '2', '3' or '4'.\n");
return;
}
}
p->cpu_model = (*spec++) * 10 + 68000;
p->address_space_24 = p->cpu_model < 68020;
p->cpu_compatible = 0;
p->address_space_24 = p->cpu_model < 68020;
p->cpu_compatible = 0;
while (*spec != '\0') {
switch (*spec) {
case 'a':
......@@ -2622,23 +2654,23 @@ static void parse_cpu_specs (struct uae_prefs *p, char *spec)
/* Returns the number of args used up (0 or 1). */
int parse_cmdline_option (struct uae_prefs *p, char c, char *arg)
{
struct strlist *u = xcalloc (struct strlist, 1);
const char arg_required[] = "0123rKpImWSAJwNCZUFcblOdHRv";
struct strlist *u = xcalloc (struct strlist, 1);
const TCHAR arg_required[] = "0123rKpImWSAJwNCZUFcblOdHRv";
if (strchr (arg_required, c) && ! arg) {
if (_tcschr (arg_required, c) && ! arg) {
write_log ("Missing argument for option `-%c'!\n", c);
return 0;
}
}
u->option = xmalloc (char, 2);
u->option[0] = c;
u->option[1] = 0;
u->value = arg ? my_strdup (arg) : NULL;
u->next = p->all_lines;
p->all_lines = u;
u->option = xmalloc (TCHAR, 2);
u->option[0] = c;
u->option[1] = 0;
u->value = my_strdup (arg);
u->next = p->all_lines;
p->all_lines = u;
switch (c) {
case 'h': usage (); exit (0);
switch (c) {
case 'h': usage (); exit (0);
case '0': strncpy (p->df[0], arg, 255); p->df[0][255] = 0; break;
case '1': strncpy (p->df[1], arg, 255); p->df[1][255] = 0; break;
......@@ -2650,11 +2682,11 @@ int parse_cmdline_option (struct uae_prefs *p, char c, char *arg)
/* case 'I': strncpy (p->sername, arg, 255); p->sername[255] = 0; currprefs.use_serial = 1; break; */
case 'm': case 'M': parse_filesys_spec (c == 'M', arg); break;
case 'W': parse_hardfile_spec (arg); break;
case 'S': parse_sound_spec (p, arg); break;
case 'S': parse_sound_spec (p, arg); break;
case 'R': p->gfx_framerate = atoi (arg); break;
case 'x': p->no_xhair = 1; break;
case 'i': p->illegal_mem = 1; break;
case 'J': parse_joy_spec (p, arg); break;
case 'i': p->illegal_mem = 1; break;
case 'J': parse_joy_spec (p, arg); break;
#if defined USE_X11_GFX
case 'L': p->x11_use_low_bandwidth = 1; break;
......@@ -2668,81 +2700,81 @@ int parse_cmdline_option (struct uae_prefs *p, char c, char *arg)
case 'w': p->m68k_speed = atoi (arg); break;
/* case 'g': p->use_gfxlib = 1; break; */
case 'G': p->start_gui = 0; break;
case 'G': p->start_gui = 0; break;
#ifdef DEBUGGER
case 'D': p->start_debugger = 1; break;
case 'D': p->start_debugger = 1; break;
#endif
case 'n':
if (strchr (arg, 'i') != 0)
p->immediate_blits = 1;
case 'n':
if (_tcschr (arg, 'i') != 0)
p->immediate_blits = 1;
break;
case 'v':
set_chipset_mask (p, atoi (arg));
case 'v':
set_chipset_mask (p, _tstoi (arg));
break;
case 'C':
case 'C':
parse_cpu_specs (p, arg);
break;
case 'Z':
p->z3fastmem_size = atoi (arg) * 0x100000;
case 'Z':
p->z3fastmem_size = _tstoi (arg) * 0x100000;
break;
case 'U':
p->gfxmem_size = atoi (arg) * 0x100000;
case 'U':
p->gfxmem_size = _tstoi (arg) * 0x100000;
break;
case 'F':
p->fastmem_size = atoi (arg) * 0x100000;
case 'F':
p->fastmem_size = _tstoi (arg) * 0x100000;
break;
case 'b':
p->bogomem_size = atoi (arg) * 0x40000;
case 'b':
p->bogomem_size = _tstoi (arg) * 0x40000;
break;
case 'c':
p->chipmem_size = atoi (arg) * 0x80000;
break;
case 'l':
if (0 == strcasecmp(arg, "de"))
p->keyboard_lang = KBD_LANG_DE;
else if (0 == strcasecmp(arg, "dk"))
p->keyboard_lang = KBD_LANG_DK;
else if (0 == strcasecmp(arg, "us"))
p->keyboard_lang = KBD_LANG_US;
else if (0 == strcasecmp(arg, "se"))
p->keyboard_lang = KBD_LANG_SE;
else if (0 == strcasecmp(arg, "fr"))
p->keyboard_lang = KBD_LANG_FR;
else if (0 == strcasecmp(arg, "it"))
p->keyboard_lang = KBD_LANG_IT;
else if (0 == strcasecmp(arg, "es"))
p->keyboard_lang = KBD_LANG_ES;
break;
case 'O': parse_gfx_specs (p, arg); break;
case 'd':
if (strchr (arg, 'S') != NULL || strchr (arg, 's')) {
case 'c':
p->chipmem_size = _tstoi (arg) * 0x80000;
break;
case 'l':
if (0 == strcasecmp(arg, "de"))
p->keyboard_lang = KBD_LANG_DE;
else if (0 == strcasecmp(arg, "dk"))
p->keyboard_lang = KBD_LANG_DK;
else if (0 == strcasecmp(arg, "us"))
p->keyboard_lang = KBD_LANG_US;
else if (0 == strcasecmp(arg, "se"))
p->keyboard_lang = KBD_LANG_SE;
else if (0 == strcasecmp(arg, "fr"))
p->keyboard_lang = KBD_LANG_FR;
else if (0 == strcasecmp(arg, "it"))
p->keyboard_lang = KBD_LANG_IT;
else if (0 == strcasecmp(arg, "es"))
p->keyboard_lang = KBD_LANG_ES;
break;
case 'O': parse_gfx_specs (p, arg); break;
case 'd':
if (_tcschr (arg, 'S') != NULL || _tcschr (arg, 's')) {
write_log (" Serial on demand.\n");
p->serial_demand = 1;
}
if (strchr (arg, 'P') != NULL || strchr (arg, 'p')) {
p->serial_demand = 1;
}
if (_tcschr (arg, 'P') != NULL || _tcschr (arg, 'p')) {
write_log (" Parallel on demand.\n");
p->parallel_demand = 1;
}
p->parallel_demand = 1;
}
break;
break;
case 'H':
case 'H':
#ifndef USE_AMIGA_GFX
p->color_mode = atoi (arg);
if (p->color_mode < 0) {
if (p->color_mode < 0) {
write_log ("Bad color mode selected. Using default.\n");
p->color_mode = 0;
}
p->color_mode = 0;
}
#else
p->amiga_screen_type = atoi (arg);
if (p->amiga_screen_type < 0 || p->amiga_screen_type > 2) {
......@@ -2750,199 +2782,202 @@ int parse_cmdline_option (struct uae_prefs *p, char c, char *arg)
p->amiga_screen_type = 2;
}
#endif
break;
default:
break;
default:
write_log ("Unknown option `-%c'!\n", c);
break;
}
return !! strchr (arg_required, c);
break;
}
return !! _tcschr (arg_required, c);
}
void cfgfile_addcfgparam (char *line)
{
struct strlist *u;
char line1b[CONFIG_BLEN], line2b[CONFIG_BLEN];
if (!line) {
struct strlist **ps = &temp_lines;
while (*ps) {
struct strlist *s = *ps;
*ps = s->next;
struct strlist *u;
TCHAR line1b[CONFIG_BLEN], line2b[CONFIG_BLEN];
if (!line) {
struct strlist **ps = &temp_lines;
while (*ps) {
struct strlist *s = *ps;
*ps = s->next;
xfree (s->value);
xfree (s->option);
xfree (s);
}
temp_lines = 0;
return;
}
temp_lines = 0;
return;
}
if (!cfgfile_separate_line (line, line1b, line2b))
return;
if (!cfgfile_separate_line (line, line1b, line2b))
return;
u = xcalloc (struct strlist, 1);
u->option = my_strdup(line1b);
u->value = my_strdup(line2b);
u->next = temp_lines;
temp_lines = u;
u->option = my_strdup (line1b);
u->value = my_strdup (line2b);
u->next = temp_lines;
temp_lines = u;
}
unsigned int cmdlineparser (const char *s, char *outp[], unsigned int max)
{
int j;
unsigned int cnt = 0;
int slash = 0;
int quote = 0;
char tmp1[MAX_DPATH];
int slash = 0;
int quote = 0;
TCHAR tmp1[MAX_DPATH];
const char *prev;
int doout;
doout = 0;
prev = s;
j = 0;
while (cnt < max) {
char c = *s++;
if (!c)
break;
if (c < 32)
continue;
if (c == '\\')
slash = 1;
if (!slash && c == '"') {
if (quote) {
quote = 0;
doout = 1;
} else {
quote = 1;
j = -1;
}
}
if (!quote && c == ' ')
doout = 1;
if (!doout) {
if (j >= 0) {
tmp1[j] = c;
tmp1[j + 1] = 0;
}
j++;
int doout;
doout = 0;
prev = s;
j = 0;
outp[0] = 0;
while (cnt < max) {
TCHAR c = *s++;
if (!c)
break;
if (c < 32)
continue;
if (c == '\\')
slash = 1;
if (!slash && c == '"') {
if (quote) {
quote = 0;
doout = 1;
} else {
quote = 1;
j = -1;
}
}
if (!quote && c == ' ')
doout = 1;
if (!doout) {
if (j >= 0) {
tmp1[j] = c;
tmp1[j + 1] = 0;
}
j++;
}
if (doout) {
outp[cnt++] = my_strdup (tmp1);
outp[cnt] = 0;
tmp1[0] = 0;
doout = 0;
j = 0;
}
slash = 0;
}
if (doout) {
outp[cnt++] = my_strdup (tmp1);
tmp1[0] = 0;
doout = 0;
j = 0;
if (j > 0 && cnt < max) {
outp[cnt++] = my_strdup (tmp1);
outp[cnt] = 0;
}
slash = 0;
}
if (j > 0 && cnt < max)
outp[cnt++] = my_strdup (tmp1);
return cnt;
return cnt;
}
#define UAELIB_MAX_PARSE 100
uae_u32 cfgfile_modify (uae_u32 index, char *parms, uae_u32 size, char *out, uae_u32 outsize)
{
char *p;
char *argc[UAELIB_MAX_PARSE];
TCHAR *p;
TCHAR *argc[UAELIB_MAX_PARSE];
unsigned int argv, i;
uae_u32 err;
uae_u8 zero = 0;
uae_u32 err;
TCHAR zero = 0;
static FILE *configstore = 0;
static char *configsearch;
static int configsearchfound;
static TCHAR *configsearch;
static int configsearchfound;
config_changed = 1;
err = 0;
argv = 0;
p = 0;
if (index != 0xffffffff) {
if (!configstore) {
err = 20;
goto end;
}
if (configsearch) {
char tmp[CONFIG_BLEN];
err = 0;
argv = 0;
p = 0;
if (index != 0xffffffff) {
if (!configstore) {
err = 20;
goto end;
}
if (configsearch) {
TCHAR tmp[CONFIG_BLEN];
unsigned int j = 0;
char *in = configsearch;
TCHAR *in = configsearch;
unsigned int inlen = strlen (configsearch);
int joker = 0;
int joker = 0;
if (in[inlen - 1] == '*') {
joker = 1;
inlen--;
}
if (in[inlen - 1] == '*') {
joker = 1;
inlen--;
}
for (;;) {
uae_u8 b = 0;
for (;;) {
uae_u8 b = 0;
if (fread (&b, 1, 1, configstore) != 1) {
err = 10;
if (configsearch)
err = 5;
if (configsearchfound)
err = 0;
goto end;
}
if (j >= sizeof (tmp) / sizeof (char) - 1)
j = sizeof (tmp) / sizeof (char) - 1;
if (b == 0) {
err = 10;
if (configsearch)
err = 5;
if (configsearchfound)
err = 0;
goto end;
}
if (b == '\n') {
if (configsearch && !strncmp (tmp, in, inlen) &&
((inlen > 0 && strlen (tmp) > inlen && tmp[inlen] == '=') || (joker))) {
char *p;
if (joker)
p = tmp - 1;
else
p = strchr (tmp, '=');
if (p) {
for (i = 0; i < outsize - 1; i++) {
uae_u8 b = *++p;
out[i] = b;
out[i + 1] = 0;
if (!b)
break;
}
err = 10;
if (configsearch)
err = 5;
if (configsearchfound)
err = 0;
goto end;
}
if (j >= sizeof (tmp) / sizeof (TCHAR) - 1)
j = sizeof (tmp) / sizeof (TCHAR) - 1;
if (b == 0) {
err = 10;
if (configsearch)
err = 5;
if (configsearchfound)
err = 0;
goto end;
}
if (b == '\n') {
if (configsearch && !_tcsncmp (tmp, in, inlen) &&
((inlen > 0 && _tcslen (tmp) > inlen && tmp[inlen] == '=') || (joker))) {
TCHAR *p;
if (joker)
p = tmp - 1;
else
p = _tcschr (tmp, '=');
if (p) {
for (i = 0; out && i < outsize - 1; i++) {
TCHAR b = *++p;
out[i] = b;
out[i + 1] = 0;
if (!b)
break;
}
}
err = 0xffffffff;
configsearchfound++;
goto end;
}
index--;
j = 0;
} else {
tmp[j++] = b;
tmp[j] = 0;
}
}
err = 0xffffffff;
configsearchfound++;
goto end;
}
index--;
j = 0;
} else {
tmp[j++] = b;
tmp[j] = 0;
}
}
}
err = 0xffffffff;
for (i = 0; i < outsize - 1; i++) {
uae_u8 b = 0;
if (fread (&b, 1, 1, configstore) != 1)
err = 0;
if (b == 0)
err = 0;
if (b == '\n')
b = 0;
out[i] = b;
out[i + 1] = 0;
if (!b)
break;
err = 0xffffffff;
for (i = 0; out && i < outsize - 1; i++) {
uae_u8 b = 0;
if (zfile_fread (&b, 1, 1, configstore) != 1)
err = 0;
if (b == 0)
err = 0;
if (b == '\n')
b = 0;
out[i] = b;
out[i + 1] = 0;
if (!b)
break;
}
goto end;
}
goto end;
}
if (size > 10000)
return 10;
argv = cmdlineparser (parms, argc, UAELIB_MAX_PARSE);
if (size > 10000)
return 10;
argv = cmdlineparser (parms, argc, UAELIB_MAX_PARSE);
if (argv <= 1 && index == 0xffffffff) {
if (argv <= 1 && index == 0xffffffff) {
if (configstore) {
fclose (configstore);
configstore = 0;
......@@ -2950,39 +2985,39 @@ uae_u32 cfgfile_modify (uae_u32 index, char *parms, uae_u32 size, char *out, uae
free (configsearch);
configstore = fopen ("configstore", "w+");
configsearch = NULL;
if (argv > 0 && strlen (argc[0]) > 0)
configsearch = my_strdup (argc[0]);
if (!configstore) {
err = 20;
goto end;
}
configsearch = NULL;
if (argv > 0 && _tcslen (argc[0]) > 0)
configsearch = my_strdup (argc[0]);
if (!configstore) {
err = 20;
goto end;
}
fseek (configstore, 0, SEEK_SET);
cfgfile_save_options (configstore, &currprefs, 0);
cfgfile_save_options (configstore, &currprefs, 0);
fwrite (&zero, 1, 1, configstore);
fseek (configstore, 0, SEEK_SET);
err = 0xffffffff;
configsearchfound = 0;
goto end;
}
err = 0xffffffff;
configsearchfound = 0;
goto end;
}
for (i = 0; i < argv; i++) {
if (i + 2 <= argv) {
if (!inputdevice_uaelib (argc[i], argc[i + 1])) {
if (!cfgfile_parse_option (&changed_prefs, argc[i], argc[i + 1], 0)) {
err = 5;
break;
}
}
for (i = 0; i < argv; i++) {
if (i + 2 <= argv) {
if (!inputdevice_uaelib (argc[i], argc[i + 1])) {
if (!cfgfile_parse_option (&changed_prefs, argc[i], argc[i + 1], 0)) {
err = 5;
break;
}
}
set_special (SPCFLAG_BRK);
i++;
i++;
}
}
}
end:
for (i = 0; i < argv; i++)
free (argc[i]);
free (p);
return err;
for (i = 0; i < argv; i++)
xfree (argc[i]);
xfree (p);
return err;
}
uae_u32 cfgfile_uaelib_modify (uae_u32 index, uae_u32 parms, uae_u32 size, uae_u32 out, uae_u32 outsize)
......@@ -2992,80 +3027,80 @@ uae_u32 cfgfile_uaelib_modify (uae_u32 index, uae_u32 parms, uae_u32 size, uae_u
int ret;
if (out)
put_byte (out, 0);
put_byte (out, 0);
if (size == 0) {
while (get_byte (parms + size) != 0)
size++;
}
parms_p = xmalloc (uae_char, size + 1);
if (!parms_p) {
parms_p = xmalloc (uae_char, size + 1);
if (!parms_p) {
ret = 10;
goto end;
}
}
if (out) {
out_p = xmalloc (char, outsize + 1);
if (!out_p) {
out_p = xmalloc (TCHAR, outsize + 1);
if (!out_p) {
ret = 10;
goto end;
}
out_p[0] = 0;
}
p = parms_p;
for (i = 0; i < size; i++) {
p[i] = get_byte (parms + i);
if (p[i] == 10 || p[i] == 13 || p[i] == 0)
break;
}
p[i] = 0;
}
p = parms_p;
for (i = 0; i < size; i++) {
p[i] = get_byte (parms + i);
if (p[i] == 10 || p[i] == 13 || p[i] == 0)
break;
}
p[i] = 0;
out_p[0] = 0;
ret = cfgfile_modify (index, parms_p, size, out_p, outsize);
if (out) {
p = out_p;
for (i = 0; i < outsize - 1; i++) {
for (i = 0; i < outsize - 1; i++) {
uae_u8 b = *p++;
put_byte (out + i, b);
put_byte (out + i + 1, 0);
if (!b)
break;
}
break;
}
}
end:
xfree (out_p);
xfree (parms_p);
return ret;
return ret;
}
uae_u32 cfgfile_uaelib (int mode, uae_u32 name, uae_u32 dst, uae_u32 maxlen)
{
char tmp[CONFIG_BLEN];
unsigned int i;
struct strlist *sl;
TCHAR tmp[CONFIG_BLEN];
int i;
struct strlist *sl;
if (mode)
return 0;
if (mode)
return 0;
for (i = 0; i < sizeof(tmp); i++) {
tmp[i] = get_byte (name + i);
if (tmp[i] == 0)
break;
}
tmp[sizeof(tmp) - 1] = 0;
if (tmp[0] == 0)
return 0;
for (sl = currprefs.all_lines; sl; sl = sl->next) {
if (!strcasecmp (sl->option, tmp))
break;
}
for (i = 0; i < sizeof (tmp) / sizeof (TCHAR); i++) {
tmp[i] = get_byte (name + i);
if (tmp[i] == 0)
break;
}
tmp[sizeof(tmp) / sizeof (TCHAR) - 1] = 0;
if (tmp[0] == 0)
return 0;
for (sl = currprefs.all_lines; sl; sl = sl->next) {
if (!strcasecmp (sl->option, tmp))
break;
}
if (sl) {
for (i = 0; i < maxlen; i++) {
if (sl) {
for (i = 0; i < maxlen; i++) {
put_byte (dst + i, sl->value[i]);
if (sl->value[i] == 0)
break;
break;
}
return dst;
}
return dst;
}
return 0;
return 0;
}
uae_u8 *restore_configuration (uae_u8 *src)
......@@ -3086,7 +3121,7 @@ uae_u8 *save_configuration (int *len)
dstbak = dst = xmalloc (uae_u8, tmpsize);
p = dst;
for (;;) {
char tmpout[256];
TCHAR tmpout[256];
int ret;
tmpout[0] = 0;
ret = cfgfile_modify (index, "*", 1, tmpout, sizeof (tmpout) / sizeof (char));
......@@ -3127,11 +3162,12 @@ void default_prefs (struct uae_prefs *p, int type)
{
int i;
int roms[] = { 6, 7, 8, 9, 10, 14, 5, 4, 3, 2, 1, -1 };
uae_u8 zero = 0;
TCHAR zero = 0;
struct zfile *f;
reset_inputdevice_config (p);
memset (p, 0, sizeof (*p));
strcpy (p->description, "UAE default configuration");
_tcscpy (p->description, "UAE default configuration");
p->config_hardware_path[0] = 0;
p->config_host_path[0] = 0;
......@@ -3182,10 +3218,10 @@ void default_prefs (struct uae_prefs *p, int type)
#ifdef JIT
# ifdef NATMEM_OFFSET
p->comptrustbyte = 0;
p->comptrustword = 0;
p->comptrustlong = 0;
p->comptrustnaddr= 0;
p->comptrustbyte = 0;
p->comptrustword = 0;
p->comptrustlong = 0;
p->comptrustnaddr= 0;
# else
p->comptrustbyte = 1;
p->comptrustword = 1;
......@@ -3877,8 +3913,8 @@ static int bip_super (struct uae_prefs *p, int config, int compa, int romcheck)
p->produce_sound = 2;
#ifdef JIT
p->cachesize = 8192;
#endif p->dfxtype[0] = DRV_35_HD;
#endif
p->dfxtype[0] = DRV_35_HD;
p->dfxtype[1] = DRV_35_HD;
p->floppy_speed = 0;
p->cpu_idle = 150;
......
......@@ -68,7 +68,7 @@
#define SPRBORDER 0
STATIC_INLINE bool nocustom (void)
STATIC_INLINE bool nocustom (void)
{
if (picasso_on && currprefs.picasso96_nocustom)
return 1;
......@@ -141,9 +141,9 @@ extern uae_u8* compiled_code;
int vpos;
static int vpos_count, vpos_count_prev;
static int lof_store; // real bit in custom registers
static int lof_current; // what display device thinks
static int lol;
static int lof_store; // real bit in custom registers
static int lof_current; // what display device thinks
static int lol;
static int next_lineno, prev_lineno;
static enum nln_how nextline_how;
static int lof_changed = 0;
......@@ -264,7 +264,7 @@ enum diw_states
int plffirstline, plflastline;
int plffirstline_total, plflastline_total;
static int autoscale_bordercolors;
static int autoscale_bordercolors;
int plfstrt_start, plfstrt, plfstop;
static int sprite_minx, sprite_maxx;
static int first_bpl_vpos;
......@@ -844,10 +844,10 @@ STATIC_INLINE void compute_delay_offset (void)
static void record_color_change2 (int hpos, int regno, unsigned long value)
{
int pos = hpos * 2;
if (regno == 0x1000 + 0x10c)
pos++; // BPLCON4 change needs 1 lores pixel delay
curr_color_changes[next_color_change].linepos = pos;
int pos = hpos * 2;
if (regno == 0x1000 + 0x10c)
pos++; // BPLCON4 change needs 1 lores pixel delay
curr_color_changes[next_color_change].linepos = pos;
curr_color_changes[next_color_change].regno = regno;
curr_color_changes[next_color_change++].value = value;
curr_color_changes[next_color_change].regno = -1;
......@@ -1804,11 +1804,11 @@ static void start_bpl_dma (int hpos, int hstart)
if (doflickerfix () && interlace_seen && !scandoubled_line) {
int i;
for (i = 0; i < 8; i++) {
prevbpl[lof_current][vpos][i] = bplptx[i];
if (!lof_current && (bplcon0 & 4))
bplpt[i] = prevbpl[1 - lof_current][vpos][i];
prevbpl[lof_current][vpos][i] = bplptx[i];
if (!lof_current && (bplcon0 & 4))
bplpt[i] = prevbpl[1 - lof_current][vpos][i];
if (!(bplcon0 & 4) || interlace_seen < 0)
prevbpl[1 - lof_current][vpos][i] = prevbpl[lof_current][vpos][i] = 0;
prevbpl[1 - lof_current][vpos][i] = prevbpl[lof_current][vpos][i] = 0;
}
}
......@@ -1942,20 +1942,20 @@ static void record_color_change (int hpos, int regno, unsigned long value)
}
record_color_change2 (hpos, regno, value);
if (regno == 0 && value != 0 && vpos >= 20) {
if (regno == 0 && value != 0 && vpos >= 20) {
// autoscale if COLOR00 changes in top or bottom of screen
if (vpos >= minfirstline) {
int vpos2 = autoscale_bordercolors ? minfirstline : vpos;
if (first_planes_vpos == 0)
first_planes_vpos = vpos2 - 2;
if (plffirstline_total == maxvpos)
plffirstline_total = vpos2 - 2;
if (vpos2 > last_planes_vpos || vpos2 > plflastline_total)
plflastline_total = last_planes_vpos = vpos2 + 3;
autoscale_bordercolors = 0;
} else {
autoscale_bordercolors++;
}
if (vpos >= minfirstline) {
int vpos2 = autoscale_bordercolors ? minfirstline : vpos;
if (first_planes_vpos == 0)
first_planes_vpos = vpos2 - 2;
if (plffirstline_total == maxvpos)
plffirstline_total = vpos2 - 2;
if (vpos2 > last_planes_vpos || vpos2 > plflastline_total)
plflastline_total = last_planes_vpos = vpos2 + 3;
autoscale_bordercolors = 0;
} else {
autoscale_bordercolors++;
}
}
}
......@@ -2713,7 +2713,7 @@ void compute_vsynctime (void)
#endif
}
if (currprefs.produce_sound > 1)
update_sound (fake_vblank_hz, (bplcon0 & 4) ? -1 : lof_store, islinetoggle ());
update_sound (fake_vblank_hz, (bplcon0 & 4) ? -1 : lof_store, islinetoggle ());
}
......@@ -2737,7 +2737,7 @@ void init_hz (void)
int ovblank = vblank_hz;
int hzc = 0;
if (vsync_switchmode (-1, 0))
if (vsync_switchmode (-1, 0))
currprefs.gfx_avsync = changed_prefs.gfx_avsync = vsync_switchmode (-1, 0);
if (!isvsync () && ((currprefs.chipset_refreshrate == 50 && !currprefs.ntscmode) ||
......@@ -2929,8 +2929,8 @@ static uae_u32 REGPARAM2 timehack_helper (TrapContext *context)
timehack_alive = 10;
gettimeofday (&tv, NULL);
x_put_long (m68k_areg (regs, 0), tv.tv_sec - (((365 * 8 + 2) * 24) * 60 * 60));
x_put_long (m68k_areg (regs, 0) + 4, tv.tv_usec);
x_put_long (m68k_areg (regs, 0), tv.tv_sec - (((365 * 8 + 2) * 24) * 60 * 60));
x_put_long (m68k_areg (regs, 0) + 4, tv.tv_usec);
return 0;
#else
return 2;
......@@ -3011,7 +3011,7 @@ STATIC_INLINE uae_u16 VPOSR (void)
if (hp + HPOS_OFFSET >= maxhpos) {
vp++;
if (vp >= maxvpos + lof_store)
if (vp >= maxvpos + lof_store)
vp = 0;
}
vp = (vp >> 8) & 7;
......@@ -3031,12 +3031,12 @@ STATIC_INLINE uae_u16 VPOSR (void)
if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
vp &= 1;
vp = vp | (lof_store ? 0x8000 : 0) | csbit;
vp = vp | (lof_store ? 0x8000 : 0) | csbit;
if (currprefs.chipset_mask & CSMASK_ECS_AGNUS)
vp |= lol ? 0x80 : 0;
#if 0
if (M68K_GETPC < 0x00f00000 || M68K_GETPC >= 0x10000000)
write_log (L"VPOSR %04x at %08x\n", vp, M68K_GETPC);
if (M68K_GETPC < 0x00f00000 || M68K_GETPC >= 0x10000000)
write_log ("VPOSR %04x at %08x\n", vp, M68K_GETPC);
#endif
if (currprefs.cpu_model >= 68020)
hsyncdelay ();
......@@ -3049,9 +3049,9 @@ static void VPOSW (uae_u16 v)
if (M68K_GETPC < 0xf00000 || 1)
write_log ("VPOSW %04X PC=%08x\n", v, M68K_GETPC);
#endif
if (lof_store != ((v & 0x8000) ? 1 : 0)) {
if (lof_store != ((v & 0x8000) ? 1 : 0)) {
lof_changed = 1;
lof_store = (v & 0x8000) ? 1 : 0;
lof_store = (v & 0x8000) ? 1 : 0;
}
if (currprefs.chipset_mask & CSMASK_ECS_AGNUS)
lol = (v & 0x0080) ? 1 : 0;
......@@ -3084,7 +3084,7 @@ STATIC_INLINE uae_u16 VHPOSR (void)
if (hp >= maxhpos) {
hp -= maxhpos;
vp++;
if (vp >= maxvpos + lof_store)
if (vp >= maxvpos + lof_store)
vp = 0;
}
hp += 1;
......@@ -3096,8 +3096,8 @@ STATIC_INLINE uae_u16 VHPOSR (void)
if (currprefs.cpu_model >= 68020)
hsyncdelay ();
#if 0
if (M68K_GETPC < 0x00f00000 || M68K_GETPC >= 0x10000000)
write_log ("VPOS %04x %04x at %08x\n", VPOSR (), vp, M68K_GETPC);
if (M68K_GETPC < 0x00f00000 || M68K_GETPC >= 0x10000000)
write_log ("VPOS %04x %04x at %08x\n", VPOSR (), vp, M68K_GETPC);
#endif
return vp;
}
......@@ -4919,8 +4919,8 @@ static void init_hardware_frame (void)
ddflastword_total = 0;
plflastline_total = 0;
plffirstline_total = maxvpos;
plffirstline_total = maxvpos;
autoscale_bordercolors = 0;
plffirstline_total = maxvpos;
autoscale_bordercolors = 0;
for (i = 0; i < MAX_SPRITES; i++)
spr[i].ptxhpos = MAXHPOS;
}
......@@ -5086,8 +5086,8 @@ static void vsync_handler (void)
write_log ("vblank interrupt not cleared\n");
#endif
if (bplcon0 & 4)
lof_store = lof_store ? 0 : 1;
lof_current = lof_store;
lof_store = lof_store ? 0 : 1;
lof_current = lof_store;
#ifdef PICASSO96
picasso_handle_vsync ();
......@@ -5333,12 +5333,12 @@ void hsync_handler (void)
if (islinetoggle ())
lol ^= 1;
if (vpos == equ_vblank_endline + 1 && lof_current != lof_store) {
// argh, line=0 field decision was wrong, someone did
// something stupid and changed LOF
// lof_current = lof_store;
// don't really know what to do here exactly without corrupt display
}
if (vpos == equ_vblank_endline + 1 && lof_current != lof_store) {
// argh, line=0 field decision was wrong, someone did
// something stupid and changed LOF
// lof_current = lof_store;
// don't really know what to do here exactly without corrupt display
}
maxhpos = maxhpos_short + lol;
eventtab[ev_hsync].evtime = get_cycles () + HSYNCTIME;
......@@ -5381,7 +5381,7 @@ void hsync_handler (void)
vpos_count++;
if (vpos >= maxvpos_total)
vpos = 0;
if (vpos == maxvpos + lof_store || vpos == maxvpos + lof_store + 1 || vpos_count >= MAXVPOS) {
if (vpos == maxvpos + lof_store || vpos == maxvpos + lof_store + 1 || vpos_count >= MAXVPOS) {
// vpos_count >= MAXVPOS just to not crash if VPOSW writes prevent vsync completely
if ((bplcon0 & 8) && !lightpen_triggered) {
vpos_lpen = vpos - 1;
......@@ -5431,7 +5431,7 @@ void hsync_handler (void)
strobe = 0x38;
else if (vpos < minfirstline)
strobe = 0x3a;
else if (vpos + 1 == maxvpos + lof_store)
else if (vpos + 1 == maxvpos + lof_store)
strobe = 0x38;
else if ((currprefs.chipset_mask & CSMASK_ECS_AGNUS) && lol)
strobe = 0x3e;
......@@ -5464,7 +5464,7 @@ void hsync_handler (void)
}
} else {
#endif
is_lastline = vpos + 1 == maxvpos + lof_store && currprefs.m68k_speed == -1;
is_lastline = vpos + 1 == maxvpos + lof_store && currprefs.m68k_speed == -1;
#ifdef JIT
}
#endif
......@@ -5481,8 +5481,8 @@ void hsync_handler (void)
} else if (currprefs.gfx_linedbl && (doublescan <= 0 || interlace_seen > 0)) {
lineno *= 2;
nextline_how = currprefs.gfx_linedbl == 1 ? nln_doubled : nln_nblack;
if ((bplcon0 & 4) || (interlace_seen > 0 && !lof_current)) {
if (!lof_current) {
if ((bplcon0 & 4) || (interlace_seen > 0 && !lof_current)) {
if (!lof_current) {
lineno++;
nextline_how = nln_lower;
} else {
......@@ -5781,8 +5781,8 @@ void customreset (int hardreset)
}
CLXCON (clxcon);
CLXCON2 (clxcon2);
calcdiw ();
write_log (L"CPU=%d Chipset=%s %s\n",
calcdiw ();
write_log ("CPU=%d Chipset=%s %s\n",
currprefs.cpu_model,
(currprefs.chipset_mask & CSMASK_AGA) ? "AGA" :
(currprefs.chipset_mask & CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE) == (CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE) ? "Full ECS" :
......@@ -6392,7 +6392,7 @@ uae_u8 *restore_custom (uae_u8 *src)
dsklen = RW; /* 024 DSKLEN */
RW; /* 026 DSKDAT */
RW; /* 028 REFPTR */
i = RW; lof_store = lof_current = (i & 0x8000) ? 1 : 0; lol = (i & 0x0080) ? 1 : 0; /* 02A VPOSW */
i = RW; lof_store = lof_current = (i & 0x8000) ? 1 : 0; lol = (i & 0x0080) ? 1 : 0; /* 02A VPOSW */
RW; /* 02C VHPOSW */
COPCON (RW); /* 02E COPCON */
RW; /* 030 SERDAT* */
......@@ -6550,7 +6550,7 @@ uae_u8 *save_custom (int *len, uae_u8 *dstptr, int full)
SW (dsklen); /* 024 DSKLEN */
SW (0); /* 026 DSKDAT */
SW (0); /* 028 REFPTR */
SW ((lof_store ? 0x8001 : 0) | (lol ? 0x0080 : 0));/* 02A VPOSW */
SW ((lof_store ? 0x8001 : 0) | (lol ? 0x0080 : 0));/* 02A VPOSW */
SW (0); /* 02C VHPOSW */
SW (copcon); /* 02E COPCON */
SW (serper); /* 030 SERDAT * */
......
......@@ -3809,7 +3809,6 @@ int main (int argc, char **argv)
* I don't dare to touch the 68k version. */
headerfile = fopen ("cputbl.h", "wb");
stblfile = fopen ("cpustbl.c", "wb");
generate_includes (stblfile);
......
......@@ -123,13 +123,13 @@ static int mousegrab;
static int mousehack;
static int is_hwsurface;
static int have_rawkeys;
static int refresh_necessary;
static int last_state = -1;
int alt_pressed;
unsigned int mouse_capture;
/*
* Set window title with some useful status info.
*/
......@@ -673,7 +673,7 @@ STATIC_INLINE void render_gl_buffer (const struct gl_buffer_t *buffer, int first
if (currprefs.leds_on_screen) bottomledspace=14; //reserve some space for drawing leds
if (currprefs.gfx_lores_mode) {
if (currprefs.gfx_lores_mode) {
amiga_real_w = 362;
gfx_gl_x_offset = (float) currprefs.gfx_gl_x_offset;
} else {
......@@ -682,21 +682,21 @@ STATIC_INLINE void render_gl_buffer (const struct gl_buffer_t *buffer, int first
}
if (currprefs.gfx_linedbl) {
amiga_real_h = 568;
gfx_gl_y_offset = (float) currprefs.gfx_gl_y_offset * 2;
} else {
gfx_gl_y_offset = (float) currprefs.gfx_gl_y_offset * 2;
} else {
amiga_real_h = 284;
gfx_gl_y_offset = (float) currprefs.gfx_gl_y_offset;
gfx_gl_y_offset = (float) currprefs.gfx_gl_y_offset;
}
if ((current_width >= amiga_real_w ) && (current_height >= amiga_real_h ) && (!screen_is_picasso) ) {
gfx_gl_x_panscan = currprefs.gfx_gl_panscan * 1.33f;
gfx_gl_y_panscan = currprefs.gfx_gl_panscan;
right_crop = (current_width - amiga_real_w) + gfx_gl_x_panscan ;
left_crop = gfx_gl_x_panscan;
bottom_crop = (current_height - amiga_real_h) + gfx_gl_y_panscan;
top_crop = gfx_gl_y_panscan;
bottom_crop = bottom_crop - bottomledspace ;
bottom_crop_global = (int) (bottom_crop - gfx_gl_y_panscan);
right_crop_global = (int) (right_crop - gfx_gl_x_panscan);
......@@ -708,7 +708,7 @@ STATIC_INLINE void render_gl_buffer (const struct gl_buffer_t *buffer, int first
gfx_gl_x_offset = 0;
gfx_gl_y_offset = 0;
}
if (have_texture_rectangles) {
tx0 = left_crop - gfx_gl_x_offset;
tx1 = (float) buffer->width - right_crop - gfx_gl_x_offset;
......@@ -1330,6 +1330,23 @@ void handle_events (void)
int keycode;
int ievent;
// Hack -- Alt + Tab
/*
if (rEvent.key.keysym.sym == SDLK_LALT) alt_pressed = rEvent.key.type;
if (rEvent.key.keysym.sym == SDLK_RALT) alt_pressed = rEvent.key.type;
if ((rEvent.key.keysym.sym == SDLK_TAB) && (alt_pressed == SDL_KEYDOWN)) {
alt_pressed = SDL_KEYUP;
if (mouse_capture) {
SDL_WM_GrabInput(SDL_GRAB_ON);
SDL_ShowCursor(SDL_DISABLE);
} else {
SDL_WM_GrabInput(SDL_GRAB_OFF);
SDL_ShowCursor(SDL_ENABLE);
}
break;
}
*/
if (currprefs.map_raw_keys) {
keycode = rEvent.key.keysym.scancode;
// Hack - OS4 keyup events have bit 7 set.
......
......@@ -836,3 +836,4 @@ int input_get_default_joystick_analog (struct uae_input_device *uid, int i, int
return 0;
}
//
......@@ -38,7 +38,7 @@ extern uae_u8* compiled_code;
#else
/* Need to have these somewhere */
static void build_comp (void) {}
bool check_prefs_changed_comp (void) { return false; }
bool check_prefs_changed_comp (void) { return false; }
#endif
/* For faster JIT cycles handling */
signed long pissoff = 0;
......@@ -85,8 +85,8 @@ static uae_u32 tt0_030, tt1_030, tc_030;
static uae_u16 mmusr_030;
static struct cache020 caches020[CACHELINES020];
static struct cache030 icaches030[CACHELINES030];
static struct cache030 dcaches030[CACHELINES030];
static struct cache030 icaches030[CACHELINES030];
static struct cache030 dcaches030[CACHELINES030];
static struct cache040 caches040[CACHESETS040];
#if COUNT_INSTRS
......@@ -139,135 +139,135 @@ void dump_counts (void)
}
#endif
uae_u32 (*x_prefetch)(int);
uae_u32 (*x_next_iword)(void);
uae_u32 (*x_next_ilong)(void);
uae_u32 (*x_get_long)(uaecptr);
uae_u32 (*x_get_word)(uaecptr);
uae_u32 (*x_get_byte)(uaecptr);
void (*x_put_long)(uaecptr,uae_u32);
void (*x_put_word)(uaecptr,uae_u32);
void (*x_put_byte)(uaecptr,uae_u32);
// shared memory access functions
static void set_x_funcs (void)
{
if (currprefs.mmu_model) {
x_prefetch = get_iword_mmu;
x_next_iword = next_iword_mmu;
x_next_ilong = next_ilong_mmu;
x_put_long = put_long_mmu;
x_put_word = put_word_mmu;
x_put_byte = put_byte_mmu;
x_get_long = get_long_mmu;
x_get_word = get_word_mmu;
x_get_byte = get_byte_mmu;
} else if (!currprefs.cpu_cycle_exact) {
x_prefetch = get_iword;
x_next_iword = next_iword;
x_next_ilong = next_ilong;
x_put_long = put_long;
x_put_word = put_word;
x_put_byte = put_byte;
x_get_long = get_long;
x_get_word = get_word;
x_get_byte = get_byte;
} else if (currprefs.cpu_model < 68020) {
x_prefetch = NULL;
x_next_iword = NULL;
x_next_ilong = NULL;
x_put_long = put_long_ce;
x_put_word = put_word_ce;
x_put_byte = put_byte_ce;
x_get_long = get_long_ce;
x_get_word = get_word_ce;
x_get_byte = get_byte_ce;
uae_u32 (*x_prefetch)(int);
uae_u32 (*x_next_iword)(void);
uae_u32 (*x_next_ilong)(void);
uae_u32 (*x_get_long)(uaecptr);
uae_u32 (*x_get_word)(uaecptr);
uae_u32 (*x_get_byte)(uaecptr);
void (*x_put_long)(uaecptr,uae_u32);
void (*x_put_word)(uaecptr,uae_u32);
void (*x_put_byte)(uaecptr,uae_u32);
// shared memory access functions
static void set_x_funcs (void)
{
if (currprefs.mmu_model) {
x_prefetch = get_iword_mmu;
x_next_iword = next_iword_mmu;
x_next_ilong = next_ilong_mmu;
x_put_long = put_long_mmu;
x_put_word = put_word_mmu;
x_put_byte = put_byte_mmu;
x_get_long = get_long_mmu;
x_get_word = get_word_mmu;
x_get_byte = get_byte_mmu;
} else if (!currprefs.cpu_cycle_exact) {
x_prefetch = get_iword;
x_next_iword = next_iword;
x_next_ilong = next_ilong;
x_put_long = put_long;
x_put_word = put_word;
x_put_byte = put_byte;
x_get_long = get_long;
x_get_word = get_word;
x_get_byte = get_byte;
} else if (currprefs.cpu_model < 68020) {
x_prefetch = NULL;
x_next_iword = NULL;
x_next_ilong = NULL;
x_put_long = put_long_ce;
x_put_word = put_word_ce;
x_put_byte = put_byte_ce;
x_get_long = get_long_ce;
x_get_word = get_word_ce;
x_get_byte = get_byte_ce;
#ifdef CPUEMU_20
} else if (currprefs.cpu_model == 68020) {
x_prefetch = get_word_ce020_prefetch;
x_next_iword = next_iword_020ce;
x_next_ilong = next_ilong_020ce;
x_put_long = put_long_ce020;
x_put_word = put_word_ce020;
x_put_byte = put_byte_ce020;
x_get_long = get_long_ce020;
x_get_word = get_word_ce020;
x_get_byte = get_byte_ce020;
} else if (currprefs.cpu_model == 68020) {
x_prefetch = get_word_ce020_prefetch;
x_next_iword = next_iword_020ce;
x_next_ilong = next_ilong_020ce;
x_put_long = put_long_ce020;
x_put_word = put_word_ce020;
x_put_byte = put_byte_ce020;
x_get_long = get_long_ce020;
x_get_word = get_word_ce020;
x_get_byte = get_byte_ce020;
#endif
#ifdef CPUEMU_21
} else {
x_prefetch = get_word_ce030_prefetch;
x_next_iword = next_iword_030ce;
x_next_ilong = next_ilong_030ce;
x_put_long = put_long_ce030;
x_put_word = put_word_ce030;
x_put_byte = put_byte_ce030;
x_get_long = get_long_ce030;
x_get_word = get_word_ce030;
x_get_byte = get_byte_ce030;
} else {
x_prefetch = get_word_ce030_prefetch;
x_next_iword = next_iword_030ce;
x_next_ilong = next_ilong_030ce;
x_put_long = put_long_ce030;
x_put_word = put_word_ce030;
x_put_byte = put_byte_ce030;
x_get_long = get_long_ce030;
x_get_word = get_word_ce030;
x_get_byte = get_byte_ce030;
#endif
}
}
}
}
static void set_cpu_caches (void)
{
int i, j;
#ifdef JIT
if (currprefs.cachesize) {
if (currprefs.cpu_model < 68040) {
if (currprefs.cachesize) {
if (currprefs.cpu_model < 68040) {
set_cache_state (regs.cacr & 1);
if (regs.cacr & 0x08) {
flush_icache (0, 3);
}
} else {
set_cache_state ((regs.cacr & 0x8000) ? 1 : 0);
}
}
}
}
#endif
if (currprefs.cpu_model == 68020) {
if (regs.cacr & 0x08) { // clear instr cache
for (i = 0; i < CACHELINES020; i++)
caches020[i].valid = 0;
regs.prefetch020addr = 0xff000000;
}
if (regs.cacr & 0x04) { // clear entry in instr cache
caches020[(regs.caar >> 2) & (CACHELINES020 - 1)].valid = 0;
regs.cacr &= ~0x04;
}
if (currprefs.cpu_model == 68020) {
if (regs.cacr & 0x08) { // clear instr cache
for (i = 0; i < CACHELINES020; i++)
caches020[i].valid = 0;
regs.prefetch020addr = 0xff000000;
}
if (regs.cacr & 0x04) { // clear entry in instr cache
caches020[(regs.caar >> 2) & (CACHELINES020 - 1)].valid = 0;
regs.cacr &= ~0x04;
}
#ifdef CPUEMU_21
} else if (currprefs.cpu_model == 68030) {
//regs.cacr |= 0x100;
if (regs.cacr & 0x08) { // clear instr cache
for (i = 0; i < CACHELINES030; i++) {
icaches030[i].valid[0] = 0;
icaches030[i].valid[1] = 0;
icaches030[i].valid[2] = 0;
icaches030[i].valid[3] = 0;
}
regs.prefetch020addr = 0xff000000;
}
if (regs.cacr & 0x04) { // clear entry in instr cache
icaches030[(regs.caar >> 4) & (CACHELINES030 - 1)].valid[(regs.caar >> 2) & 3] = 0;
regs.cacr &= ~0x04;
}
if (regs.cacr & 0x800) { // clear data cache
for (i = 0; i < CACHELINES030; i++) {
dcaches030[i].valid[0] = 0;
dcaches030[i].valid[1] = 0;
dcaches030[i].valid[2] = 0;
dcaches030[i].valid[3] = 0;
}
regs.cacr &= ~0x800;
}
if (regs.cacr & 0x400) { // clear entry in data cache
dcaches030[(regs.caar >> 4) & (CACHELINES030 - 1)].valid[(regs.caar >> 2) & 3] = 0;
regs.cacr &= ~0x400;
} else if (currprefs.cpu_model == 68030) {
//regs.cacr |= 0x100;
if (regs.cacr & 0x08) { // clear instr cache
for (i = 0; i < CACHELINES030; i++) {
icaches030[i].valid[0] = 0;
icaches030[i].valid[1] = 0;
icaches030[i].valid[2] = 0;
icaches030[i].valid[3] = 0;
}
regs.prefetch020addr = 0xff000000;
}
#endif
} else if (currprefs.cpu_model == 68040) {
if (regs.cacr & 0x04) { // clear entry in instr cache
icaches030[(regs.caar >> 4) & (CACHELINES030 - 1)].valid[(regs.caar >> 2) & 3] = 0;
regs.cacr &= ~0x04;
}
if (regs.cacr & 0x800) { // clear data cache
for (i = 0; i < CACHELINES030; i++) {
dcaches030[i].valid[0] = 0;
dcaches030[i].valid[1] = 0;
dcaches030[i].valid[2] = 0;
dcaches030[i].valid[3] = 0;
}
regs.cacr &= ~0x800;
}
if (regs.cacr & 0x400) { // clear entry in data cache
dcaches030[(regs.caar >> 4) & (CACHELINES030 - 1)].valid[(regs.caar >> 2) & 3] = 0;
regs.cacr &= ~0x400;
}
#endif
} else if (currprefs.cpu_model == 68040) {
if (!(regs.cacr & 0x8000)) {
for (i = 0; i < CACHESETS040; i++) {
for (j = 0; j < CACHELINES040; j++) {
......@@ -286,7 +286,7 @@ STATIC_INLINE void count_instr (unsigned int opcode)
{
}
static unsigned long REGPARAM3 op_illg_1 (uae_u32 opcode) REGPARAM;
static unsigned long REGPARAM3 op_illg_1 (uae_u32 opcode) REGPARAM;
static unsigned long REGPARAM2 op_illg_1 (uae_u32 opcode)
{
......@@ -309,7 +309,7 @@ static void build_cpufunctbl (void)
lvl = 5;
tbl = op_smalltbl_0_ff;
if (currprefs.cpu_cycle_exact)
tbl = op_smalltbl_21_ff;
tbl = op_smalltbl_21_ff;
if (currprefs.mmu_model)
tbl = op_smalltbl_31_ff;
break;
......@@ -317,7 +317,7 @@ static void build_cpufunctbl (void)
lvl = 4;
tbl = op_smalltbl_1_ff;
if (currprefs.cpu_cycle_exact)
tbl = op_smalltbl_22_ff;
tbl = op_smalltbl_22_ff;
if (currprefs.mmu_model)
tbl = op_smalltbl_31_ff;
break;
......@@ -325,13 +325,13 @@ static void build_cpufunctbl (void)
lvl = 3;
tbl = op_smalltbl_2_ff;
if (currprefs.cpu_cycle_exact)
tbl = op_smalltbl_23_ff;
tbl = op_smalltbl_23_ff;
break;
case 68020:
lvl = 2;
tbl = op_smalltbl_3_ff;
if (currprefs.cpu_cycle_exact)
tbl = op_smalltbl_20_ff;
tbl = op_smalltbl_20_ff;
break;
case 68010:
lvl = 1;
......@@ -464,7 +464,7 @@ static void update_68k_cycles (void)
cpucycleunit = CYCLE_UNIT * currprefs.cpu_clock_multiplier;
}
} else if (currprefs.cpu_frequency) {
cpucycleunit = CYCLE_UNIT * baseclock / currprefs.cpu_frequency;
cpucycleunit = CYCLE_UNIT * baseclock / currprefs.cpu_frequency;
}
if (cpucycleunit < 1)
cpucycleunit = 1;
......@@ -485,7 +485,7 @@ static void prefs_changed_cpu (void)
void check_prefs_changed_cpu (void)
{
bool changed = 0;
bool changed = 0;
if (!config_changed)
return;
......@@ -558,9 +558,9 @@ void init_m68k (void)
#endif
write_log ("Building CPU table for configuration: %d", currprefs.cpu_model);
regs.address_space_mask = 0xffffffff;
if (currprefs.cpu_compatible) {
if (currprefs.cpu_compatible) {
if (currprefs.address_space_24 && currprefs.cpu_model >= 68030)
currprefs.address_space_24 = false;
currprefs.address_space_24 = false;
}
if (currprefs.fpu_model > 0)
write_log ("/%d", currprefs.fpu_model);
......@@ -583,7 +583,7 @@ void init_m68k (void)
write_log ("%d CPU functions\n", nr_cpuop_funcs);
build_cpufunctbl ();
set_x_funcs ();
set_x_funcs ();
#ifdef JIT
/* We need to check whether NATMEM settings have changed
......@@ -799,7 +799,7 @@ int get_cpu_model (void)
* extract bitfield data from memory and return it in the MSBs
* bdata caches the unmodified data for put_bitfield()
*/
uae_u32 REGPARAM2 get_bitfield (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int width)
uae_u32 REGPARAM2 get_bitfield (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int width)
{
uae_u32 tmp, res, mask;
......@@ -848,7 +848,7 @@ uae_u32 REGPARAM2 get_bitfield (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, i
* write bitfield data (in the LSBs) back to memory, upper bits
* must be cleared already.
*/
void REGPARAM2 put_bitfield (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s32 offset, int width)
void REGPARAM2 put_bitfield (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s32 offset, int width)
{
offset = (offset & 7) + width;
switch ((offset + 7) >> 3) {
......@@ -872,7 +872,7 @@ void REGPARAM2 put_bitfield (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s32
}
}
uae_u32 REGPARAM2 x_get_bitfield (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int width)
uae_u32 REGPARAM2 x_get_bitfield (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int width)
{
uae_u32 tmp, res, mask;
......@@ -880,33 +880,33 @@ uae_u32 REGPARAM2 x_get_bitfield (uae_u32 src, uae_u32 bdata[2], uae_s32 offset,
mask = 0xffffffffu << (32 - width);
switch ((offset + width + 7) >> 3) {
case 1:
tmp = x_get_byte (src);
tmp = x_get_byte (src);
res = tmp << (24 + offset);
bdata[0] = tmp & ~(mask >> (24 + offset));
break;
case 2:
tmp = x_get_word (src);
tmp = x_get_word (src);
res = tmp << (16 + offset);
bdata[0] = tmp & ~(mask >> (16 + offset));
break;
case 3:
tmp = x_get_word (src);
tmp = x_get_word (src);
res = tmp << (16 + offset);
bdata[0] = tmp & ~(mask >> (16 + offset));
tmp = x_get_byte (src + 2);
tmp = x_get_byte (src + 2);
res |= tmp << (8 + offset);
bdata[1] = tmp & ~(mask >> (8 + offset));
break;
case 4:
tmp = x_get_long (src);
tmp = x_get_long (src);
res = tmp << offset;
bdata[0] = tmp & ~(mask >> offset);
break;
case 5:
tmp = x_get_long (src);
tmp = x_get_long (src);
res = tmp << offset;
bdata[0] = tmp & ~(mask >> offset);
tmp = x_get_byte (src + 4);
tmp = x_get_byte (src + 4);
res |= tmp >> (8 - offset);
bdata[1] = tmp & ~(mask << (8 - offset));
break;
......@@ -918,26 +918,26 @@ uae_u32 REGPARAM2 x_get_bitfield (uae_u32 src, uae_u32 bdata[2], uae_s32 offset,
return res;
}
void REGPARAM2 x_put_bitfield (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s32 offset, int width)
void REGPARAM2 x_put_bitfield (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s32 offset, int width)
{
offset = (offset & 7) + width;
switch ((offset + 7) >> 3) {
case 1:
x_put_byte (dst, bdata[0] | (val << (8 - offset)));
x_put_byte (dst, bdata[0] | (val << (8 - offset)));
break;
case 2:
x_put_word (dst, bdata[0] | (val << (16 - offset)));
x_put_word (dst, bdata[0] | (val << (16 - offset)));
break;
case 3:
x_put_word (dst, bdata[0] | (val >> (offset - 16)));
x_put_byte (dst + 2, bdata[1] | (val << (24 - offset)));
x_put_word (dst, bdata[0] | (val >> (offset - 16)));
x_put_byte (dst + 2, bdata[1] | (val << (24 - offset)));
break;
case 4:
x_put_long (dst, bdata[0] | (val << (32 - offset)));
x_put_long (dst, bdata[0] | (val << (32 - offset)));
break;
case 5:
x_put_long (dst, bdata[0] | (val >> (offset - 32)));
x_put_byte (dst + 4, bdata[1] | (val << (40 - offset)));
x_put_long (dst, bdata[0] | (val >> (offset - 32)));
x_put_byte (dst + 4, bdata[1] | (val << (40 - offset)));
break;
}
}
......@@ -954,22 +954,22 @@ uae_u32 REGPARAM2 get_disp_ea_020 (uae_u32 base, uae_u32 dp)
if (dp & 0x80) base = 0;
if (dp & 0x40) regd = 0;
if ((dp & 0x30) == 0x20)
base += (uae_s32)(uae_s16) next_iword ();
if ((dp & 0x30) == 0x30)
base += next_ilong ();
if ((dp & 0x30) == 0x20)
base += (uae_s32)(uae_s16) next_iword ();
if ((dp & 0x30) == 0x30)
base += next_ilong ();
if ((dp & 0x3) == 0x2)
outer = (uae_s32)(uae_s16) next_iword ();
if ((dp & 0x3) == 0x3)
outer = next_ilong ();
if ((dp & 0x3) == 0x2)
outer = (uae_s32)(uae_s16) next_iword ();
if ((dp & 0x3) == 0x3)
outer = next_ilong ();
if ((dp & 0x4) == 0)
base += regd;
if (dp & 0x3)
base = get_long (base);
if (dp & 0x4)
base += regd;
if ((dp & 0x4) == 0)
base += regd;
if (dp & 0x3)
base = get_long (base);
if (dp & 0x4)
base += regd;
return base + outer;
} else {
......@@ -977,7 +977,7 @@ uae_u32 REGPARAM2 get_disp_ea_020 (uae_u32 base, uae_u32 dp)
}
}
uae_u32 REGPARAM2 x_get_disp_ea_020 (uae_u32 base, uae_u32 dp)
uae_u32 REGPARAM2 x_get_disp_ea_020 (uae_u32 base, uae_u32 dp)
{
int reg = (dp >> 12) & 15;
int cycles = 0;
......@@ -995,20 +995,20 @@ uae_u32 REGPARAM2 x_get_disp_ea_020 (uae_u32 base, uae_u32 dp)
regd = 0;
if ((dp & 0x30) == 0x20) {
base += (uae_s32)(uae_s16) x_next_iword ();
base += (uae_s32)(uae_s16) x_next_iword ();
cycles++;
}
if ((dp & 0x30) == 0x30) {
base += x_next_ilong ();
base += x_next_ilong ();
cycles++;
}
if ((dp & 0x3) == 0x2) {
outer = (uae_s32)(uae_s16) x_next_iword ();
outer = (uae_s32)(uae_s16) x_next_iword ();
cycles++;
}
if ((dp & 0x3) == 0x3) {
outer = x_next_ilong ();
outer = x_next_ilong ();
cycles++;
}
......@@ -1017,7 +1017,7 @@ uae_u32 REGPARAM2 x_get_disp_ea_020 (uae_u32 base, uae_u32 dp)
cycles++;
}
if (dp & 0x3) {
base = x_get_long (base);
base = x_get_long (base);
cycles++;
}
if (dp & 0x4) {
......@@ -1033,8 +1033,8 @@ uae_u32 REGPARAM2 x_get_disp_ea_020 (uae_u32 base, uae_u32 dp)
return v;
}
uae_u32 REGPARAM3 get_disp_ea_000 (uae_u32 base, uae_u32 dp)
uae_u32 REGPARAM3 get_disp_ea_000 (uae_u32 base, uae_u32 dp)
{
int reg = (dp >> 12) & 15;
uae_s32 regd = regs.regs[reg];
......@@ -1475,7 +1475,7 @@ static void Exception_normal (int nr, uaecptr oldpc)
int sv = regs.s;
if (nr >= 24 && nr < 24 + 8 && currprefs.cpu_model <= 68010)
nr = x_get_byte (0x00fffff1 | (nr << 1));
nr = x_get_byte (0x00fffff1 | (nr << 1));
exception_debug (nr);
MakeSR ();
......@@ -1503,33 +1503,33 @@ static void Exception_normal (int nr, uaecptr oldpc)
for (i = 0 ; i < 7 ; i++) {
m68k_areg (regs, 7) -= 4;
x_put_long (m68k_areg (regs, 7), 0);
x_put_long (m68k_areg (regs, 7), 0);
}
m68k_areg (regs, 7) -= 4;
x_put_long (m68k_areg (regs, 7), regs.wb3_data);
x_put_long (m68k_areg (regs, 7), regs.wb3_data);
m68k_areg (regs, 7) -= 4;
x_put_long (m68k_areg (regs, 7), regs.mmu_fault_addr);
x_put_long (m68k_areg (regs, 7), regs.mmu_fault_addr);
m68k_areg (regs, 7) -= 4;
x_put_long (m68k_areg (regs, 7), regs.mmu_fault_addr);
x_put_long (m68k_areg (regs, 7), regs.mmu_fault_addr);
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), 0);
x_put_word (m68k_areg (regs, 7), 0);
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), 0);
x_put_word (m68k_areg (regs, 7), 0);
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), regs.wb3_status);
x_put_word (m68k_areg (regs, 7), regs.wb3_status);
regs.wb3_status = 0;
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), regs.mmu_ssw);
x_put_word (m68k_areg (regs, 7), regs.mmu_ssw);
m68k_areg (regs, 7) -= 4;
x_put_long (m68k_areg (regs, 7), regs.mmu_fault_addr);
x_put_long (m68k_areg (regs, 7), regs.mmu_fault_addr);
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), 0x7000 + nr * 4);
x_put_word (m68k_areg (regs, 7), 0x7000 + nr * 4);
m68k_areg (regs, 7) -= 4;
x_put_long (m68k_areg (regs, 7), oldpc);
x_put_long (m68k_areg (regs, 7), oldpc);
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), regs.sr);
newpc = x_get_long (regs.vbr + 4 * nr);
x_put_word (m68k_areg (regs, 7), regs.sr);
newpc = x_get_long (regs.vbr + 4 * nr);
if (newpc & 1) {
if (nr == 2 || nr == 3)
uae_reset (1); /* there is nothing else we can do.. */
......@@ -1548,35 +1548,35 @@ static void Exception_normal (int nr, uaecptr oldpc)
#endif
for (i = 0 ; i < 18 ; i++) {
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), 0);
x_put_word (m68k_areg (regs, 7), 0);
}
m68k_areg (regs, 7) -= 4;
x_put_long (m68k_areg (regs, 7), last_fault_for_exception_3);
x_put_long (m68k_areg (regs, 7), last_fault_for_exception_3);
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), 0);
x_put_word (m68k_areg (regs, 7), 0);
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), 0);
x_put_word (m68k_areg (regs, 7), 0);
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), 0);
x_put_word (m68k_areg (regs, 7), 0);
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), 0x0140 | (sv ? 6 : 2)); /* SSW */
x_put_word (m68k_areg (regs, 7), 0x0140 | (sv ? 6 : 2)); /* SSW */
m68k_areg (regs, 7) -= 4;
x_put_long (m68k_areg (regs, 7), last_addr_for_exception_3);
x_put_long (m68k_areg (regs, 7), last_addr_for_exception_3);
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), 0x7000 + nr * 4);
x_put_word (m68k_areg (regs, 7), 0x7000 + nr * 4);
m68k_areg (regs, 7) -= 4;
x_put_long (m68k_areg (regs, 7), oldpc);
x_put_long (m68k_areg (regs, 7), oldpc);
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), regs.sr);
x_put_word (m68k_areg (regs, 7), regs.sr);
goto kludge_me_do;
#ifdef MMU
}
#endif
} else {
m68k_areg (regs, 7) -= 4;
x_put_long (m68k_areg (regs, 7), last_fault_for_exception_3);
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), 0x2000 + nr * 4);
x_put_long (m68k_areg (regs, 7), last_fault_for_exception_3);
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), 0x2000 + nr * 4);
}
} else {
// address error
......@@ -1585,62 +1585,62 @@ static void Exception_normal (int nr, uaecptr oldpc)
ssw |= 0x20;
for (i = 0 ; i < 36; i++) {
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), 0);
x_put_word (m68k_areg (regs, 7), 0);
}
m68k_areg (regs, 7) -= 4;
x_put_long (m68k_areg (regs, 7), last_fault_for_exception_3);
x_put_long (m68k_areg (regs, 7), last_fault_for_exception_3);
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), 0);
x_put_word (m68k_areg (regs, 7), 0);
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), 0);
x_put_word (m68k_areg (regs, 7), 0);
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), 0);
x_put_word (m68k_areg (regs, 7), 0);
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), ssw);
x_put_word (m68k_areg (regs, 7), ssw);
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), 0xb000 + nr * 4);
x_put_word (m68k_areg (regs, 7), 0xb000 + nr * 4);
}
write_log ("Exception %d (%x) at %x -> %x!\n", nr, oldpc, currpc, x_get_long (regs.vbr + 4*nr));
write_log ("Exception %d (%x) at %x -> %x!\n", nr, oldpc, currpc, x_get_long (regs.vbr + 4*nr));
} else if (nr ==5 || nr == 6 || nr == 7 || nr == 9) {
m68k_areg (regs, 7) -= 4;
x_put_long (m68k_areg (regs, 7), oldpc);
x_put_long (m68k_areg (regs, 7), oldpc);
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), 0x2000 + nr * 4);
x_put_word (m68k_areg (regs, 7), 0x2000 + nr * 4);
} else if (regs.m && nr >= 24 && nr < 32) { /* M + Interrupt */
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), nr * 4);
x_put_word (m68k_areg (regs, 7), nr * 4);
m68k_areg (regs, 7) -= 4;
x_put_long (m68k_areg (regs, 7), currpc);
x_put_long (m68k_areg (regs, 7), currpc);
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), regs.sr);
x_put_word (m68k_areg (regs, 7), regs.sr);
regs.sr |= (1 << 13);
regs.msp = m68k_areg (regs, 7);
m68k_areg (regs, 7) = regs.isp;
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), 0x1000 + nr * 4);
x_put_word (m68k_areg (regs, 7), 0x1000 + nr * 4);
} else {
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), nr * 4);
x_put_word (m68k_areg (regs, 7), nr * 4);
}
} else if (nr == 2 || nr == 3) {
uae_u16 mode = (sv ? 4 : 0) | (last_instructionaccess_for_exception_3 ? 2 : 1);
mode |= last_writeaccess_for_exception_3 ? 0 : 16;
m68k_areg (regs, 7) -= 14;
/* fixme: bit3=I/N */
x_put_word (m68k_areg (regs, 7) + 0, mode);
x_put_long (m68k_areg (regs, 7) + 2, last_fault_for_exception_3);
x_put_word (m68k_areg (regs, 7) + 6, last_op_for_exception_3);
x_put_word (m68k_areg (regs, 7) + 8, regs.sr);
x_put_long (m68k_areg (regs, 7) + 10, last_addr_for_exception_3);
write_log ("Exception %d (%x) at %x -> %x!\n", nr, oldpc, currpc, x_get_long (regs.vbr + 4*nr));
x_put_word (m68k_areg (regs, 7) + 0, mode);
x_put_long (m68k_areg (regs, 7) + 2, last_fault_for_exception_3);
x_put_word (m68k_areg (regs, 7) + 6, last_op_for_exception_3);
x_put_word (m68k_areg (regs, 7) + 8, regs.sr);
x_put_long (m68k_areg (regs, 7) + 10, last_addr_for_exception_3);
write_log ("Exception %d (%x) at %x -> %x!\n", nr, oldpc, currpc, x_get_long (regs.vbr + 4*nr));
goto kludge_me_do;
}
m68k_areg (regs, 7) -= 4;
x_put_long (m68k_areg (regs, 7), currpc);
x_put_long (m68k_areg (regs, 7), currpc);
m68k_areg (regs, 7) -= 2;
x_put_word (m68k_areg (regs, 7), regs.sr);
x_put_word (m68k_areg (regs, 7), regs.sr);
kludge_me_do:
newpc = x_get_long (regs.vbr + 4 * nr);
newpc = x_get_long (regs.vbr + 4 * nr);
if (newpc & 1) {
if (nr == 2 || nr == 3)
uae_reset (1); /* there is nothing else we can do.. */
......@@ -2294,55 +2294,55 @@ static void mmu_op30_pmove (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr ex
reg = "TC";
siz = 4;
if (rw)
x_put_long (extra, tc_030);
x_put_long (extra, tc_030);
else
tc_030 = x_get_long (extra);
tc_030 = x_get_long (extra);
break;
case 0x12: // SRP
reg = "SRP";
siz = 8;
if (rw) {
x_put_long (extra, srp_030 >> 32);
x_put_long (extra + 4, srp_030);
x_put_long (extra, srp_030 >> 32);
x_put_long (extra + 4, srp_030);
} else {
srp_030 = (uae_u64)x_get_long (extra) << 32;
srp_030 |= x_get_long (extra + 4);
srp_030 = (uae_u64)x_get_long (extra) << 32;
srp_030 |= x_get_long (extra + 4);
}
break;
case 0x13: // CRP
reg = "CRP";
siz = 8;
if (rw) {
x_put_long (extra, crp_030 >> 32);
x_put_long (extra + 4, crp_030);
x_put_long (extra, crp_030 >> 32);
x_put_long (extra + 4, crp_030);
} else {
crp_030 = (uae_u64)x_get_long (extra) << 32;
crp_030 |= x_get_long (extra + 4);
crp_030 = (uae_u64)x_get_long (extra) << 32;
crp_030 |= x_get_long (extra + 4);
}
break;
case 0x18: // MMUSR
reg = "MMUSR";
siz = 2;
if (rw)
x_put_word (extra, mmusr_030);
x_put_word (extra, mmusr_030);
else
mmusr_030 = x_get_word (extra);
mmusr_030 = x_get_word (extra);
break;
case 0x02: // TT0
reg = "TT0";
siz = 4;
if (rw)
x_put_long (extra, tt0_030);
x_put_long (extra, tt0_030);
else
tt0_030 = x_get_long (extra);
tt0_030 = x_get_long (extra);
break;
case 0x03: // TT1
reg = "TT1";
siz = 4;
if (rw)
x_put_long (extra, tt1_030);
x_put_long (extra, tt1_030);
else
tt1_030 = x_get_long (extra);
tt1_030 = x_get_long (extra);
break;
}
......@@ -2354,17 +2354,17 @@ static void mmu_op30_pmove (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr ex
{
uae_u32 val;
if (siz == 8) {
uae_u32 val2 = x_get_long (extra);
val = x_get_long (extra + 4);
uae_u32 val2 = x_get_long (extra);
val = x_get_long (extra + 4);
if (rw)
write_log ("PMOVE %s,%08X%08X", reg, val2, val);
else
write_log ("PMOVE %08X%08X,%s", val2, val, reg);
} else {
if (siz == 4)
val = x_get_long (extra);
val = x_get_long (extra);
else
val = x_get_word (extra);
val = x_get_word (extra);
if (rw)
write_log ("PMOVE %s,%08X", reg, val);
else
......@@ -2961,7 +2961,7 @@ retry:
TRY (prb) {
for (;;) {
pc = regs.fault_pc = m68k_getpc ();
opcode = x_prefetch (0);
opcode = x_prefetch (0);
count_instr (opcode);
do_cycles (cpu_cycles);
cpu_cycles = (*cpufunctbl[opcode])(opcode);
......@@ -3008,7 +3008,7 @@ retry:
}
/* "cycle exact" 68020/030 */
/* "cycle exact" 68020/030 */
#define MAX68020CYCLES 4
static void m68k_run_2ce (void)
{
......@@ -3017,7 +3017,7 @@ static void m68k_run_2ce (void)
ipl_fetch ();
for (;;) {
uae_u32 opcode = x_prefetch (0);
uae_u32 opcode = x_prefetch (0);
(*cpufunctbl[opcode])(opcode);
if (r->ce020memcycles > 0) {
tmpcycles = CYCLE_UNIT * MAX68020CYCLES;
......@@ -3223,7 +3223,7 @@ void m68k_go (int may_quit)
} else {
#endif
run_func = currprefs.cpu_cycle_exact && currprefs.cpu_model == 68000 ? m68k_run_1_ce :
currprefs.cpu_compatible && currprefs.cpu_model == 68000 ? m68k_run_1 :
currprefs.cpu_compatible && currprefs.cpu_model == 68000 ? m68k_run_1 :
#ifdef JIT
currprefs.cpu_model >= 68020 && currprefs.cachesize ? m68k_run_jit :
#endif
......@@ -4143,8 +4143,8 @@ STATIC_INLINE void fill_cache040 (uae_u32 addr)
#endif
#ifdef CPUEMU_20
// this one is really simple and easy
void fill_icache020 (uae_u32 addr)
// this one is really simple and easy
void fill_icache020 (uae_u32 addr)
{
int index;
uae_u32 tag;
......@@ -4172,219 +4172,219 @@ void fill_icache020 (uae_u32 addr)
regs.prefetch020data = data;
}
// 68030 caches aren't so simple as 68020 cache..
STATIC_INLINE struct cache030 *getcache030 (struct cache030 *cp, uaecptr addr, uae_u32 *tagp, int *lwsp)
// 68030 caches aren't so simple as 68020 cache..
STATIC_INLINE struct cache030 *getcache030 (struct cache030 *cp, uaecptr addr, uae_u32 *tagp, int *lwsp)
{
int index, lws;
uae_u32 tag;
struct cache030 *c;
addr &= ~3;
index = (addr >> 4) & (CACHELINES030 - 1);
tag = regs.s | (addr & ~((CACHELINES030 << 4) - 1));
lws = (addr >> 2) & 3;
c = &cp[index];
*tagp = tag;
*lwsp = lws;
return c;
}
STATIC_INLINE void update_cache030 (struct cache030 *c, uae_u32 val, uae_u32 tag, int lws)
{
if (c->tag != tag)
c->valid[0] = c->valid[1] = c->valid[2] = c->valid[3] = false;
c->tag = tag;
c->valid[lws] = true;
c->data[lws] = val;
}
void fill_icache030 (uae_u32 addr)
{
int index, lws;
uae_u32 tag;
struct cache030 *c;
addr &= ~3;
index = (addr >> 4) & (CACHELINES030 - 1);
tag = regs.s | (addr & ~((CACHELINES030 << 4) - 1));
lws = (addr >> 2) & 3;
c = &cp[index];
*tagp = tag;
*lwsp = lws;
return c;
}
STATIC_INLINE void update_cache030 (struct cache030 *c, uae_u32 val, uae_u32 tag, int lws)
{
if (c->tag != tag)
c->valid[0] = c->valid[1] = c->valid[2] = c->valid[3] = false;
c->tag = tag;
c->valid[lws] = true;
c->data[lws] = val;
}
void fill_icache030 (uae_u32 addr)
{
int lws;
uae_u32 tag;
uae_u32 data;
struct cache030 *c;
addr &= ~3;
c = getcache030 (icaches030, addr, &tag, &lws);
if (c->valid[lws] && c->tag == tag) {
// cache hit
regs.prefetch020addr = addr;
regs.prefetch020data = c->data[lws];
return;
}
// cache miss
data = mem_access_delay_longi_read_ce020 (addr);
if ((regs.cacr & 3) == 1) { // not frozen and enabled
update_cache030 (c, data, tag, lws);
int lws;
uae_u32 tag;
uae_u32 data;
struct cache030 *c;
addr &= ~3;
c = getcache030 (icaches030, addr, &tag, &lws);
if (c->valid[lws] && c->tag == tag) {
// cache hit
regs.prefetch020addr = addr;
regs.prefetch020data = c->data[lws];
return;
}
// cache miss
data = mem_access_delay_longi_read_ce020 (addr);
if ((regs.cacr & 3) == 1) { // not frozen and enabled
update_cache030 (c, data, tag, lws);
#if 0
if ((regs.cacr & 0x11) == 0x11 && lws == 0 && !c->valid[0] && !c->valid[1] && !c->valid[2] && !c->valid[3] && ce_banktype[addr >> 16] == CE_MEMBANK_FAST) {
// do burst fetch if cache enabled, not frozen, all slots invalid, no chip ram
c->data[1] = mem_access_delay_long_read_ce020 (addr + 4);
c->data[2] = mem_access_delay_long_read_ce020 (addr + 8);
c->data[3] = mem_access_delay_long_read_ce020 (addr + 12);
c->valid[1] = c->valid[2] = c->valid[3] = true;
}
if ((regs.cacr & 0x11) == 0x11 && lws == 0 && !c->valid[0] && !c->valid[1] && !c->valid[2] && !c->valid[3] && ce_banktype[addr >> 16] == CE_MEMBANK_FAST) {
// do burst fetch if cache enabled, not frozen, all slots invalid, no chip ram
c->data[1] = mem_access_delay_long_read_ce020 (addr + 4);
c->data[2] = mem_access_delay_long_read_ce020 (addr + 8);
c->data[3] = mem_access_delay_long_read_ce020 (addr + 12);
c->valid[1] = c->valid[2] = c->valid[3] = true;
}
#endif
}
regs.prefetch020addr = addr;
regs.prefetch020data = data;
}
STATIC_INLINE bool cancache030 (uaecptr addr)
{
return ce_cachable[addr >> 16];
}
// and finally the worst part, 68030 data cache..
void write_dcache030 (uaecptr addr, uae_u32 val, int size)
{
struct cache030 *c1, *c2;
int lws1, lws2;
uae_u32 tag1, tag2;
int aligned = addr & 3;
if (!(regs.cacr & 0x100) || currprefs.cpu_model == 68040) // data cache disabled? 68040 shares this too.
return;
if (!cancache030 (addr))
return;
c1 = getcache030 (dcaches030, addr, &tag1, &lws1);
#if 0
uaecptr a = 0x1db0c;
if (addr - (1 << size) + 1 <= a && addr + (1 << size) >= a) {
write_log (L"%08x %d %d %08x %08x %d\n", addr, aligned, size, val, tag1, lws1);
if (aligned == 2)
write_log (L"*\n");
}
#endif
// easy one
if (size == 2 && aligned == 0) {
update_cache030 (c1, val, tag1, lws1);
#if 0
if ((regs.cacr & 0x1100) == 0x1100 && lws1 == 0 && !c1->valid[0] && !c1->valid[1] && !c1->valid[2] && !c1->valid[3] && ce_banktype[addr >> 16] == CE_MEMBANK_FAST) {
// do burst fetch if cache enabled, not frozen, all slots invalid, no chip ram
c1->data[1] = mem_access_delay_long_read_ce020 (addr + 4);
c1->data[2] = mem_access_delay_long_read_ce020 (addr + 8);
c1->data[3] = mem_access_delay_long_read_ce020 (addr + 12);
c1->valid[1] = c1->valid[2] = c1->valid[3] = true;
}
#endif
return;
}
// argh!! merge partial write
c2 = getcache030 (dcaches030, addr + 4, &tag2, &lws2);
if (size == 2) {
if (c1->valid[lws1] && c1->tag == tag1) {
c1->data[lws1] &= ~(0xffffffff >> (aligned * 8));
c1->data[lws1] |= val >> (aligned * 8);
}
if (c2->valid[lws2] && c2->tag == tag2) {
c2->data[lws2] &= 0xffffffff >> ((4 - aligned) * 8);
c2->data[lws2] |= val << ((4 - aligned) * 8);
}
} else if (size == 1) {
val <<= 16;
if (c1->valid[lws1] && c1->tag == tag1) {
c1->data[lws1] &= ~(0xffff0000 >> (aligned * 8));
c1->data[lws1] |= val >> (aligned * 8);
}
if (c2->valid[lws2] && c2->tag == tag2 && aligned == 3) {
c2->data[lws2] &= 0x00ffffff;
c2->data[lws2] |= val << 8;
}
} else if (size == 0) {
val <<= 24;
if (c1->valid[lws1] && c1->tag == tag1) {
c1->data[lws1] &= ~(0xff000000 >> (aligned * 8));
c1->data[lws1] |= val >> (aligned * 8);
}
}
}
uae_u32 read_dcache030 (uaecptr addr, int size)
{
struct cache030 *c1, *c2;
int lws1, lws2;
uae_u32 tag1, tag2;
int aligned = addr & 3;
int len = (1 << size) * 8;
uae_u32 v1, v2;
if (!(regs.cacr & 0x100) || currprefs.cpu_model == 68040 || !cancache030 (addr)) { // data cache disabled? shared with 68040 "ce"
if (size == 2)
return mem_access_delay_long_read_ce020 (addr);
else if (size == 1)
return mem_access_delay_word_read_ce020 (addr);
else
return mem_access_delay_byte_read_ce020 (addr);
}
c1 = getcache030 (dcaches030, addr, &tag1, &lws1);
addr &= ~3;
if (!c1->valid[lws1] || c1->tag != tag1) {
v1 = mem_access_delay_long_read_ce020 (addr);
update_cache030 (c1, v1, tag1, lws1);
} else {
v1 = c1->data[lws1];
if (get_long (addr) != v1) {
write_log (L"data cache mismatch %d %d %08x %08x != %08x %08x %d PC=%08x\n",
size, aligned, addr, get_long (addr), v1, tag1, lws1, M68K_GETPC);
v1 = get_long (addr);
}
}
// only one long fetch needed?
if (size == 0) {
v1 >>= (3 - aligned) * 8;
return v1;
} else if (size == 1 && aligned <= 2) {
v1 >>= (2 - aligned) * 8;
return v1;
} else if (size == 2 && aligned == 0) {
return v1;
}
// need two longs
addr += 4;
c2 = getcache030 (dcaches030, addr, &tag2, &lws2);
if (!c2->valid[lws2] || c2->tag != tag2) {
v2 = mem_access_delay_long_read_ce020 (addr);
update_cache030 (c2, v2, tag2, lws2);
} else {
v2 = c2->data[lws2];
if (get_long (addr) != v2) {
write_log (L"data cache mismatch %d %d %08x %08x != %08x %08x %d PC=%08x\n",
size, aligned, addr, get_long (addr), v2, tag2, lws2, M68K_GETPC);
v2 = get_long (addr);
}
}
if (size == 1 && aligned == 3)
return (v1 << 8) | (v2 >> 24);
else if (size == 2 && aligned == 1)
return (v1 << 8) | (v2 >> 24);
else if (size == 2 && aligned == 2)
return (v1 << 16) | (v2 >> 16);
else if (size == 2 && aligned == 3)
return (v1 << 24) | (v2 >> 8);
write_log (L"dcache030 weirdness!?\n");
return 0;
}
void flush_dcache (uaecptr addr, int size)
{
if (!currprefs.cpu_cycle_exact)
return;
}
regs.prefetch020addr = addr;
regs.prefetch020data = data;
}
STATIC_INLINE bool cancache030 (uaecptr addr)
{
return ce_cachable[addr >> 16];
}
// and finally the worst part, 68030 data cache..
void write_dcache030 (uaecptr addr, uae_u32 val, int size)
{
struct cache030 *c1, *c2;
int lws1, lws2;
uae_u32 tag1, tag2;
int aligned = addr & 3;
if (!(regs.cacr & 0x100) || currprefs.cpu_model == 68040) // data cache disabled? 68040 shares this too.
return;
if (!cancache030 (addr))
return;
c1 = getcache030 (dcaches030, addr, &tag1, &lws1);
#if 0
uaecptr a = 0x1db0c;
if (addr - (1 << size) + 1 <= a && addr + (1 << size) >= a) {
write_log ("%08x %d %d %08x %08x %d\n", addr, aligned, size, val, tag1, lws1);
if (aligned == 2)
write_log ("*\n");
}
#endif
// easy one
if (size == 2 && aligned == 0) {
update_cache030 (c1, val, tag1, lws1);
#if 0
if ((regs.cacr & 0x1100) == 0x1100 && lws1 == 0 && !c1->valid[0] && !c1->valid[1] && !c1->valid[2] && !c1->valid[3] && ce_banktype[addr >> 16] == CE_MEMBANK_FAST) {
// do burst fetch if cache enabled, not frozen, all slots invalid, no chip ram
c1->data[1] = mem_access_delay_long_read_ce020 (addr + 4);
c1->data[2] = mem_access_delay_long_read_ce020 (addr + 8);
c1->data[3] = mem_access_delay_long_read_ce020 (addr + 12);
c1->valid[1] = c1->valid[2] = c1->valid[3] = true;
}
#endif
return;
}
// argh!! merge partial write
c2 = getcache030 (dcaches030, addr + 4, &tag2, &lws2);
if (size == 2) {
if (c1->valid[lws1] && c1->tag == tag1) {
c1->data[lws1] &= ~(0xffffffff >> (aligned * 8));
c1->data[lws1] |= val >> (aligned * 8);
}
if (c2->valid[lws2] && c2->tag == tag2) {
c2->data[lws2] &= 0xffffffff >> ((4 - aligned) * 8);
c2->data[lws2] |= val << ((4 - aligned) * 8);
}
} else if (size == 1) {
val <<= 16;
if (c1->valid[lws1] && c1->tag == tag1) {
c1->data[lws1] &= ~(0xffff0000 >> (aligned * 8));
c1->data[lws1] |= val >> (aligned * 8);
}
if (c2->valid[lws2] && c2->tag == tag2 && aligned == 3) {
c2->data[lws2] &= 0x00ffffff;
c2->data[lws2] |= val << 8;
}
} else if (size == 0) {
val <<= 24;
if (c1->valid[lws1] && c1->tag == tag1) {
c1->data[lws1] &= ~(0xff000000 >> (aligned * 8));
c1->data[lws1] |= val >> (aligned * 8);
}
}
}
uae_u32 read_dcache030 (uaecptr addr, int size)
{
struct cache030 *c1, *c2;
int lws1, lws2;
uae_u32 tag1, tag2;
int aligned = addr & 3;
int len = (1 << size) * 8;
uae_u32 v1, v2;
if (!(regs.cacr & 0x100) || currprefs.cpu_model == 68040 || !cancache030 (addr)) { // data cache disabled? shared with 68040 "ce"
if (size == 2)
return mem_access_delay_long_read_ce020 (addr);
else if (size == 1)
return mem_access_delay_word_read_ce020 (addr);
else
return mem_access_delay_byte_read_ce020 (addr);
}
c1 = getcache030 (dcaches030, addr, &tag1, &lws1);
addr &= ~3;
if (!c1->valid[lws1] || c1->tag != tag1) {
v1 = mem_access_delay_long_read_ce020 (addr);
update_cache030 (c1, v1, tag1, lws1);
} else {
v1 = c1->data[lws1];
if (get_long (addr) != v1) {
write_log ("data cache mismatch %d %d %08x %08x != %08x %08x %d PC=%08x\n",
size, aligned, addr, get_long (addr), v1, tag1, lws1, M68K_GETPC);
v1 = get_long (addr);
}
}
// only one long fetch needed?
if (size == 0) {
v1 >>= (3 - aligned) * 8;
return v1;
} else if (size == 1 && aligned <= 2) {
v1 >>= (2 - aligned) * 8;
return v1;
} else if (size == 2 && aligned == 0) {
return v1;
}
// need two longs
addr += 4;
c2 = getcache030 (dcaches030, addr, &tag2, &lws2);
if (!c2->valid[lws2] || c2->tag != tag2) {
v2 = mem_access_delay_long_read_ce020 (addr);
update_cache030 (c2, v2, tag2, lws2);
} else {
v2 = c2->data[lws2];
if (get_long (addr) != v2) {
write_log ("data cache mismatch %d %d %08x %08x != %08x %08x %d PC=%08x\n",
size, aligned, addr, get_long (addr), v2, tag2, lws2, M68K_GETPC);
v2 = get_long (addr);
}
}
if (size == 1 && aligned == 3)
return (v1 << 8) | (v2 >> 24);
else if (size == 2 && aligned == 1)
return (v1 << 8) | (v2 >> 24);
else if (size == 2 && aligned == 2)
return (v1 << 16) | (v2 >> 16);
else if (size == 2 && aligned == 3)
return (v1 << 24) | (v2 >> 8);
write_log ("dcache030 weirdness!?\n");
return 0;
}
void flush_dcache (uaecptr addr, int size)
{
if (!currprefs.cpu_cycle_exact)
return;
unsigned int i;
if (currprefs.cpu_model >= 68030) {
for (i = 0; i < CACHELINES030; i++) {
dcaches030[i].valid[0] = 0;
dcaches030[i].valid[1] = 0;
dcaches030[i].valid[2] = 0;
dcaches030[i].valid[3] = 0;
}
}
if (currprefs.cpu_model >= 68030) {
for (i = 0; i < CACHELINES030; i++) {
dcaches030[i].valid[0] = 0;
dcaches030[i].valid[1] = 0;
dcaches030[i].valid[2] = 0;
dcaches030[i].valid[3] = 0;
}
}
}
void do_cycles_ce020 (int clocks)
......
......@@ -28,8 +28,8 @@
<key>CFBundleName</key>
<string>PUAE</string>
<key>CFBundleGetInfoString</key>
<string>2.1.0</string>
<string>2.2.0</string>
<key>CFBundleVersion</key>
<string>2.1.0</string>
<string>2.2.0</string>
</dict>
</plist>
......@@ -358,7 +358,7 @@ static void restore_header (uae_u8 *src)
emuversion = restore_string ();
description = restore_string ();
write_log ("Saved with: '%s %s', description: '%s'\n",
emuname, emuversion, description);
emuname, emuversion, description);
xfree (description);
xfree (emuversion);
xfree (emuname);
......
......@@ -47,8 +47,8 @@ static int scsierr(SCSI *scgp)
{
register struct scg_cmd *cp = scgp->scmd;
if(cp->error != SCG_NO_ERROR ||
cp->ux_errno != 0 || *(u_char *)&cp->scb != 0)
if (cp->error != SCG_NO_ERROR ||
cp->ux_errno != 0 || *(u_char *)&cp->scb != 0)
return -1;
return 0;
}
......@@ -72,7 +72,7 @@ static int inquiry (SCSI *scgp, void *bp, int cnt)
scgp->cmdname = "inquiry";
if (scsicmd(scgp) < 0)
return (-1);
return (-1);
return (0);
}
......@@ -82,7 +82,7 @@ static void print_product(struct scsi_inquiry *ip)
write_log ("'%.16s' ", ip->ident);
write_log ("'%.4s' ", ip->revision);
if (ip->add_len < 31) {
write_log ("NON CCS ");
write_log ("NON CCS ");
}
}
......@@ -98,22 +98,22 @@ static SCSI *openscsi (int scsibus, int target, int lun)
{
SCSI *scgp = scsi_smalloc ();
if (!scgp) {
return NULL;
return NULL;
}
scgp->debug = getenvint ("UAE_SCSI_DEBUG", 0);
scgp->kdebug = getenvint ("UAE_SCSI_KDEBUG", 0);
scgp->silent = getenvint ("UAE_SCSI_SILENT", 1);
scgp->verbose = getenvint ("UAE_SCSI_VERBOSE", 0);
scgp->verbose = getenvint ("UAE_SCSI_VERBOSE", 0);
scgp->scsibus = scsibus;
scgp->target = target;
scgp->lun = lun;
if (!scsi_open(scgp, NULL, scsibus, target, lun)) {
scsi_sfree (scgp);
return NULL;
scsi_sfree (scgp);
return NULL;
} else {
return scgp;
return scgp;
}
}
......@@ -159,9 +159,9 @@ static struct scsidevdata *get_scsidev_data (int unit)
int i;
for (i = 0; i < num_drives; i++) {
if (unit == drives[i].aunit) {
return &drives[i];
}
if (unit == drives[i].aunit) {
return &drives[i];
}
}
return NULL;
}
......@@ -169,21 +169,21 @@ static struct scsidevdata *get_scsidev_data (int unit)
static struct scsidevdata *add_scsidev_data (int bus, int target, int lun, int aunit)
{
if (num_drives + 1 < MAX_DRIVES) {
memset(&drives[num_drives], 0, sizeof(drives[num_drives]));
drives[num_drives].bus = bus;
drives[num_drives].target = target;
drives[num_drives].lun = lun;
drives[num_drives].aunit = aunit;
memset(&drives[num_drives], 0, sizeof(drives[num_drives]));
drives[num_drives].bus = bus;
drives[num_drives].target = target;
drives[num_drives].lun = lun;
drives[num_drives].aunit = aunit;
#if !defined(UAE_SCSIDEV_THREADS)
drives[num_drives].scgp = scgp;
drives[num_drives].max_dma = scsi_bufsize (scgp, 512 * 1024);
drives[num_drives].scgp = scgp;
drives[num_drives].max_dma = scsi_bufsize (scgp, 512 * 1024);
#endif
/* check if this drive is an ATAPI drive */
scgp->scsibus = bus;
scgp->target = target;
scgp->lun = lun;
drives[num_drives].isatapi = scsi_isatapi (scgp);
return &drives[num_drives++];
/* check if this drive is an ATAPI drive */
scgp->scsibus = bus;
scgp->target = target;
scgp->lun = lun;
drives[num_drives].isatapi = scsi_isatapi (scgp);
return &drives[num_drives++];
}
return NULL;
......@@ -194,7 +194,7 @@ static int start_thread (struct scsidevdata *sdd)
{
#ifdef UAE_SCSIDEV_THREADS
if (sdd->thread_running)
return 1;
return 1;
init_comm_pipe (&sdd->requests, 10, 1);
uae_sem_init (&sdd->sync_sem, 0, 0);
uae_start_thread (scsidev_thread, sdd, &sdd->tid);
......@@ -219,14 +219,13 @@ static uae_u32 scsidev_open (void)
#endif
/* Check unit number */
if ((sdd = get_scsidev_data (unit)) &&
start_thread (sdd)) {
opencount++;
put_word (m68k_areg (regs, 6)+32, get_word (m68k_areg (regs, 6)+32) + 1);
put_long (tmp1 + 24, unit); /* io_Unit */
put_byte (tmp1 + 31, 0); /* io_Error */
put_byte (tmp1 + 8, 7); /* ln_type = NT_REPLYMSG */
return 0;
if ((sdd = get_scsidev_data (unit)) && start_thread (sdd)) {
opencount++;
put_word (m68k_areg (regs, 6)+32, get_word (m68k_areg (regs, 6)+32) + 1);
put_long (tmp1 + 24, unit); /* io_Unit */
put_byte (tmp1 + 31, 0); /* io_Error */
put_byte (tmp1 + 8, 7); /* ln_type = NT_REPLYMSG */
return 0;
}
put_long (tmp1 + 20, (uae_u32)-1);
......@@ -280,8 +279,8 @@ static LONG TestNegativeTime(LONG block)
-150 == 100:00:00 = 00:00:00 */
if (block > (97 * 60 * 75))
{
/* must be a negative block */
block -= 100 * 60 * 75;
/* must be a negative block */
block -= 100 * 60 * 75;
}
return block;
}
......@@ -320,17 +319,16 @@ static void scsidev_do_scsi (struct scsidevdata *sdd, uaecptr request)
addrbank *bank_cmd = &get_mem_bank (scsi_cmd);
/* do transfer directly to and from Amiga memory */
if (!bank_data || !bank_data->check (scsi_data, scsi_len) ||
!bank_cmd || !bank_cmd->check (scsi_cmd, scsi_cmd_len)) {
put_byte (request + 31, (uae_u8)-5); /* IOERR_BADADDRESS */
return;
if (!bank_data || !bank_data->check (scsi_data, scsi_len) || !bank_cmd || !bank_cmd->check (scsi_cmd, scsi_cmd_len)) {
put_byte (request + 31, (uae_u8)-5); /* IOERR_BADADDRESS */
return;
}
#ifdef SCSI_IS_NOT_THREAD_SAFE
uae_sem_wait (&scgp_sem);
#endif
scmd->timeout = 80 * 60; /* the Amiga does not tell us how long the timeout shall be, so make it _very_ long (specified in seconds) */
scmd->timeout = 80 * 60; /* the Amiga does not tell us how long the timeout shall be, so make it _very_ long (specified in seconds) */
scmd->addr = bank_data->xlateaddr (scsi_data);
scmd->size = scsi_len;
scmd->flags = ((scsi_flags & 1) ? SCG_RECV_DATA : 0) | SCG_DISRE_ENA;
......@@ -406,29 +404,29 @@ static void scsidev_do_scsi (struct scsidevdata *sdd, uaecptr request)
buffer[len++] = *tmp++; /* medium type */
buffer[len++] = 0; *tmp++; /* ignore host application code */
for (i = 0; i < 4; i++) {
buffer[len++] = 0;
buffer[len++] = 0;
}
if (*tmp) {
/* skip block descriptor */
tmp += 8;
/* skip block descriptor */
tmp += 8;
}
tmp++;
page_len = scsi_len - (tmp - data);
if (page_len > 0) {
memcpy (&buffer[len], tmp, page_len);
len += page_len;
scmd->cdb.g1_cdb.cmd = MODE_SELECT_10;
scmd->cdb.g1_cdb.lun = sdd->lun;
scmd->cdb.g1_cdb.res = 1 << 3; /* PF bit */
scmd->cdb.g1_cdb.reladr = sp;
scmd->cdb.g1_cdb.count[0] = len >> 8;
scmd->cdb.g1_cdb.count[1] = len;
memcpy (&buffer[len], tmp, page_len);
len += page_len;
scmd->cdb.g1_cdb.cmd = MODE_SELECT_10;
scmd->cdb.g1_cdb.lun = sdd->lun;
scmd->cdb.g1_cdb.res = 1 << 3; /* PF bit */
scmd->cdb.g1_cdb.reladr = sp;
scmd->cdb.g1_cdb.count[0] = len >> 8;
scmd->cdb.g1_cdb.count[1] = len;
} else {
do_it = 0;
scmd->error = 0;
*(uae_u8 *)&scmd->scb = 0;
scmd->ux_errno = 0;
do_it = 0;
scmd->error = 0;
*(uae_u8 *)&scmd->scb = 0;
scmd->ux_errno = 0;
}
} else {
/* MODE_SENSE_6 */
......@@ -472,44 +470,44 @@ static void scsidev_do_scsi (struct scsidevdata *sdd, uaecptr request)
}
}
} else {
scsicmd (scgp);
scsicmd (scgp);
}
put_word (acmd + 18, scmd->error == SCG_FATAL ? 0 : scsi_cmd_len); /* fake scsi_CmdActual */
put_byte (acmd + 21, *(uae_u8 *)&scmd->scb); /* scsi_Status */
if (*(uae_u8 *)&scmd->scb) {
put_byte (request + 31, 45); /* HFERR_BadStatus */
put_byte (request + 31, 45); /* HFERR_BadStatus */
/* copy sense? */
for (sactual = 0;
scsi_sense && sactual < scsi_sense_len && sactual < scmd->sense_count;
sactual++) {
put_byte (scsi_sense + sactual, scmd->u_sense.cmd_sense[sactual]);
}
put_long (acmd + 8, 0); /* scsi_Actual */
/* copy sense? */
for (sactual = 0;
scsi_sense && sactual < scsi_sense_len && sactual < scmd->sense_count;
sactual++) {
put_byte (scsi_sense + sactual, scmd->u_sense.cmd_sense[sactual]);
}
put_long (acmd + 8, 0); /* scsi_Actual */
} else {
int i;
int i;
for (i = 0; i < scsi_sense_len; i++) {
put_byte (scsi_sense + i, 0);
}
sactual = 0;
if (scmd->error != SCG_NO_ERROR ||
scmd->ux_errno != 0) {
/* we might have been limited by the hosts DMA limits,
which is usually indicated by ENOMEM */
if (scsi_len > (unsigned int)sdd->max_dma &&
scmd->ux_errno == ENOMEM) {
put_byte (request + 31, (uae_u8)-4); /* IOERR_BADLENGTH */
} else {
put_byte (request + 31, 20); /* io_Error, but not specified */
put_long (acmd + 8, 0); /* scsi_Actual */
}
} else {
put_byte (request + 31, 0);
put_long (acmd + 8, scsi_len - scmd->resid); /* scsi_Actual */
}
for (i = 0; i < scsi_sense_len; i++) {
put_byte (scsi_sense + i, 0);
}
sactual = 0;
if (scmd->error != SCG_NO_ERROR ||
scmd->ux_errno != 0) {
/* we might have been limited by the hosts DMA limits,
which is usually indicated by ENOMEM */
if (scsi_len > (unsigned int)sdd->max_dma &&
scmd->ux_errno == ENOMEM) {
put_byte (request + 31, (uae_u8)-4); /* IOERR_BADLENGTH */
} else {
put_byte (request + 31, 20); /* io_Error, but not specified */
put_long (acmd + 8, 0); /* scsi_Actual */
}
} else {
put_byte (request + 31, 0);
put_long (acmd + 8, scsi_len - scmd->resid); /* scsi_Actual */
}
}
put_word (acmd + 28, sactual);
......@@ -524,14 +522,14 @@ static void scsidev_do_io (struct scsidevdata *sdd, uaecptr request)
tmp2 = get_word (request+28); /* io_Command */
switch (tmp2) {
case 28:
/* HD_SCSICMD */
scsidev_do_scsi (sdd, request);
break;
default:
/* Command not understood. */
put_byte (request+31, (uae_u8)-3); /* io_Error */
break;
case 28:
/* HD_SCSICMD */
scsidev_do_scsi (sdd, request);
break;
default:
/* Command not understood. */
put_byte (request+31, (uae_u8)-3); /* io_Error */
break;
}
#ifdef DEBUGME
printf ("scsidev: did io: sdd = 0x%x\n", sdd);
......@@ -584,21 +582,21 @@ static void *scsidev_thread (void *sddv)
/* init SCSI */
if (!(sdd->scgp = openscsi (sdd->bus, sdd->target, sdd->lun)) ||
(sdd->max_dma = scsi_bufsize (sdd->scgp, 512 * 1024)) <= 0) {
sdd->thread_running = 0;
uae_sem_post (&sdd->sync_sem);
return 0;
sdd->thread_running = 0;
uae_sem_post (&sdd->sync_sem);
return 0;
}
sdd->thread_running = 1;
uae_sem_post (&sdd->sync_sem);
for (;;) {
uaecptr request;
uaecptr request;
request = (uaecptr)read_comm_pipe_u32_blocking (&sdd->requests);
request = (uaecptr)read_comm_pipe_u32_blocking (&sdd->requests);
#ifdef DEBUGME
printf ("scsidev_penguin: sdd = 0x%x\n", sdd);
printf ("scsidev_penguin: req = %08lx\n", (unsigned long)request);
printf ("scsidev_penguin: cmd = %d\n", (int)get_word (request+28));
printf ("scsidev_penguin: sdd = 0x%x\n", sdd);
printf ("scsidev_penguin: req = %08lx\n", (unsigned long)request);
printf ("scsidev_penguin: cmd = %d\n", (int)get_word (request+28));
#endif
if (!request) {
printf ("scsidev_penguin: going down with 0x%x\n", sdd->sync_sem);
......@@ -629,41 +627,41 @@ static uae_u32 scsidev_init (void)
#endif
if (scgp) {
/* we still have everything in place */
return m68k_dreg (regs, 0); /* device base */
/* we still have everything in place */
return m68k_dreg (regs, 0); /* device base */
}
/* init global SCSI */
if (!(scgp = openscsi (-1, -1, -1))) {
return 0;
return 0;
}
uae_sem_init (&scgp_sem, 0, 1);
/* add all units we find */
for (scgp->scsibus=0; scgp->scsibus < 8; scgp->scsibus++) {
if (!scsi_havebus(scgp, scgp->scsibus))
continue;
printf("scsibus%d:\n", scgp->scsibus);
for (scgp->target=0; scgp->target < 16; scgp->target++) {
struct scsi_inquiry inq;
scgp->lun = 0;
if (inquiry (scgp, &inq, sizeof(inq))) {
continue;
}
for (scgp->lun=0; scgp->lun < 8; scgp->lun++) {
if (!inquiry (scgp, &inq, sizeof(inq))) {
int aunit = BTL2UNIT(scgp->scsibus, scgp->target, scgp->lun);
struct scsidevdata *sdd;
write_log (" %2.01d,%d (= %3.d): ", scgp->target, scgp->lun, aunit);
print_product (&inq);
sdd = add_scsidev_data (scgp->scsibus, scgp->target, scgp->lun, aunit);
write_log (!sdd ? " - init failed ???" : sdd->isatapi ? " - ATAPI" : " - SCSI");
write_log ("\n");
if (!scsi_havebus(scgp, scgp->scsibus))
continue;
printf("scsibus%d:\n", scgp->scsibus);
for (scgp->target=0; scgp->target < 16; scgp->target++) {
struct scsi_inquiry inq;
scgp->lun = 0;
if (inquiry (scgp, &inq, sizeof(inq))) {
continue;
}
for (scgp->lun=0; scgp->lun < 8; scgp->lun++) {
if (!inquiry (scgp, &inq, sizeof(inq))) {
int aunit = BTL2UNIT(scgp->scsibus, scgp->target, scgp->lun);
struct scsidevdata *sdd;
write_log (" %2.01d,%d (= %3.d): ", scgp->target, scgp->lun, aunit);
print_product (&inq);
sdd = add_scsidev_data (scgp->scsibus, scgp->target, scgp->lun, aunit);
write_log (!sdd ? " - init failed ???" : sdd->isatapi ? " - ATAPI" : " - SCSI");
write_log ("\n");
}
}
}
}
}
}
return m68k_dreg (regs, 0); /* device base */
}
......@@ -791,7 +789,7 @@ void scsidev_reset (void)
for (i = 0; i < num_drives; i++) {
if (!drives[i].thread_running) {
continue;
continue;
}
write_comm_pipe_int (&drives[i].requests, 0, 1);
uae_sem_wait (&drives[i].sync_sem);
......@@ -801,8 +799,8 @@ void scsidev_reset (void)
#endif
if (scgp) {
closescsi (scgp);
scgp = NULL;
closescsi (scgp);
scgp = NULL;
}
#endif
......
......@@ -207,33 +207,33 @@ static uae_u32 REGPARAM2 dev_open_2 (TrapContext *context, int type)
if (!dev)
return openfail (ioreq, 32); /* badunitnum */
if (!dev->opencnt) {
for (i = 0; i < MAX_OPEN_DEVICES; i++) {
pdev = &pdevst[i];
if (pdev->inuse == 0) break;
}
for (i = 0; i < MAX_OPEN_DEVICES; i++) {
pdev = &pdevst[i];
if (pdev->inuse == 0) break;
}
if (type == UAEDEV_SCSI_ID && sys_command_open (dev->allow_scsi ? DF_SCSI : DF_IOCTL, dev->unitnum)) {
setpdev (pdev, dev);
}
if (type == UAEDEV_DISK_ID && sys_command_open (DF_IOCTL, dev->unitnum)) {
pdev->ioctl = 1;
pdev->mode = DF_IOCTL;
}
if (!pdev->scsi && !pdev->ioctl)
return openfail (ioreq, IOERR_OPENFAIL);
pdev->type = type;
pdev->unit = unit;
pdev->flags = flags;
pdev->inuse = 1;
put_long (ioreq + 24, pdev - pdevst);
start_thread (dev);
}
if (type == UAEDEV_DISK_ID && sys_command_open (DF_IOCTL, dev->unitnum)) {
pdev->ioctl = 1;
pdev->mode = DF_IOCTL;
}
if (!pdev->scsi && !pdev->ioctl)
return openfail (ioreq, IOERR_OPENFAIL);
pdev->type = type;
pdev->unit = unit;
pdev->flags = flags;
pdev->inuse = 1;
put_long (ioreq + 24, pdev - pdevst);
start_thread (dev);
} else {
for (i = 0; i < MAX_OPEN_DEVICES; i++) {
pdev = &pdevst[i];
for (i = 0; i < MAX_OPEN_DEVICES; i++) {
pdev = &pdevst[i];
if (pdev->inuse && pdev->unit == unit) break;
}
if (i == MAX_OPEN_DEVICES)
}
if (i == MAX_OPEN_DEVICES)
return openfail (ioreq, IOERR_OPENFAIL);
put_long (ioreq + 24, pdev - pdevst);
put_long (ioreq + 24, pdev - pdevst);
}
dev->opencnt++;
......@@ -265,8 +265,8 @@ static int is_async_request (struct devstruct *dev, uaecptr request)
{
int i = 0;
while (i < MAX_ASYNC_REQUESTS) {
if (dev->d_request[i] == request) return 1;
i++;
if (dev->d_request[i] == request) return 1;
i++;
}
return 0;
}
......@@ -559,7 +559,7 @@ static int dev_do_io (struct devstruct *dev, uaecptr request)
if (!dev->di.media_inserted)
goto no_media;
if (dev->di.write_protected || dev->drivetype == INQ_ROMD) {
io_error = 28; /* writeprotect */
io_error = 28; /* writeprotect */
} else if ((io_offset & bmask) || bmask == 0 || io_data == 0) {
goto bad_command;
} else if ((io_length & bmask) || io_length == 0) {
......
......@@ -293,7 +293,7 @@
#define PACKAGE_NAME "PUAE"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "PUAE 2.1.0"
#define PACKAGE_STRING "PUAE 2.2.0"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "puae"
......@@ -302,7 +302,7 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "2.1.0"
#define PACKAGE_VERSION "2.2.0"
/* Define to the necessary symbol if this constant uses a non-standard name on
your system. */
......@@ -395,7 +395,7 @@
/* Version number of package */
#define VERSION "2.1.0"
#define VERSION "2.2.0"
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
......
......@@ -445,7 +445,7 @@ configure:4344: $? = 0
configure:4344: result: yes
configure:4350: checking for _doprnt
configure:4350: gcc -o conftest -g -O2 -Wall -W -Wno-unused conftest.c >&5
/tmp/ccSMtDaE.o: In function `main':
/tmp/ccduySMn.o: In function `main':
/home/gnostic/puaex/src/tools/conftest.c:67: undefined reference to `_doprnt'
collect2: ld returned 1 exit status
configure:4350: $? = 1
......@@ -533,7 +533,7 @@ configure:4364: $? = 0
configure:4364: result: yes
configure:4364: checking for strcmpi
configure:4364: gcc -o conftest -g -O2 -Wall -W -Wno-unused conftest.c >&5
/tmp/ccMreunT.o: In function `main':
/tmp/ccgpaTxE.o: In function `main':
/home/gnostic/puaex/src/tools/conftest.c:69: undefined reference to `strcmpi'
collect2: ld returned 1 exit status
configure:4364: $? = 1
......@@ -613,7 +613,7 @@ configure: failed program was:
configure:4364: result: no
configure:4364: checking for stricmp
configure:4364: gcc -o conftest -g -O2 -Wall -W -Wno-unused conftest.c >&5
/tmp/ccfHXHOY.o: In function `main':
/tmp/ccAjejvH.o: In function `main':
/home/gnostic/puaex/src/tools/conftest.c:69: undefined reference to `stricmp'
collect2: ld returned 1 exit status
configure:4364: $? = 1
......
......@@ -227,8 +227,6 @@ static void *trap_thread (void *arg)
{
TrapContext *context = (TrapContext *) arg;
uae_set_thread_priority (2);
/* Wait until main thread is ready to switch to the
* this trap context. */
uae_sem_wait (&context->switch_to_trap_sem);
......
......@@ -19,7 +19,7 @@
static struct uae_xcmd *first = NULL;
static struct uae_xcmd *last = NULL;
static TCHAR running = 0;
static uae_u32 uaeexe_server (TrapContext *context) REGPARAM;
static uae_u32 REGPARAM3 uaeexe_server (TrapContext *context) REGPARAM;
/*
* Install the server
......
......@@ -57,7 +57,7 @@ static uae_u32 emulib_Reset (void)
static uae_u32 emulib_EnableSound (uae_u32 val)
{
if (!sound_available || currprefs.produce_sound == 2)
return 0;
return 0;
currprefs.produce_sound = val;
return 1;
......@@ -79,12 +79,12 @@ static uae_u32 emulib_EnableJoystick (uae_u32 val)
static uae_u32 emulib_SetFrameRate (uae_u32 val)
{
if (val == 0)
return 0;
return 0;
else if (val > 20)
return 0;
return 0;
else {
currprefs.gfx_framerate = val;
return 1;
currprefs.gfx_framerate = val;
return 1;
}
}
......@@ -191,7 +191,7 @@ static uae_u32 emulib_InsertDisk (uaecptr name, uae_u32 drive)
return 0;
while ((real_name[i] = get_byte (name + i)) != 0 && i++ != 254)
;
;
if (i == 255)
return 0; /* ENAMETOOLONG */
......@@ -371,32 +371,32 @@ static uae_u32 REGPARAM2 uaelib_demux2 (TrapContext *context)
switch (ARG0)
{
case 0: return emulib_GetVersion ();
case 1: return emulib_GetUaeConfig (ARG1);
case 2: return emulib_SetUaeConfig (ARG1);
case 3: return emulib_HardReset ();
case 4: return emulib_Reset ();
case 5: return emulib_InsertDisk (ARG1, ARG2);
case 6: return emulib_EnableSound (ARG1);
case 7: return emulib_EnableJoystick (ARG1);
case 8: return emulib_SetFrameRate (ARG1);
case 0: return emulib_GetVersion ();
case 1: return emulib_GetUaeConfig (ARG1);
case 2: return emulib_SetUaeConfig (ARG1);
case 3: return emulib_HardReset ();
case 4: return emulib_Reset ();
case 5: return emulib_InsertDisk (ARG1, ARG2);
case 6: return emulib_EnableSound (ARG1);
case 7: return emulib_EnableJoystick (ARG1);
case 8: return emulib_SetFrameRate (ARG1);
case 9: return emulib_ChgCMemSize (ARG1);
case 10: return emulib_ChgSMemSize (ARG1);
case 11: return emulib_ChgFMemSize (ARG1);
case 12: return emulib_ChangeLanguage (ARG1);
/* The next call brings bad luck */
case 13: return emulib_ExitEmu ();
case 14: return emulib_GetDisk (ARG1, ARG2);
case 15: return emulib_Debug ();
case 12: return emulib_ChangeLanguage (ARG1);
/* The next call brings bad luck */
case 13: return emulib_ExitEmu ();
case 14: return emulib_GetDisk (ARG1, ARG2);
case 15: return emulib_Debug ();
case 68: return emulib_Minimize ();
case 68: return emulib_Minimize ();
case 69: return emulib_ExecuteNativeCode ();
case 70: return 0; /* RESERVED. Something uses this.. */
case 80: return currprefs.maprom ? currprefs.maprom : 0xffffffff;
case 81: return cfgfile_uaelib (ARG1, ARG2, ARG3, ARG4);
case 82: return cfgfile_uaelib_modify (ARG1, ARG2, ARG3, ARG4, ARG5);
case 80: return currprefs.maprom ? currprefs.maprom : 0xffffffff;
case 81: return cfgfile_uaelib (ARG1, ARG2, ARG3, ARG4);
case 82: return cfgfile_uaelib_modify (ARG1, ARG2, ARG3, ARG4, ARG5);
case 83: currprefs.mmkeyboard = ARG1 ? 1 : 0; return currprefs.mmkeyboard;
#ifdef DEBUGGER
case 84: return mmu_init (ARG1, ARG2, ARG3);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment