trying to sync rc1

parent e63e410c
......@@ -603,6 +603,8 @@ STATIC_INLINE int ar3a (uaecptr addr, uae_u8 b, int writing)
return 0;
}
static void action_replay_chipwrite (void);
void REGPARAM2 chipmem_lput_actionreplay1 (uaecptr addr, uae_u32 l)
{
uae_u32 *m;
......@@ -619,7 +621,7 @@ void REGPARAM2 chipmem_wput_actionreplay1 (uaecptr addr, uae_u32 w)
addr -= chipmem_start & chipmem_mask;
addr &= chipmem_mask;
if (addr == 0x62 && !is_ar_pc_in_rom())
if (addr == 0x60 && !is_ar_pc_in_rom())
action_replay_chipwrite ();
m = (uae_u16 *)(chipmemory + addr);
do_put_mem_word (m, w);
......
......@@ -32,8 +32,10 @@ static void install_driver (int flags)
device_func[DF_IOCTL] = NULL;
device_func[DF_SCSI] = &devicefunc_win32_aspi;
if (devicefunc_cdimage.openbus (0)) {
if (devicefunc_cdimage.openbus (flags)) {
device_func[DF_IOCTL] = &devicefunc_cdimage;
device_func[DF_SCSI] = NULL;
return;
}
#ifdef WINDDK
if (!device_func[DF_IOCTL])
......@@ -85,18 +87,24 @@ static void install_driver (int flags)
int sys_command_open (int mode, int unitnum)
{
if (mode == DF_SCSI || !have_ioctl)
if (mode == DF_SCSI || !have_ioctl) {
if (device_func[DF_SCSI] == NULL)
return 0;
return device_func[DF_SCSI]->opendev (unitnum);
else
} else {
return device_func[DF_IOCTL]->opendev (unitnum);
}
}
void sys_command_close (int mode, int unitnum)
{
if (mode == DF_SCSI || !have_ioctl)
if (mode == DF_SCSI || !have_ioctl) {
if (device_func[DF_SCSI] == NULL)
return;
device_func[DF_SCSI]->closedev (unitnum);
else
} else {
device_func[DF_IOCTL]->closedev (unitnum);
}
}
void device_func_reset (void)
......@@ -114,9 +122,13 @@ int device_func_init (int flags)
have_ioctl = 1;
else
have_ioctl = 0;
support_scsi = device_func[DF_SCSI]->openbus (oflags) ? 1 : 0;
if (flags & DEVICE_TYPE_ALLOWEMU)
oflags |= DEVICE_TYPE_ALLOWEMU;
if (device_func[DF_SCSI])
support_scsi = device_func[DF_SCSI]->openbus (oflags) ? 1 : 0;
oflags |= 1 << INQ_ROMD;
if (have_ioctl)
support_ioctl = device_func[DF_IOCTL]->openbus (1 << INQ_ROMD) ? 1 : 0;
support_ioctl = device_func[DF_IOCTL]->openbus (oflags) ? 1 : 0;
write_log ("support_scsi = %d support_ioctl = %d\n", support_scsi, support_ioctl);
return (support_scsi ? (1 << DF_SCSI) : 0) | (support_ioctl ? (1 << DF_IOCTL) : 0);
}
......@@ -394,9 +406,9 @@ static void scsi_atapi_fixup_inquiry (struct amigascsi *as)
int sys_command_scsi_direct_native(int unitnum, struct amigascsi *as)
{
int ret = device_func[DF_SCSI]->exec_direct (unitnum, as);
if (!ret && device_func[DF_SCSI]->isatapi(unitnum))
if (!ret && device_func[DF_SCSI]->isatapi(unitnum))
scsi_atapi_fixup_inquiry (as);
return ret;
return ret;
}
int sys_command_scsi_direct (int unitnum, uaecptr acmd)
......
......@@ -214,7 +214,7 @@ static const TCHAR *obsolete[] = {
"kickstart_key_file", "fast_copper", "sound_adjust",
"serial_hardware_dtrdsr", "gfx_filter_upscale",
"gfx_correct_aspect", "gfx_autoscale", "parallel_sampler", "parallel_ascii_emulation",
"avoid_vid", "avoid_dga",
"avoid_vid", "avoid_dga", "z3chipmem_size",
NULL
};
......@@ -292,9 +292,9 @@ const char *prefs_get_attr (const char *key)
prefs_attr_t *attr = lookup_attr (key);
if (attr)
return attr->value;
return attr->value;
else
return 0;
return 0;
}
static void trimwsa (char *s)
......@@ -423,13 +423,13 @@ void cfgfile_target_dwrite_str (struct zfile *f, const TCHAR *option, const TCHA
void cfgfile_write (struct zfile *f, const TCHAR *option, const TCHAR *format,...)
{
va_list parms;
va_list parms;
TCHAR tmp[CONFIG_BLEN];
va_start (parms, format);
va_start (parms, format);
vsnprintf (tmp, CONFIG_BLEN, format, parms);
cfg_dowrite (f, option, tmp, 0, 0);
va_end (parms);
va_end (parms);
}
void cfgfile_dwrite (struct zfile *f, const TCHAR *option, const TCHAR *format,...)
{
......@@ -642,6 +642,7 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
cfgfile_write (f, "floppy_speed", "%d", p->floppy_speed);
#ifdef DRIVESOUND
cfgfile_write (f, "floppy_volume", "%d", p->dfxclickvolume);
cfgfile_dwrite (f, "floppy_channel_mask", "0x%x", p->dfxclickchannelmask);
#endif
cfgfile_write_bool (f, "parallel_on_demand", p->parallel_demand);
cfgfile_write_bool (f, "serial_on_demand", p->serial_demand);
......@@ -882,11 +883,11 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
cfgfile_write (f, "mbresmem_size", "%d", p->mbresmem_high_size / 0x100000);
cfgfile_write (f, "z3mem_size", "%d", p->z3fastmem_size / 0x100000);
cfgfile_write (f, "z3mem2_size", "%d", p->z3fastmem2_size / 0x100000);
cfgfile_write (f, "z3chipmem_size", "%d", p->z3chipmem_size / 0x100000);
cfgfile_write (f, "z3mem_start", "0x%x", p->z3fastmem_start);
cfgfile_write (f, "bogomem_size", "%d", p->bogomem_size / 0x40000);
cfgfile_write (f, "gfxcard_size", "%d", p->gfxmem_size / 0x100000);
cfgfile_write (f, "chipmem_size", "%d", p->chipmem_size == 0x20000 ? -1 : (p->chipmem_size == 0x40000 ? 0 : p->chipmem_size / 0x80000));
cfgfile_dwrite (f, "megachipmem_size", "%d", p->z3chipmem_size / 0x100000);
if (p->m68k_speed > 0)
cfgfile_write (f, "finegrain_cpu_speed", "%d", p->m68k_speed);
......@@ -942,7 +943,7 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
cfgfile_dwrite_bool (f, "warp", p->turbo_emulation);
#ifdef FILESYS
//write_filesys_config (currprefs.mountinfo, UNEXPANDED, prefs_get_attr ("hardfile_path"), f);
//write_filesys_config (currprefs.mountinfo, UNEXPANDED, prefs_get_attr ("hardfile_path"), f);
if (p->filesys_no_uaefsdb)
cfgfile_write_bool (f, "filesys_no_fsdb", p->filesys_no_uaefsdb);
#endif
......@@ -957,10 +958,11 @@ int cfgfile_yesno2 (const TCHAR *option, const TCHAR *value, const TCHAR *name,
|| strcasecmp (value, "true") == 0 || strcasecmp (value, "t") == 0)
*location = 1;
else if (strcasecmp (value, "no") == 0 || strcasecmp (value, "n") == 0
|| strcasecmp (value, "false") == 0 || strcasecmp (value, "f") == 0)
|| strcasecmp (value, "false") == 0 || strcasecmp (value, "f") == 0
|| strcasecmp (value, "0") == 0)
*location = 0;
else {
write_log ("Option `%s' requires a value of either `yes' or `no'.\n", option);
write_log ("Option `%s' requires a value of either `yes' or `no' (was '%s').\n", option, value);
return -1;
}
return 1;
......@@ -1251,8 +1253,10 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value)
}
}
if (cfgfile_path (option, value, "cdimage0", p->cdimagefile, sizeof p->cdimagefile / sizeof (TCHAR)))
if (cfgfile_path (option, value, "cdimage0", p->cdimagefile, sizeof p->cdimagefile / sizeof (TCHAR))) {
p->cdimagefileuse = true;
return 1;
}
if (cfgfile_intval (option, value, "sound_frequency", &p->sound_freq, 1)) {
/* backwards compatibility */
......@@ -1314,7 +1318,8 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value)
|| cfgfile_intval (option, value, "floppy2sound", &p->dfxclick[2], 1)
|| cfgfile_intval (option, value, "floppy3sound", &p->dfxclick[3], 1)
#endif
|| cfgfile_intval (option, value, "floppy_volume", &p->dfxclickvolume, 1))
|| cfgfile_intval (option, value, "floppy_channel_mask", &p->dfxclickchannelmask, 1)
|| cfgfile_intval (option, value, "floppy_volume", &p->dfxclickvolume, 1))
return 1;
if (
......@@ -1921,32 +1926,33 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, TCHAR *option, TCHAR *va
return 1;
if (cfgfile_intval (option, value, "cpu060_revision", &p->cpu060_revision, 1)
|| cfgfile_intval (option, value, "fpu_revision", &p->fpu_revision, 1)
|| cfgfile_intval (option, value, "cdtvramcard", &p->cs_cdtvcard, 1)
|| cfgfile_intval (option, value, "fatgary", &p->cs_fatgaryrev, 1)
|| cfgfile_intval (option, value, "ramsey", &p->cs_ramseyrev, 1)
|| cfgfile_intval (option, value, "chipset_refreshrate", &p->chipset_refreshrate, 1)
|| cfgfile_intval (option, value, "fastmem_size", &p->fastmem_size, 0x100000)
|| cfgfile_intval (option, value, "a3000mem_size", &p->mbresmem_low_size, 0x100000)
|| cfgfile_intval (option, value, "mbresmem_size", &p->mbresmem_high_size, 0x100000)
|| cfgfile_intval (option, value, "z3mem_size", &p->z3fastmem_size, 0x100000)
|| cfgfile_intval (option, value, "z3mem2_size", &p->z3fastmem2_size, 0x100000)
|| cfgfile_intval (option, value, "z3mem_start", &p->z3fastmem_start, 1)
|| cfgfile_intval (option, value, "bogomem_size", &p->bogomem_size, 0x40000)
|| cfgfile_intval (option, value, "gfxcard_size", &p->gfxmem_size, 0x100000)
|| cfgfile_intval (option, value, "rtg_modes", &p->picasso96_modeflags, 1)
|| cfgfile_intval (option, value, "floppy_speed", &p->floppy_speed, 1)
|| cfgfile_intval (option, value, "floppy_write_length", &p->floppy_write_length, 1)
|| cfgfile_intval (option, value, "nr_floppies", &p->nr_floppies, 1)
|| cfgfile_intval (option, value, "floppy0type", &p->dfxtype[0], 1)
|| cfgfile_intval (option, value, "floppy1type", &p->dfxtype[1], 1)
|| cfgfile_intval (option, value, "floppy2type", &p->dfxtype[2], 1)
|| cfgfile_intval (option, value, "floppy3type", &p->dfxtype[3], 1)
|| cfgfile_intval (option, value, "maprom", &p->maprom, 1)
|| cfgfile_intval (option, value, "parallel_autoflush", &p->parallel_autoflush_time, 1)
|| cfgfile_intval (option, value, "uae_hide", &p->uae_hide, 1)
|| cfgfile_intval (option, value, "cpu_frequency", &p->cpu_frequency, 1)
|| cfgfile_intval (option, value, "catweasel", &p->catweasel, 1))
|| cfgfile_intval (option, value, "fpu_revision", &p->fpu_revision, 1)
|| cfgfile_intval (option, value, "cdtvramcard", &p->cs_cdtvcard, 1)
|| cfgfile_intval (option, value, "fatgary", &p->cs_fatgaryrev, 1)
|| cfgfile_intval (option, value, "ramsey", &p->cs_ramseyrev, 1)
|| cfgfile_intval (option, value, "chipset_refreshrate", &p->chipset_refreshrate, 1)
|| cfgfile_intval (option, value, "fastmem_size", &p->fastmem_size, 0x100000)
|| cfgfile_intval (option, value, "a3000mem_size", &p->mbresmem_low_size, 0x100000)
|| cfgfile_intval (option, value, "mbresmem_size", &p->mbresmem_high_size, 0x100000)
|| cfgfile_intval (option, value, "z3mem_size", &p->z3fastmem_size, 0x100000)
|| cfgfile_intval (option, value, "z3mem2_size", &p->z3fastmem2_size, 0x100000)
|| cfgfile_intval (option, value, "megachipmem_size", &p->z3chipmem_size, 0x100000)
|| cfgfile_intval (option, value, "z3mem_start", &p->z3fastmem_start, 1)
|| cfgfile_intval (option, value, "bogomem_size", &p->bogomem_size, 0x40000)
|| cfgfile_intval (option, value, "gfxcard_size", &p->gfxmem_size, 0x100000)
|| cfgfile_intval (option, value, "rtg_modes", &p->picasso96_modeflags, 1)
|| cfgfile_intval (option, value, "floppy_speed", &p->floppy_speed, 1)
|| cfgfile_intval (option, value, "floppy_write_length", &p->floppy_write_length, 1)
|| cfgfile_intval (option, value, "nr_floppies", &p->nr_floppies, 1)
|| cfgfile_intval (option, value, "floppy0type", &p->dfxtype[0], 1)
|| cfgfile_intval (option, value, "floppy1type", &p->dfxtype[1], 1)
|| cfgfile_intval (option, value, "floppy2type", &p->dfxtype[2], 1)
|| cfgfile_intval (option, value, "floppy3type", &p->dfxtype[3], 1)
|| cfgfile_intval (option, value, "maprom", &p->maprom, 1)
|| cfgfile_intval (option, value, "parallel_autoflush", &p->parallel_autoflush_time, 1)
|| cfgfile_intval (option, value, "uae_hide", &p->uae_hide, 1)
|| cfgfile_intval (option, value, "cpu_frequency", &p->cpu_frequency, 1)
|| cfgfile_intval (option, value, "catweasel", &p->catweasel, 1))
return 1;
#ifdef JIT
......@@ -2522,7 +2528,7 @@ static int cfgfile_load_2 (struct uae_prefs *p, const TCHAR *filename, bool real
write_log ("Opening cfgfile '%s': ", filename);
fh = zfile_fopen (filename, "r", ZFD_NORMAL);
#ifndef SINGLEFILE
#ifndef SINGLEFILE
if (! fh) {
write_log ("failed\n");
return 0;
......@@ -2576,7 +2582,7 @@ static int cfgfile_load_2 (struct uae_prefs *p, const TCHAR *filename, bool real
subst (prefs_get_attr("rom_path"), p->romextfile, sizeof p->romextfile);
subst (prefs_get_attr("rom_path"), p->keyfile, sizeof p->keyfile);
return 1;
return 1;
}
int cfgfile_load (struct uae_prefs *p, const TCHAR *filename, int *type, int ignorelink, int userconfig)
......@@ -3605,6 +3611,13 @@ void default_prefs (struct uae_prefs *p, int type)
strcpy (p->cartfile, "");
#endif
prefs_set_attr ("rom_path", strdup_path_expand (TARGET_ROM_PATH));
prefs_set_attr ("floppy_path", strdup_path_expand (TARGET_FLOPPY_PATH));
prefs_set_attr ("hardfile_path", strdup_path_expand (TARGET_HARDFILE_PATH));
#ifdef SAVESTATE
prefs_set_attr ("savestate_path", strdup_path_expand (TARGET_SAVESTATE_PATH));
#endif
_tcscpy (p->path_rom, "./");
_tcscpy (p->path_floppy, "./");
_tcscpy (p->path_hardfile, "./");
......
......@@ -1082,10 +1082,16 @@ static void illg_init (void)
memset (illgdebug + 0xe00000, 1, 512 * 1024); /* CD32 ext ROM */
}
#endif
if (currprefs.cs_ksmirror_e0)
memset (illgdebug + 0xe00000, 1, 512 * 1024);
if (currprefs.cs_ksmirror_a8)
memset (illgdebug + 0xa80000, 1, 2 * 512 * 1024);
#ifdef FILESYS
if (uae_boot_rom) /* filesys "rom" */
memset (illgdebug + rtarea_base, 1, 0x10000);
#endif
if (currprefs.cs_ide > 0)
memset (illgdebug + 0xdd0000, 3, 65536);
}
/* add special custom register check here */
......@@ -1130,7 +1136,7 @@ static void illg_debug_do (uaecptr addr, int rwi, int size, uae_u32 val)
}
}
STATIC_INLINE uae_u8 debug_mem_off (uaecptr addr)
STATIC_INLINE int debug_mem_off (uaecptr addr)
{
return munge24 (addr) >> 16;
}
......@@ -1534,7 +1540,7 @@ static void deinitialize_memwatch (void)
unsigned int i;
if (!memwatch_enabled)
return;
return;
for (i = 0; i < 256; i++) {
addrbank *a1 = debug_mem_banks[i];
addrbank *a2 = mem_banks[i];
......@@ -1686,18 +1692,18 @@ static void memwatch (const char **c)
console_out ("Memwatch %d removed\n", num);
return;
}
mwn->addr = readhex (c);
mwn->size = 1;
mwn->addr = readhex (c);
mwn->size = 1;
mwn->rwi = 7;
mwn->val_enabled = 0;
mwn->val_enabled = 0;
mwn->valmask = 0xffffffff;
mwn->frozen = 0;
mwn->modval_written = 0;
ignore_ws (c);
if (more_params (c)) {
mwn->size = readhex (c);
mwn->modval_written = 0;
ignore_ws (c);
if (more_params (c)) {
mwn->size = readhex (c);
ignore_ws (c);
if (more_params (c)) {
char nc = toupper (next_char (c));
if (nc == 'W')
mwn->rwi = 1;
......@@ -1711,38 +1717,49 @@ static void memwatch (const char **c)
mwn->modval_written = 1;
} else if (toupper (**c) == 'C') {
mwn->mustchange = 1;
} else {
mwn->val = readhex (c);
mwn->val_enabled = 1;
} else {
mwn->val = readhex (c);
mwn->val_enabled = 1;
}
}
}
}
}
}
if (mwn->frozen && mwn->rwi == 0)
mwn->rwi = 3;
memwatch_dump (num);
memwatch_dump (num);
}
static void writeintomem (const char **c)
{
uae_u32 addr = 0;
uae_u32 val = 0;
char cc;
ignore_ws (c);
addr = readhex (c);
ignore_ws (c);
val = readhex (c);
if (val > 0xffff) {
put_long (addr, val);
cc = 'L';
} else if (val > 0xff) {
put_word (addr, val);
cc = 'W';
} else {
put_byte (addr, val);
cc = 'B';
}
uae_u32 addr = 0;
uae_u32 val = 0;
char cc;
int len = 1;
ignore_ws(c);
addr = readhex (c);
ignore_ws(c);
val = readhex (c);
if (val > 0xffff)
len = 4;
else if (val > 0xff)
len = 2;
else
len = 1;
if (more_params (c)) {
ignore_ws (c);
len = readint (c);
}
if (len == 4) {
put_long (addr, val);
cc = 'L';
} else if (len == 2) {
put_word (addr, val);
cc = 'W';
} else {
put_byte (addr, val);
cc = 'B';
}
console_out ("Wrote %X (%u) at %08X.%c\n", val, val, addr, cc);
}
......@@ -1755,12 +1772,13 @@ static uae_u8 *dump_xlate (uae_u32 addr)
static void memory_map_dump_2 (int log)
{
int i, j, max, im;
bool imold;
int i, j, max;
addrbank *a1 = mem_banks[0];
char txt[256];
im = currprefs.illegal_mem;
currprefs.illegal_mem = 0;
imold = currprefs.illegal_mem;
currprefs.illegal_mem = false;
max = currprefs.address_space_24 ? 256 : 65536;
j = 0;
for (i = 0; i < max + 1; i++) {
......@@ -1824,7 +1842,7 @@ static void memory_map_dump_2 (int log)
a1 = a2;
}
}
currprefs.illegal_mem = im;
currprefs.illegal_mem = imold;
}
void memory_map_dump (void)
{
......@@ -2006,56 +2024,56 @@ int instruction_breakpoint (const char **c)
static void savemem (char **cc)
{
uae_u8 b;
uae_u32 src, src2, len, len2;
uae_u8 b;
uae_u32 src, src2, len, len2;
char *name;
FILE *fp;
FILE *fp;
if (!more_params (cc))
goto S_argh;
if (!more_params (cc))
goto S_argh;
name = *cc;
while (**cc != '\0' && !isspace (**cc))
name = *cc;
while (**cc != '\0' && !isspace (**cc))
(*cc)++;
if (!isspace (**cc))
if (!isspace (**cc))
goto S_argh;
**cc = '\0';
(*cc)++;
if (!more_params (cc))
(*cc)++;
if (!more_params (cc))
goto S_argh;
src2 = src = readhex (cc);
if (!more_params (cc))
src2 = src = readhex (cc);
if (!more_params (cc))
goto S_argh;
len2 = len = readhex (cc);
len2 = len = readhex (cc);
fp = fopen (name, "wb");
if (fp == NULL) {
if (fp == NULL) {
console_out ("Couldn't open file '%s'\n", name);
return;
}
while (len > 0) {
}
while (len > 0) {
b = get_byte (src);
src++;
len--;
if (fwrite (&b, 1, 1, fp) != 1) {
console_out ("Error writing file\n");
break;
break;
}
}
fclose (fp);
if (len == 0)
}
fclose (fp);
if (len == 0)
console_out ("Wrote %08X - %08X (%d bytes) to '%s'\n",
src2, src2 + len2 - 1, len2, name);
return;
return;
S_argh:
console_out ("S-command needs more arguments!\n");
}
static void searchmem (const char **cc)
{
int i, sslen, got, val, stringmode;
uae_u8 ss[256];
uae_u32 addr, endaddr;
int i, sslen, got, val, stringmode;
uae_u8 ss[256];
uae_u32 addr, endaddr;
char nc;
got = 0;
......@@ -2075,7 +2093,7 @@ static void searchmem (const char **cc)
for (;;) {
if (**cc == 32 || **cc == 0)
break;
nc = toupper (next_char (cc));
nc = toupper (next_char (cc));
if (isspace (nc))
break;
if (isdigit(nc))
......@@ -2087,7 +2105,7 @@ static void searchmem (const char **cc)
val *= 16;
if (**cc == 32 || **cc == 0)
break;
nc = toupper (next_char (cc));
nc = toupper (next_char (cc));
if (isspace (nc))
break;
if (isdigit(nc))
......@@ -2109,30 +2127,30 @@ static void searchmem (const char **cc)
if (more_params (cc))
endaddr = readhex (cc);
}
console_out ("Searching from %08x to %08x..\n", addr, endaddr);
console_out ("Searching from %08x to %08x..\n", addr, endaddr);
while ((addr = nextaddr (addr, NULL)) != 0xffffffff) {
if (addr == endaddr)
break;
for (i = 0; i < sslen; i++) {
uae_u8 b = get_byte (addr + i);
if (stringmode) {
if (tolower (b) != ss[i])
break;
} else {
if (b != ss[i])
break;
}
}
if (i == sslen) {
got++;
console_out (" %08x", addr);
if (got > 100) {
console_out ("\nMore than 100 results, aborting..");
break;
}
uae_u8 b = get_byte (addr + i);
if (stringmode) {
if (tolower (b) != ss[i])
break;
} else {
if (b != ss[i])
break;
}
}
if (i == sslen) {
got++;
console_out (" %08x", addr);
if (got > 100) {
console_out ("\nMore than 100 results, aborting..");
break;
}
}
}
}
if (!got)
if (!got)
console_out ("nothing found");
console_out ("\n");
}
......@@ -2140,7 +2158,7 @@ static void searchmem (const char **cc)
#ifdef SAVESTATE
static int staterecorder (const char **cc)
{
char nc;
char nc;
if (!more_params (cc)) {
if (savestate_dorewind (1)) {
......@@ -2165,8 +2183,8 @@ static const TCHAR *debugtest_names[] = {
static void disk_debug (const char **inptr)
{
char parm[10];
unsigned int i;
char parm[10];
unsigned int i;
if (**inptr == 'd') {
(*inptr)++;
......@@ -2236,16 +2254,16 @@ static void find_ea (char **inptr)
static void m68k_modify (const char **inptr)
{
uae_u32 v;
char parm[10];
unsigned char c1, c2;
uae_u32 v;
char parm[10];
unsigned char c1, c2;
int i;
if (!next_string (inptr, parm, sizeof (parm) / sizeof (TCHAR), 1))
return;
c1 = toupper (parm[0]);
c2 = 99;
if (c1 == 'A' || c1 == 'D' || c1 == 'P') {
c1 = toupper (parm[0]);
c2 = 99;
if (c1 == 'A' || c1 == 'D' || c1 == 'P') {
c2 = toupper (parm[1]);
if (isdigit (c2))
c2 -= '0';
......@@ -2285,13 +2303,13 @@ static void m68k_modify (const char **inptr)
static void debug_1 (void)
{
char input[MAX_LINEWIDTH];
uaecptr nxdis, nxmem, addr;
uaecptr nxdis, nxmem, addr;
m68k_dumpstate (stdout, &nextpc);
nxdis = nextpc; nxmem = 0;
m68k_dumpstate (stdout, &nextpc);
nxdis = nextpc; nxmem = 0;
debugger_active = 1;
for (;;) {
for (;;) {
char cmd;
const char *inptr;
int v;
......@@ -2333,20 +2351,24 @@ static void debug_1 (void)
}
break;
}
case 'e': dump_custom_regs (); break;
case 'r': if (more_params (&inptr))
m68k_modify (&inptr);
else
m68k_dumpstate (stdout, &nextpc);
break;
case 'C': cheatsearch (&inptr); break;
case 'W': writeintomem (&inptr); break;
case 'w': memwatch (&inptr); break;
case 'S': savemem (&inptr); break;
case 's':
if (*inptr == 'c') {
// screenshot (1, 1);
} else if (*inptr == 'm') {
case 'e': dump_custom_regs (); break;
case 'r':
{
if (more_params(&inptr))
m68k_modify (&inptr);
else
m68k_dumpstate (stdout, &nextpc);
}
break;
//case 'D': deepcheatsearch (&inptr); break;
case 'C': cheatsearch (&inptr); break;
case 'W': writeintomem (&inptr); break;
case 'w': memwatch (&inptr); break;
case 'S': savemem (&inptr); break;
case 's':
if (*inptr == 'c') {
;//screenshot (1, 1);
} else if (*inptr == 'm') {
next_char (&inptr);
if (more_params (&inptr))
debug_sprite_mask = readint (&inptr);
......@@ -2497,13 +2519,13 @@ static void debug_1 (void)
static void addhistory (void)
{
history[lasthist] = regs;
history[lasthist].pc = m68k_getpc ();
if (++lasthist == MAX_HIST)
lasthist = 0;
if (lasthist == firsthist) {
if (++firsthist == MAX_HIST) firsthist = 0;
}
history[lasthist] = regs;
history[lasthist].pc = m68k_getpc ();
if (++lasthist == MAX_HIST)
lasthist = 0;
if (lasthist == firsthist) {
if (++firsthist == MAX_HIST) firsthist = 0;
}
}
void debug (void)
......@@ -2537,91 +2559,95 @@ void debug (void)
}
#endif
if (!memwatch_triggered) {
if (do_skip) {
uae_u32 pc = munge24 (m68k_getpc ());
uae_u16 opcode = (currprefs.cpu_compatible || currprefs.cpu_cycle_exact) ? regs.ir : get_word (pc);
int bp = 0;
for (i = 0; i < BREAKPOINT_TOTAL; i++) {
if (!bpnodes[i].enabled)
continue;
if (bpnodes[i].addr == pc) {
bp = 1;
console_out ("Breakpoint at %8.8X\n", pc);
break;
}
}
if (skipaddr_doskip) {
if (skipaddr_start == pc)
bp = 1;
if (skipins != 0xffffffff) {
if (skipins == 0x10000) {
if (opcode == 0x4e75 || opcode == 0x4e73 || opcode == 0x4e77)
bp = 1;
} else if (opcode == skipins)
bp = 1;
} else if (skipaddr_start == 0xffffffff && skipaddr_doskip < 0) {
if ((pc < 0xe00000 || pc >= 0x1000000) && opcode != 0x4ef9)
bp = 1;
} else if (skipaddr_start == 0xffffffff && skipaddr_doskip > 0) {
bp = 1;
} else if (skipaddr_end != 0xffffffff) {
if (pc >= skipaddr_start && pc < skipaddr_end)
bp = 1;
if (!memwatch_triggered) {
if (do_skip) {
uae_u32 pc;
uae_u16 opcode;
int bp = 0;
pc = munge24 (m68k_getpc ());
opcode = (currprefs.cpu_compatible || currprefs.cpu_cycle_exact) ? regs.ir : get_word (pc);
for (i = 0; i < BREAKPOINT_TOTAL; i++) {
if (!bpnodes[i].enabled)
continue;
if (bpnodes[i].addr == pc) {
bp = 1;
console_out (L"Breakpoint at %08X\n", pc);
break;
}
}
if (skipaddr_doskip) {
if (skipaddr_start == pc)
bp = 1;
if (skipins != 0xffffffff) {
if (skipins == 0x10000) {
if (opcode == 0x4e75 || opcode == 0x4e73 || opcode == 0x4e77)
bp = 1;
} else if (opcode == skipins)
bp = 1;
} else if (skipaddr_start == 0xffffffff && skipaddr_doskip < 0) {
if ((pc < 0xe00000 || pc >= 0x1000000) && opcode != 0x4ef9)
bp = 1;
} else if (skipaddr_start == 0xffffffff && skipaddr_doskip > 0) {
bp = 1;
} else if (skipaddr_end != 0xffffffff) {
if (pc >= skipaddr_start && pc < skipaddr_end)
bp = 1;
}
}
if (sr_bpmask || sr_bpvalue) {
MakeSR ();
if ((regs.sr & sr_bpmask) == sr_bpvalue) {
console_out ("SR breakpoint\n");
bp = 1;
}
}
if (!bp) {
set_special (SPCFLAG_BRK);
return;
}
}
}
if (!bp) {
set_special (SPCFLAG_BRK);
return;
}
}
} else {
write_log ("Memwatch %d: break at %8.8X.%c %c %8.8X\n", memwatch_triggered - 1, mwhit.addr,
} else {
write_log ("Memwatch %d: break at %8.8X.%c %c %8.8X\n", memwatch_triggered - 1, mwhit.addr,
mwhit.size == 1 ? 'B' : (mwhit.size == 2 ? 'W' : 'L'), mwhit.rwi ? 'W' : 'R', mwhit.val);
memwatch_triggered = 0;
}
if (skipaddr_doskip > 0) {
skipaddr_doskip--;
memwatch_triggered = 0;
}
if (skipaddr_doskip > 0) {
skipaddr_doskip--;
if (skipaddr_doskip > 0) {
set_special (SPCFLAG_BRK);
return;
return;
}
}
}
inputdevice_unacquire ();
audio_pause ();
do_skip = 0;
skipaddr_start = 0xffffffff;
skipaddr_end = 0xffffffff;
skipins = 0xffffffff;
skipaddr_doskip = 0;
exception_debugging = 0;
inputdevice_unacquire ();
audio_pause ();
do_skip = 0;
skipaddr_start = 0xffffffff;
skipaddr_end = 0xffffffff;
skipins = 0xffffffff;
skipaddr_doskip = 0;
exception_debugging = 0;
#ifdef SAVESTATE
debug_rewind = 0;
debug_rewind = 0;
processptr = 0;
#if 0
if (!currprefs.statecapture) {
changed_prefs.statecapture = currprefs.statecapture = 1;
savestate_init ();
}
#endif
#endif
debug_1 ();
debug_1 ();
#ifdef SAVESTATE
if (!debug_rewind
if (!debug_rewind
#ifdef JIT
&& !currprefs.cachesize
#endif
#ifdef FILESYS
&& nr_units () == 0
#endif
) {
savestate_capture (1);
}
) {
savestate_capture (1);
}
#endif
for (i = 0; i < BREAKPOINT_TOTAL; i++) {
......
......@@ -1291,7 +1291,7 @@ static void drive_motor (drive * drv, bool off)
#endif
}
static void read_floppy_data (struct zfile *diskfile, trackid *tid, int offset, void *dst, int len)
static void read_floppy_data (struct zfile *diskfile, trackid *tid, int offset, uae_u8 *dst, int len)
{
if (len == 0)
return;
......@@ -1300,7 +1300,7 @@ static void read_floppy_data (struct zfile *diskfile, trackid *tid, int offset,
}
/* Megalomania does not like zero MFM words... */
static void mfmcode (uae_u16 *mfm, unsigned int words)
static void mfmcode (uae_u16 * mfm, unsigned int words)
{
uae_u32 lastword = 0;
while (words--) {
......
......@@ -343,16 +343,28 @@ void driveclick_mix (uae_s16 *sndbuffer, int size, int channelmask)
uae_s16 s = clickbuffer[i];
if (channelmask & 1)
sndbuffer[0] = limit (((sndbuffer[0] + s) * 2) / 3);
else
sndbuffer[0] = sndbuffer[0] * 2 / 3;
if (channelmask & 2)
sndbuffer[1] = limit (((sndbuffer[1] + s) * 2) / 3);
else
sndbuffer[1] = sndbuffer[1] * 2 / 3;
if (channelmask & 4)
sndbuffer[2] = limit (((sndbuffer[2] + s) * 2) / 3);
else
sndbuffer[2] = sndbuffer[2] * 2 / 3;
if (channelmask & 8)
sndbuffer[3] = limit (((sndbuffer[3] + s) * 2) / 3);
else
sndbuffer[3] = sndbuffer[3] * 2 / 3;
if (channelmask & 16)
sndbuffer[4] = limit (((sndbuffer[4] + s) * 2) / 3);
else
sndbuffer[4] = sndbuffer[4] * 2 / 3;
if (channelmask & 32)
sndbuffer[5] = limit (((sndbuffer[5] + s) * 2) / 3);
else
sndbuffer[5] = sndbuffer[5] * 2 / 3;
sndbuffer += 6;
}
break;
......@@ -361,12 +373,20 @@ void driveclick_mix (uae_s16 *sndbuffer, int size, int channelmask)
uae_s16 s = clickbuffer[i];
if (channelmask & 1)
sndbuffer[0] = limit (((sndbuffer[0] + s) * 2) / 3);
else
sndbuffer[0] = sndbuffer[0] * 2 / 3;
if (channelmask & 2)
sndbuffer[1] = limit (((sndbuffer[1] + s) * 2) / 3);
else
sndbuffer[1] = sndbuffer[1] * 2 / 3;
if (channelmask & 4)
sndbuffer[2] = limit (((sndbuffer[2] + s) * 2) / 3);
else
sndbuffer[2] = sndbuffer[2] * 2 / 3;
if (channelmask & 8)
sndbuffer[3] = limit (((sndbuffer[3] + s) * 2) / 3);
else
sndbuffer[3] = sndbuffer[3] * 2 / 3;
sndbuffer += 4;
}
break;
......@@ -375,8 +395,12 @@ void driveclick_mix (uae_s16 *sndbuffer, int size, int channelmask)
uae_s16 s = clickbuffer[i];
if (channelmask & 1)
sndbuffer[0] = limit (((sndbuffer[0] + s) * 2) / 3);
else
sndbuffer[0] = sndbuffer[0] * 2 / 3;
if (channelmask & 2)
sndbuffer[1] = limit (((sndbuffer[1] + s) * 2) / 3);
else
sndbuffer[1] = sndbuffer[1] * 2 / 3;
sndbuffer += 2;
}
break;
......
/*
* UAE - The Un*x Amiga Emulator
*
* AutoConfig (tm) Expansions (ZorroII/III)
*
* Copyright 1996,1997 Stefan Reinauer <stepan@linux.de>
* Copyright 1997 Brian King <Brian_King@Mitel.com>
* - added gfxcard code
*
*/
/*
* UAE - The Un*x Amiga Emulator
*
* AutoConfig (tm) Expansions (ZorroII/III)
*
* Copyright 1996,1997 Stefan Reinauer <stepan@linux.de>
* Copyright 1997 Brian King <Brian_King@Mitel.com>
* - added gfxcard code
*
*/
#include "sysconfig.h"
#include "sysdeps.h"
......@@ -30,7 +30,7 @@
#include "debug.h"
#include "gayle.h"
#define MAX_EXPANSION_BOARDS 8
#define MAX_EXPANSION_BOARDS 8
/* ********************************************************** */
/* 00 / 02 */
......@@ -178,10 +178,10 @@ static void REGPARAM3 expamem_wput (uaecptr, uae_u32) REGPARAM;
static void REGPARAM3 expamem_bput (uaecptr, uae_u32) REGPARAM;
addrbank expamem_bank = {
expamem_lget, expamem_wget, expamem_bget,
expamem_lput, expamem_wput, expamem_bput,
expamem_lget, expamem_wget, expamem_bget,
expamem_lput, expamem_wput, expamem_bput,
default_xlate, default_check, NULL, "Autoconfig",
dummy_lgeti, dummy_wgeti, ABFLAG_IO | ABFLAG_SAFE
dummy_lgeti, dummy_wgeti, ABFLAG_IO | ABFLAG_SAFE
};
static void expamem_map_clear (void)
......@@ -232,7 +232,7 @@ static uae_u32 REGPARAM2 expamem_bget (uaecptr addr)
#ifdef JIT
special_mem |= SPECIAL_MEM_READ;
#endif
addr &= 0xFFFF;
addr &= 0xFFFF;
b = expamem[addr];
//write_log ("%08x=%02X\n", addr, b);
return b;
......@@ -243,19 +243,19 @@ static void REGPARAM2 expamem_write (uaecptr addr, uae_u32 value)
#ifdef JIT
special_mem |= SPECIAL_MEM_WRITE;
#endif
addr &= 0xffff;
if (addr == 00 || addr == 02 || addr == 0x40 || addr == 0x42) {
expamem[addr] = (value & 0xf0);
expamem[addr + 2] = (value & 0x0f) << 4;
} else {
expamem[addr] = ~(value & 0xf0);
expamem[addr + 2] = ~((value & 0x0f) << 4);
}
addr &= 0xffff;
if (addr == 00 || addr == 02 || addr == 0x40 || addr == 0x42) {
expamem[addr] = (value & 0xf0);
expamem[addr + 2] = (value & 0x0f) << 4;
} else {
expamem[addr] = ~(value & 0xf0);
expamem[addr + 2] = ~((value & 0x0f) << 4);
}
}
static int REGPARAM2 expamem_type (void)
{
return ((expamem[0] | expamem[2] >> 4) & 0xc0);
return ((expamem[0] | expamem[2] >> 4) & 0xc0);
}
static void REGPARAM2 expamem_lput (uaecptr addr, uae_u32 value)
......@@ -274,12 +274,12 @@ static void REGPARAM2 expamem_wput (uaecptr addr, uae_u32 value)
value &= 0xffff;
if (ecard >= cardno)
return;
if (expamem_type() != zorroIII)
if (expamem_type() != zorroIII)
write_log ("warning: WRITE.W to address $%lx : value $%x\n", addr, value);
else {
switch (addr & 0xff) {
case 0x44:
if (expamem_type() == zorroIII) {
else {
switch (addr & 0xff) {
case 0x44:
if (expamem_type() == zorroIII) {
uae_u32 p1, p2;
// +Bernd Roesch & Toni Wilen
p1 = get_word (regs.regs[11] + 0x20);
......@@ -288,9 +288,9 @@ static void REGPARAM2 expamem_wput (uaecptr addr, uae_u32 value)
p2 = 0;
while (!p2 && z3num < 2) {
if (z3num == 0 && currprefs.z3fastmem_size)
p2 = z3fastmem_start >> 16;
p2 = z3fastmem_start >> 16;
else if (z3num == 1 && currprefs.z3fastmem2_size)
p2 = z3fastmem2_start >> 16;
p2 = z3fastmem2_start >> 16;
if (!p2)
z3num++;
}
......@@ -301,21 +301,21 @@ static void REGPARAM2 expamem_wput (uaecptr addr, uae_u32 value)
}
put_word (regs.regs[11] + 0x20, p2);
put_word (regs.regs[11] + 0x28, p2);
// -Bernd Roesch
// -Bernd Roesch
expamem_hi = p2;
(*card_map[ecard]) ();
(*card_map[ecard]) ();
ecard++;
if (p1 != p2)
write_log (" Card %d remapped %04x0000 -> %04x0000\n", ecard, p1, p2);
write_log (" Card %d (Zorro%s) done.\n", ecard, expamem_type () == 0xc0 ? "II" : "III");
if (ecard < cardno)
(*card_init[ecard]) ();
else
expamem_init_clear2 ();
}
break;
(*card_init[ecard]) ();
else
expamem_init_clear2 ();
}
break;
}
}
}
}
static void REGPARAM2 expamem_bput (uaecptr addr, uae_u32 value)
......@@ -353,15 +353,15 @@ static void REGPARAM2 expamem_bput (uaecptr addr, uae_u32 value)
expamem_lo = value;
break;
case 0x4c:
write_log (" Card %d (Zorro%s) had no success.\n", ecard + 1, expamem_type () == 0xc0 ? "II" : "III");
case 0x4c:
write_log (" Card %d (Zorro%s) had no success.\n", ecard + 1, expamem_type () == 0xc0 ? L"II" : L"III");
++ecard;
if (ecard < cardno)
(*card_init[ecard]) ();
(*card_init[ecard]) ();
else
expamem_init_clear2 ();
expamem_init_clear2 ();
break;
}
}
}
#ifdef CD32
......@@ -415,73 +415,73 @@ static uae_u8 *fastmemory;
static uae_u32 REGPARAM2 fastmem_lget (uaecptr addr)
{
uae_u8 *m;
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
m = fastmemory + addr;
return do_get_mem_long ((uae_u32 *)m);
uae_u8 *m;
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
m = fastmemory + addr;
return do_get_mem_long ((uae_u32 *)m);
}
static uae_u32 REGPARAM2 fastmem_wget (uaecptr addr)
{
uae_u8 *m;
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
m = fastmemory + addr;
return do_get_mem_word ((uae_u16 *)m);
uae_u8 *m;
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
m = fastmemory + addr;
return do_get_mem_word ((uae_u16 *)m);
}
static uae_u32 REGPARAM2 fastmem_bget (uaecptr addr)
{
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
return fastmemory[addr];
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
return fastmemory[addr];
}
static void REGPARAM2 fastmem_lput (uaecptr addr, uae_u32 l)
{
uae_u8 *m;
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
m = fastmemory + addr;
do_put_mem_long ((uae_u32 *)m, l);
uae_u8 *m;
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
m = fastmemory + addr;
do_put_mem_long ((uae_u32 *)m, l);
}
static void REGPARAM2 fastmem_wput (uaecptr addr, uae_u32 w)
{
uae_u8 *m;
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
m = fastmemory + addr;
do_put_mem_word ((uae_u16 *)m, w);
uae_u8 *m;
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
m = fastmemory + addr;
do_put_mem_word ((uae_u16 *)m, w);
}
static void REGPARAM2 fastmem_bput (uaecptr addr, uae_u32 b)
{
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
fastmemory[addr] = b;
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
fastmemory[addr] = b;
}
static int REGPARAM2 fastmem_check (uaecptr addr, uae_u32 size)
{
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
return (addr + size) <= allocated_fastmem;
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
return (addr + size) <= allocated_fastmem;
}
static uae_u8 *REGPARAM2 fastmem_xlate (uaecptr addr)
{
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
return fastmemory + addr;
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
return fastmemory + addr;
}
addrbank fastmem_bank = {
fastmem_lget, fastmem_wget, fastmem_bget,
fastmem_lput, fastmem_wput, fastmem_bput,
fastmem_lget, fastmem_wget, fastmem_bget,
fastmem_lput, fastmem_wput, fastmem_bput,
fastmem_xlate, fastmem_check, NULL, "Fast memory",
fastmem_lget, fastmem_wget, ABFLAG_RAM
fastmem_lget, fastmem_wget, ABFLAG_RAM
};
......@@ -509,7 +509,7 @@ static uae_u32 REGPARAM2 catweasel_lget (uaecptr addr)
special_mem |= SPECIAL_MEM_READ;
#endif
write_log ("catweasel_lget @%08X!\n",addr);
return 0;
return 0;
}
static uae_u32 REGPARAM2 catweasel_wget (uaecptr addr)
......@@ -518,7 +518,7 @@ static uae_u32 REGPARAM2 catweasel_wget (uaecptr addr)
special_mem |= SPECIAL_MEM_READ;
#endif
write_log ("catweasel_wget @%08X!\n",addr);
return 0;
return 0;
}
static uae_u32 REGPARAM2 catweasel_bget (uaecptr addr)
......@@ -526,9 +526,9 @@ static uae_u32 REGPARAM2 catweasel_bget (uaecptr addr)
#ifdef JIT
special_mem |= SPECIAL_MEM_READ;
#endif
addr -= catweasel_start & catweasel_mask;
addr &= catweasel_mask;
return catweasel_do_bget (addr);
addr -= catweasel_start & catweasel_mask;
addr &= catweasel_mask;
return catweasel_do_bget (addr);
}
static void REGPARAM2 catweasel_lput (uaecptr addr, uae_u32 l)
......@@ -552,33 +552,33 @@ static void REGPARAM2 catweasel_bput (uaecptr addr, uae_u32 b)
#ifdef JIT
special_mem |= SPECIAL_MEM_WRITE;
#endif
addr -= catweasel_start & catweasel_mask;
addr &= catweasel_mask;
catweasel_do_bput (addr, b);
addr -= catweasel_start & catweasel_mask;
addr &= catweasel_mask;
catweasel_do_bput (addr, b);
}
static int REGPARAM2 catweasel_check (uaecptr addr, uae_u32 size)
{
return 0;
return 0;
}
static uae_u8 *REGPARAM2 catweasel_xlate (uaecptr addr)
{
write_log ("catweasel_xlate @%08X size %08X\n", addr);
return 0;
return 0;
}
static addrbank catweasel_bank = {
catweasel_lget, catweasel_wget, catweasel_bget,
catweasel_lput, catweasel_wput, catweasel_bput,
catweasel_lget, catweasel_wget, catweasel_bget,
catweasel_lput, catweasel_wput, catweasel_bput,
catweasel_xlate, catweasel_check, NULL, "Catweasel",
dummy_lgeti, dummy_wgeti, ABFLAG_IO
dummy_lgeti, dummy_wgeti, ABFLAG_IO
};
static void expamem_map_catweasel (void)
{
catweasel_start = ((expamem_hi | (expamem_lo >> 4)) << 16);
map_banks (&catweasel_bank, catweasel_start >> 16, 1, 0);
catweasel_start = ((expamem_hi | (expamem_lo >> 4)) << 16);
map_banks (&catweasel_bank, catweasel_start >> 16, 1, 0);
write_log ("Catweasel MK%d: mapped @$%lx\n", cwc.type, catweasel_start);
}
......@@ -589,26 +589,26 @@ static void expamem_init_catweasel (void)
catweasel_mask = (cwc.type >= CATWEASEL_TYPE_MK3) ? 0xffff : 0x1ffff;
expamem_init_clear();
expamem_init_clear ();
expamem_write (0x00, (cwc.type >= CATWEASEL_TYPE_MK3 ? Z2_MEM_64KB : Z2_MEM_128KB) | zorroII);
expamem_write (0x04, productid);
expamem_write (0x04, productid);
expamem_write (0x08, no_shutup);
expamem_write (0x08, no_shutup);
expamem_write (0x10, vendorid >> 8);
expamem_write (0x14, vendorid & 0xff);
expamem_write (0x10, vendorid >> 8);
expamem_write (0x14, vendorid & 0xff);
expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
expamem_write (0x24, 0x00); /* ser.no. Byte 3 */
expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
expamem_write (0x24, 0x00); /* ser.no. Byte 3 */
expamem_write (0x28, 0x00); /* Rom-Offset hi */
expamem_write (0x2c, 0x00); /* ROM-Offset lo */
expamem_write (0x28, 0x00); /* Rom-Offset hi */
expamem_write (0x2c, 0x00); /* ROM-Offset lo */
expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
}
#endif
......@@ -632,26 +632,26 @@ uae_u8 *filesysory;
static uae_u32 REGPARAM2 filesys_lget (uaecptr addr)
{
uae_u8 *m;
uae_u8 *m;
#ifdef JIT
special_mem |= SPECIAL_MEM_READ;
#endif
addr -= filesys_start & 65535;
addr &= 65535;
m = filesysory + addr;
return do_get_mem_long ((uae_u32 *)m);
addr -= filesys_start & 65535;
addr &= 65535;
m = filesysory + addr;
return do_get_mem_long ((uae_u32 *)m);
}
static uae_u32 REGPARAM2 filesys_wget (uaecptr addr)
{
uae_u8 *m;
uae_u8 *m;
#ifdef JIT
special_mem |= SPECIAL_MEM_READ;
#endif
addr -= filesys_start & 65535;
addr &= 65535;
m = filesysory + addr;
return do_get_mem_word ((uae_u16 *)m);
addr -= filesys_start & 65535;
addr &= 65535;
m = filesysory + addr;
return do_get_mem_word ((uae_u16 *)m);
}
static uae_u32 REGPARAM2 filesys_bget (uaecptr addr)
......@@ -659,9 +659,9 @@ static uae_u32 REGPARAM2 filesys_bget (uaecptr addr)
#ifdef JIT
special_mem |= SPECIAL_MEM_READ;
#endif
addr -= filesys_start & 65535;
addr &= 65535;
return filesysory[addr];
addr -= filesys_start & 65535;
addr &= 65535;
return filesysory[addr];
}
static void REGPARAM2 filesys_lput (uaecptr addr, uae_u32 l)
......@@ -688,10 +688,10 @@ static void REGPARAM2 filesys_bput (uaecptr addr, uae_u32 b)
}
static addrbank filesys_bank = {
filesys_lget, filesys_wget, filesys_bget,
filesys_lput, filesys_wput, filesys_bput,
filesys_lget, filesys_wget, filesys_bget,
filesys_lput, filesys_wput, filesys_bput,
default_xlate, default_check, NULL, "Filesystem Autoconfig Area",
dummy_lgeti, dummy_wgeti, ABFLAG_IO | ABFLAG_SAFE
dummy_lgeti, dummy_wgeti, ABFLAG_IO | ABFLAG_SAFE
};
#endif /* FILESYS */
......@@ -706,60 +706,60 @@ static uae_u8 *z3fastmem, *z3fastmem2, *z3chipmem;
static uae_u32 REGPARAM2 z3fastmem_lget (uaecptr addr)
{
uae_u8 *m;
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
m = z3fastmem + addr;
return do_get_mem_long ((uae_u32 *)m);
uae_u8 *m;
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
m = z3fastmem + addr;
return do_get_mem_long ((uae_u32 *)m);
}
static uae_u32 REGPARAM2 z3fastmem_wget (uaecptr addr)
{
uae_u8 *m;
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
m = z3fastmem + addr;
return do_get_mem_word ((uae_u16 *)m);
uae_u8 *m;
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
m = z3fastmem + addr;
return do_get_mem_word ((uae_u16 *)m);
}
static uae_u32 REGPARAM2 z3fastmem_bget (uaecptr addr)
{
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
return z3fastmem[addr];
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
return z3fastmem[addr];
}
static void REGPARAM2 z3fastmem_lput (uaecptr addr, uae_u32 l)
{
uae_u8 *m;
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
m = z3fastmem + addr;
do_put_mem_long ((uae_u32 *)m, l);
uae_u8 *m;
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
m = z3fastmem + addr;
do_put_mem_long ((uae_u32 *)m, l);
}
static void REGPARAM2 z3fastmem_wput (uaecptr addr, uae_u32 w)
{
uae_u8 *m;
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
m = z3fastmem + addr;
do_put_mem_word ((uae_u16 *)m, w);
uae_u8 *m;
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
m = z3fastmem + addr;
do_put_mem_word ((uae_u16 *)m, w);
}
static void REGPARAM2 z3fastmem_bput (uaecptr addr, uae_u32 b)
{
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
z3fastmem[addr] = b;
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
z3fastmem[addr] = b;
}
static int REGPARAM2 z3fastmem_check (uaecptr addr, uae_u32 size)
{
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
return (addr + size) <= allocated_z3fastmem;
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
return (addr + size) <= allocated_z3fastmem;
}
static uae_u8 *REGPARAM2 z3fastmem_xlate (uaecptr addr)
{
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
return z3fastmem + addr;
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
return z3fastmem + addr;
}
static uae_u32 REGPARAM2 z3fastmem2_lget (uaecptr addr)
......@@ -878,10 +878,10 @@ static uae_u8 *REGPARAM2 z3chipmem_xlate (uaecptr addr)
addrbank z3fastmem_bank = {
z3fastmem_lget, z3fastmem_wget, z3fastmem_bget,
z3fastmem_lput, z3fastmem_wput, z3fastmem_bput,
z3fastmem_lget, z3fastmem_wget, z3fastmem_bget,
z3fastmem_lput, z3fastmem_wput, z3fastmem_bput,
z3fastmem_xlate, z3fastmem_check, NULL, "ZorroIII Fast RAM",
z3fastmem_lget, z3fastmem_wget, ABFLAG_RAM
z3fastmem_lget, z3fastmem_wget, ABFLAG_RAM
};
addrbank z3fastmem2_bank = {
z3fastmem2_lget, z3fastmem2_wget, z3fastmem2_bget,
......@@ -909,8 +909,8 @@ uae_u32 gfxmem_start;
static void expamem_map_fastcard (void)
{
fastmem_start = ((expamem_hi | (expamem_lo >> 4)) << 16);
map_banks (&fastmem_bank, fastmem_start >> 16, allocated_fastmem >> 16, 0);
fastmem_start = ((expamem_hi | (expamem_lo >> 4)) << 16);
map_banks (&fastmem_bank, fastmem_start >> 16, allocated_fastmem >> 16, 0);
write_log ("Fastcard: mapped @$%lx: %dMB fast memory\n", fastmem_start, allocated_fastmem >> 20);
}
......@@ -919,32 +919,32 @@ static void expamem_init_fastcard (void)
uae_u16 mid = (currprefs.cs_a2091 || currprefs.uae_hide) ? commodore : uae_id;
uae_u8 pid = (currprefs.cs_a2091 || currprefs.uae_hide) ? commodore_a2091_ram : 1;
expamem_init_clear();
if (allocated_fastmem == 0x100000)
expamem_init_clear ();
if (allocated_fastmem == 0x100000)
expamem_write (0x00, Z2_MEM_1MB + add_memory + zorroII);
else if (allocated_fastmem == 0x200000)
else if (allocated_fastmem == 0x200000)
expamem_write (0x00, Z2_MEM_2MB + add_memory + zorroII);
else if (allocated_fastmem == 0x400000)
else if (allocated_fastmem == 0x400000)
expamem_write (0x00, Z2_MEM_4MB + add_memory + zorroII);
else if (allocated_fastmem == 0x800000)
else if (allocated_fastmem == 0x800000)
expamem_write (0x00, Z2_MEM_8MB + add_memory + zorroII);
expamem_write (0x08, care_addr);
expamem_write (0x08, care_addr);
expamem_write (0x04, pid);
expamem_write (0x10, mid >> 8);
expamem_write (0x14, mid & 0xff);
expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
expamem_write (0x24, 0x01); /* ser.no. Byte 3 */
expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
expamem_write (0x24, 0x01); /* ser.no. Byte 3 */
expamem_write (0x28, 0x00); /* Rom-Offset hi */
expamem_write (0x2c, 0x00); /* ROM-Offset lo */
expamem_write (0x28, 0x00); /* Rom-Offset hi */
expamem_write (0x2c, 0x00); /* ROM-Offset lo */
expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
}
/* ********************************************************** */
......@@ -957,59 +957,59 @@ static void expamem_init_fastcard (void)
static void expamem_map_filesys (void)
{
uaecptr a;
uaecptr a;
filesys_start = ((expamem_hi | (expamem_lo >> 4)) << 16);
map_banks (&filesys_bank, filesys_start >> 16, 1, 0);
filesys_start = ((expamem_hi | (expamem_lo >> 4)) << 16);
map_banks (&filesys_bank, filesys_start >> 16, 1, 0);
write_log ("Filesystem: mapped memory @$%lx.\n", filesys_start);
/* 68k code needs to know this. */
a = here ();
/* 68k code needs to know this. */
a = here ();
org (rtarea_base + 0xFFFC);
dl (filesys_start + 0x2000);
org (a);
dl (filesys_start + 0x2000);
org (a);
}
static void expamem_init_filesys (void)
{
/* struct DiagArea - the size has to be large enough to store several device ROMTags */
uae_u8 diagarea[] = { 0x90, 0x00, /* da_Config, da_Flags */
/* struct DiagArea - the size has to be large enough to store several device ROMTags */
uae_u8 diagarea[] = { 0x90, 0x00, /* da_Config, da_Flags */
0x02, 0x00, /* da_Size */
0x01, 0x00, /* da_DiagPoint */
0x01, 0x06 /* da_BootPoint */
};
};
expamem_init_clear ();
expamem_write (0x00, Z2_MEM_64KB | rom_card | zorroII);
expamem_init_clear ();
expamem_write (0x00, Z2_MEM_64KB | rom_card | zorroII);
expamem_write (0x08, no_shutup);
expamem_write (0x08, no_shutup);
expamem_write (0x04, 2);
expamem_write (0x04, 2);
expamem_write (0x10, uae_id >> 8);
expamem_write (0x14, uae_id & 0xff);
expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
expamem_write (0x24, 0x01); /* ser.no. Byte 3 */
expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
expamem_write (0x24, 0x01); /* ser.no. Byte 3 */
/* er_InitDiagVec */
expamem_write (0x28, 0x10); /* Rom-Offset hi */
expamem_write (0x2c, 0x00); /* ROM-Offset lo */
/* er_InitDiagVec */
expamem_write (0x28, 0x10); /* Rom-Offset hi */
expamem_write (0x2c, 0x00); /* ROM-Offset lo */
expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
/* Build a DiagArea */
memcpy (expamem + 0x1000, diagarea, sizeof diagarea);
/* Build a DiagArea */
memcpy (expamem + 0x1000, diagarea, sizeof diagarea);
/* Call DiagEntry */
do_put_mem_word ((uae_u16 *)(expamem + 0x1100), 0x4EF9); /* JMP */
do_put_mem_long ((uae_u32 *)(expamem + 0x1102), ROM_filesys_diagentry);
/* Call DiagEntry */
do_put_mem_word ((uae_u16 *)(expamem + 0x1100), 0x4EF9); /* JMP */
do_put_mem_long ((uae_u32 *)(expamem + 0x1102), ROM_filesys_diagentry);
/* What comes next is a plain bootblock */
do_put_mem_word ((uae_u16 *)(expamem + 0x1106), 0x4EF9); /* JMP */
do_put_mem_long ((uae_u32 *)(expamem + 0x1108), EXPANSION_bootcode);
/* What comes next is a plain bootblock */
do_put_mem_word ((uae_u16 *)(expamem + 0x1106), 0x4EF9); /* JMP */
do_put_mem_long ((uae_u32 *)(expamem + 0x1108), EXPANSION_bootcode);
memcpy (filesysory, expamem, 0x3000);
memcpy (filesysory, expamem, 0x3000);
}
#endif
......@@ -1038,7 +1038,7 @@ static void expamem_map_z3fastmem_2 (addrbank *bank, uaecptr *startp, uae_u32 si
static void expamem_map_z3fastmem (void)
{
expamem_map_z3fastmem_2 (&z3fastmem_bank, &z3fastmem_start, currprefs.z3fastmem_size, allocated_z3fastmem, 0);
}
}
static void expamem_map_z3fastmem2 (void)
{
expamem_map_z3fastmem_2 (&z3fastmem2_bank, &z3fastmem2_start, currprefs.z3fastmem2_size, allocated_z3fastmem2, 0);
......@@ -1058,25 +1058,25 @@ static void expamem_init_z3fastmem_2 (addrbank *bank, uae_u32 start, uae_u32 siz
: allocated == 0x20000000 ? Z2_MEM_512MB
: Z2_MEM_1GB);
expamem_init_clear();
expamem_write (0x00, add_memory | zorroIII | code);
expamem_init_clear ();
expamem_write (0x00, add_memory | zorroIII | code);
expamem_write (0x08, care_addr | no_shutup | force_z3 | (allocated > 0x800000 ? ext_size : Z3_MEM_AUTO));
expamem_write (0x04, 3);
expamem_write (0x04, 3);
expamem_write (0x10, uae_id >> 8);
expamem_write (0x14, uae_id & 0xff);
expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
expamem_write (0x24, 0x01); /* ser.no. Byte 3 */
expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
expamem_write (0x24, 0x01); /* ser.no. Byte 3 */
expamem_write (0x28, 0x00); /* Rom-Offset hi */
expamem_write (0x2c, 0x00); /* ROM-Offset lo */
expamem_write (0x28, 0x00); /* Rom-Offset hi */
expamem_write (0x2c, 0x00); /* ROM-Offset lo */
expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
map_banks (bank, start >> 16, size >> 16, allocated);
......@@ -1123,24 +1123,24 @@ static void expamem_init_gfxcard (void)
: allocated_gfxmem == 0x800000 ? Z3_MEM_8MB
: 0);
expamem_init_clear();
expamem_init_clear ();
expamem_write (0x00, zorroIII | code);
expamem_write (0x08, care_addr | no_shutup | force_z3 | ext_size | subsize);
expamem_write (0x04, 96);
expamem_write (0x04, 96);
expamem_write (0x10, uae_id >> 8);
expamem_write (0x14, uae_id & 0xff);
expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
expamem_write (0x24, 0x01); /* ser.no. Byte 3 */
expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
expamem_write (0x24, 0x01); /* ser.no. Byte 3 */
expamem_write (0x28, 0x00); /* Rom-Offset hi */
expamem_write (0x2c, 0x00); /* ROM-Offset lo */
expamem_write (0x28, 0x00); /* Rom-Offset hi */
expamem_write (0x2c, 0x00); /* ROM-Offset lo */
expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
}
#endif
......@@ -1158,10 +1158,10 @@ void free_fastmemory (void)
static void allocate_expamem (void)
{
currprefs.fastmem_size = changed_prefs.fastmem_size;
currprefs.z3fastmem_size = changed_prefs.z3fastmem_size;
currprefs.fastmem_size = changed_prefs.fastmem_size;
currprefs.z3fastmem_size = changed_prefs.z3fastmem_size;
currprefs.z3fastmem2_size = changed_prefs.z3fastmem2_size;
currprefs.gfxmem_size = changed_prefs.gfxmem_size;
currprefs.gfxmem_size = changed_prefs.gfxmem_size;
currprefs.z3chipmem_size = changed_prefs.z3chipmem_size;
z3chipmem_start = currprefs.z3fastmem_start;
......@@ -1170,23 +1170,23 @@ static void allocate_expamem (void)
z3fastmem_start += currprefs.z3chipmem_size + 16 * 1024 * 1024;
z3fastmem2_start = currprefs.z3fastmem_start + currprefs.z3fastmem_size;
if (allocated_fastmem != currprefs.fastmem_size) {
if (allocated_fastmem != currprefs.fastmem_size) {
free_fastmemory ();
allocated_fastmem = currprefs.fastmem_size;
fastmem_mask = allocated_fastmem - 1;
if (allocated_fastmem) {
fastmemory = mapped_malloc (allocated_fastmem, "fast");
if (fastmemory == 0) {
if (fastmemory == 0) {
write_log ("Out of memory for fastmem card.\n");
allocated_fastmem = 0;
}
}
}
memory_hardreset ();
}
if (allocated_z3fastmem != currprefs.z3fastmem_size) {
}
if (allocated_z3fastmem != currprefs.z3fastmem_size) {
if (z3fastmem)
mapped_free (z3fastmem);
mapped_free (z3fastmem);
z3fastmem = 0;
allocated_z3fastmem = currprefs.z3fastmem_size;
......@@ -1194,13 +1194,13 @@ static void allocate_expamem (void)
if (allocated_z3fastmem) {
z3fastmem = mapped_malloc (allocated_z3fastmem, "z3");
if (z3fastmem == 0) {
if (z3fastmem == 0) {
write_log ("Out of memory for 32 bit fast memory.\n");
allocated_z3fastmem = 0;
}
}
}
memory_hardreset ();
}
}
if (allocated_z3fastmem2 != currprefs.z3fastmem2_size) {
if (z3fastmem2)
mapped_free (z3fastmem2);
......@@ -1237,9 +1237,9 @@ static void allocate_expamem (void)
}
#ifdef PICASSO96
if (allocated_gfxmem != currprefs.gfxmem_size) {
if (allocated_gfxmem != currprefs.gfxmem_size) {
if (gfxmemory)
mapped_free (gfxmemory);
mapped_free (gfxmemory);
gfxmemory = 0;
allocated_gfxmem = currprefs.gfxmem_size;
......@@ -1247,32 +1247,32 @@ static void allocate_expamem (void)
if (allocated_gfxmem) {
gfxmemory = mapped_malloc (allocated_gfxmem, "gfx");
if (gfxmemory == 0) {
if (gfxmemory == 0) {
write_log ("Out of memory for graphics card memory\n");
allocated_gfxmem = 0;
}
}
}
memory_hardreset ();
}
}
#endif
z3fastmem_bank.baseaddr = z3fastmem;
z3fastmem_bank.baseaddr = z3fastmem;
z3fastmem2_bank.baseaddr = z3fastmem2;
z3chipmem_bank.baseaddr = z3chipmem;
fastmem_bank.baseaddr = fastmemory;
fastmem_bank.baseaddr = fastmemory;
gfxmem_bank.baseaddr = gfxmemory;
#ifdef SAVESTATE
if (savestate_state == STATE_RESTORE) {
if (savestate_state == STATE_RESTORE) {
if (allocated_fastmem > 0) {
restore_ram (fast_filepos, fastmemory);
map_banks (&fastmem_bank, fastmem_start >> 16, currprefs.fastmem_size >> 16,
allocated_fastmem);
restore_ram (fast_filepos, fastmemory);
map_banks (&fastmem_bank, fastmem_start >> 16, currprefs.fastmem_size >> 16,
allocated_fastmem);
}
if (allocated_z3fastmem > 0) {
restore_ram (z3_filepos, z3fastmem);
map_banks (&z3fastmem_bank, z3fastmem_start >> 16, currprefs.z3fastmem_size >> 16,
allocated_z3fastmem);
restore_ram (z3_filepos, z3fastmem);
map_banks (&z3fastmem_bank, z3fastmem_start >> 16, currprefs.z3fastmem_size >> 16,
allocated_z3fastmem);
}
if (allocated_z3fastmem2 > 0) {
restore_ram (z3_filepos2, z3fastmem2);
......@@ -1286,12 +1286,12 @@ static void allocate_expamem (void)
}
#ifdef PICASSO96
if (allocated_gfxmem > 0 && gfxmem_start > 0) {
restore_ram (p96_filepos, gfxmemory);
restore_ram (p96_filepos, gfxmemory);
map_banks (&gfxmem_bank, gfxmem_start >> 16, currprefs.gfxmem_size >> 16,
allocated_gfxmem);
allocated_gfxmem);
}
#endif
}
}
#endif /* SAVESTATE */
}
......@@ -1387,7 +1387,7 @@ static void expamem_init_a4091 (void)
#endif
}
void p96memstart(void)
void p96memstart (void)
{
/* make sure there is always empty space between Z3 and P96 RAM */
p96ram_start = currprefs.z3fastmem_start + ((currprefs.z3fastmem_size + currprefs.z3fastmem2_size + currprefs.z3chipmem_size + 0xffffff) & ~0xffffff);
......@@ -1398,9 +1398,9 @@ void p96memstart(void)
void expamem_reset (void)
{
int do_mount = 1;
int do_mount = 1;
ecard = 0;
ecard = 0;
cardno = 0;
if (currprefs.uae_hide)
......@@ -1408,25 +1408,25 @@ void expamem_reset (void)
else
uae_id = hackers_id;
allocate_expamem ();
allocate_expamem ();
/* check if Kickstart version is below 1.3 */
if (! ersatzkickfile && kickstart_version
&& (/* Kickstart 1.0 & 1.1! */
kickstart_version == 0xFFFF
/* Kickstart < 1.3 */
|| kickstart_version < 34))
{
/* check if Kickstart version is below 1.3 */
if (! ersatzkickfile && kickstart_version
&& (/* Kickstart 1.0 & 1.1! */
kickstart_version == 0xFFFF
/* Kickstart < 1.3 */
|| kickstart_version < 34))
{
/* warn user */
write_log ("Kickstart version is below 1.3! Disabling autoconfig devices.\n");
do_mount = 0;
}
if (need_uae_boot_rom() == 0)
}
if (need_uae_boot_rom () == 0)
do_mount = 0;
if (fastmemory != NULL) {
if (fastmemory != NULL) {
card_init[cardno] = expamem_init_fastcard;
card_map[cardno++] = expamem_map_fastcard;
}
}
if (z3fastmem != NULL) {
z3num = 0;
......@@ -1480,59 +1480,59 @@ void expamem_reset (void)
}
#endif
#ifdef PICASSO96
if (gfxmemory != NULL) {
if (gfxmemory != NULL) {
card_init[cardno] = expamem_init_gfxcard;
card_map[cardno++] = expamem_map_gfxcard;
}
}
#endif
#ifdef FILESYS
if (do_mount && ! ersatzkickfile) {
if (do_mount && ! ersatzkickfile) {
card_init[cardno] = expamem_init_filesys;
card_map[cardno++] = expamem_map_filesys;
}
}
#endif
#ifdef CATWEASEL
if (currprefs.catweasel && catweasel_init ()) {
card_init[cardno] = expamem_init_catweasel;
card_map[cardno++] = expamem_map_catweasel;
}
}
#endif
if (cardno > 0 && cardno < MAX_EXPANSION_BOARDS) {
card_init[cardno] = expamem_init_last;
card_map[cardno++] = expamem_map_clear;
}
}
if (cardno == 0)
expamem_init_clear_zero ();
else
(*card_init[0]) ();
(*card_init[0]) ();
}
void expansion_init (void)
{
allocated_fastmem = 0;
fastmem_mask = fastmem_start = 0;
fastmemory = 0;
allocated_fastmem = 0;
fastmem_mask = fastmem_start = 0;
fastmemory = 0;
#ifdef PICASSO96
allocated_gfxmem = 0;
gfxmem_mask = gfxmem_start = 0;
gfxmemory = 0;
gfxmem_mask = gfxmem_start = 0;
gfxmemory = 0;
#endif
#ifdef CATWEASEL
catweasel_mask = catweasel_start = 0;
catweasel_mask = catweasel_start = 0;
#endif
#ifdef FILESYS
filesys_start = 0;
filesysory = 0;
filesys_start = 0;
filesysory = 0;
#endif
allocated_z3fastmem = 0;
z3fastmem_mask = z3fastmem_start = 0;
z3fastmem = 0;
z3fastmem_mask = z3fastmem_start = 0;
z3fastmem = 0;
allocated_z3fastmem2 = 0;
z3fastmem2_mask = z3fastmem2_start = 0;
z3fastmem2 = 0;
......@@ -1540,25 +1540,25 @@ void expansion_init (void)
z3chipmem_mask = z3chipmem_start = 0;
z3chipmem = 0;
allocate_expamem ();
allocate_expamem ();
#ifdef FILESYS
filesysory = mapped_malloc (0x10000, "filesys");
if (!filesysory) {
if (!filesysory) {
write_log ("virtual memory exhausted (filesysory)!\n");
exit (0);
}
}
filesys_bank.baseaddr = filesysory;
#endif
}
void expansion_cleanup (void)
{
if (fastmemory)
if (fastmemory)
mapped_free (fastmemory);
fastmemory = 0;
if (z3fastmem)
if (z3fastmem)
mapped_free (z3fastmem);
z3fastmem = 0;
if (z3fastmem2)
......@@ -1569,23 +1569,23 @@ void expansion_cleanup (void)
z3chipmem = 0;
#ifdef PICASSO96
if (gfxmemory)
if (gfxmemory)
mapped_free (gfxmemory);
gfxmemory = 0;
#endif
#ifdef FILESYS
if (filesysory)
if (filesysory)
mapped_free (filesysory);
filesysory = 0;
filesysory = 0;
#endif
#ifdef CATWEASEL
catweasel_free ();
catweasel_free ();
#endif
}
void expansion_clear(void)
void expansion_clear (void)
{
if (fastmemory)
memset (fastmemory, 0, allocated_fastmem);
......@@ -1605,8 +1605,8 @@ void expansion_clear(void)
uae_u8 *save_fram (int *len)
{
*len = allocated_fastmem;
return fastmemory;
*len = allocated_fastmem;
return fastmemory;
}
uae_u8 *save_zram (int *len, int num)
......@@ -1621,14 +1621,14 @@ uae_u8 *save_zram (int *len, int num)
uae_u8 *save_pram (int *len)
{
*len = allocated_gfxmem;
return gfxmemory;
*len = allocated_gfxmem;
return gfxmemory;
}
void restore_fram (int len, size_t filepos)
{
fast_filepos = filepos;
changed_prefs.fastmem_size = len;
fast_filepos = filepos;
changed_prefs.fastmem_size = len;
}
void restore_zram (int len, size_t filepos, int num)
......@@ -1640,40 +1640,40 @@ void restore_zram (int len, size_t filepos, int num)
z3_filepos2 = filepos;
changed_prefs.z3fastmem2_size = len;
} else {
z3_filepos = filepos;
changed_prefs.z3fastmem_size = len;
z3_filepos = filepos;
changed_prefs.z3fastmem_size = len;
}
}
void restore_pram (int len, size_t filepos)
{
p96_filepos = filepos;
changed_prefs.gfxmem_size = len;
p96_filepos = filepos;
changed_prefs.gfxmem_size = len;
}
uae_u8 *save_expansion (int *len, uae_u8 *dstptr)
{
static uae_u8 t[20];
uae_u8 *dst = t, *dstbak = t;
if (dstptr)
static uae_u8 t[20];
uae_u8 *dst = t, *dstbak = t;
if (dstptr)
dst = dstbak = dstptr;
save_u32 (fastmem_start);
save_u32 (z3fastmem_start);
save_u32 (gfxmem_start);
save_u32 (fastmem_start);
save_u32 (z3fastmem_start);
save_u32 (gfxmem_start);
save_u32 (rtarea_base);
*len = 4 + 4 + 4 + 4;
return dstbak;
*len = 4 + 4 + 4 + 4;
return dstbak;
}
uae_u8 *restore_expansion (uae_u8 *src)
{
fastmem_start = restore_u32 ();
z3fastmem_start = restore_u32 ();
gfxmem_start = restore_u32 ();
fastmem_start = restore_u32 ();
z3fastmem_start = restore_u32 ();
gfxmem_start = restore_u32 ();
rtarea_base = restore_u32 ();
if (rtarea_base != 0 && rtarea_base != RTAREA_DEFAULT && rtarea_base != RTAREA_BACKUP)
rtarea_base = 0;
return src;
return src;
}
#endif /* SAVESTATE */
......@@ -250,9 +250,9 @@ FSIN_chip_done
move.w #$FF80,d0
bsr.w getrtbase
jsr (a0) ; d1 = size, a1 = start address
beq.s FSIN_fchip_done
move.l a1,a0
move.l d1,d0
beq.s FSIN_fchip_done
move.l d4,d1
moveq #-5,d2
lea fchipname(pc),a1
......
/*
* UAE - The Un*x Amiga Emulator
*
* Unix file system handler for AmigaDOS
*
* Copyright 1996 Ed Hanway
* Copyright 1996, 1997 Bernd Schmidt
*
* Version 0.4: 970308
*
* Based on example code (c) 1988 The Software Distillery
* and published in Transactor for the Amiga, Volume 2, Issues 2-5.
* (May - August 1989)
*
* Known limitations:
* Does not support several (useless) 2.0+ packet types.
* May not return the correct error code in some cases.
* Does not check for sane values passed by AmigaDOS. May crash the emulation
* if passed garbage values.
* Could do tighter checks on malloc return values.
* Will probably fail spectacularly in some cases if the filesystem is
* modified at the same time by another process while UAE is running.
*/
/*
* UAE - The Un*x Amiga Emulator
*
* Unix file system handler for AmigaDOS
*
* Copyright 1996 Ed Hanway
* Copyright 1996, 1997 Bernd Schmidt
*
* Version 0.4: 970308
*
* Based on example code (c) 1988 The Software Distillery
* and published in Transactor for the Amiga, Volume 2, Issues 2-5.
* (May - August 1989)
*
* Known limitations:
* Does not support several (useless) 2.0+ packet types.
* May not return the correct error code in some cases.
* Does not check for sane values passed by AmigaDOS. May crash the emulation
* if passed garbage values.
* Could do tighter checks on malloc return values.
* Will probably fail spectacularly in some cases if the filesystem is
* modified at the same time by another process while UAE is running.
*/
#include "sysconfig.h"
#include "sysdeps.h"
......@@ -69,8 +69,8 @@
#define TRACING_ENABLED 0
#if TRACING_ENABLED
#define TRACE(x) do { write_log x; } while(0)
#define DUMPLOCK(u,x) dumplock(u,x)
#define TRACE(x) do { write_log x; } while(0)
#define DUMPLOCK(u,x) dumplock(u,x)
#else
#define TRACE(x)
#define DUMPLOCK(u,x)
......@@ -87,10 +87,10 @@ static uae_u32 dlg (uae_u32 a)
static void aino_test (a_inode *aino)
{
#ifdef AINO_DEBUG
a_inode *aino2 = aino, *aino3;
for (;;) {
a_inode *aino2 = aino, *aino3;
for (;;) {
if (!aino || !aino->next)
return;
return;
if ((aino->checksum1 ^ aino->checksum2) != 0xaaaa5555) {
write_log ("PANIC: corrupted or freed but used aino detected!", aino);
}
......@@ -98,10 +98,10 @@ static void aino_test (a_inode *aino)
aino = aino->next;
if (aino->prev != aino3) {
write_log ("PANIC: corrupted aino linking!\n");
break;
break;
}
if (aino == aino2) break;
}
}
#endif
}
......@@ -204,10 +204,10 @@ int is_hardfile (int unit_no)
return FILESYS_VIRTUAL;
if (mountinfo.ui[unit_no].hf.secspertrack == 0) {
if (mountinfo.ui[unit_no].hf.flags & 1)
return FILESYS_HARDDRIVE;
return FILESYS_HARDDRIVE;
return FILESYS_HARDFILE_RDB;
}
return FILESYS_HARDFILE;
}
return FILESYS_HARDFILE;
}
static void close_filesys_unit (UnitInfo *uip)
......@@ -237,7 +237,7 @@ static void close_filesys_unit (UnitInfo *uip)
uip->open = 0;
}
static UnitInfo *getuip(struct uae_prefs *p, int index)
static UnitInfo *getuip (struct uae_prefs *p, int index)
{
if (index < 0)
return NULL;
......@@ -648,7 +648,7 @@ static void initialize_mountinfo (void)
uci->devname, uci->sectors, uci->surfaces, uci->reserved,
uci->bootpri, uci->filesys);
#endif
} else if (currprefs.cs_a2091) {
} else if (currprefs.cs_a2091) {
#ifdef A2091
a2091_add_scsi_unit (uci->controller - HD_CONTROLLER_SCSI0, uci->rootdir, uci->blocksize, uci->readonly,
uci->devname, uci->sectors, uci->surfaces, uci->reserved,
......@@ -705,7 +705,7 @@ struct hardfiledata *get_hardfile_data (int nr)
/* field offsets in DosPacket */
#define dp_Type 8
#define dp_Res1 12
#define dp_Res1 12
#define dp_Res2 16
#define dp_Arg1 20
#define dp_Arg2 24
......@@ -732,10 +732,10 @@ struct hardfiledata *get_hardfile_data (int nr)
#define MAXFILESIZE32 (0x7fffffff)
/* Passed as type to Lock() */
#define SHARED_LOCK -2 /* File is readable by others */
#define ACCESS_READ -2 /* Synonym */
#define EXCLUSIVE_LOCK -1 /* No other access allowed */
#define ACCESS_WRITE -1 /* Synonym */
#define SHARED_LOCK -2 /* File is readable by others */
#define ACCESS_READ -2 /* Synonym */
#define EXCLUSIVE_LOCK -1 /* No other access allowed */
#define ACCESS_WRITE -1 /* Synonym */
/* packet types */
#define ACTION_CURRENT_VOLUME 7
......@@ -1668,7 +1668,7 @@ TCHAR *build_aname (const TCHAR *d, const TCHAR *n)
_tcscpy (p, d);
_tcscat (p, "/");
_tcscat (p, n);
return p;
return p;
}
/* This gets called to translate an Amiga name that some program used to
......@@ -1740,7 +1740,7 @@ oh_dear:
#if 0
/* Delete this code once we know everything works. */
if (access (p, R_OK) >= 0 || errno != ENOENT) {
write_log ("Filesystem in trouble... please report.\n");
write_log ("Filesystem in trouble... please report.\n");
xfree (p);
goto oh_dear;
}
......@@ -1779,7 +1779,7 @@ static int fill_file_attrs (Unit *u, a_inode *base, a_inode *c)
*/
static TCHAR *get_aname (Unit *unit, a_inode *base, TCHAR *rel)
{
return my_strdup (rel);
return my_strdup (rel);
}
static void init_child_aino_tree (Unit *unit, a_inode *base, a_inode *aino)
......@@ -2428,11 +2428,11 @@ static uaecptr make_lock (Unit *unit, uae_u32 uniq, long mode)
#define NOTIFY_CODE 0x1234
#ifndef TARGET_AMIGAOS
# define NRF_SEND_MESSAGE 1
# define NRF_SEND_SIGNAL 2
# define NRF_WAIT_REPLY 8
# define NRF_NOTIFY_INITIAL 16
# define NRF_MAGIC (1 << 31)
#define NRF_SEND_MESSAGE 1
#define NRF_SEND_SIGNAL 2
#define NRF_WAIT_REPLY 8
#define NRF_NOTIFY_INITIAL 16
#define NRF_MAGIC (1 << 31)
#endif
static void notify_send (Unit *unit, Notify *n)
......@@ -2457,7 +2457,7 @@ static void notify_check (Unit *unit, a_inode *a)
int hash = notifyhash (a->aname);
for (n = unit->notifyhash[hash]; n; n = n->next) {
uaecptr nr = n->notifyrequest;
if (same_aname(n->partname, a->aname)) {
if (same_aname (n->partname, a->aname)) {
int err;
a_inode *a2 = find_aino (unit, 0, n->fullname, &err);
if (err == 0 && a == a2)
......@@ -2468,7 +2468,7 @@ static void notify_check (Unit *unit, a_inode *a)
hash = notifyhash (a->parent->aname);
for (n = unit->notifyhash[hash]; n; n = n->next) {
uaecptr nr = n->notifyrequest;
if (same_aname(n->partname, a->parent->aname)) {
if (same_aname (n->partname, a->parent->aname)) {
int err;
a_inode *a2 = find_aino (unit, 0, n->fullname, &err);
if (err == 0 && a->parent == a2)
......@@ -2787,7 +2787,7 @@ static time_t
}
# endif
# endif
return t;
return t;
}
#endif
......@@ -3345,22 +3345,22 @@ static uae_u32 REGPARAM2 exall_helper (TrapContext *context)
static void action_examine_object (Unit *unit, dpacket packet)
{
uaecptr lock = GET_PCK_ARG1 (packet) << 2;
uaecptr info = GET_PCK_ARG2 (packet) << 2;
a_inode *aino = 0;
uaecptr lock = GET_PCK_ARG1 (packet) << 2;
uaecptr info = GET_PCK_ARG2 (packet) << 2;
a_inode *aino = 0;
TRACE(("ACTION_EXAMINE_OBJECT(0x%lx,0x%lx)\n", lock, info));
DUMPLOCK(unit, lock);
DUMPLOCK(unit, lock);
if (lock != 0)
if (lock != 0)
aino = lookup_aino (unit, get_long (lock + 4));
if (aino == 0)
if (aino == 0)
aino = &unit->rootnode;
get_fileinfo (unit, packet, info, aino);
if (aino->dir) {
get_fileinfo (unit, packet, info, aino);
if (aino->dir) {
put_long (info, 0xFFFFFFFF);
} else
} else
put_long (info, 0);
}
......@@ -3374,24 +3374,24 @@ static void action_examine_object (Unit *unit, dpacket packet)
static void populate_directory (Unit *unit, a_inode *base)
{
struct fs_dirhandle *d;
a_inode *aino;
a_inode *aino;
d = fs_opendir (unit, base->nname);
if (!d)
if (!d)
return;
for (aino = base->child; aino; aino = aino->sibling) {
base->locked_children++;
unit->total_locked_ainos++;
}
for (aino = base->child; aino; aino = aino->sibling) {
base->locked_children++;
unit->total_locked_ainos++;
}
TRACE(("Populating directory, child %p, locked_children %d\n",
base->child, base->locked_children));
for (;;) {
base->child, base->locked_children));
for (;;) {
TCHAR fn[MAX_DPATH];
struct dirent *ok;
uae_u32 err;
/* Find next file that belongs to the Amiga fs (skipping things
like "..", "." etc. */
like "..", "." etc. */
do {
/* if (d->isarch)
ok = zfile_readdir_archive(d->zd, fn);
......@@ -3399,11 +3399,11 @@ static void populate_directory (Unit *unit, a_inode *base)
ok = readdir (d->od);
} while (ok && !d->isarch && fsdb_name_invalid (ok->d_name));
if (!ok)
break;
break;
/* This calls init_child_aino, which will notice that the parent is
being ExNext()ed, and it will increment the locked counts. */
being ExNext()ed, and it will increment the locked counts. */
aino = lookup_child_aino_for_exnext (unit, base, ok->d_name, &err);
}
}
fs_closedir (d);
}
......@@ -3411,11 +3411,11 @@ static void do_examine (Unit *unit, dpacket packet, ExamineKey *ek, uaecptr info
{
for (;;) {
TCHAR *name;
if (ek->curr_file == 0)
if (ek->curr_file == 0)
break;
name = ek->curr_file->nname;
get_fileinfo (unit, packet, info, ek->curr_file);
ek->curr_file = ek->curr_file->sibling;
get_fileinfo (unit, packet, info, ek->curr_file);
ek->curr_file = ek->curr_file->sibling;
if (!(unit->volflags & MYVOLUMEINFO_ARCHIVE) && !fsdb_exists(name)) {
TRACE (("%s orphaned", name));
continue;
......@@ -3425,53 +3425,53 @@ static void do_examine (Unit *unit, dpacket packet, ExamineKey *ek, uaecptr info
return;
}
TRACE(("no more entries\n"));
free_exkey (unit, ek);
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_NO_MORE_ENTRIES);
free_exkey (unit, ek);
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_NO_MORE_ENTRIES);
}
static void action_examine_next (Unit *unit, dpacket packet)
{
uaecptr lock = GET_PCK_ARG1 (packet) << 2;
uaecptr info = GET_PCK_ARG2 (packet) << 2;
a_inode *aino = 0;
ExamineKey *ek;
uae_u32 uniq;
uaecptr lock = GET_PCK_ARG1 (packet) << 2;
uaecptr info = GET_PCK_ARG2 (packet) << 2;
a_inode *aino = 0;
ExamineKey *ek;
uae_u32 uniq;
TRACE(("ACTION_EXAMINE_NEXT(0x%lx,0x%lx)\n", lock, info));
gui_flicker_led (LED_HD, unit->unit, 1);
DUMPLOCK(unit, lock);
DUMPLOCK(unit, lock);
if (lock != 0)
aino = lookup_aino (unit, get_long (lock + 4));
if (aino == 0)
aino = &unit->rootnode;
if (lock != 0)
aino = lookup_aino (unit, get_long (lock + 4));
if (aino == 0)
aino = &unit->rootnode;
for(;;) {
uniq = get_long (info);
if (uniq == 0) {
uniq = get_long (info);
if (uniq == 0) {
write_log ("ExNext called for a file! (Houston?)\n");
goto no_more_entries;
} else if (uniq == 0xFFFFFFFE)
} else if (uniq == 0xFFFFFFFE)
goto no_more_entries;
else if (uniq == 0xFFFFFFFF) {
else if (uniq == 0xFFFFFFFF) {
TRACE(("Creating new ExKey\n"));
ek = new_exkey (unit, aino);
if (ek) {
if (aino->exnext_count++ == 0)
if (aino->exnext_count++ == 0)
populate_directory (unit, aino);
ek->curr_file = aino->child;
TRACE(("Initial curr_file: %p %s\n", ek->curr_file,
ek->curr_file ? ek->curr_file->aname : "NULL"));
}
} else {
} else {
TRACE(("Looking up ExKey\n"));
ek = lookup_exkey (unit, get_long (info));
}
if (ek == 0) {
}
if (ek == 0) {
write_log ("Couldn't find a matching ExKey. Prepare for trouble.\n");
goto no_more_entries;
}
put_long (info, ek->uniq);
}
put_long (info, ek->uniq);
if (!ek->curr_file || ek->curr_file->mountcount == unit->mountcount)
break;
ek->curr_file = ek->curr_file->sibling;
......@@ -3641,8 +3641,8 @@ static void
TRACE ((" mode is %d\n", mode));
openmode = (((mode & A_FIBF_READ) ? "wb"
: (mode & A_FIBF_WRITE) ? "rb"
: "r+b"));
: (mode & A_FIBF_WRITE) ? "rb"
: "r+b"));
/* the files on CD really can have the write-bit set. */
if (unit->ui.readonly || unit->ui.locked)
......@@ -3661,7 +3661,7 @@ static void
put_long (fh + 36, k->uniq);
/* I don't think I need to play with shlock count here, because I'm
opening from an existing lock ??? */
opening from an existing lock ??? */
de_recycle_aino (unit, aino);
free_lock (unit, lock); /* lock must be unlocked */
......@@ -3701,7 +3701,7 @@ static void
static void updatedirtime (a_inode *a1, int now)
{
#if !defined TARGET_AMIGAOS || !defined WORDS_BIGENDIAN
struct stat statbuf;
struct stat statbuf;
struct utimbuf ut;
long days, mins, ticks;
......@@ -4219,7 +4219,7 @@ static void
uaecptr info = GET_PCK_ARG2 (packet) << 2;
TRACE(("ACTION_EXAMINE_FH(0x%lx,0x%lx)\n",
GET_PCK_ARG1 (packet), GET_PCK_ARG2 (packet) ));
GET_PCK_ARG1 (packet), GET_PCK_ARG2 (packet) ));
k = lookup_key (unit, GET_PCK_ARG1 (packet));
if (k != 0)
......@@ -4315,7 +4315,7 @@ static void relock_re (Unit *unit, a_inode *a1, a_inode *a2, int failed)
for (k1 = unit->keys; k1; k1 = knext) {
knext = k1->next;
if (k1->aino == a1 && k1->fd) {
char *mode = (k1->dosmode & A_FIBF_READ) == 0 ? "wb" : (k1->dosmode & A_FIBF_WRITE) == 0 ? "rb" : "r+b";
char *mode = (k1->dosmode & A_FIBF_READ) == 0 ? "wb" : (k1->dosmode & A_FIBF_WRITE) == 0 ? "rb" : "r+b";
if (failed) {
/* rename still failed, restore fd */
k1->fd = fs_open (unit, a1->nname, mode);
......@@ -4419,10 +4419,10 @@ static void
}
#if defined TARGET_AMIGAOS && defined WORDS_BIGENDIAN
if (err == 0 && SetFileDate (a->nname, (struct DateStamp *) date) == DOSFALSE)
err = IoErr ();
if (err == 0 && SetFileDate (a->nname, (struct DateStamp *) date) == DOSFALSE)
err = IoErr ();
#else
ut.actime = ut.modtime = put_time(get_long (date), get_long (date + 4), get_long (date + 8));
ut.actime = ut.modtime = put_time (get_long (date), get_long (date + 4),get_long (date + 8));
a = find_aino (unit, lock, bstr (unit, name), &err);
if (err == 0 && utime (a->nname, &ut) == -1)
err = dos_errno ();
......@@ -4557,7 +4557,7 @@ static void
{
uaecptr name = GET_PCK_ARG1 (packet) << 2;
TRACE(("ACTION_RENAME_DISK(\"%s\")\n", bstr (unit, name)));
TRACE(("ACTION_RENAME_DISK(\"%s\")\n", bstr (unit, name)));
if (unit->ui.readonly || unit->ui.locked) {
PUT_PCK_RES1 (packet, DOS_FALSE);
......@@ -5160,9 +5160,9 @@ static void filesys_reset2 (void)
{
Unit *u, *u1;
/* We get called once from customreset at the beginning of the program
* before filesys_start_threads has been called. Survive that. */
if (savestate_state == STATE_RESTORE)
/* We get called once from customreset at the beginning of the program
* before filesys_start_threads has been called. Survive that. */
if (savestate_state == STATE_RESTORE)
return;
filesys_free_handles ();
......@@ -5480,12 +5480,12 @@ static void dump_partinfo (const char *name, int num, uaecptr pp, int partblock)
static int rdb_mount (UnitInfo *uip, int unit_no, unsigned int partnum, uaecptr parmpacket)
{
unsigned int lastblock = 63, blocksize, readblocksize;
unsigned int lastblock = 63, blocksize, readblocksize;
int badblock, driveinitblock;
uae_u8 bufrdb[FILESYS_MAX_BLOCKSIZE], *buf = 0;
uae_u8 *fsmem = 0;
unsigned int rdblock, partblock, fileblock, i;
int lsegblock;
unsigned int rdblock, partblock, fileblock, i;
int lsegblock;
uae_u32 flags;
struct hardfiledata *hfd = &uip->hf;
uae_u32 dostype;
......
......@@ -22,9 +22,9 @@
db(0x22); db(0x4e); db(0x20); db(0x08); db(0x30); db(0x7c); db(0xff); db(0xb8);
db(0x4e); db(0xae); db(0xfe); db(0x5c); db(0x61); db(0x00); db(0x11); db(0xfe);
db(0x61); db(0x00); db(0x15); db(0xb0); db(0x4c); db(0xdf); db(0x7e); db(0xff);
db(0x4e); db(0x75); db(0x4e); db(0xae); db(0x08); db(0x00); db(0x00); db(0x02);
db(0x4e); db(0x75); db(0x00); db(0x00); db(0x08); db(0x00); db(0x00); db(0x02);
db(0x67); db(0x06); db(0x4e); db(0xb9); db(0x00); db(0xf0); db(0x00); db(0x00);
db(0x4e); db(0xf9); db(0x00); db(0xf0); db(0x00); db(0x00); db(0x28); db(0x40);
db(0x4e); db(0xf9); db(0x00); db(0xf0); db(0x00); db(0x00); db(0x00); db(0x00);
db(0x48); db(0xe7); db(0xff); db(0xfe); db(0x2c); db(0x78); db(0x00); db(0x04);
db(0x30); db(0x3c); db(0xff); db(0xfc); db(0x61); db(0x00); db(0x0b); db(0xaa);
db(0x2a); db(0x50); db(0x43); db(0xfa); db(0x16); db(0xf3); db(0x70); db(0x24);
......@@ -51,7 +51,7 @@
db(0x00); db(0x20); db(0x00); db(0x00); db(0x90); db(0x88); db(0x65); db(0x08);
db(0x67); db(0x06); db(0x93); db(0xc9); db(0x4e); db(0xae); db(0xfd); db(0x96);
db(0x30); db(0x3c); db(0xff); db(0x80); db(0x61); db(0x00); db(0x0a); db(0xea);
db(0x4e); db(0x90); db(0x67); db(0x10); db(0x20); db(0x49); db(0x20); db(0x01);
db(0x4e); db(0x90); db(0x20); db(0x49); db(0x20); db(0x01); db(0x67); db(0x0c);
db(0x22); db(0x04); db(0x74); db(0xfb); db(0x43); db(0xfa); db(0x16); db(0x4f);
db(0x4e); db(0xae); db(0xfd); db(0x96); db(0x41); db(0xfa); db(0x15); db(0xc6);
db(0x43); db(0xfa); db(0x00); db(0x54); db(0x70); db(0x0a); db(0x61); db(0x00);
......
......@@ -1358,18 +1358,14 @@ void handle_events (void)
keycode = rEvent.key.keysym.sym;
DEBUG_LOG ("Event: key %d %s\n", keycode, state ? "down" : "up");
write_log ("Event: key %d %s -- ", keycode, state ? "down" : "up");
if ((ievent = match_hotkey_sequence (keycode, state))) {
write_log ("HOT %d\n", ievent);
DEBUG_LOG ("Hotkey event: %d\n", ievent);
handle_hotkey_event (ievent, state);
} else {
if (currprefs.map_raw_keys) {
write_log ("RAW\n");
inputdevice_translatekeycode (0, keycode, state);
} else {
write_log ("SYM\n");
inputdevice_do_keyboard (keysym2amiga (keycode), state);
}
}
......
......@@ -288,7 +288,7 @@ void alloc_colors64k (int rw, int gw, int bw, int rs, int gs, int bs, int aw, in
redc[2 * 256 + i] = xredcolors[255];
grec[2 * 256 + i] = xgreencolors[255];
bluc[2 * 256 + i] = xbluecolors[255];
}
}
#ifdef GFXFILTER
if (usedfilter && usedfilter->yuv) {
/* create internal 5:6:5 color tables */
......
......@@ -237,7 +237,7 @@ void floppyfileentry_set_currentdir (FloppyFileEntry *ffe, const gchar *pathname
int len = strlen (pathname);
if (ffe_currentdir)
g_free (ffe_currentdir);
g_free (ffe_currentdir);
/*
* Make sure it has a trailing path separator so the file dialog
......
......@@ -25,6 +25,7 @@
#define DEVICE_TYPE_ANY 1
#define DEVICE_TYPE_SCSI 2
#define DEVICE_TYPE_ALLOWEMU 0x100
#define DF_SCSI 0
#define DF_IOCTL 1
......
......@@ -29,7 +29,7 @@ struct strlist {
#define MAX_INPUT_SETTINGS 4
#define GAMEPORT_INPUT_SETTINGS 3 // last slot is for gameport panel mappings
#define MAX_INPUT_SUB_EVENT 4
#define SPARE_SUB_EVENT 4
#define SPARE_SUB_EVENT 4
// this better be here than in sound.h -mustafa.
#define FILTER_SOUND_OFF 0
......@@ -42,11 +42,11 @@ struct strlist {
struct uae_input_device {
TCHAR *name;
TCHAR *configname;
uae_s16 eventid[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT + 1];
TCHAR *custom[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT + 1];
uae_u16 flags[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT + 1];
uae_s8 port[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT + 1];
uae_s16 extra[MAX_INPUT_DEVICE_EVENTS];
uae_s16 eventid[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT + 1];
TCHAR *custom[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT + 1];
uae_u16 flags[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT + 1];
uae_s8 port[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT + 1];
uae_s16 extra[MAX_INPUT_DEVICE_EVENTS];
uae_s8 enabled;
};
......@@ -302,6 +302,7 @@ struct uae_prefs {
TCHAR amaxromfile[MAX_DPATH];
TCHAR a2065name[MAX_DPATH];
TCHAR cdimagefile[MAX_DPATH];
bool cdimagefileuse;
TCHAR quitstatefile[MAX_DPATH];
#ifndef WIN32
char scsi_device[256];
......@@ -360,7 +361,7 @@ struct uae_prefs {
int hide_cursor; /* Whether to hide host WM cursor or not */
/* Target specific options */
/* Target specific options */
#ifdef USE_X11_GFX
int x11_use_low_bandwidth;
int x11_use_mitshm;
......@@ -460,8 +461,8 @@ extern int config_changed;
extern void config_check_vsync (void);
/* Contains the filename of .uaerc */
extern TCHAR optionsfile[];
extern void save_options (struct zfile *, struct uae_prefs *, int);
extern TCHAR optionsfile[];
extern void save_options (struct zfile *, struct uae_prefs *, int);
/*
extern void cfgfile_write (struct zfile *, const TCHAR *option, const TCHAR *format,...);
extern void cfgfile_dwrite (struct zfile *, const TCHAR *option, const TCHAR *format,...);
......@@ -478,25 +479,25 @@ extern void cfgfile_dwrite_str (struct zfile *f, const TCHAR *option, const TCHA
extern void cfgfile_target_write_str (struct zfile *f, const TCHAR *option, const TCHAR *value);
extern void cfgfile_target_dwrite_str (struct zfile *f, const TCHAR *option, const TCHAR *value);
*/
extern void cfgfile_backup (const TCHAR *path);
extern struct uaedev_config_info *add_filesys_config (struct uae_prefs *p, int index,
TCHAR *devname, TCHAR *volname, TCHAR *rootdir, bool readonly,
int secspertrack, int surfaces, int reserved,
int blocksize, int bootpri, TCHAR *filesysdir, int hdc, int flags);
extern void cfgfile_backup (const TCHAR *path);
extern struct uaedev_config_info *add_filesys_config (struct uae_prefs *p, int index,
TCHAR *devname, TCHAR *volname, TCHAR *rootdir, bool readonly,
int secspertrack, int surfaces, int reserved,
int blocksize, int bootpri, TCHAR *filesysdir, int hdc, int flags);
extern void default_prefs (struct uae_prefs *, int);
extern void discard_prefs (struct uae_prefs *, int);
int parse_cmdline_option (struct uae_prefs *, TCHAR, const TCHAR *);
int parse_cmdline_option (struct uae_prefs *, TCHAR, const TCHAR *);
extern int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, bool *location);
extern int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, int scale);
extern int cfgfile_strval (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, const TCHAR *table[], int more);
extern int cfgfile_string (const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz);
extern TCHAR *cfgfile_subst_path (const TCHAR *path, const TCHAR *subst, const TCHAR *file);
extern int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, bool *location);
extern int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, int scale);
extern int cfgfile_strval (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, const TCHAR *table[], int more);
extern int cfgfile_string (const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz);
extern TCHAR *cfgfile_subst_path (const TCHAR *path, const TCHAR *subst, const TCHAR *file);
extern TCHAR *target_expand_environment (const TCHAR *path);
extern int target_parse_option (struct uae_prefs *, TCHAR *option, TCHAR *value);
extern TCHAR *target_expand_environment (const TCHAR *path);
extern int target_parse_option (struct uae_prefs *, TCHAR *option, TCHAR *value);
/*extern void target_save_options (struct zfile*, struct uae_prefs *);
extern void target_default_options (struct uae_prefs *, int type);
extern void target_fixup_options (struct uae_prefs *);
......@@ -510,13 +511,13 @@ extern int cfgfile_parse_option (struct uae_prefs *p, TCHAR *option, TCHAR *valu
extern int cfgfile_get_description (const TCHAR *filename, TCHAR *description, TCHAR *hostlink, TCHAR *hardwarelink, int *type);
extern void cfgfile_show_usage (void);
*/
extern uae_u32 cfgfile_uaelib(int mode, uae_u32 name, uae_u32 dst, uae_u32 maxlen);
extern uae_u32 cfgfile_uaelib (int mode, uae_u32 name, uae_u32 dst, uae_u32 maxlen);
extern uae_u32 cfgfile_uaelib_modify (uae_u32 mode, uae_u32 parms, uae_u32 size, uae_u32 out, uae_u32 outsize);
extern uae_u32 cfgfile_modify (uae_u32 index, TCHAR *parms, uae_u32 size, TCHAR *out, uae_u32 outsize);
extern void cfgfile_addcfgparam (TCHAR *);
extern int built_in_prefs (struct uae_prefs *p, int model, int config, int compa, int romcheck);
extern int built_in_chipset_prefs (struct uae_prefs *p);
extern int cmdlineparser (TCHAR *s, TCHAR *outp[], int max);
extern uae_u32 cfgfile_modify (uae_u32 index, TCHAR *parms, uae_u32 size, TCHAR *out, uae_u32 outsize);
extern void cfgfile_addcfgparam (TCHAR *);
extern int built_in_prefs (struct uae_prefs *p, int model, int config, int compa, int romcheck);
extern int built_in_chipset_prefs (struct uae_prefs *p);
extern int cmdlineparser (TCHAR *s, TCHAR *outp[], int max);
extern int cfgfile_configuration_change(int);
extern void fixup_prefs_dimensions (struct uae_prefs *prefs);
extern void fixup_prefs (struct uae_prefs *prefs);
......
......@@ -13,6 +13,7 @@ void scsidev_install (void);
void scsidev_reset (void);
void scsidev_start_threads (void);
int scsi_do_disk_change (int device_id, int insert);
int scsi_do_disk_device_change (void);
extern int log_scsi;
......
......@@ -4706,10 +4706,7 @@ void inputdevice_get_eventname (const struct inputevent *ie, TCHAR *out)
{
if (!out)
return;
if (ie->allow_mask == AM_K)
_stprintf (out, "%s (0x%02X)", ie->name, ie->data);
else
_tcscpy (out, ie->name);
_tcscpy (out, ie->name);
}
int inputdevice_iterate (int devnum, int num, TCHAR *name, int *af)
......
/*
* UAE - The Un*x Amiga Emulator
*
* scsi.device emulation
*
* Copyright 1995 Bernd Schmidt
* Copyright 1999 Patrick Ohly
* Copyright 2001 Brian King
* Copyright 2002 Toni Wilen
*
*/
/*
* UAE - The Un*x Amiga Emulator
*
* scsi.device emulation
*
* Copyright 1995 Bernd Schmidt
* Copyright 1999 Patrick Ohly
* Copyright 2001 Brian King
* Copyright 2002 Toni Wilen
*
*/
#include "sysconfig.h"
#include "sysdeps.h"
......@@ -44,33 +44,33 @@
#define ASYNC_REQUEST_CHANGEINT 10
struct devstruct {
int unitnum, aunit;
int opencnt;
int changenum;
int allow_scsi;
int allow_ioctl;
int drivetype;
int iscd;
volatile uaecptr d_request[MAX_ASYNC_REQUESTS];
volatile int d_request_type[MAX_ASYNC_REQUESTS];
volatile uae_u32 d_request_data[MAX_ASYNC_REQUESTS];
struct device_info di;
int unitnum, aunit;
int opencnt;
int changenum;
int allow_scsi;
int allow_ioctl;
int drivetype;
int iscd;
volatile uaecptr d_request[MAX_ASYNC_REQUESTS];
volatile int d_request_type[MAX_ASYNC_REQUESTS];
volatile uae_u32 d_request_data[MAX_ASYNC_REQUESTS];
struct device_info di;
uaecptr changeint;
smp_comm_pipe requests;
int thread_running;
uae_sem_t sync_sem;
smp_comm_pipe requests;
int thread_running;
uae_sem_t sync_sem;
};
struct priv_devstruct {
int inuse;
int unit;
int mode;
int scsi;
int ioctl;
int noscsi;
int type;
int flags; /* OpenDevice() */
int inuse;
int unit;
int mode;
int scsi;
int ioctl;
int noscsi;
int type;
int flags; /* OpenDevice() */
};
static struct devstruct devst[MAX_TOTAL_DEVICES];
......@@ -80,108 +80,108 @@ static uae_sem_t change_sem;
static struct device_info *devinfo (int mode, int unitnum, struct device_info *di)
{
return sys_command_info (mode, unitnum, di);
return sys_command_info (mode, unitnum, di);
}
static void io_log (const TCHAR *msg, uaecptr request)
{
if (log_scsi)
write_log ("%s: %08X %d %08X %d %d io_actual=%d io_error=%d\n",
msg, request,get_word (request + 28),get_long (request + 40),
get_long (request + 36),get_long (request + 44),
get_long (request + 32), get_byte (request + 31));
msg, request, get_word (request + 28), get_long (request + 40),
get_long (request + 36), get_long (request + 44),
get_long (request + 32), get_byte (request + 31));
}
static struct devstruct *getdevstruct (int unit)
{
int i;
for (i = 0; i < MAX_TOTAL_DEVICES; i++) {
int i;
for (i = 0; i < MAX_TOTAL_DEVICES; i++) {
if (unit >= 0 && devst[i].aunit == unit) return &devst[i];
}
return 0;
}
return 0;
}
static struct priv_devstruct *getpdevstruct (uaecptr request)
{
int i = get_long (request + 24);
if (i < 0 || i >= MAX_OPEN_DEVICES || pdevst[i].inuse == 0) {
int i = get_long (request + 24);
if (i < 0 || i >= MAX_OPEN_DEVICES || pdevst[i].inuse == 0) {
write_log ("uaescsi.device: corrupt iorequest %08X %d\n", request, i);
return 0;
}
return &pdevst[i];
}
return &pdevst[i];
}
static const TCHAR *getdevname (int type)
{
switch (type) {
switch (type) {
case UAEDEV_SCSI_ID:
return UAEDEV_SCSI;
case UAEDEV_DISK_ID:
return UAEDEV_DISK;
default:
return "NULL";
}
}
}
static void *dev_thread (void *devs);
static int start_thread (struct devstruct *dev)
{
if (dev->thread_running)
return 1;
init_comm_pipe (&dev->requests, 100, 1);
uae_sem_init (&dev->sync_sem, 0, 0);
if (dev->thread_running)
return 1;
init_comm_pipe (&dev->requests, 100, 1);
uae_sem_init (&dev->sync_sem, 0, 0);
uae_start_thread ("uaescsi", dev_thread, dev, NULL);
uae_sem_wait (&dev->sync_sem);
return dev->thread_running;
uae_sem_wait (&dev->sync_sem);
return dev->thread_running;
}
static void dev_close_3 (struct devstruct *dev, struct priv_devstruct *pdev)
{
if (!dev->opencnt) return;
dev->opencnt--;
if (!dev->opencnt) {
if (pdev->scsi)
sys_command_close (DF_SCSI, dev->unitnum);
if (pdev->ioctl)
sys_command_close (DF_IOCTL, dev->unitnum);
pdev->inuse = 0;
write_comm_pipe_u32 (&dev->requests, 0, 1);
}
if (!dev->opencnt) return;
dev->opencnt--;
if (!dev->opencnt) {
if (pdev->scsi)
sys_command_close (DF_SCSI, dev->unitnum);
if (pdev->ioctl)
sys_command_close (DF_IOCTL, dev->unitnum);
pdev->inuse = 0;
write_comm_pipe_u32 (&dev->requests, 0, 1);
}
}
static uae_u32 REGPARAM2 dev_close_2 (TrapContext *context)
{
uae_u32 request = m68k_areg (regs, 1);
struct priv_devstruct *pdev = getpdevstruct (request);
struct devstruct *dev;
uae_u32 request = m68k_areg (regs, 1);
struct priv_devstruct *pdev = getpdevstruct (request);
struct devstruct *dev;
if (!pdev)
if (!pdev)
return 0;
dev = getdevstruct (pdev->unit);
if (log_scsi)
dev = getdevstruct (pdev->unit);
if (log_scsi)
write_log ("%s:%d close, req=%08X\n", getdevname (pdev->type), pdev->unit, request);
if (!dev)
if (!dev)
return 0;
dev_close_3 (dev, pdev);
put_long (request + 24, 0);
dev_close_3 (dev, pdev);
put_long (request + 24, 0);
put_word (m68k_areg (regs, 6) + 32, get_word (m68k_areg (regs, 6) + 32) - 1);
return 0;
return 0;
}
static uae_u32 REGPARAM2 dev_close (TrapContext *context)
{
return dev_close_2 (context);
return dev_close_2 (context);
}
static uae_u32 REGPARAM2 diskdev_close (TrapContext *context)
{
return dev_close_2 (context);
return dev_close_2 (context);
}
static int openfail (uaecptr ioreq, int error)
{
put_long (ioreq + 20, -1);
put_byte (ioreq + 31, error);
return (uae_u32)-1;
put_long (ioreq + 20, -1);
put_byte (ioreq + 31, error);
return (uae_u32)-1;
}
static void setpdev (struct priv_devstruct *pdev, struct devstruct *dev)
......@@ -196,79 +196,79 @@ static uae_u32 REGPARAM2 dev_open_2 (TrapContext *context, int type)
uaecptr ioreq = m68k_areg (regs, 1);
uae_u32 unit = m68k_dreg (regs, 0);
uae_u32 flags = m68k_dreg (regs, 1);
struct devstruct *dev = getdevstruct (unit);
struct priv_devstruct *pdev = 0;
int i;
struct devstruct *dev = getdevstruct (unit);
struct priv_devstruct *pdev = 0;
int i;
if (log_scsi)
if (log_scsi)
write_log ("opening %s:%d ioreq=%08X\n", getdevname (type), unit, ioreq);
if (get_word (ioreq + 0x12) < IOSTDREQ_SIZE)
return openfail (ioreq, IOERR_BADLENGTH);
if (!dev)
if (!dev)
return openfail (ioreq, 32); /* badunitnum */
if (!dev->opencnt) {
if (!dev->opencnt) {
for (i = 0; i < MAX_OPEN_DEVICES; i++) {
pdev = &pdevst[i];
if (pdev->inuse == 0) break;
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;
pdev->ioctl = 1;
pdev->mode = DF_IOCTL;
}
if (!pdev->scsi && !pdev->ioctl)
return openfail (ioreq, IOERR_OPENFAIL);
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 {
} else {
for (i = 0; i < MAX_OPEN_DEVICES; i++) {
pdev = &pdevst[i];
pdev = &pdevst[i];
if (pdev->inuse && pdev->unit == unit) break;
}
if (i == MAX_OPEN_DEVICES)
return openfail (ioreq, IOERR_OPENFAIL);
put_long (ioreq + 24, pdev - pdevst);
}
dev->opencnt++;
}
dev->opencnt++;
put_word (m68k_areg (regs, 6) + 32, get_word (m68k_areg (regs, 6) + 32) + 1);
put_byte (ioreq + 31, 0);
put_byte (ioreq + 8, 7);
return 0;
put_byte (ioreq + 31, 0);
put_byte (ioreq + 8, 7);
return 0;
}
static uae_u32 REGPARAM2 dev_open (TrapContext *context)
{
return dev_open_2 (context, UAEDEV_SCSI_ID);
return dev_open_2 (context, UAEDEV_SCSI_ID);
}
static uae_u32 REGPARAM2 diskdev_open (TrapContext *context)
{
return dev_open_2 (context, UAEDEV_DISK_ID);
return dev_open_2 (context, UAEDEV_DISK_ID);
}
static uae_u32 REGPARAM2 dev_expunge (TrapContext *context)
{
return 0;
return 0;
}
static uae_u32 REGPARAM2 diskdev_expunge (TrapContext *context)
{
return 0;
return 0;
}
static int is_async_request (struct devstruct *dev, uaecptr request)
{
int i = 0;
while (i < MAX_ASYNC_REQUESTS) {
int i = 0;
while (i < MAX_ASYNC_REQUESTS) {
if (dev->d_request[i] == request) return 1;
i++;
}
return 0;
}
return 0;
}
......@@ -289,14 +289,17 @@ int scsiemul_switchscsi (TCHAR *name)
dev = NULL;
for (j = 0; j < 2; j++) {
int mode = j == 0 ? DF_SCSI : DF_IOCTL;
device_func_init (j == 0 ? DEVICE_TYPE_SCSI : DEVICE_TYPE_ANY);
if (!(device_func_init (j == 0 ? DEVICE_TYPE_SCSI : DEVICE_TYPE_ANY) & (1 << mode)))
continue;
if (devst[0].di.media_inserted < 0)
devst[0].di.media_inserted = 0;
i = 0;
while (i < MAX_TOTAL_DEVICES && dev == NULL) {
discsi = 0;
if (sys_command_open (mode, i)) {
discsi = sys_command_info (mode, i, &discsi2);
if (discsi && discsi->type == INQ_ROMD) {
if (!_tcsicmp (currprefs.cdimagefile, discsi->label) || j) {
if (!_tcsicmp (currprefs.cdimagefile, discsi->label)) {
dev = &devst[0];
dev->unitnum = i;
dev->allow_scsi = j == 0 ? 1 : 0;
......@@ -309,6 +312,10 @@ int scsiemul_switchscsi (TCHAR *name)
struct priv_devstruct *pdev = &pdevst[dev->aunit];
setpdev (pdev, dev);
}
if (dev->di.media_inserted) {
dev->di.media_inserted = 0;
scsi_do_disk_change (dev->di.id, 1);
}
}
}
if (devst[0].opencnt == 0)
......@@ -317,11 +324,50 @@ int scsiemul_switchscsi (TCHAR *name)
i++;
}
if (dev)
return i;
return dev->unitnum;
}
return -1;
}
static int scsiemul_switchemu (const TCHAR *name)
{
struct devstruct *dev = NULL;
struct device_info *discsi, discsi2;
if (!device_func_init (DEVICE_TYPE_ANY | DEVICE_TYPE_ALLOWEMU))
return -1;
if (sys_command_open (DF_IOCTL, 0)) {
if (discsi = sys_command_info (DF_IOCTL, 0, &discsi2)) {
dev = &devst[0];
dev->unitnum = 0;
dev->allow_scsi = 0;
dev->allow_ioctl = 1;
dev->drivetype = discsi->type;
memcpy (&dev->di, discsi, sizeof (struct device_info));
dev->iscd = 1;
write_log ("IMG_EMU (%s) mounted as uaescsi.device:0\n", name);
if (dev->aunit >= 0) {
struct priv_devstruct *pdev = &pdevst[dev->aunit];
setpdev (pdev, dev);
}
dev->di.media_inserted = 0;
}
if (devst[0].opencnt == 0)
sys_command_close (DF_IOCTL, 0);
return 0;
}
return -1;
}
int scsi_do_disk_device_change (void)
{
int ret = scsiemul_switchscsi (currprefs.cdimagefile);
if (ret < 0) {
scsiemul_switchemu (currprefs.cdimagefile);
}
return ret;
}
// device_id = -1 and insert==0 -> all medias going away
int scsi_do_disk_change (int device_id, int insert)
{
int i, j, ret;
......@@ -329,99 +375,97 @@ int scsi_do_disk_change (int device_id, int insert)
ret = -1;
if (!change_sem)
return ret;
uae_sem_wait (&change_sem);
if (device_id < 0 && insert) {
ret = scsiemul_switchscsi (currprefs.cdimagefile);
if (ret < 0)
goto end;
}
for (i = 0; i < MAX_TOTAL_DEVICES; i++) {
uae_sem_wait (&change_sem);
for (i = 0; i < MAX_TOTAL_DEVICES; i++) {
struct devstruct *dev = &devst[i];
if (dev->di.id == device_id || (device_id < 0 && i == 0)) {
ret = i;
if (dev->aunit >= 0) {
struct priv_devstruct *pdev = &pdevst[dev->aunit];
devinfo (pdev->mode, dev->unitnum, &dev->di);
}
dev->changenum++;
j = 0;
while (j < MAX_ASYNC_REQUESTS) {
if (dev->d_request_type[j] == ASYNC_REQUEST_CHANGEINT) {
uae_Cause (dev->d_request_data[j]);
if ((dev->di.media_inserted > 0 && insert == 0) || (dev->di.media_inserted <= 0 && insert)) {
if (dev->aunit >= 0) {
struct priv_devstruct *pdev = &pdevst[dev->aunit];
devinfo (pdev->mode, dev->unitnum, &dev->di);
}
j++;
}
if (dev->changeint)
uae_Cause (dev->changeint);
if (device_id < 0 && insert == 0)
dev->di.media_inserted = -1; // stay away!
dev->changenum++;
j = 0;
while (j < MAX_ASYNC_REQUESTS) {
if (dev->d_request_type[j] == ASYNC_REQUEST_CHANGEINT) {
uae_Cause (dev->d_request_data[j]);
}
j++;
}
if (dev->changeint)
uae_Cause (dev->changeint);
}
}
}
end:
uae_sem_post (&change_sem);
}
uae_sem_post (&change_sem);
return ret;
}
static int add_async_request (struct devstruct *dev, uaecptr request, int type, uae_u32 data)
{
int i;
int i;
if (log_scsi)
if (log_scsi)
write_log ("async request %08x (%d) added\n", request, type);
i = 0;
while (i < MAX_ASYNC_REQUESTS) {
i = 0;
while (i < MAX_ASYNC_REQUESTS) {
if (dev->d_request[i] == request) {
dev->d_request_type[i] = type;
dev->d_request_data[i] = data;
return 0;
dev->d_request_type[i] = type;
dev->d_request_data[i] = data;
return 0;
}
i++;
}
i = 0;
while (i < MAX_ASYNC_REQUESTS) {
}
i = 0;
while (i < MAX_ASYNC_REQUESTS) {
if (dev->d_request[i] == 0) {
dev->d_request[i] = request;
dev->d_request_type[i] = type;
dev->d_request_data[i] = data;
return 0;
dev->d_request[i] = request;
dev->d_request_type[i] = type;
dev->d_request_data[i] = data;
return 0;
}
i++;
}
return -1;
}
return -1;
}
static int release_async_request (struct devstruct *dev, uaecptr request)
{
int i = 0;
int i = 0;
if (log_scsi)
if (log_scsi)
write_log ("async request %p removed\n", request);
while (i < MAX_ASYNC_REQUESTS) {
while (i < MAX_ASYNC_REQUESTS) {
if (dev->d_request[i] == request) {
int type = dev->d_request_type[i];
dev->d_request[i] = 0;
dev->d_request_data[i] = 0;
dev->d_request_type[i] = 0;
return type;
int type = dev->d_request_type[i];
dev->d_request[i] = 0;
dev->d_request_data[i] = 0;
dev->d_request_type[i] = 0;
return type;
}
i++;
}
return -1;
}
return -1;
}
static void abort_async (struct devstruct *dev, uaecptr request, int errcode, int type)
{
int i;
i = 0;
while (i < MAX_ASYNC_REQUESTS) {
int i;
i = 0;
while (i < MAX_ASYNC_REQUESTS) {
if (dev->d_request[i] == request && dev->d_request_type[i] == ASYNC_REQUEST_TEMP) {
/* ASYNC_REQUEST_TEMP = request is processing */
uae_msleep (10);
i = 0;
continue;
/* ASYNC_REQUEST_TEMP = request is processing */
uae_msleep (10);
i = 0;
continue;
}
i++;
}
i = release_async_request (dev, request);
if (i >= 0 && log_scsi)
}
i = release_async_request (dev, request);
if (i >= 0 && log_scsi)
write_log ("asyncronous request=%08X aborted, error=%d\n", request, errcode);
}
......@@ -509,26 +553,26 @@ static int command_cd_read (int mode, struct devstruct *dev, uaecptr data, uae_u
static int dev_do_io (struct devstruct *dev, uaecptr request)
{
uae_u32 command;
uae_u32 io_data = get_long (request + 40); // 0x28
uae_u32 io_length = get_long (request + 36); // 0x24
uae_u32 io_actual = get_long (request + 32); // 0x20
uae_u32 io_offset = get_long (request + 44); // 0x2c
uae_u32 io_error = 0;
uae_u32 command;
uae_u32 io_data = get_long (request + 40); // 0x28
uae_u32 io_length = get_long (request + 36); // 0x24
uae_u32 io_actual = get_long (request + 32); // 0x20
uae_u32 io_offset = get_long (request + 44); // 0x2c
uae_u32 io_error = 0;
uae_u64 io_offset64;
int async = 0;
int async = 0;
int bmask = dev->di.bytespersector - 1;
struct priv_devstruct *pdev = getpdevstruct (request);
struct priv_devstruct *pdev = getpdevstruct (request);
if (!pdev)
if (!pdev)
return 0;
command = get_word (request+28);
command = get_word (request + 28);
switch (command)
{
switch (command)
{
case CMD_READ:
//write_log ("CMD_READ %08x %d %d %08x\n", io_data, io_offset, io_length, bmask);
if (!dev->di.media_inserted)
if (dev->di.media_inserted <= 0)
goto no_media;
if (dev->drivetype == INQ_ROMD) {
io_error = command_cd_read (pdev->mode, dev, io_data, io_offset, io_length, &io_actual);
......@@ -542,7 +586,7 @@ static int dev_do_io (struct devstruct *dev, uaecptr request)
break;
case TD_READ64:
case NSCMD_TD_READ64:
if (!dev->di.media_inserted)
if (dev->di.media_inserted <= 0)
goto no_media;
io_offset64 = get_long (request + 44) | ((uae_u64)get_long (request + 32) << 32);
if ((io_offset64 & bmask) || bmask == 0 || io_data == 0)
......@@ -556,7 +600,7 @@ static int dev_do_io (struct devstruct *dev, uaecptr request)
break;
case CMD_WRITE:
if (!dev->di.media_inserted)
if (dev->di.media_inserted <= 0)
goto no_media;
if (dev->di.write_protected || dev->drivetype == INQ_ROMD) {
io_error = 28; /* writeprotect */
......@@ -570,7 +614,7 @@ static int dev_do_io (struct devstruct *dev, uaecptr request)
break;
case TD_WRITE64:
case NSCMD_TD_WRITE64:
if (!dev->di.media_inserted)
if (dev->di.media_inserted <= 0)
goto no_media;
io_offset64 = get_long (request + 44) | ((uae_u64)get_long (request + 32) << 32);
if (dev->di.write_protected || dev->drivetype == INQ_ROMD) {
......@@ -585,7 +629,7 @@ static int dev_do_io (struct devstruct *dev, uaecptr request)
break;
case CMD_FORMAT:
if (!dev->di.media_inserted)
if (dev->di.media_inserted <= 0)
goto no_media;
if (dev->di.write_protected || dev->drivetype == INQ_ROMD) {
io_error = 28; /* writeprotect */
......@@ -599,7 +643,7 @@ static int dev_do_io (struct devstruct *dev, uaecptr request)
break;
case TD_FORMAT64:
case NSCMD_TD_FORMAT64:
if (!dev->di.media_inserted)
if (dev->di.media_inserted <= 0)
goto no_media;
io_offset64 = get_long (request + 44) | ((uae_u64)get_long (request + 32) << 32);
if (dev->di.write_protected || dev->drivetype == INQ_ROMD) {
......@@ -628,7 +672,11 @@ static int dev_do_io (struct devstruct *dev, uaecptr request)
io_actual = dev->changenum;
break;
case CMD_CHANGESTATE:
io_actual = devinfo (pdev->mode, dev->unitnum, &dev->di)->media_inserted ? 0 : 1;
if (dev->di.media_inserted >= 0) {
io_actual = devinfo (pdev->mode, dev->unitnum, &dev->di)->media_inserted > 0 ? 0 : 1;
} else {
io_actual = 1;
}
break;
case CMD_PROTSTATUS:
io_actual = devinfo (pdev->mode, dev->unitnum, &dev->di)->write_protected ? -1 : 0;
......@@ -637,7 +685,7 @@ static int dev_do_io (struct devstruct *dev, uaecptr request)
io_actual = dev->drivetype;
break;
case CMD_GETNUMTRACKS:
if (!dev->di.media_inserted)
if (dev->di.media_inserted <= 0)
goto no_media;
io_actual = dev->di.cylinders;
break;
......@@ -645,7 +693,7 @@ static int dev_do_io (struct devstruct *dev, uaecptr request)
{
struct device_info *di;
di = devinfo (pdev->mode, dev->unitnum, &dev->di);
if (!di->media_inserted)
if (di->media_inserted <= 0)
goto no_media;
put_long (io_data + 0, di->bytespersector);
put_long (io_data + 4, di->sectorspertrack * di->trackspercylinder * di->cylinders);
......@@ -662,19 +710,19 @@ static int dev_do_io (struct devstruct *dev, uaecptr request)
case CMD_ADDCHANGEINT:
io_error = add_async_request (dev, request, ASYNC_REQUEST_CHANGEINT, io_data);
if (!io_error)
async = 1;
async = 1;
break;
case CMD_REMCHANGEINT:
release_async_request (dev, request);
break;
case HD_SCSICMD:
if (dev->allow_scsi && pdev->scsi) {
uae_u32 sdd = get_long (request + 40);
io_error = sys_command_scsi_direct (dev->unitnum, sdd);
if (log_scsi)
uae_u32 sdd = get_long (request + 40);
io_error = sys_command_scsi_direct (dev->unitnum, sdd);
if (log_scsi)
write_log ("scsidev: did io: sdd %p request %p error %d\n", sdd, request, get_byte (request + 31));
} else {
io_error = IOERR_NOCMD;
io_error = IOERR_NOCMD;
}
break;
case NSCMD_DEVICEQUERY:
......@@ -697,17 +745,17 @@ bad_command:
no_media:
io_error = TDERR_DiskChanged;
break;
}
put_long (request + 32, io_actual);
put_byte (request + 31, io_error);
}
put_long (request + 32, io_actual);
put_byte (request + 31, io_error);
io_log ("dev_io",request);
return async;
return async;
}
static int dev_can_quick (uae_u32 command)
{
switch (command)
{
switch (command)
{
case CMD_RESET:
case CMD_STOP:
case CMD_START:
......@@ -716,25 +764,25 @@ static int dev_can_quick (uae_u32 command)
case CMD_GETDRIVETYPE:
case CMD_GETNUMTRACKS:
return 1;
}
return 0;
}
return 0;
}
static int dev_canquick (struct devstruct *dev, uaecptr request)
{
uae_u32 command = get_word (request + 28);
return dev_can_quick (command);
uae_u32 command = get_word (request + 28);
return dev_can_quick (command);
}
static uae_u32 REGPARAM2 dev_beginio (TrapContext *context)
{
uae_u32 request = m68k_areg (regs, 1);
uae_u8 flags = get_byte (request + 30);
int command = get_word (request + 28);
struct priv_devstruct *pdev = getpdevstruct (request);
uae_u8 flags = get_byte (request + 30);
int command = get_word (request + 28);
struct priv_devstruct *pdev = getpdevstruct (request);
struct devstruct *dev;
put_byte (request+8, NT_MESSAGE);
put_byte (request + 8, NT_MESSAGE);
if (!pdev) {
put_byte (request + 31, 32);
return get_byte (request + 31);
......@@ -743,18 +791,18 @@ static uae_u32 REGPARAM2 dev_beginio (TrapContext *context)
if (!dev) {
put_byte (request + 31, 32);
return get_byte (request + 31);
}
put_byte (request+31, 0);
if ((flags & 1) && dev_canquick (dev, request)) {
}
put_byte (request + 31, 0);
if ((flags & 1) && dev_canquick (dev, request)) {
if (dev_do_io (dev, request))
write_log ("device %s command %d bug with IO_QUICK\n", getdevname (pdev->type), command);
return get_byte (request + 31);
} else {
} else {
add_async_request (dev, request, ASYNC_REQUEST_TEMP, 0);
put_byte (request+30, get_byte (request + 30) & ~1);
put_byte (request + 30, get_byte (request + 30) & ~1);
write_comm_pipe_u32 (&dev->requests, request, 1);
return 0;
}
}
}
static void *dev_thread (void *devs)
......@@ -762,27 +810,27 @@ static void *dev_thread (void *devs)
struct devstruct *dev = (struct devstruct*)devs;
uae_set_thread_priority (2);
dev->thread_running = 1;
uae_sem_post (&dev->sync_sem);
for (;;) {
dev->thread_running = 1;
uae_sem_post (&dev->sync_sem);
for (;;) {
uaecptr request = (uaecptr)read_comm_pipe_u32_blocking (&dev->requests);
uae_sem_wait (&change_sem);
if (!request) {
dev->thread_running = 0;
uae_sem_post (&dev->sync_sem);
uae_sem_post (&change_sem);
dev->thread_running = 0;
uae_sem_post (&dev->sync_sem);
uae_sem_post (&change_sem);
return 0;
} else if (dev_do_io (dev, request) == 0) {
put_byte (request + 30, get_byte (request + 30) & ~1);
release_async_request (dev, request);
uae_ReplyMsg (request);
put_byte (request + 30, get_byte (request + 30) & ~1);
release_async_request (dev, request);
uae_ReplyMsg (request);
} else {
if (log_scsi)
if (log_scsi)
write_log ("%s:%d async request %08X\n", getdevname(0), dev->unitnum, request);
}
uae_sem_post (&change_sem);
}
return 0;
}
return 0;
}
static uae_u32 REGPARAM2 dev_init_2 (TrapContext *context, int type)
......@@ -790,48 +838,48 @@ static uae_u32 REGPARAM2 dev_init_2 (TrapContext *context, int type)
uae_u32 base = m68k_dreg (regs,0);
if (log_scsi)
write_log ("%s init\n", getdevname (type));
return base;
return base;
}
static uae_u32 REGPARAM2 dev_init (TrapContext *context)
{
return dev_init_2 (context, UAEDEV_SCSI_ID);
return dev_init_2 (context, UAEDEV_SCSI_ID);
}
static uae_u32 REGPARAM2 diskdev_init (TrapContext *context)
{
return dev_init_2 (context, UAEDEV_DISK_ID);
return dev_init_2 (context, UAEDEV_DISK_ID);
}
static uae_u32 REGPARAM2 dev_abortio (TrapContext *context)
{
uae_u32 request = m68k_areg (regs, 1);
struct priv_devstruct *pdev = getpdevstruct (request);
struct devstruct *dev;
struct priv_devstruct *pdev = getpdevstruct (request);
struct devstruct *dev;
if (!pdev) {
if (!pdev) {
put_byte (request + 31, 32);
return get_byte (request + 31);
}
dev = getdevstruct (pdev->unit);
if (!dev) {
}
dev = getdevstruct (pdev->unit);
if (!dev) {
put_byte (request + 31, 32);
return get_byte (request + 31);
}
}
put_byte (request + 31, IOERR_ABORTED);
if (log_scsi)
if (log_scsi)
write_log ("abortio %s unit=%d, request=%08.8X\n", getdevname (pdev->type), pdev->unit, request);
abort_async (dev, request, IOERR_ABORTED, 0);
return 0;
abort_async (dev, request, IOERR_ABORTED, 0);
return 0;
}
#define BTL2UNIT(bus, target, lun) (2 * (bus) + (target) / 8) * 100 + (lun) * 10 + (target % 8)
static void dev_reset (void)
{
int i, j;
struct devstruct *dev;
struct device_info *discsi, discsi2;
int unitnum = 0;
int i, j;
struct devstruct *dev;
struct device_info *discsi, discsi2;
int unitnum = 0;
for (i = 0; i < MAX_TOTAL_DEVICES; i++) {
dev = &devst[i];
......@@ -850,259 +898,270 @@ static void dev_reset (void)
memset (dev, 0, sizeof (struct devstruct));
dev->unitnum = dev->aunit = -1;
}
for (i = 0; i < MAX_OPEN_DEVICES; i++)
for (i = 0; i < MAX_OPEN_DEVICES; i++)
memset (&pdevst[i], 0, sizeof (struct priv_devstruct));
if (currprefs.cdimagefile[0]) {
scsiemul_switchscsi (currprefs.cdimagefile);
} else {
int didswitch = -1;
if (currprefs.cdimagefile[0] || currprefs.cdimagefileuse)
didswitch = scsiemul_switchscsi (currprefs.cdimagefile);
if (didswitch < 0) {
device_func_init (DEVICE_TYPE_SCSI);
i = j = 0;
while (i < MAX_TOTAL_DEVICES) {
dev = &devst[i];
discsi = 0;
if (sys_command_open (DF_SCSI, j)) {
discsi = sys_command_info (DF_SCSI, j, &discsi2);
sys_command_close (DF_SCSI, j);
}
if (discsi) {
dev->unitnum = j;
dev->allow_scsi = 1;
dev->drivetype = discsi->type;
memcpy (&dev->di, discsi, sizeof (struct device_info));
if (discsi->type == INQ_ROMD)
dev->iscd = 1;
}
i++;
j++;
i = j = 0;
while (i < MAX_TOTAL_DEVICES) {
int mode = -1;
dev = &devst[i];
discsi = 0;
if (sys_command_open (DF_SCSI, j)) {
dev->allow_scsi = 1;
mode = DF_SCSI;
}
if (!dev->allow_scsi) {
if (sys_command_open (DF_IOCTL, j)) {
dev->allow_ioctl = 1;
mode = DF_IOCTL;
}
}
if (mode >= 0) {
discsi = sys_command_info (mode, j, &discsi2);
sys_command_close (mode, j);
}
if (discsi) {
dev->unitnum = j;
dev->drivetype = discsi->type;
memcpy (&dev->di, discsi, sizeof (struct device_info));
if (discsi->type == INQ_ROMD)
dev->iscd = 1;
}
i++;
j++;
}
}
unitnum = 0;
for (i = 0; i < MAX_TOTAL_DEVICES; i++) {
}
unitnum = 0;
for (i = 0; i < MAX_TOTAL_DEVICES; i++) {
dev = &devst[i];
if (dev->unitnum >= 0 && dev->iscd) {
dev->aunit = unitnum;
unitnum++;
dev->aunit = unitnum;
unitnum++;
}
}
if (unitnum == 0)
}
if (unitnum == 0)
unitnum = 1;
for (i = 0; i < MAX_TOTAL_DEVICES; i++) {
for (i = 0; i < MAX_TOTAL_DEVICES; i++) {
dev = &devst[i];
if (dev->unitnum >= 0) {
if (!dev->iscd) {
if (!dev->iscd) {
dev->aunit = unitnum;
unitnum++;
}
}
write_log ("%s:%d = '%s'\n", UAEDEV_SCSI, dev->aunit, dev->di.label);
}
dev->di.label[0] = 0;
}
}
}
static uaecptr ROM_scsidev_resname = 0,
ROM_scsidev_resid = 0,
ROM_scsidev_init = 0;
ROM_scsidev_resid = 0,
ROM_scsidev_init = 0;
static uaecptr ROM_diskdev_resname = 0,
ROM_diskdev_resid = 0,
ROM_diskdev_init = 0;
ROM_diskdev_resid = 0,
ROM_diskdev_init = 0;
static uaecptr diskdev_startup (uaecptr resaddr)
{
/* Build a struct Resident. This will set up and initialize
* the cd.device */
if (log_scsi)
/* Build a struct Resident. This will set up and initialize
* the cd.device */
if (log_scsi)
write_log ("diskdev_startup(0x%x)\n", resaddr);
put_word (resaddr + 0x0, 0x4AFC);
put_long (resaddr + 0x2, resaddr);
put_long (resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */
put_word (resaddr + 0xA, 0x8101); /* RTF_AUTOINIT|RTF_COLDSTART; Version 1 */
put_word (resaddr + 0xC, 0x0305); /* NT_DEVICE; pri 05 */
put_long (resaddr + 0xE, ROM_diskdev_resname);
put_long (resaddr + 0x12, ROM_diskdev_resid);
put_long (resaddr + 0x16, ROM_diskdev_init);
resaddr += 0x1A;
return resaddr;
put_word (resaddr + 0x0, 0x4AFC);
put_long (resaddr + 0x2, resaddr);
put_long (resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */
put_word (resaddr + 0xA, 0x8101); /* RTF_AUTOINIT|RTF_COLDSTART; Version 1 */
put_word (resaddr + 0xC, 0x0305); /* NT_DEVICE; pri 05 */
put_long (resaddr + 0xE, ROM_diskdev_resname);
put_long (resaddr + 0x12, ROM_diskdev_resid);
put_long (resaddr + 0x16, ROM_diskdev_init);
resaddr += 0x1A;
return resaddr;
}
uaecptr scsidev_startup (uaecptr resaddr)
{
if (currprefs.scsi != 1)
return resaddr;
if (log_scsi)
if (log_scsi)
write_log ("scsidev_startup(0x%x)\n", resaddr);
/* Build a struct Resident. This will set up and initialize
* the uaescsi.device */
put_word (resaddr + 0x0, 0x4AFC);
put_long (resaddr + 0x2, resaddr);
put_long (resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */
put_word (resaddr + 0xA, 0x8101); /* RTF_AUTOINIT|RTF_COLDSTART; Version 1 */
put_word (resaddr + 0xC, 0x0305); /* NT_DEVICE; pri 05 */
put_long (resaddr + 0xE, ROM_scsidev_resname);
put_long (resaddr + 0x12, ROM_scsidev_resid);
put_long (resaddr + 0x16, ROM_scsidev_init); /* calls scsidev_init */
resaddr += 0x1A;
return resaddr;
return diskdev_startup (resaddr);
/* Build a struct Resident. This will set up and initialize
* the uaescsi.device */
put_word (resaddr + 0x0, 0x4AFC);
put_long (resaddr + 0x2, resaddr);
put_long (resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */
put_word (resaddr + 0xA, 0x8101); /* RTF_AUTOINIT|RTF_COLDSTART; Version 1 */
put_word (resaddr + 0xC, 0x0305); /* NT_DEVICE; pri 05 */
put_long (resaddr + 0xE, ROM_scsidev_resname);
put_long (resaddr + 0x12, ROM_scsidev_resid);
put_long (resaddr + 0x16, ROM_scsidev_init); /* calls scsidev_init */
resaddr += 0x1A;
return resaddr;
return diskdev_startup (resaddr);
}
static void diskdev_install (void)
{
uae_u32 functable, datatable;
uae_u32 initcode, openfunc, closefunc, expungefunc;
uae_u32 beginiofunc, abortiofunc;
uae_u32 functable, datatable;
uae_u32 initcode, openfunc, closefunc, expungefunc;
uae_u32 beginiofunc, abortiofunc;
if (currprefs.scsi != 1)
return;
if (log_scsi)
if (log_scsi)
write_log ("diskdev_install(): 0x%x\n", here ());
ROM_diskdev_resname = ds (UAEDEV_DISK);
ROM_diskdev_resname = ds (UAEDEV_DISK);
ROM_diskdev_resid = ds ("UAE disk.device 0.1");
/* initcode */
initcode = here ();
calltrap (deftrap (diskdev_init)); dw (RTS);
/* Open */
openfunc = here ();
calltrap (deftrap (diskdev_open)); dw (RTS);
/* Close */
closefunc = here ();
calltrap (deftrap (diskdev_close)); dw (RTS);
/* Expunge */
expungefunc = here ();
calltrap (deftrap (diskdev_expunge)); dw (RTS);
/* BeginIO */
beginiofunc = here ();
calltrap (deftrap (dev_beginio));
dw (RTS);
/* AbortIO */
abortiofunc = here ();
calltrap (deftrap (dev_abortio)); dw (RTS);
/* FuncTable */
functable = here ();
dl (openfunc); /* Open */
dl (closefunc); /* Close */
dl (expungefunc); /* Expunge */
dl (EXPANSION_nullfunc); /* Null */
dl (beginiofunc); /* BeginIO */
dl (abortiofunc); /* AbortIO */
dl (0xFFFFFFFFul); /* end of table */
/* DataTable */
datatable = here ();
dw (0xE000); /* INITBYTE */
dw (0x0008); /* LN_TYPE */
dw (0x0300); /* NT_DEVICE */
dw (0xC000); /* INITLONG */
dw (0x000A); /* LN_NAME */
dl (ROM_diskdev_resname);
dw (0xE000); /* INITBYTE */
dw (0x000E); /* LIB_FLAGS */
dw (0x0600); /* LIBF_SUMUSED | LIBF_CHANGED */
dw (0xD000); /* INITWORD */
dw (0x0014); /* LIB_VERSION */
dw (0x0004); /* 0.4 */
dw (0xD000); /* INITWORD */
dw (0x0016); /* LIB_REVISION */
dw (0x0000); /* end of table already ??? */
dw (0xC000); /* INITLONG */
dw (0x0018); /* LIB_IDSTRING */
dl (ROM_diskdev_resid);
dw (0x0000); /* end of table */
ROM_diskdev_init = here ();
dl (0x00000100); /* size of device base */
dl (functable);
dl (datatable);
dl (initcode);
/* initcode */
initcode = here ();
calltrap (deftrap (diskdev_init)); dw (RTS);
/* Open */
openfunc = here ();
calltrap (deftrap (diskdev_open)); dw (RTS);
/* Close */
closefunc = here ();
calltrap (deftrap (diskdev_close)); dw (RTS);
/* Expunge */
expungefunc = here ();
calltrap (deftrap (diskdev_expunge)); dw (RTS);
/* BeginIO */
beginiofunc = here ();
calltrap (deftrap (dev_beginio));
dw (RTS);
/* AbortIO */
abortiofunc = here ();
calltrap (deftrap (dev_abortio)); dw (RTS);
/* FuncTable */
functable = here ();
dl (openfunc); /* Open */
dl (closefunc); /* Close */
dl (expungefunc); /* Expunge */
dl (EXPANSION_nullfunc); /* Null */
dl (beginiofunc); /* BeginIO */
dl (abortiofunc); /* AbortIO */
dl (0xFFFFFFFFul); /* end of table */
/* DataTable */
datatable = here ();
dw (0xE000); /* INITBYTE */
dw (0x0008); /* LN_TYPE */
dw (0x0300); /* NT_DEVICE */
dw (0xC000); /* INITLONG */
dw (0x000A); /* LN_NAME */
dl (ROM_diskdev_resname);
dw (0xE000); /* INITBYTE */
dw (0x000E); /* LIB_FLAGS */
dw (0x0600); /* LIBF_SUMUSED | LIBF_CHANGED */
dw (0xD000); /* INITWORD */
dw (0x0014); /* LIB_VERSION */
dw (0x0004); /* 0.4 */
dw (0xD000); /* INITWORD */
dw (0x0016); /* LIB_REVISION */
dw (0x0000); /* end of table already ??? */
dw (0xC000); /* INITLONG */
dw (0x0018); /* LIB_IDSTRING */
dl (ROM_diskdev_resid);
dw (0x0000); /* end of table */
ROM_diskdev_init = here ();
dl (0x00000100); /* size of device base */
dl (functable);
dl (datatable);
dl (initcode);
}
void scsidev_install (void)
{
uae_u32 functable, datatable;
uae_u32 initcode, openfunc, closefunc, expungefunc;
uae_u32 beginiofunc, abortiofunc;
uae_u32 functable, datatable;
uae_u32 initcode, openfunc, closefunc, expungefunc;
uae_u32 beginiofunc, abortiofunc;
if (currprefs.scsi != 1)
return;
if (log_scsi)
if (log_scsi)
write_log ("scsidev_install(): 0x%x\n", here ());
ROM_scsidev_resname = ds (UAEDEV_SCSI);
ROM_scsidev_resname = ds (UAEDEV_SCSI);
ROM_scsidev_resid = ds ("UAE scsi.device 0.2");
/* initcode */
initcode = here ();
calltrap (deftrap (dev_init)); dw (RTS);
/* Open */
openfunc = here ();
calltrap (deftrap (dev_open)); dw (RTS);
/* Close */
closefunc = here ();
calltrap (deftrap (dev_close)); dw (RTS);
/* Expunge */
expungefunc = here ();
calltrap (deftrap (dev_expunge)); dw (RTS);
/* BeginIO */
beginiofunc = here ();
calltrap (deftrap (dev_beginio));
dw (RTS);
/* AbortIO */
abortiofunc = here ();
calltrap (deftrap (dev_abortio)); dw (RTS);
/* FuncTable */
functable = here ();
dl (openfunc); /* Open */
dl (closefunc); /* Close */
dl (expungefunc); /* Expunge */
dl (EXPANSION_nullfunc); /* Null */
dl (beginiofunc); /* BeginIO */
dl (abortiofunc); /* AbortIO */
dl (0xFFFFFFFFul); /* end of table */
/* DataTable */
datatable = here ();
dw (0xE000); /* INITBYTE */
dw (0x0008); /* LN_TYPE */
dw (0x0300); /* NT_DEVICE */
dw (0xC000); /* INITLONG */
dw (0x000A); /* LN_NAME */
dl (ROM_scsidev_resname);
dw (0xE000); /* INITBYTE */
dw (0x000E); /* LIB_FLAGS */
dw (0x0600); /* LIBF_SUMUSED | LIBF_CHANGED */
dw (0xD000); /* INITWORD */
dw (0x0014); /* LIB_VERSION */
dw (0x0004); /* 0.4 */
dw (0xD000); /* INITWORD */
dw (0x0016); /* LIB_REVISION */
/* initcode */
initcode = here ();
calltrap (deftrap (dev_init)); dw (RTS);
/* Open */
openfunc = here ();
calltrap (deftrap (dev_open)); dw (RTS);
/* Close */
closefunc = here ();
calltrap (deftrap (dev_close)); dw (RTS);
/* Expunge */
expungefunc = here ();
calltrap (deftrap (dev_expunge)); dw (RTS);
/* BeginIO */
beginiofunc = here ();
calltrap (deftrap (dev_beginio));
dw (RTS);
/* AbortIO */
abortiofunc = here ();
calltrap (deftrap (dev_abortio)); dw (RTS);
/* FuncTable */
functable = here ();
dl (openfunc); /* Open */
dl (closefunc); /* Close */
dl (expungefunc); /* Expunge */
dl (EXPANSION_nullfunc); /* Null */
dl (beginiofunc); /* BeginIO */
dl (abortiofunc); /* AbortIO */
dl (0xFFFFFFFFul); /* end of table */
/* DataTable */
datatable = here ();
dw (0xE000); /* INITBYTE */
dw (0x0008); /* LN_TYPE */
dw (0x0300); /* NT_DEVICE */
dw (0xC000); /* INITLONG */
dw (0x000A); /* LN_NAME */
dl (ROM_scsidev_resname);
dw (0xE000); /* INITBYTE */
dw (0x000E); /* LIB_FLAGS */
dw (0x0600); /* LIBF_SUMUSED | LIBF_CHANGED */
dw (0xD000); /* INITWORD */
dw (0x0014); /* LIB_VERSION */
dw (0x0004); /* 0.4 */
dw (0xD000); /* INITWORD */
dw (0x0016); /* LIB_REVISION */
dw (0x0000);
dw (0xC000); /* INITLONG */
dw (0x0018); /* LIB_IDSTRING */
dl (ROM_scsidev_resid);
dw (0x0000); /* end of table */
dw (0xC000); /* INITLONG */
dw (0x0018); /* LIB_IDSTRING */
dl (ROM_scsidev_resid);
dw (0x0000); /* end of table */
ROM_scsidev_init = here ();
dl (0x00000100); /* size of device base */
dl (functable);
dl (datatable);
dl (initcode);
ROM_scsidev_init = here ();
dl (0x00000100); /* size of device base */
dl (functable);
dl (datatable);
dl (initcode);
nscmd_cmd = here ();
dw (NSCMD_DEVICEQUERY);
......@@ -1132,21 +1191,21 @@ void scsidev_install (void)
dw (NSCMD_TD_FORMAT64);
dw (0);
diskdev_install ();
diskdev_install ();
}
void scsidev_start_threads (void)
{
if (currprefs.scsi != 1) /* quite useless.. */
return;
if (log_scsi)
if (log_scsi)
write_log ("scsidev_start_threads()\n");
uae_sem_init (&change_sem, 0, 1);
uae_sem_init (&change_sem, 0, 1);
}
void scsidev_reset (void)
{
if (currprefs.scsi != 1)
return;
dev_reset ();
dev_reset ();
}
......@@ -4,7 +4,7 @@ running configure, to aid debugging if configure makes a mistake.
It was created by configure, which was
generated by GNU Autoconf 2.65. Invocation command line was
$ ./configure --disable-option-checking --prefix=/usr/local --with-sdl --with-sdl-gl --with-sdl-gfx --with-sdl-sound --with-caps --with-gayle --enable-drvsnd --enable-amax --enable-cd32 --enable-scsi-device --disable-jit --cache-file=/dev/null --srcdir=.
$ ./configure --disable-option-checking --prefix=/usr/local --with-sdl --with-sdl-gl --with-sdl-gfx --with-alsa --with-caps --with-gayle --enable-drvsnd --enable-amax --enable-cd32 --enable-scsi-device --cache-file=/dev/null --srcdir=.
## --------- ##
## Platform. ##
......@@ -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/ccLbz9UG.o: In function `main':
/tmp/cc4HIdmv.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/cc9bDtRS.o: In function `main':
/tmp/cc8gAlpK.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/ccXCfhuX.o: In function `main':
/tmp/ccuLVxdI.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
......
......@@ -438,7 +438,7 @@ $config_links
Report bugs to the package provider."
ac_cs_config="'--disable-option-checking' '--prefix=/usr/local' '--with-sdl' '--with-sdl-gl' '--with-sdl-gfx' '--with-sdl-sound' '--with-caps' '--with-gayle' '--enable-drvsnd' '--enable-amax' '--enable-cd32' '--enable-scsi-device' '--disable-jit' '--cache-file=/dev/null' '--srcdir=.'"
ac_cs_config="'--disable-option-checking' '--prefix=/usr/local' '--with-sdl' '--with-sdl-gl' '--with-sdl-gfx' '--with-alsa' '--with-caps' '--with-gayle' '--enable-drvsnd' '--enable-amax' '--enable-cd32' '--enable-scsi-device' '--cache-file=/dev/null' '--srcdir=.'"
ac_cs_version="\
config.status
configured by ./configure, generated by GNU Autoconf 2.65,
......@@ -522,7 +522,7 @@ if $ac_cs_silent; then
fi
if $ac_cs_recheck; then
set X '/bin/bash' './configure' '--disable-option-checking' '--prefix=/usr/local' '--with-sdl' '--with-sdl-gl' '--with-sdl-gfx' '--with-sdl-sound' '--with-caps' '--with-gayle' '--enable-drvsnd' '--enable-amax' '--enable-cd32' '--enable-scsi-device' '--disable-jit' '--cache-file=/dev/null' '--srcdir=.' $ac_configure_extra_args --no-create --no-recursion
set X '/bin/bash' './configure' '--disable-option-checking' '--prefix=/usr/local' '--with-sdl' '--with-sdl-gl' '--with-sdl-gfx' '--with-alsa' '--with-caps' '--with-gayle' '--enable-drvsnd' '--enable-amax' '--enable-cd32' '--enable-scsi-device' '--cache-file=/dev/null' '--srcdir=.' $ac_configure_extra_args --no-create --no-recursion
shift
$as_echo "running CONFIG_SHELL=/bin/bash $*" >&6
CONFIG_SHELL='/bin/bash'
......
......@@ -41,14 +41,14 @@ static uae_u32 emulib_GetVersion (void)
*/
static uae_u32 emulib_HardReset (void)
{
uae_reset(0);
return 0;
uae_reset(0);
return 0;
}
static uae_u32 emulib_Reset (void)
{
uae_reset(0);
return 0;
uae_reset(0);
return 0;
}
/*
......@@ -56,11 +56,11 @@ static uae_u32 emulib_Reset (void)
*/
static uae_u32 emulib_EnableSound (uae_u32 val)
{
if (!sound_available || currprefs.produce_sound == 2)
if (!sound_available || currprefs.produce_sound == 2)
return 0;
currprefs.produce_sound = val;
return 1;
currprefs.produce_sound = val;
return 1;
}
/*
......@@ -70,7 +70,7 @@ static uae_u32 emulib_EnableJoystick (uae_u32 val)
{
currprefs.jports[0].id = val & 255;
currprefs.jports[1].id = (val >> 8) & 255;
return 1;
return 1;
}
/*
......@@ -78,14 +78,14 @@ static uae_u32 emulib_EnableJoystick (uae_u32 val)
*/
static uae_u32 emulib_SetFrameRate (uae_u32 val)
{
if (val == 0)
if (val == 0)
return 0;
else if (val > 20)
else if (val > 20)
return 0;
else {
else {
currprefs.gfx_framerate = val;
return 1;
}
}
}
/*
......@@ -132,16 +132,16 @@ static uae_u32 emulib_ChangeLanguage (uae_u32 which)
*/
static uae_u32 REGPARAM2 emulib_ChgCMemSize (uae_u32 memsize)
{
if (memsize != 0x80000 && memsize != 0x100000 &&
if (memsize != 0x80000 && memsize != 0x100000 &&
memsize != 0x200000) {
memsize = 0x200000;
write_log ("Unsupported chipmem size!\n");
}
m68k_dreg (regs, 0) = 0;
}
m68k_dreg (regs, 0) = 0;
changed_prefs.chipmem_size = memsize;
uae_reset(0);
return 1;
uae_reset(0);
return 1;
}
/*
......@@ -150,16 +150,16 @@ static uae_u32 REGPARAM2 emulib_ChgCMemSize (uae_u32 memsize)
*/
static uae_u32 REGPARAM2 emulib_ChgSMemSize (uae_u32 memsize)
{
if (memsize != 0x80000 && memsize != 0x100000 &&
if (memsize != 0x80000 && memsize != 0x100000 &&
memsize != 0x180000 && memsize != 0x1C0000) {
memsize = 0;
write_log ("Unsupported bogomem size!\n");
}
}
m68k_dreg (regs, 0) = 0;
m68k_dreg (regs, 0) = 0;
changed_prefs.bogomem_size = memsize;
uae_reset (0);
return 1;
uae_reset (0);
return 1;
}
/*
......@@ -168,15 +168,15 @@ static uae_u32 REGPARAM2 emulib_ChgSMemSize (uae_u32 memsize)
*/
static uae_u32 REGPARAM2 emulib_ChgFMemSize (uae_u32 memsize)
{
if (memsize != 0x100000 && memsize != 0x200000 &&
if (memsize != 0x100000 && memsize != 0x200000 &&
memsize != 0x400000 && memsize != 0x800000) {
memsize = 0;
write_log ("Unsupported fastmem size!\n");
}
m68k_dreg (regs, 0) = 0;
}
m68k_dreg (regs, 0) = 0;
changed_prefs.fastmem_size = memsize;
uae_reset (0);
return 0;
uae_reset (0);
return 0;
}
/*
......@@ -184,21 +184,21 @@ static uae_u32 REGPARAM2 emulib_ChgFMemSize (uae_u32 memsize)
*/
static uae_u32 emulib_InsertDisk (uaecptr name, uae_u32 drive)
{
int i = 0;
char real_name[256];
int i = 0;
char real_name[256];
if (drive > 3)
if (drive > 3)
return 0;
while ((real_name[i] = get_byte (name + i)) != 0 && i++ != 254)
while ((real_name[i] = get_byte (name + i)) != 0 && i++ != 254)
;
if (i == 255)
if (i == 255)
return 0; /* ENAMETOOLONG */
strcpy (changed_prefs.df[drive], real_name);
return 1;
return 1;
}
/*
......@@ -206,8 +206,8 @@ static uae_u32 emulib_InsertDisk (uaecptr name, uae_u32 drive)
*/
static uae_u32 emulib_ExitEmu (void)
{
uae_quit ();
return 1;
uae_quit ();
return 1;
}
/*
......@@ -215,38 +215,38 @@ static uae_u32 emulib_ExitEmu (void)
*/
static uae_u32 emulib_GetUaeConfig (uaecptr place)
{
int i, j;
int i, j;
put_long (place, UAEVERSION);
put_long (place + 4, allocated_chipmem);
put_long (place + 8, allocated_bogomem);
put_long (place + 12, allocated_fastmem);
put_long (place + 16, currprefs.gfx_framerate);
put_long (place + 20, currprefs.produce_sound);
put_long (place + 4, allocated_chipmem);
put_long (place + 8, allocated_bogomem);
put_long (place + 12, allocated_fastmem);
put_long (place + 16, currprefs.gfx_framerate);
put_long (place + 20, currprefs.produce_sound);
put_long (place + 24, currprefs.jports[0].id | (currprefs.jports[1].id << 8));
put_long (place + 28, currprefs.keyboard_lang);
if (disk_empty (0))
put_long (place + 28, currprefs.keyboard_lang);
if (disk_empty (0))
put_byte (place + 32, 0);
else
else
put_byte (place + 32, 1);
if (disk_empty (1))
if (disk_empty (1))
put_byte (place + 33, 0);
else
else
put_byte (place + 33, 1);
if (disk_empty(2))
if (disk_empty(2))
put_byte (place + 34, 0);
else
else
put_byte (place + 34, 1);
if (disk_empty(3))
if (disk_empty(3))
put_byte (place + 35, 0);
else
else
put_byte (place + 35, 1);
for (j = 0; j < 4; j++) {
for (i = 0; i < 256; i++)
put_byte (place + 36 + i + j * 256, currprefs.df[j][i]);
}
return 1;
}
return 1;
}
/*
......@@ -256,7 +256,7 @@ static uae_u32 emulib_GetUaeConfig (uaecptr place)
*/
static uae_u32 emulib_SetUaeConfig (uaecptr place)
{
return 1;
return 1;
}
/*
......@@ -264,14 +264,14 @@ static uae_u32 emulib_SetUaeConfig (uaecptr place)
*/
static uae_u32 emulib_GetDisk (uae_u32 drive, uaecptr name)
{
int i;
if (drive > 3)
int i;
if (drive > 3)
return 0;
for (i = 0;i < 256; i++) {
for (i = 0;i < 256; i++) {
put_byte (name + i, currprefs.df[drive][i]);
}
return 1;
}
return 1;
}
/*
......@@ -280,16 +280,16 @@ static uae_u32 emulib_GetDisk (uae_u32 drive, uaecptr name)
static uae_u32 emulib_Debug (void)
{
#ifdef DEBUGGER
activate_debugger ();
return 1;
activate_debugger ();
return 1;
#else
return 0;
return 0;
#endif
}
#define CREATE_NATIVE_FUNC_PTR uae_u32 (* native_func)( uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, \
uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32)
#define CREATE_NATIVE_FUNC_PTR uae_u32 (* native_func) (uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, \
uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32)
#define SET_NATIVE_FUNC(x) native_func = (uae_u32 (*)(uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32))(x)
#define CALL_NATIVE_FUNC( d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6 ) if(native_func) native_func( d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6 )
/* A0 - Contains a ptr to the native .obj data. This ptr is Amiga-based. */
......@@ -297,39 +297,39 @@ static uae_u32 emulib_Debug (void)
static uae_u32 REGPARAM2 emulib_ExecuteNativeCode (void)
{
#if 0
uaecptr object_AAM = m68k_areg (regs, 0);
uae_u32 d1 = m68k_dreg (regs, 1);
uae_u32 d2 = m68k_dreg (regs, 2);
uae_u32 d3 = m68k_dreg (regs, 3);
uae_u32 d4 = m68k_dreg (regs, 4);
uae_u32 d5 = m68k_dreg (regs, 5);
uae_u32 d6 = m68k_dreg (regs, 6);
uae_u32 d7 = m68k_dreg (regs, 7);
uae_u32 a1 = m68k_areg (regs, 1);
uae_u32 a2 = m68k_areg (regs, 2);
uae_u32 a3 = m68k_areg (regs, 3);
uae_u32 a4 = m68k_areg (regs, 4);
uae_u32 a5 = m68k_areg (regs, 5);
uae_u32 a6 = m68k_areg (regs, 6);
uae_u8* object_UAM = NULL;
CREATE_NATIVE_FUNC_PTR;
if( get_mem_bank( object_AAM ).check( object_AAM, 1 ) )
object_UAM = get_mem_bank( object_AAM).xlateaddr( object_AAM );
uaecptr object_AAM = m68k_areg (regs, 0);
uae_u32 d1 = m68k_dreg (regs, 1);
uae_u32 d2 = m68k_dreg (regs, 2);
uae_u32 d3 = m68k_dreg (regs, 3);
uae_u32 d4 = m68k_dreg (regs, 4);
uae_u32 d5 = m68k_dreg (regs, 5);
uae_u32 d6 = m68k_dreg (regs, 6);
uae_u32 d7 = m68k_dreg (regs, 7);
uae_u32 a1 = m68k_areg (regs, 1);
uae_u32 a2 = m68k_areg (regs, 2);
uae_u32 a3 = m68k_areg (regs, 3);
uae_u32 a4 = m68k_areg (regs, 4);
uae_u32 a5 = m68k_areg (regs, 5);
uae_u32 a6 = m68k_areg (regs, 6);
uae_u8* object_UAM = NULL;
CREATE_NATIVE_FUNC_PTR;
if (get_mem_bank(object_AAM).check (object_AAM, 1))
object_UAM = get_mem_bank (object_AAM).xlateaddr (object_AAM);
if (object_UAM) {
SET_NATIVE_FUNC( FindFunctionInObject( object_UAM ) );
CALL_NATIVE_FUNC( d1, d2, d3, d4, d5, d6, d7, a1, a2, a3, a4, a5, a6);
}
return 1;
SET_NATIVE_FUNC (FindFunctionInObject (object_UAM));
CALL_NATIVE_FUNC (d1, d2, d3, d4, d5, d6, d7, a1, a2, a3, a4, a5, a6);
}
return 1;
#endif
return 0;
return 0;
}
static uae_u32 emulib_Minimize (void)
{
return 0; // OSDEP_minimize_uae();
return 0; // OSDEP_minimize_uae();
}
static int native_dos_op (uae_u32 mode, uae_u32 p1, uae_u32 p2, uae_u32 p3)
......@@ -369,7 +369,7 @@ static uae_u32 REGPARAM2 uaelib_demux2 (TrapContext *context)
// return picasso_demux (ARG0, context);
#endif
switch (ARG0)
switch (ARG0)
{
case 0: return emulib_GetVersion ();
case 1: return emulib_GetUaeConfig (ARG1);
......@@ -414,8 +414,8 @@ static uae_u32 REGPARAM2 uaelib_demux2 (TrapContext *context)
return d0;
}
}
return 0;
}
return 0;
}
int uaelib_debug;
......@@ -458,6 +458,6 @@ void emulib_install (void)
dw (get_word (rtarea_base + 38) + 12);
#endif
calltrap (deftrapres (uaelib_demux, 0, "uaelib_demux"));
dw (RTS);
org (a);
dw (RTS);
org (a);
}
/*
* UAE - The Un*x Amiga Emulator
*
* routines to handle compressed file automatically
*
* (c) 1996 Samuel Devulder, Tim Gunn
* 2002-2007 Toni Wilen
*/
/*
* UAE - The Un*x Amiga Emulator
*
* routines to handle compressed file automatically
*
* (c) 1996 Samuel Devulder, Tim Gunn
* 2002-2007 Toni Wilen
*/
#define ZLIB_WINAPI
#define RECURSIVE_ARCHIVES 1
......@@ -152,29 +152,29 @@ static struct zcache *zcache_put (const TCHAR *name, struct zdiskimage *data)
static struct zfile *zfile_create (struct zfile *prev)
{
struct zfile *z;
struct zfile *z;
z = xmalloc (struct zfile, 1);
if (!z)
if (!z)
return 0;
memset (z, 0, sizeof *z);
z->next = zlist;
zlist = z;
memset (z, 0, sizeof *z);
z->next = zlist;
zlist = z;
z->opencnt = 1;
if (prev) {
z->zfdmask = prev->zfdmask;
}
return z;
return z;
}
static void zfile_free (struct zfile *f)
{
if (f->f)
if (f->f)
fclose (f->f);
if (f->deleteafterclose) {
if (f->deleteafterclose) {
_wunlink (f->name);
write_log ("deleted temporary file '%s'\n", f->name);
}
}
xfree (f->name);
xfree (f->data);
xfree (f->mode);
......@@ -184,22 +184,22 @@ static void zfile_free (struct zfile *f)
void zfile_exit (void)
{
struct zfile *l;
while ((l = zlist)) {
struct zfile *l;
while ((l = zlist)) {
zlist = l->next;
zfile_free (l);
}
}
}
void zfile_fclose (struct zfile *f)
{
struct zfile *pl = NULL;
struct zfile *l = zlist;
struct zfile *nxt;
struct zfile *pl = NULL;
struct zfile *l = zlist;
struct zfile *nxt;
//write_log ("%p\n", f);
if (!f)
return;
if (!f)
return;
if (f->opencnt < 0) {
write_log ("zfile: tried to free already closed filehandle!\n");
return;
......@@ -213,22 +213,22 @@ void zfile_fclose (struct zfile *f)
if (f->parent->opencnt <= 0)
zfile_fclose (f->parent);
}
while (l != f) {
while (l != f) {
if (l == 0) {
write_log ("zfile: tried to free already freed or nonexisting filehandle!\n");
return;
return;
}
pl = l;
l = l->next;
}
}
if (l)
nxt = l->next;
zfile_free (f);
if (l == 0)
zfile_free (f);
if (l == 0)
return;
if(!pl)
if(!pl)
zlist = nxt;
else
else
pl->next = nxt;
}
......@@ -240,43 +240,43 @@ static void removeext (TCHAR *s, TCHAR *ext)
s[_tcslen (s) - _tcslen (ext)] = 0;
}
static uae_u8 exeheader[]={0x00,0x00,0x03,0xf3,0x00,0x00,0x00,0x00};
static uae_u8 exeheader[]={ 0x00,0x00,0x03,0xf3,0x00,0x00,0x00,0x00 };
static TCHAR *diskimages[] = { "adf", "adz", "ipf", "fdi", "dms", "wrp", "dsq", 0 };
int zfile_gettype (struct zfile *z)
{
uae_u8 buf[8];
uae_u8 buf[8];
TCHAR *ext;
if (!z || !z->name)
return ZFILE_UNKNOWN;
ext = _tcsrchr (z->name, '.');
if (ext != NULL) {
if (ext != NULL) {
int i;
ext++;
for (i = 0; diskimages[i]; i++) {
if (strcasecmp (ext, diskimages[i]) == 0)
return ZFILE_DISKIMAGE;
return ZFILE_DISKIMAGE;
}
if (strcasecmp (ext, "roz") == 0)
return ZFILE_ROM;
return ZFILE_ROM;
if (strcasecmp (ext, "uss") == 0)
return ZFILE_STATEFILE;
return ZFILE_STATEFILE;
if (strcasecmp (ext, "rom") == 0)
return ZFILE_ROM;
return ZFILE_ROM;
if (strcasecmp (ext, "key") == 0)
return ZFILE_KEY;
return ZFILE_KEY;
if (strcasecmp (ext, "nvr") == 0)
return ZFILE_NVR;
return ZFILE_NVR;
if (strcasecmp (ext, "uae") == 0)
return ZFILE_CONFIGURATION;
return ZFILE_CONFIGURATION;
if (strcasecmp (ext, "cue") == 0 || strcasecmp (ext, "iso") == 0)
return ZFILE_CDIMAGE;
}
memset (buf, 0, sizeof (buf));
zfile_fread (buf, 8, 1, z);
zfile_fseek (z, -8, SEEK_CUR);
if (!memcmp (buf, exeheader, sizeof(buf)))
}
memset (buf, 0, sizeof (buf));
zfile_fread (buf, 8, 1, z);
zfile_fseek (z, -8, SEEK_CUR);
if (!memcmp (buf, exeheader, sizeof (buf)))
return ZFILE_DISKIMAGE;
if (!memcmp (buf, "RDSK", 4))
return ZFILE_HDFRDB;
......@@ -292,7 +292,7 @@ int zfile_gettype (struct zfile *z)
if (strcasecmp (ext, "hdz") == 0)
return ZFILE_HDF;
}
return ZFILE_UNKNOWN;
return ZFILE_UNKNOWN;
}
#define VHD_DYNAMIC 3
......@@ -501,35 +501,35 @@ end:
struct zfile *zfile_gunzip (struct zfile *z)
{
uae_u8 header[2 + 1 + 1 + 4 + 1 + 1];
z_stream zs;
int i, size, ret, first;
uae_u8 flags;
uae_u8 header[2 + 1 + 1 + 4 + 1 + 1];
z_stream zs;
int i, size, ret, first;
uae_u8 flags;
uae_s64 offset;
TCHAR name[MAX_DPATH];
uae_u8 buffer[8192];
struct zfile *z2;
uae_u8 b;
uae_u8 buffer[8192];
struct zfile *z2;
uae_u8 b;
_tcscpy (name, z->name);
memset (&zs, 0, sizeof (zs));
memset (header, 0, sizeof (header));
zfile_fread (header, sizeof (header), 1, z);
flags = header[3];
if (header[0] != 0x1f && header[1] != 0x8b)
memset (&zs, 0, sizeof (zs));
memset (header, 0, sizeof (header));
zfile_fread (header, sizeof (header), 1, z);
flags = header[3];
if (header[0] != 0x1f && header[1] != 0x8b)
return NULL;
if (flags & 2) /* multipart not supported */
if (flags & 2) /* multipart not supported */
return NULL;
if (flags & 32) /* encryption not supported */
if (flags & 32) /* encryption not supported */
return NULL;
if (flags & 4) { /* skip extra field */
if (flags & 4) { /* skip extra field */
zfile_fread (&b, 1, 1, z);
size = b;
zfile_fread (&b, 1, 1, z);
size |= b << 8;
zfile_fseek (z, size + 2, SEEK_CUR);
}
if (flags & 8) { /* get original file name */
}
if (flags & 8) { /* get original file name */
uae_char aname[MAX_DPATH];
i = 0;
do {
......@@ -537,51 +537,51 @@ struct zfile *zfile_gunzip (struct zfile *z)
} while (i < MAX_DPATH - 1 && aname[i++]);
aname[i] = 0;
memcpy (name, aname, MAX_DPATH);
}
if (flags & 16) { /* skip comment */
}
if (flags & 16) { /* skip comment */
i = 0;
do {
b = 0;
zfile_fread (&b, 1, 1, z);
zfile_fread (&b, 1, 1, z);
} while (b);
}
}
removeext (name, ".gz");
offset = zfile_ftell (z);
zfile_fseek (z, -4, SEEK_END);
zfile_fread (&b, 1, 1, z);
size = b;
zfile_fread (&b, 1, 1, z);
size |= b << 8;
zfile_fread (&b, 1, 1, z);
size |= b << 16;
zfile_fread (&b, 1, 1, z);
size |= b << 24;
offset = zfile_ftell (z);
zfile_fseek (z, -4, SEEK_END);
zfile_fread (&b, 1, 1, z);
size = b;
zfile_fread (&b, 1, 1, z);
size |= b << 8;
zfile_fread (&b, 1, 1, z);
size |= b << 16;
zfile_fread (&b, 1, 1, z);
size |= b << 24;
if (size < 8 || size > 256 * 1024 * 1024) /* safety check */
return NULL;
zfile_fseek (z, offset, SEEK_SET);
z2 = zfile_fopen_empty (z, name, size);
if (!z2)
zfile_fseek (z, offset, SEEK_SET);
z2 = zfile_fopen_empty (z, name, size);
if (!z2)
return NULL;
zs.next_out = z2->data;
zs.avail_out = size;
first = 1;
do {
zs.next_out = z2->data;
zs.avail_out = size;
first = 1;
do {
zs.next_in = buffer;
zs.avail_in = zfile_fread (buffer, 1, sizeof (buffer), z);
if (first) {
if (inflateInit2 (&zs, -MAX_WBITS) != Z_OK)
break;
first = 0;
first = 0;
}
ret = inflate (&zs, 0);
} while (ret == Z_OK);
inflateEnd (&zs);
if (ret != Z_STREAM_END || first != 0) {
} while (ret == Z_OK);
inflateEnd (&zs);
if (ret != Z_STREAM_END || first != 0) {
zfile_fclose (z2);
return NULL;
}
zfile_fclose (z);
return z2;
}
zfile_fclose (z);
return z2;
}
static void truncate880k (struct zfile *z)
......@@ -1046,8 +1046,8 @@ static struct zfile *lha (struct zfile *z)
static struct zfile *dms (struct zfile *z, int index, int *retcode)
{
int ret;
struct zfile *zo;
int ret;
struct zfile *zo;
TCHAR *orgname = zfile_getname (z);
TCHAR *ext = _tcsrchr (orgname, '.');
TCHAR newname[MAX_DPATH];
......@@ -1065,10 +1065,10 @@ static struct zfile *dms (struct zfile *z, int index, int *retcode)
}
zo = zfile_fopen_empty (z, newname, 1760 * 512);
if (!zo)
if (!zo)
return NULL;
ret = DMS_Process_File (z, zo, CMD_UNPACK, OPT_VERBOSE, 0, 0, 0, zextra);
if (ret == NO_PROBLEM || ret == DMS_FILE_END) {
ret = DMS_Process_File (z, zo, CMD_UNPACK, OPT_VERBOSE, 0, 0, 0, zextra);
if (ret == NO_PROBLEM || ret == DMS_FILE_END) {
int off = zfile_ftell (zo);
if (off >= 1760 * 512 / 3 && off <= 1760 * 512 * 3 / 4) { // possible split dms?
if (_tcslen (orgname) > 5) {
......@@ -1100,7 +1100,7 @@ static struct zfile *dms (struct zfile *z, int index, int *retcode)
}
if (retcode)
*retcode = 1;
zfile_fclose (z);
zfile_fclose (z);
z = NULL;
} else {
......@@ -1401,38 +1401,38 @@ static FILE *openzip (char *name, char *zippath)
#ifdef SINGLEFILE
extern uae_u8 singlefile_data[];
static struct zfile *zfile_opensinglefile (struct zfile *l)
static struct zfile *zfile_opensinglefile(struct zfile *l)
{
uae_u8 *p = singlefile_data;
int size, offset;
uae_u8 *p = singlefile_data;
int size, offset;
TCHAR tmp[256], *s;
_tcscpy (tmp, l->name);
s = tmp + _tcslen (tmp) - 1;
while (*s != 0 && *s != '/' && *s != '\\')
s--;
if (s > tmp)
if (s > tmp)
s++;
write_log ("loading from singlefile: '%s'\n", tmp);
while (*p++);
offset = (p[0] << 24)|(p[1] << 16)|(p[2] << 8)|(p[3] << 0);
p += 4;
for (;;) {
while (*p++);
offset = (p[0] << 24)|(p[1] << 16)|(p[2] << 8)|(p[3] << 0);
p += 4;
for (;;) {
size = (p[0] << 24)|(p[1] << 16)|(p[2] << 8)|(p[3] << 0);
if (!size)
break;
break;
if (!strcmpi (tmp, p + 4)) {
l->data = singlefile_data + offset;
l->size = size;
l->data = singlefile_data + offset;
l->size = size;
write_log ("found, size %d\n", size);
return l;
return l;
}
offset += size;
p += 4;
p += _tcslen (p) + 1;
}
}
write_log ("not found\n");
return 0;
return 0;
}
#endif
......@@ -1441,38 +1441,38 @@ static struct zfile *zfile_opensinglefile (struct zfile *l)
*/
struct zfile *zfile_fopen (const char *name, const char *mode, int mask)
{
struct zfile *l;
FILE *f;
struct zfile *l;
FILE *f;
char zipname[1000];
if( *name == '\0' )
if(*name == '\0')
return NULL;
l = zfile_create (NULL);
l = zfile_create (NULL);
l->name = strdup (name);
l->mode = strdup (mode);
#ifdef SINGLEFILE
if (zfile_opensinglefile (l))
if (zfile_opensinglefile (l))
return l;
#endif
f = openzip (l->name, zipname);
if (f) {
if (_tcsicmp (mode, "rb")) {
zfile_fclose (l);
zfile_fclose (l);
fclose (f);
return 0;
return 0;
}
l->zipname = strdup (zipname);
}
if (!f) {
f = fopen (name, mode);
if (!f) {
zfile_fclose (l);
return 0;
zfile_fclose (l);
return 0;
}
}
l->f = f;
l->f = f;
l = zuncompress (l);
return l;
return l;
}
int zfile_exists (const TCHAR *name)
......@@ -1490,13 +1490,13 @@ int zfile_exists (const TCHAR *name)
int zfile_iscompressed (struct zfile *z)
{
return z->data ? 1 : 0;
return z->data ? 1 : 0;
}
struct zfile *zfile_fopen_empty (struct zfile *prev, const TCHAR *name, uae_u64 size)
{
struct zfile *l;
l = zfile_create (prev);
struct zfile *l;
l = zfile_create (prev);
l->name = name ? my_strdup (name) : "";
if (size) {
l->data = xcalloc (uae_u8, size);
......@@ -1510,7 +1510,7 @@ struct zfile *zfile_fopen_empty (struct zfile *prev, const TCHAR *name, uae_u64
l->data = xcalloc (uae_u8, 1);
l->size = 0;
}
return l;
return l;
}
struct zfile *zfile_fopen_parent (struct zfile *z, const TCHAR *name, uae_u64 offset, uae_u64 size)
......@@ -1573,13 +1573,13 @@ uae_s64 zfile_fseek (struct zfile *z, uae_s64 offset, int mode)
int ret = 0;
switch (mode)
{
case SEEK_SET:
case SEEK_SET:
z->seek = offset;
break;
case SEEK_CUR:
case SEEK_CUR:
z->seek += offset;
break;
case SEEK_END:
case SEEK_END:
z->seek = z->size + offset;
break;
}
......@@ -1594,7 +1594,7 @@ uae_s64 zfile_fseek (struct zfile *z, uae_s64 offset, int mode)
return ret;
} else {
return fseek (z->f, offset, mode);
}
}
return 1;
}
......@@ -1602,7 +1602,7 @@ size_t zfile_fread (void *b, size_t l1, size_t l2, struct zfile *z)
{
if (z->zfileread)
return z->zfileread (b, l1, l2, z);
if (z->data) {
if (z->data) {
if (z->datasize < z->size && z->seek + l1 * l2 > z->datasize) {
write_log ("zfile_fread(%s) attempted to read past PEEK_BYTES\n", z->name);
......@@ -1619,7 +1619,7 @@ size_t zfile_fread (void *b, size_t l1, size_t l2, struct zfile *z)
memcpy (b, z->data + z->offset + z->seek, l1 * l2);
z->seek += l1 * l2;
return l2;
}
}
if (z->parent && z->useparent) {
size_t ret;
uae_s64 v;
......@@ -1648,7 +1648,7 @@ size_t zfile_fwrite (const void *b, size_t l1, size_t l2, struct zfile *z)
return z->zfilewrite (b, l1, l2, z);
if (z->parent && z->useparent)
return 0;
if (z->data) {
if (z->data) {
int off = z->seek + l1 * l2;
if (off > z->size) {
z->data = xrealloc (uae_u8, z->data, off);
......@@ -1657,8 +1657,8 @@ size_t zfile_fwrite (const void *b, size_t l1, size_t l2, struct zfile *z)
memcpy (z->data + z->seek, b, l1 * l2);
z->seek += l1 * l2;
return l2;
}
return fwrite (b, l1, l2, z->f);
}
return fwrite (b, l1, l2, z->f);
}
size_t zfile_fputs (struct zfile *z, TCHAR *s)
......@@ -1777,56 +1777,56 @@ uae_u8 *zfile_getdata (struct zfile *z, uae_s64 offset, int len)
int zfile_zuncompress (void *dst, int dstsize, struct zfile *src, int srcsize)
{
z_stream zs;
int v;
uae_u8 inbuf[4096];
int incnt;
z_stream zs;
int v;
uae_u8 inbuf[4096];
int incnt;
memset (&zs, 0, sizeof(zs));
memset (&zs, 0, sizeof(zs));
if (inflateInit (&zs) != Z_OK)
return 0;
zs.next_out = (Bytef*)dst;
zs.avail_out = dstsize;
incnt = 0;
v = Z_OK;
while (v == Z_OK && zs.avail_out > 0) {
zs.avail_out = dstsize;
incnt = 0;
v = Z_OK;
while (v == Z_OK && zs.avail_out > 0) {
if (zs.avail_in == 0) {
int left = srcsize - incnt;
if (left == 0)
int left = srcsize - incnt;
if (left == 0)
break;
if (left > sizeof (inbuf))
left = sizeof (inbuf);
zs.next_in = inbuf;
zs.avail_in = zfile_fread (inbuf, 1, left, src);
incnt += left;
zs.next_in = inbuf;
zs.avail_in = zfile_fread (inbuf, 1, left, src);
incnt += left;
}
v = inflate (&zs, 0);
}
inflateEnd (&zs);
return 0;
}
inflateEnd (&zs);
return 0;
}
int zfile_zcompress (struct zfile *f, void *src, int size)
{
int v;
z_stream zs;
uae_u8 outbuf[4096];
int v;
z_stream zs;
uae_u8 outbuf[4096];
memset (&zs, 0, sizeof (zs));
memset (&zs, 0, sizeof (zs));
if (deflateInit (&zs, Z_DEFAULT_COMPRESSION) != Z_OK)
return 0;
zs.next_in = (Bytef*)src;
zs.avail_in = size;
v = Z_OK;
while (v == Z_OK) {
zs.avail_in = size;
v = Z_OK;
while (v == Z_OK) {
zs.next_out = outbuf;
zs.avail_out = sizeof (outbuf);
v = deflate(&zs, Z_NO_FLUSH | Z_FINISH);
if (sizeof(outbuf) - zs.avail_out > 0)
zfile_fwrite (outbuf, 1, sizeof (outbuf) - zs.avail_out, f);
}
deflateEnd (&zs);
return zs.total_out;
v = deflate (&zs, Z_NO_FLUSH | Z_FINISH);
if (sizeof (outbuf) - zs.avail_out > 0)
zfile_fwrite (outbuf, 1, sizeof (outbuf) - zs.avail_out, f);
}
deflateEnd (&zs);
return zs.total_out;
}
TCHAR *zfile_getname (struct zfile *f)
......@@ -1850,27 +1850,27 @@ TCHAR *zfile_getfilename (struct zfile *f)
uae_u32 zfile_crc32 (struct zfile *f)
{
uae_u8 *p;
int pos, size;
uae_u32 crc;
uae_u8 *p;
int pos, size;
uae_u32 crc;
if (!f)
if (!f)
return 0;
if (f->data)
if (f->data)
return get_crc32 (f->data, f->size);
pos = zfile_ftell (f);
zfile_fseek (f, 0, SEEK_END);
size = zfile_ftell (f);
pos = zfile_ftell (f);
zfile_fseek (f, 0, SEEK_END);
size = zfile_ftell (f);
p = xmalloc (uae_u8, size);
if (!p)
if (!p)
return 0;
memset (p, 0, size);
zfile_fseek (f, 0, SEEK_SET);
zfile_fread (p, 1, size, f);
zfile_fseek (f, pos, SEEK_SET);
crc = get_crc32 (p, size);
memset (p, 0, size);
zfile_fseek (f, 0, SEEK_SET);
zfile_fread (p, 1, size, f);
zfile_fseek (f, pos, SEEK_SET);
crc = get_crc32 (p, size);
xfree (p);
return crc;
return crc;
}
#ifdef _CONSOLE
......
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