puae 2.6.0

This commit is contained in:
Mustafa Tufan 2013-01-17 16:11:07 +02:00
parent 4b2fe8dc76
commit 212f1388ac
119 changed files with 4726 additions and 10031 deletions

135
.gitignore vendored
View File

@ -1,109 +1,68 @@
.gitignore
# .gitignore
# Editor backup files
*~
*.bak
*.old
*.rej
*.ori
# Build chain generated files
.deps
*.a
*.o
*.Po
# Autoconf generated files
*.scan
autoscan*
Makefile
Makefile.am.*
config.*
Makefile.in
aclocal.m4
autom4te.cache/
autom4te.cache
configure
src/Makefile.in
src/archivers/dms/Makefile.in
src/archivers/zip/Makefile.in
src/caps/Makefile.in
src/gfx-amigaos/Makefile.in
src/gfx-beos/Makefile.in
src/gfx-cocoa/Makefile.in
src/gfx-curses/Makefile.in
src/gfx-sdl/Makefile.in
src/gfx-x11/Makefile.in
src/gui-beos/Makefile.in
src/gui-cocoa/Makefile.in
src/gui-gtk/Makefile.in
src/gui-muirexx/Makefile.in
src/gui-none/Makefile.in
src/gui-qt/Makefile.in
src/jd-amigainput/Makefile.in
src/jd-amigaos/Makefile.in
src/jd-beos/Makefile.in
src/jd-linuxold/Makefile.in
src/jd-none/Makefile.in
src/jd-sdl/Makefile.in
src/keymap/Makefile.in
src/md-68k/Makefile.in
src/md-amd64-gcc/Makefile.in
src/md-generic/Makefile.in
src/md-i386-gcc/Makefile.in
src/md-ppc-gcc/Makefile.in
src/md-ppc/Makefile.in
src/od-amiga/Makefile.in
src/od-beos/Makefile.in
src/od-generic/Makefile.in
src/od-linux/Makefile.in
src/od-macosx/Makefile.in
src/od-win32/Makefile.in
src/sd-alsa/Makefile.in
src/sd-amigaos/Makefile.in
src/sd-beos/Makefile.in
src/sd-none/Makefile.in
src/sd-sdl/Makefile.in
src/sd-solaris/Makefile.in
src/sd-uss/Makefile.in
src/td-amigaos/Makefile.in
src/td-beos/Makefile.in
src/td-none/Makefile.in
src/td-posix/Makefile.in
src/td-sdl/Makefile.in
src/td-win32/Makefile.in
src/test/Makefile.in
src/tools/autom4te.cache/
src/tools/configure
src/tools/blitops.c
src/tools/build68k.c
src/tools/genblitter.c
src/tools/gencomp.c
src/tools/gencpu.c
src/tools/genlinetoscr.c
src/tools/missing.c
src/tools/readcpu.c
src/tools/sysconfig.h
src/tools/writelog.c
Makefile.in
sysconfig.h
src/*dep
# The tools folder has mostly autogenerated files
src/tools/
!src/tools/Makefile.in
!src/tools/configure.ac
!src/tools/sysconfig.h.in
!src/tools/target.h
# Generated Emulator source and header files
src/md-fpp.h
src/od-macosx/Credits.rtf
src/od-macosx/Info.plist
src/sysconfig.h
src/target.h
src/blit.h
src/blitfunc.c
src/blitfunc.h
src/blittable.c
src/compemu.c
src/compstbl.c
src/comptbl.h
src/cpudefs.c
src/cpuemu_*.c
src/cpuemu_11.c
src/cpuemu_12.c
src/cpustbl.c
src/cputbl.h
src/blit*
src/comp*
src/cpu*
src/linetoscr.c
src/tools/build68k
src/tools/cpudefs.c
src/tools/genblitter
src/tools/gencomp
src/tools/gencpu
src/tools/genlinetoscr
# Executables
src/make_hdf
src/readdisk
src/uae
# Unwanted files that are not ready yet or temporary
src/od-macosx/Credits.rtf
src/od-macosx/Info.plist
config_.sh
cfg_*.log
*_template.txt
# Files generated by automoc and other qt related stuff:
moc_*.cpp
ui_puae_*.h
src/gui-qt/*.pro.user.*
ui_puae_mainwindow.h
# Eclipse CDT files
.autotools
.*project
# Code::Blocks files
*.workspace
*.depend
*.cbp
*.layout

View File

@ -372,9 +372,6 @@ case $host_os in
HOST_OS=aros
OSDEP=od-amiga
;;
mingw32*)
HOST_OS=win32
OSDEP=od-win32
esac
AC_MSG_RESULT([$HOST_OS])
@ -566,6 +563,7 @@ WANT_CDTV=dunno
WANT_BSDSOCK=dunno
WANT_UI=dunno
WANT_AUDIO=dunno
WANT_MMU=yes
WANT_FPU=yes
WANT_COMPATIBLE=yes
WANT_CYCLEEXACT=yes
@ -625,22 +623,14 @@ else if [[ "$OSDEP" = "od-amiga" ]]; then
JOY_NAME="Amiga lowlevel.library"
fi
WANT_BSDSOCK=no
else if [[ "$OSDEP" = "od-win32" ]]; then
TARGET=win32
TARGETDEP=t-win32.h
WANT_BSDSOCK=no
fi
fi
fi
fi
dnl
dnl Win32 build has its own writelog.c
dnl writelog is needed almost everywhere
dnl
if [[ "$OSDEP" != "od-win32" ]]; then
EXTRAOBJS='writelog.$(OBJEXT)'
fi
EXTRAOBJS='writelog.$(OBJEXT)'
dnl
dnl Options
@ -670,6 +660,7 @@ AC_ARG_ENABLE(gccopt, AS_HELP_STRING([--enable-gccopt], [Enable
AC_ARG_ENABLE(gccdebug, AS_HELP_STRING([--enable-gccdebug], [Enable gcc debugging options (default no)]), [WANT_GGDB=$enableval],[])
AC_ARG_ENABLE(jit, AS_HELP_STRING([--enable-jit], [Enable JIT compiler (currently x86 only)]), [WANT_JIT=$enableval],[])
AC_ARG_ENABLE(profiling, AS_HELP_STRING([--enable-profiling], [Build a profiling (SLOW!) version]), [DO_PROFILING=$enableval],[])
AC_ARG_ENABLE(mmu, AS_HELP_STRING([--enable-mmu], [Enable MMU emulation (default yes)]), [WANT_MMU=$enableval],[])
AC_ARG_ENABLE(natmem, AS_HELP_STRING([--enable-natmem], [Enable JIT direct memory support (default auto)]), [NATMEM=$enableval],[])
AC_ARG_ENABLE(noflags, AS_HELP_STRING([--enable-noflags], [Enable noflags support in JIT (default no)]), [NOFLAGS=$enableval],[])
AC_ARG_ENABLE(ncr, AS_HELP_STRING([--enable-ncr], [Enable NCR SCSI emulation (default no)]), [WANT_NCR=$enableval],[])
@ -915,10 +906,12 @@ fi
dnl
dnl CPUEMU_31: 68040 Aranym MMU
dnl CPUEMU_32: Previous 68030 MMU
dnl CPUEMU_33: 68060 MMU
dnl
dnl if [[ "x$WANT_MMU" != "xno" ]]; then
UAE_DEFINES="$UAE_DEFINES -DCPUEMU_31 -DMMU"
CPUOBJS="$CPUOBJS cpuemu_31.\$(OBJEXT) cpummu.\$(OBJEXT)"
UAE_DEFINES="$UAE_DEFINES -DCPUEMU_31 -DCPUEMU_32 -DCPUEMU_33 -DMMUEMU -DFULLMMU"
CPUOBJS="$CPUOBJS cpuemu_31.\$(OBJEXT) cpuemu_32.\$(OBJEXT) cpuemu_33.\$(OBJEXT) cpummu.\$(OBJEXT) cpummu30.\$(OBJEXT)"
dnl fi
if [[ "x$WANT_FPU" != "xno" ]]; then
@ -1404,10 +1397,10 @@ if [[ "x$WANT_AUTOCONFIG" != "xno" ]]; then
dnl Configure hard disk emulation
UAE_DEFINES="$UAE_DEFINES -DFILESYS"
NEED_THREAD_SUPPORT=yes
FILESYSOBJS='filesys.$(OBJEXT) fsdb.$(OBJEXT) fsusage.$(OBJEXT) hardfile.$(OBJEXT)'
if [[ "x$HOST_OS" != "xwin32" ]]; then
FILESYSOBJS="$FILESYSOBJS filesys_unix.\$(OBJEXT) fsdb_unix.\$(OBJEXT) hardfile_unix.\$(OBJEXT)"
fi
FILESYSOBJS="filesys.\$(OBJEXT) fsdb.\$(OBJEXT) fsusage.\$(OBJEXT) \
hardfile.\$(OBJEXT) filesys_unix.\$(OBJEXT) fsdb_unix.\$(OBJEXT) \
hardfile_unix.\$(OBJEXT)"
dnl Filesys support currently requires threads, because hardfile
dnl support requires threads and we can't currently separate the
dnl two.
@ -2088,7 +2081,7 @@ UAE_CFLAGS="$OPTIMIZED_FLAGS $UAE_CFLAGS $GUI_CFLAGS $GFX_CFLAGS $SND_CFLAGS $JO
if [[ "x$HAVE_GCC47" = "xyes" ]]; then
UAE_CXXFLAGS="$UAE_CXXFLAGS $UAE_CFLAGS -std=c++11"
else
UAE_CXXFLAGS="$UAE_CXXFLAGS $UAE_CFLAGS"
UAE_CXXFLAGS="$UAE_CXXFLAGS $UAE_CFLAGS -std=c++98"
fi
UAE_CFLAGS="$UAE_CFLAGS -std=c99"
@ -2121,13 +2114,11 @@ AC_CONFIG_FILES([Makefile
src/od-macosx/Makefile
src/od-macosx/Info.plist
src/od-macosx/Credits.rtf
src/od-win32/Makefile
src/td-none/Makefile
src/td-amigaos/Makefile
src/td-beos/Makefile
src/td-posix/Makefile
src/td-sdl/Makefile
src/td-win32/Makefile
src/gfx-amigaos/Makefile
src/gfx-beos/Makefile
src/gfx-x11/Makefile
@ -2160,7 +2151,6 @@ AC_CONFIG_FILES([Makefile
AM_CONDITIONAL(TARGET_BIGENDIAN, test x$ac_cv_c_bigendian = xyes)
AM_CONDITIONAL(TARGET_BEOS, test x$OSDEP = xod-beos)
AM_CONDITIONAL(TARGET_WIN32, test x$OSDEP = xod-win32)
AM_CONDITIONAL(TARGET_LINUX, test x$OSDEP = xod-linux)
AM_CONDITIONAL(BUILD_MACOSX_BUNDLE, test x$OSDEP = xod-macosx)
AM_CONDITIONAL(ANDROID, test x$WANT_ANDROID = xyes)

View File

@ -1,6 +1,6 @@
# P-UAE
#
# 2006-2011 Mustafa TUFAN
# 2006-2013 Mustafa TUFAN
#
# this script cleans up various files so that we don't push unnecessary files to git..
#
@ -74,7 +74,6 @@ rm -rf src/od-linux/Makefile.in
rm -rf src/od-macosx/Makefile.in
rm -rf src/od-macosx/Credits.rtf
rm -rf src/od-macosx/Info.plist
rm -rf src/od-win32/Makefile.in
rm -rf src/sd-alsa/Makefile.in
rm -rf src/sd-amigaos/Makefile.in
rm -rf src/sd-beos/Makefile.in
@ -87,7 +86,6 @@ rm -rf src/td-beos/Makefile.in
rm -rf src/td-none/Makefile.in
rm -rf src/td-posix/Makefile.in
rm -rf src/td-sdl/Makefile.in
rm -rf src/td-win32/Makefile.in
rm -rf src/test/Makefile.in
# remove generated files, just in case
@ -111,6 +109,8 @@ rm -rf src/cpuemu_20.c
rm -rf src/cpuemu_21.c
rm -rf src/cpuemu_22.c
rm -rf src/cpuemu_31.c
rm -rf src/cpuemu_32.c
rm -rf src/cpuemu_33.c
# jit
rm -rf src/compemu.cpp
rm -rf src/compstbl.h

View File

@ -36,15 +36,15 @@ DIST_SUBDIRS = \
sd-none sd-alsa sd-amigaos sd-beos sd-sdl sd-solaris sd-uss \
jd-none jd-amigainput jd-amigaos jd-beos jd-linuxold jd-sdl \
gui-none gui-beos gui-cocoa gui-gtk gui-muirexx gui-sdl \
od-generic od-amiga od-beos od-linux od-macosx od-win32 \
td-none td-amigaos td-beos td-posix td-sdl td-win32 \
od-generic od-amiga od-beos od-linux od-macosx \
td-none td-amigaos td-beos td-posix td-sdl \
keymap caps archivers/dms archivers/zip
BUILT_SOURCES = \
blit.h blitfunc.h blitfunc.c blittable.c \
linetoscr.c \
cpudefs.c \
cpuemu_0.c cpuemu_11.c cpuemu_12.c cpuemu_20.c cpuemu_21.c cpuemu_22.c cpuemu_31.c \
cpuemu_0.c cpuemu_11.c cpuemu_12.c cpuemu_20.c cpuemu_21.c cpuemu_22.c cpuemu_31.c cpuemu_32.c cpuemu_33.c \
cpustbl.c cputbl.h \
compemu.c \
compstbl.c comptbl.h
@ -52,7 +52,7 @@ BUILT_SOURCES = \
CLEANFILES = \
blit.h blitfunc.h blitfunc.c blittable.c \
cpudefs.c \
cpuemu_0.c cpuemu_11.c cpuemu_12.c cpuemu_20.c cpuemu_21.c cpuemu_22.c cpuemu_31.c \
cpuemu_0.c cpuemu_11.c cpuemu_12.c cpuemu_20.c cpuemu_21.c cpuemu_22.c cpuemu_31.c cpuemu_32.c cpuemu_32.c \
cpustbl.c cputbl.h \
compemu.c \
compstbl.c comptbl.h \
@ -160,7 +160,7 @@ noinst_HEADERS = \
include/writelog.h \
include/xwin.h include/zfile.h include/diskutil.h \
targets/t-amiga.h targets/t-beos.h \
targets/t-unix.h targets/t-win32.h \
targets/t-unix.h\
include/gcc_warnings.h
dist_noinst_SCRIPTS = \
@ -261,6 +261,8 @@ cpuemu_20.c: cpuemu_0.c
cpuemu_21.c: cpuemu_0.c
cpuemu_22.c: cpuemu_0.c
cpuemu_31.c: cpuemu_0.c
cpuemu_32.c: cpuemu_0.c
cpuemu_33.c: cpuemu_0.c
compemu.c: tools/gencomp
./tools/gencomp

View File

@ -17,9 +17,6 @@
#include "custom.h"
#include "newcpu.h"
#include "a2065.h"
#ifdef _WIN32
#include "win32_uaenet.h"
#endif
#include "crc32.h"
#include "savestate.h"
#include "autoconf.h"

View File

@ -3,7 +3,7 @@
*
* A590/A2091/A3000/CDTV SCSI expansion (DMAC/SuperDMAC + WD33C93) emulation
*
* Copyright 2007 Toni Wilen
* Copyright 2007-2013 Toni Wilen
*
*/
@ -11,6 +11,7 @@
#define A2091_DEBUG 0
#define A3000_DEBUG 0
#define WD33C93_DEBUG 0
#define WD33C93_DEBUG_PIO 0
#include "sysconfig.h"
#include "sysdeps.h"
@ -30,6 +31,7 @@
#include "filesys.h"
#include "autoconf.h"
#include "cdtv.h"
#include "savestate.h"
#define ROM_VECTOR 0x2000
#define ROM_OFFSET 0x2000
@ -139,6 +141,39 @@
#define PHS_MESS_OUT 0x06
#define PHS_MESS_IN 0x07
/* Auxialiry status */
#define ASR_INT 0x80 /* Interrupt pending */
#define ASR_LCI 0x40 /* Last command ignored */
#define ASR_BSY 0x20 /* Busy, only cmd/data/asr readable */
#define ASR_CIP 0x10 /* Busy, cmd unavail also */
#define ASR_xxx 0x0c
#define ASR_PE 0x02 /* Parity error (even) */
#define ASR_DBR 0x01 /* Data Buffer Ready */
/* Status */
#define CSR_CAUSE 0xf0
#define CSR_RESET 0x00 /* chip was reset */
#define CSR_CMD_DONE 0x10 /* cmd completed */
#define CSR_CMD_STOPPED 0x20 /* interrupted or abrted*/
#define CSR_CMD_ERR 0x40 /* end with error */
#define CSR_BUS_SERVICE 0x80 /* REQ pending on the bus */
/* Control */
#define CTL_DMA 0x80 /* Single byte dma */
#define CTL_DBA_DMA 0x40 /* direct buffer access (bus master) */
#define CTL_BURST_DMA 0x20 /* continuous mode (8237) */
#define CTL_NO_DMA 0x00 /* Programmed I/O */
#define CTL_HHP 0x10 /* Halt on host parity error */
#define CTL_EDI 0x08 /* Ending disconnect interrupt */
#define CTL_IDI 0x04 /* Intermediate disconnect interrupt*/
#define CTL_HA 0x02 /* Halt on ATN */
#define CTL_HSP 0x01 /* Halt on SCSI parity error */
/* SCSI Messages */
#define MSG_COMMAND_COMPLETE 0x00
#define MSG_SAVE_DATA_POINTER 0x02
#define MSG_RESTORE_DATA_POINTERS 0x03
#define MSG_NOP 0x08
#define MSG_IDENTIFY 0x80
static int configured;
static uae_u8 dmacmemory[100];
static uae_u8 *rom;
@ -163,6 +198,7 @@ static uae_u8 scsidelay_status;
static int wd33c93a = 1;
struct scsi_data *scsis[8];
static struct scsi_data *scsi;
uae_u8 wdregs[32];
@ -196,7 +232,7 @@ static void INT2 (void)
{
if (currprefs.cs_cdtvscsi)
return;
if (!(auxstatus & 0x80))
if (!(auxstatus & ASR_INT))
return;
dmac_istr |= ISTR_INTS;
if (isirq ())

View File

@ -68,6 +68,8 @@ typedef voidp unzFile;
#endif
#define ZIP_BZIP2 12
#define UNZ_OK (0)
#define UNZ_END_OF_LIST_OF_FILE (-100)
#define UNZ_ERRNO (Z_ERRNO)

View File

@ -1533,9 +1533,6 @@ static int sound_prefs_changed (void)
if (!config_changed)
return 0;
if (changed_prefs.produce_sound != currprefs.produce_sound
#ifdef WIN32
|| changed_prefs.win32_soundcard != currprefs.win32_soundcard
#endif
|| changed_prefs.sound_stereo != currprefs.sound_stereo
|| changed_prefs.sound_maxbsiz != currprefs.sound_maxbsiz
|| changed_prefs.sound_freq != currprefs.sound_freq
@ -1607,9 +1604,6 @@ void set_audio (void)
close_sound ();
currprefs.produce_sound = changed_prefs.produce_sound;
#ifdef WIN32
currprefs.win32_soundcard = changed_prefs.win32_soundcard;
#endif
currprefs.sound_stereo = changed_prefs.sound_stereo;
currprefs.sound_auto = changed_prefs.sound_auto;
currprefs.sound_freq = changed_prefs.sound_freq;

View File

@ -106,24 +106,11 @@ int isdatatrack (struct cd_toc_head *th, int block)
static int cdscsidevicetype[MAX_TOTAL_SCSI_DEVICES];
#ifdef _WIN32
#include "od-win32/win32.h"
extern struct device_functions devicefunc_win32_spti;
extern struct device_functions devicefunc_win32_ioctl;
#endif
extern struct device_functions devicefunc_cdimage;
static struct device_functions *devicetable[] = {
NULL,
&devicefunc_cdimage,
#ifdef _WIN32
&devicefunc_win32_ioctl,
&devicefunc_win32_spti,
#endif
NULL
};
static int driver_installed[6];
@ -152,16 +139,7 @@ static void install_driver (int flags)
scsiemu[i] = true;
break;
case SCSI_UNIT_SPTI:
#ifdef _WIN32
if (currprefs.win32_uaescsimode == UAESCSI_CDEMU) {
device_func[i] = devicetable[SCSI_UNIT_IOCTL];
scsiemu[i] = true;
} else {
#endif
device_func[i] = devicetable[SCSI_UNIT_SPTI];
#ifdef _WIN32
}
#endif
break;
}
}
@ -220,21 +198,11 @@ void blkdev_fix_prefs (struct uae_prefs *p)
if (p->cdslots[i].inuse || p->cdslots[i].name[0]) {
TCHAR *name = p->cdslots[i].name;
if (_tcslen (name) == 3 && name[1] == ':' && name[2] == '\\') {
#ifdef _WIN32
if (currprefs.scsi && (currprefs.win32_uaescsimode == UAESCSI_SPTI || currprefs.win32_uaescsimode == UAESCSI_SPTISCAN))
cdscsidevicetype[i] = SCSI_UNIT_SPTI;
else
#endif
cdscsidevicetype[i] = SCSI_UNIT_IOCTL;
} else {
cdscsidevicetype[i] = SCSI_UNIT_IMAGE;
}
} else if (currprefs.scsi) {
#ifdef _WIN32
if (currprefs.win32_uaescsimode == UAESCSI_CDEMU)
cdscsidevicetype[i] = SCSI_UNIT_IOCTL;
else
#endif
cdscsidevicetype[i] = SCSI_UNIT_SPTI;
} else {
cdscsidevicetype[i] = SCSI_UNIT_IOCTL;
@ -363,27 +331,7 @@ static int get_standard_cd_unit2 (unsigned int csu)
}
return unitnum;
}
#ifdef _WIN32
device_func_init (SCSI_UNIT_IOCTL);
for (int drive = 'C'; drive <= 'Z'; ++drive) {
TCHAR vol[100];
_stprintf (vol, _T("%c:\\"), drive);
int drivetype = GetDriveType (vol);
if (drivetype == DRIVE_CDROM) {
if (sys_command_open_internal (unitnum, vol, csu)) {
if (getunitinfo (unitnum, drive, csu, &isaudio))
return unitnum;
sys_command_close (unitnum);
}
}
}
if (isaudio) {
TCHAR vol[100];
_stprintf (vol, _T("%c:\\"), isaudio);
if (sys_command_open_internal (unitnum, vol, csu))
return unitnum;
}
#endif
fallback:
device_func_init (SCSI_UNIT_IMAGE);
if (!sys_command_open_internal (unitnum, _T(""), csu)) {

View File

@ -206,379 +206,6 @@ static uae_u8 *flac_get_data (struct cdtoc *t)
return t->data;
}
#ifdef _WIN32
static HWAVEOUT cdda_wavehandle;
static void cdda_closewav (void)
{
if (cdda_wavehandle != NULL)
waveOutClose (cdda_wavehandle);
cdda_wavehandle = NULL;
}
static int cdda_openwav (void)
{
WAVEFORMATEX wav = { 0 };
MMRESULT mmr;
wav.cbSize = 0;
wav.nChannels = 2;
wav.nSamplesPerSec = 44100;
wav.wBitsPerSample = 16;
wav.nBlockAlign = wav.wBitsPerSample / 8 * wav.nChannels;
wav.nAvgBytesPerSec = wav.nBlockAlign * wav.nSamplesPerSec;
wav.wFormatTag = WAVE_FORMAT_PCM;
mmr = waveOutOpen (&cdda_wavehandle, WAVE_MAPPER, &wav, 0, 0, WAVE_ALLOWSYNC | WAVE_FORMAT_DIRECT);
if (mmr != MMSYSERR_NOERROR) {
write_log ("IMAGE CDDA: wave open %d\n", mmr);
cdda_closewav ();
return 0;
}
return 1;
}
static void sub_to_interleaved (const uae_u8 *s, uae_u8 *d)
{
for (int i = 0; i < 8 * 12; i ++) {
int dmask = 0x80;
int smask = 1 << (7 - (i & 7));
(*d) = 0;
for (int j = 0; j < 8; j++) {
(*d) |= (s[(i / 8) + j * 12] & smask) ? dmask : 0;
dmask >>= 1;
}
d++;
}
}
static void sub_to_deinterleaved (const uae_u8 *s, uae_u8 *d)
{
for (int i = 0; i < 8 * 12; i ++) {
int dmask = 0x80;
int smask = 1 << (7 - (i / 12));
(*d) = 0;
for (int j = 0; j < 8; j++) {
(*d) |= (s[(i % 12) * 8 + j] & smask) ? dmask : 0;
dmask >>= 1;
}
d++;
}
}
static int getsub_deinterleaved (uae_u8 *dst, struct cdunit *cdu, struct cdtoc *t, int sector)
{
int ret = 0;
uae_sem_wait (&cdu->sub_sem);
if (t->subcode) {
if (t->subhandle) {
int offset = 0;
int totalsize = SUB_CHANNEL_SIZE;
if (t->skipsize) {
totalsize += t->size;
offset = t->size;
}
zfile_fseek (t->subhandle, (uae_u64)sector * totalsize + t->suboffset + offset, SEEK_SET);
if (zfile_fread (dst, SUB_CHANNEL_SIZE, 1, t->subhandle) > 0)
ret = t->subcode;
} else {
memcpy (dst, t->subdata + sector * SUB_CHANNEL_SIZE + t->suboffset, SUB_CHANNEL_SIZE);
ret = t->subcode;
}
}
if (!ret) {
memset (dst, 0, SUB_CHANNEL_SIZE);
// regenerate Q-subchannel
uae_u8 *s = dst + 12;
s[0] = (t->ctrl << 4) | (t->adr << 0);
s[1] = tobcd (t - &cdu->toc[0] + 1);
s[2] = tobcd (1);
int msf = lsn2msf (sector);
tolongbcd (s + 7, msf);
msf = lsn2msf (sector - t->address - 150);
tolongbcd (s + 3, msf);
ret = 2;
}
if (ret == 1) {
uae_u8 tmp[SUB_CHANNEL_SIZE];
memcpy (tmp, dst, SUB_CHANNEL_SIZE);
sub_to_deinterleaved (tmp, dst);
ret = 2;
}
uae_sem_post (&cdu->sub_sem);
return ret;
}
static void dosub (struct cdunit *cdu, uae_u8 *subbuf)
{
uae_u8 subbuf2[SUB_CHANNEL_SIZE];
if (!cdu->cdda_subfunc)
return;
if (!subbuf) {
memset (subbuf2, 0, sizeof subbuf2);
cdu->cdda_subfunc (subbuf2, 1);
return;
}
sub_to_interleaved (subbuf, subbuf2);
cdu->cdda_subfunc (subbuf2, 1);
}
static int setstate (struct cdunit *cdu, int state)
{
cdu->cdda_play_state = state;
if (cdu->cdda_statusfunc)
return cdu->cdda_statusfunc (cdu->cdda_play_state);
return 0;
}
static void *cdda_unpack_func (void *v)
{
cdimage_unpack_thread = 1;
mp3decoder *mp3dec = NULL;
for (;;) {
uae_u32 cduidx = read_comm_pipe_u32_blocking (&unpack_pipe);
if (cdimage_unpack_thread == 0)
break;
uae_u32 tocidx = read_comm_pipe_u32_blocking (&unpack_pipe);
struct cdunit *cdu = &cdunits[cduidx];
struct cdtoc *t = &cdu->toc[tocidx];
if (t->handle) {
// force unpack if handle points to delayed zipped file
uae_s64 pos = zfile_ftell (t->handle);
zfile_fseek (t->handle, -1, SEEK_END);
uae_u8 b;
zfile_fread (&b, 1, 1, t->handle);
zfile_fseek (t->handle, pos, SEEK_SET);
if (!t->data && (t->enctype == AUDENC_MP3 || t->enctype == AUDENC_FLAC)) {
t->data = xcalloc (uae_u8, t->filesize + 2352);
cdimage_unpack_active = 1;
if (t->data) {
if (t->enctype == AUDENC_MP3) {
if (!mp3dec) {
try {
mp3dec = new mp3decoder();
} catch (exception) { };
}
if (mp3dec)
t->data = mp3dec->get (t->handle, t->data, t->filesize);
} else if (t->enctype == AUDENC_FLAC) {
flac_get_data (t);
}
}
}
}
cdimage_unpack_active = 2;
}
delete mp3dec;
cdimage_unpack_thread = -1;
return 0;
}
static void *cdda_play_func (void *v)
{
int cdda_pos;
int num_sectors = CDDA_BUFFERS;
int quit = 0;
int bufnum;
int bufon[2];
int oldplay;
int idleframes;
bool foundsub;
struct cdunit *cdu = (struct cdunit*)v;
while (cdu->cdda_play == 0)
Sleep (10);
oldplay = -1;
bufon[0] = bufon[1] = 0;
bufnum = 0;
cda_audio *cda = new cda_audio (num_sectors);
while (cdu->cdda_play > 0) {
if (oldplay != cdu->cdda_play) {
struct cdtoc *t;
int sector, diff;
struct _timeb tb1, tb2;
idleframes = 0;
foundsub = false;
_ftime (&tb1);
cdda_pos = cdu->cdda_start;
oldplay = cdu->cdda_play;
sector = cdu->cd_last_pos = cdda_pos;
t = findtoc (cdu, &sector);
if (!t) {
write_log (_T("IMAGE CDDA: illegal sector number %d\n"), cdu->cdda_start);
setstate (cdu, AUDIO_STATUS_PLAY_ERROR);
} else {
write_log (_T("IMAGE CDDA: playing from %d to %d, track %d ('%s', offset %lld, secoffset %d)\n"),
cdu->cdda_start, cdu->cdda_end, t->track, t->fname, t->offset, sector);
// do this even if audio is not compressed, t->handle also could be
// compressed and we want to unpack it in background too
while (cdimage_unpack_active == 1)
Sleep (10);
cdimage_unpack_active = 0;
write_comm_pipe_u32 (&unpack_pipe, cdu - &cdunits[0], 0);
write_comm_pipe_u32 (&unpack_pipe, t - &cdu->toc[0], 1);
while (cdimage_unpack_active == 0)
Sleep (10);
}
idleframes = cdu->cdda_delay_frames;
while (cdu->cdda_paused && cdu->cdda_play > 0) {
Sleep (10);
idleframes = -1;
}
if (cdu->cdda_scan == 0) {
// find possible P-subchannel=1 and fudge starting point so that
// buggy CD32/CDTV software CD+G handling does not miss any frames
bool seenindex = false;
for (sector = cdda_pos - 200; sector < cdda_pos; sector++) {
int sec = sector;
t = findtoc (cdu, &sec);
if (t) {
uae_u8 subbuf[SUB_CHANNEL_SIZE];
getsub_deinterleaved (subbuf, cdu, t, sector);
if (seenindex) {
for (int i = 2 * SUB_ENTRY_SIZE; i < SUB_CHANNEL_SIZE; i++) {
if (subbuf[i]) { // non-zero R-W subchannels
int diff = cdda_pos - sector + 2;
write_log (_T("-> CD+G start pos fudge -> %d (%d)\n"), sector, -diff);
idleframes -= diff;
cdda_pos = sector;
break;
}
}
} else if (subbuf[0] == 0xff) { // P == 1?
seenindex = true;
}
}
}
}
cdda_pos -= idleframes;
_ftime (&tb2);
diff = (tb2.time * (uae_s64)1000 + tb2.millitm) - (tb1.time * (uae_s64)1000 + tb1.millitm);
diff -= cdu->cdda_delay;
if (idleframes >= 0 && diff < 0 && cdu->cdda_play > 0)
Sleep (-diff);
setstate (cdu, AUDIO_STATUS_IN_PROGRESS);
}
cda->wait(bufnum);
bufon[bufnum] = 0;
if (!cdu->cdda_play)
goto end;
if (idleframes <= 0 && cdda_pos >= cdu->cdda_start && !isaudiotrack (&cdu->di.toc, cdda_pos)) {
setstate (cdu, AUDIO_STATUS_PLAY_ERROR);
write_log (_T("IMAGE CDDA: attempted to play data track %d\n"), cdda_pos);
goto end; // data track?
}
if ((cdda_pos < cdu->cdda_end || cdu->cdda_end == 0xffffffff) && !cdu->cdda_paused && cdu->cdda_play > 0) {
struct cdtoc *t;
int sector, cnt;
int dofinish = 0;
gui_flicker_led (LED_CD, cdu->di.unitnum - 1, LED_CD_AUDIO);
memset (cda->buffers[bufnum], 0, num_sectors * 2352);
for (cnt = 0; cnt < num_sectors; cnt++) {
uae_u8 *dst = cda->buffers[bufnum] + cnt * 2352;
uae_u8 subbuf[SUB_CHANNEL_SIZE];
sector = cdda_pos;
memset (subbuf, 0, SUB_CHANNEL_SIZE);
t = findtoc (cdu, &sector);
if (t) {
if (t->handle && !(t->ctrl & 4)) {
int totalsize = t->size + t->skipsize;
if ((t->enctype == AUDENC_MP3 || t->enctype == AUDENC_FLAC) && t->data) {
if (t->filesize >= sector * totalsize + t->offset + t->size)
memcpy (dst, t->data + sector * totalsize + t->offset, t->size);
} else if (t->enctype == AUDENC_PCM) {
if (sector * totalsize + t->offset + totalsize < t->filesize) {
zfile_fseek (t->handle, (uae_u64)sector * totalsize + t->offset, SEEK_SET);
zfile_fread (dst, t->size, 1, t->handle);
}
}
}
getsub_deinterleaved (subbuf, cdu, t, cdda_pos);
}
if (idleframes > 0) {
idleframes--;
memset (dst, 0, 2352);
memset (subbuf, 0, SUB_CHANNEL_SIZE);
}
if (cdda_pos < cdu->cdda_start && cdu->cdda_scan == 0)
memset (dst, 0, 2352);
dosub (cdu, subbuf);
if (cdu->cdda_scan) {
cdda_pos += cdu->cdda_scan;
if (cdda_pos < 0)
cdda_pos = 0;
} else {
cdda_pos++;
}
if (cdda_pos - num_sectors < cdu->cdda_end && cdda_pos >= cdu->cdda_end)
dofinish = 1;
}
if (idleframes <= 0)
cdu->cd_last_pos = cdda_pos;
bufon[bufnum] = 1;
cda->setvolume (currprefs.sound_volume_cd >= 0 ? currprefs.sound_volume_cd : currprefs.sound_volume, cdu->cdda_volume[0], cdu->cdda_volume[1]);
if (!cda->play (bufnum)) {
setstate (cdu, AUDIO_STATUS_PLAY_ERROR);
goto end;
}
if (dofinish) {
setstate (cdu, AUDIO_STATUS_PLAY_COMPLETE);
cdu->cdda_play = -1;
cdda_pos = cdu->cdda_end + 1;
}
}
if (bufon[0] == 0 && bufon[1] == 0) {
while (cdu->cdda_paused && cdu->cdda_play == oldplay)
Sleep (10);
}
bufnum = 1 - bufnum;
}
end:
cda->wait (0);
cda->wait (1);
while (cdimage_unpack_active == 1)
Sleep (10);
delete cda;
cdu->cdda_play = 0;
write_log (_T("IMAGE CDDA: thread killed\n"));
return NULL;
}
#endif
static void cdda_stop (struct cdunit *cdu)
{
if (cdu->cdda_play != 0) {

View File

@ -745,7 +745,13 @@ uae_u32 bsdthr_Accept_2 (SB)
uae_u32 bsdthr_Recv_2 (SB)
{
int foo;
int l, i;
int i;
/* REMOVEME:
* nowhere used
*/
#if 0
int l;
#endif
if (sb->from == 0) {
foo = recv (sb->s, sb->buf, sb->len, sb->flags /*| MSG_NOSIGNAL*/);
DEBUG_LOG ("recv2, recv returns %d, errno is %d\n", foo, errno);

View File

@ -29,10 +29,6 @@
int log_bsd;
#ifdef WIN32
# include <winsock2.h>
#endif
struct socketbase *socketbases;
static uae_u32 SockLibBase;
@ -73,6 +69,8 @@ uae_u32 addstr (uae_u32 * dst, const TCHAR *src)
xfree (s);
return res;
}
#if 0
static uae_u32 addstr_ansi (uae_u32 * dst, const uae_char *src)
{
uae_u32 res = *dst;
@ -82,6 +80,7 @@ static uae_u32 addstr_ansi (uae_u32 * dst, const uae_char *src)
(*dst) += len;
return res;
}
#endif
uae_u32 addmem (uae_u32 * dst, const uae_char *src, int len)
{
@ -466,7 +465,7 @@ static uae_u32 REGPARAM2 bsdsocklib_Expunge (TrapContext *context)
return 0;
}
static uae_u32 functable, datatable, inittable;
static uae_u32 functable, datatable;
static uae_u32 REGPARAM2 bsdsocklib_Open (TrapContext *context)
{
@ -680,7 +679,7 @@ static uae_u32 bsdsocklib_SetDTableSize (SB, int newSize)
newdtable = xcalloc (int, newSize);
newftable = xcalloc (int, newSize);
if (newdtable == NULL || newftable == NULL /*win32|| newmtable == NULL*/) {
if (newdtable == NULL || newftable == NULL) {
sb->resultval = -1;
bsdsocklib_seterrno(sb, ENOMEM);
xfree (newdtable);
@ -1466,29 +1465,6 @@ done:
static uae_u32 REGPARAM2 bsdsocklib_GetSocketEvents (TrapContext *context)
{
#ifdef _WIN32
struct socketbase *sb = get_socketbase (context);
int i;
int flags;
uae_u32 ptr = m68k_areg (regs, 0);
BSDTRACE ((_T("GetSocketEvents(0x%x) -> "), ptr));
for (i = sb->dtablesize; i--; sb->eventindex++) {
if (sb->eventindex >= sb->dtablesize)
sb->eventindex = 0;
if (sb->mtable[sb->eventindex]) {
flags = sb->ftable[sb->eventindex] & SET_ALL;
if (flags) {
sb->ftable[sb->eventindex] &= ~SET_ALL;
put_long (m68k_areg (regs, 0), flags >> 8);
BSDTRACE ((_T("%d (0x%x)\n"), sb->eventindex + 1, flags >> 8));
return sb->eventindex; // xxx
}
}
}
#endif
BSDTRACE ((_T("-1\n")));
return -1;
}
@ -1498,10 +1474,12 @@ static uae_u32 REGPARAM2 bsdsocklib_getdtablesize (TrapContext *context)
return get_socketbase (context)->dtablesize;
}
#if 0
static uae_u32 REGPARAM2 bsdsocklib_null (TrapContext *context)
{
return 0;
}
#endif
static uae_u32 REGPARAM2 bsdsocklib_init (TrapContext *context)
{

View File

@ -166,7 +166,7 @@ static const TCHAR *filtermode2[] = { _T("1x"), _T("2x"), _T("3x"), _T("4x"), 0
#endif
static const TCHAR *cartsmode[] = { _T("none"), _T("hrtmon"), 0 };
static const TCHAR *idemode[] = { _T("none"), _T("a600/a1200"), _T("a4000"), 0 };
static const TCHAR *rtctype[] = { _T("none"), _T("MSM6242B"), _T("RP5C01A"), 0 };
static const TCHAR *rtctype[] = { _T("none"), _T("MSM6242B"), _T("RP5C01A"), _T("MSM6242B_A2000"), 0 };
static const TCHAR *ciaatodmode[] = { _T("vblank"), _T("50hz"), _T("60hz"), 0 };
static const TCHAR *ksmirrortype[] = { _T("none"), _T("e0"), _T("a8+e0"), 0 };
static const TCHAR *cscompa[] = {
@ -184,7 +184,7 @@ static const TCHAR *maxvert[] = { _T("nointerlace"), _T("interlace"), 0 };
static const TCHAR *abspointers[] = { _T("none"), _T("mousehack"), _T("tablet"), 0 };
static const TCHAR *magiccursors[] = { _T("both"), _T("native"), _T("host"), 0 };
static const TCHAR *autoscale[] = { _T("none"), _T("auto"), _T("standard"), _T("max"), _T("scale"), _T("resize"), _T("center"), _T("manual"), _T("integer"), _T("integer_auto"), 0 };
static const TCHAR *joyportmodes[] = { _T(""), _T("mouse"), _T("djoy"), _T("gamepad"), _T("ajoy"), _T("cdtvjoy"), _T("cd32joy"), _T("lightpen"), 0 };
static const TCHAR *joyportmodes[] = { _T(""), _T("mouse"), _T("mousenowheel"), _T("djoy"), _T("gamepad"), _T("ajoy"), _T("cdtvjoy"), _T("cd32joy"), _T("lightpen"), 0 };
static const TCHAR *joyaf[] = { _T("none"), _T("normal"), _T("toggle"), 0 };
static const TCHAR *epsonprinter[] = { _T("none"), _T("ascii"), _T("epson_matrix_9pin"), _T("epson_matrix_24pin"), _T("epson_matrix_48pin"), 0 };
static const TCHAR *aspects[] = { _T("none"), _T("vga"), _T("tv"), 0 };
@ -216,6 +216,12 @@ static const TCHAR *obsolete[] = {
_T("serial_hardware_dtrdsr"), _T("gfx_filter_upscale"),
_T("gfx_correct_aspect"), _T("gfx_autoscale"), _T("parallel_sampler"), _T("parallel_ascii_emulation"),
_T("avoid_vid"), _T("avoid_dga"), _T("z3chipmem_size"), _T("state_replay_buffer"), _T("state_replay"),
_T("gfx_filter_vert_zoom"),_T("gfx_filter_horiz_zoom"),
_T("gfx_filter_vert_zoom_mult"), _T("gfx_filter_horiz_zoom_mult"),
_T("gfx_filter_vert_offset"), _T("gfx_filter_horiz_offset"),
_T("rtg_vert_zoom_multf"), _T("rtg_horiz_zoom_multf"),
NULL
};
@ -563,18 +569,19 @@ static void write_filesys_config (struct uae_prefs *p, struct zfile *f)
_T("scsram"), _T("scide") }; /* scsram = smart card sram = pcmcia sram card */
for (i = 0; i < p->mountitems; i++) {
struct uaedev_config_info *uci = &p->mountconfig[i];
struct uaedev_config_data *uci = &p->mountconfig[i];
struct uaedev_config_info *ci = &uci->ci;
TCHAR *str;
int bp = uci->bootpri;
int bp = ci->bootpri;
if (!uci->autoboot)
if (!ci->autoboot)
bp = -128;
if (uci->donotmount)
if (ci->donotmount)
bp = -129;
str = cfgfile_put_multipath (&p->path_hardfile, uci->rootdir);
str = cfgfile_put_multipath (&p->path_hardfile, ci->rootdir);
if (!uci->ishdf) {
_stprintf (tmp, _T("%s,%s:%s:%s,%d"), uci->readonly ? _T("ro") : _T("rw"),
uci->devname ? uci->devname : _T(""), uci->volname, str, bp);
_stprintf (tmp, _T("%s,%s:%s:%s,%d"), ci->readonly ? _T("ro") : _T("rw"),
ci->devname ? ci->devname : _T(""), ci->volname, str, bp);
cfgfile_write_str (f, _T("filesystem2"), tmp);
#if 0
_stprintf (tmp2, _T("filesystem=%s,%s:%s"), uci->readonly ? _T("ro") : _T("rw"),
@ -583,13 +590,17 @@ static void write_filesys_config (struct uae_prefs *p, struct zfile *f)
#endif
} else {
_stprintf (tmp, _T("%s,%s:%s,%d,%d,%d,%d,%d,%s,%s"),
uci->readonly ? _T("ro") : _T("rw"),
uci->devname ? uci->devname : _T(""), str,
uci->sectors, uci->surfaces, uci->reserved, uci->blocksize,
bp, uci->filesys ? uci->filesys : _T(""), hdcontrollers[uci->controller]);
if (uci->cyls || (uci->pcyls && uci->pheads && uci->psecs)) {
ci->readonly ? _T("ro") : _T("rw"),
ci->devname ? ci->devname : _T(""), str,
ci->sectors, ci->surfaces, ci->reserved, ci->blocksize,
bp, ci->filesys ? ci->filesys : _T(""), hdcontrollers[ci->controller]);
if (ci->highcyl) {
TCHAR *s = tmp + _tcslen (tmp);
_stprintf (s, _T(",%d,%d/%d/%d"), uci->cyls, uci->pcyls, uci->pheads, uci->psecs);
_stprintf (s, _T(",%d"), ci->highcyl);
if (ci->pcyls && ci->pheads && ci->psecs) {
TCHAR *s = tmp + _tcslen (tmp);
_stprintf (s, _T(",%d/%d/%d"), ci->pcyls, ci->pheads, ci->psecs);
}
}
cfgfile_write_str (f, _T("hardfile2"), tmp);
#if 0
@ -648,6 +659,17 @@ static void write_leds (struct zfile *f, const TCHAR *name, int mask)
cfgfile_dwrite_str (f, name, tmp);
}
static void write_resolution (struct zfile *f, const TCHAR *ws, const TCHAR *hs, struct wh *wh)
{
if (wh->width <= 0 || wh->height <= 0 || wh->special == WH_NATIVE) {
cfgfile_write_str (f, ws, _T("native"));
cfgfile_write_str (f, hs, _T("native"));
} else {
cfgfile_write (f, ws, _T("%d"), wh->width);
cfgfile_write (f, hs, _T("%d"), wh->height);
}
}
void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
{
struct strlist *sl;
@ -895,14 +917,11 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
cfgfile_write_str (f, _T("gfx_display_name_rtg"), target_get_display_name (p->gfx_apmode[APMODE_RTG].gfx_display, false));
cfgfile_write (f, _T("gfx_framerate"), _T("%d"), p->gfx_framerate);
cfgfile_write (f, _T("gfx_width"), _T("%d"), p->gfx_size_win.width); /* compatibility with old versions */
cfgfile_write (f, _T("gfx_height"), _T("%d"), p->gfx_size_win.height); /* compatibility with old versions */
write_resolution (f, _T("gfx_width"), _T("gfx_height"), &p->gfx_size_win); /* compatibility with old versions */
cfgfile_write (f, _T("gfx_top_windowed"), _T("%d"), p->gfx_size_win.x);
cfgfile_write (f, _T("gfx_left_windowed"), _T("%d"), p->gfx_size_win.y);
cfgfile_write (f, _T("gfx_width_windowed"), _T("%d"), p->gfx_size_win.width);
cfgfile_write (f, _T("gfx_height_windowed"), _T("%d"), p->gfx_size_win.height);
cfgfile_write (f, _T("gfx_width_fullscreen"), _T("%d"), p->gfx_size_fs.width);
cfgfile_write (f, _T("gfx_height_fullscreen"), _T("%d"), p->gfx_size_fs.height);
write_resolution (f, _T("gfx_width_windowed"), _T("gfx_height_windowed"), &p->gfx_size_win);
write_resolution (f, _T("gfx_width_fullscreen"), _T("gfx_height_fullscreen"), &p->gfx_size_fs);
cfgfile_write (f, _T("gfx_refreshrate"), _T("%d"), p->gfx_apmode[0].gfx_refreshrate);
cfgfile_dwrite (f, _T("gfx_refreshrate_rtg"), _T("%d"), p->gfx_apmode[1].gfx_refreshrate);
cfgfile_write_bool (f, _T("gfx_autoresolution"), p->gfx_autoresolution);
@ -948,12 +967,12 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
cfgfile_dwrite (f, _T("gfx_filter"), _T("no"));
}
cfgfile_dwrite_str (f, _T("gfx_filter_mode"), filtermode2[p->gfx_filter_filtermode]);
cfgfile_dwrite (f, _T("gfx_filter_vert_zoom"), _T("%d"), p->gfx_filter_vert_zoom);
cfgfile_dwrite (f, _T("gfx_filter_horiz_zoom"), _T("%d"), p->gfx_filter_horiz_zoom);
cfgfile_dwrite (f, _T("gfx_filter_vert_zoom_mult"), _T("%d"), p->gfx_filter_vert_zoom_mult);
cfgfile_dwrite (f, _T("gfx_filter_horiz_zoom_mult"), _T("%d"), p->gfx_filter_horiz_zoom_mult);
cfgfile_dwrite (f, _T("gfx_filter_vert_offset"), _T("%d"), p->gfx_filter_vert_offset);
cfgfile_dwrite (f, _T("gfx_filter_horiz_offset"), _T("%d"), p->gfx_filter_horiz_offset);
cfgfile_dwrite (f, _T("gfx_filter_vert_zoomf"), _T("%f"), p->gfx_filter_vert_zoom);
cfgfile_dwrite (f, _T("gfx_filter_horiz_zoomf"), _T("%f"), p->gfx_filter_horiz_zoom);
cfgfile_dwrite (f, _T("gfx_filter_vert_zoom_multf"), _T("%f"), p->gfx_filter_vert_zoom_mult);
cfgfile_dwrite (f, _T("gfx_filter_horiz_zoom_multf"), _T("%f"), p->gfx_filter_horiz_zoom_mult);
cfgfile_dwrite (f, _T("gfx_filter_vert_offsetf"), _T("%f"), p->gfx_filter_vert_offset);
cfgfile_dwrite (f, _T("gfx_filter_horiz_offsetf"), _T("%f"), p->gfx_filter_horiz_offset);
cfgfile_dwrite (f, _T("gfx_filter_scanlines"), _T("%d"), p->gfx_filter_scanlines);
cfgfile_dwrite (f, _T("gfx_filter_scanlinelevel"), _T("%d"), p->gfx_filter_scanlinelevel);
cfgfile_dwrite (f, _T("gfx_filter_scanlineratio"), _T("%d"), p->gfx_filter_scanlineratio);
@ -999,6 +1018,9 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
cfgfile_dwrite (f, _T("gfx_center_horizontal_size"), _T("%d"), p->gfx_xcenter_size);
cfgfile_dwrite (f, _T("gfx_center_vertical_size"), _T("%d"), p->gfx_ycenter_size);
cfgfile_dwrite (f, _T("rtg_vert_zoom_multf"), _T("%.f"), p->rtg_vert_zoom_mult);
cfgfile_dwrite (f, _T("rtg_horiz_zoom_multf"), _T("%.f"), p->rtg_horiz_zoom_mult);
#endif
cfgfile_write_bool (f, _T("immediate_blits"), p->immediate_blits);
@ -1238,6 +1260,15 @@ int cfgfile_doubleval (const TCHAR *option, const TCHAR *value, const TCHAR *nam
return 1;
}
int cfgfile_floatval (const TCHAR *option, const TCHAR *value, const TCHAR *name, float *location)
{
int base = 10;
TCHAR *endptr;
if (name != NULL && _tcscmp (option, name) != 0)
return 0;
*location = (float)_tcstod (value, &endptr);
return 1;
}
int cfgfile_intval_unsigned (const TCHAR *option, const TCHAR *value, const TCHAR *name, unsigned int *location, int scale)
{
@ -1619,12 +1650,12 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value)
|| cfgfile_intval (option, value, _T("gfx_center_vertical_size"), &p->gfx_ycenter_size, 1)
#ifdef GFXFILTER
|| cfgfile_intval (option, value, _T("gfx_filter_vert_zoom"), &p->gfx_filter_vert_zoom, 1)
|| cfgfile_intval (option, value, _T("gfx_filter_horiz_zoom"), &p->gfx_filter_horiz_zoom, 1)
|| cfgfile_intval (option, value, _T("gfx_filter_vert_zoom_mult"), &p->gfx_filter_vert_zoom_mult, 1)
|| cfgfile_intval (option, value, _T("gfx_filter_horiz_zoom_mult"), &p->gfx_filter_horiz_zoom_mult, 1)
|| cfgfile_intval (option, value, _T("gfx_filter_vert_offset"), &p->gfx_filter_vert_offset, 1)
|| cfgfile_intval (option, value, _T("gfx_filter_horiz_offset"), &p->gfx_filter_horiz_offset, 1)
|| cfgfile_floatval (option, value, _T("gfx_filter_vert_zoomf"), &p->gfx_filter_vert_zoom)
|| cfgfile_floatval (option, value, _T("gfx_filter_horiz_zoomf"), &p->gfx_filter_horiz_zoom)
|| cfgfile_floatval (option, value, _T("gfx_filter_vert_zoom_multf"), &p->gfx_filter_vert_zoom_mult)
|| cfgfile_floatval (option, value, _T("gfx_filter_horiz_zoom_multf"), &p->gfx_filter_horiz_zoom_mult)
|| cfgfile_floatval (option, value, _T("gfx_filter_vert_offsetf"), &p->gfx_filter_vert_offset)
|| cfgfile_floatval (option, value, _T("gfx_filter_horiz_offsetf"), &p->gfx_filter_horiz_offset)
|| cfgfile_intval (option, value, _T("gfx_filter_scanlines"), &p->gfx_filter_scanlines, 1)
|| cfgfile_intval (option, value, _T("gfx_filter_scanlinelevel"), &p->gfx_filter_scanlinelevel, 1)
|| cfgfile_intval (option, value, _T("gfx_filter_scanlineratio"), &p->gfx_filter_scanlineratio, 1)
@ -1643,8 +1674,8 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value)
|| cfgfile_string (option, value, _T("gfx_filter_mask"), p->gfx_filtermask, sizeof p->gfx_filtermask / sizeof (TCHAR))
|| cfgfile_intval (option, value, _T("filesys_max_size"), &p->filesys_limit, 1)
|| cfgfile_intval (option, value, _T("rtg_vert_zoom_mult"), &p->rtg_vert_zoom_mult, 1)
|| cfgfile_intval (option, value, _T("rtg_horiz_zoom_mult"), &p->rtg_horiz_zoom_mult, 1)
|| cfgfile_floatval (option, value, _T("rtg_vert_zoom_multf"), &p->rtg_vert_zoom_mult)
|| cfgfile_floatval (option, value, _T("rtg_horiz_zoom_multf"), &p->rtg_horiz_zoom_mult)
#endif
#ifdef DRIVESOUND
|| cfgfile_intval (option, value, _T("floppy0sound"), &p->floppyslots[0].dfxclick, 1)
@ -1718,6 +1749,46 @@ cfgfile_path (option, value, _T("floppy0soundext"), p->floppyslots[0].dfxclickex
|| cfgfile_strval (option, value, _T("absolute_mouse"), &p->input_tablet, abspointers, 0))
return 1;
if (_tcscmp (option, _T("gfx_width_windowed")) == 0) {
if (!_tcscmp (value, _T("native"))) {
p->gfx_size_win.width = 0;
p->gfx_size_win.height = 0;
} else {
cfgfile_intval (option, value, _T("gfx_width_windowed"), &p->gfx_size_win.width, 1);
}
return 1;
}
if (_tcscmp (option, _T("gfx_height_windowed")) == 0) {
if (!_tcscmp (value, _T("native"))) {
p->gfx_size_win.width = 0;
p->gfx_size_win.height = 0;
} else {
cfgfile_intval (option, value, _T("gfx_height_windowed"), &p->gfx_size_win.height, 1);
}
return 1;
}
if (_tcscmp (option, _T("gfx_width_fullscreen")) == 0) {
if (!_tcscmp (value, _T("native"))) {
p->gfx_size_fs.width = 0;
p->gfx_size_fs.height = 0;
p->gfx_size_fs.special = WH_NATIVE;
} else {
cfgfile_intval (option, value, _T("gfx_width_fullscreen"), &p->gfx_size_fs.width, 1);
p->gfx_size_fs.special = 0;
}
return 1;
}
if (_tcscmp (option, _T("gfx_height_fullscreen")) == 0) {
if (!_tcscmp (value, _T("native"))) {
p->gfx_size_fs.width = 0;
p->gfx_size_fs.height = 0;
p->gfx_size_fs.special = WH_NATIVE;
} else {
cfgfile_intval (option, value, _T("gfx_height_fullscreen"), &p->gfx_size_fs.height, 1);
p->gfx_size_fs.special = 0;
}
return 1;
}
if (cfgfile_intval (option, value, _T("gfx_display"), &p->gfx_apmode[APMODE_NATIVE].gfx_display, 1)) {
p->gfx_apmode[APMODE_RTG].gfx_display = p->gfx_apmode[APMODE_NATIVE].gfx_display;
@ -1766,12 +1837,12 @@ cfgfile_path (option, value, _T("floppy0soundext"), p->floppyslots[0].dfxclickex
return 1;
}
if (_tcscmp (option, _T("gfx_vsync")) == 0) {
if (cfgfile_strboolval (option, value, _T("gfx_vsync"), &p->gfx_apmode[APMODE_NATIVE].gfx_vsync, vsyncmodes, 0) >= 0)
if (cfgfile_strval (option, value, _T("gfx_vsync"), &p->gfx_apmode[APMODE_NATIVE].gfx_vsync, vsyncmodes, 0) >= 0)
return 1;
return cfgfile_yesno (option, value, _T("gfx_vsync"), &p->gfx_apmode[APMODE_NATIVE].gfx_vsync);
}
if (_tcscmp (option, _T("gfx_vsync_picasso")) == 0) {
if (cfgfile_strboolval (option, value, _T("gfx_vsync_picasso"), &p->gfx_apmode[APMODE_RTG].gfx_vsync, vsyncmodes, 0) >= 0)
if (cfgfile_strval (option, value, _T("gfx_vsync_picasso"), &p->gfx_apmode[APMODE_RTG].gfx_vsync, vsyncmodes, 0) >= 0)
return 1;
return cfgfile_yesno (option, value, _T("gfx_vsync_picasso"), &p->gfx_apmode[APMODE_RTG].gfx_vsync);
}
@ -2029,6 +2100,7 @@ cfgfile_path (option, value, _T("floppy0soundext"), p->floppyslots[0].dfxclickex
return 1;
}
#ifdef SAVESTATE
if (cfgfile_path (option, value, _T("statefile"), tmpbuf, sizeof tmpbuf / sizeof (TCHAR))) {
_tcscpy (p->statefile, tmpbuf);
_tcscpy (savestate_fname, tmpbuf);
@ -2065,6 +2137,7 @@ cfgfile_path (option, value, _T("floppy0soundext"), p->floppyslots[0].dfxclickex
}
return 1;
}
#endif // SAVESTATE
if (cfgfile_strval (option, value, _T("sound_channels"), &p->sound_stereo, stereomode, 1)) {
if (p->sound_stereo == SND_NONE) { /* "mixed stereo" compatibility hack */
@ -2305,27 +2378,21 @@ end:
xfree (romtxt);
}
static struct uaedev_config_info *getuci(struct uae_prefs *p)
static struct uaedev_config_data *getuci (struct uae_prefs *p)
{
if (p->mountitems < MOUNT_CONFIG_SIZE)
return &p->mountconfig[p->mountitems++];
return NULL;
}
struct uaedev_config_info *add_filesys_config (struct uae_prefs *p, int index,
const TCHAR *devname, const TCHAR *volname, const TCHAR *rootdir, bool readonly,
int cyls, int secspertrack, int surfaces, int reserved,
int blocksize, int bootpri,
const TCHAR *filesysdir, int hdc, int flag,
int pcyls, int pheads, int psecs)
struct uaedev_config_data *add_filesys_config (struct uae_prefs *p, int index, struct uaedev_config_info *ci, bool hdf)
{
struct uaedev_config_info *uci;
struct uaedev_config_data *uci;
int i;
TCHAR *s;
if (index < 0 && devname && _tcslen (devname) > 0) {
if (index < 0 && ci->devname && _tcslen (ci->devname) > 0) {
for (i = 0; i < p->mountitems; i++) {
if (p->mountconfig[i].devname && !_tcscmp (p->mountconfig[i].devname, devname))
if (p->mountconfig[i].ci.devname && !_tcscmp (p->mountconfig[i].ci.devname, ci->devname))
return 0;
}
}
@ -2339,55 +2406,39 @@ struct uaedev_config_info *add_filesys_config (struct uae_prefs *p, int index,
if (!uci)
return 0;
uci->ishdf = volname == NULL ? 1 : 0;
_tcscpy (uci->devname, devname ? devname : _T(""));
_tcscpy (uci->volname, volname ? volname : _T(""));
_tcscpy (uci->rootdir, rootdir ? rootdir : _T(""));
validatedevicename (uci->devname);
validatevolumename (uci->volname);
uci->readonly = readonly;
uci->cyls = cyls;
uci->sectors = secspertrack;
uci->surfaces = surfaces;
uci->reserved = reserved;
uci->blocksize = blocksize;
uci->bootpri = bootpri;
uci->donotmount = 0;
uci->autoboot = 0;
if (!pcyls || !pheads || !psecs)
pcyls = pheads = psecs = 0;
uci->pcyls = pcyls;
uci->pheads = pheads;
uci->psecs = psecs;
if (bootpri < -128)
uci->donotmount = 1;
else if (bootpri >= -127)
uci->autoboot = 1;
uci->controller = hdc;
_tcscpy (uci->filesys, filesysdir ? filesysdir : _T(""));
if (!uci->devname[0]) {
memcpy (&uci->ci, ci, sizeof (struct uaedev_config_info));
uci->ishdf = hdf;
validatedevicename (uci->ci.devname);
validatevolumename (uci->ci.volname);
if (uci->ci.bootpri < -128)
uci->ci.donotmount = true;
else if (uci->ci.bootpri >= -127)
uci->ci.autoboot = true;
if (!uci->ci.devname[0]) {
TCHAR base[32];
TCHAR base2[32];
int num = 0;
if (uci->rootdir[0] == 0 && !uci->ishdf)
if (uci->ci.rootdir[0] == 0 && !uci->ishdf)
_tcscpy (base, _T("RDH"));
else
_tcscpy (base, _T("DH"));
_tcscpy (base2, base);
for (i = 0; i < p->mountitems; i++) {
_stprintf (base2, _T("%s%d"), base, num);
if (!_tcscmp(base2, p->mountconfig[i].devname)) {
if (!_tcsicmp(base2, p->mountconfig[i].ci.devname)) {
num++;
i = -1;
continue;
}
}
_tcscpy (uci->devname, base2);
validatedevicename (uci->devname);
_tcscpy (uci->ci.devname, base2);
validatedevicename (uci->ci.devname);
}
if (!uci->ishdf) {
TCHAR *s = filesys_createvolname (uci->ci.volname, uci->ci.rootdir, _T("Harddrive"));
_tcscpy (uci->ci.volname, s);
xfree (s);
}
s = filesys_createvolname (volname, rootdir, _T("Harddrive"));
_tcscpy (uci->volname, s);
xfree (s);
return uci;
}
@ -2427,14 +2478,153 @@ static int get_filesys_controller (const TCHAR *hdc)
return hdcv;
}
static bool parse_geo (const TCHAR *tname, struct uaedev_config_info *uci, struct hardfiledata *hfd, bool empty)
{
struct zfile *f;
int found;
TCHAR buf[200];
f = zfile_fopen (tname, _T("r"), 0);
if (!f)
return false;
found = hfd == NULL && !empty ? 2 : 0;
if (found)
write_log (_T("Geometry file '%s' detected\n"), tname);
while (zfile_fgets (buf, sizeof buf / sizeof (TCHAR), f)) {
int v;
TCHAR *sep;
my_trim (buf);
if (_tcslen (buf) == 0)
continue;
if (buf[0] == '[' && buf[_tcslen (buf) - 1] == ']') {
if (found > 1) {
zfile_fclose (f);
return true;
}
found = 0;
buf[_tcslen (buf) - 1] = 0;
my_trim (buf + 1);
if (!_tcsicmp (buf + 1, _T("empty"))) {
if (empty)
found = 1;
} else if (!_tcsicmp (buf + 1, _T("default"))) {
if (!empty)
found = 1;
} else if (hfd) {
uae_u64 size = atoi (buf + 1);
if (size == hfd->virtsize)
found = 2;
}
if (found)
write_log (_T("Geometry file '%s', entry '%s' detected\n"), tname, buf + 1);
continue;
}
if (!found)
continue;
sep = _tcschr (buf, '=');
if (!sep)
continue;
sep[0] = 0;
TCHAR *key = my_strdup_trim (buf);
TCHAR *val = my_strdup_trim (sep + 1);
if (val[0] == '0' && _totupper (val[1]) == 'X') {
TCHAR *endptr;
v = _tcstol (val, &endptr, 16);
} else {
v = _tstol (val);
}
if (!_tcsicmp (key, _T("surfaces")))
uci->surfaces = v;
if (!_tcsicmp (key, _T("sectorspertrack")) || !_tcsicmp (key, _T("blockspertrack")))
uci->sectors = v;
if (!_tcsicmp (key, _T("sectorsperblock")))
uci->sectorsperblock = v;
if (!_tcsicmp (key, _T("reserved")))
uci->reserved = v;
if (!_tcsicmp (key, _T("lowcyl")))
uci->lowcyl = v;
if (!_tcsicmp (key, _T("highcyl")) || !_tcsicmp (key, _T("cyl")))
uci->highcyl = v;
if (!_tcsicmp (key, _T("blocksize")) || !_tcsicmp (key, _T("sectorsize")))
uci->blocksize = v;
if (!_tcsicmp (key, _T("buffers")))
uci->buffers = v;
if (!_tcsicmp (key, _T("maxtransfer")))
uci->maxtransfer = v;
if (!_tcsicmp (key, _T("interleave")))
uci->interleave = v;
if (!_tcsicmp (key, _T("dostype")))
uci->dostype = v;
if (!_tcsicmp (key, _T("bufmemtype")))
uci->bufmemtype = v;
if (!_tcsicmp (key, _T("stacksize")))
uci->stacksize = v;
if (!_tcsicmp (key, _T("mask")))
uci->mask = v;
if (!_tcsicmp (key, _T("unit")))
uci->unit = v;
if (!_tcsicmp (key, _T("controller")))
uci->controller = get_filesys_controller (val);
if (!_tcsicmp (key, _T("flags")))
uci->flags = v;
if (!_tcsicmp (key, _T("priority")))
uci->priority = v;
if (!_tcsicmp (key, _T("bootpri"))) {
uci->bootpri = v;
uci->donotmount = false;
if (uci->bootpri <= -128) {
uci->bootpri = -128;
uci->donotmount = true;
}
}
if (!_tcsicmp (key, _T("filesystem")))
_tcscpy (uci->filesys, val);
if (!_tcsicmp (key, _T("device")))
_tcscpy (uci->devname, val);
xfree (val);
xfree (key);
}
zfile_fclose (f);
return false;
}
bool get_hd_geometry (struct uaedev_config_info *uci)
{
TCHAR tname[MAX_DPATH];
fetch_configurationpath (tname, sizeof tname / sizeof (TCHAR));
_tcscat (tname, _T("default.geo"));
if (zfile_exists (tname)) {
struct hardfiledata hfd;
memset (&hfd, 0, sizeof hfd);
hfd.ci.readonly = true;
hfd.ci.blocksize = 512;
if (hdf_open (&hfd, uci->rootdir)) {
parse_geo (tname, uci, &hfd, false);
hdf_close (&hfd);
} else {
parse_geo (tname, uci, NULL, true);
}
}
if (uci->rootdir[0]) {
_tcscpy (tname, uci->rootdir);
_tcscat (tname, _T(".geo"));
return parse_geo (tname, uci, NULL, false);
}
return false;
}
static int cfgfile_parse_newfilesys (struct uae_prefs *p, int nr, bool hdf, TCHAR *value)
{
int cyls, secs, heads, reserved, bs, bp, hdcv;
int pcyls, pheads, psecs;
bool ro;
TCHAR *dname = NULL, *aname = _T(""), *root = NULL, *fs = NULL, *hdc;
TCHAR *tmpp = _tcschr (value, ',');
struct uaedev_config_info uci;
TCHAR *tmpp = _tcschr (value, ','), *tmpp2;
TCHAR *str = NULL;
TCHAR devname[MAX_DPATH], volname[MAX_DPATH];
devname[0] = volname[0] = 0;
uci_set_defaults (&uci, false);
config_newfilesystem = 1;
if (tmpp == 0)
@ -2442,14 +2632,11 @@ static int cfgfile_parse_newfilesys (struct uae_prefs *p, int nr, bool hdf, TCHA
*tmpp++ = '\0';
if (strcasecmp (value, _T("ro")) == 0)
ro = true;
uci.readonly = true;
else if (strcasecmp (value, _T("rw")) == 0)
ro = false;
uci.readonly = false;
else
goto invalid_fs;
cyls = 0,secs = 0; heads = 0; reserved = 0; bs = 0; bp = 0;
fs = 0; hdc = 0; hdcv = 0;
pcyls = pheads = psecs = 0;
value = tmpp;
if (!hdf) {
@ -2457,65 +2644,76 @@ static int cfgfile_parse_newfilesys (struct uae_prefs *p, int nr, bool hdf, TCHA
if (tmpp == 0)
goto empty_fs;
*tmpp++ = 0;
dname = value;
aname = tmpp;
_tcscpy (devname, value);
tmpp2 = tmpp;
tmpp = _tcschr (tmpp, ':');
if (tmpp == 0)
goto empty_fs;
*tmpp++ = 0;
root = tmpp;
_tcscpy (volname, tmpp2);
tmpp2 = tmpp;
tmpp = _tcschr (tmpp, ',');
if (tmpp == 0)
goto empty_fs;
*tmpp++ = 0;
if (! getintval (&tmpp, &bp, 0))
_tcscpy (uci.rootdir, tmpp2);
_tcscpy (uci.volname, volname);
_tcscpy (uci.devname, devname);
if (! getintval (&tmpp, &uci.bootpri, 0))
goto empty_fs;
} else {
tmpp = _tcschr (value, ':');
if (tmpp == 0)
goto invalid_fs;
*tmpp++ = '\0';
dname = value;
root = tmpp;
_tcscpy (devname, value);
tmpp2 = tmpp;
tmpp = _tcschr (tmpp, ',');
if (tmpp == 0)
goto invalid_fs;
*tmpp++ = 0;
aname = 0;
if (! getintval (&tmpp, &secs, ',')
|| ! getintval (&tmpp, &heads, ',')
|| ! getintval (&tmpp, &reserved, ',')
|| ! getintval (&tmpp, &bs, ','))
_tcscpy (uci.rootdir, tmpp2);
if (uci.rootdir[0] != ':')
get_hd_geometry (&uci);
_tcscpy (uci.devname, devname);
if (! getintval (&tmpp, &uci.sectors, ',')
|| ! getintval (&tmpp, &uci.surfaces, ',')
|| ! getintval (&tmpp, &uci.reserved, ',')
|| ! getintval (&tmpp, &uci.blocksize, ','))
goto invalid_fs;
if (getintval2 (&tmpp, &bp, ',')) {
fs = tmpp;
if (getintval2 (&tmpp, &uci.bootpri, ',')) {
tmpp2 = tmpp;
tmpp = _tcschr (tmpp, ',');
if (tmpp != 0) {
*tmpp++ = 0;
_tcscpy (uci.filesys, tmpp2);
TCHAR *tmpp2 = _tcschr (tmpp, ',');
if (tmpp2)
*tmpp2++ = 0;
hdcv = get_filesys_controller (tmpp);
uci.controller = get_filesys_controller (tmpp);
if (tmpp2) {
if (getintval2 (&tmpp2, &cyls, ',')) {
getintval (&tmpp2, &pcyls, '/');
getintval (&tmpp2, &pheads, '/');
getintval2 (&tmpp2, &psecs, '/');
if (getintval2 (&tmpp2, &uci.highcyl, ',')) {
getintval (&tmpp2, &uci.pcyls, '/');
getintval (&tmpp2, &uci.pheads, '/');
getintval2 (&tmpp2, &uci.psecs, '/');
}
}
}
}
}
empty_fs:
if (root) {
if (_tcslen (root) > 3 && root[0] == 'H' && root[1] == 'D' && root[2] == '_') {
root += 2;
*root = ':';
uci.autoboot = uci.bootpri >= -127;
uci.donotmount = uci.bootpri == -129;
if (uci.rootdir[0]) {
if (_tcslen (uci.rootdir) > 3 && uci.rootdir[0] == 'H' && uci.rootdir[1] == 'D' && uci.rootdir[2] == '_') {
memmove (uci.rootdir, uci.rootdir + 2, (_tcslen (uci.rootdir + 2) + 1) * sizeof (TCHAR));
uci.rootdir[0] = ':';
}
str = cfgfile_subst_path_load (UNEXPANDED, &p->path_hardfile, root, false);
str = cfgfile_subst_path_load (UNEXPANDED, &p->path_hardfile, uci.rootdir, false);
_tcscpy (uci.rootdir, str);
}
#ifdef FILESYS
add_filesys_config (p, nr, dname, aname, str, ro, cyls, secs, heads, reserved, bs, bp, fs, hdcv, 0, pcyls, pheads, psecs);
add_filesys_config (p, nr, &uci, hdf);
#endif
// xfree (str);
return 1;
@ -2552,7 +2750,7 @@ static int cfgfile_parse_filesys (struct uae_prefs *p, const TCHAR *option, TCHA
}
return 1;
} else if (!_tcsncmp (option, tmp, _tcslen (tmp)) && option[_tcslen (tmp)] == '_') {
struct uaedev_config_info *uci = &currprefs.mountconfig[i];
struct uaedev_config_info *uci = &currprefs.mountconfig[i].ci;
if (uci->devname) {
const TCHAR *s = &option[_tcslen (tmp) + 1];
if (!_tcscmp (s, _T("bootpri"))) {
@ -2577,11 +2775,12 @@ static int cfgfile_parse_filesys (struct uae_prefs *p, const TCHAR *option, TCHA
if (_tcscmp (option, _T("filesystem")) == 0
|| _tcscmp (option, _T("hardfile")) == 0)
{
int secs, heads, reserved, bs;
bool ro;
TCHAR *aname, *root;
struct uaedev_config_info uci;
TCHAR *tmpp = _tcschr (value, ',');
TCHAR *str;
bool hdf;
uci_set_defaults (&uci, false);
if (config_newfilesystem)
return 1;
@ -2593,35 +2792,35 @@ static int cfgfile_parse_filesys (struct uae_prefs *p, const TCHAR *option, TCHA
if (_tcscmp (value, _T("1")) == 0 || strcasecmp (value, _T("ro")) == 0
|| strcasecmp (value, _T("readonly")) == 0
|| strcasecmp (value, _T("read-only")) == 0)
ro = true;
uci.readonly = true;
else if (_tcscmp (value, _T("0")) == 0 || strcasecmp (value, _T("rw")) == 0
|| strcasecmp (value, _T("readwrite")) == 0
|| strcasecmp (value, _T("read-write")) == 0)
ro = false;
uci.readonly = false;
else
goto invalid_fs;
secs = 0; heads = 0; reserved = 0; bs = 0;
value = tmpp;
if (_tcscmp (option, _T("filesystem")) == 0) {
hdf = false;
tmpp = _tcschr (value, ':');
if (tmpp == 0)
goto invalid_fs;
*tmpp++ = '\0';
aname = value;
root = tmpp;
_tcscpy (uci.volname, value);
_tcscpy (uci.rootdir, tmpp);
} else {
if (! getintval (&value, &secs, ',')
|| ! getintval (&value, &heads, ',')
|| ! getintval (&value, &reserved, ',')
|| ! getintval (&value, &bs, ','))
hdf = true;
if (! getintval (&value, &uci.sectors, ',')
|| ! getintval (&value, &uci.surfaces, ',')
|| ! getintval (&value, &uci.reserved, ',')
|| ! getintval (&value, &uci.blocksize, ','))
goto invalid_fs;
root = value;
aname = 0;
_tcscpy (uci.rootdir, value);
}
str = cfgfile_subst_path_load (UNEXPANDED, &p->path_hardfile, root, true);
str = cfgfile_subst_path_load (UNEXPANDED, &p->path_hardfile, uci.rootdir, true);
#ifdef FILESYS
add_filesys_config (p, -1, NULL, aname, str, ro, 0, secs, heads, reserved, bs, 0, NULL, 0, 0, 0, 0, 0);
add_filesys_config (p, -1, &uci, hdf);
#endif
xfree (str);
return 1;
@ -2690,7 +2889,6 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, const TCHAR *option, TCH
|| cfgfile_yesno (option, value, _T("cd32nvram"), &p->cs_cd32nvram)
|| cfgfile_yesno (option, value, _T("cdtvcd"), &p->cs_cdtvcd)
|| cfgfile_yesno (option, value, _T("cdtvram"), &p->cs_cdtvram)
|| cfgfile_yesno (option, value, _T("cdtvramcard"), &p->cs_cdtvcard)
|| cfgfile_yesno (option, value, _T("a1000ram"), &p->cs_a1000ram)
|| cfgfile_yesno (option, value, _T("pcmcia"), &p->cs_pcmcia)
|| cfgfile_yesno (option, value, _T("scsi_cdtv"), &p->cs_cdtvscsi)
@ -2744,6 +2942,7 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, const TCHAR *option, TCH
|| cfgfile_intval (option, value, _T("serial_stopbits"), &p->serial_stopbits, 1)
|| cfgfile_intval (option, value, _T("cpu060_revision"), &p->cpu060_revision, 1)
|| cfgfile_intval (option, value, _T("fpu_revision"), &p->fpu_revision, 1)
|| cfgfile_intval (option, value, _T("cdtvramcard"), &p->cs_cdtvcard, 1)
|| cfgfile_intval (option, value, _T("fatgary"), &p->cs_fatgaryrev, 1)
|| cfgfile_intval (option, value, _T("ramsey"), &p->cs_ramseyrev, 1)
|| cfgfile_doubleval (option, value, _T("chipset_refreshrate"), &p->chipset_refreshrate)
@ -3030,7 +3229,10 @@ static void calcformula (struct uae_prefs *prefs, TCHAR *in)
return;
}
if (calc (out, &val)) {
_stprintf (in, _T("%d"), (int)val);
if (val - (int)val != 0.0f)
_stprintf (in, _T("%f"), val);
else
_stprintf (in, _T("%d"), (int)val);
updatestore = true;
return;
}
@ -3634,9 +3836,11 @@ bad:
static void parse_filesys_spec (struct uae_prefs *p, bool readonly, const TCHAR *spec)
{
struct uaedev_config_info uci;
TCHAR buf[256];
TCHAR *s2;
uci_set_defaults (&uci, false);
_tcsncpy (buf, spec, 255); buf[255] = 0;
s2 = _tcschr (buf, ':');
if (s2) {
@ -3650,7 +3854,10 @@ static void parse_filesys_spec (struct uae_prefs *p, bool readonly, const TCHAR
}
#endif
#ifdef FILESYS
add_filesys_config (p, -1, NULL, buf, s2, readonly, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
_tcscpy (uci.volname, buf);
_tcscpy (uci.rootdir, s2);
uci.readonly = readonly;
add_filesys_config (p, -1, &uci, false);
#endif
} else {
write_log (_T("Usage: [-m | -M] VOLNAME:mount_point\n"));
@ -3659,9 +3866,11 @@ static void parse_filesys_spec (struct uae_prefs *p, bool readonly, const TCHAR
static void parse_hardfile_spec (struct uae_prefs *p, const TCHAR *spec)
{
struct uaedev_config_info uci;
TCHAR *x0 = my_strdup (spec);
TCHAR *x1, *x2, *x3, *x4;
uci_set_defaults (&uci, false);
x1 = _tcschr (x0, ':');
if (x1 == NULL)
goto argh;
@ -3679,7 +3888,8 @@ static void parse_hardfile_spec (struct uae_prefs *p, const TCHAR *spec)
goto argh;
*x4++ = '\0';
#ifdef FILESYS
add_filesys_config (p, -1, NULL, NULL, x4, 0, 0, _tstoi (x0), _tstoi (x1), _tstoi (x2), _tstoi (x3), 0, 0, 0, 0, 0, 0, 0);
_tcscpy (uci.rootdir, x4);
//add_filesys_config (p, -1, NULL, NULL, x4, 0, 0, _tstoi (x0), _tstoi (x1), _tstoi (x2), _tstoi (x3), 0, 0, 0, 0, 0, 0, 0);
#endif
xfree (x0);
return;
@ -4498,8 +4708,8 @@ void default_prefs (struct uae_prefs *p, int type)
p->gfx_filter = 0;
p->gfx_filtershader[0] = 0;
p->gfx_filtermask[0] = 0;
p->gfx_filter_horiz_zoom_mult = 1000;
p->gfx_filter_vert_zoom_mult = 1000;
p->gfx_filter_horiz_zoom_mult = 1.0;
p->gfx_filter_vert_zoom_mult = 1.0;
p->gfx_filter_bilinear = 0;
p->gfx_filter_filtermode = 0;
p->gfx_filter_scanlineratio = (1 << 4) | 1;
@ -4509,8 +4719,8 @@ void default_prefs (struct uae_prefs *p, int type)
p->gfx_filteroverlay_overscan = 0;
#endif
p->rtg_horiz_zoom_mult = 1000;
p->rtg_vert_zoom_mult = 1000;
p->rtg_horiz_zoom_mult = 1.0;
p->rtg_vert_zoom_mult = 1.0;
_tcscpy (p->floppyslots[0].df, _T("df0.adf"));
_tcscpy (p->floppyslots[1].df, _T("df1.adf"));
@ -4833,14 +5043,17 @@ static int bip_a3000 (struct uae_prefs *p, int config, int compa, int romcheck)
p->chipmem_size = 0x200000;
p->cpu_model = 68030;
p->fpu_model = 68882;
if (compa == 0)
p->mmu_model = 68030;
#ifdef JIT
else
p->cachesize = 8192;
#endif
p->chipset_mask = CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE;
p->cpu_compatible = p->address_space_24 = 0;
p->m68k_speed = -1;
p->immediate_blits = 0;
p->produce_sound = 2;
#ifdef JIT
p->cachesize = 8192;
#endif
p->floppyslots[0].dfxtype = DRV_35_HD;
p->floppy_speed = 0;
p->cpu_idle = 150;

View File

@ -34,11 +34,7 @@ extern uae_u8 *natmem_offset, *natmem_offset_end;
#define REG_RESULT EAX_INDEX
/* The registers subroutines take their first and second argument in */
#if defined(_WIN32)
/* Handle the _fastcall parameters of ECX and EDX */
#define REG_PAR1 ECX_INDEX
#define REG_PAR2 EDX_INDEX
#elif defined(__x86_64__)
#if defined(__x86_64__)
#define REG_PAR1 EDI_INDEX
#define REG_PAR2 ESI_INDEX
#else
@ -46,15 +42,9 @@ extern uae_u8 *natmem_offset, *natmem_offset_end;
#define REG_PAR2 EDX_INDEX
#endif
#if defined(_WIN32)
#define REG_PC_PRE EAX_INDEX /* The register we use for preloading regs.pc_p */
#define REG_PC_TMP ECX_INDEX
#define SHIFTCOUNT_NREG ECX_INDEX /* Register that can be used for shiftcount. -1 if any reg will do */
#else
#define REG_PC_PRE EAX_INDEX /* The register we use for preloading regs.pc_p */
#define REG_PC_TMP ECX_INDEX /* Another register that is not the above */
#define SHIFTCOUNT_NREG ECX_INDEX /* Register that can be used for shiftcount. -1 if any reg will do */
#endif
#define MUL_NREG1 EAX_INDEX /* %eax will hold the low 32 bits after a 32x32 mul */
#define MUL_NREG2 EDX_INDEX /* %edx will hold the high 32 bits */
@ -1677,12 +1667,8 @@ STATIC_INLINE void raw_inc_sp(int off)
#ifdef NATMEM_OFFSET
#ifdef _WIN32 // %%% BRIAN KING WAS HERE %%%
#include <winbase.h>
#else
#ifndef __USE_GNU
#define __USE_GNU
#endif
#include <sys/ucontext.h>
#endif
#include <signal.h>
@ -1693,308 +1679,6 @@ STATIC_INLINE void raw_inc_sp(int off)
static int in_handler=0;
static uae_u8 *veccode;
#ifdef _WIN32
#if defined(__x86_64__)
#define ctxPC (pContext->Rip)
#else
#define ctxPC (pContext->Eip)
#endif
extern int mman_guard_exception (LPEXCEPTION_POINTERS);
int EvalException (LPEXCEPTION_POINTERS blah, int n_except)
{
PEXCEPTION_RECORD pExceptRecord = NULL;
PCONTEXT pContext = NULL;
uae_u8* i = NULL;
uae_u32 addr = 0;
int r=-1;
int size=4;
int dir=-1;
int len=0;
if (n_except == STATUS_GUARD_PAGE_VIOLATION)
return mman_guard_exception (blah);
if (n_except != STATUS_ACCESS_VIOLATION || !canbang || currprefs.cachesize == 0)
return EXCEPTION_CONTINUE_SEARCH;
pExceptRecord = blah->ExceptionRecord;
pContext = blah->ContextRecord;
if (pContext)
i = (uae_u8 *)ctxPC;
if (pExceptRecord)
addr = (uae_u32)(pExceptRecord->ExceptionInformation[1]);
#ifdef JIT_DEBUG
write_log (_T("JIT: fault address is 0x%x at 0x%x\n"),addr,i);
#endif
if (!canbang || !currprefs.cachesize)
return EXCEPTION_CONTINUE_SEARCH;
if (in_handler)
write_log (_T("JIT: Argh --- Am already in a handler. Shouldn't happen!\n"));
if (canbang && i>=compiled_code && i<=current_compile_p) {
if (*i==0x66) {
i++;
size=2;
len++;
}
switch(i[0]) {
case 0x8a:
if ((i[1]&0xc0)==0x80) {
r=(i[1]>>3)&7;
dir=SIG_READ;
size=1;
len+=6;
break;
}
break;
case 0x88:
if ((i[1]&0xc0)==0x80) {
r=(i[1]>>3)&7;
dir=SIG_WRITE;
size=1;
len+=6;
break;
}
break;
case 0x8b:
switch(i[1]&0xc0) {
case 0x80:
r=(i[1]>>3)&7;
dir=SIG_READ;
len+=6;
break;
case 0x40:
r=(i[1]>>3)&7;
dir=SIG_READ;
len+=3;
break;
case 0x00:
r=(i[1]>>3)&7;
dir=SIG_READ;
len+=2;
break;
default:
break;
}
break;
case 0x89:
switch(i[1]&0xc0) {
case 0x80:
r=(i[1]>>3)&7;
dir=SIG_WRITE;
len+=6;
break;
case 0x40:
r=(i[1]>>3)&7;
dir=SIG_WRITE;
len+=3;
break;
case 0x00:
r=(i[1]>>3)&7;
dir=SIG_WRITE;
len+=2;
break;
}
break;
}
}
if (r!=-1) {
void* pr=NULL;
#ifdef JIT_DEBUG
write_log (_T("JIT: register was %d, direction was %d, size was %d\n"),r,dir,size);
#endif
switch(r) {
#if defined(__x86_64__)
case 0: pr=&(pContext->Rax); break;
case 1: pr=&(pContext->Rcx); break;
case 2: pr=&(pContext->Rdx); break;
case 3: pr=&(pContext->Rbx); break;
case 4: pr=(size>1) ? NULL:(((uae_u8*)&(pContext->Rax))+1); break;
case 5: pr=(size>1) ?
(void*)(&(pContext->Rbp)):
(void*)(((uae_u8*)&(pContext->Rcx))+1); break;
case 6: pr=(size>1) ?
(void*)(&(pContext->Rsi)):
(void*)(((uae_u8*)&(pContext->Rdx))+1); break;
case 7: pr=(size>1) ?
(void*)(&(pContext->Rdi)):
(void*)(((uae_u8*)&(pContext->Rbx))+1); break;
#else
case 0: pr=&(pContext->Eax); break;
case 1: pr=&(pContext->Ecx); break;
case 2: pr=&(pContext->Edx); break;
case 3: pr=&(pContext->Ebx); break;
case 4: pr=(size>1) ? NULL:(((uae_u8*)&(pContext->Eax))+1); break;
case 5: pr=(size>1) ?
(void*)(&(pContext->Ebp)):
(void*)(((uae_u8*)&(pContext->Ecx))+1); break;
case 6: pr=(size>1) ?
(void*)(&(pContext->Esi)):
(void*)(((uae_u8*)&(pContext->Edx))+1); break;
case 7: pr=(size>1) ?
(void*)(&(pContext->Edi)):
(void*)(((uae_u8*)&(pContext->Ebx))+1); break;
#endif
default: abort();
}
if (pr) {
blockinfo* bi;
if (currprefs.comp_oldsegv) {
addr-=(uae_u32)NATMEM_OFFSET;
#ifdef JIT_DEBUG
if ((addr>=0x10000000 && addr<0x40000000) ||
(addr>=0x50000000)) {
write_log (_T("JIT: Suspicious address 0x%x in SEGV handler.\n"),addr);
}
#endif
if (dir==SIG_READ) {
switch (size) {
case 1: *((uae_u8*)pr)=get_byte (addr); break;
case 2: *((uae_u16*)pr)=swap16(get_word (addr)); break;
case 4: *((uae_u32*)pr)=swap32(get_long (addr)); break;
default: abort();
}
}
else { /* write */
switch (size) {
case 1: put_byte (addr,*((uae_u8*)pr)); break;
case 2: put_word (addr,swap16(*((uae_u16*)pr))); break;
case 4: put_long (addr,swap32(*((uae_u32*)pr))); break;
default: abort();
}
}
#ifdef JIT_DEBUG
write_log (_T("JIT: Handled one access!\n"));
#endif
fflush(stdout);
segvcount++;
ctxPC+=len;
}
else {
void* tmp=target;
int i;
uae_u8 vecbuf[5];
addr-=(uae_u32)NATMEM_OFFSET;
#ifdef JIT_DEBUG
if ((addr>=0x10000000 && addr<0x40000000) ||
(addr>=0x50000000)) {
write_log (_T("JIT: Suspicious address 0x%x in SEGV handler.\n"),addr);
}
#endif
target=(uae_u8*)ctxPC;
for (i=0;i<5;i++)
vecbuf[i]=target[i];
emit_byte(0xe9);
emit_long((uae_u32)veccode-(uae_u32)target-4);
#ifdef JIT_DEBUG
write_log (_T("JIT: Create jump to %p\n"),veccode);
write_log (_T("JIT: Handled one access!\n"));
#endif
segvcount++;
target=veccode;
if (dir==SIG_READ) {
switch(size) {
case 1: raw_mov_b_ri(r,get_byte (addr)); break;
case 2: raw_mov_w_ri(r,swap16(get_word (addr))); break;
case 4: raw_mov_l_ri(r,swap32(get_long (addr))); break;
default: abort();
}
}
else { /* write */
switch(size) {
case 1: put_byte (addr,*((uae_u8*)pr)); break;
case 2: put_word (addr,swap16(*((uae_u16*)pr))); break;
case 4: put_long (addr,swap32(*((uae_u32*)pr))); break;
default: abort();
}
}
for (i=0;i<5;i++)
raw_mov_b_mi(ctxPC+i,vecbuf[i]);
raw_mov_l_mi((uae_u32)&in_handler,0);
emit_byte(0xe9);
emit_long(ctxPC+len-(uae_u32)target-4);
in_handler=1;
target=(uae_u8*)tmp;
}
bi=active;
while (bi) {
if (bi->handler &&
(uae_u8*)bi->direct_handler<=i &&
(uae_u8*)bi->nexthandler>i) {
#ifdef JIT_DEBUG
write_log (_T("JIT: deleted trigger (%p<%p<%p) %p\n"),
bi->handler,
i,
bi->nexthandler,
bi->pc_p);
#endif
invalidate_block(bi);
raise_in_cl_list(bi);
set_special(0);
return EXCEPTION_CONTINUE_EXECUTION;
}
bi=bi->next;
}
/* Not found in the active list. Might be a rom routine that
is in the dormant list */
bi=dormant;
while (bi) {
if (bi->handler &&
(uae_u8*)bi->direct_handler<=i &&
(uae_u8*)bi->nexthandler>i) {
#ifdef JIT_DEBUG
write_log (_T("JIT: deleted trigger (%p<%p<%p) %p\n"),
bi->handler,
i,
bi->nexthandler,
bi->pc_p);
#endif
invalidate_block(bi);
raise_in_cl_list(bi);
set_special(0);
return EXCEPTION_CONTINUE_EXECUTION;
}
bi=bi->next;
}
#ifdef JIT_DEBUG
write_log (_T("JIT: Huh? Could not find trigger!\n"));
#endif
return EXCEPTION_CONTINUE_EXECUTION;
}
}
write_log (_T("JIT: Can't handle access %08X!\n"), i);
#if 0
if (i)
{
int j;
for (j=0;j<10;j++) {
write_log (_T("JIT: instruction byte %2d is 0x%02x\n"),j,i[j]);
}
}
write_log (_T("Please send the above info (starting at \"fault address\") to\n"));
write_log (_T("bmeyer@csse.monash.edu.au\n"));
write_log (_T("This shouldn't happen ;-)\n"));
#endif
return EXCEPTION_CONTINUE_SEARCH;
}
# else
#if defined(__APPLE__) && __DARWIN_UNIX03
#define CONTEXT_MEMBER(x) __##x
#elif defined(__FreeBSD__)
@ -2268,7 +1952,6 @@ static void vec(int x, struct sigcontext sc)
signal(SIGSEGV,SIG_DFL); /* returning here will cause a "real" SEGV */
}
#endif
#endif
/*************************************************************************
* Checking for CPU features *

View File

@ -125,10 +125,8 @@ static uae_s32 nextused[VREGS];
static uae_u8 *popallspace;
#ifdef NATMEM_OFFSET
# ifndef WIN32
struct sigaction *saved_handler;
# endif
#endif
uae_u32 m68k_pc_offset;
@ -5390,7 +5388,6 @@ void alloc_cache(void)
}
#ifdef NATMEM_OFFSET
if (canbang) {
# ifndef _WIN32
/* Set up signal handler to catch illegal natmem accesses */
struct sigaction act;
act.sa_sigaction = vec;
@ -5398,7 +5395,6 @@ void alloc_cache(void)
sigemptyset (&act.sa_mask);
act.sa_flags = SA_SIGINFO;
sigaction (SIGSEGV, &act, NULL);
# endif
/* Cache for generating illegal natmem access handler. */
#endif
if (veccode == NULL)
@ -5731,9 +5727,7 @@ void build_comp(void)
raw_init_cpu();
#ifdef NATMEM_OFFSET
write_log (_T("JIT: Setting signal handler\n"));
#ifndef _WIN32
signal(SIGSEGV,vec);
#endif
#endif
write_log (_T("JIT: Building Compiler function table\n"));
for (opcode = 0; opcode < 65536; opcode++) {

View File

@ -49,11 +49,9 @@
/* kludge for Brian, so he can compile under MSVC++ */
#define USE_NORMAL_CALLING_CONVENTION 0
#ifndef WIN32
#include <unistd.h>
#include <sys/types.h>
#include <sys/mman.h>
#endif
#include <stdlib.h>
#include <fcntl.h>
@ -86,21 +84,13 @@
#include "mon.h"
#endif
#ifndef WIN32
#define PROFILE_COMPILE_TIME 1
#define PROFILE_UNTRANSLATED_INSNS 1
#endif
#if defined(__x86_64__) && 0
#define RECORD_REGISTER_USAGE 1
#endif
#ifdef WIN32
#undef write_log
#define write_log dummy_write_log
static void dummy_write_log(const char *, ...) { }
#endif
#if JIT_DEBUG
#undef abort
#define abort() do { \

View File

@ -19,6 +19,7 @@ static uaecptr beginio;
void consolehook_config (struct uae_prefs *p)
{
struct uaedev_config_info ci = { 0 };
int roms[] = { 15, 31, 16, 46, -1 };
default_prefs (p, 0);
@ -49,10 +50,12 @@ void consolehook_config (struct uae_prefs *p)
p->gfx_size_win.width = 320;
p->gfx_size_win.height = 256;
p->turbo_emulation = 0;
//p->win32_automount_drives = 2;
//p->win32_automount_cddrives = 2;
add_filesys_config (p, -1, _T("DH0"), _T("CLIBOOT"), _T("."), 1, 0, 0, 0, 0, 0, 15, NULL, 0, 0, 0, 0, 0);
_tcscpy (ci.rootdir, _T("."));
_tcscpy (ci.volname, _T("CLIBOOT"));
_tcscpy (ci.devname, _T("DH0"));
ci.bootpri = 15;
add_filesys_config (p, -1, &ci, false);
}
static void *console_thread (void *v)

File diff suppressed because it is too large Load Diff

View File

@ -93,11 +93,7 @@ void uae_abort (const TCHAR *format,...)
TCHAR buffer[1000];
va_start (parms, format);
#ifdef _WIN32
_vsnprintf(buffer, sizeof (buffer) -1, format, parms);
#else
vsnprintf(buffer, sizeof (buffer) -1, format, parms);
#endif
va_end (parms);
if (nomore) {
write_log (_T("%s\n"), buffer);
@ -2932,10 +2928,10 @@ void compute_framesync (void)
}
}
if (isvsync_chipset () < 0) {
double v2;
v2 = vblank_calibrate (cr->locked ? cr->rate : vblank_hz, cr->locked);
// double v2;
// v2 = vblank_calibrate (cr->locked ? cr->rate : vblank_hz, cr->locked);
if (!cr->locked)
v = v2;
v = -1; //v2
} else if (isvsync_chipset () > 0) {
if (currprefs.gfx_apmode[0].gfx_refreshrate)
v = abs (currprefs.gfx_apmode[0].gfx_refreshrate);
@ -3041,9 +3037,7 @@ void compute_framesync (void)
if (gfxvidinfo.outheight > gfxvidinfo.height_allocated)
gfxvidinfo.outheight = gfxvidinfo.height_allocated;
if (target_graphics_buffer_update ()) {
reset_drawing ();
}
reset_drawing ();
memset (line_decisions, 0, sizeof line_decisions);
@ -3780,7 +3774,6 @@ void INTREQ_0 (uae_u16 v)
void INTREQ (uae_u16 data)
{
INTREQ_0 (data);
serial_check_irq ();
rethink_cias ();
#ifdef A2065
rethink_a2065 ();
@ -3807,8 +3800,6 @@ static void ADKCON (int hpos, uae_u16 v)
DISK_update_adkcon (hpos, v);
setclr (&adkcon, v);
audio_update_adkmasks ();
if ((v >> 11) & 1)
serial_uartbreak ((adkcon >> 11) & 1);
}
static void BEAMCON0 (uae_u16 v)
@ -5375,13 +5366,10 @@ static void rtg_vsync (void)
static void rtg_vsynccheck (void)
{
if (vblank_found_rtg) {
vblank_found_rtg = false;
#ifdef PICASSO96
rtg_vsync ();
#endif
}
}
// moving average algorithm
@ -5419,7 +5407,6 @@ static int mavg (struct mavg_data *md, int newval, int size)
#define MAVG_VSYNC_SIZE 128
extern int log_vsync, debug_vsync_min_delay, debug_vsync_forced_delay;
static bool framewait (void)
{
frame_time_t curr_time;
@ -5457,12 +5444,6 @@ static bool framewait (void)
if (t > legacy_avg)
legacy_avg = t;
t = legacy_avg;
if (debug_vsync_min_delay && t < debug_vsync_min_delay * vsynctimebase / 100)
t = debug_vsync_min_delay * vsynctimebase / 100;
if (debug_vsync_forced_delay > 0)
t = debug_vsync_forced_delay * vsynctimebase / 100;
vsync_time = read_processor_time ();
if (t > vsynctimebase * 2 / 3)
t = vsynctimebase * 2 / 3;
@ -5475,11 +5456,6 @@ static bool framewait (void)
if (vsynctimeperline < 1)
vsynctimeperline = 1;
if (0 || (log_vsync & 2)) {
write_log (_T("%06d %06d/%06d %03d%%\n"), t, vsynctimeperline, vsynctimebase, t * 100 / vsynctimebase);
}
frame_shown = true;
return 1;
@ -5494,7 +5470,7 @@ static bool framewait (void)
if (vs == -2 || vs == -3) {
// fastest possible
int max, adjust, flipdelay, val;
int max, adjust, flipdelay = 0, val;
frame_time_t now;
static struct mavg_data ma_skip, ma_adjust;
@ -5507,10 +5483,8 @@ static bool framewait (void)
end = read_processor_time ();
val += end - start;
}
curr_time = vsync_busywait_end (&flipdelay); // vsync time
curr_time = 0;
status = vsync_busywait_do (NULL, (bplcon0 & 4) != 0 && !lof_changed && !lof_changing, lof_store != 0);
vsync_busywait_start ();
now = read_processor_time (); // current time
adjust = (int)now - (int)curr_time;
@ -5533,13 +5507,6 @@ static bool framewait (void)
}
val += frameskipt_avg;
if (currprefs.gfx_apmode[0].gfx_vflip == 0) {
if (debug_vsync_min_delay && val < debug_vsync_min_delay * vsynctimebase / 100)
val = debug_vsync_min_delay * vsynctimebase / 100;
if (debug_vsync_forced_delay > 0)
val = debug_vsync_forced_delay * vsynctimebase / 100;
}
//write_log (_T("%d "), adjust);
if (val > vsynctimebase * 2 / 3)
@ -5556,12 +5523,6 @@ static bool framewait (void)
if (status <= 0 || vsynctimeperline < 1)
vsynctimeperline = 1;
vsyncmaxtime = now + max;
if (0 || (log_vsync & 2)) {
write_log (_T("%05d:%05d:%05d=%05d:%05d/%05d %03d%%\n"), adjust_avg, frameskipt_avg, flipdelay_avg,
val, vsynctimeperline, vsynctimebase, val * 100 / vsynctimebase);
}
frame_shown = true;
} else {
@ -5571,13 +5532,11 @@ static bool framewait (void)
frame_time_t now;
flipdelay = 0;
curr_time = vsync_busywait_end (&flipdelay);
curr_time = 0;
if (!frame_rendered && !picasso_on)
frame_rendered = render_screen (false);
status = vsync_busywait_do (&freetime, (bplcon0 & 4) != 0 && !lof_changed && !lof_changing, lof_store != 0);
vsync_busywait_start ();
now = read_processor_time ();
if (extraframewait && !currprefs.turbo_emulation)
@ -5607,10 +5566,6 @@ static bool framewait (void)
if (currprefs.gfx_apmode[0].gfx_vflip == 0) {
int val = vsynctimebase - max;
if (debug_vsync_min_delay && val < debug_vsync_min_delay * vsynctimebase / 100)
val = debug_vsync_min_delay * vsynctimebase / 100;
if (debug_vsync_forced_delay > 0)
val = debug_vsync_forced_delay * vsynctimebase / 100;
max = vsynctimebase - val;
}
@ -5618,14 +5573,7 @@ static bool framewait (void)
if (status <= 0 || vsynctimeperline < 1)
vsynctimeperline = 1;
vsyncmaxtime = now + max;
if (0 || (log_vsync & 2)) {
write_log (_T("%06d:%06d:%06d:%06d %06d/%06d %03d%%\n"), frameskipt_avg, flipdelay_avg, adjust, adjustx,
vsynctimeperline, vsynctimebase, (vsynctimebase - max) * 100 / vsynctimebase);
}
frame_shown = true;
}
return status != 0;
}
@ -6383,7 +6331,7 @@ static void hsync_handler_post (bool onvsync)
vsyncmintime += vsynctimeperline;
linecounter++;
is_syncline = 0;
if (!vsync_isdone () && !currprefs.turbo_emulation) {
if (!currprefs.turbo_emulation) {
if ((int)vsyncmaxtime - (int)vsyncmintime > 0) {
if ((int)vsyncwaittime - (int)vsyncmintime > 0) {
frame_time_t rpt = read_processor_time ();
@ -6409,10 +6357,11 @@ static void hsync_handler_post (bool onvsync)
} else {
if (vpos + 1 < maxvpos + lof_store && (vpos == maxvpos_nom * 1 / 3 || vpos == maxvpos_nom * 2 / 3)) {
vsyncmintime += vsynctimeperline;
if (!vsync_isdone () && !currprefs.turbo_emulation) {
if (!currprefs.turbo_emulation) {
frame_time_t rpt = read_processor_time ();
// sleep if more than 2ms "free" time
while (!vsync_isdone () && (int)vsyncmintime - (int)(rpt + vsynctimebase / 10) > 0 && (int)vsyncmintime - (int)rpt < vsynctimebase) {
while ( ((int)vsyncmintime - (int)(rpt + vsynctimebase / 10) > 0)
&& ((int)vsyncmintime - (int)rpt < vsynctimebase) ) {
sleep_millis_main (1);
rpt = read_processor_time ();
//write_log (_T("*"));
@ -6472,7 +6421,6 @@ static void hsync_handler_post (bool onvsync)
cop_state.last_write = 0;
compute_spcflag_copper (maxhpos);
serial_hsynchandler ();
#ifdef CUSTOM_SIMPLE
do_sprites (0);
#endif
@ -6722,7 +6670,6 @@ void custom_reset (bool hardreset, bool keyboardreset)
if (!isrestore ()) {
/* must be called after audio_reset */
adkcon = 0;
serial_uartbreak (0);
audio_update_adkmasks ();
}

View File

@ -36,6 +36,8 @@
#include "rommgr.h"
#include "inputrecord.h"
#include "calc.h"
#include "cpummu.h"
#include "cpummu030.h"
#include "misc.h"
/* internal members */
@ -57,6 +59,7 @@ int debug_dma = 0;
int debug_sprite_mask = 0xff;
int debug_illegal = 0;
uae_u64 debug_illegal_mask;
static int debug_mmu_mode;
static uaecptr processptr;
static uae_char *processname;
@ -66,14 +69,10 @@ static uaecptr debug_copper_pc;
extern int audio_channel_mask;
extern int inputdevice_logging;
static FILE *logfile;
#ifndef _WIN32
#define console_out printf
#define console_flush() fflush( stdout )
#define console_get( input, len ) fgets( input, len, stdin )
#define console_out_f printf
#endif
void deactivate_debugger (void)
{
@ -158,12 +157,6 @@ static TCHAR help[] = {
" v <vpos> [<hpos>] Show DMA data (accurate only in cycle-exact mode).\n"
" v [-1 to -4] = enable visual DMA debugger.\n"
" ?<value> Hex ($ and 0x)/Bin (%)/Dec (!) converter.\n"
#ifdef _WIN32
" x Close debugger.\n"
" xx Switch between console and GUI debugger.\n"
" mg <address> Memory dump starting at <address> in GUI.\n"
" dg <address> Disassembly starting at <address> in GUI.\n"
#endif
" q Quit the emulator. You don't want to use this command.\n\n"
};
@ -192,6 +185,96 @@ static int debug_out (const TCHAR *format, ...)
return 1;
}
#ifdef MMUEMU
uae_u32 get_byte_debug (uaecptr addr)
{
uae_u32 v = 0xff;
if (debug_mmu_mode) {
flagtype olds = regs.s;
regs.s = (debug_mmu_mode & 4) != 0;
TRY(p) {
if (currprefs.mmu_model == 68030) {
v = mmu030_get_byte (addr, debug_mmu_mode, sz_byte);
} else {
v = mmu_get_byte (addr, (debug_mmu_mode & 1) ? true : false, sz_byte);
}
} CATCH(p) {
}
regs.s = olds;
} else {
v = get_byte (addr);
}
return v;
}
uae_u32 get_word_debug (uaecptr addr)
{
uae_u32 v = 0xffff;
if (debug_mmu_mode) {
flagtype olds = regs.s;
regs.s = (debug_mmu_mode & 4) != 0;
TRY(p) {
if (currprefs.mmu_model == 68030) {
v = mmu030_get_word (addr, debug_mmu_mode, sz_word);
} else {
v = mmu_get_word (addr, (debug_mmu_mode & 1) ? true : false, sz_word);
}
} CATCH(p) {
}
regs.s = olds;
} else {
v = get_word (addr);
}
return v;
}
uae_u32 get_long_debug (uaecptr addr)
{
uae_u32 v = 0xffffffff;
if (debug_mmu_mode) {
flagtype olds = regs.s;
regs.s = (debug_mmu_mode & 4) != 0;
TRY(p) {
if (currprefs.mmu_model == 68030) {
v = mmu030_get_long (addr, debug_mmu_mode, sz_long);
} else {
v = mmu_get_long (addr, (debug_mmu_mode & 1) ? true : false, sz_long);
}
} CATCH(p) {
}
regs.s = olds;
} else {
v = get_long (addr);
}
return v;
}
int safe_addr (uaecptr addr, int size)
{
if (debug_mmu_mode) {
flagtype olds = regs.s;
regs.s = (debug_mmu_mode & 4) != 0;
TRY(p) {
if (currprefs.mmu_model >= 68040)
addr = mmu_translate (addr, regs.s != 0, (debug_mmu_mode & 1), false);
else
addr = mmu030_translate (addr, regs.s != 0, (debug_mmu_mode & 1), false);
} CATCH(p) {
return 0;
}
regs.s = olds;
}
addrbank *ab = &get_mem_bank (addr);
if (!ab)
return 0;
if (ab->flags & ABFLAG_SAFE)
return 1;
if (!ab->check (addr, size))
return 0;
if (ab->flags & (ABFLAG_RAM | ABFLAG_ROM | ABFLAG_ROMIN | ABFLAG_SAFE))
return 1;
return 0;
}
#endif
static bool iscancel (int counter)
{
static int cnt;
@ -244,7 +327,6 @@ static int more_params (TCHAR **c)
}
static uae_u32 readint (TCHAR **c);
static uae_u32 readbin (TCHAR **c);
static uae_u32 readhex (TCHAR **c);
static int readregx (TCHAR **c, uae_u32 *valp)
@ -493,11 +575,13 @@ static uae_u32 readhex (TCHAR **c)
int size;
return readnum (c, &size, '$');
}
#if 0
static uae_u32 readbin (TCHAR **c)
{
int size;
return readnum (c, &size, '%');
}
#endif
static uae_u32 readint_2 (TCHAR **c, int *size)
{
return readnum (c, size, '!');
@ -539,7 +623,6 @@ static void converter (TCHAR **c)
{
uae_u32 v = readint (c);
TCHAR s[100];
TCHAR *p = s;
int i;
for (i = 0; i < 32; i++)
@ -662,7 +745,7 @@ static uaecptr nextaddr2 (uaecptr addr, uaecptr *next)
static uaecptr nextaddr (uaecptr addr, uaecptr last, uaecptr *end)
{
static uaecptr old;
uaecptr paddr = addr, next = 0;
uaecptr next = 0;
if (last && 0) {
if (addr >= last)
return 0xffffffff;
@ -694,20 +777,6 @@ static uaecptr nextaddr (uaecptr addr, uaecptr last, uaecptr *end)
return addr;
}
static int safe_addr(uaecptr addr, int size)
{
addrbank *ab = &get_mem_bank (addr);
if (!ab)
return 0;
if (ab->flags & ABFLAG_SAFE)
return 1;
if (!ab->check (addr, size))
return 0;
if (ab->flags & (ABFLAG_RAM | ABFLAG_ROM | ABFLAG_ROMIN | ABFLAG_SAFE))
return 1;
return 0;
}
uaecptr dumpmem2 (uaecptr addr, TCHAR *out, int osize)
{
int i, cols = 8;
@ -720,8 +789,8 @@ uaecptr dumpmem2 (uaecptr addr, TCHAR *out, int osize)
uae_u8 b1, b2;
b1 = b2 = 0;
if (safe_addr (addr, 1)) {
b1 = get_byte (addr + 0);
b2 = get_byte (addr + 1);
b1 = get_byte_debug (addr + 0);
b2 = get_byte_debug (addr + 1);
_stprintf (out + 9 + i * 5, _T("%02X%02X "), b1, b2);
out[9 + cols * 5 + 1 + i * 2 + 0] = b1 >= 32 && b1 < 127 ? b1 : '.';
out[9 + cols * 5 + 1 + i * 2 + 1] = b2 >= 32 && b2 < 127 ? b2 : '.';
@ -814,12 +883,12 @@ static void dump_vectors (uaecptr addr)
while (int_labels[i].name || trap_labels[j].name) {
if (int_labels[i].name) {
console_out_f (_T("$%08X %02d: %12s $%08X "), int_labels[i].adr + addr, int_labels[i].adr / 4,
int_labels[i].name, get_long (int_labels[i].adr + addr));
int_labels[i].name, get_long_debug (int_labels[i].adr + addr));
i++;
}
if (trap_labels[j].name) {
console_out_f (_T("$%08X %02d: %12s $%08X"), trap_labels[j].adr + addr, trap_labels[j].adr / 4,
trap_labels[j].name, get_long (trap_labels[j].adr + addr));
trap_labels[j].name, get_long_debug (trap_labels[j].adr + addr));
j++;
}
console_out (_T("\n"));
@ -1349,9 +1418,9 @@ static void listcheater(int mode, int size)
uae_u16 b;
if (size) {
b = get_byte (ts->addr);
b = get_byte_debug (ts->addr);
} else {
b = get_word (ts->addr);
b = get_word_debug (ts->addr);
}
if (mode)
console_out_f (_T("%08X=%04X "), ts->addr, b);
@ -1364,7 +1433,6 @@ static void listcheater(int mode, int size)
static void deepcheatsearch (TCHAR **c)
{
static int first = 1;
static uae_u8 *memtmp;
static int memsize, memsize2;
uae_u8 *p1, *p2;
@ -1395,7 +1463,6 @@ static void deepcheatsearch (TCHAR **c)
maxdiff = readint (c);
if (!memtmp || v == 'S') {
first = 1;
xfree (memtmp);
memsize = 0;
addr = 0xffffffff;
@ -1413,7 +1480,7 @@ static void deepcheatsearch (TCHAR **c)
while ((addr = nextaddr (addr, 0, &end)) != 0xffffffff) {
uaecptr i = addr;
for ( ; i < end; i++)
*p1++ = get_byte (i);
*p1++ = get_byte_debug (i);
addr = end - 1;
}
console_out (_T("Deep trainer first pass complete.\n"));
@ -1438,11 +1505,11 @@ static void deepcheatsearch (TCHAR **c)
int addrmask ;
if (size == 1) {
b = (uae_s8)get_byte (addr);
b = (uae_s8)get_byte_debug (addr);
b2 = (uae_s8)p1[addrcnt];
addrmask = 1 << (addrcnt & 7);
} else {
b = (uae_s16)get_word (addr);
b = (uae_s16)get_word_debug (addr);
b2 = (uae_s16)((p1[addrcnt] << 8) | p1[addrcnt + 1]);
addrmask = 3 << (addrcnt & 7);
}
@ -1515,7 +1582,7 @@ static void cheatsearch (TCHAR **c)
static int first = 1;
static int size = 1;
uae_u32 val, memcnt, prevmemcnt;
int i, count, vcnt, memsize;
int i, count, memsize;
uaecptr addr, end;
memsize = 0;
@ -1549,7 +1616,6 @@ static void cheatsearch (TCHAR **c)
}
count = 0;
vcnt = 0;
clearcheater ();
addr = 0xffffffff;
@ -1558,7 +1624,7 @@ static void cheatsearch (TCHAR **c)
if (addr + size < end) {
for (i = 0; i < size; i++) {
int shift = (size - i - 1) * 8;
if (get_byte (addr + i) != ((val >> shift) & 0xff))
if (get_byte_debug (addr + i) != ((val >> shift) & 0xff))
break;
}
if (i == size) {
@ -2635,17 +2701,17 @@ STATIC_INLINE uaecptr BPTR2APTR (uaecptr addr)
static void print_task_info (uaecptr node)
{
TCHAR *s;
int process = get_byte (node + 8) == 13 ? 1 : 0;
int process = get_byte_debug (node + 8) == 13 ? 1 : 0;
console_out_f (_T("%08X: "), node);
s = au ((char*)get_real_address (get_long (node + 10)));
s = au ((char*)get_real_address (get_long_debug (node + 10)));
console_out_f (process ? _T(" PROCESS '%s'\n") : _T(" TASK '%s'\n"), s);
xfree (s);
if (process) {
uaecptr cli = BPTR2APTR (get_long (node + 172));
int tasknum = get_long (node + 140);
uaecptr cli = BPTR2APTR (get_long_debug (node + 172));
int tasknum = get_long_debug (node + 140);
if (cli && tasknum) {
uae_u8 *command_bstr = get_real_address (BPTR2APTR (get_long (cli + 16)));
uae_u8 *command_bstr = get_real_address (BPTR2APTR (get_long_debug (cli + 16)));
console_out_f (_T(" [%d, '%s']\n"), tasknum, command_bstr);
} else {
console_out (_T("\n"));
@ -2655,45 +2721,45 @@ static void print_task_info (uaecptr node)
static void show_exec_tasks (void)
{
uaecptr execbase = get_long (4);
uaecptr taskready = get_long (execbase + 406);
uaecptr taskwait = get_long (execbase + 420);
uaecptr execbase = get_long_debug (4);
uaecptr taskready = get_long_debug (execbase + 406);
uaecptr taskwait = get_long_debug (execbase + 420);
uaecptr node, end;
console_out_f (_T("Execbase at 0x%08X\n"), execbase);
console_out (_T("Current:\n"));
node = get_long (execbase + 276);
node = get_long_debug (execbase + 276);
print_task_info (node);
console_out_f (_T("Ready:\n"));
node = get_long (taskready);
end = get_long (taskready + 4);
node = get_long_debug (taskready);
end = get_long_debug (taskready + 4);
while (node) {
print_task_info (node);
node = get_long (node);
node = get_long_debug (node);
}
console_out (_T("Waiting:\n"));
node = get_long (taskwait);
end = get_long (taskwait + 4);
node = get_long_debug (taskwait);
end = get_long_debug (taskwait + 4);
while (node) {
print_task_info (node);
node = get_long (node);
node = get_long_debug (node);
}
}
static uaecptr get_base (const uae_char *name)
{
uaecptr v = get_long (4);
uaecptr v = get_long_debug (4);
addrbank *b = &get_mem_bank(v);
if (!b || !b->check (v, 400) || b->flags != ABFLAG_RAM)
return 0;
v += 378; // liblist
while ( (v = get_long (v)) ) {
while (v = get_long_debug (v)) {
uae_u32 v2;
uae_u8 *p;
b = &get_mem_bank (v);
if (!b || !b->check (v, 32) || b->flags != ABFLAG_RAM)
goto fail;
v2 = get_long (v + 10); // name
v2 = get_long_debug (v + 10); // name
b = &get_mem_bank (v2);
if (!b || !b->check (v2, 20))
goto fail;
@ -2717,26 +2783,26 @@ static TCHAR *getfrombstr(uaecptr pp)
static void show_exec_lists (TCHAR t)
{
uaecptr execbase = get_long (4);
uaecptr execbase = get_long_debug (4);
uaecptr list = 0, node;
if (_totupper (t) == 'O') { // doslist
uaecptr dosbase = get_base ("dos.library");
if (dosbase) {
uaecptr rootnode = get_long (dosbase + 34);
uaecptr dosinfo = get_long (rootnode + 24) << 2;
uaecptr rootnode = get_long_debug (dosbase + 34);
uaecptr dosinfo = get_long_debug (rootnode + 24) << 2;
console_out_f (_T("ROOTNODE: %08x DOSINFO: %08x\n"), rootnode, dosinfo);
uaecptr doslist = get_long (dosinfo + 4) << 2;
uaecptr doslist = get_long_debug (dosinfo + 4) << 2;
while (doslist) {
int type = get_long (doslist + 4);
uaecptr msgport = get_long (doslist + 8);
TCHAR *name = getfrombstr (get_long (doslist + 40));
int type = get_long_debug (doslist + 4);
uaecptr msgport = get_long_debug (doslist + 8);
TCHAR *name = getfrombstr (get_long_debug (doslist + 40));
console_out_f (_T("%08x: %d %08x '%s'\n"), doslist, type, msgport, name);
if (type == 0) {
console_out_f (_T(" - H=%08x Stack=%5d Pri=%2d Start=%08x Seg=%08x GV=%08x\n"),
get_long (doslist + 16) << 2, get_long (doslist + 20),
get_long (doslist + 24), get_long (doslist + 28),
get_long (doslist + 32) << 2, get_long (doslist + 36));
get_long_debug (doslist + 16) << 2, get_long_debug (doslist + 20),
get_long_debug (doslist + 24), get_long_debug (doslist + 28),
get_long_debug (doslist + 32) << 2, get_long_debug (doslist + 36));
}
xfree (name);
doslist = get_long (doslist) << 2;
@ -2752,33 +2818,33 @@ static void show_exec_lists (TCHAR t)
for (unsigned int i = 0; i < 16; i++) {
console_out_f (_T("%2d %d: %08x\n"), i + 1, it2[i], list);
if (it[i]) {
console_out_f (_T(" [H] %08x\n"), get_long (list));
node = get_long (list + 8);
console_out_f (_T(" [H] %08x\n"), get_long_debug (list));
node = get_long_debug (list + 8);
if (node) {
uae_u8 *addr = get_real_address (get_long (node + 10));
uae_u8 *addr = get_real_address (get_long_debug (node + 10));
TCHAR *name = addr ? au ((char*)addr) : au("<null>");
console_out_f (_T(" %08x (C=%08X D=%08X) '%s'\n"), node, get_long (list + 4), get_long (list), name);
console_out_f (_T(" %08x (C=%08X D=%08X) '%s'\n"), node, get_long_debug (list + 4), get_long_debug (list), name);
xfree (name);
}
} else {
int cnt = 0;
node = get_long (list);
node = get_long (node);
while (get_long (node)) {
uae_u8 *addr = get_real_address (get_long (node + 10));
node = get_long_debug (list);
node = get_long_debug (node);
while (get_long_debug (node)) {
uae_u8 *addr = get_real_address (get_long_debug (node + 10));
TCHAR *name = addr ? au ((char*)addr) : au("<null>");
console_out_f (_T(" [S] %08x (C=%08x D=%08X) '%s'\n"), node, get_long (node + 18), get_long (node + 14), name);
console_out_f (_T(" [S] %08x (C=%08x D=%08X) '%s'\n"), node, get_long_debug (node + 18), get_long_debug (node + 14), name);
if (i == 4 - 1 || i == 14 - 1) {
if (!_tcsicmp (name, _T("cia-a")) || !_tcsicmp (name, _T("cia-b"))) {
static const TCHAR *ciai[] = { _T("A"), _T("B"), _T("ALRM"), _T("SP"), _T("FLG") };
uaecptr cia = node + 22;
for (unsigned int j = 0; j < 5; j++) {
uaecptr ciap = get_long (cia);
for (int j = 0; j < 5; j++) {
uaecptr ciap = get_long_debug (cia);
console_out_f (_T(" %5s: %08x"), ciai[j], ciap);
if (ciap) {
uae_u8 *addr2 = get_real_address (get_long (ciap + 10));
uae_u8 *addr2 = get_real_address (get_long_debug (ciap + 10));
TCHAR *name2 = addr ? au ((char*)addr2) : au("<null>");
console_out_f (_T(" (C=%08x D=%08X) '%s'"), get_long (ciap + 18), get_long (ciap + 14), name2);
console_out_f (_T(" (C=%08x D=%08X) '%s'"), get_long_debug (ciap + 18), get_long_debug (ciap + 14), name2);
xfree (name2);
}
console_out_f (_T("\n"));
@ -2787,7 +2853,7 @@ static void show_exec_lists (TCHAR t)
}
}
xfree (name);
node = get_long (node);
node = get_long_debug (node);
cnt++;
}
if (!cnt)
@ -2812,12 +2878,12 @@ static void show_exec_lists (TCHAR t)
}
if (list == 0)
return;
node = get_long (list);
while (get_long (node)) {
TCHAR *name = au ((char*)get_real_address (get_long (node + 10)));
node = get_long_debug (list);
while (get_long_debug (node)) {
TCHAR *name = au ((char*)get_real_address (get_long_debug (node + 10)));
console_out_f (_T("%08x %s\n"), node, name);
xfree (name);
node = get_long (node);
node = get_long_debug (node);
}
}
@ -2969,7 +3035,7 @@ static void savemem (TCHAR **cc)
return;
}
while (len > 0) {
b = get_byte (src);
b = get_byte_debug (src);
src++;
len--;
if (fwrite (&b, 1, 1, fp) != 1) {
@ -3049,7 +3115,7 @@ static void searchmem (TCHAR **cc)
if (addr == endaddr)
break;
for (i = 0; i < sslen; i++) {
uae_u8 b = get_byte (addr + i);
uae_u8 b = get_byte_debug (addr + i);
if (stringmode) {
if (tolower (b) != ss[i])
break;
@ -3184,11 +3250,11 @@ static void debug_sprite (TCHAR **inptr)
sh10 = 0;
saddr = addr;
width = size * 16;
w1 = get_word (addr);
w2 = get_word (addr + size * 2);
w1 = get_word_debug (addr);
w2 = get_word_debug (addr + size * 2);
console_out_f (_T(" %06X "), addr);
for (i = 0; i < size * 2; i++)
console_out_f (_T("%04X "), get_word (addr + i * 2));
console_out_f (_T("%04X "), get_word_debug (addr + i * 2));
console_out_f (_T("\n"));
ypos = w1 >> 8;
@ -3226,33 +3292,33 @@ static void debug_sprite (TCHAR **inptr)
if (addr2)
addr2 += size * 4;
if (size == 1) {
w1 = get_word (addr);
w2 = get_word (addr + 2);
w1 = get_word_debug (addr);
w2 = get_word_debug (addr + 2);
if (addr2) {
ww1 = get_word (addr2);
ww2 = get_word (addr2 + 2);
ww1 = get_word_debug (addr2);
ww2 = get_word_debug (addr2 + 2);
}
} else if (size == 2) {
w1 = get_long (addr);
w2 = get_long (addr + 4);
w1 = get_long_debug (addr);
w2 = get_long_debug (addr + 4);
if (addr2) {
ww1 = get_long (addr2);
ww2 = get_long (addr2 + 4);
ww1 = get_long_debug (addr2);
ww2 = get_long_debug (addr2 + 4);
}
} else if (size == 4) {
w1 = get_long (addr + 0);
w2 = get_long (addr + 8);
w1 = get_long_debug (addr + 0);
w2 = get_long_debug (addr + 8);
w1 <<= 32;
w2 <<= 32;
w1 |= get_long (addr + 4);
w2 |= get_long (addr + 12);
w1 |= get_long_debug (addr + 4);
w2 |= get_long_debug (addr + 12);
if (addr2) {
ww1 = get_long (addr2 + 0);
ww2 = get_long (addr2 + 8);
ww1 = get_long_debug (addr2 + 0);
ww2 = get_long_debug (addr2 + 8);
ww1 <<= 32;
ww2 <<= 32;
ww1 |= get_long (addr2 + 4);
ww2 |= get_long (addr2 + 12);
ww1 |= get_long_debug (addr2 + 4);
ww2 |= get_long_debug (addr2 + 12);
}
}
width = size * 16;
@ -3285,7 +3351,7 @@ static void debug_sprite (TCHAR **inptr)
console_out_f (_T("Attach: %d. AGA SSCAN/SH10 bit: %d\n"), attach, sh10);
addr += size * 4;
if (get_word (addr) == 0 && get_word (addr + size * 4) == 0)
if (get_word_debug (addr) == 0 && get_word_debug (addr + size * 4) == 0)
break;
max--;
if (max <= 0)
@ -3352,9 +3418,9 @@ static void find_ea (TCHAR **inptr)
if ((addr & 1) == 0 && addr + 6 <= end) {
sea = 0xffffffff;
dea = 0xffffffff;
m68k_disasm_ea (NULL, addr, NULL, 1, &sea, &dea);
m68k_disasm_ea (addr, NULL, 1, &sea, &dea);
if (ea == sea || ea == dea) {
m68k_disasm (stdout, addr, NULL, 1);
m68k_disasm (addr, NULL, 1);
hits++;
if (hits > 100) {
console_out_f (_T("Too many hits. End addr = %08X\n"), addr);
@ -3456,7 +3522,7 @@ static bool debug_line (TCHAR *input)
if (more_params(&inptr))
m68k_modify (&inptr);
else
m68k_dumpstate (stdout, &nextpc);
m68k_dumpstate (&nextpc);
}
break;
case 'D': deepcheatsearch (&inptr); break;
@ -3499,13 +3565,6 @@ static bool debug_line (TCHAR *input)
} else if (*inptr == 't') {
next_char (&inptr);
debugtest_set (&inptr);
#ifdef _WIN32
} else if (*inptr == 'g') {
extern void update_disassembly (uae_u32);
next_char (&inptr);
if (more_params (&inptr))
update_disassembly (readhex (&inptr));
#endif
} else {
uae_u32 daddr;
int count;
@ -3517,7 +3576,7 @@ static bool debug_line (TCHAR *input)
count = readhex (&inptr);
else
count = 10;
m68k_disasm (stdout, daddr, &nxdis, count);
m68k_disasm (daddr, &nxdis, count);
}
}
break;
@ -3623,9 +3682,9 @@ static bool debug_line (TCHAR *input)
if (history[temp].pc == addr || addr == 0) {
m68k_setpc (history[temp].pc);
if (badly)
m68k_dumpstate (stdout, NULL);
m68k_dumpstate (NULL);
else
m68k_disasm (stdout, history[temp].pc, NULL, 1);
m68k_disasm (history[temp].pc, NULL, 1);
if (addr && history[temp].pc == addr)
break;
}
@ -3668,15 +3727,17 @@ static bool debug_line (TCHAR *input)
{
uae_u32 maddr;
int lines;
#ifdef _WIN32
if (*inptr == 'g') {
extern void update_memdump (uae_u32);
next_char (&inptr);
if (more_params (&inptr))
update_memdump (readhex (&inptr));
if (*inptr == 'm' && inptr[1] == 'u') {
if (currprefs.mmu_model) {
inptr += 2;
if (more_params (&inptr))
debug_mmu_mode = readint (&inptr);
else
debug_mmu_mode = 0;
console_out_f (_T("MMU translation function code = %d\n"), debug_mmu_mode);
}
break;
}
#endif
if (more_params (&inptr)) {
maddr = readhex (&inptr);
} else {
@ -3721,7 +3782,7 @@ static bool debug_line (TCHAR *input)
return true;
break;
case 'U':
if (currprefs.cpu_model && more_params (&inptr)) {
if (currprefs.mmu_model && more_params (&inptr)) {
int i;
uaecptr addrl = readhex (&inptr);
uaecptr addrp;
@ -3731,10 +3792,16 @@ static bool debug_line (TCHAR *input)
bool data = (i & 1) != 0;
console_out_f (_T("S%dD%d="), super, data);
TRY(prb) {
addrp = mmu_translate (addrl, super, data, false);
if (currprefs.mmu_model >= 68040)
addrp = mmu_translate (addrl, super, data, false);
else
addrp = mmu030_translate (addrl, super, data, false);
console_out_f (_T("%08X"), addrp);
TRY(prb2) {
addrp = mmu_translate (addrl, super, data, true);
if (currprefs.mmu_model >= 68040)
addrp = mmu_translate (addrl, super, data, true);
else
addrp = mmu030_translate (addrl, super, data, true);
console_out_f (_T(" RW"));
} CATCH(prb2) {
console_out_f (_T(" RO"));
@ -3762,7 +3829,7 @@ static void debug_1 (void)
{
TCHAR input[MAX_LINEWIDTH];
m68k_dumpstate (stdout, &nextpc);
m68k_dumpstate (&nextpc);
nxdis = nextpc; nxmem = 0;
debugger_active = 1;
@ -3775,11 +3842,7 @@ static void debug_1 (void)
console_out (_T(">"));
console_flush ();
debug_linecounter = 0;
#if defined(_WIN32)
v = console_get (input, MAX_LINEWIDTH);
#else
v = _tcslen(console_get (input, MAX_LINEWIDTH));
#endif // _WIN32
if (v < 0)
return;
if (v == 0)
@ -3792,8 +3855,7 @@ static void debug_1 (void)
static void addhistory (void)
{
uae_u32 pc = m68k_getpc ();
// if (!notinrom())
// return;
history[lasthist] = regs;
history[lasthist].pc = m68k_getpc ();
if (++lasthist == MAX_HIST)
@ -3841,7 +3903,7 @@ void debug (void)
int bp = 0;
pc = munge24 (m68k_getpc ());
opcode = currprefs.cpu_model < 68020 && (currprefs.cpu_compatible || currprefs.cpu_cycle_exact) ? regs.ir : get_word (pc);
opcode = currprefs.cpu_model < 68020 && (currprefs.cpu_compatible || currprefs.cpu_cycle_exact) ? regs.ir : get_word_debug (pc);
for (i = 0; i < BREAKPOINT_TOTAL; i++) {
if (!bpnodes[i].enabled)
@ -3857,37 +3919,31 @@ void debug (void)
if (skipaddr_start == pc)
bp = 1;
if ((processptr || processname) && notinrom()) {
uaecptr execbase = get_long (4);
uaecptr activetask = get_long (execbase + 276);
int process = get_byte (activetask + 8) == 13 ? 1 : 0;
char *name = (char*)get_real_address (get_long (activetask + 10));
uaecptr execbase = get_long_debug (4);
uaecptr activetask = get_long_debug (execbase + 276);
int process = get_byte_debug (activetask + 8) == 13 ? 1 : 0;
char *name = (char*)get_real_address (get_long_debug (activetask + 10));
if (process) {
uaecptr cli = BPTR2APTR(get_long (activetask + 172));
uaecptr cli = BPTR2APTR(get_long_debug (activetask + 172));
uaecptr seglist = 0;
uae_char *command = NULL;
if (cli) {
if (processname)
command = (char*)get_real_address (BPTR2APTR(get_long (cli + 16)));
seglist = BPTR2APTR(get_long (cli + 60));
command = (char*)get_real_address (BPTR2APTR(get_long_debug (cli + 16)));
seglist = BPTR2APTR(get_long_debug (cli + 60));
} else {
seglist = BPTR2APTR(get_long (activetask + 128));
seglist = BPTR2APTR(get_long (seglist + 12));
seglist = BPTR2APTR(get_long_debug (activetask + 128));
seglist = BPTR2APTR(get_long_debug (seglist + 12));
}
if (activetask == processptr
|| (processname
&& (!strcasecmp (name, processname)
|| (command
&& command[0]
&& !strncasecmp (command + 1, processname, command[0])
&& processname[(int)command[0]] == 0)))) {
if (activetask == processptr || (processname && (!strcasecmp (name, processname) || (command && command[0] && !strncasecmp (command + 1, processname, command[0]) && processname[command[0]] == 0)))) {
while (seglist) {
uae_u32 size = get_long (seglist - 4) - 4;
uae_u32 size = get_long_debug (seglist - 4) - 4;
if (pc >= (seglist + 4) && pc < (seglist + size)) {
bp = 1;
break;
}
seglist = BPTR2APTR(get_long (seglist));
seglist = BPTR2APTR(get_long_debug (seglist));
}
}
}
@ -3979,7 +4035,7 @@ const TCHAR *debuginfo (int mode)
static TCHAR txt[100];
uae_u32 pc = M68K_GETPC;
_stprintf (txt, _T("PC=%08X INS=%04X %04X %04X"),
pc, get_word (pc), get_word (pc + 2), get_word (pc + 4));
pc, get_word_debug (pc), get_word_debug (pc + 2), get_word_debug (pc + 4));
return txt;
}
@ -4007,7 +4063,7 @@ struct mmunode {
struct mmunode *next;
};
static struct mmunode **mmunl;
//extern regstruct mmu_backup_regs;
extern struct regstruct mmu_backup_regs;
#define MMU_READ_U (1 << 0)
#define MMU_WRITE_U (1 << 1)
@ -4033,7 +4089,7 @@ void mmu_do_hit (void)
pc = m68k_getpc ();
p = mmu_regs + 18 * 4;
put_long (p, pc);
//regs = mmu_backup_regs;
regs = mmu_backup_regs;
regs.intmask = 7;
regs.t0 = regs.t1 = 0;
if (!regs.s) {
@ -4070,7 +4126,7 @@ void mmu_do_hit (void)
put_word (m68k_areg (regs, 7), 0x7002);
}
m68k_areg (regs, 7) -= 4;
put_long (m68k_areg (regs, 7), get_long (p - 4));
put_long (m68k_areg (regs, 7), get_long_debug (p - 4));
m68k_areg (regs, 7) -= 2;
put_word (m68k_areg (regs, 7), mmur.sr);
#ifdef JIT
@ -4167,13 +4223,13 @@ static int mmu_hit (uaecptr addr, int size, int rwi, uae_u32 *v)
switch (size)
{
case 4:
*v = get_long (maddr);
*v = get_long_debug (maddr);
break;
case 2:
*v = get_word (maddr);
*v = get_word_debug (maddr);
break;
case 1:
*v = get_byte (maddr);
*v = get_byte_debug (maddr);
break;
}
}
@ -4205,6 +4261,7 @@ static int mmu_hit (uaecptr addr, int size, int rwi, uae_u32 *v)
return 0;
}
#ifdef JIT
static void mmu_free_node(struct mmunode *mn)
{
if (!mn)
@ -4227,15 +4284,16 @@ static void mmu_free(void)
xfree (mmubanks);
mmubanks = NULL;
}
#endif
static int getmmubank(struct mmudata *snptr, uaecptr p)
{
snptr->flags = get_long (p);
snptr->flags = get_long_debug (p);
if (snptr->flags == 0xffffffff)
return 1;
snptr->addr = get_long (p + 4);
snptr->len = get_long (p + 8);
snptr->remap = get_long (p + 12);
snptr->addr = get_long_debug (p + 4);
snptr->len = get_long_debug (p + 8);
snptr->remap = get_long_debug (p + 12);
snptr->p_addr = p;
return 0;
}
@ -4246,8 +4304,8 @@ int mmu_init(int mode, uaecptr parm, uaecptr parm2)
int size;
struct mmudata *snptr;
struct mmunode *mn;
static int wasjit;
#ifdef JIT
static int wasjit;
if (currprefs.cachesize) {
wasjit = currprefs.cachesize;
changed_prefs.cachesize = 0;
@ -4274,21 +4332,21 @@ int mmu_init(int mode, uaecptr parm, uaecptr parm2)
p = parm;
mmu_struct = p;
if (get_long (p) != 1) {
console_out_f (_T("MMU: version mismatch %d <> %d\n"), get_long (p), 1);
if (get_long_debug (p) != 1) {
console_out_f (_T("MMU: version mismatch %d <> %d\n"), get_long_debug (p), 1);
return 0;
}
p += 4;
mmu_logging = get_long (p) & 1;
mmu_logging = get_long_debug (p) & 1;
p += 4;
mmu_callback = get_long (p);
mmu_callback = get_long_debug (p);
p += 4;
mmu_regs = get_long (p);
mmu_regs = get_long_debug (p);
p += 4;
if (mode == 3) {
int off;
uaecptr addr = get_long (parm2 + 4);
uaecptr addr = get_long_debug (parm2 + 4);
if (!mmu_enabled)
return 0;
off = addr >> MMU_PAGE_SHIFT;
@ -4309,12 +4367,12 @@ int mmu_init(int mode, uaecptr parm, uaecptr parm2)
mmu_slots = 1 << ((currprefs.address_space_24 ? 24 : 32) - MMU_PAGE_SHIFT);
mmunl = xcalloc (struct mmunode*, mmu_slots);
size = 1;
p2 = get_long (p);
while (get_long (p2) != 0xffffffff) {
p2 = get_long_debug (p);
while (get_long_debug (p2) != 0xffffffff) {
p2 += 16;
size++;
}
p = banks = get_long (p);
p = banks = get_long_debug (p);
snptr = mmubanks = xmalloc (struct mmudata, size);
for (;;) {
int off;
@ -4345,10 +4403,12 @@ void debug_parser (const TCHAR *cmd, TCHAR *out, uae_u32 outsize)
{
TCHAR empty[2] = { 0 };
TCHAR *input = my_strdup (cmd);
if (out == NULL || outsize == 0)
if (out == NULL && outsize == 0) {
setconsolemode (empty, 1);
else
} else if (out != NULL && outsize > 0) {
out[0] = 0;
setconsolemode (out, outsize);
}
debug_line (input);
setconsolemode (NULL, 0);
xfree (input);

View File

@ -41,12 +41,8 @@ int disk_debug_track = -1;
#include "catweasel.h"
#include "driveclick.h"
#ifdef CAPS
#ifdef _WIN32
#include "caps/caps_win32.h"
#else
#include "caps.h"
#endif
#endif
#include "crc32.h"
#include "inputdevice.h"
#include "amax.h"

View File

@ -350,14 +350,17 @@ extern int lof_store;
static int gclow, gcloh, gclox, gcloy, gclorealh;
void get_custom_topedge (int *x, int *y)
void get_custom_topedge (int *xp, int *yp, bool max)
{
if (isnativevidbuf ()) {
*x = visible_left_border + (DISPLAY_LEFT_SHIFT << currprefs.gfx_resolution);
*y = minfirstline << currprefs.gfx_vresolution;
if (isnativevidbuf () && !max) {
int x, y;
x = visible_left_border + (DISPLAY_LEFT_SHIFT << currprefs.gfx_resolution);
y = minfirstline << currprefs.gfx_vresolution;
*xp = x;
*yp = y;
} else {
*x = 0;
*y = 0;
*xp = 0;
*yp = 0;
}
}
@ -659,6 +662,25 @@ static int src_pixel, ham_src_pixel;
static int unpainted;
static int seen_sprites;
STATIC_INLINE xcolnr getbgc (bool blank)
{
#if 0
if (blank)
return xcolors[0x088];
else if (hposblank == 1)
return xcolors[0xf00];
else if (hposblank == 2)
return xcolors[0x0f0];
else if (hposblank == 3)
return xcolors[0x00f];
else if (brdblank)
return xcolors[0x880];
//return colors_for_drawing.acolors[0];
return xcolors[0xf0f];
#endif
return (blank || hposblank || colors_for_drawing.borderblank) ? 0 : colors_for_drawing.acolors[0];
}
/* Initialize the variables necessary for drawing a line.
* This involves setting up start/stop positions and display window
* borders. */
@ -781,24 +803,6 @@ STATIC_INLINE uae_u32 merge_2pixel32 (uae_u32 p1, uae_u32 p2)
return v;
}
STATIC_INLINE xcolnr getbgc (bool blank)
{
#if 0
if (blank)
return xcolors[0x088];
else if (hposblank == 1)
return xcolors[0xf00];
else if (hposblank == 2)
return xcolors[0x0f0];
else if (hposblank == 3)
return xcolors[0x00f];
else if (brdblank)
return xcolors[0x880];
return xcolors[0xf0f];
#endif
return (blank || hposblank || colors_for_drawing.borderblank) ? 0 : colors_for_drawing.acolors[0];
}
STATIC_INLINE void fill_line_16 (uae_u8 *buf, int start, int stop, bool blank)
{
uae_u16 *b = (uae_u16 *)buf;
@ -2852,7 +2856,7 @@ void redraw_frame (void)
flush_screen (0, 0);
}
void vsync_handle_check (void)
bool vsync_handle_check (void)
{
check_picasso ();
@ -2876,6 +2880,7 @@ void vsync_handle_check (void)
#endif
check_prefs_changed_custom ();
check_prefs_changed_cpu ();
return changed != 0;
}
void vsync_handle_redraw (int long_frame, int lof_changed, uae_u16 bplcon0p, uae_u16 bplcon3p)
@ -3041,13 +3046,11 @@ void reset_decision_table (void)
void reset_drawing (void)
{
unsigned int i;
max_diwstop = 0;
lores_reset ();
for (i = sizeof linestate / sizeof *linestate; i--;)
for (int i = sizeof linestate / sizeof *linestate; i--;)
linestate[i] = LINE_UNDECIDED;
init_aspect_maps ();

View File

@ -97,7 +97,7 @@ static void freesample (struct drvsample *s)
static void processclicks (struct drvsample *ds)
{
int n = 0;
int nClick = 0;
unsigned int nClick = 0;
for (n = 0; n < CLICK_TRACKS; n++) {
ds->indexes[n] = 0;

View File

@ -24,12 +24,6 @@
#ifdef ENFORCER
#ifndef _WIN32
#define console_out printf
#else
#define console_out(...) do {;} while (0)
#endif
//#if defined(AHI)
#if defined(JIT)
@ -376,7 +370,6 @@ static void enforcer_display_hit (const TCHAR *addressmode, uae_u32 pc, uaecptr
_stprintf (enforcer_buf_ptr, _T("Name: \"%s\"\n\n"), native_task_name);
enforcer_buf_ptr += _tcslen (enforcer_buf_ptr);
console_out (enforcer_buf);
write_log (enforcer_buf);
sleep_millis (5);
doflashscreen ();
@ -581,13 +574,14 @@ static void REGPARAM2 dummy_bput2 (uaecptr addr, uae_u32 b)
}
}
#if 0
static int REGPARAM2 dummy_check2 (uaecptr addr, uae_u32 size)
{
special_mem_r;
enforcer_display_hit (_T("CHECK from "),(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
return 0;
}
#endif 0
/*************************************************************
enable the enforcer like support, maybe later this make MMU

View File

@ -51,8 +51,6 @@ void do_cycles_slow (unsigned long cycles_to_add)
int i;
/* Keep only CPU emulation running while waiting for sync point. */
if (is_syncline) {
if (!vblank_found_chipset) {
if (is_syncline > 0) {
int rpt = read_processor_time ();
int v = rpt - vsyncmintime;
@ -71,10 +69,8 @@ void do_cycles_slow (unsigned long cycles_to_add)
pissoff = pissoff_value;
return;
}
}
}
is_syncline = 0;
}
is_syncline = 0;
cycles_to_add -= nextevent - currcycle;
currcycle = nextevent;

View File

@ -1384,10 +1384,6 @@ static uaecptr check_boot_rom (void)
return b;
if (currprefs.rtgmem_size)
return b;
#ifdef WIN32
if (currprefs.win32_automount_removable)
return b;
#endif
if (currprefs.chipmem_size > 2 * 1024 * 1024)
return b;
if (currprefs.z3chipmem_size)

View File

@ -82,12 +82,12 @@ static TCHAR *datalog (uae_u8 *src, int len) { return _T(""); }
#ifdef DEBUG
#define debuglog write_log
#else
#define debuglog
#define debuglog(...) { }
#endif
#ifdef VERBOSE
#define outlog write_log
#else
#define outlog
#define outlog(...) { }
#endif
static int fdi_allocated;

View File

@ -32,9 +32,10 @@ FreeMem = -210
PP_MAXSIZE = 4 * 96
PP_FSSIZE = 400
PP_FSPTR = 404
PP_FSRES = 408
PP_EXPLIB = 412
PP_FSHDSTART = 416
PP_ADDTOFSRES = 408
PP_FSRES = 412
PP_EXPLIB = 416
PP_FSHDSTART = 420
PP_TOTAL = (PP_FSHDSTART+140)
NOTIFY_CLASS = $40000000
@ -49,7 +50,9 @@ NRF_MAGIC = $80000000
our_seglist:
dc.l 0 ; 8 /* NextSeg */
start:
dc.l 9 ;0 12
bra.s startjmp
dc.w 9 ;0 12
startjmp:
bra.w filesys_mainloop ;1 16
dc.l make_dev-start ;2 20
dc.l filesys_init-start ;3 24
@ -605,7 +608,8 @@ r13
r0 move.l d7,d0
movem.l (sp)+,d1-d7/a1-a6
rts
ree moveq #0,d7
ree sub.l a0,a0
moveq #0,d7
bra.s r0
fsres:
@ -1021,9 +1025,12 @@ do_mount:
move.l d0,32(a3) ; dn_SegList
dont_mount:
tst.l PP_FSPTR(a1) ; filesystem?
beq.s nordbfs2
move.l PP_FSPTR(a1),a0
tst.l PP_FSSIZE(a1)
beq.s nordbfs3
; filesystem needs relocation?
move.l a0,d0
beq.s nordbfs2
bsr.w relocate
movem.l d0/a0-a1,-(sp)
move.l PP_FSSIZE(a1),d0
@ -1031,8 +1038,13 @@ dont_mount:
move.l 4.w,a6
jsr FreeMem(a6)
movem.l (sp)+,d0/a0-a1
clr.l PP_FSSIZE(a1)
move.l a0,PP_FSPTR(a1)
tst.l d0
beq.s nordbfs2
nordbfs3:
tst.l PP_ADDTOFSRES(a1)
beq.s nordbfs2
bsr.w addfs
nordbfs2:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -99,7 +99,7 @@ static int setfiletime (const TCHAR *name, int days, int minute, int tick, int t
bool my_utime (const TCHAR *name, struct mytimeval *tv)
{
int result = -1, tolocal;
int tolocal;
int days, mins, ticks;
struct mytimeval tv2;
@ -180,11 +180,11 @@ FILE *my_opentext (const TCHAR *name)
struct my_opendir_s *my_opendir (const TCHAR *name)
{
/*
struct my_opendir_s *mod;
TCHAR tmp[MAX_DPATH];
tmp[0] = 0;
/*
if (currprefs.win32_filesystem_mangle_reserved_names == false)
_tcscpy (tmp, PATHPREFIX);
_tcscat (tmp, name);
@ -225,6 +225,7 @@ int my_readdir (struct my_opendir_s *mod, TCHAR *name) {
return 1;
}
#if 0
static int recycle (const TCHAR *name)
{
/* DWORD dirattr = GetFileAttributesSafe (name);
@ -292,12 +293,14 @@ static int recycle (const TCHAR *name)
}*/
return 0;
}
#endif
int my_rmdir (const TCHAR *name)
{
struct my_opendir_s *od;
int cnt;
TCHAR tname[MAX_DPATH];
memset(tname, 0, sizeof(TCHAR) * MAX_DPATH);
/* SHFileOperation() ignores FOF_NORECURSION when deleting directories.. */
od = my_opendir (name);
@ -318,14 +321,12 @@ int my_rmdir (const TCHAR *name)
return -1;
}
// return recycle (name);
return rmdir (name);
}
/* "move to Recycle Bin" (if enabled) -version of DeleteFile() */
int my_unlink (const TCHAR *name)
{
// return recycle (name);
return unlink (name);
}
@ -447,7 +448,7 @@ HANDLE CreateFile(const TCHAR *lpFileName, DWORD dwDesiredAccess, DWORD dwShareM
}
int fd = 0;
mode = S_IREAD | S_IWRITE;
mode = S_IRUSR | S_IWUSR;
if (dwFlagsAndAttributes & FILE_FLAG_NO_BUFFERING)
flags |= O_SYNC;
@ -481,15 +482,8 @@ struct my_openfile_s *my_open (const TCHAR *name, int flags) {
DWORD FlagsAndAttributes = FILE_ATTRIBUTE_NORMAL;
DWORD attr;
const TCHAR *namep;
TCHAR path[MAX_DPATH];
/* if (currprefs.win32_filesystem_mangle_reserved_names == false) {
_tcscpy (path, PATHPREFIX);
_tcscat (path, name);
namep = path;
} else {*/
namep = name;
// }
namep = name;
mos = xmalloc (struct my_openfile_s, 1);
if (!mos)
return NULL;
@ -549,18 +543,11 @@ BOOL SetEndOfFile(HANDLE hFile) {
int my_truncate (const TCHAR *name, uae_u64 len) {
HANDLE hFile;
bool bResult = false;
int result = -1;
const TCHAR *namep;
TCHAR path[MAX_DPATH];
/* if (currprefs.win32_filesystem_mangle_reserved_names == false) {
_tcscpy (path, PATHPREFIX);
_tcscat (path, name);
namep = path;
} else {*/
namep = name;
// }
namep = name;
if ((hFile = CreateFile (namep, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ) ) != INVALID_HANDLE_VALUE ) {
LARGE_INTEGER li;
li.QuadPart = len;

View File

@ -8,6 +8,7 @@
#include "sysconfig.h"
#include "sysdeps.h"
#include "options.h"
#include "filesys.h"

View File

@ -120,26 +120,6 @@ float fp_1e0 = 1, fp_1e1 = 10, fp_1e2 = 100, fp_1e4 = 10000;
static __inline__ void native_set_fpucw (uae_u32 m68k_cw)
{
#ifdef _WIN32
static int ex = 0;
// RN, RZ, RM, RP
static unsigned int fp87_round[4] = { _RC_NEAR, _RC_CHOP, _RC_DOWN, _RC_UP };
// X, S, D, U
static unsigned int fp87_prec[4] = { _PC_64 , _PC_24 , _PC_53, 0 };
#if 0
if (m68k_cw & (0x0100 | 0x0200))
ex |= _EM_INEXACT;
if (m68k_cw & (0x0400))
ex |= _EM_ZERODIVIDE;
if (m68k_cw & (0x0800))
ex |= _EM_UNDERFLOW;
if (m68k_cw & (0x1000))
ex |= _EM_OVERFLOW;
#endif
_control87(ex | fp87_round[(m68k_cw >> 4) & 3] | fp87_prec[(m68k_cw >> 6) & 3], _MCW_RC | _MCW_PC);
#else
static uae_u16 x87_cw_tab[] = {
0x137f, 0x1f7f, 0x177f, 0x1b7f, /* Extended */
0x107f, 0x1c7f, 0x147f, 0x187f, /* Single */
@ -149,15 +129,10 @@ static uae_u16 x87_cw_tab[] = {
#if USE_X86_FPUCW
uae_u16 x87_cw = x87_cw_tab[(m68k_cw >> 4) & 0xf];
#if defined(X86_MSVC_ASSEMBLY)
__asm {
fldcw word ptr x87_cw
}
#elif defined(X86_ASSEMBLY)
#if defined(X86_ASSEMBLY)
__asm__ ("fldcw %0" : : "m" (*&x87_cw));
#endif
#endif
#endif
#endif // X86_ASSEMBLY
#endif // USE_X86_FPUCW
}
#if defined(HAS_uae_64) /* Close enough for government work? */

View File

@ -20,6 +20,7 @@
#include "fsusage.h"
#include "scsidev.h"
#include "fsdb.h"
#include "misc.h"
/* The on-disk format is as follows:
* Offset 0, 1 byte, valid
@ -44,7 +45,6 @@ TCHAR *nname_begin (TCHAR *nname)
return nname;
}
#ifndef _WIN32
#include "filesys_linux.c"
/* Find the name REL in directory DIRNAME. If we find a file that
@ -72,7 +72,6 @@ TCHAR *fsdb_search_dir (const TCHAR *dirname, TCHAR *rel)
my_closedir (dir);
return p;
}
#endif
static FILE *get_fsdb (a_inode *dir, const TCHAR *mode)
{

View File

@ -83,8 +83,7 @@ static int fsdb_name_invalid_2 (const TCHAR *n, int dir)
TCHAR a = n[0];
TCHAR b = (a == '\0' ? a : n[1]);
TCHAR c = (b == '\0' ? b : n[2]);
TCHAR d = (c == '\0' ? c : n[3]);
int l = _tcslen (n), ll;
int l = _tcslen (n);
/* the reserved fsdb filename */
if (_tcscmp (n, FSDB_FILE) == 0)
@ -104,25 +103,6 @@ static int fsdb_name_invalid_2 (const TCHAR *n, int dir)
if (c >= 'a' && c <= 'z')
c -= 32;
// if (currprefs.win32_filesystem_mangle_reserved_names) {
// /* reserved dos devices */
// ll = 0;
// if (a == 'A' && b == 'U' && c == 'X') ll = 3; /* AUX */
// if (a == 'C' && b == 'O' && c == 'N') ll = 3; /* CON */
// if (a == 'P' && b == 'R' && c == 'N') ll = 3; /* PRN */
// if (a == 'N' && b == 'U' && c == 'L') ll = 3; /* NUL */
// if (a == 'L' && b == 'P' && c == 'T' && (d >= '0' && d <= '9')) ll = 4; /* LPT# */
// if (a == 'C' && b == 'O' && c == 'M' && (d >= '0' && d <= '9')) ll = 4; /* COM# */
// /* AUX.anything, CON.anything etc.. are also illegal names */
// if (ll && (l == ll || (l > ll && n[ll] == '.')))
// return 1;
//
// /* spaces and periods at the end are a no-no */
// i = l - 1;
// if (n[i] == '.' || n[i] == ' ')
// return 1;
// }
/* these characters are *never* allowed */
for (i = 0; i < NUM_EVILCHARS; i++) {
if (_tcschr (n, evilchars[i]) != 0)

View File

@ -52,40 +52,6 @@ static long adjust_blocks (long blocks, int fromsize, int tosize)
return (blocks + (blocks < 0 ? -1 : 1)) / (tosize / fromsize);
}
#ifdef _WIN32
#include "sysdeps.h"
#include <windows.h>
int get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp)
{
char buf2[MAX_DPATH];
DWORD SectorsPerCluster;
DWORD BytesPerSector;
DWORD NumberOfFreeClusters;
DWORD TotalNumberOfClusters;
GetFullPathName (path, sizeof buf2, buf2, NULL);
buf2[3] = 0;
if (!GetDiskFreeSpace (buf2, &SectorsPerCluster, &BytesPerSector,
&NumberOfFreeClusters, &TotalNumberOfClusters)) {
/* lasterror = GetLastError ();*/
return -1;
}
/* HACK ALERT! WinNT returns 0 in TotalNumberOfClusters for an audio-CD, which calls the GURU! */
if ((TotalNumberOfClusters == 0) && (GetDriveType (buf2) == DRIVE_CDROM))
TotalNumberOfClusters = 327680;
BytesPerSector *= SectorsPerCluster;
fsp->fsu_blocks = adjust_blocks (TotalNumberOfClusters, BytesPerSector, 512);
fsp->fsu_bavail = adjust_blocks (NumberOfFreeClusters, BytesPerSector, 512);
return 0;
}
#else /* ! _WIN32 */
#if defined TARGET_AMIGAOS
#include <dos/dos.h>
@ -402,4 +368,3 @@ int
#endif /* ! __BEOS__ */
#endif /* ! TARGET_AMIGAOS */
#endif /* ! _WIN32 */

View File

@ -187,6 +187,7 @@ struct ide_hdf
int type;
int blocksize;
int maxtransferstate;
bool atapi;
};
#define TOTAL_IDE 3
@ -455,6 +456,7 @@ static void ide_identify_drive (void)
int v;
uae_u8 *buf = ide->secbuf;
TCHAR tmp[100];
bool atapi = ide->atapi;
if (ide->hdhfd.size == 0) {
ide_fail ();
@ -465,7 +467,7 @@ static void ide_identify_drive (void)
write_log (_T("IDE%d identify drive\n"), ide->num);
ide_data_ready ();
ide->data_size *= -1;
pw (0, 1 << 6);
pw (0, atapi ? 0x85c0 : 1 << 6);
pw (1, ide->hdhfd.cyls_def);
pw (2, 0xc837);
pw (3, ide->hdhfd.heads_def);
@ -507,7 +509,7 @@ static void ide_identify_drive (void)
pw (68, 120);
pw (80, (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6)); /* ATA-1 to ATA-6 */
pw (81, 0x1c); /* ATA revision */
pw (82, (1 << 14)); /* NOP command supported */
pw (82, (1 << 14) | (atapi ? 0x10 | 4 : 0)); /* NOP, ATAPI: PACKET and Removable media features supported */
pw (83, (1 << 14) | (1 << 13) | (1 << 12) | (ide->lba48 ? (1 << 10) : 0)); /* cache flushes, LBA 48 supported */
pw (84, 1 << 14);
pw (85, 1 << 14);
@ -527,13 +529,19 @@ static void ide_identify_drive (void)
static void ide_execute_drive_diagnostics (bool irq)
{
ide->regs->ide_error = 1;
ide->regs->ide_sector = ide->regs->ide_nsector = 1;
ide->regs->ide_select = 0;
ide->regs->ide_lcyl = ide->regs->ide_hcyl = 0;
if (ide->atapi) {
ide->regs->ide_sector = ide->regs->ide_nsector = 1;
ide->regs->ide_lcyl = 0x14;
ide->regs->ide_hcyl = 0xeb;
} else {
ide->regs->ide_sector = ide->regs->ide_nsector = 1;
ide->regs->ide_select = 0;
ide->regs->ide_lcyl = ide->regs->ide_hcyl = 0;
}
if (irq)
ide_interrupt ();
else
ide->status = ~IDE_STATUS_BSY;
ide->status &= ~IDE_STATUS_BSY;
}
static void ide_initialize_drive_parameters (void)
@ -735,6 +743,16 @@ static void ide_write_sectors (int flags)
ide->data_size = nsec * ide->blocksize;
}
static void atapi_packet (void)
{
ide->regs->ide_error = 1; /* C/D = 1 */
ide->status = IDE_STATUS_DRQ;
ide->data_size = (ide->regs->ide_hcyl << 8) | ide->regs->ide_lcyl;
if (ide->data_size == 65535)
ide->data_size = 65534;
}
static void ide_do_command (uae_u8 cmd)
{
int lba48 = ide->lba48;
@ -744,6 +762,16 @@ static void ide_do_command (uae_u8 cmd)
ide->status &= ~ (IDE_STATUS_DRDY | IDE_STATUS_DRQ | IDE_STATUS_ERR);
ide->regs->ide_error = 0;
if (ide->atapi) {
if (cmd == 0x08) { /* device reset */
ide_execute_drive_diagnostics (false);
} else if (cmd == 0xa1) { /* identify packet device */
ide_identify_drive ();
} else if (cmd == 0xa0) { /* packet */
atapi_packet ();
}
}
if (cmd == 0x10) { /* recalibrate */
ide_recalibrate ();
} else if (cmd == 0xec) { /* identify drive */
@ -753,6 +781,9 @@ static void ide_do_command (uae_u8 cmd)
} else if (cmd == 0x91) { /* initialize drive parameters */
ide_initialize_drive_parameters ();
} else if (cmd == 0xc6) { /* set multiple mode */
if (ide->atapi)
ide_fail ();
else
ide_set_multiple_mode ();
} else if (cmd == 0x20 || cmd == 0x21) { /* read sectors */
ide_read_sectors (0);
@ -772,8 +803,6 @@ static void ide_do_command (uae_u8 cmd)
ide_write_sectors (1|2);
} else if (cmd == 0x50) { /* format track (nop) */
ide_interrupt ();
} else if (cmd == 0xa1) { /* ATAPI identify (IDE HD is not ATAPI) */
ide_fail ();
} else if (cmd == 0xef) { /* set features */
ide_set_features ();
} else if (cmd == 0x00) { /* nop */
@ -912,9 +941,7 @@ static int get_gayle_ide_reg (uaecptr addr)
addr &= ~0x400;
}
}
ide = idedrive[ide2];
if (ide->regs->ide_drv)
ide = idedrive[ide2 + 1];
ide = idedrive[ide2 + (ide->regs->ide_drv ? 1 : 0)];
return addr;
}
@ -1541,18 +1568,17 @@ static void alloc_ide_mem (struct ide_hdf **ide, int max)
}
}
static struct ide_hdf *add_ide_unit (int ch, const TCHAR *path, int blocksize, int readonly,
const TCHAR *devname, int cyls, int sectors, int surfaces, int reserved,
int bootpri, const TCHAR *filesys,
int pcyls, int pheads, int psecs)
static struct ide_hdf *add_ide_unit (int ch, struct uaedev_config_info *ci)
{
struct ide_hdf *ide;
alloc_ide_mem (idedrive, TOTAL_IDE * 2);
ide = idedrive[ch];
if (!hdf_hd_open (&ide->hdhfd, path, blocksize, readonly, devname, cyls, sectors, surfaces, reserved, bootpri, filesys, pcyls, pheads, psecs))
if (ci)
memcpy (&ide->hdhfd.hfd.ci, ci, sizeof (struct uaedev_config_info));
if (!hdf_hd_open (&ide->hdhfd))
return NULL;
ide->blocksize = blocksize;
ide->blocksize = ide->hdhfd.hfd.ci.blocksize;
ide->lba48 = ide->hdhfd.size >= 128 * (uae_u64)0x40000000 ? 1 : 0;
ide->status = 0;
ide->data_offset = 0;
@ -1882,7 +1908,7 @@ static void checkflush (int addr)
}
if (pcmcia_write_min >= 0) {
if (abs (pcmcia_write_min - addr) >= 512 || abs (pcmcia_write_max - addr) >= 512) {
int blocksize = pcmcia_sram->hfd.blocksize;
int blocksize = pcmcia_sram->hfd.ci.blocksize;
int mask = ~(blocksize - 1);
int start = pcmcia_write_min & mask;
int end = (pcmcia_write_max + blocksize - 1) & mask;
@ -1939,21 +1965,24 @@ static int initpcmcia (const TCHAR *path, int readonly, int type, int reset)
pcmcia_sram = xcalloc (struct hd_hardfiledata, 1);
if (!pcmcia_sram->hfd.handle_valid)
reset = 1;
_tcscpy (pcmcia_sram->hfd.ci.rootdir, path);
pcmcia_sram->hfd.ci.readonly = readonly != 0;
pcmcia_sram->hfd.ci.blocksize = 512;
if (type == PCMCIA_SRAM) {
if (reset) {
if (path)
hdf_hd_open (pcmcia_sram, path, 512, readonly, NULL, 0, 0, 0, 0, 0, NULL, 0, 0, 0);
} else {
pcmcia_sram->hfd.drive_empty = 0;
}
if (reset) {
if (path)
hdf_hd_open (pcmcia_sram);
} else {
pcmcia_sram->hfd.drive_empty = 0;
}
if (pcmcia_sram->hfd.readonly)
readonly = 1;
pcmcia_common_size = 0;
pcmcia_readonly = readonly;
pcmcia_attrs_size = 256;
pcmcia_attrs = xcalloc (uae_u8, pcmcia_attrs_size);
if (pcmcia_sram->hfd.ci.readonly)
readonly = 1;
pcmcia_common_size = 0;
pcmcia_readonly = readonly;
pcmcia_attrs_size = 256;
pcmcia_attrs = xcalloc (uae_u8, pcmcia_attrs_size);
pcmcia_type = type;
if (!pcmcia_sram->hfd.drive_empty) {
@ -1975,8 +2004,13 @@ static int initpcmcia (const TCHAR *path, int readonly, int type, int reset)
} else if (type == PCMCIA_IDE) {
if (reset) {
if (path)
add_ide_unit (PCMCIA_IDE_ID * 2, path, 512, readonly, NULL, 0, 0, 0, 0, 0, NULL, 0, 0, 0);
if (path) {
struct uaedev_config_info ci = { 0 };
_tcscpy (ci.rootdir , path);
ci.blocksize = 512;
ci.readonly = readonly != 0;
add_ide_unit (PCMCIA_IDE_ID * 2, &ci);
}
}
pcmcia_common_size = 0;
@ -2254,21 +2288,19 @@ static void dumphdf (struct hardfiledata *hfd)
}
#endif
int gayle_add_ide_unit (int ch, const TCHAR *path, int blocksize, int readonly, const TCHAR *devname,
int cyls, int sectors, int surfaces, int reserved, int bootpri, const TCHAR *filesys,
int pcyls, int pheads, int psecs)
int gayle_add_ide_unit (int ch, struct uaedev_config_info *ci)
{
struct ide_hdf *ide;
if (ch >= 2 * 2)
return -1;
ide = add_ide_unit (ch, path, blocksize, readonly, devname, cyls, sectors, surfaces, reserved, bootpri, filesys, pcyls, pheads, psecs);
ide = add_ide_unit (ch, ci);
if (ide == NULL)
return 0;
write_log (_T("GAYLE_IDE%d '%s', LCHS=%d/%d/%d. PCHS=%d/%d/%d %uM. LBA48=%d\n"),
ch, path,
ch, ide->hdhfd.hfd.ci.rootdir,
ide->hdhfd.cyls, ide->hdhfd.heads, ide->hdhfd.secspertrack,
pcyls, pheads, psecs,
ide->hdhfd.hfd.ci.pcyls, ide->hdhfd.hfd.ci.pheads, ide->hdhfd.hfd.ci.psecs,
(int)(ide->hdhfd.size / (1024 * 1024)), ide->lba48);
ide->type = IDE_GAYLE;
//dumphdf (&ide->hdhfd.hfd);
@ -2315,6 +2347,10 @@ static void initide (void)
ideregs[i].ide_lcyl = ideregs[i].ide_hcyl = ideregs[i].ide_devcon = ideregs[i].ide_feat = 0;
idedrive[i * 2 + 0]->regs = &ideregs[i];
idedrive[i * 2 + 1]->regs = &ideregs[i];
ide = idedrive[i * 2 + 0];
ide_execute_drive_diagnostics (false);
ide = idedrive[i * 2 + 1];
ide_execute_drive_diagnostics (false);
}
ide_splitter = 0;
if (idedrive[2]->hdhfd.size) {
@ -2399,9 +2435,9 @@ uae_u8 *save_ide (int num, int *len, uae_u8 *dstptr)
dstbak = dst = xmalloc (uae_u8, 1000);
save_u32 (num);
save_u64 (ide->hdhfd.size);
save_string (ide->hdhfd.path);
save_u32 (ide->hdhfd.hfd.blocksize);
save_u32 (ide->hdhfd.hfd.readonly);
save_string (ide->hdhfd.hfd.ci.rootdir);
save_u32 (ide->hdhfd.hfd.ci.blocksize);
save_u32 (ide->hdhfd.hfd.ci.readonly);
save_u8 (ide->multiple_mode);
save_u32 (ide->hdhfd.cyls);
save_u32 (ide->hdhfd.heads);
@ -2420,10 +2456,10 @@ uae_u8 *save_ide (int num, int *len, uae_u8 *dstptr)
save_u8 (ide->regs->ide_error);
save_u8 (ide->regs->ide_devcon);
save_u64 (ide->hdhfd.hfd.virtual_size);
save_u32 (ide->hdhfd.hfd.secspertrack);
save_u32 (ide->hdhfd.hfd.heads);
save_u32 (ide->hdhfd.hfd.reservedblocks);
save_u32 (ide->hdhfd.bootpri);
save_u32 (ide->hdhfd.hfd.ci.sectors);
save_u32 (ide->hdhfd.hfd.ci.surfaces);
save_u32 (ide->hdhfd.hfd.ci.reserved);
save_u32 (ide->hdhfd.hfd.ci.bootpri);
*len = dst - dstbak;
return dstbak;
}
@ -2440,6 +2476,7 @@ uae_u8 *restore_ide (uae_u8 *src)
ide = idedrive[num];
size = restore_u64 ();
path = restore_string ();
_tcscpy (ide->hdhfd.hfd.ci.rootdir, path);
blocksize = restore_u32 ();
readonly = restore_u32 ();
ide->multiple_mode = restore_u8 ();
@ -2460,15 +2497,14 @@ uae_u8 *restore_ide (uae_u8 *src)
ide->regs->ide_error = restore_u8 ();
ide->regs->ide_devcon = restore_u8 ();
ide->hdhfd.hfd.virtual_size = restore_u64 ();
ide->hdhfd.hfd.secspertrack = restore_u32 ();
ide->hdhfd.hfd.heads = restore_u32 ();
ide->hdhfd.hfd.reservedblocks = restore_u32 ();
ide->hdhfd.bootpri = restore_u32 ();
ide->hdhfd.hfd.ci.sectors = restore_u32 ();
ide->hdhfd.hfd.ci.surfaces = restore_u32 ();
ide->hdhfd.hfd.ci.reserved = restore_u32 ();
ide->hdhfd.hfd.ci.bootpri = restore_u32 ();
if (ide->hdhfd.hfd.virtual_size)
gayle_add_ide_unit (num, path, blocksize, readonly, ide->hdhfd.hfd.device_name,
0, ide->hdhfd.hfd.secspertrack, ide->hdhfd.hfd.heads, ide->hdhfd.hfd.reservedblocks, ide->hdhfd.bootpri, NULL, 0, 0, 0);
gayle_add_ide_unit (num, NULL);
else
gayle_add_ide_unit (num, path, blocksize, readonly, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
gayle_add_ide_unit (num, NULL);
xfree (path);
return src;
}

View File

@ -99,7 +99,7 @@ static void generate_func(void)
if (a_is_on) {
printf("\tfor (i = 0; i < b->hblitsize; i++) {\n\t\tuae_u32 bltadat, srca;\n\n");
} else {
printf("\tfor (i = b->hblitsize; i--; ) {\n\t\tuae_u32 bltadat, srca;\n\n");
printf("\tfor (i = b->hblitsize; i--; ) {\n");
}
if (c_is_on) printf("\t\tif (ptc) { srcc = chipmem_wget_indirect (ptc); ptc += 2; }\n");
if (b_is_on) printf("\t\tif (ptb) {\n\t\t\tuae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb += 2;\n");
@ -180,7 +180,7 @@ static void generate_func(void)
if (a_is_on) {
printf("\tfor (i = 0; i < b->hblitsize; i++) {\n\t\tuae_u32 bltadat, srca;\n");
} else {
printf("\tfor (i = b->hblitsize; i--; ) {\n\t\tuae_u32 bltadat, srca;\n");
printf("\tfor (i = b->hblitsize; i--; ) {\n");
}
if (c_is_on) printf("\t\tif (ptc) { srcc = chipmem_wget_indirect (ptc); ptc -= 2; }\n");
if (b_is_on) printf("\t\tif (ptb) {\n\t\t\tuae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb -= 2;\n");

View File

@ -3134,38 +3134,38 @@ main (int argc, char **argv)
"");
stblfile = fopen ("compstbl.c", "wb");
if (freopen ("compemu.c", "wb", stdout))
generate_includes (stdout, 1);
if (freopen ("compemu.c", "wb", stdout))
generate_includes (stdout, 1);
generate_includes (stblfile, 1);
generate_includes (stblfile, 1);
printf("#include \"compemu.h\"\n");
printf("#include \"compemu.h\"\n");
noflags=0;
generate_func (noflags);
noflags=0;
generate_func (noflags);
xfree (opcode_map);
xfree (opcode_last_postfix);
xfree (opcode_next_clev);
xfree (counts);
opcode_map = xmalloc (int, nr_cpuop_funcs);
opcode_last_postfix = xmalloc (int, nr_cpuop_funcs);
opcode_next_clev = xmalloc (int, nr_cpuop_funcs);
counts = xmalloc (unsigned long, 65536);
opcode_map = xmalloc (int, nr_cpuop_funcs);
opcode_last_postfix = xmalloc (int, nr_cpuop_funcs);
opcode_next_clev = xmalloc (int, nr_cpuop_funcs);
counts = xmalloc (unsigned long, 65536);
read_counts ();
noflags=1;
generate_func (noflags);
read_counts ();
noflags=1;
generate_func (noflags);
printf ("#endif\n");
fprintf (stblfile, "#endif\n");
printf ("#endif\n");
fprintf (stblfile, "#endif\n");
xfree (opcode_map);
xfree (opcode_last_postfix);
xfree (opcode_next_clev);
xfree (counts);
xfree (table68k);
xfree (table68k);
return 0;
return 0;
}

View File

@ -50,6 +50,7 @@ static int using_tracer;
static int cpu_level;
static int count_read, count_write, count_cycles, count_ncycles;
static int count_read_ea, count_write_ea, count_cycles_ea;
static const char *mmu_postfix;
static int optimized_flags;
@ -73,7 +74,10 @@ static int *opcode_next_clev;
static int *opcode_last_postfix;
static unsigned long *counts;
static int generate_stbl;
static int fixupcnt;
static int mmufixupcnt;
static int mmufixupstate;
static int mmudisp020cnt;
#define GENA_GETV_NO_FETCH 0
#define GENA_GETV_FETCH 1
@ -87,6 +91,8 @@ static char *srcw, *dstw;
static char *srcb, *dstb;
static char *prefetch_long, *prefetch_word;
static char *srcli, *srcwi, *srcbi, *nextl, *nextw, *nextb;
static char *srcld, *dstld;
static char *srcwd, *dstwd;
static char *do_cycles, *disp000, *disp020;
static void read_counts (void)
@ -474,7 +480,7 @@ static void sync_m68k_pc (void)
static void gen_set_fault_pc (void)
{
if (!using_mmu)
if (using_mmu != 68040)
return;
sync_m68k_pc ();
printf ("\tregs.instruction_pc = m68k_getpci ();\n");
@ -493,6 +499,27 @@ static void syncmovepc (int getv, int flags)
#endif
}
static void addmmufixup (char *reg)
{
if (!using_mmu)
return;
if (using_mmu == 68040 && (mmufixupstate || mmufixupcnt > 0))
return;
printf ("\tmmufixup[%d].reg = %s;\n", mmufixupcnt, reg);
printf ("\tmmufixup[%d].value = m68k_areg (regs, %s);\n", mmufixupcnt, reg);
mmufixupstate |= 1 << mmufixupcnt;
mmufixupcnt++;
}
static void clearmmufixup (int cnt)
{
if (mmufixupstate & (1 << cnt)) {
printf ("\tmmufixup[%d].reg = -1;\n", cnt);
mmufixupstate &= ~(1 << cnt);
}
}
/* getv == 1: fetch data; getv != 0: check for odd address. If movem != 0,
* the calling routine handles Apdi and Aipi modes.
* gb-- movem == 2 means the same thing but for a MOVE16 instruction */
@ -504,7 +531,7 @@ static void syncmovepc (int getv, int flags)
* side effect in case a bus fault is generated by any memory access.
* XJ - 2006/11/13 */
static void genamode2 (amodes mode, char *reg, wordsizes size, char *name, int getv, int movem, int flags, int fixup)
static void genamode2 (amodes mode, char *reg, wordsizes size, char *name, int getv, int movem, int flags)
{
char namea[100];
int m68k_pc_offset_last = m68k_pc_offset;
@ -600,7 +627,7 @@ static void genamode2 (amodes mode, char *reg, wordsizes size, char *name, int g
start_brace ();
/* This would ordinarily be done in gen_nextiword, which we bypass. */
insn_n_cycles += 4;
printf ("\t%sa = %s (m68k_areg (regs, %s), %s ());\n", name, disp020, reg, nextw);
printf ("\t%sa = %s (m68k_areg (regs, %s), %d);\n", name, disp020, reg, mmudisp020cnt++);
} else {
if (!(flags & GF_AD8R)) {
addcycles000 (2);
@ -626,7 +653,7 @@ static void genamode2 (amodes mode, char *reg, wordsizes size, char *name, int g
/* This would ordinarily be done in gen_nextiword, which we bypass. */
insn_n_cycles += 4;
printf ("\ttmppc = m68k_getpc ();\n");
printf ("\t%sa = %s (tmppc, %s ());\n", name, disp020, nextw);
printf ("\t%sa = %s (tmppc, %d);\n", name, disp020, mmudisp020cnt++);
} else {
printf ("\ttmppc = m68k_getpc () + %d;\n", m68k_pc_offset);
if (!(flags & GF_PC8R)) {
@ -725,7 +752,7 @@ static void genamode2 (amodes mode, char *reg, wordsizes size, char *name, int g
if (flags & GF_PREFETCH)
fill_prefetch_next ();
else if (flags & GF_IR2IRC)
irc2ir (1);
irc2ir (true);
if (getv == 1) {
start_brace ();
@ -746,9 +773,9 @@ static void genamode2 (amodes mode, char *reg, wordsizes size, char *name, int g
} else if (using_mmu) {
if (flags & GF_FC) {
switch (size) {
case sz_byte: insn_n_cycles += 4; printf ("\tuae_s8 %s = sfc_get_byte (%sa);\n", name, name); break;
case sz_word: insn_n_cycles += 4; printf ("\tuae_s16 %s = sfc_get_word (%sa);\n", name, name); break;
case sz_long: insn_n_cycles += 8; printf ("\tuae_s32 %s = sfc_get_long (%sa);\n", name, name); break;
case sz_byte: insn_n_cycles += 4; printf ("\tuae_s8 %s = sfc%s_get_byte (%sa);\n", name, mmu_postfix, name); break;
case sz_word: insn_n_cycles += 4; printf ("\tuae_s16 %s = sfc%s_get_word (%sa);\n", name, mmu_postfix, name); break;
case sz_long: insn_n_cycles += 8; printf ("\tuae_s32 %s = sfc%s_get_long (%sa);\n", name, mmu_postfix, name); break;
default: abort ();
}
} else {
@ -774,10 +801,7 @@ static void genamode2 (amodes mode, char *reg, wordsizes size, char *name, int g
if (!movem)
switch (mode) {
case Aipi:
if (fixup == 1) {
printf ("\tmmufixup[%d].reg = %s;\n", fixupcnt, reg);
printf ("\tmmufixup[%d].value = m68k_areg (regs, %s);\n", fixupcnt, reg);
}
addmmufixup (reg);
switch (size) {
case sz_byte:
printf ("\tm68k_areg (regs, %s) += areg_byteinc[%s];\n", reg, reg);
@ -793,10 +817,7 @@ static void genamode2 (amodes mode, char *reg, wordsizes size, char *name, int g
}
break;
case Apdi:
if (fixup == 1) {
printf ("\tmmufixup[%d].reg = %s;\n", fixupcnt, reg);
printf ("\tmmufixup[%d].value = m68k_areg (regs, %s);\n", fixupcnt, reg);
}
addmmufixup (reg);
printf ("\tm68k_areg (regs, %s) = %sa;\n", reg, name);
break;
default:
@ -804,54 +825,15 @@ static void genamode2 (amodes mode, char *reg, wordsizes size, char *name, int g
}
}
static void genamode_fixup (amodes mode, char *reg, wordsizes size, char *name, int getv, int movem, int flags, int fixup)
{
if (fixup != 2) {
genamode2 (mode, reg, size, name, getv, movem, flags, fixup);
} else {
if (!movem) {
switch (mode)
{
case Dreg:
case Areg:
case Aind:
case Aipi:
break;
case Apdi:
printf("%s", "\tmmufixup[0].reg = -1;\n");
break;
case Ad16:
case Ad8r:
case absw:
case absl:
case PC16:
case PC8r:
case imm:
case imm0:
case imm1:
case imm2:
case immi:
case am_unknown:
case am_illg:
default:
break;
}
}
}
}
static void genamode (amodes mode, char *reg, wordsizes size, char *name, int getv, int movem, int flags)
{
genamode2 (mode, reg, size, name, getv, movem, flags, 0);
int oldfixup = mmufixupstate;
genamode2 (mode, reg, size, name, getv, movem, flags);
if (using_mmu == 68040 && (oldfixup & 1)) {
// we have fixup already active = this genamode call is destination mode and we can now clear previous source fixup.
clearmmufixup (0);
}
static void genamode_pre (amodes mode, char *reg, wordsizes size, char *name, int getv, int movem, int flags)
{
genamode_fixup (mode, reg, size, name, getv, movem, flags, using_mmu ? 1 : 0);
}
static void genamode_post (amodes mode, char *reg, wordsizes size, char *name, int getv, int movem, int flags)
{
if (using_mmu)
genamode_fixup (mode, reg, size, name, getv, movem, flags, 2);
}
static void genastore_2 (char *from, amodes mode, char *reg, wordsizes size, char *to, int store_dir, int flags)
@ -944,7 +926,7 @@ static void genastore_2 (char *from, amodes mode, char *reg, wordsizes size, cha
case sz_byte:
insn_n_cycles += 4;
if (flags & GF_FC)
printf ("\tdfc_put_byte (%sa, %s);\n", to, from);
printf ("\tdfc%s_put_byte (%sa, %s);\n", mmu_postfix, to, from);
else
printf ("\t%s (%sa, %s);\n", dstb, to, from);
break;
@ -953,7 +935,7 @@ static void genastore_2 (char *from, amodes mode, char *reg, wordsizes size, cha
if (cpu_level < 2 && (mode == PC16 || mode == PC8r))
abort ();
if (flags & GF_FC)
printf ("\tdfc_put_word (%sa, %s);\n", to, from);
printf ("\tdfc%s_put_word (%sa, %s);\n", mmu_postfix, to, from);
else
printf ("\t%s (%sa, %s);\n", dstw, to, from);
break;
@ -962,7 +944,7 @@ static void genastore_2 (char *from, amodes mode, char *reg, wordsizes size, cha
if (cpu_level < 2 && (mode == PC16 || mode == PC8r))
abort ();
if (flags & GF_FC)
printf ("\tdfc_put_long (%sa, %s);\n", to, from);
printf ("\tdfc%s_put_long (%sa, %s);\n", mmu_postfix, to, from);
else
printf ("\t%s (%sa, %s);\n", dstl, to, from);
break;
@ -1020,29 +1002,81 @@ static void genastore_fc (char *from, amodes mode, char *reg, wordsizes size, ch
genastore_2 (from, mode, reg, size, to, 1, GF_FC);
}
/* 68030 MMU does not restore register state if it bus faults.
* (also there wouldn't be enough space in stack frame to store all registers)
*/
static void movem_mmu030 (const char *code, int size, bool put, bool aipi, bool apdi)
{
char *index;
int dphase, aphase;
int i;
if (apdi) {
dphase = 1; aphase = 0;
index = "movem_index2";
} else {
dphase = 0; aphase = 1;
index = "movem_index1";
}
printf ("\tmmu030_state[1] |= MMU030_STATEFLAG1_MOVEM1;\n");
printf ("\tint movem_cnt = 0;\n");
for (i = 0; i < 2; i++) {
char reg;
if (i == dphase)
reg = 'd';
else
reg = 'a';
printf ("\twhile (%cmask) {\n", reg);
if (apdi)
printf ("\t\tsrca -= %d;\n", size);
printf ("\t\tif (mmu030_state[0] == movem_cnt) {\n");
printf ("\t\t\tif (mmu030_state[1] & MMU030_STATEFLAG1_MOVEM2) {\n");
printf ("\t\t\t\tmmu030_state[1] &= ~MMU030_STATEFLAG1_MOVEM2;\n");
if (!put)
printf ("\t\t\t\tm68k_%creg (regs, %s[%cmask]) = %smmu030_data_buffer;\n", reg, index, reg, size == 2 ? "(uae_s32)(uae_s16)" : "");
printf ("\t\t\t} else {\n");
if (put)
printf ("\t\t\t\t%s, m68k_%creg (regs, %s[%cmask]));\n", code, reg, index, reg);
else
printf ("\t\t\t\tm68k_%creg (regs, %s[%cmask]) = %s;\n", reg, index, reg, code);
printf ("\t\t\t}\n");
printf ("\t\t\tmmu030_state[0]++;\n");
printf ("\t\t}\n");
if (!apdi)
printf ("\t\tsrca += %d;\n", size);
printf ("\t\tmovem_cnt++;\n");
printf ("\t\t%cmask = movem_next[%cmask];\n", reg, reg);
printf ("\t}\n");
}
if (aipi || apdi)
printf ("\tm68k_areg (regs, dstreg) = srca;\n");
}
static void genmovemel (uae_u16 opcode)
{
char getcode[100];
int size = table68k[opcode].size == sz_long ? 4 : 2;
if (table68k[opcode].size == sz_long) {
sprintf (getcode, "%s (srca)", srcl);
sprintf (getcode, "%s (srca)", srcld);
} else {
sprintf (getcode, "(uae_s32)(uae_s16)%s (srca)", srcw);
sprintf (getcode, "(uae_s32)(uae_s16)%s (srca)", srcwd);
}
count_read += table68k[opcode].size == sz_long ? 2 : 1;
printf ("\tuae_u16 mask = %s;\n", gen_nextiword (0));
printf ("\tuae_u32 dmask = mask & 0xff, amask = (mask >> 8) & 0xff;\n");
genamode (table68k[opcode].dmode, "dstreg", table68k[opcode].size, "src", 2, 1, 0);
start_brace ();
printf ("\twhile (dmask) { m68k_dreg (regs, movem_index1[dmask]) = %s; srca += %d; dmask = movem_next[dmask]; }\n",
getcode, size);
printf ("\twhile (amask) { m68k_areg (regs, movem_index1[amask]) = %s; srca += %d; amask = movem_next[amask]; }\n",
getcode, size);
if (table68k[opcode].dmode == Aipi) {
printf ("\tm68k_areg (regs, dstreg) = srca;\n");
count_read++;
if (using_mmu == 68030) {
movem_mmu030 (getcode, size, false, table68k[opcode].dmode == Aipi, false);
} else {
printf ("\twhile (dmask) { m68k_dreg (regs, movem_index1[dmask]) = %s; srca += %d; dmask = movem_next[dmask]; }\n",
getcode, size);
printf ("\twhile (amask) { m68k_areg (regs, movem_index1[amask]) = %s; srca += %d; amask = movem_next[amask]; }\n",
getcode, size);
if (table68k[opcode].dmode == Aipi) {
printf ("\tm68k_areg (regs, dstreg) = srca;\n");
count_read++;
}
}
count_ncycles++;
fill_prefetch_next ();
@ -1083,35 +1117,43 @@ static void genmovemle (uae_u16 opcode)
int size = table68k[opcode].size == sz_long ? 4 : 2;
if (table68k[opcode].size == sz_long) {
sprintf (putcode, "%s (srca", dstl);
sprintf (putcode, "%s (srca", dstld);
} else {
sprintf (putcode, "%s (srca", dstw);
sprintf (putcode, "%s (srca", dstwd);
}
count_write += table68k[opcode].size == sz_long ? 2 : 1;
printf ("\tuae_u16 mask = %s;\n", gen_nextiword (0));
genamode (table68k[opcode].dmode, "dstreg", table68k[opcode].size, "src", 2, 1, 0);
start_brace ();
if (table68k[opcode].dmode == Apdi) {
printf ("\tuae_u16 amask = mask & 0xff, dmask = (mask >> 8) & 0xff;\n");
if (!using_mmu)
printf ("\tint type = get_cpu_model () >= 68020;\n");
printf ("\twhile (amask) {\n");
printf ("\t\tsrca -= %d;\n", size);
if (!using_mmu)
printf ("\t\tif (type) m68k_areg (regs, dstreg) = srca;\n");
printf ("\t\t%s, m68k_areg (regs, movem_index2[amask]));\n", putcode);
printf ("\t\tamask = movem_next[amask];\n");
printf ("\t}\n");
printf ("\twhile (dmask) { srca -= %d; %s, m68k_dreg (regs, movem_index2[dmask])); dmask = movem_next[dmask]; }\n",
size, putcode);
printf ("\tm68k_areg (regs, dstreg) = srca;\n");
if (using_mmu == 68030) {
if (table68k[opcode].dmode == Apdi)
printf ("\tuae_u16 amask = mask & 0xff, dmask = (mask >> 8) & 0xff;\n");
else
printf ("\tuae_u16 dmask = mask & 0xff, amask = (mask >> 8) & 0xff;\n");
movem_mmu030 (putcode, size, true, false, table68k[opcode].dmode == Apdi);
} else {
printf ("\tuae_u16 dmask = mask & 0xff, amask = (mask >> 8) & 0xff;\n");
printf ("\twhile (dmask) { %s, m68k_dreg (regs, movem_index1[dmask])); srca += %d; dmask = movem_next[dmask]; }\n",
putcode, size);
printf ("\twhile (amask) { %s, m68k_areg (regs, movem_index1[amask])); srca += %d; amask = movem_next[amask]; }\n",
putcode, size);
if (table68k[opcode].dmode == Apdi) {
printf ("\tuae_u16 amask = mask & 0xff, dmask = (mask >> 8) & 0xff;\n");
if (!using_mmu)
printf ("\tint type = get_cpu_model () >= 68020;\n");
printf ("\twhile (amask) {\n");
printf ("\t\tsrca -= %d;\n", size);
if (!using_mmu)
printf ("\t\tif (type) m68k_areg (regs, dstreg) = srca;\n");
printf ("\t\t%s, m68k_areg (regs, movem_index2[amask]));\n", putcode);
printf ("\t\tamask = movem_next[amask];\n");
printf ("\t}\n");
printf ("\twhile (dmask) { srca -= %d; %s, m68k_dreg (regs, movem_index2[dmask])); dmask = movem_next[dmask]; }\n",
size, putcode);
printf ("\tm68k_areg (regs, dstreg) = srca;\n");
} else {
printf ("\tuae_u16 dmask = mask & 0xff, amask = (mask >> 8) & 0xff;\n");
printf ("\twhile (dmask) { %s, m68k_dreg (regs, movem_index1[dmask])); srca += %d; dmask = movem_next[dmask]; }\n",
putcode, size);
printf ("\twhile (amask) { %s, m68k_areg (regs, movem_index1[amask])); srca += %d; amask = movem_next[amask]; }\n",
putcode, size);
}
}
count_ncycles++;
fill_prefetch_next ();
@ -1512,6 +1554,9 @@ static void gen_opcode (unsigned long int opcode)
insn_n_cycles = using_prefetch ? 0 : 4;
ir2irc = 0;
mmufixupcnt = 0;
mmufixupstate = 0;
mmudisp020cnt = 0;
prefetch_long = NULL;
srcli = NULL;
@ -1521,6 +1566,8 @@ static void gen_opcode (unsigned long int opcode)
nextw = NULL;
nextl = NULL;
do_cycles = "do_cycles";
srcwd = srcld = NULL;
dstwd = dstld = NULL;
if (using_indirect) {
// tracer
@ -1603,22 +1650,58 @@ static void gen_opcode (unsigned long int opcode)
srcb = "get_byte_ce020";
dstb = "put_byte_ce020";
}
} else if (using_mmu) {
} else if (using_mmu == 68030) {
// 68030 MMU
disp020 = "get_disp_ea_020_mmu030";
prefetch_long = "get_ilong_mmu030_state";
prefetch_word = "get_iword_mmu030_state";
nextw = "next_iword_mmu030_state";
nextl = "next_ilong_mmu030_state";
srcli = "get_ilong_mmu030_state";
srcwi = "get_iword_mmu030_state";
srcbi = "get_ibyte_mmu030_state";
srcl = "get_long_mmu030_state";
dstl = "put_long_mmu030_state";
srcw = "get_word_mmu030_state";
dstw = "put_word_mmu030_state";
srcb = "get_byte_mmu030_state";
dstb = "put_byte_mmu030_state";
srcld = "get_long_mmu030";
srcwd = "get_word_mmu030";
dstld = "put_long_mmu030";
dstwd = "put_word_mmu030";
} else if (using_mmu == 68040) {
// 68040 MMU
disp020 = "x_get_disp_ea_020";
prefetch_long = "get_ilong_mmu";
prefetch_word = "get_iword_mmu";
nextw = "next_iword_mmu";
nextl = "next_ilong_mmu";
srcli = "get_ilong_mmu";
srcwi = "get_iword_muu";
srcbi = "get_ibyte_mmu";
srcl = "get_long_mmu";
dstl = "put_long_mmu";
srcw = "get_word_mmu";
dstw = "put_word_mmu";
srcb = "get_byte_mmu";
dstb = "put_byte_mmu";
prefetch_long = "get_ilong_mmu040";
prefetch_word = "get_iword_mmu040";
nextw = "next_iword_mmu040";
nextl = "next_ilong_mmu040";
srcli = "get_ilong_mmu040";
srcwi = "get_iword_mmu040";
srcbi = "get_ibyte_mmu040";
srcl = "get_long_mmu040";
dstl = "put_long_mmu040";
srcw = "get_word_mmu040";
dstw = "put_word_mmu040";
srcb = "get_byte_mmu040";
dstb = "put_byte_mmu040";
} else if (using_mmu) {
// 68060 MMU
disp020 = "x_get_disp_ea_020";
prefetch_long = "get_ilong_mmu060";
prefetch_word = "get_iword_mmu060";
nextw = "next_iword_mmu060";
nextl = "next_ilong_mmu060";
srcli = "get_ilong_mmu060";
srcwi = "get_iword_mmu060";
srcbi = "get_ibyte_mmu060";
srcl = "get_long_mmu060";
dstl = "put_long_mmu060";
srcw = "get_word_mmu060";
dstw = "put_word_mmu060";
srcb = "get_byte_mmu060";
dstb = "put_byte_mmu060";
} else if (using_ce) {
// 68000 ce
prefetch_word = "get_word_ce000_prefetch";
@ -1656,6 +1739,14 @@ static void gen_opcode (unsigned long int opcode)
srcb = "get_byte";
dstb = "put_byte";
}
if (!dstld)
dstld = dstl;
if (!dstwd)
dstwd = dstw;
if (!srcld)
srcld = srcl;
if (!srcwd)
srcwd = srcw;
insn_n_cycles020 = 0;
@ -1775,9 +1866,8 @@ static void gen_opcode (unsigned long int opcode)
case i_SUBX:
if (!isreg (curi->smode))
addcycles000 (2);
genamode_pre (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA);
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA);
genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_AA);
genamode_post (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA);
fill_prefetch_next ();
if (curi->size == sz_long && isreg (curi->smode))
addcycles000 (4);
@ -1790,9 +1880,8 @@ static void gen_opcode (unsigned long int opcode)
case i_SBCD:
if (!isreg (curi->smode))
addcycles000 (2);
genamode_pre (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA);
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA);
genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_AA);
genamode_post (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA);
fill_prefetch_next ();
start_brace ();
printf ("\tuae_u16 newv_lo = (dst & 0xF) - (src & 0xF) - (GET_XFLG () ? 1 : 0);\n");
@ -1861,9 +1950,8 @@ static void gen_opcode (unsigned long int opcode)
case i_ADDX:
if (!isreg (curi->smode))
addcycles000 (2);
genamode_pre (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA);
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA);
genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_AA);
genamode_post (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA);
fill_prefetch_next ();
if (curi->size == sz_long && isreg (curi->smode))
addcycles000 (4);
@ -1876,9 +1964,8 @@ static void gen_opcode (unsigned long int opcode)
case i_ABCD:
if (!isreg (curi->smode))
addcycles000 (2);
genamode_pre (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA);
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA);
genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_AA);
genamode_post (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA);
fill_prefetch_next ();
start_brace ();
printf ("\tuae_u16 newv_lo = (src & 0xF) + (dst & 0xF) + (GET_XFLG () ? 1 : 0);\n");
@ -2006,9 +2093,8 @@ static void gen_opcode (unsigned long int opcode)
break;
case i_CMPM:
// confirmed
genamode_pre (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA);
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA);
genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_AA);
genamode_post (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA);
fill_prefetch_next ();
start_brace ();
genflags (flag_cmp, curi->size, "newv", "src", "dst");
@ -2036,11 +2122,11 @@ static void gen_opcode (unsigned long int opcode)
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0);
printf ("\tuaecptr memp = m68k_areg (regs, dstreg) + (uae_s32)(uae_s16)%s;\n", gen_nextiword (0));
if (curi->size == sz_word) {
printf ("\t%s (memp, src >> 8); %s (memp + 2, src);\n", dstb, dstb);
printf ("\t%s (memp, src >> 8);\n\t%s (memp + 2, src);\n", dstb, dstb);
count_write += 2;
} else {
printf ("\t%s (memp, src >> 24); %s (memp + 2, src >> 16);\n", dstb, dstb);
printf ("\t%s (memp + 4, src >> 8); %s (memp + 6, src);\n", dstb, dstb);
printf ("\t%s (memp, src >> 24);\n\t%s (memp + 2, src >> 16);\n", dstb, dstb);
printf ("\t%s (memp + 4, src >> 8);\n\t%s (memp + 6, src);\n", dstb, dstb);
count_write += 4;
}
fill_prefetch_next ();
@ -2072,10 +2158,9 @@ static void gen_opcode (unsigned long int opcode)
*/
int prefetch_done = 0, flags;
int dualprefetch = curi->dmode == absl && (curi->smode != Dreg && curi->smode != Areg && curi->smode != imm);
genamode_pre (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_MOVE);
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_MOVE);
flags = 1 | (dualprefetch ? GF_NOREFILL : 0);
genamode2 (curi->dmode, "dstreg", curi->size, "dst", 2, 0, flags | GF_MOVE, 0);
genamode_post (curi->smode, "srcreg", curi->size, "src", 1, 0, 0);
genamode (curi->dmode, "dstreg", curi->size, "dst", 2, 0, flags | GF_MOVE);
if (curi->mnemo == i_MOVEA && curi->size == sz_word)
printf ("\tsrc = (uae_s32)(uae_s16)src;\n");
if (curi->dmode == Apdi) {
@ -2236,10 +2321,10 @@ static void gen_opcode (unsigned long int opcode)
setpc ("pc");
printf ("\tMakeFromSR ();\n");
} else {
int old_brace_level = n_braces;
if (next_cpu_level < 0)
int old_brace_level = n_braces;
if (next_cpu_level < 0)
next_cpu_level = 0;
printf ("\tuae_u16 newsr; uae_u32 newpc;\n");
printf ("\tuae_u16 newsr; uae_u32 newpc;\n");
printf ("\tfor (;;) {\n");
printf ("\t\tuaecptr a = m68k_areg (regs, 7);\n");
printf ("\t\tuae_s16 sr = %s (a);\n", srcw);
@ -2248,27 +2333,35 @@ static void gen_opcode (unsigned long int opcode)
printf ("\t\tint frame = format >> 12;\n");
printf ("\t\tint offset = 8;\n");
printf ("\t\tnewsr = sr; newpc = pc;\n");
printf ("\t\tif (frame == 0x0) { m68k_areg (regs, 7) += offset; break; }\n");
printf ("\t\telse if (frame == 0x1) { m68k_areg (regs, 7) += offset; }\n");
printf ("\t\telse if (frame == 0x2) { m68k_areg (regs, 7) += offset + 4; break; }\n");
printf ("\t\telse if (frame == 0x4) { m68k_areg (regs, 7) += offset + 8; break; }\n");
if (using_mmu)
printf ("\t\telse if (frame == 0x7) { m68k_do_rte_mmu (a); m68k_areg (regs, 7) += offset + 52; break; }\n");
printf ("\t\telse if (frame == 0x8) { m68k_areg (regs, 7) += offset + 50; break; }\n");
printf ("\t\telse if (frame == 0x9) { m68k_areg (regs, 7) += offset + 12; break; }\n");
printf ("\t\telse if (frame == 0xa) { m68k_areg (regs, 7) += offset + 24; break; }\n");
printf ("\t\telse if (frame == 0xb) { m68k_areg (regs, 7) += offset + 84; break; }\n");
printf ("\t\telse { m68k_areg (regs, 7) += offset; Exception (14); goto %s; }\n", endlabelstr);
printf ("\t\tregs.sr = newsr; MakeFromSR ();\n}\n");
pop_braces (old_brace_level);
printf ("\tregs.sr = newsr; MakeFromSR ();\n");
printf ("\tif (newpc & 1) {\n");
printf ("\t\texception3i (0x%04lX, newpc);\n", opcode);
printf ("\t\tif (frame == 0x0) { m68k_areg (regs, 7) += offset; break; }\n");
printf ("\t\telse if (frame == 0x1) { m68k_areg (regs, 7) += offset; }\n");
printf ("\t\telse if (frame == 0x2) { m68k_areg (regs, 7) += offset + 4; break; }\n");
printf ("\t\telse if (frame == 0x4) { m68k_areg (regs, 7) += offset + 8; break; }\n");
printf ("\t\telse if (frame == 0x8) { m68k_areg (regs, 7) += offset + 50; break; }\n");
if (using_mmu == 68040) {
printf ("\t\telse if (frame == 0x7) { m68k_do_rte_mmu040 (a); m68k_areg (regs, 7) += offset + 52; break; }\n");
} else {
printf ("\t\telse if (frame == 0x7) { m68k_areg (regs, 7) += offset + 52; break; }\n");
}
printf ("\t\telse if (frame == 0x9) { m68k_areg (regs, 7) += offset + 12; break; }\n");
if (using_mmu == 68030) {
printf ("\t\telse if (frame == 0xa) { m68k_do_rte_mmu030 (a); break; }\n");
printf ("\t\telse if (frame == 0xb) { m68k_do_rte_mmu030 (a); break; }\n");
} else {
printf ("\t\telse if (frame == 0xa) { m68k_areg (regs, 7) += offset + 24; break; }\n");
printf ("\t\telse if (frame == 0xb) { m68k_areg (regs, 7) += offset + 84; break; }\n");
}
printf ("\t\telse { m68k_areg (regs, 7) += offset; Exception (14); goto %s; }\n", endlabelstr);
printf ("\t\tregs.sr = newsr; MakeFromSR ();\n}\n");
pop_braces (old_brace_level);
printf ("\tregs.sr = newsr; MakeFromSR ();\n");
printf ("\tif (newpc & 1) {\n");
printf ("\t\texception3i (0x%04lX, newpc);\n", opcode);
printf ("\t\tgoto %s;\n", endlabelstr);
printf ("\t}\n");
printf ("\t\tm68k_setpc (newpc);\n");
printf ("\t\tm68k_setpc (newpc);\n");
printf ("\tipl_fetch ();\n");
need_endlabel = 1;
need_endlabel = 1;
}
/* PC is set and prefetch filled. */
m68k_pc_offset = 0;
@ -2301,6 +2394,7 @@ static void gen_opcode (unsigned long int opcode)
case i_LINK:
// ce confirmed
if (using_mmu) {
addmmufixup ("srcreg");
genamode (curi->dmode, "dstreg", curi->size, "offs", GENA_GETV_FETCH, GENA_MOVEM_DO_INC, 0);
genamode (Apdi, "7", sz_long, "old", GENA_GETV_FETCH_ALIGN, GENA_MOVEM_DO_INC, 0);
genamode (curi->smode, "srcreg", sz_long, "src", GENA_GETV_FETCH, GENA_MOVEM_DO_INC, 0);
@ -2321,7 +2415,7 @@ static void gen_opcode (unsigned long int opcode)
// ce confirmed
if (using_mmu) {
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0);
printf ("\tuae_s32 old = get_long_mmu (src);\n");
printf ("\tuae_s32 old = %s (src);\n", srcl);
printf ("\tm68k_areg (regs, 7) = src + 4;\n");
printf ("\tm68k_areg (regs, srcreg) = old;\n");
} else {
@ -2341,7 +2435,7 @@ static void gen_opcode (unsigned long int opcode)
else if (using_ce)
printf ("\tm68k_do_rts_ce ();\n");
else if (using_mmu)
printf ("\tm68k_do_rts_mmu ();\n");
printf ("\tm68k_do_rts_mmu%s ();\n", mmu_postfix);
else
printf ("\tm68k_do_rts ();\n");
printf ("\tif (m68k_getpc () & 1) {\n");
@ -2365,9 +2459,8 @@ static void gen_opcode (unsigned long int opcode)
case i_RTR:
printf ("\tuaecptr oldpc = m68k_getpc ();\n");
printf ("\tMakeSR ();\n");
genamode_pre (Aipi, "7", sz_word, "sr", 1, 0, 0);
genamode (Aipi, "7", sz_word, "sr", 1, 0, 0);
genamode (Aipi, "7", sz_long, "pc", 1, 0, 0);
genamode_post (Aipi, "7", sz_word, "sr", 1, 0, 0);
printf ("\tregs.sr &= 0xFF00; sr &= 0xFF;\n");
printf ("\tregs.sr |= sr;\n");
setpc ("pc");
@ -2458,7 +2551,7 @@ static void gen_opcode (unsigned long int opcode)
} else if (using_ce) {
printf ("\tm68k_do_bsr_ce (m68k_getpc () + %d, s);\n", m68k_pc_offset);
} else if (using_mmu) {
printf ("\tm68k_do_bsr_mmu (m68k_getpc () + %d, s);\n", m68k_pc_offset);
printf ("\tm68k_do_bsr_mmu%s (m68k_getpc () + %d, s);\n", mmu_postfix, m68k_pc_offset);
} else {
printf ("\tm68k_do_bsr (m68k_getpc () + %d, s);\n", m68k_pc_offset);
}
@ -3214,6 +3307,8 @@ static void gen_opcode (unsigned long int opcode)
genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, 0);
if (cpu_level == 5 && curi->size > 0) {
printf ("\tif ((dsta & %d) && currprefs.cpu_compatible && get_cpu_model () == 68060) {\n", curi->size == 1 ? 1 : 3);
if (curi->dmode == Aipi || curi->dmode == Apdi)
printf ("\t\tm68k_areg (regs, dstreg) %c= %d;\n", curi->dmode == Aipi ? '-' : '+', 1 << curi->size);
printf ("\t\top_unimpl ();\n");
printf ("\t\tgoto %s;\n", endlabelstr);
printf ("\t}\n");
@ -3311,9 +3406,12 @@ static void gen_opcode (unsigned long int opcode)
printf ("\t} else {\n");
genastore ("src", Dreg, "(extra >> 12) & 7", curi->size, "");
printf ("\t}\n");
if (using_mmu == 68040)
sync_m68k_pc ();
pop_braces (old_brace_level);
}
sync_m68k_pc ();
if (using_mmu != 68040)
sync_m68k_pc ();
}
break;
case i_BKPT: /* only needed for hardware emulators */
@ -3443,10 +3541,12 @@ static void gen_opcode (unsigned long int opcode)
printf ("\tm68k_dreg (regs, dstreg) = (m68k_dreg (regs, dstreg) & 0xffffff00) | ((val >> 4) & 0xf0) | (val & 0xf);\n");
} else {
printf ("\tuae_u16 val;\n");
addmmufixup ("srcreg");
printf ("\tm68k_areg (regs, srcreg) -= areg_byteinc[srcreg];\n");
printf ("\tval = (uae_u16)%s (m68k_areg (regs, srcreg));\n", srcb);
printf ("\tm68k_areg (regs, srcreg) -= areg_byteinc[srcreg];\n");
printf ("\tval = (val | ((uae_u16)%s (m68k_areg (regs, srcreg)) << 8)) + %s;\n", srcb, gen_nextiword (0));
addmmufixup ("dstreg");
printf ("\tm68k_areg (regs, dstreg) -= areg_byteinc[dstreg];\n");
gen_set_fault_pc ();
printf ("\t%s (m68k_areg (regs, dstreg),((val >> 4) & 0xf0) | (val & 0xf));\n", dstb);
@ -3459,9 +3559,11 @@ static void gen_opcode (unsigned long int opcode)
printf ("\tm68k_dreg (regs, dstreg) = (m68k_dreg (regs, dstreg) & 0xffff0000) | (val & 0xffff);\n");
} else {
printf ("\tuae_u16 val;\n");
addmmufixup ("srcreg");
printf ("\tm68k_areg (regs, srcreg) -= areg_byteinc[srcreg];\n");
printf ("\tval = (uae_u16)%s (m68k_areg (regs, srcreg));\n", srcb);
printf ("\tval = (((val << 4) & 0xf00) | (val & 0xf)) + %s;\n", gen_nextiword (0));
addmmufixup ("dstreg");
if (cpu_level >= 2) {
printf ("\tm68k_areg (regs, dstreg) -= 2 * areg_byteinc[dstreg];\n");
printf ("\t%s (m68k_areg (regs, dstreg) + areg_byteinc[dstreg], val);\n", dstb);
@ -3548,7 +3650,7 @@ static void gen_opcode (unsigned long int opcode)
case i_CPUSHP:
case i_CPUSHA:
if (using_mmu)
printf ("\tflush_mmu(m68k_areg (regs, opcode & 3), (opcode >> 6) & 3);\n");
printf ("\tflush_mmu%s(m68k_areg (regs, opcode & 3), (opcode >> 6) & 3);\n", mmu_postfix);
#ifdef JIT
printf ("\tif (opcode & 0x80)\n");
printf ("\t\tflush_icache(m68k_areg (regs, opcode & 3), (opcode >> 6) & 3);\n");
@ -3559,36 +3661,46 @@ static void gen_opcode (unsigned long int opcode)
{
if ((opcode & 0xfff8) == 0xf620) {
/* MOVE16 (Ax)+,(Ay)+ */
printf ("\tuae_u32 v1, v2, v3, v4;\n");
printf ("\tuae_u32 v[4];\n");
printf ("\tuaecptr mems = m68k_areg (regs, srcreg) & ~15, memd;\n");
printf ("\tdstreg = (%s >> 12) & 7;\n", gen_nextiword (0));
printf ("\tmemd = m68k_areg (regs, dstreg) & ~15;\n");
printf ("\tv1 = %s (mems);\n", srcl);
printf ("\tv2 = %s (mems + 4);\n", srcl);
printf ("\tv3 = %s (mems + 8);\n", srcl);
printf ("\tv4 = %s (mems + 12);\n", srcl);
printf ("\t%s (memd , v1);\n", dstl);
printf ("\t%s (memd + 4, v2);\n", dstl);
printf ("\t%s (memd + 8, v3);\n", dstl);
printf ("\t%s (memd + 12, v4);\n", dstl);
if (using_mmu == 68060) {
printf ("\tget_move16_mmu060 (mems, v);\n");
printf ("\tput_move16_mmu060 (memd, v);\n");
} else {
printf ("\tv[0] = %s (mems);\n", srcl);
printf ("\tv[1] = %s (mems + 4);\n", srcl);
printf ("\tv[2] = %s (mems + 8);\n", srcl);
printf ("\tv[3] = %s (mems + 12);\n", srcl);
printf ("\t%s (memd , v[0]);\n", dstl);
printf ("\t%s (memd + 4, v[1]);\n", dstl);
printf ("\t%s (memd + 8, v[2]);\n", dstl);
printf ("\t%s (memd + 12, v[3]);\n", dstl);
}
printf ("\tif (srcreg != dstreg)\n");
printf ("\t\tm68k_areg (regs, srcreg) += 16;\n");
printf ("\tm68k_areg (regs, dstreg) += 16;\n");
} else {
/* Other variants */
printf ("\tuae_u32 v1, v2, v3, v4;\n");
printf ("\tuae_u32 v[4];\n");
genamode (curi->smode, "srcreg", curi->size, "mems", 0, 2, 0);
genamode (curi->dmode, "dstreg", curi->size, "memd", 0, 2, 0);
printf ("\tmemsa &= ~15;\n");
printf ("\tmemda &= ~15;\n");
printf ("\tv1 = %s (memsa);\n", srcl);
printf ("\tv2 = %s (memsa + 4);\n", srcl);
printf ("\tv3 = %s (memsa + 8);\n", srcl);
printf ("\tv4 = %s (memsa + 12);\n", srcl);
printf ("\t%s (memda , v1);\n", dstl);
printf ("\t%s (memda + 4, v2);\n", dstl);
printf ("\t%s (memda + 8, v3);\n", dstl);
printf ("\t%s (memda + 12, v4);\n", dstl);
if (using_mmu == 68060) {
printf ("\tget_move16_mmu060 (memsa, v);\n");
printf ("\tput_move16_mmu060 (memda, v);\n");
} else {
printf ("\tv[0] = %s (memsa);\n", srcl);
printf ("\tv[1] = %s (memsa + 4);\n", srcl);
printf ("\tv[2] = %s (memsa + 8);\n", srcl);
printf ("\tv[3] = %s (memsa + 12);\n", srcl);
printf ("\t%s (memda , v[0]);\n", dstl);
printf ("\t%s (memda + 4, v[1]);\n", dstl);
printf ("\t%s (memda + 8, v[2]);\n", dstl);
printf ("\t%s (memda + 12, v[3]);\n", dstl);
}
if ((opcode & 0xfff8) == 0xf600)
printf ("\tm68k_areg (regs, srcreg) += 16;\n");
else if ((opcode & 0xfff8) == 0xf608)
@ -3610,7 +3722,7 @@ static void gen_opcode (unsigned long int opcode)
break;
case i_MMUOP030:
printf ("\tuaecptr pc = m68k_getpc ();\n");
printf ("\tuae_u16 extra = x_get_word (pc + 2);\n");
printf ("\tuae_u16 extra = %s (2);\n", prefetch_word);
m68k_pc_offset += 2;
sync_m68k_pc ();
if (curi->smode == Areg || curi->smode == Dreg)
@ -3639,7 +3751,7 @@ static void gen_opcode (unsigned long int opcode)
did_prefetch = 0;
}
static void generate_includes (FILE * f)
static void generate_includes (FILE * f, int id)
{
fprintf (f, "#include \"sysconfig.h\"\n");
fprintf (f, "#include \"sysdeps.h\"\n");
@ -3651,8 +3763,10 @@ static void generate_includes (FILE * f)
fprintf (f, "#include \"machdep/m68kops.h\"\n");
fprintf (f, "#include \"cpu_prefetch.h\"\n");
fprintf (f, "#include \"cputbl.h\"\n");
fprintf (f, "#include \"cpummu.h\"\n");
if (id == 31 || id == 33)
fprintf (f, "#include \"cpummu.h\"\n");
else if (id == 32)
fprintf (f, "#include \"cpummu030.h\"\n");
fprintf (f, "#define CPUFUNC(x) x##_ff\n"
"#define SET_CFLG_ALWAYS(x) SET_CFLG(x)\n"
@ -3873,6 +3987,8 @@ static void generate_one_opcode (int rp, char *extra)
gen_opcode (opcode);
if (need_endlabel)
printf ("%s: ;\n", endlabelstr);
clearmmufixup (0);
clearmmufixup (1);
returncycles ("", insn_n_cycles);
printf ("}");
if (using_ce || using_prefetch) {
@ -3951,21 +4067,21 @@ static void generate_cpu (int id, int mode)
}
postfix = id;
if (id == 0 || id == 11 || id == 12 || id == 20 || id == 21 || id == 22 || id == 31) {
if (id == 0 || id == 11 || id == 12 || id == 20 || id == 21 || id == 22 || id == 31 || id == 32 || id == 33) {
if (generate_stbl)
fprintf (stblfile, "#ifdef CPUEMU_%d%s\n", postfix, extraup);
postfix2 = postfix;
sprintf (fname, "cpuemu_%d%s.c", postfix, extra);
if (freopen (fname, "wb", stdout))
generate_includes (stdout);
generate_includes (stdout, id);
}
using_mmu = 0;
using_prefetch = 0;
using_prefetch_020 = 0;
using_ce = 0;
using_ce020 = 0;
using_mmu = 0;
mmu_postfix = "";
if (id == 11 || id == 12) { // 11 = 68000 prefetch, 12 = 68000 cycle-exact
cpu_level = 0;
@ -3995,10 +4111,24 @@ static void generate_cpu (int id, int mode)
for (rp = 0; rp < nr_cpuop_funcs; rp++)
opcode_next_clev[rp] = cpu_level;
}
} else if (id >= 31 && id < 40) { // 31 = 68040 MMU
} else if (id == 31) { // 31 = 68040 MMU
mmu_postfix = "040";
cpu_level = 4;
using_mmu = 1;
if (id == 31)
using_mmu = 68040;
read_counts ();
for (rp = 0; rp < nr_cpuop_funcs; rp++)
opcode_next_clev[rp] = cpu_level;
} else if (id == 32) { // 32 = 68030 MMU
mmu_postfix = "030";
cpu_level = 3;
using_mmu = 68030;
read_counts ();
for (rp = 0; rp < nr_cpuop_funcs; rp++)
opcode_next_clev[rp] = cpu_level;
} else if (id == 33) { // 33 = 68060 MMU
mmu_postfix = "060";
cpu_level = 5;
using_mmu = 68060;
read_counts ();
for (rp = 0; rp < nr_cpuop_funcs; rp++)
opcode_next_clev[rp] = cpu_level;
@ -4047,14 +4177,14 @@ int main (int argc, char **argv)
headerfile = fopen ("cputbl.h", "wb");
stblfile = fopen ("cpustbl.c", "wb");
generate_includes (stblfile);
generate_includes (stblfile, 0);
using_prefetch = 0;
using_indirect = 0;
using_exception_3 = 1;
using_ce = 0;
for (i = 0; i < 32; i++) {
for (i = 0; i <= 33; i++) {
if ((i >= 6 && i < 11) || (i > 12 && i < 20) || (i > 24 && i < 31))
continue;
generate_stbl = 1;

View File

@ -2381,15 +2381,6 @@ static int get_mouse_widget_type (unsigned int mouse, unsigned int num, char *na
return IDEV_WIDGET_NONE;
}
static int get_mouse_flags (int num)
{
/* if (di_mouse[num].rawinput || !rawinput_enabled_mouse)
return 0;
if (di_mouse[num].catweasel)
return 0;*/
return 1;
}
static void read_mouse (void)
{
/* We handle mouse input in handle_events() */
@ -2397,11 +2388,7 @@ static void read_mouse (void)
static int get_mouse_flags (int num)
{
/* if (di_mouse[num].rawinput || !rawinput_enabled_mouse)
return 0;
if (di_mouse[num].catweasel)
return 0;*/
return 1;
}
struct inputdevice_functions inputdevicefunc_mouse = {

View File

@ -489,11 +489,7 @@ static int get_mouse_widget_type (unsigned int mouse, unsigned int num, char *na
static int get_mouse_flags (int num)
{
/* if (di_mouse[num].rawinput || !rawinput_enabled_mouse)
return 0;
if (di_mouse[num].catweasel)
return 0;*/
return 1;
return 0;
}
static void read_mouse (void)

View File

@ -26,7 +26,7 @@
#ifdef PICASSO96
#include "picasso96.h"
static int screen_is_picasso;
extern int screen_is_picasso;
#endif
// -----
@implementation PUAE_GLView
@ -103,11 +103,6 @@ void gfx_set_picasso_modeinfo (uae_u32 w, uae_u32 h, uae_u32 depth, RGBFTYPE rgb
{
}
int WIN32GFX_IsPicassoScreen (void)
{
return screen_is_picasso;
}
int picasso_palette (void)
{
return 0;

View File

@ -756,11 +756,7 @@ static void read_mouse (void)
static int get_mouse_flags (int num)
{
/* if (di_mouse[num].rawinput || !rawinput_enabled_mouse)
return 0;
if (di_mouse[num].catweasel)
return 0;*/
return 1;
return 0;
}
struct inputdevice_functions inputdevicefunc_mouse = {

View File

@ -34,12 +34,8 @@ void setupExtensions(void);
void setmaintitle (void);
int mousehack_allowed (void);
int is_vsync (void);
int WIN32GFX_IsPicassoScreen (void);
uae_u8 *gfx_lock_picasso (bool fullupdate, bool doclear);
void gfx_unlock_picasso (bool dorender);
int is_vsync (void);
int WIN32GFX_IsPicassoScreen (void);
#ifdef USE_GL
#define NO_SDL_GLEXT
@ -53,10 +49,7 @@ int WIN32GFX_IsPicassoScreen (void);
# endif
#ifdef GL_SHADER
#ifdef __WIN32__
#define uglGetProcAddress(x) wglGetProcAddress(x)
#define WIN32_OR_X11
#elifdef __APPLE__
#ifdef __APPLE__
#include <OpenGL/glu.h>
#include <OpenGL/glext.h>
void setupExtensions(void)
@ -65,7 +58,7 @@ int WIN32GFX_IsPicassoScreen (void);
#include <GL/glx.h>
#include <GL/glxext.h>
#define uglGetProcAddress(x) (*glXGetProcAddressARB)((const GLubyte*)(x))
#define WIN32_OR_X11
#define X11_GL
#else
void setupExtensions(void)
{ shading_enabled = 0; } // just fail otherwise?
@ -141,8 +134,8 @@ static int red_shift, green_shift, blue_shift, alpha_shift;
static int alpha;
#ifdef PICASSO96
static int screen_is_picasso;
static int screen_was_picasso;
extern int screen_is_picasso;
extern int screen_was_picasso;
static char picasso_invalid_lines[1201];
static int picasso_has_invalid_lines;
static int picasso_invalid_start, picasso_invalid_stop;
@ -253,7 +246,7 @@ unsigned int mouse_capture;
TCHAR config_filename[256] = "";
#if defined(WIN32_OR_X11) && defined(GL_SHADER)
#if defined(X11_GL)
PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB = NULL;
PFNGLDELETEOBJECTARBPROC glDeleteObjectARB = NULL;
PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB = NULL;
@ -342,7 +335,7 @@ void setupExtensions(void)
} else
shading_enabled = 0;
}
#endif /* defined(WIN32_OR_X11) && defined(GL_SHADER) */
#endif /* defined(X11_GL) */
/*
* What graphics platform are we running on . . .?
@ -2012,11 +2005,7 @@ static void read_mouse (void)
static int get_mouse_flags (int num)
{
/* if (di_mouse[num].rawinput || !rawinput_enabled_mouse)
return 0;
if (di_mouse[num].catweasel)
return 0;*/
return 1;
return 0;
}
struct inputdevice_functions inputdevicefunc_mouse = {
@ -2193,7 +2182,7 @@ void setcapslockstate (int state)
/*
* Default inputdevice config for SDL mouse
*/
int input_get_default_mouse (struct uae_input_device *uid, int num, int port, int af, bool gp)
int input_get_default_mouse (struct uae_input_device *uid, int num, int port, int af, bool gp, bool wheel)
{
/* SDL supports only one mouse */
setid (uid, num, ID_AXIS_OFFSET + 0, 0, port, port ? INPUTEVENT_MOUSE2_HORIZ : INPUTEVENT_MOUSE1_HORIZ);
@ -2258,11 +2247,6 @@ int gfx_parse_option (struct uae_prefs *p, const char *option, const char *value
return result;
}
int WIN32GFX_IsPicassoScreen (void)
{
return screen_is_picasso;
}
int target_checkcapslock (int scancode, int *state)
{
if (scancode != DIK_CAPITAL && scancode != DIK_NUMLOCK && scancode != DIK_SCROLL)
@ -2298,11 +2282,6 @@ void setmaintitle (void)
}
_tcscat (txt, title);
txt2[0] = 0;
/* if (mouseactive > 0) {
WIN32GUI_LoadUIString (currprefs.win32_middle_mouse ? IDS_WINUAETITLE_MMB : IDS_WINUAETITLE_NORMAL,
txt2, sizeof (txt2) / sizeof (TCHAR));
}
*/
if (txt2[0]) {
_tcscat (txt, " - ");
_tcscat (txt, txt2);

View File

@ -159,7 +159,7 @@ static int bitdepth, bit_unit, using_linear, vgamode, current_vgamode, gui_reque
static vga_modeinfo modeinfo;
static char *linear_mem = NULL;
static int need_dither;
static int screen_is_picasso;
extern int screen_is_picasso;
static int picasso_vgamode = -1;
static char picasso_invalid_lines[1200];

View File

@ -130,7 +130,7 @@ static int dga_colormap_installed;
static int need_dither;
static int screen_is_picasso;
extern int screen_is_picasso;
static char picasso_invalid_lines[1201];
static int picasso_has_invalid_lines;
static int picasso_invalid_start, picasso_invalid_stop;
@ -1592,11 +1592,7 @@ static void read_mouse (void)
static int get_mouse_flags (int num)
{
/* if (di_mouse[num].rawinput || !rawinput_enabled_mouse)
return 0;
if (di_mouse[num].catweasel)
return 0;*/
return 1;
return 0;
}
struct inputdevice_functions inputdevicefunc_mouse = {
@ -1694,7 +1690,7 @@ static void unacquire_kb (int num)
/*
* Default inputdevice config for X11 mouse
*/
int input_get_default_mouse (struct uae_input_device *uid, int num, int port, int af, bool gp)
int input_get_default_mouse (struct uae_input_device *uid, int num, int port, int af, bool gp, bool wheel)
{
/* Supports only one mouse */
uid[0].eventid[ID_AXIS_OFFSET + 0][0] = INPUTEVENT_MOUSE1_HORIZ;

View File

@ -425,7 +425,7 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
[cpuMenu addItem:[NSMenuItem separatorItem]];
[self createMenuItemInMenu:cpuMenu withTitle:@"24-bit Addressing" action:@selector(changeCPU:) tag:10];
[self createMenuItemInMenu:cpuMenu withTitle:@"More Compatible" action:@selector(changeCPU:) tag:11];
#ifdef MMU
#ifdef MMUEMU
[self createMenuItemInMenu:cpuMenu withTitle:@"68040 MMU" action:@selector(changeCPU:) tag:12];
#endif
menuItem = [[NSMenuItem alloc] initWithTitle:@"CPU" action:nil keyEquivalent:@""];
@ -919,7 +919,7 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
if (changed_prefs.cpu_compatible) [menuItem setState:NSOnState];
else [menuItem setState:NSOffState];
}
#ifdef MMU
#ifdef MMUEMU
if (tag == 12) {
if (changed_prefs.mmu_model) [menuItem setState:NSOnState];
else [menuItem setState:NSOffState];
@ -1681,7 +1681,7 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
case 11:
changed_prefs.cpu_compatible = !changed_prefs.cpu_compatible;
break;
#ifdef MMU
#ifdef MMUEMU
case 12:
changed_prefs.mmu_model = 68040;
break;

View File

@ -242,7 +242,7 @@ static void do_file_dialog (unsigned int type)
set_last_savestate_dir (FileRequest->fr_Drawer);
strcpy (changed_prefs.df[FILEDIALOG_DRIVE(type)], path);
break;
#ifdef SAVESTATE
case FILEDIALOG_SAVE_STATE:
set_last_savestate_dir (FileRequest->fr_Drawer);
savestate_initsave (path, 1, 0);
@ -255,6 +255,7 @@ static void do_file_dialog (unsigned int type)
savestate_state = STATE_DORESTORE;
write_log ("Restoring state from '%s'...\n", path);
break;
#endif // SAVESTATE
}
}

View File

@ -894,10 +894,6 @@ void puae_MainWindow::display_fromselect (int val, int *fs, int *vsync, int p96)
if (p96) {
*fs = val / 2;
*vsync = val & 1;
/*if (*fs == 2 && *fs != ofs) {
workprefs.win32_rtgscaleifsmall = 1;
workprefs.win32_rtgmatchdepth = 0;
}*/
return;
}
switch (val)
@ -1112,19 +1108,6 @@ void puae_MainWindow::values_to_memorydlg()
printf (tmp, "%d", workprefs.win32_rtgvblankrate);
//ui->IDC_RTG_VBLANKRATE->setText(tmp);
}
/*
workprefs.win32_rtgscaleifsmall = ui->IDC_RTG_SCALE->getValue();
workprefs.win32_rtgallowscaling = ui->IDC_RTG_SCALE_ALLOW->getValue();
workprefs.win32_rtgmatchdepth = ui->IDC_RTG_MATCH_DEPTH->getValue();
ui->IDC_RTG_SCALE_ASPECTRATIO->setCurrentIndex (
(workprefs.win32_rtgscaleaspectratio == 0) ? 0 :
(workprefs.win32_rtgscaleaspectratio == 4 * 256 + 3) ? 2 :
(workprefs.win32_rtgscaleaspectratio == 5 * 256 + 4) ? 3 :
(workprefs.win32_rtgscaleaspectratio == 15 * 256 + 9) ? 4 :
(workprefs.win32_rtgscaleaspectratio == 16 * 256 + 9) ? 5 :
(workprefs.win32_rtgscaleaspectratio == 16 * 256 + 10) ? 6 : 1);
*/
mem_size = 0;
switch (workprefs.mbresmem_low_size) {
case 0x00000000: mem_size = 0; break;

View File

@ -7,6 +7,8 @@
* 2002 Toni Wilen (scsi emulation, 64-bit support)
*/
#define USE_CHD 0
#include "sysconfig.h"
#include "sysdeps.h"
@ -30,6 +32,11 @@
#include "sleep.h"
#include "misc.h"
#if USE_CHD
#include "archivers/chd/chdtypes.h"
#include "archivers/chd/chd.h"
#endif
#undef DEBUGME
//#define DEBUGME
@ -63,8 +70,9 @@ struct hardfileprivdata {
uae_thread_id tid;
};
#define VHD_DYNAMIC 3
#define VHD_FIXED 2
#define HFD_VHD_DYNAMIC 3
#define HFD_VHD_FIXED 2
#define HFD_CHD 1
STATIC_INLINE uae_u32 gl (uae_u8 *p)
{
@ -102,19 +110,19 @@ static void getchs2 (struct hardfiledata *hfd, int *cyl, int *cylsec, int *head,
int sectors = 63;
/* do we have RDB values? */
if (hfd->cylinders) {
*cyl = hfd->cylinders;
*tracksec = hfd->sectors;
*head = hfd->heads;
*cylsec = hfd->sectors * hfd->heads;
if (hfd->rdbcylinders) {
*cyl = hfd->rdbcylinders;
*tracksec = hfd->rdbsectors;
*head = hfd->rdbheads;
*cylsec = hfd->rdbsectors * hfd->rdbheads;
return;
}
/* what about HDF settings? */
if (hfd->surfaces && hfd->secspertrack) {
*head = hfd->surfaces;
*tracksec = hfd->secspertrack;
if (hfd->ci.surfaces && hfd->ci.sectors) {
*head = hfd->ci.surfaces;
*tracksec = hfd->ci.sectors;
*cylsec = (*head) * (*tracksec);
*cyl = (unsigned int)(hfd->virtsize / hfd->blocksize) / ((*tracksec) * (*head));
*cyl = (unsigned int)(hfd->virtsize / hfd->ci.blocksize) / ((*tracksec) * (*head));
return;
}
/* no, lets guess something.. */
@ -128,7 +136,7 @@ static void getchs2 (struct hardfiledata *hfd, int *cyl, int *cylsec, int *head,
heads = 128;
else
heads = 255;
*cyl = (unsigned int)(hfd->virtsize / hfd->blocksize) / (sectors * heads);
*cyl = (unsigned int)(hfd->virtsize / hfd->ci.blocksize) / (sectors * heads);
*cylsec = sectors * heads;
*tracksec = sectors;
*head = heads;
@ -276,10 +284,10 @@ static void rdb_crc (uae_u8 *p)
pl (p, 2, sum);
}
static void create_virtual_rdb (struct hardfiledata *hfd, uae_u32 dostype, int bootpri, const TCHAR *filesys)
static void create_virtual_rdb (struct hardfiledata *hfd)
{
uae_u8 *rdb, *part, *denv;
int cyl = hfd->heads * hfd->secspertrack;
int cyl = hfd->ci.surfaces * hfd->ci.sectors;
int cyls = 262144 / (cyl * 512);
int size = cyl * cyls * 512;
@ -303,10 +311,10 @@ static void create_virtual_rdb (struct hardfiledata *hfd, uae_u32 dostype, int b
pl(rdb, 13, -1); // reserved
pl(rdb, 14, -1); // reserved
pl(rdb, 15, -1); // reserved
pl(rdb, 16, hfd->nrcyls);
pl(rdb, 17, hfd->secspertrack);
pl(rdb, 18, hfd->heads);
pl(rdb, 19, 0); // interleave
pl(rdb, 16, hfd->ci.highcyl);
pl(rdb, 17, hfd->ci.sectors);
pl(rdb, 18, hfd->ci.surfaces);
pl(rdb, 19, hfd->ci.interleave); // interleave
pl(rdb, 20, 0); // park
pl(rdb, 21, -1); // res
pl(rdb, 22, -1); // res
@ -322,7 +330,7 @@ static void create_virtual_rdb (struct hardfiledata *hfd, uae_u32 dostype, int b
pl(rdb, 32, 0); // rdbblockslo
pl(rdb, 33, cyl * cyls); // rdbblockshi
pl(rdb, 34, cyls); // locyl
pl(rdb, 35, hfd->nrcyls + cyls); // hicyl
pl(rdb, 35, hfd->ci.highcyl + cyls); // hicyl
pl(rdb, 36, cyl); // cylblocks
pl(rdb, 37, 0); // autopark
pl(rdb, 38, 2); // highrdskblock
@ -348,20 +356,20 @@ static void create_virtual_rdb (struct hardfiledata *hfd, uae_u32 dostype, int b
pl(denv, 0, 80);
pl(denv, 1, 512 / 4);
pl(denv, 2, 0); // secorg
pl(denv, 3, hfd->heads);
pl(denv, 4, hfd->blocksize / 512);
pl(denv, 5, hfd->secspertrack);
pl(denv, 6, hfd->reservedblocks);
pl(denv, 3, hfd->ci.surfaces);
pl(denv, 4, hfd->ci.blocksize / 512);
pl(denv, 5, hfd->ci.sectors);
pl(denv, 6, hfd->ci.reserved);
pl(denv, 7, 0); // prealloc
pl(denv, 8, 0); // interleave
pl(denv, 8, hfd->ci.interleave); // interleave
pl(denv, 9, cyls); // lowcyl
pl(denv, 10, hfd->nrcyls + cyls - 1);
pl(denv, 11, 50);
pl(denv, 12, 0);
pl(denv, 13, 0x00ffffff);
pl(denv, 14, 0x7ffffffe);
pl(denv, 15, bootpri);
pl(denv, 16, dostype);
pl(denv, 10, hfd->ci.highcyl + cyls - 1);
pl(denv, 11, hfd->ci.buffers);
pl(denv, 12, hfd->ci.bufmemtype);
pl(denv, 13, hfd->ci.maxtransfer);
pl(denv, 14, hfd->ci.mask);
pl(denv, 15, hfd->ci.bootpri);
pl(denv, 16, hfd->ci.dostype);
rdb_crc (part);
hfd->virtsize += size;
@ -373,48 +381,36 @@ void hdf_hd_close (struct hd_hardfiledata *hfd)
if (!hfd)
return;
hdf_close (&hfd->hfd);
xfree (hfd->path);
// xfree (hfd->path);
}
int hdf_hd_open (struct hd_hardfiledata *hfd, const TCHAR *path, int blocksize, int readonly,
const TCHAR *devname, int cyls, int sectors, int surfaces, int reserved,
int bootpri, const TCHAR *filesys,
int pcyls, int pheads, int psecs)
int hdf_hd_open (struct hd_hardfiledata *hfd)
{
memset (hfd, 0, sizeof (struct hd_hardfiledata));
hfd->bootpri = bootpri;
hfd->hfd.blocksize = blocksize;
hfd->hfd.readonly = readonly;
if (!hdf_open (&hfd->hfd, path))
struct uaedev_config_info *ci = &hfd->hfd.ci;
if (!hdf_open (&hfd->hfd, NULL))
return 0;
hfd->path = my_strdup(path);
hfd->hfd.cylinders = cyls;
hfd->hfd.heads = surfaces;
hfd->hfd.reservedblocks = reserved;
hfd->hfd.secspertrack = sectors;
if (devname)
_tcscpy (hfd->hfd.device_name, devname);
if (pcyls && pheads && psecs) {
hfd->cyls = pcyls;
hfd->heads = pheads;
hfd->secspertrack = psecs;
} else if (cyls && surfaces && sectors) {
hfd->cyls = cyls;
hfd->heads = surfaces;
hfd->secspertrack = sectors;
if (ci->pcyls && ci->pheads && ci->psecs) {
hfd->cyls = ci->pcyls;
hfd->heads = ci->pheads;
hfd->secspertrack = ci->psecs;
} else if (ci->highcyl && ci->surfaces && ci->sectors) {
hfd->cyls = ci->highcyl;
hfd->heads = ci->surfaces;
hfd->secspertrack = ci->sectors;
} else {
getchshd (&hfd->hfd, &hfd->cyls, &hfd->heads, &hfd->secspertrack);
}
hfd->cyls_def = hfd->cyls;
hfd->secspertrack_def = hfd->secspertrack;
hfd->heads_def = hfd->heads;
if (hfd->hfd.heads && hfd->hfd.secspertrack) {
if (ci->surfaces && ci->sectors) {
uae_u8 buf[512] = { 0 };
hdf_read (&hfd->hfd, buf, 0, 512);
if (buf[0] != 0 && memcmp (buf, _T("RDSK"), 4)) {
hfd->hfd.nrcyls = (hfd->hfd.virtsize / blocksize) / (sectors * surfaces);
create_virtual_rdb (&hfd->hfd, rl (buf), hfd->bootpri, filesys);
while (hfd->hfd.nrcyls * surfaces * sectors > hfd->cyls_def * hfd->secspertrack_def * hfd->heads_def) {
ci->highcyl = (hfd->hfd.virtsize / ci->blocksize) / (ci->sectors * ci->surfaces);
ci->dostype = rl (buf);
create_virtual_rdb (&hfd->hfd);
while (ci->highcyl * ci->surfaces * ci->sectors > hfd->cyls_def * hfd->secspertrack_def * hfd->heads_def) {
hfd->cyls_def++;
}
}
@ -462,8 +458,36 @@ int hdf_open (struct hardfiledata *hfd, const TCHAR *pname)
uae_u8 tmp[512], tmp2[512];
uae_u32 v;
if ((!pname || pname[0] == 0) && hfd->ci.rootdir[0] == 0)
return 0;
hfd->adide = 0;
hfd->byteswap = 0;
hfd->hfd_type = 0;
if (!pname)
pname = hfd->ci.rootdir;
#if USE_CHD
TCHAR nametmp[MAX_DPATH];
_tcscpy (nametmp, pname);
TCHAR *ext = _tcsrchr (nametmp, '.');
if (ext && !_tcsicmp (ext, _T(".chd"))) {
struct zfile *zf = zfile_fopen (nametmp, _T("rb"));
if (zf) {
int err;
chd_file *cf = new chd_file();
err = cf->open(zf, false, NULL);
if (err != CHDERR_NONE) {
zfile_fclose (zf);
goto nonvhd;
}
hfd->chd_handle = cf;
hfd->ci.readonly = true;
hfd->hfd_type = HFD_CHD;
hfd->handle_valid = -1;
hfd->virtsize = cf->logical_bytes ();
goto nonvhd;
}
}
#endif
if (!hdf_open_target (hfd, pname))
return 0;
if (hdf_read_target (hfd, tmp, 0, 512) != 512)
@ -474,8 +498,8 @@ int hdf_open (struct hardfiledata *hfd, const TCHAR *pname)
v = gl (tmp + 8 + 4); // version
if ((v >> 16) != 1)
goto nonvhd;
hfd->vhd_type = gl (tmp + 8 + 4 + 4 + 8 + 4 + 4 + 4 + 4 + 8 + 8 + 4);
if (hfd->vhd_type != VHD_FIXED && hfd->vhd_type != VHD_DYNAMIC)
hfd->hfd_type = gl (tmp + 8 + 4 + 4 + 8 + 4 + 4 + 4 + 4 + 8 + 8 + 4);
if (hfd->hfd_type != HFD_VHD_FIXED && hfd->hfd_type != HFD_VHD_DYNAMIC)
goto nonvhd;
v = gl (tmp + 8 + 4 + 4 + 8 + 4 + 4 + 4 + 4 + 8 + 8 + 4 + 4);
if (v == 0)
@ -489,7 +513,7 @@ int hdf_open (struct hardfiledata *hfd, const TCHAR *pname)
hfd->vhd_footerblock = hfd->physsize - 512;
hfd->virtsize = (uae_u64)(gl (tmp + 8 + 4 + 4 + 8 + 4 + 4 +4 + 4 + 8)) << 32;
hfd->virtsize |= gl (tmp + 8 + 4 + 4 + 8 + 4 + 4 +4 + 4 + 8 + 4);
if (hfd->vhd_type == VHD_DYNAMIC) {
if (hfd->hfd_type == HFD_VHD_DYNAMIC) {
uae_u32 size;
hfd->vhd_bamoffset = gl (tmp + 8 + 4 + 4 + 4);
if (hfd->vhd_bamoffset == 0 || hfd->vhd_bamoffset >= hfd->physsize)
@ -514,12 +538,11 @@ int hdf_open (struct hardfiledata *hfd, const TCHAR *pname)
hfd->vhd_bitmapsize = ((hfd->vhd_blocksize / (8 * 512)) + 511) & ~511;
}
write_log (_T("HDF is VHD %s image, virtual size=%dK\n"),
hfd->vhd_type == 2 ? _T("fixed") : _T("dynamic"),
hfd->hfd_type == HFD_VHD_FIXED ? _T("fixed") : _T("dynamic"),
hfd->virtsize / 1024);
hdf_init_cache (hfd);
return 1;
nonvhd:
hfd->vhd_type = 0;
return 1;
end:
hdf_close_target (hfd);
@ -530,11 +553,16 @@ void hdf_close (struct hardfiledata *hfd)
{
hdf_flush_cache (hfd);
hdf_close_target (hfd);
hfd->vhd_type = 0;
#if USE_CHD
if (hfd->chd_handle) {
chd_file *cf = (chd_file*)hfd->chd_handle;
cf->close();
hfd->chd_handle = NULL;
}
#endif
hfd->hfd_type = 0;
xfree (hfd->vhd_header);
hfd->vhd_header = NULL;
xfree (hfd->vhd_sectormap);
hfd->vhd_sectormap = NULL;
}
int hdf_dup (struct hardfiledata *dhfd, const struct hardfiledata *shfd)
@ -723,7 +751,7 @@ int vhd_create (const TCHAR *name, uae_u64 size, uae_u32 dostype)
memset (&hfd, 0, sizeof hfd);
hfd.virtsize = hfd.physsize = size;
hfd.blocksize = 512;
hfd.ci.blocksize = 512;
strcpy ((char*)b, "conectix"); // cookie
b[0x0b] = 2; // features
b[0x0d] = 1; // version
@ -755,7 +783,7 @@ int vhd_create (const TCHAR *name, uae_u64 size, uae_u32 dostype)
// sectors per track
b[0x3b] = tracksec;
// disk type
b[0x3c + 3] = VHD_DYNAMIC;
b[0x3c + 3] = HFD_VHD_DYNAMIC;
get_guid_target (b + 0x44);
crc = vhd_checksum (b, -1);
b[0x40] = crc >> 24;
@ -830,20 +858,30 @@ end:
static int hdf_read2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
{
if (hfd->vhd_type == VHD_DYNAMIC)
if (hfd->hfd_type == HFD_VHD_DYNAMIC)
return vhd_read (hfd, buffer, offset, len);
else if (hfd->vhd_type == VHD_FIXED)
else if (hfd->hfd_type == HFD_VHD_FIXED)
return hdf_read_target (hfd, buffer, offset + 512, len);
#if USE_CHD
else if (hfd->hfd_type == HFD_CHD) {
chd_file *cf = (chd_file*)hfd->chd_handle;
if (cf->read_bytes(offset, buffer, len) == CHDERR_NONE)
return len;
return 0;
}
#endif
else
return hdf_read_target (hfd, buffer, offset, len);
}
static int hdf_write2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
{
if (hfd->vhd_type == VHD_DYNAMIC)
if (hfd->hfd_type == HFD_VHD_DYNAMIC)
return vhd_write (hfd, buffer, offset, len);
else if (hfd->vhd_type == VHD_FIXED)
else if (hfd->hfd_type == HFD_VHD_FIXED)
return hdf_write_target (hfd, buffer, offset + 512, len);
else if (hfd->hfd_type == HFD_CHD)
return 0;
else
return hdf_write_target (hfd, buffer, offset, len);
}
@ -1028,7 +1066,7 @@ static uae_u64 cmd_readx (struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 off
{
gui_flicker_led (LED_HD, hfd->unitnum, 1);
hf_log3 (_T("cmd_read: %p %04x-%08x (%d) %08x (%d)\n"),
dataptr, (uae_u32)(offset >> 32), (uae_u32)offset, (uae_u32)(offset / hfd->blocksize), (uae_u32)len, (uae_u32)(len / hfd->blocksize));
dataptr, (uae_u32)(offset >> 32), (uae_u32)offset, (uae_u32)(offset / hfd->ci.blocksize), (uae_u32)len, (uae_u32)(len / hfd->ci.blocksize));
return hdf_read (hfd, dataptr, offset, len);
}
static uae_u64 cmd_read (struct hardfiledata *hfd, uaecptr dataptr, uae_u64 offset, uae_u64 len)
@ -1042,7 +1080,7 @@ static uae_u64 cmd_writex (struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 of
{
gui_flicker_led (LED_HD, hfd->unitnum, 2);
hf_log3 (_T("cmd_write: %p %04x-%08x (%d) %08x (%d)\n"),
dataptr, (uae_u32)(offset >> 32), (uae_u32)offset, (uae_u32)(offset / hfd->blocksize), (uae_u32)len, (uae_u32)(len / hfd->blocksize));
dataptr, (uae_u32)(offset >> 32), (uae_u32)offset, (uae_u32)(offset / hfd->ci.blocksize), (uae_u32)len, (uae_u32)(len / hfd->ci.blocksize));
return hdf_write (hfd, dataptr, offset, len);
}
@ -1077,12 +1115,21 @@ int scsi_emulate (struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u
int lr = 0, ls = 0;
int scsi_len = -1;
int status = 0;
int i;
int i, lun;
char *ss;
*reply_len = *sense_len = 0;
memset (r, 0, 256);
memset (s, 0, 256);
lun = cmdbuf[1] >> 5;
if (lun) {
status = 2; /* CHECK CONDITION */
s[0] = 0x70;
s[2] = 5; /* ILLEGAL REQUEST */
s[12] = 0x25; /* INVALID LUN */
ls = 12;
goto err;
}
switch (cmdbuf[0])
{
case 0x00: /* TEST UNIT READY */
@ -1090,82 +1137,89 @@ int scsi_emulate (struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u
goto nodisk;
scsi_len = 0;
break;
case 0x03: /* REQUEST SENSE */
scsi_len = cmdbuf[4] > MAX_SCSI_SENSE ? MAX_SCSI_SENSE : cmdbuf[4];
memcpy (r, hfd->scsi_sense, scsi_len);
memset (hfd->scsi_sense, 0, MAX_SCSI_SENSE);
break;
case 0x08: /* READ (6) */
if (nodisk (hfd))
goto nodisk;
offset = ((cmdbuf[1] & 31) << 16) | (cmdbuf[2] << 8) | cmdbuf[3];
offset *= hfd->blocksize;
offset *= hfd->ci.blocksize;
len = cmdbuf[4];
if (!len)
len = 256;
len *= hfd->blocksize;
len *= hfd->ci.blocksize;
if (checkbounds(hfd, offset, len))
scsi_len = (uae_u32)cmd_readx (hfd, scsi_data, offset, len);
break;
case 0x0a: /* WRITE (6) */
if (nodisk (hfd))
goto nodisk;
if (hfd->readonly || hfd->dangerous)
if (hfd->ci.readonly || hfd->dangerous)
goto readprot;
offset = ((cmdbuf[1] & 31) << 16) | (cmdbuf[2] << 8) | cmdbuf[3];
offset *= hfd->blocksize;
offset *= hfd->ci.blocksize;
len = cmdbuf[4];
if (!len)
len = 256;
len *= hfd->blocksize;
len *= hfd->ci.blocksize;
if (checkbounds(hfd, offset, len))
scsi_len = (uae_u32)cmd_writex (hfd, scsi_data, offset, len);
break;
case 0x12: /* INQUIRY */
if ((cmdbuf[1] & 1) || cmdbuf[2] != 0)
goto err;
len = cmdbuf[4];
if (cmdbuf[1] >> 5)
goto err;//r[0] = 0x7f; /* no lun supported */
if (hfd->drive_empty)
r[1] |= 0x80; // removable..
r[2] = 2; /* supports SCSI-2 */
r[3] = 2; /* response data format */
r[4] = 32; /* additional length */
r[7] = 0x20; /* 16 bit bus */
scsi_len = lr = len < 36 ? (uae_u32)len : 36;
if (hdhfd) {
r[2] = hdhfd->ansi_version;
r[3] = hdhfd->ansi_version >= 2 ? 2 : 0;
{
if ((cmdbuf[1] & 1) || cmdbuf[2] != 0)
goto err;
int alen = (cmdbuf[3] << 8) | cmdbuf[4];
if (hfd->drive_empty) {
r[1] |= 0x80; // removable..
r[0] |= 0x20; // not present
}
r[2] = 2; /* supports SCSI-2 */
r[3] = 2; /* response data format */
r[4] = 32; /* additional length */
r[7] = 0x20; /* 16 bit bus */
scsi_len = lr = alen < 36 ? (uae_u32)alen : 36;
if (hdhfd) {
r[2] = hdhfd->ansi_version;
r[3] = hdhfd->ansi_version >= 2 ? 2 : 0;
}
ss = ua (hfd->vendor_id);
i = 0; /* vendor id */
while (i < 8 && ss[i]) {
r[8 + i] = ss[i];
i++;
}
while (i < 8) {
r[8 + i] = 32;
i++;
}
xfree (ss);
ss = ua (hfd->product_id);
i = 0; /* product id */
while (i < 16 && ss[i]) {
r[16 + i] = ss[i];
i++;
}
while (i < 16) {
r[16 + i] = 32;
i++;
}
xfree (ss);
ss = ua (hfd->product_rev);
i = 0; /* product revision */
while (i < 4 && ss[i]) {
r[32 + i] = ss[i];
i++;
}
while (i < 4) {
r[32 + i] = 32;
i++;
}
xfree (ss);
}
ss = ua (hfd->vendor_id);
i = 0; /* vendor id */
while (i < 8 && ss[i]) {
r[8 + i] = ss[i];
i++;
}
while (i < 8) {
r[8 + i] = 32;
i++;
}
xfree (ss);
ss = ua (hfd->product_id);
i = 0; /* product id */
while (i < 16 && ss[i]) {
r[16 + i] = ss[i];
i++;
}
while (i < 16) {
r[16 + i] = 32;
i++;
}
xfree (ss);
ss = ua (hfd->product_rev);
i = 0; /* product revision */
while (i < 4 && ss[i]) {
r[32 + i] = ss[i];
i++;
}
while (i < 4) {
r[32 + i] = 32;
i++;
}
xfree (ss);
break;
case 0x1a: /* MODE SENSE(6) */
{
@ -1173,6 +1227,7 @@ int scsi_emulate (struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u
int pc = cmdbuf[2] >> 6;
int pcode = cmdbuf[2] & 0x3f;
int dbd = cmdbuf[1] & 8;
int alen = cmdbuf[4];
int cyl, cylsec, head, tracksec;
if (nodisk (hfd))
goto nodisk;
@ -1192,42 +1247,54 @@ int scsi_emulate (struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u
p[3] = 0;
p += 4;
if (!dbd) {
uae_u32 blocks = (uae_u32)(hfd->virtsize / hfd->blocksize);
p[-1] = 8;
wl(p + 0, blocks);
wl(p + 4, hfd->blocksize);
p += 8;
if (alen >= r[0] + 1 + 8) {
uae_u32 blocks = (uae_u32)(hfd->virtsize / hfd->ci.blocksize);
p[-1] = 8;
wl(p + 0, blocks);
wl(p + 4, hfd->ci.blocksize);
p += 8;
}
}
if (pcode == 0) {
if (alen >= r[0] + 1 + r[3] + 4) {
p[0] = 0;
p[1] = 0;
p[1] = 3;
p[2] = 0x20;
p[3] = 0;
r[0] += 4;
r[0] += p[1];
}
} else if (pcode == 3) {
p[0] = 3;
p[1] = 24;
p[3] = 1;
p[10] = tracksec >> 8;
p[11] = tracksec;
p[12] = hfd->blocksize >> 8;
p[13] = hfd->blocksize;
p[15] = 1; // interleave
p[20] = 0x80;
r[0] += p[1];
// format parameters
if (alen >= r[0] + 1 + r[3] + 24) {
p[0] = 3;
p[1] = 24;
p[3] = 1;
p[10] = tracksec >> 8;
p[11] = tracksec;
p[12] = hfd->ci.blocksize >> 8;
p[13] = hfd->ci.blocksize;
p[15] = 1; // interleave
p[20] = 0x80;
r[0] += p[1];
}
} else if (pcode == 4) {
p[0] = 4;
wl(p + 1, cyl);
p[1] = 24;
p[5] = head;
wl(p + 13, cyl);
ww(p + 20, 5400);
r[0] += p[1];
// rigid drive geometry
if (alen >= r[0] + 1 + r[3] + 16) {
p[0] = 4;
wl(p + 1, cyl);
p[1] = 24;
p[5] = head;
wl(p + 13, cyl);
ww(p + 20, 5400);
r[0] += p[1];
}
} else {
goto err;
}
r[0] += r[3];
scsi_len = lr = r[0] + 1;
if (scsi_len > alen)
scsi_len = alen;
break;
}
break;
@ -1241,7 +1308,7 @@ int scsi_emulate (struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u
int cyl, cylsec, head, tracksec;
if (nodisk (hfd))
goto nodisk;
blocks = (uae_u32)(hfd->virtsize / hfd->blocksize - 1);
blocks = (uae_u32)(hfd->virtsize / hfd->ci.blocksize - 1);
if (hdhfd) {
cyl = hdhfd->cyls;
head = hdhfd->heads;
@ -1261,7 +1328,7 @@ int scsi_emulate (struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u
blocks = lba;
}
wl (r, blocks);
wl (r + 4, hfd->blocksize);
wl (r + 4, hfd->ci.blocksize);
scsi_len = lr = 8;
}
break;
@ -1269,21 +1336,21 @@ int scsi_emulate (struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u
if (nodisk (hfd))
goto nodisk;
offset = rl (cmdbuf + 2);
offset *= hfd->blocksize;
offset *= hfd->ci.blocksize;
len = rl (cmdbuf + 7 - 2) & 0xffff;
len *= hfd->blocksize;
len *= hfd->ci.blocksize;
if (checkbounds (hfd, offset, len))
scsi_len = (uae_u32)cmd_readx (hfd, scsi_data, offset, len);
break;
case 0x2a: /* WRITE (10) */
if (nodisk (hfd))
goto nodisk;
if (hfd->readonly || hfd->dangerous)
if (hfd->ci.readonly || hfd->dangerous)
goto readprot;
offset = rl (cmdbuf + 2);
offset *= hfd->blocksize;
offset *= hfd->ci.blocksize;
len = rl (cmdbuf + 7 - 2) & 0xffff;
len *= hfd->blocksize;
len *= hfd->ci.blocksize;
if (checkbounds (hfd, offset, len))
scsi_len = (uae_u32)cmd_writex (hfd, scsi_data, offset, len);
break;
@ -1294,19 +1361,19 @@ int scsi_emulate (struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u
if (nodisk (hfd))
goto nodisk;
offset = rl (cmdbuf + 2);
offset *= hfd->blocksize;
offset *= hfd->ci.blocksize;
len = rl (cmdbuf + 7 - 2) & 0xffff;
len *= hfd->blocksize;
len *= hfd->ci.blocksize;
if (checkbounds (hfd, offset, len)) {
uae_u8 *vb = xmalloc (hfd->blocksize);
uae_u8 *vb = xmalloc (hfd->ci.blocksize);
while (len > 0) {
int len = cmd_readx (hfd, vb, offset, hfd->blocksize);
int len = cmd_readx (hfd, vb, offset, hfd->ci.blocksize);
if (bytchk) {
if (memcmp (vb, scsi_data, hfd->blocksize))
if (memcmp (vb, scsi_data, hfd->ci.blocksize))
goto miscompare;
scsi_data += hfd->blocksize;
scsi_data += hfd->ci.blocksize;
}
offset += hfd->blocksize;
offset += hfd->ci.blocksize;
}
xfree (vb);
}
@ -1322,21 +1389,21 @@ int scsi_emulate (struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u
if (nodisk (hfd))
goto nodisk;
offset = rl (cmdbuf + 2);
offset *= hfd->blocksize;
offset *= hfd->ci.blocksize;
len = rl (cmdbuf + 6);
len *= hfd->blocksize;
len *= hfd->ci.blocksize;
if (checkbounds(hfd, offset, len))
scsi_len = (uae_u32)cmd_readx (hfd, scsi_data, offset, len);
break;
case 0xaa: /* WRITE (12) */
if (nodisk (hfd))
goto nodisk;
if (hfd->readonly || hfd->dangerous)
if (hfd->ci.readonly || hfd->dangerous)
goto readprot;
offset = rl (cmdbuf + 2);
offset *= hfd->blocksize;
offset *= hfd->ci.blocksize;
len = rl (cmdbuf + 6);
len *= hfd->blocksize;
len *= hfd->ci.blocksize;
if (checkbounds(hfd, offset, len))
scsi_len = (uae_u32)cmd_writex (hfd, scsi_data, offset, len);
break;
@ -1387,6 +1454,10 @@ miscompare:
*data_len = scsi_len;
*reply_len = lr;
*sense_len = ls;
if (ls > 0) {
memset (hfd->scsi_sense, 0, MAX_SCSI_SENSE);
memcpy (hfd->scsi_sense, s, ls);
}
return status;
}
@ -1459,41 +1530,45 @@ static int handle_scsi (uaecptr request, struct hardfiledata *hfd)
return ret;
}
void hardfile_do_disk_change (struct uaedev_config_info *uci, int insert)
{
int fsid = uci->configoffset;
int j;
int newstate = insert ? 0 : 1;
struct hardfiledata *hfd;
#ifdef GAYLE
if (uci->controller == HD_CONTROLLER_PCMCIA_SRAM) {
gayle_modify_pcmcia_sram_unit (uci->rootdir, uci->readonly, insert);
return;
} else if (uci->controller == HD_CONTROLLER_PCMCIA_IDE) {
gayle_modify_pcmcia_ide_unit (uci->rootdir, uci->readonly, insert);
return;
}
#endif
hfd = get_hardfile_data (fsid);
if (!hfd)
return;
void hardfile_send_disk_change (struct hardfiledata *hfd, bool insert)
{
int newstate = insert ? 0 : 1;
uae_sem_wait (&change_sem);
hardfpd[fsid].changenum++;
write_log (_T("uaehf.device:%d media status=%d changenum=%d\n"), fsid, insert, hardfpd[fsid].changenum);
hardfpd[hfd->unitnum].changenum++;
write_log (_T("uaehf.device:%d media status=%d changenum=%d\n"), hfd->unitnum, insert, hardfpd[hfd->unitnum].changenum);
hfd->drive_empty = newstate;
j = 0;
int j = 0;
while (j < MAX_ASYNC_REQUESTS) {
if (hardfpd[fsid].d_request_type[j] == ASYNC_REQUEST_CHANGEINT) {
uae_Cause (hardfpd[fsid].d_request_data[j]);
if (hardfpd[hfd->unitnum].d_request_type[j] == ASYNC_REQUEST_CHANGEINT) {
uae_Cause (hardfpd[hfd->unitnum].d_request_data[j]);
}
j++;
}
if (hardfpd[fsid].changeint)
uae_Cause (hardfpd[fsid].changeint);
if (hardfpd[hfd->unitnum].changeint)
uae_Cause (hardfpd[hfd->unitnum].changeint);
uae_sem_post (&change_sem);
}
void hardfile_do_disk_change (struct uaedev_config_data *uci, bool insert)
{
int fsid = uci->configoffset;
struct hardfiledata *hfd;
if (uci->ci.controller == HD_CONTROLLER_PCMCIA_SRAM) {
gayle_modify_pcmcia_sram_unit (uci->ci.rootdir, uci->ci.readonly, insert);
return;
} else if (uci->ci.controller == HD_CONTROLLER_PCMCIA_IDE) {
gayle_modify_pcmcia_ide_unit (uci->ci.rootdir, uci->ci.readonly, insert);
return;
}
hfd = get_hardfile_data (fsid);
if (!hfd)
return;
hardfile_send_disk_change (hfd, insert);
}
static int add_async_request (struct hardfileprivdata *hfpd, uaecptr request, int type, uae_u32 data)
{
int i;
@ -1601,7 +1676,7 @@ static uae_u32 REGPARAM2 hardfile_open (TrapContext *context)
/* Check unit number */
if (unit >= 0) {
struct hardfiledata *hfd = get_hardfile_data (unit);
if (hfd && hfd->handle_valid && start_thread (context, unit)) {
if (hfd && (hfd->handle_valid || hfd->drive_empty) && start_thread (context, unit)) {
put_word (hfpd->base + 32, get_word (hfpd->base + 32) + 1);
put_long (ioreq + 24, unit); /* io_Unit */
put_byte (ioreq + 31, 0); /* io_Error */
@ -1660,7 +1735,7 @@ static uae_u32 hardfile_do_io (struct hardfiledata *hfd, struct hardfileprivdata
int unit = get_long (request + 24);
uae_u32 error = 0, len;
int async = 0;
int bmask = hfd->blocksize - 1;
int bmask = hfd->ci.blocksize - 1;
cmd = get_word (request + 28); /* io_Command */
dataptr = get_long (request + 40);
@ -1672,11 +1747,11 @@ static uae_u32 hardfile_do_io (struct hardfiledata *hfd, struct hardfileprivdata
offset = get_long (request + 44);
len = get_long (request + 36); /* io_Length */
if (offset & bmask) {
unaligned (cmd, offset, len, hfd->blocksize);
unaligned (cmd, offset, len, hfd->ci.blocksize);
goto bad_command;
}
if (len & bmask) {
unaligned (cmd, offset, len, hfd->blocksize);
unaligned (cmd, offset, len, hfd->ci.blocksize);
goto bad_len;
}
if (len + offset > hfd->virtsize) {
@ -1693,11 +1768,11 @@ static uae_u32 hardfile_do_io (struct hardfiledata *hfd, struct hardfileprivdata
offset64 = get_long (request + 44) | ((uae_u64)get_long (request + 32) << 32);
len = get_long (request + 36); /* io_Length */
if (offset64 & bmask) {
unaligned (cmd, offset64, len, hfd->blocksize);
unaligned (cmd, offset64, len, hfd->ci.blocksize);
goto bad_command;
}
if (len & bmask) {
unaligned (cmd, offset64, len, hfd->blocksize);
unaligned (cmd, offset64, len, hfd->ci.blocksize);
goto bad_len;
}
if (len + offset64 > hfd->virtsize) {
@ -1711,17 +1786,17 @@ static uae_u32 hardfile_do_io (struct hardfiledata *hfd, struct hardfileprivdata
case CMD_FORMAT: /* Format */
if (nodisk (hfd))
goto no_disk;
if (hfd->readonly || hfd->dangerous) {
if (hfd->ci.readonly || hfd->dangerous) {
error = 28; /* write protect */
} else {
offset = get_long (request + 44);
len = get_long (request + 36); /* io_Length */
if (offset & bmask) {
unaligned (cmd, offset, len, hfd->blocksize);
unaligned (cmd, offset, len, hfd->ci.blocksize);
goto bad_command;
}
if (len & bmask) {
unaligned (cmd, offset, len, hfd->blocksize);
unaligned (cmd, offset, len, hfd->ci.blocksize);
goto bad_len;
}
if (len + offset > hfd->virtsize) {
@ -1738,17 +1813,17 @@ static uae_u32 hardfile_do_io (struct hardfiledata *hfd, struct hardfileprivdata
case NSCMD_TD_FORMAT64:
if (nodisk (hfd))
goto no_disk;
if (hfd->readonly || hfd->dangerous) {
if (hfd->ci.readonly || hfd->dangerous) {
error = 28; /* write protect */
} else {
offset64 = get_long (request + 44) | ((uae_u64)get_long (request + 32) << 32);
len = get_long (request + 36); /* io_Length */
if (offset64 & bmask) {
unaligned (cmd, offset64, len, hfd->blocksize);
unaligned (cmd, offset64, len, hfd->ci.blocksize);
goto bad_command;
}
if (len & bmask) {
unaligned (cmd, offset64, len, hfd->blocksize);
unaligned (cmd, offset64, len, hfd->ci.blocksize);
goto bad_len;
}
if (len + offset64 > hfd->virtsize) {
@ -1764,6 +1839,7 @@ bad_command:
break;
bad_len:
error = IOERR_BADLENGTH;
break;
no_disk:
error = 29; /* no disk */
break;
@ -1794,8 +1870,8 @@ no_disk:
int cyl, cylsec, head, tracksec;
uae_u64 size;
getchsx (hfd, &cyl, &cylsec, &head, &tracksec);
put_long (dataptr + 0, hfd->blocksize);
size = hfd->virtsize / hfd->blocksize;
put_long (dataptr + 0, hfd->ci.blocksize);
size = hfd->virtsize / hfd->ci.blocksize;
if (size > 0x00ffffffff)
size = 0xffffffff;
put_long (dataptr + 4, (uae_u32)size);
@ -1810,7 +1886,7 @@ no_disk:
break;
case CMD_PROTSTATUS:
if (hfd->readonly || hfd->dangerous)
if (hfd->ci.readonly || hfd->dangerous)
actual = -1;
else
actual = 0;
@ -1847,7 +1923,7 @@ no_disk:
break;
case HD_SCSICMD: /* SCSI */
if (hfd->nrcyls == 0) {
if (!hfd->ci.sectors && !hfd->ci.surfaces && !hfd->ci.reserved) {
error = handle_scsi (request, hfd);
} else { /* we don't want users trashing their "partition" hardfiles with hdtoolbox */
error = IOERR_NOCMD;
@ -1855,6 +1931,25 @@ no_disk:
}
break;
case CD_EJECT:
if (hfd->ci.sectors && hfd->ci.surfaces) {
int len = get_long (request + 36);
if (len) {
if (hfd->drive_empty) {
hardfile_media_change (hfd, NULL, true, false);
} else {
hardfile_media_change (hfd, NULL, false, false);
}
} else {
if (hfd->drive_empty) {
hardfile_media_change (hfd, NULL, true, false);
}
}
} else {
error = IOERR_NOCMD;
}
break;
default:
/* Command not understood. */
error = IOERR_NOCMD;
@ -2003,7 +2098,7 @@ void hardfile_install (void)
uae_sem_init (&change_sem, 0, 1);
ROM_hardfile_resname = ds (_T("uaehf.device"));
ROM_hardfile_resid = ds (_T("UAE hardfile.device 0.2"));
ROM_hardfile_resid = ds (_T("UAE hardfile.device 0.3"));
nscmd_cmd = here ();
dw (NSCMD_DEVICEQUERY);

View File

@ -10,6 +10,7 @@
#include "sysconfig.h"
#include "sysdeps.h"
#include "options.h"
#include "filesys.h"
#include "zfile.h"
@ -23,8 +24,6 @@
#define DEBUG_LOG(...) { }
#endif
static int usefloppydrives = 0;
struct hardfilehandle
{
int zfile;
@ -63,6 +62,7 @@ struct uae_driveinfo {
int harddrive_dangerous, do_rdbdump;
static struct uae_driveinfo uae_drives[MAX_FILESYSTEM_UNITS];
static int num_drives = 0;
static void rdbdump (FILE *h, uae_u64 offset, uae_u8 *buf, int blocksize)
{
@ -163,11 +163,13 @@ static int safetycheck (FILE *h, const char *name, uae_u64 offset, uae_u8 *buf,
}
#if 0
static void trim (TCHAR *s)
{
while(_tcslen(s) > 0 && s[_tcslen(s) - 1] == ' ')
s[_tcslen(s) - 1] = 0;
}
#endif
static int isharddrive (const TCHAR *name)
{
@ -207,14 +209,13 @@ int hdf_open_target (struct hardfiledata *hfd, const char *pname)
hdf_init_target ();
i = isharddrive (name);
if (i >= 0) {
long r;
udi = &uae_drives[i];
hfd->flags = HFD_FLAGS_REALDRIVE;
if (udi->nomedia)
hfd->drive_empty = -1;
if (udi->readonly)
hfd->readonly = 1;
h = fopen (udi->device_path, hfd->readonly ? "rb" : "r+b");
// if (udi->readonly)
// hfd->readonly = 1;
h = fopen (udi->device_path, /*hfd->readonly ? "rb" :*/ "r+b");
hfd->handle->h = h;
if (h == INVALID_HANDLE_VALUE)
goto end;
@ -223,12 +224,12 @@ int hdf_open_target (struct hardfiledata *hfd, const char *pname)
_tcsncpy (hfd->product_rev, udi->product_rev, 4);
hfd->offset = udi->offset;
hfd->physsize = hfd->virtsize = udi->size;
hfd->blocksize = udi->bytespersector;
// hfd->blocksize = udi->bytespersector;
if (hfd->offset == 0 && !hfd->drive_empty) {
int sf = safetycheck (hfd->handle->h, udi->device_path, 0, hfd->cache, hfd->blocksize);
int sf = safetycheck (hfd->handle->h, udi->device_path, 0, hfd->cache, 0/*hfd->blocksize*/);
if (sf > 0)
goto end;
if (sf == 0 && !hfd->readonly && harddrive_dangerous != 0x1234dead) {
if (sf == 0 /*&& !hfd->readonly*/ && harddrive_dangerous != 0x1234dead) {
write_log ("'%s' forced read-only, safetycheck enabled\n", udi->device_path);
hfd->dangerous = 1;
// clear GENERIC_WRITE
@ -256,7 +257,7 @@ int hdf_open_target (struct hardfiledata *hfd, const char *pname)
zmode = 1;
}
}
h = fopen (name, hfd->readonly ? "rb" : "r+b");
h = fopen (name, /*hfd->readonly ? "rb" :*/ "r+b");
if (h == INVALID_HANDLE_VALUE)
goto end;
hfd->handle->h = h;
@ -279,14 +280,14 @@ int hdf_open_target (struct hardfiledata *hfd, const char *pname)
low = ftell (h);
if (low == -1)
goto end;
low &= ~(hfd->blocksize - 1);
// low &= ~(hfd->blocksize - 1);
hfd->physsize = hfd->virtsize = low;
hfd->handle_valid = HDF_HANDLE_LINUX;
if (hfd->physsize < 64 * 1024 * 1024 && zmode) {
write_log ("HDF '%s' re-opened in zfile-mode\n", name);
fclose (h);
hfd->handle->h = INVALID_HANDLE_VALUE;
hfd->handle->zf = zfile_fopen(name, hfd->readonly ? "rb" : "r+b", ZFD_NORMAL);
hfd->handle->zf = zfile_fopen(name, /*hfd->readonly ? "rb" :*/ "r+b", ZFD_NORMAL);
hfd->handle->zfile = 1;
if (!h)
goto end;
@ -310,6 +311,7 @@ end:
return 0;
}
#if 0
static void freehandle (struct hardfilehandle *h)
{
if (!h)
@ -322,6 +324,7 @@ static void freehandle (struct hardfilehandle *h)
h->h = INVALID_HANDLE_VALUE;
h->zfile = 0;
}
#endif
void hdf_close_target (struct hardfiledata *hfd)
{
@ -331,9 +334,9 @@ void hdf_close_target (struct hardfiledata *hfd)
hfd->emptyname = NULL;
hfd->handle = NULL;
hfd->handle_valid = 0;
if (hfd->cache)
xfree (hfd->cache);
xfree (hfd->cache);
xfree(hfd->virtual_rdb);
hfd->handle_valid = 0;
hfd->virtual_rdb = 0;
hfd->virtual_size = 0;
hfd->cache = 0;
@ -363,11 +366,11 @@ static int hdf_seek (struct hardfiledata *hfd, uae_u64 offset)
abort ();
}
offset += hfd->offset;
if (offset & (hfd->blocksize - 1)) {
gui_message ("hd: poscheck failed, offset=0x%llx not aligned to blocksize=%d! (0x%llx & 0x%04.4x = 0x%04.4x)\n",
offset, hfd->blocksize, offset, hfd->blocksize, offset & (hfd->blocksize - 1));
abort ();
}
// if (offset & (hfd->blocksize - 1)) {
// gui_message ("hd: poscheck failed, offset=0x%llx not aligned to blocksize=%d! (0x%llx & 0x%04.4x = 0x%04.4x)\n",
// offset, hfd->blocksize, offset, hfd->blocksize, offset & (hfd->blocksize - 1));
// abort ();
// }
if (hfd->handle_valid == HDF_HANDLE_LINUX) {
ret = fseek (hfd->handle->h, (long)offset, SEEK_SET);
if (ret)
@ -403,10 +406,10 @@ static void poscheck (struct hardfiledata *hfd, int len)
gui_message ("hd: poscheck failed, offset out of bounds! (0x%llx >= 0x%llx, LEN=%d)", pos, hfd->offset + hfd->physsize, len);
abort ();
}
if (pos & (hfd->blocksize - 1)) {
gui_message ("hd: poscheck failed, offset not aligned to blocksize! (0x%llx & 0x%04.4x = 0x%04.4x\n", pos, hfd->blocksize, pos & hfd->blocksize);
abort ();
}
// if (pos & (hfd->blocksize - 1)) {
// gui_message ("hd: poscheck failed, offset not aligned to blocksize! (0x%llx & 0x%04.4x = 0x%04.4x\n", pos, hfd->blocksize, pos & hfd->blocksize);
// abort ();
// }
}
static int isincache (struct hardfiledata *hfd, uae_u64 offset, int len)
@ -516,8 +519,8 @@ static int hdf_write_2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset,
{
long outlen = 0;
if (hfd->readonly)
return 0;
// if (hfd->readonly)
// return 0;
if (hfd->dangerous)
return 0;
hfd->cache_valid = 0;
@ -526,7 +529,9 @@ static int hdf_write_2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset,
memcpy (hfd->cache, buffer, len);
if (hfd->handle_valid == HDF_HANDLE_LINUX) {
outlen = fwrite (hfd->cache, 1, len, hfd->handle->h);
if (offset == 0) {
if (outlen != len)
gui_message ("Harddrive\n%s\ncache write failed!", hfd->device_name);
else if (offset == 0) {
long outlen2;
uae_u8 *tmp;
int tmplen = 512;
@ -535,7 +540,7 @@ static int hdf_write_2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset,
memset (tmp, 0xa1, tmplen);
hdf_seek (hfd, offset);
outlen2 = fread (tmp, 1, tmplen, hfd->handle->h);
if (memcmp (hfd->cache, tmp, tmplen) != 0 || outlen != len)
if (memcmp (hfd->cache, tmp, tmplen) != 0 || outlen2 != len)
gui_message ("Harddrive\n%s\nblock zero write failed!", hfd->device_name);
xfree (tmp);
}
@ -578,15 +583,15 @@ int hdf_resize_target (struct hardfiledata *hfd, uae_u64 newsize)
return 0;
}
static int num_drives;
static int hdf_init2 (int force)
{
#if 0
int index = 0, index2 = 0, drive;
uae_u8 *buffer;
int errormode;
int dwDriveMask;
static int done;
#endif
static int done = 0;
if (done && !force)
return num_drives;

View File

@ -22,17 +22,10 @@ extern uae_u8 wdregs[32];
extern struct scsi_data *scsis[8];
#define WD33C93 _T("WD33C93")
#define SCSIID (scsis[wdregs[WD_DESTINATION_ID] & 7])
extern int a2091_add_scsi_unit (int ch, const TCHAR *path, int blocksize, int readonly,
const TCHAR *devname, int sectors, int surfaces, int reserved,
int bootpri, const TCHAR *filesys);
extern int a3000_add_scsi_unit (int ch, const TCHAR *path, int blocksize, int readonly,
const TCHAR *devname, int sectors, int surfaces, int reserved,
int bootpri, const TCHAR *filesys);
extern int a2091_add_scsi_unit (int ch, struct uaedev_config_info *ci);
extern int a3000_add_scsi_unit (int ch, struct uaedev_config_info *ci);
extern int addscsi (int ch, const TCHAR *path, int blocksize, int readonly,
const TCHAR *devname, int sectors, int surfaces, int reserved,
int bootpri, const TCHAR *filesys, int scsi_level);
extern int addscsi (int ch, struct hd_hardfiledata *hfd, struct uaedev_config_info *ci, int scsi_level);
#endif

View File

@ -31,9 +31,9 @@ extern uae_u32 addr (int);
extern void db (uae_u8);
extern void dw (uae_u16);
extern void dl (uae_u32);
extern uae_u32 ds_bstr_ansi (const uae_char *);
extern uae_u32 ds_ansi (const uae_char*);
extern uae_u32 ds (const char *);
extern uae_u32 ds_bstr_ansi (const uae_char *);
extern uae_u8 dbg (uaecptr);
extern void calltrap (uae_u32);
extern void org (uae_u32);
@ -76,7 +76,7 @@ extern char *validatevolumename (char *s);
int filesys_insert (int nr, TCHAR *volume, const TCHAR *rootdir, bool readonly, int flags);
int filesys_eject (int nr);
int filesys_media_change (const char *rootdir, int inserted, struct uaedev_config_info *uci);
int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_config_data *uci);
extern char *filesys_createvolname (const char *volname, const char *rootdir, const char *def);
extern int target_get_volume_name(struct uaedev_mount_info *mtinf, const char *volumepath, char *volumename, int size, int inserted, int fullcheck);

View File

@ -41,6 +41,7 @@ extern int blitter_need (int hpos);
extern void blitter_done_notify (int hpos);
extern void blitter_slowdown (int, int, int, int);
extern int blitter_channel_state (void);
extern void blitter_check_start (void);
typedef void blitter_func(uaecptr, uaecptr, uaecptr, uaecptr, struct bltinfo *);

View File

@ -30,11 +30,7 @@ extern void deinit_socket_layer (void);
#define MAXADDRLEN 256
#ifdef _WIN32
#define SOCKET_TYPE SOCKET
#else
#define SOCKET_TYPE int
#endif
/* allocated and maintained on a per-task basis */
struct socketbase {
@ -70,14 +66,6 @@ struct socketbase {
uaecptr fdcallback;
/* host-specific fields below */
#ifdef _WIN32
SOCKET_TYPE sockAbort; /* for aborting WinSock2 select() (damn Microsoft) */
SOCKET_TYPE sockAsync; /* for aborting WSBAsyncSelect() in window message handler */
int needAbort; /* abort flag */
void *hAsyncTask; /* async task handle */
void *hEvent; /* thread event handle */
unsigned int *mtable; /* window messages allocated for asynchronous event notification */
#else
uae_sem_t sem; /* semaphore to notify the socket thread of work */
uae_thread_id thread; /* socket thread */
int sockabort[2]; /* pipe used to tell the thread to abort a select */
@ -94,7 +82,6 @@ struct socketbase {
uae_u32 sets [3];
uae_u32 timeout;
uae_u32 sigmp;
#endif
};
#define LIBRARY_SIZEOF 36
@ -142,10 +129,8 @@ extern uae_u32 strncpyha (uae_u32, const char *, int);
#define SB struct socketbase *sb
#ifndef _WIN32
typedef int SOCKET;
#define INVALID_SOCKET -1
#endif
extern void bsdsocklib_seterrno (SB, int);
extern void bsdsocklib_setherrno (SB, int);

View File

@ -14,9 +14,8 @@ uae_u8 cdtv_battram_read (int addr);
extern void cdtv_loadcardmem (uae_u8*, int);
extern void cdtv_savecardmem (uae_u8*, int);
int cdtv_add_scsi_unit (int ch, TCHAR *path, int blocksize, int readonly,
TCHAR *devname, int sectors, int surfaces, int reserved,
int bootpri, TCHAR *filesys);
extern int cdtv_add_scsi_unit (int ch, struct uaedev_config_info *ci);
extern void cdtv_getdmadata (uae_u32*);

View File

@ -27,6 +27,4 @@ extern int parallel_direct_read_data (uae_u8*);
extern int parallel_direct_write_status (uae_u8, uae_u8);
extern int parallel_direct_read_status (uae_u8*);
extern void rtc_hardreset (void);
extern void cia_heartbeat (void);
extern void rtc_hardreset (void);

View File

@ -23,9 +23,15 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef CPUMMU_H
#define CPUMMU_H
#include "mmu_common.h"
#define NO_MACHDEP
#include "sysdeps.h"
#ifndef FULLMMU
#define FULLMMU
#endif
@ -38,35 +44,10 @@
#define bug
#endif
#define SAVE_EXCEPTION
#define RESTORE_EXCEPTION
#ifdef _WIN32
struct m68k_exception {
int prb;
m68k_exception (int exc) : prb (exc) {}
operator int() { return prb; }
};
#define TRY(var) try
#define CATCH(var) catch(m68k_exception var)
#define THROW(n) throw m68k_exception(n)
#define THROW_AGAIN(var) throw
#define VOLATILE
#define ALWAYS_INLINE __inline
#else
#define TRY(x)
#define CATCH(x)
#define THROW(x)
#define THROW_AGAIN(x)
#define VOLATILE
#define ALWAYS_INLINE inline __attribute__ ((__always_inline__))
#endif //if win32
#define true 1
#define false 0
#define likely(x) x
#define unlikely(x) x
static __inline void flush_internals (void) { }
//typedef uae_u8 flagtype;
extern int mmu060_state;
extern bool mmu_pagesize_8k;
struct xttrx {
uae_u32 log_addr_base : 8;
@ -166,22 +147,6 @@ extern void mmu_dump_tables(void);
#define MMU_MMUSR_T (1 << 1)
#define MMU_MMUSR_R (1 << 0)
/* special status word (access error stack frame) */
#define MMU_SSW_TM 0x0007
#define MMU_SSW_TT 0x0018
#define MMU_SSW_SIZE 0x0060
#define MMU_SSW_SIZE_B 0x0020
#define MMU_SSW_SIZE_W 0x0040
#define MMU_SSW_SIZE_L 0x0000
#define MMU_SSW_RW 0x0100
#define MMU_SSW_LK 0x0200
#define MMU_SSW_ATC 0x0400
#define MMU_SSW_MA 0x0800
#define MMU_SSW_CM 0x1000
#define MMU_SSW_CT 0x2000
#define MMU_SSW_CU 0x4000
#define MMU_SSW_CP 0x8000
#define TTR_I0 4
#define TTR_I1 5
#define TTR_D0 6
@ -192,74 +157,140 @@ extern void mmu_dump_tables(void);
#define TTR_OK_MATCH 2
struct mmu_atc_line {
uae_u16 tag;
unsigned tt : 1;
unsigned valid_data : 1;
unsigned valid_inst : 1;
uaecptr tag; // tag is 16 or 17 bits S+logical
unsigned valid : 1;
unsigned global : 1;
unsigned modified : 1;
unsigned write_protect : 1;
unsigned hw : 1;
unsigned bus_fault : 1;
uaecptr phys;
uaecptr phys; // phys base address
};
/*
* We don't need to store the whole logical address in the atc cache, as part of
* it is encoded as index into the cache. 14 bits of the address are stored in
* the tag, this means at least 6 bits must go into the index. The upper two
* bits of the tag define the type of data in the atc line:
* - 00: a normal memory address
* - 11: invalid memory address or hardware access
* (generated via ~ATC_TAG(addr) in the slow path)
* - 10: empty atc line
* 68040 ATC is a 4 way 16 slot associative address translation cache
* the 68040 has a DATA and an INSTRUCTION ATC.
* an ATC lookup may result in : a hit, a miss and a modified state.
* the 68060 can disable ATC allocation
* we must take care of 8k and 4k page size, index position is relative to page size
*/
#define ATC_TAG_SHIFT 18
#define ATC_TAG(addr) ((uae_u32)(addr) >> ATC_TAG_SHIFT)
#define ATC_WAYS 4
#define ATC_SLOTS 16
#define ATC_TYPE 2
#define ATC_L1_SIZE_LOG 8
#define ATC_L1_SIZE (1 << ATC_L1_SIZE_LOG)
#define ATC_L1_INDEX(addr) (((addr) >> 12) % ATC_L1_SIZE)
extern uae_u32 mmu_is_super;
extern uae_u32 mmu_tagmask, mmu_pagemask;
extern struct mmu_atc_line mmu_atc_array[ATC_TYPE][ATC_WAYS][ATC_SLOTS];
/*
* first level atc cache
* indexed by [super][data][rw][idx]
*/
typedef struct mmu_atc_line mmu_atc_l1_array[2][2][ATC_L1_SIZE];
extern mmu_atc_l1_array atc_l1[2];
extern mmu_atc_l1_array *current_atc;
#define ATC_L2_SIZE_LOG 12
#define ATC_L2_SIZE (1 << ATC_L2_SIZE_LOG)
#define ATC_L2_INDEX(addr) ((((addr) >> 12) ^ ((addr) >> (32 - ATC_L2_SIZE_LOG))) % ATC_L2_SIZE)
/*
* lookup address in the level 1 atc cache,
* the data and write arguments are constant in the common,
* thus allows gcc to generate a constant offset.
* mmu access is a 4 step process:
* if mmu is not enabled just read physical
* check transparent region, if transparent, read physical
* check ATC (address translation cache), read immediatly if HIT
* read from mmu with the long path (and allocate ATC entry if needed)
*/
static ALWAYS_INLINE bool mmu_lookup(uaecptr addr, bool data, bool write,
struct mmu_atc_line **cl)
{
addr >>= 12;
*cl = &(*current_atc)[data ? 1 : 0][write ? 1 : 0][addr % ATC_L1_SIZE];
return (*cl)->tag == addr >> (ATC_TAG_SHIFT - 12);
int way,index;
static int way_miss=0;
uae_u32 tag = (mmu_is_super | (addr >> 1)) & mmu_tagmask;
if (mmu_pagesize_8k)
index=(addr & 0x0001E000)>>13;
else
index=(addr & 0x0000F000)>>12;
for (way=0;way<ATC_WAYS;way++) {
// if we have this
if ((tag == mmu_atc_array[data][way][index].tag) && (mmu_atc_array[data][way][index].valid)) {
*cl=&mmu_atc_array[data][way][index];
// if first write to this take slow path (but modify this slot)
if ((!mmu_atc_array[data][way][index].modified & write) || (mmu_atc_array[data][way][index].write_protect & write))
return false;
return true;
}
}
// we select a random way to void
*cl=&mmu_atc_array[data][way_miss%ATC_WAYS][index];
(*cl)->tag = tag;
way_miss++;
return false;
}
/*
* similiar to mmu_user_lookup, but for the use of the moves instruction
*/
static ALWAYS_INLINE bool mmu_user_lookup(uaecptr addr, bool super, bool data,
bool write, struct mmu_atc_line **cl)
{
addr >>= 12;
*cl = &atc_l1[super ? 1 : 0][data ? 1 : 0][write ? 1 : 0][addr % ATC_L1_SIZE];
return (*cl)->tag == addr >> (ATC_TAG_SHIFT - 12);
int way,index;
static int way_miss=0;
uae_u32 tag = ((super ? 0x80000000 : 0x00000000) | (addr >> 1)) & mmu_tagmask;
if (mmu_pagesize_8k)
index=(addr & 0x0001E000)>>13;
else
index=(addr & 0x0000F000)>>12;
for (way=0;way<ATC_WAYS;way++) {
// if we have this
if ((tag == mmu_atc_array[data][way][index].tag) && (mmu_atc_array[data][way][index].valid)) {
*cl=&mmu_atc_array[data][way][index];
// if first write to this take slow path (but modify this slot)
if ((!mmu_atc_array[data][way][index].modified & write) || (mmu_atc_array[data][way][index].write_protect & write))
return false;
return true;
}
}
// we select a random way to void
*cl=&mmu_atc_array[data][way_miss%ATC_WAYS][index];
(*cl)->tag = tag;
way_miss++;
return false;
}
/* check if an address matches a ttr */
STATIC_INLINE int mmu_do_match_ttr(uae_u32 ttr, uaecptr addr, bool super)
{
if (ttr & MMU_TTR_BIT_ENABLED) { /* TTR enabled */
uae_u8 msb, mask;
msb = ((addr ^ ttr) & MMU_TTR_LOGICAL_BASE) >> 24;
mask = (ttr & MMU_TTR_LOGICAL_MASK) >> 16;
if (!(msb & ~mask)) {
if ((ttr & MMU_TTR_BIT_SFIELD_ENABLED) == 0) {
if (((ttr & MMU_TTR_BIT_SFIELD_SUPER) == 0) != (super == 0)) {
return TTR_NO_MATCH;
}
}
return (ttr & MMU_TTR_BIT_WRITE_PROTECT) ? TTR_NO_WRITE : TTR_OK_MATCH;
}
}
return TTR_NO_MATCH;
}
STATIC_INLINE int mmu_match_ttr(uaecptr addr, bool super, bool data)
{
int res;
if (data) {
res = mmu_do_match_ttr(regs.dtt0, addr, super);
if (res == TTR_NO_MATCH)
res = mmu_do_match_ttr(regs.dtt1, addr, super);
} else {
res = mmu_do_match_ttr(regs.itt0, addr, super);
if (res == TTR_NO_MATCH)
res = mmu_do_match_ttr(regs.itt1, addr, super);
}
return res;
}
extern void mmu_bus_error_ttr_write_fault(uaecptr addr, bool super, bool data, uae_u32 val, int size);
STATIC_INLINE int mmu_match_ttr_write(uaecptr addr, bool super, bool data, uae_u32 val,int size)
{
int res = mmu_match_ttr(addr, super, data);
if (res == TTR_NO_WRITE)
mmu_bus_error_ttr_write_fault(addr, super, data, val, size);
return res;
}
extern uae_u16 REGPARAM3 mmu_get_word_unaligned(uaecptr addr, bool data) REGPARAM;
@ -296,51 +327,55 @@ extern void REGPARAM3 dfc_put_long(uaecptr addr, uae_u32 val) REGPARAM;
extern void REGPARAM3 dfc_put_word(uaecptr addr, uae_u16 val) REGPARAM;
extern void REGPARAM3 dfc_put_byte(uaecptr addr, uae_u8 val) REGPARAM;
#define sfc040_get_long sfc_get_long
#define sfc040_get_word sfc_get_word
#define sfc040_get_byte sfc_get_byte
#define dfc040_put_long dfc_put_long
#define dfc040_put_word dfc_put_word
#define dfc040_put_byte dfc_put_byte
#define sfc060_get_long sfc_get_long
#define sfc060_get_word sfc_get_word
#define sfc060_get_byte sfc_get_byte
#define dfc060_put_long dfc_put_long
#define dfc060_put_word dfc_put_word
#define dfc060_put_byte dfc_put_byte
extern void REGPARAM3 mmu_flush_atc(uaecptr addr, bool super, bool global) REGPARAM;
extern void REGPARAM3 mmu_flush_atc_all(bool global) REGPARAM;
extern void REGPARAM3 mmu_op_real(uae_u32 opcode, uae_u16 extra) REGPARAM;
extern void REGPARAM3 mmu_reset(void) REGPARAM;
extern void REGPARAM3 mmu_set_tc(uae_u16 tc) REGPARAM;
extern void REGPARAM3 mmu_set_super(bool super) REGPARAM;
static ALWAYS_INLINE bool is_unaligned(uaecptr addr, int size)
{
return unlikely((addr & (size - 1)) && (addr ^ (addr + size - 1)) & 0x1000);
}
static ALWAYS_INLINE uaecptr mmu_get_real_address(uaecptr addr, struct mmu_atc_line *cl)
{
return cl->phys + addr;
return cl->phys | (addr & mmu_pagemask);
}
static ALWAYS_INLINE void phys_put_long(uaecptr addr, uae_u32 l)
static ALWAYS_INLINE void mmu060_get_move16(uaecptr addr, uae_u32 *v, bool data, int size)
{
longput(addr, l);
struct mmu_atc_line *cl;
for (int i = 0; i < 4; i++) {
uaecptr addr2 = addr + i * 4;
// addr,super,data
if ((!regs.mmu_enabled) || (mmu_match_ttr(addr2,regs.s != 0,data)!=TTR_NO_MATCH))
v[i] = phys_get_long(addr2);
else if (likely(mmu_lookup(addr2, data, false, &cl)))
v[i] = phys_get_long(mmu_get_real_address(addr2, cl));
else
v[i] = mmu_get_long_slow(addr2, regs.s != 0, data, size, cl);
}
static ALWAYS_INLINE void phys_put_word(uaecptr addr, uae_u32 w)
{
wordput(addr, w);
}
static ALWAYS_INLINE void phys_put_byte(uaecptr addr, uae_u32 b)
{
byteput(addr, b);
}
static ALWAYS_INLINE uae_u32 phys_get_long(uaecptr addr)
{
return longget (addr);
}
static ALWAYS_INLINE uae_u32 phys_get_word(uaecptr addr)
{
return wordget (addr);
}
static ALWAYS_INLINE uae_u32 phys_get_byte(uaecptr addr)
{
return byteget (addr);
}
static ALWAYS_INLINE uae_u32 mmu_get_long(uaecptr addr, bool data, int size)
{
struct mmu_atc_line *cl;
// addr,super,data
if ((!regs.mmu_enabled) || (mmu_match_ttr(addr,regs.s != 0,data)!=TTR_NO_MATCH))
return phys_get_long(addr);
if (likely(mmu_lookup(addr, data, false, &cl)))
return phys_get_long(mmu_get_real_address(addr, cl));
return mmu_get_long_slow(addr, regs.s != 0, data, size, cl);
@ -350,6 +385,9 @@ static ALWAYS_INLINE uae_u16 mmu_get_word(uaecptr addr, bool data, int size)
{
struct mmu_atc_line *cl;
// addr,super,data
if ((!regs.mmu_enabled) || (mmu_match_ttr(addr,regs.s != 0,data)!=TTR_NO_MATCH))
return phys_get_word(addr);
if (likely(mmu_lookup(addr, data, false, &cl)))
return phys_get_word(mmu_get_real_address(addr, cl));
return mmu_get_word_slow(addr, regs.s != 0, data, size, cl);
@ -359,26 +397,53 @@ static ALWAYS_INLINE uae_u8 mmu_get_byte(uaecptr addr, bool data, int size)
{
struct mmu_atc_line *cl;
// addr,super,data
if ((!regs.mmu_enabled) || (mmu_match_ttr(addr,regs.s != 0,data)!=TTR_NO_MATCH))
return phys_get_byte(addr);
if (likely(mmu_lookup(addr, data, false, &cl)))
return phys_get_byte(mmu_get_real_address(addr, cl));
return mmu_get_byte_slow(addr, regs.s != 0, data, size, cl);
}
static ALWAYS_INLINE void mmu_put_long(uaecptr addr, uae_u32 val, bool data, int size)
{
struct mmu_atc_line *cl;
// addr,super,data
if ((!regs.mmu_enabled) || mmu_match_ttr_write(addr,regs.s != 0,data,val,size)==TTR_OK_MATCH) {
phys_put_long(addr,val);
return;
}
if (likely(mmu_lookup(addr, data, true, &cl)))
phys_put_long(mmu_get_real_address(addr, cl), val);
else
mmu_put_long_slow(addr, val, regs.s != 0, data, size, cl);
}
static ALWAYS_INLINE void mmu060_put_move16(uaecptr addr, uae_u32 *val, bool data, int size)
{
struct mmu_atc_line *cl;
for (int i = 0; i < 4; i++) {
uaecptr addr2 = addr + i * 4;
// addr,super,data
if ((!regs.mmu_enabled) || (mmu_match_ttr_write(addr2,regs.s != 0,data,val[i],size)==TTR_OK_MATCH))
phys_put_long(addr2,val[i]);
else if (likely(mmu_lookup(addr2, data, true, &cl)))
phys_put_long(mmu_get_real_address(addr2, cl), val[i]);
else
mmu_put_long_slow(addr2, val[i], regs.s != 0, data, size, cl);
}
}
static ALWAYS_INLINE void mmu_put_word(uaecptr addr, uae_u16 val, bool data, int size)
{
struct mmu_atc_line *cl;
// addr,super,data
if ((!regs.mmu_enabled) || (mmu_match_ttr_write(addr,regs.s != 0,data,val,size)==TTR_OK_MATCH)) {
phys_put_word(addr,val);
return;
}
if (likely(mmu_lookup(addr, data, true, &cl)))
phys_put_word(mmu_get_real_address(addr, cl), val);
else
@ -389,6 +454,11 @@ static ALWAYS_INLINE void mmu_put_byte(uaecptr addr, uae_u8 val, bool data, int
{
struct mmu_atc_line *cl;
// addr,super,data
if ((!regs.mmu_enabled) || (mmu_match_ttr_write(addr,regs.s != 0,data,val,size)==TTR_OK_MATCH)) {
phys_put_byte(addr,val);
return;
}
if (likely(mmu_lookup(addr, data, true, &cl)))
phys_put_byte(mmu_get_real_address(addr, cl), val);
else
@ -399,6 +469,9 @@ static ALWAYS_INLINE uae_u32 mmu_get_user_long(uaecptr addr, bool super, bool da
{
struct mmu_atc_line *cl;
// addr,super,data
if ((!regs.mmu_enabled) || (mmu_match_ttr(addr,super,data)!=TTR_NO_MATCH))
return phys_get_long(addr);
if (likely(mmu_user_lookup(addr, super, data, false, &cl)))
return phys_get_long(mmu_get_real_address(addr, cl));
return mmu_get_long_slow(addr, super, data, size, cl);
@ -408,6 +481,9 @@ static ALWAYS_INLINE uae_u16 mmu_get_user_word(uaecptr addr, bool super, bool da
{
struct mmu_atc_line *cl;
// addr,super,data
if ((!regs.mmu_enabled) || (mmu_match_ttr(addr,super,data)!=TTR_NO_MATCH))
return phys_get_word(addr);
if (likely(mmu_user_lookup(addr, super, data, false, &cl)))
return phys_get_word(mmu_get_real_address(addr, cl));
return mmu_get_word_slow(addr, super, data, size, cl);
@ -417,6 +493,9 @@ static ALWAYS_INLINE uae_u8 mmu_get_user_byte(uaecptr addr, bool super, bool dat
{
struct mmu_atc_line *cl;
// addr,super,data
if ((!regs.mmu_enabled) || (mmu_match_ttr(addr,super,data)!=TTR_NO_MATCH))
return phys_get_byte(addr);
if (likely(mmu_user_lookup(addr, super, data, false, &cl)))
return phys_get_byte(mmu_get_real_address(addr, cl));
return mmu_get_byte_slow(addr, super, data, size, cl);
@ -426,6 +505,11 @@ static ALWAYS_INLINE void mmu_put_user_long(uaecptr addr, uae_u32 val, bool supe
{
struct mmu_atc_line *cl;
// addr,super,data
if ((!regs.mmu_enabled) || (mmu_match_ttr(addr,super,data)==TTR_OK_MATCH)) {
phys_put_long(addr,val);
return;
}
if (likely(mmu_user_lookup(addr, super, data, true, &cl)))
phys_put_long(mmu_get_real_address(addr, cl), val);
else
@ -436,6 +520,11 @@ static ALWAYS_INLINE void mmu_put_user_word(uaecptr addr, uae_u16 val, bool supe
{
struct mmu_atc_line *cl;
// addr,super,data
if ((!regs.mmu_enabled) || (mmu_match_ttr(addr,super,data)==TTR_OK_MATCH)) {
phys_put_word(addr,val);
return;
}
if (likely(mmu_user_lookup(addr, super, data, true, &cl)))
phys_put_word(mmu_get_real_address(addr, cl), val);
else
@ -446,6 +535,11 @@ static ALWAYS_INLINE void mmu_put_user_byte(uaecptr addr, uae_u8 val, bool super
{
struct mmu_atc_line *cl;
// addr,super,data
if ((!regs.mmu_enabled) || (mmu_match_ttr(addr,super,data)==TTR_OK_MATCH)) {
phys_put_byte(addr,val);
return;
}
if (likely(mmu_user_lookup(addr, super, data, true, &cl)))
phys_put_byte(mmu_get_real_address(addr, cl), val);
else
@ -478,119 +572,245 @@ static ALWAYS_INLINE uae_u32 HWget_b(uaecptr addr)
return get_byte (addr);
}
static ALWAYS_INLINE uae_u32 uae_mmu_get_ilong(uaecptr addr)
static ALWAYS_INLINE uae_u32 uae_mmu040_get_ilong(uaecptr addr)
{
if (unlikely(is_unaligned(addr, 4)))
return mmu_get_long_unaligned(addr, false);
return mmu_get_long(addr, false, sz_long);
}
static ALWAYS_INLINE uae_u16 uae_mmu_get_iword(uaecptr addr)
static ALWAYS_INLINE uae_u16 uae_mmu040_get_iword(uaecptr addr)
{
if (unlikely(is_unaligned(addr, 2)))
return mmu_get_word_unaligned(addr, false);
return mmu_get_word(addr, false, sz_word);
}
static ALWAYS_INLINE uae_u16 uae_mmu_get_ibyte(uaecptr addr)
static ALWAYS_INLINE uae_u16 uae_mmu040_get_ibyte(uaecptr addr)
{
return mmu_get_byte(addr, false, sz_byte);
}
static ALWAYS_INLINE uae_u32 uae_mmu_get_long(uaecptr addr)
static ALWAYS_INLINE uae_u32 uae_mmu040_get_long(uaecptr addr)
{
if (unlikely(is_unaligned(addr, 4)))
return mmu_get_long_unaligned(addr, true);
return mmu_get_long(addr, true, sz_long);
}
static ALWAYS_INLINE uae_u16 uae_mmu_get_word(uaecptr addr)
static ALWAYS_INLINE uae_u16 uae_mmu040_get_word(uaecptr addr)
{
if (unlikely(is_unaligned(addr, 2)))
return mmu_get_word_unaligned(addr, true);
return mmu_get_word(addr, true, sz_word);
}
static ALWAYS_INLINE uae_u8 uae_mmu_get_byte(uaecptr addr)
static ALWAYS_INLINE uae_u8 uae_mmu040_get_byte(uaecptr addr)
{
return mmu_get_byte(addr, true, sz_byte);
}
static ALWAYS_INLINE void uae_mmu_put_long(uaecptr addr, uae_u32 val)
{
if (unlikely(is_unaligned(addr, 4)))
mmu_put_long_unaligned(addr, val, true);
else
mmu_put_long(addr, val, true, sz_long);
}
static ALWAYS_INLINE void uae_mmu_put_word(uaecptr addr, uae_u16 val)
static ALWAYS_INLINE void uae_mmu040_put_word(uaecptr addr, uae_u16 val)
{
if (unlikely(is_unaligned(addr, 2)))
mmu_put_word_unaligned(addr, val, true);
else
mmu_put_word(addr, val, true, sz_word);
}
static ALWAYS_INLINE void uae_mmu_put_byte(uaecptr addr, uae_u8 val)
static ALWAYS_INLINE void uae_mmu040_put_byte(uaecptr addr, uae_u8 val)
{
mmu_put_byte(addr, val, true, sz_byte);
}
static ALWAYS_INLINE void uae_mmu040_put_long(uaecptr addr, uae_u32 val)
{
if (unlikely(is_unaligned(addr, 4)))
mmu_put_long_unaligned(addr, val, true);
else
mmu_put_long(addr, val, true, sz_long);
}
STATIC_INLINE void put_byte_mmu (uaecptr addr, uae_u32 v)
static ALWAYS_INLINE uae_u32 uae_mmu060_get_ilong(uaecptr addr)
{
uae_mmu_put_byte (addr, v);
if (unlikely(is_unaligned(addr, 4)))
return mmu_get_long_unaligned(addr, false);
return mmu_get_long(addr, false, sz_long);
}
STATIC_INLINE void put_word_mmu (uaecptr addr, uae_u32 v)
static ALWAYS_INLINE uae_u16 uae_mmu060_get_iword(uaecptr addr)
{
uae_mmu_put_word (addr, v);
if (unlikely(is_unaligned(addr, 2)))
return mmu_get_word_unaligned(addr, false);
return mmu_get_word(addr, false, sz_word);
}
STATIC_INLINE void put_long_mmu (uaecptr addr, uae_u32 v)
static ALWAYS_INLINE uae_u16 uae_mmu060_get_ibyte(uaecptr addr)
{
uae_mmu_put_long (addr, v);
return mmu_get_byte(addr, false, sz_byte);
}
STATIC_INLINE uae_u32 get_byte_mmu (uaecptr addr)
static ALWAYS_INLINE uae_u32 uae_mmu060_get_long(uaecptr addr)
{
return uae_mmu_get_byte (addr);
if (unlikely(is_unaligned(addr, 4)))
return mmu_get_long_unaligned(addr, true);
return mmu_get_long(addr, true, sz_long);
}
STATIC_INLINE uae_u32 get_word_mmu (uaecptr addr)
static ALWAYS_INLINE uae_u16 uae_mmu060_get_word(uaecptr addr)
{
return uae_mmu_get_word (addr);
if (unlikely(is_unaligned(addr, 2)))
return mmu_get_word_unaligned(addr, true);
return mmu_get_word(addr, true, sz_word);
}
STATIC_INLINE uae_u32 get_long_mmu (uaecptr addr)
static ALWAYS_INLINE uae_u8 uae_mmu060_get_byte(uaecptr addr)
{
return uae_mmu_get_long (addr);
return mmu_get_byte(addr, true, sz_byte);
}
STATIC_INLINE uae_u32 get_ibyte_mmu (int o)
static ALWAYS_INLINE void uae_mmu060_get_move16(uaecptr addr, uae_u32 *val)
{
// move16 is always aligned
mmu060_get_move16(addr, val, true, 16);
}
static ALWAYS_INLINE void uae_mmu060_put_long(uaecptr addr, uae_u32 val)
{
if (unlikely(is_unaligned(addr, 4)))
mmu_put_long_unaligned(addr, val, true);
else
mmu_put_long(addr, val, true, sz_long);
}
static ALWAYS_INLINE void uae_mmu060_put_word(uaecptr addr, uae_u16 val)
{
if (unlikely(is_unaligned(addr, 2)))
mmu_put_word_unaligned(addr, val, true);
else
mmu_put_word(addr, val, true, sz_word);
}
static ALWAYS_INLINE void uae_mmu060_put_byte(uaecptr addr, uae_u8 val)
{
mmu_put_byte(addr, val, true, sz_byte);
}
static ALWAYS_INLINE void uae_mmu060_put_move16(uaecptr addr, uae_u32 *val)
{
// move16 is always aligned
mmu060_put_move16(addr, val, true, 16);
}
STATIC_INLINE void put_byte_mmu040 (uaecptr addr, uae_u32 v)
{
uae_mmu040_put_byte (addr, v);
}
STATIC_INLINE void put_word_mmu040 (uaecptr addr, uae_u32 v)
{
uae_mmu040_put_word (addr, v);
}
STATIC_INLINE void put_long_mmu040 (uaecptr addr, uae_u32 v)
{
uae_mmu040_put_long (addr, v);
}
STATIC_INLINE uae_u32 get_byte_mmu040 (uaecptr addr)
{
return uae_mmu040_get_byte (addr);
}
STATIC_INLINE uae_u32 get_word_mmu040 (uaecptr addr)
{
return uae_mmu040_get_word (addr);
}
STATIC_INLINE uae_u32 get_long_mmu040 (uaecptr addr)
{
return uae_mmu040_get_long (addr);
}
STATIC_INLINE void put_byte_mmu060 (uaecptr addr, uae_u32 v)
{
uae_mmu060_put_byte (addr, v);
}
STATIC_INLINE void put_word_mmu060 (uaecptr addr, uae_u32 v)
{
uae_mmu060_put_word (addr, v);
}
STATIC_INLINE void put_long_mmu060 (uaecptr addr, uae_u32 v)
{
uae_mmu060_put_long (addr, v);
}
STATIC_INLINE uae_u32 get_byte_mmu060 (uaecptr addr)
{
return uae_mmu060_get_byte (addr);
}
STATIC_INLINE uae_u32 get_word_mmu060 (uaecptr addr)
{
return uae_mmu060_get_word (addr);
}
STATIC_INLINE uae_u32 get_long_mmu060 (uaecptr addr)
{
return uae_mmu060_get_long (addr);
}
STATIC_INLINE void get_move16_mmu060 (uaecptr addr, uae_u32 *v)
{
return uae_mmu060_get_move16 (addr, v);
}
STATIC_INLINE void put_move16_mmu060 (uaecptr addr, uae_u32 *v)
{
return uae_mmu060_put_move16 (addr, v);
}
STATIC_INLINE uae_u32 get_ibyte_mmu040 (int o)
{
uae_u32 pc = m68k_getpc () + o;
return uae_mmu_get_iword (pc);
return uae_mmu040_get_iword (pc);
}
STATIC_INLINE uae_u32 get_iword_mmu (int o)
STATIC_INLINE uae_u32 get_iword_mmu040 (int o)
{
uae_u32 pc = m68k_getpc () + o;
return uae_mmu_get_iword (pc);
return uae_mmu040_get_iword (pc);
}
STATIC_INLINE uae_u32 get_ilong_mmu (int o)
STATIC_INLINE uae_u32 get_ilong_mmu040 (int o)
{
uae_u32 pc = m68k_getpc () + o;
return uae_mmu_get_ilong (pc);
return uae_mmu040_get_ilong (pc);
}
STATIC_INLINE uae_u32 next_iword_mmu (void)
STATIC_INLINE uae_u32 next_iword_mmu040 (void)
{
uae_u32 pc = m68k_getpc ();
m68k_incpci (2);
return uae_mmu_get_iword (pc);
return uae_mmu040_get_iword (pc);
}
STATIC_INLINE uae_u32 next_ilong_mmu (void)
STATIC_INLINE uae_u32 next_ilong_mmu040 (void)
{
uae_u32 pc = m68k_getpc ();
m68k_incpci (4);
return uae_mmu_get_ilong (pc);
return uae_mmu040_get_ilong (pc);
}
extern void m68k_do_rts_mmu (void);
extern void m68k_do_rte_mmu (uaecptr a7);
extern void m68k_do_bsr_mmu (uaecptr oldpc, uae_s32 offset);
extern void mmu_dump_atc(void);
struct mmufixup
STATIC_INLINE uae_u32 get_ibyte_mmu060 (int o)
{
int reg;
uae_u32 value;
};
extern struct mmufixup mmufixup[2];
uae_u32 pc = m68k_getpc () + o;
return uae_mmu060_get_iword (pc);
}
STATIC_INLINE uae_u32 get_iword_mmu060 (int o)
{
uae_u32 pc = m68k_getpc () + o;
return uae_mmu060_get_iword (pc);
}
STATIC_INLINE uae_u32 get_ilong_mmu060 (int o)
{
uae_u32 pc = m68k_getpc () + o;
return uae_mmu060_get_ilong (pc);
}
STATIC_INLINE uae_u32 next_iword_mmu060 (void)
{
uae_u32 pc = m68k_getpc ();
m68k_incpci (2);
return uae_mmu060_get_iword (pc);
}
STATIC_INLINE uae_u32 next_ilong_mmu060 (void)
{
uae_u32 pc = m68k_getpc ();
m68k_incpci (4);
return uae_mmu060_get_ilong (pc);
}
extern void flush_mmu040 (uaecptr, int);
extern void m68k_do_rts_mmu040 (void);
extern void m68k_do_rte_mmu040 (uaecptr a7);
extern void m68k_do_bsr_mmu040 (uaecptr oldpc, uae_s32 offset);
extern void flush_mmu060 (uaecptr, int);
extern void m68k_do_rts_mmu060 (void);
extern void m68k_do_rte_mmu060 (uaecptr a7);
extern void m68k_do_bsr_mmu060 (uaecptr oldpc, uae_s32 offset);
#endif /* CPUMMU_H */

View File

@ -18,6 +18,10 @@
#define CHIPSET_CLOCK_PAL 3546895
#define CHIPSET_CLOCK_NTSC 3579545
#define MAXHPOS_ROWS 256
#define MAXVPOS_LINES_ECS 2048
#define MAXVPOS_LINES_OCS 512
uae_u32 get_copper_address (int copno);
extern int custom_init (void);

View File

@ -75,6 +75,11 @@ void debug_bputpeek (uaecptr addr, uae_u32 v);
void debug_wputpeek (uaecptr addr, uae_u32 v);
void debug_lputpeek (uaecptr addr, uae_u32 v);
uae_u32 get_byte_debug (uaecptr addr);
uae_u32 get_word_debug (uaecptr addr);
uae_u32 get_long_debug (uaecptr addr);
enum debugtest_item { DEBUGTEST_BLITTER, DEBUGTEST_KEYBOARD, DEBUGTEST_FLOPPY, DEBUGTEST_MAX };
void debugtest (enum debugtest_item, const TCHAR *, ...);

View File

@ -21,7 +21,6 @@ extern int disk_empty (int num);
extern void disk_insert (int num, const TCHAR *name);
extern void disk_insert_force (int num, const TCHAR *name, bool writeprotected);
extern void DISK_vsync (void);
//extern int DISK_validate_filename (const TCHAR *fname, int leave_open, bool *wrprot, uae_u32 *crc32, struct zfile **zf);
extern int DISK_validate_filename (struct uae_prefs *p, const TCHAR *fname, int leave_open, bool *wrprot, uae_u32 *crc32, struct zfile **zf);
extern void DISK_handler (uae_u32);
extern void DISK_update (int hpos);
@ -54,9 +53,6 @@ extern int disk_fifostatus (void);
extern int disk_debug_logging;
extern int disk_debug_mode;
extern int disk_debug_track;
extern int getdebug(void);
#define DISK_DEBUG_DMA_READ 1
#define DISK_DEBUG_DMA_WRITE 2
#define DISK_DEBUG_PIO 4

View File

@ -40,6 +40,7 @@
#define PIXEL_XPOS(HPOS) (((HPOS)*2 - DISPLAY_LEFT_SHIFT + DIW_DDF_OFFSET - 1) << lores_shift)
#define min_diwlastword (0)
#define max_diwlastword (PIXEL_XPOS(0x1d4 >> 1))
extern int lores_factor, lores_shift, interlace_seen;
@ -269,7 +270,7 @@ enum nln_how {
extern void hsync_record_line_state (int lineno, enum nln_how, int changed);
extern void vsync_handle_redraw (int long_frame, int lof_changed, uae_u16, uae_u16);
extern void vsync_handle_check (void);
extern bool vsync_handle_check (void);
extern void init_hardware_for_drawing_frame (void);
extern void reset_drawing (void);
extern void drawing_init (void);
@ -279,7 +280,7 @@ extern void frame_drawn (void);
extern void redraw_frame (void);
extern int get_custom_limits (int *pw, int *ph, int *pdx, int *pdy, int *prealh);
extern void set_custom_limits (int w, int h, int dx, int dy);
extern void get_custom_topedge (int *x, int *y);
extern void get_custom_topedge (int *x, int *y, bool max);
extern void putpixel (uae_u8 *buf, int bpp, int x, xcolnr c8, int opaq);
/* Finally, stuff that shouldn't really be shared. */
@ -289,7 +290,6 @@ extern int thisframe_first_drawn_line, thisframe_last_drawn_line;
#define IHF_SCROLLLOCK 0
#define IHF_QUIT_PROGRAM 1
#define IHF_PICASSO 2
#define IHF_SOUNDADJUST 3
extern int inhibit_frame;

View File

@ -89,9 +89,6 @@ extern signed long pissoff;
extern struct ev eventtab[ev_max];
extern struct ev2 eventtab2[ev2_max];
extern volatile bool vblank_found_chipset;
extern volatile bool vblank_found_rtg;
STATIC_INLINE void cycles_do_special (void)
{
#ifdef JIT

View File

@ -17,6 +17,7 @@ struct uaedev_config_info;
struct uae_prefs;
#define MAX_HDF_CACHE_BLOCKS 128
#define MAX_SCSI_SENSE 36
struct hdf_cache
{
bool valid;
@ -32,14 +33,9 @@ struct hardfiledata {
uae_u64 virtsize; // virtual size
uae_u64 physsize; // physical size (dynamic disk)
uae_u64 offset;
int nrcyls;
int secspertrack;
int surfaces;
int reservedblocks;
int blocksize;
struct uaedev_config_info ci;
struct hardfilehandle *handle;
int handle_valid;
int readonly;
int dangerous;
int flags;
uae_u8 *cache;
@ -50,36 +46,42 @@ struct hardfiledata {
TCHAR product_rev[4 + 1];
TCHAR device_name[256];
/* geometry from possible RDSK block */
int cylinders;
int sectors;
int heads;
int rdbcylinders;
int rdbsectors;
int rdbheads;
uae_u8 *virtual_rdb;
uae_u64 virtual_size;
int unitnum;
int byteswap;
int adide;
int hfd_type;
uae_u8 *vhd_header;
uae_u32 vhd_bamoffset;
uae_u32 vhd_bamsize;
uae_u32 vhd_blocksize;
uae_u32 vhd_type;
uae_u8 *vhd_sectormap;
uae_u64 vhd_sectormapblock;
uae_u32 vhd_bitmapsize;
uae_u64 vhd_footerblock;
void *chd_handle;
int drive_empty;
TCHAR *emptyname;
struct hdf_cache bcache[MAX_HDF_CACHE_BLOCKS];
uae_u8 scsi_sense[MAX_SCSI_SENSE];
struct uaedev_config_info delayedci;
int reinsertdelay;
bool isreinsert;
};
#define HFD_FLAGS_REALDRIVE 1
struct hd_hardfiledata {
struct hardfiledata hfd;
int bootpri;
uae_u64 size;
int cyls;
int heads;
@ -87,7 +89,6 @@ struct hd_hardfiledata {
int cyls_def;
int secspertrack_def;
int heads_def;
TCHAR *path;
int ansi_version;
};
@ -130,13 +131,12 @@ extern int hdf_getnumharddrives (void);
extern TCHAR *hdf_getnameharddrive (int index, int flags, int *sectorsize, int *dangerousdrive);
extern int isspecialdrive(const TCHAR *name);
extern int get_native_path(uae_u32 lock, TCHAR *out);
extern void hardfile_do_disk_change (struct uaedev_config_info *uci, int insert);
extern void hardfile_do_disk_change (struct uaedev_config_data *uci, bool insert);
extern void hardfile_send_disk_change (struct hardfiledata *hfd, bool insert);
extern int hardfile_media_change (struct hardfiledata *hfd, struct uaedev_config_info *ci, bool inserted, bool timer);
void hdf_hd_close(struct hd_hardfiledata *hfd);
int hdf_hd_open(struct hd_hardfiledata *hfd, const TCHAR *path, int blocksize, int readonly,
const TCHAR *devname, int cyls, int sectors, int surfaces, int reserved,
int bootpri, const TCHAR *filesys,
int pcyls, int pheads, int psectors);
int hdf_hd_open(struct hd_hardfiledata *hfd);
extern int vhd_create (const TCHAR *name, uae_u64 size, uae_u32);
@ -152,21 +152,4 @@ extern void getchsgeometry (uae_u64 size, int *pcyl, int *phead, int *psectorspe
extern void getchsgeometry_hdf (struct hardfiledata *hfd, uae_u64 size, int *pcyl, int *phead, int *psectorspertrack);
extern void getchspgeometry (uae_u64 total, int *pcyl, int *phead, int *psectorspertrack, bool idegeometry);
int get_filesys_unitconfig (struct uae_prefs *, int, struct mountedinfo *);
int set_filesys_unit (int nr,
const TCHAR *devname, const TCHAR *volname, const TCHAR *rootdir, bool readonly,
int cyls, int secspertrack, int surfaces, int reserved,
int blocksize, int bootpri, bool donotmount, bool autoboot,
const TCHAR *filesysdir, int hdc, int flags);
int add_filesys_unit (const TCHAR *devname, const TCHAR *volname, const TCHAR *rootdir, bool readonly,
int cyls, int secspertrack, int surfaces, int reserved,
int blocksize, int bootpri, bool donotmount, bool autoboot,
const TCHAR *filesysdir, int hdc, int flags);
int kill_filesys_unitconfig (struct uae_prefs *, int);
int move_filesys_unitconfig (struct uae_prefs *p, int nr, int to);
void filesys_addexternals (void);
void free_mountinfo (void);
void setsystime (void);
#endif // SRC_INCLUDE_FILESYS_H_INCLUDED

View File

@ -118,18 +118,10 @@ struct mystat
struct mytimeval mtime;
};
#ifdef __WIN32__
struct my_opendir_s {
HANDLE h;
WIN32_FIND_DATA fd;
int first;
};
#else
struct my_opendir_s {
DIR *h;
int first;
};
#endif
struct my_openfile_s {
HANDLE h;

View File

@ -1,9 +1,7 @@
extern void gayle_reset (int);
extern void gayle_hsync (void);
extern int gayle_add_ide_unit (int ch, const TCHAR *path, int blocksize, int readonly,
const TCHAR *devname, int cyls, int sectors, int surfaces, int reserved,
int bootpri, const TCHAR *filesys, int pcyls, int pheads, int psecs);
extern int gayle_add_ide_unit (int ch, struct uaedev_config_info *ci);
extern int gayle_modify_pcmcia_sram_unit (const TCHAR *path, int readonly, int insert);
extern int gayle_modify_pcmcia_ide_unit (const TCHAR *path, int readonly, int insert);
extern int gayle_add_pcmcia_sram_unit (const TCHAR *path, int readonly);

View File

@ -7,7 +7,7 @@ typedef unsigned long u32;
extern void S2X_refresh (void);
extern void S2X_render (void);
extern void S2X_init (int dw, int dh, int aw, int ah, int ad, int dd);
extern bool S2X_init (int dw, int dh, int dd);
extern void S2X_reset (void);
extern void S2X_free (void);
extern int S2X_getmult (void);
@ -73,6 +73,5 @@ struct uae_filter
};
extern struct uae_filter uaefilters[];
extern struct uae_filter *usedfilter;
#endif

View File

@ -55,6 +55,7 @@ struct gui_info
uae_s8 hd; /* harddrive */
uae_s8 cd; /* CD */
uae_s8 md; /* CD32 or CDTV internal storage */
bool cpu_halted;
int fps, idle;
int fps_color;
int sndbuf, sndbuf_status;

View File

@ -154,14 +154,12 @@ extern int inputdevice_get_device_total (int type);
extern int inputdevice_get_widget_num (int devnum);
extern int inputdevice_get_widget_type (int devnum, int num, TCHAR *name);
extern int input_get_default_mouse (struct uae_input_device *uid, int num, int port, int af, bool gp);
extern int input_get_default_mouse (struct uae_input_device *uid, int num, int port, int af, bool gp, bool wheel);
extern int input_get_default_lightpen (struct uae_input_device *uid, int num, int port, int af, bool gp);
extern int input_get_default_joystick (struct uae_input_device *uid, int num, int port, int af, int mode, bool gp);
extern int input_get_default_joystick_analog (struct uae_input_device *uid, int num, int port, int af, bool gp);
extern int input_get_default_keyboard (int num);
extern void inputdevice_release_all_keys (void);
#define DEFEVENT(A, B, C, D, E, F) INPUTEVENT_ ## A,
enum inputevents {
INPUTEVENT_ZERO,
@ -179,7 +177,6 @@ extern uae_u8 handle_joystick_buttons (uae_u8, uae_u8);
#define MAGICMOUSE_HOST_ONLY 2
extern int magicmouse_alive (void);
extern int is_tablet (void);
extern int inputdevice_is_tablet (void);
extern int input_mousehack_status (int mode, uaecptr diminfo, uaecptr dispinfo, uaecptr vp, uae_u32 moffset);
extern void input_mousehack_mouseoffset (uaecptr pointerprefs);
@ -263,13 +260,14 @@ extern void inputdevice_tablet_strobe (void);
extern uae_u64 input_getqualifiers (void);
#define JSEM_MODE_DEFAULT 0
#define JSEM_MODE_MOUSE 1
#define JSEM_MODE_JOYSTICK 2
#define JSEM_MODE_GAMEPAD 3
#define JSEM_MODE_JOYSTICK_ANALOG 4
#define JSEM_MODE_MOUSE_CDTV 5
#define JSEM_MODE_JOYSTICK_CD32 6
#define JSEM_MODE_LIGHTPEN 7
#define JSEM_MODE_WHEELMOUSE 1
#define JSEM_MODE_MOUSE 2
#define JSEM_MODE_JOYSTICK 3
#define JSEM_MODE_GAMEPAD 4
#define JSEM_MODE_JOYSTICK_ANALOG 5
#define JSEM_MODE_MOUSE_CDTV 6
#define JSEM_MODE_JOYSTICK_CD32 7
#define JSEM_MODE_LIGHTPEN 8
#define JSEM_KBDLAYOUT 0
#define JSEM_JOYS 100

View File

@ -118,6 +118,12 @@ struct cache040
uae_u32 tag[CACHELINES040];
};
struct mmufixup
{
int reg;
uae_u32 value;
};
extern struct mmufixup mmufixup[2];
struct regstruct
{
@ -139,6 +145,7 @@ struct regstruct
flagtype m;
flagtype x;
flagtype stopped;
int halted;
int exception;
int intmask;
int ipl, ipl_pin;
@ -148,9 +155,9 @@ struct regstruct
#ifdef FPUEMU
fptype fp[8];
fptype fp_result;
uae_u32 fpcr, fpsr, fpiar;
uae_u32 fpsr_highbyte;
uae_u32 fpu_state;
#endif
#ifndef CPUEMU_68000_ONLY
uae_u32 cacr, caar;
@ -161,7 +168,7 @@ struct regstruct
uae_u32 wb3_data;
uae_u16 wb3_status;
int mmu_enabled;
int mmu_pagesize_8k;
int mmu_page_size;
#endif
uae_u32 pcr;
@ -255,7 +262,7 @@ STATIC_INLINE void m68k_incpc (int o)
regs.pc_p += o;
}
#ifdef MMU
#ifdef MMUEMU
STATIC_INLINE void m68k_setpc_mmu (uaecptr newpc)
{
regs.instruction_pc = regs.pc = newpc;
@ -351,25 +358,38 @@ extern uae_u32 (*x_next_ilong)(void);
extern uae_u32 (*x_get_ilong)(int);
extern uae_u32 (*x_get_iword)(int);
extern uae_u32 (*x_get_ibyte)(int);
extern uae_u32 (*x_cp_get_byte)(uaecptr addr);
extern uae_u32 (*x_cp_get_word)(uaecptr addr);
extern uae_u32 (*x_cp_get_long)(uaecptr addr);
extern void (*x_cp_put_byte)(uaecptr addr, uae_u32 v);
extern void (*x_cp_put_word)(uaecptr addr, uae_u32 v);
extern void (*x_cp_put_long)(uaecptr addr, uae_u32 v);
extern uae_u32 (*x_cp_next_iword)(void);
extern uae_u32 (*x_cp_next_ilong)(void);
extern uae_u32 (REGPARAM3 *x_cp_get_disp_ea_020)(uae_u32 base, int idx) REGPARAM;
extern void (*x_do_cycles)(unsigned long);
extern void (*x_do_cycles_pre)(unsigned long);
extern void (*x_do_cycles_post)(unsigned long, uae_u32);
extern uae_u32 REGPARAM3 x_get_disp_ea_020 (uae_u32 base, uae_u32 dp) REGPARAM;
extern uae_u32 REGPARAM3 x_get_disp_ea_ce020 (uae_u32 base, uae_u32 dp) REGPARAM;
extern uae_u32 REGPARAM3 x_get_disp_ea_020 (uae_u32 base, int idx) REGPARAM;
extern uae_u32 REGPARAM3 x_get_disp_ea_ce020 (uae_u32 base, int idx) REGPARAM;
extern uae_u32 REGPARAM3 x_get_bitfield (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int width) REGPARAM;
extern void REGPARAM3 x_put_bitfield (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s32 offset, int width) REGPARAM;
extern void m68k_setstopped (void);
extern void m68k_resumestopped (void);
extern uae_u32 REGPARAM3 get_disp_ea_020 (uae_u32 base, uae_u32 dp) REGPARAM;
extern uae_u32 REGPARAM3 get_disp_ea_020 (uae_u32 base, int idx) REGPARAM;
extern uae_u32 REGPARAM3 get_bitfield (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int width) REGPARAM;
extern void REGPARAM3 put_bitfield (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s32 offset, int width) REGPARAM;
extern void m68k_disasm_ea (void *f, uaecptr addr, uaecptr *nextpc, int cnt, uae_u32 *seaddr, uae_u32 *deaddr);
extern void m68k_disasm (void *f, uaecptr addr, uaecptr *nextpc, int cnt);
extern void m68k_disasm_ea (uaecptr addr, uaecptr *nextpc, int cnt, uae_u32 *seaddr, uae_u32 *deaddr);
extern void m68k_disasm (uaecptr addr, uaecptr *nextpc, int cnt);
extern void m68k_disasm_2 (TCHAR *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int cnt, uae_u32 *seaddr, uae_u32 *deaddr, int safemode);
extern void sm68k_disasm (TCHAR*, TCHAR*, uaecptr addr, uaecptr *nextpc);
extern int get_cpu_model (void);
/* Hack to stop conflict with AROS Exception function */
@ -391,9 +411,7 @@ extern void m68k_mull (uae_u32, uae_u32, uae_u16);
extern void init_m68k (void);
extern void init_m68k_full (void);
extern void m68k_go (int);
extern void m68k_dumpstate (void *, uaecptr *);
extern void m68k_disasm (void *, uaecptr, uaecptr *, int);
extern void sm68k_disasm (TCHAR*, TCHAR*, uaecptr addr, uaecptr *nextpc);
extern void m68k_dumpstate (uaecptr *);
extern void m68k_reset (int);
extern int getDivu68kCycles (uae_u32 dividend, uae_u16 divisor);
extern int getDivs68kCycles (uae_s32 dividend, uae_s16 divisor);
@ -420,6 +438,7 @@ extern void exception3i (uae_u32 opcode, uaecptr addr);
extern void exception3pc (uae_u32 opcode, uaecptr addr, int w, int i, uaecptr pc);
extern void exception2 (uaecptr addr);
extern void cpureset (void);
extern void cpu_halt (int id);
extern void fill_prefetch (void);
@ -428,6 +447,7 @@ extern void fill_prefetch (void);
/* 68060 */
extern const struct cputbl op_smalltbl_0_ff[];
extern const struct cputbl op_smalltbl_22_ff[]; // CE
extern const struct cputbl op_smalltbl_33_ff[]; // MMU
/* 68040 */
extern const struct cputbl op_smalltbl_1_ff[];
extern const struct cputbl op_smalltbl_23_ff[]; // CE
@ -435,6 +455,7 @@ extern const struct cputbl op_smalltbl_31_ff[]; // MMU
/* 68030 */
extern const struct cputbl op_smalltbl_2_ff[];
extern const struct cputbl op_smalltbl_24_ff[]; // CE
extern const struct cputbl op_smalltbl_32_ff[]; // MMU
/* 68020 */
extern const struct cputbl op_smalltbl_3_ff[];
extern const struct cputbl op_smalltbl_20_ff[]; // prefetch
@ -469,4 +490,4 @@ extern struct cpum2c m2cregs[];
extern bool is_cpu_tracer (void);
extern bool set_cpu_tracer (bool force);
extern bool can_cpu_tracer (void);
extern bool can_cpu_tracer (void);

View File

@ -12,8 +12,8 @@
*/
#define UAEMAJOR 2
#define UAEMINOR 5
#define UAESUBREV 1
#define UAEMINOR 6
#define UAESUBREV 0
#include "uae_types.h"
@ -119,9 +119,11 @@ struct floppyslot
TCHAR dfxclickexternal[256];
};
#define WH_NATIVE 1
struct wh {
int x, y;
int width, height;
int special;
};
#define MOUNT_CONFIG_SIZE 30
@ -132,21 +134,40 @@ struct uaedev_config_info {
TCHAR devname[MAX_DPATH];
TCHAR volname[MAX_DPATH];
TCHAR rootdir[MAX_DPATH];
bool ishdf;
bool readonly;
int bootpri;
bool autoboot;
bool donotmount;
TCHAR filesys[MAX_DPATH];
int cyls; // zero if detected from size
int lowcyl;
int highcyl; // zero if detected from size
int cyls; // calculated/corrected highcyl
int surfaces;
int sectors;
int reserved;
int blocksize;
int configoffset;
int controller;
// zero if default
int pcyls, pheads, psecs;
int flags;
int buffers;
int bufmemtype;
int stacksize;
int priority;
uae_u32 mask;
int maxtransfer;
uae_u32 dostype;
int unit;
int interleave;
int sectorsperblock;
};
struct uaedev_config_data
{
struct uaedev_config_info ci;
int configoffset;
bool ishdf;
};
enum { CP_GENERIC = 1, CP_CDTV, CP_CD32, CP_A500, CP_A500P, CP_A600, CP_A1000,
@ -202,7 +223,7 @@ struct apmode
{
int gfx_fullscreen;
int gfx_display;
bool gfx_vsync;
int gfx_vsync;
// 0 = immediate flip
// -1 = wait for flip, before frame ends
// 1 = wait for flip, after new frame has started
@ -321,9 +342,9 @@ struct uae_prefs {
int gfx_filter_scanlines;
int gfx_filter_scanlineratio;
int gfx_filter_scanlinelevel;
int gfx_filter_horiz_zoom, gfx_filter_vert_zoom;
int gfx_filter_horiz_zoom_mult, gfx_filter_vert_zoom_mult;
int gfx_filter_horiz_offset, gfx_filter_vert_offset;
float gfx_filter_horiz_zoom, gfx_filter_vert_zoom;
float gfx_filter_horiz_zoom_mult, gfx_filter_vert_zoom_mult;
float gfx_filter_horiz_offset, gfx_filter_vert_offset;
int gfx_filter_filtermode;
int gfx_filter_bilinear;
int gfx_filter_noise, gfx_filter_blur;
@ -332,8 +353,8 @@ struct uae_prefs {
int gfx_filter_autoscale;
int gfx_filter_keep_autoscale_aspect;
int rtg_horiz_zoom_mult;
int rtg_vert_zoom_mult;
float rtg_horiz_zoom_mult;
float rtg_vert_zoom_mult;
bool immediate_blits;
int waiting_blits;
@ -367,7 +388,7 @@ struct uae_prefs {
int floppy_auto_ext2;
bool tod_hack;
uae_u32 maprom;
bool turbo_emulation;
int turbo_emulation;
bool headless;
int filesys_limit;
@ -384,7 +405,7 @@ struct uae_prefs {
bool cs_cd32nvram;
bool cs_cdtvcd;
bool cs_cdtvram;
bool cs_cdtvcard;
int cs_cdtvcard;
int cs_ide;
bool cs_pcmcia;
bool cs_a1000ram;
@ -425,9 +446,7 @@ struct uae_prefs {
TCHAR statefile[MAX_DPATH];
TCHAR inprecfile[MAX_DPATH];
bool inprec_autoplay;
#ifndef WIN32
char scsi_device[256];
#endif
struct multipath path_floppy;
struct multipath path_hardfile;
@ -472,7 +491,7 @@ struct uae_prefs {
bool native_code;
int mountitems;
struct uaedev_config_info mountconfig[MOUNT_CONFIG_SIZE];
struct uaedev_config_data mountconfig[MOUNT_CONFIG_SIZE];
int nr_floppies;
struct floppyslot floppyslots[4];
@ -520,9 +539,10 @@ struct uae_prefs {
bool win32_iconified_nosound;
bool win32_rtgmatchdepth;
bool win32_rtgscaleifsmall;
int win32_rtgscalemode;
bool win32_rtgallowscaling;
int win32_rtgscaleaspectratio;
int win32_rtgvblankrate;
bool win32_borderless;
bool win32_ctrl_F11_is_quit;
bool win32_automount_removable;
@ -601,8 +621,6 @@ struct uae_prefs {
extern int config_changed;
extern void config_check_vsync (void);
extern uae_u32 uaerand (void);
/* Contains the filename of .uaerc */
extern TCHAR optionsfile[];
extern void save_options (struct zfile *, struct uae_prefs *, int);
@ -623,11 +641,9 @@ extern void cfgfile_target_write_str (struct zfile *f, const TCHAR *option, cons
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,
const TCHAR *devname, const TCHAR *volname, const TCHAR *rootdir, bool readonly,
int cyls, int secspertrack, int surfaces, int reserved,
int blocksize, int bootpri, const TCHAR *filesysdir, int hdc, int flags,
int pcyls, int pheads, int psecs);
extern struct uaedev_config_data *add_filesys_config (struct uae_prefs *p, int index, struct uaedev_config_info*, bool hdf);
extern bool get_hd_geometry (struct uaedev_config_info *);
extern void uci_set_defaults (struct uaedev_config_info *uci, bool rdb);
extern void default_prefs (struct uae_prefs *, int);
extern void discard_prefs (struct uae_prefs *, int);

View File

@ -1,9 +1,6 @@
#ifdef WIN32
#include "picasso96_win.h"
#else
#pragma once
#ifndef SRC_INCLUDE_PICASSO96_H_INCLUDED
#define SRC_INCLUDE_PICASSO96_H_INCLUDED 1
/*
* UAE - The U*nix Amiga Emulator
*
@ -723,10 +720,6 @@ extern int uaegfx_card_found;
extern struct picasso96_state_struct picasso96_state;
extern uae_u16 picasso96_pixel_format;
#ifdef _WIN32
extern unsigned int timer_id;
#endif
#include "traps.h"
extern void picasso_enablescreen (int on);
@ -797,4 +790,4 @@ extern int p96hsync_counter;
#endif
#endif
#endif // SRC_INCLUDE_PICASSO96_H_INCLUDED

View File

@ -15,6 +15,4 @@ void netdev_install (void);
void netdev_reset (void);
void netdev_start_threads (void);
extern int log_net;
#endif // SRC_INCLUDE_SANA2_H_INCLUDED

View File

@ -21,16 +21,4 @@ int scsi_do_disk_device_change (void);
uae_u32 scsi_get_cd_drive_mask (void);
uae_u32 scsi_get_cd_drive_media_mask (void);
extern int log_scsi;
#ifdef _WIN32
#define UAESCSI_CDEMU 0
#define UAESCSI_SPTI 1
#define UAESCSI_SPTISCAN 2
#define UAESCSI_ASPI_FIRST 3
#define UAESCSI_ADAPTECASPI 3
#define UAESCSI_NEROASPI 4
#define UAESCSI_FROGASPI 5
#endif
#endif // SRC_INCLUDE_SCSIDEV_H_INCLUDED

View File

@ -19,16 +19,12 @@ extern void SERDAT (uae_u16 w);
extern uae_u8 serial_writestatus (uae_u8, uae_u8);
extern uae_u8 serial_readstatus (uae_u8);
extern void serial_uartbreak (int);
extern uae_u16 serdat;
extern int doreadser, serstat;
extern void serial_flush_buffer (void);
extern void serial_hsynchandler (void);
extern void serial_check_irq (void);
extern void uaeser_initdata (void *vsd, void *user);
extern int uaeser_getdatalength (void);
extern int uaeser_getbytespending (void*);

View File

@ -42,18 +42,13 @@
*/
#ifdef __BEOS__
# define uae_msleep(msecs) snooze (msecs * ONE_THOUSAND)
#else
# if 0 //defined _WIN32
# define uae_msleep(msecs) Sleep (msecs)
# else
# if defined TARGET_AMIGAOS
#elif defined TARGET_AMIGAOS
# if defined __amigaos4__ || defined __MORPHOS__
# define uae_msleep(msecs) TimeDelay (0, msecs / ONE_THOUSAND, (msecs % ONE_THOUSAND) * ONE_THOUSAND)
# else
# define uae_msleep(msecs) Delay (msecs <= 20 ? 1 : msecs/20);
# endif
# else
# ifdef HAVE_NANOSLEEP
# endif // __amigaos4__ || __MORPHOS__
#elif defined HAVE_NANOSLEEP
# define uae_msleep(msecs) \
{ \
if (msecs < 1000) { \
@ -66,19 +61,12 @@
nanosleep (&t, 0); \
} \
}
# else
# ifdef HAVE_USLEEP
#elif defined HAVE_USLEEP
# define uae_msleep(msecs) usleep (msecs * ONE_THOUSAND)
# else
# ifdef USE_SDL
#elif defined USE_SDL
# define uae_msleep(msecs) SDL_Delay (msecs)
# else
# error "No system sleep function found"
# endif
# endif
# endif
# endif
# endif
#endif
#endif // Get uae_msleep working
void sleep_test (void);

View File

@ -212,61 +212,6 @@ struct utimbuf
extern "C" {
# endif
#if defined _WIN32
#if defined __WATCOMC__
#define O_NDELAY 0
#include <direct.h>
#define dirent direct
#define mkdir(a,b) mkdir(a)
#define strcasecmp stricmp
#elif defined __MINGW32__
#define O_NDELAY 0
#define mkdir(a,b) mkdir(a)
#elif defined _MSC_VER
#ifdef HAVE_GETTIMEOFDAY
#include <winsock.h> // for 'struct timeval' definition
extern void gettimeofday( struct timeval *tv, void *blah );
#endif
#define O_NDELAY 0
#ifdef REGPARAM2
#undef REGPARAM2
#endif
#define REGPARAM2 __fastcall
#define REGPARAM3 __fastcall
#define REGPARAM
#include <io.h>
#define O_BINARY _O_BINARY
#define O_WRONLY _O_WRONLY
#define O_RDONLY _O_RDONLY
#define O_RDWR _O_RDWR
#define O_CREAT _O_CREAT
#define O_TRUNC _O_TRUNC
#define strcasecmp _tcsicmp
#define strncasecmp _tcsncicmp
#define W_OK 0x2
#define R_OK 0x4
#define STAT struct stat
#define DIR struct DIR
struct direct
{
char d_name[1];
};
#include <sys/utime.h>
#define utimbuf __utimbuf64
#define USE_ZFILE
#undef S_ISDIR
#undef S_IWUSR
#undef S_IRUSR
#undef S_IXUSR
#define S_ISDIR(a) (a&FILEFLAG_DIR)
#define S_ISARC(a) (a&FILEFLAG_ARCHIVE)
#define S_IWUSR FILEFLAG_WRITE
#define S_IRUSR FILEFLAG_READ
#define S_IXUSR FILEFLAG_EXECUTE
#endif
#endif /* _WIN32 */
#ifdef DONT_HAVE_POSIX
#define access posixemu_access
extern int posixemu_access (const char *, int);

View File

@ -17,12 +17,4 @@ void uaeserialdev_start_threads (void);
extern int log_uaeserial;
#ifdef _WIN32
struct uaeserialdata
{
void *handle;
void *writeevent;
};
#endif
#endif // SRC_INCLUDE_UAESERIAL_H_INCLUDED

View File

@ -16,13 +16,6 @@ extern xcolnr xcolors_16[4096];
extern xcolnr xcolors_32[4096];
extern uae_u32 p96_rgbx16[65536];
extern bool vsync_switchmode (int);
extern frame_time_t vsync_busywait_end (int*);
extern int vsync_busywait_do (int*, bool, bool);
extern void vsync_busywait_start (void);
extern double vblank_calibrate (double, bool);
extern bool vsync_isdone (void);
extern void doflashscreen (void);
extern int flashscreen;
extern void updatedisplayarea (void);
extern int isvsync_chipset (void);

View File

@ -117,7 +117,7 @@ extern const TCHAR *uae_ignoreextensions[];
extern const TCHAR *uae_diskimageextensions[];
extern struct zvolume *zfile_fopen_archive (const TCHAR *filename);
extern struct zvolume *zfile_fopen_archive2 (const TCHAR *filename, int flags);
extern struct zvolume *zfile_fopen_archive_flags (const TCHAR *filename, int flags);
extern struct zvolume *zfile_fopen_archive_root (const TCHAR *filename, int flags);
extern void zfile_fclose_archive (struct zvolume *zv);
extern int zfile_fs_usage_archive (const TCHAR *path, const TCHAR *disk, struct fs_usage *fsp);

View File

@ -67,7 +67,6 @@ extern void sound_volume (int dir);
// 32 = vsync
int inputdevice_logging = 0;
extern int tablet_log;
#define ID_FLAG_CANRELEASE 0x1000
#define ID_FLAG_TOGGLED 0x2000
@ -1174,12 +1173,7 @@ int inputdevice_is_tablet (void)
return 0;
if (currprefs.input_tablet == TABLET_MOUSEHACK)
return -1;
v = is_tablet ();
if (!v)
return 0;
if (kickstart_version < 37)
return v ? -1 : 0;
return v ? 1 : 0;
return 0;
}
static uaecptr mousehack_address;
@ -1378,19 +1372,6 @@ void inputdevice_tablet (int x, int y, int z, int pressure, uae_u32 buttonbits,
if (!memcmp (tmp, p + MH_START, MH_END - MH_START))
return;
if (tablet_log & 1) {
static uae_u32 obuttonbits = 0;
static int oinproximity = 0;
if (inproximity != oinproximity || buttonbits != obuttonbits) {
obuttonbits = buttonbits;
oinproximity = inproximity;
write_log (_T("TABLET: B=%08x P=%d\n"), buttonbits, inproximity);
}
}
if (tablet_log & 2) {
write_log (_T("TABLET: X=%d Y=%d Z=%d AX=%d AY=%d AZ=%d\n"), x, y, z, ax, ay, az);
}
p[MH_E] = 0xc0 | 2;
p[MH_CNT]++;
}
@ -1426,8 +1407,6 @@ void inputdevice_tablet_info (int maxx, int maxy, int maxz, int maxax, int maxay
}
void getgfxoffset (int *dx, int *dy, int*,int*);
static void inputdevice_mh_abs (int x, int y, uae_u32 buttonbits)
{
uae_u8 *p;
@ -1587,7 +1566,7 @@ static void mousehack_helper (uae_u32 buttonmask)
{
#ifdef FILESYS /* Internal mousehack depends on filesys boot-rom */
int x, y;
int fdy, fdx, fmx, fmy;
float fdy, fdx, fmx, fmy;
if (currprefs.input_magic_mouse == 0 && currprefs.input_tablet < TABLET_MOUSEHACK)
return;
@ -1601,22 +1580,21 @@ static void mousehack_helper (uae_u32 buttonmask)
y = lastmy;
getgfxoffset (&fdx, &fdy, &fmx, &fmy);
#ifdef PICASSO96
if (picasso_on) {
x -= picasso96_state.XOffset;
y -= picasso96_state.YOffset;
x = x * fmx / 1000;
y = y * fmy / 1000;
x -= fdx * fmx / 1000;
y -= fdy * fmy / 1000;
x = (int)(x * fmx);
y = (int)(y * fmy);
x -= (int)(fdx * fmx);
y -= (int)(fdy * fmy);
} else
#endif
{
x = x * fmx / 1000;
y = y * fmy / 1000;
x -= fdx * fmx / 1000 - 1;
y -= fdy * fmy / 1000 - 2;
x = (int)(x * fmx);
y = (int)(y * fmy);
x -= (int)(fdx * fmx) - 1;
y -= (int)(fdy * fmy) - 2;
if (x < 0)
x = 0;
if (x >= gfxvidinfo.outwidth)
@ -2314,11 +2292,12 @@ static int handle_custom_event (const TCHAR *custom)
while (*nextp == ' ')
nextp++;
}
//write_log (_T("-> '%s'\n"), p);
if (!_tcsicmp (p, _T("no_config_check"))) {
config_changed = 0;
} else if (!_tcsicmp (p, _T("do_config_check"))) {
config_changed = 1;
} else if (!_tcsnicmp (p, _T("dbg "), 4)) {
debug_parser (p + 4, NULL, -1);
} else {
cfgfile_parse_line (&changed_prefs, p, 0);
}
@ -3275,7 +3254,7 @@ void inputdevice_reset (void)
{
magicmouse_ibase = 0;
magicmouse_gfxbase = 0;
// mousehack_reset ();
mousehack_reset ();
if (inputdevice_is_tablet ())
mousehack_enable ();
bouncy = 0;
@ -4405,7 +4384,7 @@ void inputdevice_compa_prepare_custom (struct uae_prefs *prefs, int index, int n
if (newmode >= 0) {
mode = newmode;
} else if (mode == 0) {
mode = index == 0 ? JSEM_MODE_MOUSE : (prefs->cs_cd32cd ? JSEM_MODE_JOYSTICK_CD32 : JSEM_MODE_JOYSTICK);
mode = index == 0 ? JSEM_MODE_WHEELMOUSE : (prefs->cs_cd32cd ? JSEM_MODE_JOYSTICK_CD32 : JSEM_MODE_JOYSTICK);
}
prefs->jports[index].mode = mode;
prefs->jports[index].id = -2;
@ -4491,6 +4470,7 @@ static void setjoyinputs (struct uae_prefs *prefs, int port)
case JSEM_MODE_JOYSTICK_ANALOG:
joyinputs[port] = port ? ip_analog2 : ip_analog1;
break;
case JSEM_MODE_WHEELMOUSE:
case JSEM_MODE_MOUSE:
joyinputs[port] = port ? ip_mouse2 : ip_mouse1;
break;
@ -4564,8 +4544,9 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
{
case JSEM_MODE_DEFAULT:
case JSEM_MODE_MOUSE:
case JSEM_MODE_WHEELMOUSE:
default:
joymodes[i] = JSEM_MODE_MOUSE;
joymodes[i] = JSEM_MODE_WHEELMOUSE;
joyinputs[i] = i ? ip_mouse2 : ip_mouse1;
break;
case JSEM_MODE_LIGHTPEN:
@ -4604,7 +4585,8 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
joyinputs[i] = i ? ip_analog2 : ip_analog1;
break;
case JSEM_MODE_MOUSE:
joymodes[i] = JSEM_MODE_MOUSE;
case JSEM_MODE_WHEELMOUSE:
joymodes[i] = JSEM_MODE_WHEELMOUSE;
joyinputs[i] = i ? ip_mouse2 : ip_mouse1;
break;
case JSEM_MODE_LIGHTPEN:
@ -4617,7 +4599,7 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
break;
}
} else if (prefs->jports[i].id >= 0) {
joymodes[i] = i ? JSEM_MODE_JOYSTICK : JSEM_MODE_MOUSE;
joymodes[i] = i ? JSEM_MODE_JOYSTICK : JSEM_MODE_WHEELMOUSE;
joyinputs[i] = i ? ip_joy2 : ip_mouse1;
}
}
@ -4647,9 +4629,10 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
{
case JSEM_MODE_DEFAULT:
case JSEM_MODE_MOUSE:
case JSEM_MODE_WHEELMOUSE:
default:
input_get_default_mouse (mice, joy, i, af, !gameports);
joymodes[i] = JSEM_MODE_MOUSE;
input_get_default_mouse (mice, joy, i, af, !gameports, mode != JSEM_MODE_MOUSE);
joymodes[i] = JSEM_MODE_WHEELMOUSE;
break;
case JSEM_MODE_LIGHTPEN:
input_get_default_lightpen (mice, joy, i, af, !gameports);
@ -4693,8 +4676,9 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
joymodes[i] = JSEM_MODE_JOYSTICK_ANALOG;
break;
case JSEM_MODE_MOUSE:
input_get_default_mouse (joysticks, joy, i, af, !gameports);
joymodes[i] = JSEM_MODE_MOUSE;
case JSEM_MODE_WHEELMOUSE:
input_get_default_mouse (joysticks, joy, i, af, !gameports, mode == JSEM_MODE_WHEELMOUSE);
joymodes[i] = JSEM_MODE_WHEELMOUSE;
break;
case JSEM_MODE_LIGHTPEN:
input_get_default_lightpen (joysticks, joy, i, af, !gameports);
@ -4784,8 +4768,9 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
}
break;
case JSEM_MODE_MOUSE:
case JSEM_MODE_WHEELMOUSE:
setcompakb (kb, i ? ip_mouse2 : ip_mouse1, i, af);
joymodes[i] = JSEM_MODE_MOUSE;
joymodes[i] = JSEM_MODE_WHEELMOUSE;
break;
}
used[joy] = 1;
@ -4906,7 +4891,7 @@ static void matchdevices (struct inputdevice_functions *inf, struct uae_input_de
} else if (p1 && p2 && p1 - bname == p2 - bname2) {
*p1 = 0;
*p2 = 0;
if (!_tcscmp (bname2, bname))
if (bname && !_tcscmp (bname2, bname))
matched = true;
}
if (matched) {
@ -5057,16 +5042,16 @@ static void resetinput (void)
}
void inputdevice_updateconfig_internal (const struct uae_prefs *srcprefs, struct uae_prefs *dstprefs)
void inputdevice_updateconfig_internal (const struct uae_prefs *srcprrefs, struct uae_prefs *dstprefs)
{
int i;
keyboard_default = keyboard_default_table[currprefs.input_keyboard_type];
copyjport (srcprefs, dstprefs, 0);
copyjport (srcprefs, dstprefs, 1);
copyjport (srcprefs, dstprefs, 2);
copyjport (srcprefs, dstprefs, 3);
copyjport (srcprrefs, dstprefs, 0);
copyjport (srcprrefs, dstprefs, 1);
copyjport (srcprrefs, dstprefs, 2);
copyjport (srcprrefs, dstprefs, 3);
resetinput ();
@ -6434,9 +6419,9 @@ void setmousestate (int mouse, int axis, int data, int isabs)
{
int i, v, diff;
int *mouse_p, *oldm_p;
double d;
float d;
struct uae_input_device *id = &mice[mouse];
static double fract[MAX_INPUT_DEVICES][MAX_INPUT_DEVICE_EVENTS];
static float fract[MAX_INPUT_DEVICES][MAX_INPUT_DEVICE_EVENTS];
if (testmode) {
inputdevice_testrecord (IDTYPE_MOUSE, mouse, IDEV_WIDGET_AXIS, axis, data, -1);
@ -6466,7 +6451,7 @@ void setmousestate (int mouse, int axis, int data, int isabs)
return;*/
*oldm_p = *mouse_p;
*mouse_p += data;
d = (*mouse_p - *oldm_p) * currprefs.input_mouse_speed / 100.0;
d = (*mouse_p - *oldm_p) * currprefs.input_mouse_speed / 100.0f;
} else {
d = data - *oldm_p;
*oldm_p = data;

View File

@ -816,15 +816,7 @@ static void savelog (const TCHAR *path, const TCHAR *file)
int loglen;
uae_u8 *log;
loglen = 0;
log = save_log (true, &loglen);
if (log)
zfile_fwrite (log, loglen, 1, zfd);
xfree (log);
loglen = 0;
log = save_log (false, &loglen);
if (log)
zfile_fwrite (log, loglen, 1, zfd);
xfree (log);
zfile_fclose (zfd);
write_log (_T("log '%s' saved\n"), tmp);
}

View File

@ -366,25 +366,11 @@ void my_kbd_handler (int keyboard, int scancode, int newstate)
bool special = false;
static int swapperdrive = 0;
#ifdef WIN32
if (amode && scancode == DIK_F11 && currprefs.win32_ctrl_F11_is_quit && ctrlpressed ())
code = AKS_QUIT;
#endif
scancode_new = scancode;
if (!specialpressed () && inputdevice_iskeymapped (keyboard, scancode))
scancode = 0;
scancode_new = scancode;
if (!specialpressed () && inputdevice_iskeymapped (keyboard, scancode))
scancode = 0;
defaultguikey = amode ? DIK_F12 : DIK_NUMLOCK;
#ifdef WIN32
// GUI must be always available
if (scancode_new == defaultguikey && currprefs.win32_guikey < 0)
scancode = scancode_new;
if (scancode_new == currprefs.win32_guikey && scancode_new != defaultguikey)
scancode = scancode_new;
#endif
// write_log ("KBDHANDLER_1: kbd = %d, scancode= %d (0x%02x), state= %d, sc_new= %d\n", keyboard, scancode, scancode, newstate, scancode_new);
defaultguikey = amode ? DIK_F12 : DIK_NUMLOCK;
if (newstate && code == 0 && amode) {

View File

@ -328,8 +328,5 @@ struct uaekey_hostmap
/* Alternate names for keys originally not used on US keyboards. */
#define DIK_CIRCUMFLEX DIK_PREVTRACK /* Japanese keyboard */
/* fixme
struct uae_input_device_kbr_default *uaekey_make_default_kbr (const struct uaekey_hostmap *hostkeys);
- Sven */
extern void my_kbd_handler (int keyboard, int scancode, int newstate);

View File

@ -530,9 +530,6 @@ void fixup_prefs (struct uae_prefs *p)
#endif
#if !defined (SCSIEMU)
p->scsi = 0;
#ifdef _WIN32
p->win32_aspi = 0;
#endif
#endif
#if !defined (SANA2)
p->sana2 = 0;
@ -709,10 +706,15 @@ static void parse_cmdline (int argc, TCHAR **argv)
target_cfgfile_load (&currprefs, txt, -1, 0);
xfree (txt);
} else if (_tcsncmp (argv[i], _T("-statefile="), 11) == 0) {
#ifdef SAVESTATE
TCHAR *txt = parsetextpath (argv[i] + 11);
savestate_state = STATE_DORESTORE;
_tcscpy (savestate_fname, txt);
xfree (txt);
#else
write_log (_T("Option -statefile ignored:\n"));
write_log (_T("-> puae has been configured with --disable-save-state\n"));
#endif // SAVESTATE
} else if (_tcscmp (argv[i], _T("-f")) == 0) {
/* Check for new-style "-f xxx" argument, where xxx is config-file */
if (i + 1 == argc) {
@ -964,23 +966,8 @@ void virtualdevice_init (void)
#endif
}
#if (defined (_WIN32) || defined (_WIN64)) && !defined (NO_WIN32_EXCEPTION_HANDLER)
#ifndef JIT
extern int DummyException (LPEXCEPTION_POINTERS blah, int n_except)
{
return EXCEPTION_CONTINUE_SEARCH;
}
#endif
#endif
static int real_main2 (int argc, TCHAR **argv)
{
#if (defined (_WIN32) || defined (_WIN64)) && !defined (NO_WIN32_EXCEPTION_HANDLER)
extern int EvalException (LPEXCEPTION_POINTERS blah, int n_except);
__try
#endif
{
#ifdef USE_SDL
int result = (SDL_Init (SDL_INIT_TIMER | SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE) == 0);
if (result)
@ -1023,15 +1010,18 @@ static int real_main2 (int argc, TCHAR **argv)
changed_prefs = currprefs;
no_gui = ! currprefs.start_gui;
if (restart_program == 2)
no_gui = 1;
else if (restart_program == 3)
no_gui = 0;
restart_program = 0;
if (! no_gui) {
int err = gui_init ();
currprefs = changed_prefs;
config_changed = 1;
if (err == -1) {
write_log (_T("Failed to initialize the GUI\n"));
return -1;
@ -1060,9 +1050,11 @@ static int real_main2 (int argc, TCHAR **argv)
#endif
fixup_prefs (&currprefs);
#ifdef RETROPLATFORM
rp_fixup_options (&currprefs);
#endif
changed_prefs = currprefs;
target_run ();
/* force sound settings change */
@ -1079,9 +1071,11 @@ static int real_main2 (int argc, TCHAR **argv)
#endif
custom_init (); /* Must come after memory_init */
#ifdef SERIAL_PORT
serial_init ();
#endif
DISK_init ();
reset_frame_rate_hack ();
@ -1090,6 +1084,7 @@ static int real_main2 (int argc, TCHAR **argv)
gui_update ();
if (graphics_init ()) {
#ifdef DEBUGGER
setup_brkhandler ();
if (currprefs.start_debugger && debuggable ())
@ -1105,17 +1100,6 @@ static int real_main2 (int argc, TCHAR **argv)
start_program ();
}
}
#if (defined (_WIN32) || defined (_WIN64)) && !defined (NO_WIN32_EXCEPTION_HANDLER)
#ifdef JIT
__except( EvalException( GetExceptionInformation(), GetExceptionCode() ) )
#else
__except (DummyException (GetExceptionInformation (), GetExceptionCode ()))
#endif
{
// EvalException does the good stuff...
}
#endif
return 0;
}

View File

@ -141,9 +141,6 @@ static bool canjit (void)
}
static bool needmman (void)
{
#ifdef _WIN32
return true;
#endif
if (canjit ())
return true;
return false;
@ -1035,7 +1032,7 @@ uae_u32 REGPARAM2 kickmem_lget (uaecptr addr)
return do_get_mem_long (m);
}
uae_u32 REGPARAM2 kickmem_wget (uaecptr addr)
static uae_u32 REGPARAM2 kickmem_wget (uaecptr addr)
{
uae_u16 *m;
addr &= kickmem_mask;
@ -1043,13 +1040,13 @@ uae_u32 REGPARAM2 kickmem_wget (uaecptr addr)
return do_get_mem_word (m);
}
uae_u32 REGPARAM2 kickmem_bget (uaecptr addr)
static uae_u32 REGPARAM2 kickmem_bget (uaecptr addr)
{
addr &= kickmem_mask;
return kickmemory[addr];
}
void REGPARAM2 kickmem_lput (uaecptr addr, uae_u32 b)
static void REGPARAM2 kickmem_lput (uaecptr addr, uae_u32 b)
{
uae_u32 *m;
#ifdef JIT
@ -1097,8 +1094,9 @@ void REGPARAM2 kickmem_bput (uaecptr addr, uae_u32 b)
return;
} else
a1000_handle_kickstart (0);
} else if (currprefs.illegal_mem)
} else if (currprefs.illegal_mem) {
write_log (_T("Illegal kickmem bput at %08x\n"), addr);
}
}
void REGPARAM2 kickmem2_lput (uaecptr addr, uae_u32 l)
@ -1316,7 +1314,7 @@ uae_u8 *REGPARAM2 default_xlate (uaecptr a)
write_log (_T("Your Amiga program just did something terribly stupid %08X PC=%08X\n"), a, M68K_GETPC);
/* if (debugging || DEBUG_STUPID)
activate_debugger ();*/
m68k_dumpstate (0, 0);
m68k_dumpstate (0);
for (i = 0; i < 10; i++) {
write_log (_T("%08X "), i >= 5 ? a3 : a2);
for (j = 0; j < 16; j += 2) {
@ -1328,11 +1326,11 @@ uae_u8 *REGPARAM2 default_xlate (uaecptr a)
memory_map_dump ();
}
be_cnt++;
if (be_cnt > 1000) {
uae_reset (0, 0);
if (regs.s || be_cnt > 1000) {
cpu_halt (3);
be_cnt = 0;
} else {
regs.panic = 1;
regs.panic = 4;
regs.panic_pc = m68k_getpc ();
regs.panic_addr = a;
set_special (SPCFLAG_BRK);
@ -1857,7 +1855,7 @@ static void patch_kick (void)
extern unsigned char arosrom[];
extern unsigned int arosrom_len;
extern int seriallog;
static bool load_kickstart_replacement (void)
{
struct zfile *f = NULL;
@ -1878,9 +1876,7 @@ static bool load_kickstart_replacement (void)
extendedkickmem_mask = extendedkickmem_size - 1;
read_kickstart (f, kickmemory, 0x80000, 1, 0);
zfile_fclose (f);
#ifdef SERIAL_PORT
seriallog = -1;
#endif
return true;
}
@ -2273,7 +2269,7 @@ static void allocate_memory (void)
memsize = allocated_chipmem = chipmem_full_size = currprefs.chipmem_size;
chipmem_full_mask = chipmem_mask = allocated_chipmem - 1;
if (!canbang && memsize < 0x100000)
if (!currprefs.cachesize && memsize < 0x100000)
memsize = 0x100000;
if (memsize > 0x100000 && memsize < 0x200000)
memsize = 0x200000;
@ -2288,7 +2284,7 @@ static void allocate_memory (void)
}
currprefs.chipset_mask = changed_prefs.chipset_mask;
chipmem_full_mask = allocated_chipmem - 1;
if ((currprefs.chipset_mask & CSMASK_ECS_AGNUS) && !canbang) {
if ((currprefs.chipset_mask & CSMASK_ECS_AGNUS) && !currprefs.cachesize) {
if (allocated_chipmem < 0x100000)
chipmem_full_mask = 0x100000 - 1;
if (allocated_chipmem > 0x100000 && allocated_chipmem < 0x200000)
@ -2678,8 +2674,8 @@ void memory_reset (void)
map_banks (&custom_bank, 0xC0, 0xE0 - 0xC0, 0); // Map custom chips at at 0xC00000 - 0xDFFFFF
map_banks (&cia_bank, 0xA0, 32, 0); // Map CIAs at 0xA00000 - 0xBFFFFF
if (!currprefs.cs_a1000ram)
/* D80000 - DDFFFF not mapped (A1000 = custom chips) */
if (!currprefs.cs_a1000ram && currprefs.cs_rtc != 3)
/* D80000 - DDFFFF not mapped (A1000 or A2000 = custom chips) */
map_banks (&dummy_bank, 0xD8, 6, 0);
/* map "nothing" to 0x200000 - 0x9FFFFF (0xBEFFFF if Gayle or Fat Gary) */
@ -2722,8 +2718,10 @@ void memory_reset (void)
map_banks (&gayle_bank, 0xDD, 1, 0);
}
#endif
if (currprefs.cs_rtc || currprefs.cs_cdtvram)
// Real-time clock at 0xDC0000 - 0xDCFFFF.
// Real-time clock at 0xDC0000 - 0xDCFFFF.
if (currprefs.cs_rtc == 3) // A2000 clock
map_banks (&clock_bank, 0xD8, 4, 0);
if (currprefs.cs_rtc == 1 || currprefs.cs_rtc == 2 || currprefs.cs_cdtvram)
map_banks (&clock_bank, 0xDC, 1, 0);
else if (currprefs.cs_ksmirror_a8 || currprefs.cs_ide > 0 || currprefs.cs_pcmcia)
map_banks (&clock_bank, 0xDC, 1, 0); /* none clock */
@ -2880,6 +2878,7 @@ void memory_init (void)
a3000lmemory = a3000hmemory = 0;
bogomemory = 0;
cardmemory = 0;
allocated_custmem1 = allocated_custmem2 = 0;
custmem1 = 0;
custmem2 = 0;

View File

@ -34,33 +34,40 @@
#include "sleep.h"
#include "zfile.h"
static int logging_started;
#define LOG_BOOT "puae_bootlog.txt"
#define LOG_NORMAL "puae_log.txt"
// this is handled by the graphics drivers and set up in picasso96.c
#if defined(PICASSO96)
extern int screen_is_picasso;
#else
static int screen_is_picasso = 0;
#endif
static int tablet;
static int axmax, aymax, azmax;
static int xmax, ymax, zmax;
static int xres, yres;
static int maxpres;
static TCHAR *tabletname;
static int tablet_x, tablet_y, tablet_z, tablet_pressure, tablet_buttons, tablet_proximity;
static int tablet_ax, tablet_ay, tablet_az, tablet_flags;
uae_u32 redc[3 * 256], grec[3 * 256], bluc[3 * 256];
unsigned int log_scsi = 1;
int log_net, uaelib_debug;
#define VBLANKTH_KILL 0
#define VBLANKTH_CALIBRATE 1
#define VBLANKTH_IDLE 2
#define VBLANKTH_ACTIVE_WAIT 3
#define VBLANKTH_ACTIVE 4
#define VBLANKTH_ACTIVE_START 5
#define VBLANKTH_ACTIVE_SKIPFRAME 6
#define VBLANKTH_ACTIVE_SKIPFRAME2 7
static volatile frame_time_t vblank_prev_time;
struct winuae_currentmode {
unsigned int flags;
int native_width, native_height, native_depth, pitch;
int current_width, current_height, current_depth;
int amiga_width, amiga_height;
int frequency;
int initdone;
int fullfill;
int vsync;
unsigned int flags;
int native_width, native_height, native_depth, pitch;
int current_width, current_height, current_depth;
int amiga_width, amiga_height;
int frequency;
int initdone;
int fullfill;
int vsync;
};
static struct winuae_currentmode currentmodestruct;
static struct winuae_currentmode *currentmode = &currentmodestruct;
typedef struct {
WORD dmSize;
WORD dmDriverExtra;
@ -72,80 +79,7 @@ typedef struct {
DWORD dmDisplayFrequency;
} DEVMODE;
static struct winuae_currentmode currentmodestruct;
static struct winuae_currentmode *currentmode = &currentmodestruct;
static int serial_period_hsyncs, serial_period_hsync_counter;
static int data_in_serdatr; /* new data received */
// win32
int log_vsync, debug_vsync_min_delay, debug_vsync_forced_delay;
// serial
unsigned int seriallog = 0;
// dinput
int rawkeyboard = -1;
static bool rawinput_enabled_mouse, rawinput_enabled_keyboard;
int no_rawinput;
int tablet_log = 0;
int is_tablet (void)
{
return tablet ? 1 : 0;
}
//win32gfx.cpp
int screen_is_picasso = 0;
struct uae_filter *usedfilter;
uae_u32 redc[3 * 256], grec[3 * 256], bluc[3 * 256];
volatile bool vblank_found_chipset = false;
static struct remembered_vsync *vsyncmemory;
static int wasfullwindow_a, wasfullwindow_p;
static int vblankbasewait1, vblankbasewait2, vblankbasewait3, vblankbasefull, vblankbaseadjust;
static bool vblankbaselace;
static int vblankbaselace_chipset;
static bool vblankthread_oddeven;
#define VBLANKTH_KILL 0
#define VBLANKTH_CALIBRATE 1
#define VBLANKTH_IDLE 2
#define VBLANKTH_ACTIVE_WAIT 3
#define VBLANKTH_ACTIVE 4
#define VBLANKTH_ACTIVE_START 5
#define VBLANKTH_ACTIVE_SKIPFRAME 6
#define VBLANKTH_ACTIVE_SKIPFRAME2 7
static volatile bool vblank_found;
static volatile int flipthread_mode;
volatile bool vblank_found_chipset;
volatile bool vblank_found_rtg;
static int flipevent, flipevent2, vblankwaitevent;
static volatile int flipevent_mode;
static double remembered_vblank;
static volatile int vblankthread_mode, vblankthread_counter;
static int vblankbasewait, vblankbasefull;
static volatile frame_time_t vblank_prev_time, thread_vblank_time;
static volatile int vblank_found_flipdelay;
static int frame_missed, frame_counted, frame_errors;
static int frame_usage, frame_usage_avg, frame_usage_total;
extern int log_vsync;
static bool dooddevenskip;
static volatile bool vblank_skipeveryother;
static int vblank_flip_delay;
static volatile bool vblank_first_time;
/* internal prototypes */
void getgfxoffset (int *dxp, int *dyp, int *mxp, int *myp);
bool vsync_isdone (void);
int vsync_switchmode (int hz);
void serial_check_irq (void);
void serial_uartbreak (int v);
void serial_hsynchandler (void);
void setmouseactivexy (int x, int y, int dir);
int get_guid_target (uae_u8 *out);
uae_u8 *save_log (int bootlog, int *len);
@ -158,21 +92,6 @@ void fetch_screenshotpath (TCHAR *out, int size);
struct MultiDisplay *getdisplay (struct uae_prefs *p);
void addmode (struct MultiDisplay *md, DEVMODE *dm, int rawmode);
void updatedisplayarea (void);
double vblank_calibrate (double approx_vblank, bool waitonly);
frame_time_t vsync_busywait_end (int *flipdelay);
void vsync_busywait_start (void);
bool vsync_busywait_do (int *freetime, bool lace, bool oddeven);
void serialuartbreak (int v);
void doflashscreen (void);
bool vsync_busywait_do (int *freetime, bool lace, bool oddeven);
void serialuartbreak (int v);
void doflashscreen (void);
bool vsync_busywait_do (int *freetime, bool lace, bool oddeven);
void serialuartbreak (int v);
void doflashscreen (void);
/* external prototypes */
extern void setmaintitle(void);
@ -188,11 +107,6 @@ void getgfxoffset (int *dxp, int *dyp, int *mxp, int *myp)
*myp = 0;
}
bool vsync_isdone (void)
{
return vblank_found_chipset || dooddevenskip;
}
int vsync_switchmode (int hz)
{
static struct PicassoResolution *oldmode;
@ -245,44 +159,9 @@ int vsync_switchmode (int hz)
return true;
}
}
///////////////////////////////////////////////////
// serial_win32
///////////////////////////////////////////////////
void serial_check_irq (void)
{
if (data_in_serdatr)
INTREQ_0 (0x8000 | 0x0800);
}
void serial_uartbreak (int v)
{
#ifdef SERIAL_PORT
serialuartbreak (v);
#endif
}
void serial_hsynchandler (void)
{
#ifdef AHI
extern void hsyncstuff(void);
hsyncstuff();
#endif
/*
if (serial_period_hsyncs == 0)
return;
serial_period_hsync_counter++;
if (serial_period_hsyncs == 1 || (serial_period_hsync_counter % (serial_period_hsyncs - 1)) == 0) {
checkreceive_serial (0);
checkreceive_enet (0);
}
if ((serial_period_hsync_counter % serial_period_hsyncs) == 0)
checksend (0);
*/
}
//win32.cpp
int extraframewait = 5;
int log_vsync;
void sleep_millis_main (int ms)
{
@ -293,36 +172,15 @@ void target_restart (void)
{
}
// driveclick_win32
int driveclick_loadresource (struct drvsample *sp, int drivetype) { return 0; }
void driveclick_fdrawcmd_close(int drive){}
static int driveclick_fdrawcmd_open_2(int drive){ return 0; }
int driveclick_fdrawcmd_open(int drive){ return 0; }
void driveclick_fdrawcmd_detect(void){}
void driveclick_fdrawcmd_seek(int drive, int cyl){}
void driveclick_fdrawcmd_motor (int drive, int running){}
void driveclick_fdrawcmd_vsync(void){}
static int driveclick_fdrawcmd_init(int drive){ return 1; }
// win32
uae_u32 emulib_target_getcpurate (uae_u32 v, uae_u32 *low)
{
#ifdef _WIN32
*low = 0;
if (v == 1) {
LARGE_INTEGER pf;
pf.QuadPart = 0;
QueryPerformanceFrequency (&pf);
*low = pf.LowPart;
return pf.HighPart;
} else if (v == 2) {
LARGE_INTEGER pf;
pf.QuadPart = 0;
QueryPerformanceCounter (&pf);
*low = pf.LowPart;
return pf.HighPart;
}
#else
/*
static struct timeval _tstart, _tend;
static struct timezone tz;
@ -339,7 +197,6 @@ uae_u32 emulib_target_getcpurate (uae_u32 v, uae_u32 *low)
t2 = (double)_tend.tv_sec + (double)_tend.tv_usec/(1000*1000);
return t2-t1;
*/
#endif
return 0;
}
@ -379,7 +236,7 @@ void setmouseactive (int active)
// unicode
char *au_fs_copy (char *dst, int maxlen, const char *src)
{
unsigned int i;
int i;
for (i = 0; src[i] && i < maxlen - 1; i++)
dst[i] = src[i];
@ -389,7 +246,7 @@ char *au_fs_copy (char *dst, int maxlen, const char *src)
// clipboard
static uaecptr clipboard_data;
static int vdelay, signaling, initialized;
static int signaling, initialized;
void amiga_clipboard_die (void)
{
@ -462,18 +319,12 @@ void target_run (void)
// dinput
int input_get_default_keyboard (int i)
{
if (rawinput_enabled_keyboard) {
if (i == 0)
return 1;
} else {
if (i == 0)
return 1;
return 0;
}
return 0;
}
// unicode
static unsigned int fscodepage;
char *ua_fs (const char *s, int defchar)
{
return strdup(s);
@ -544,38 +395,6 @@ int target_cfgfile_load (struct uae_prefs *p, const TCHAR *filename, int type, i
return v;
}
// win32
uae_u8 *save_log (int bootlog, int *len)
{
FILE *f;
uae_u8 *dst = NULL;
int size;
if (!logging_started)
return NULL;
f = fopen (bootlog ? LOG_BOOT : LOG_NORMAL, "rb");
if (!f)
return NULL;
fseek (f, 0, SEEK_END);
size = ftell (f);
fseek (f, 0, SEEK_SET);
if (size > 30000)
size = 30000;
if (size > 0) {
dst = xcalloc (uae_u8, size + 1);
if (dst && fread (dst, 1, size, f))
*len = size + 1;
else {
if (dst)
xfree(dst);
*len = 0;
dst = NULL;
}
fclose (f);
}
return dst;
}
void stripslashes (TCHAR *p)
{
while (_tcslen (p) > 0 && (p[_tcslen (p) - 1] == '\\' || p[_tcslen (p) - 1] == '/'))
@ -897,28 +716,6 @@ char *utf8u (const char *s)
return strdup(s);
}
// dxwrap
int DirectDraw_CurrentRefreshRate (void)
{
//DirectDraw_GetDisplayMode ();
//return dxdata.native.dwRefreshRate;
return 50;
}
int DirectDraw_GetVerticalBlankStatus (void)
{
// BOOL status;
// if (FAILED (IDirectDraw7_GetVerticalBlankStatus (dxdata.maindd, &status)))
return -1;
// return status;
}
// direct3d
int D3D_goodenough (void)
{
return 0;
}
// debug_win32
void update_debug_info(void)
{
@ -1014,14 +811,13 @@ int isfullscreen (void)
#define REFRESH_RATE_LACE 2
int GetSystemMetrics (int nIndex) {
switch (nIndex) {
case SM_CXSCREEN: return 1024;
case SM_CYSCREEN: return 768;
case SM_CXVIRTUALSCREEN: return 1024;
case SM_CYVIRTUALSCREEN: return 768;
}
return 0;
switch (nIndex) {
case SM_CXSCREEN: return 1024;
case SM_CYSCREEN: return 768;
case SM_CXVIRTUALSCREEN: return 1024;
case SM_CYVIRTUALSCREEN: return 768;
}
return 0;
}
static int resolution_compare (const void *a, const void *b)
@ -1164,7 +960,8 @@ void addmode (struct MultiDisplay *md, DEVMODE *dm, int rawmode)
md->DisplayModes[i].res.width, md->DisplayModes[i].res.height,
lace ? _T("i") : _T(""),
md->DisplayModes[i].depth * 8);
write_log ("Add Mode: %s\n", md->DisplayModes[i].name);
// write_log ("Add Mode: %s\n", md->DisplayModes[i].name);
}
void sortdisplays (void)
@ -1276,68 +1073,10 @@ void updatedisplayarea (void)
*/
}
bool target_graphics_buffer_update (void)
{
/*
int w, h;
if (screen_is_picasso) {
w = picasso96_state.Width > picasso_vidinfo.width ? picasso96_state.Width : picasso_vidinfo.width;
h = picasso96_state.Height > picasso_vidinfo.height ? picasso96_state.Height : picasso_vidinfo.height;
} else {
struct vidbuffer *vb = gfxvidinfo.drawbuffer.tempbufferinuse ? &gfxvidinfo.tempbuffer : &gfxvidinfo.drawbuffer;
gfxvidinfo.outbuffer = vb;
w = vb->outwidth;
h = vb->outheight;
}
if (oldtex_w == w && oldtex_h == h && oldtex_rtg == screen_is_picasso)
return true;
oldtex_w = w;
oldtex_h = h;
oldtex_rtg = screen_is_picasso;
write_log (_T("Buffer size (%d*%d) %s\n"), w, h, screen_is_picasso ? _T("RTG") : _T("Native"));
S2X_free ();
if (currentmode->flags & DM_D3D) {
D3D_alloctexture (w, h);
} else {
DirectDraw_ClearSurface (NULL);
}
if (currentmode->flags & DM_SWSCALE) {
S2X_init (currentmode->native_width, currentmode->native_height, currentmode->native_depth);
}
*/
return true;
}
static bool render_ok;
int vsync_busy_wait_mode;
static bool vblanklaceskip (void)
{
if (vblankbaselace_chipset >= 0 && vblankbaselace) {
if ((vblankbaselace_chipset && !vblankthread_oddeven) || (!vblankbaselace_chipset && vblankthread_oddeven))
return true;
}
return false;
}
static bool vblanklaceskip_check (void)
{
int vp = -2;
if (!vblanklaceskip ()) {
// if (vblankbaselace_chipset >= 0)
// write_log (_T("%d == %d\n"), vblankbaselace_chipset, vblankthread_oddeven);
return false;
}
write_log (_T("Interlaced frame type mismatch %d<>%d\n"), vblankbaselace_chipset, vblankthread_oddeven);
return true;
}
static void vsync_sleep (bool preferbusy)
{
struct apmode *ap = picasso_on ? &currprefs.gfx_apmode[1] : &currprefs.gfx_apmode[0];
@ -1355,57 +1094,6 @@ static void vsync_sleep (bool preferbusy)
sleep_millis_main (1);
}
static void changevblankthreadmode_do (int newmode, bool fast)
{
int t = vblankthread_counter;
vblank_found = false;
vblank_found_chipset = false;
vblank_found_rtg = false;
if (vblankthread_mode <= 0 || vblankthread_mode == newmode)
return;
vblankthread_mode = newmode;
if (newmode == VBLANKTH_KILL) {
flipthread_mode = 0;
// SetEvent (flipevent);
while (flipthread_mode == 0)
sleep_millis_main (1);
// CloseHandle (flipevent);
// CloseHandle (flipevent2);
// CloseHandle (vblankwaitevent);
flipevent = 0;
flipevent2 = 0;
vblankwaitevent = 0;
}
if (!fast) {
while (t == vblankthread_counter && vblankthread_mode > 0);
}
}
static void changevblankthreadmode (int newmode)
{
changevblankthreadmode_do (newmode, false);
}
static void changevblankthreadmode_fast (int newmode)
{
changevblankthreadmode_do (newmode, true);
}
static void waitflipevent (void)
{
/* while (flipevent_mode) {
if (WaitForSingleObject (flipevent2, 10) == WAIT_ABANDONED)
break;
}*/
}
static void doflipevent (void)
{
if (!flipevent)
return;
waitflipevent ();
flipevent_mode = 1;
// SetEvent (flipevent);
}
bool show_screen_maybe (bool show)
{
struct apmode *ap = picasso_on ? &currprefs.gfx_apmode[1] : &currprefs.gfx_apmode[0];
@ -1414,12 +1102,6 @@ bool show_screen_maybe (bool show)
show_screen ();
return false;
}
#if 0
if (ap->gfx_vflip < 0) {
doflipevent ();
return true;
}
#endif
return false;
}
@ -1439,27 +1121,11 @@ static int maxscanline, minscanline, prevvblankpos;
static bool getvblankpos (int *vp)
{
int sl = 0;
#if 0
frame_time_t t = read_processor_time ();
#endif
*vp = -2;
/* if (currprefs.gfx_api) {
if (!D3D_getvblankpos (&sl))
return false;
} else {
if (!DD_getvblankpos (&sl))
return false;
}*/
#if 0
t = read_processor_time () - t;
write_log (_T("(%d:%d)"), t, sl);
#endif
prevvblankpos = sl;
if (sl > maxscanline)
maxscanline = sl;
if (sl > 0) {
vblankthread_oddeven = (sl & 1) != 0;
if (sl < minscanline || minscanline < 0)
if ( (sl > 0) && ( (sl < minscanline) || (minscanline < 0) ) ) {
minscanline = sl;
}
*vp = sl;
@ -1479,239 +1145,6 @@ static bool getvblankpos2 (int *vp, int *flags)
return true;
}
double vblank_calibrate (double approx_vblank, bool waitonly)
{
frame_time_t t1, t2;
double tsum, tsum2, tval, tfirst, div;
int maxcnt, maxtotal, total, cnt, tcnt2;
// HANDLE th;
int maxvpos, mult;
int width, height, depth, rate, mode;
struct remembered_vsync *rv;
double rval = -1;
struct apmode *ap = picasso_on ? &currprefs.gfx_apmode[1] : &currprefs.gfx_apmode[0];
bool remembered = false;
bool lace = false;
if (picasso_on) {
width = picasso96_state.Width;
height = picasso96_state.Height;
depth = picasso96_state.BytesPerPixel;
} else {
width = currentmode->native_width;
height = currentmode->native_height;
depth = (currentmode->native_depth + 7) / 8;
}
rate = ap->gfx_refreshrate;
mode = isfullscreen ();
/*
// clear remembered modes if restarting and start thread again.
if (vblankthread_mode <= 0) {
rv = vsyncmemory;
while (rv) {
struct remembered_vsync *rvo = rv->next;
xfree (rv);
rv = rvo;
}
vsyncmemory = NULL;
}
rv = vsyncmemory;
while (rv) {
if (rv->width == width && rv->height == height && rv->depth == depth && rv->rate == rate && rv->mode == mode && rv->rtg == picasso_on) {
approx_vblank = rv->remembered_rate2;
tsum = rval = rv->remembered_rate;
maxscanline = rv->maxscanline;
minscanline = rv->minscanline;
vblankbaseadjust = rv->remembered_adjust;
maxvpos = rv->maxvpos;
lace = rv->lace;
waitonly = true;
remembered = true;
goto skip;
}
rv = rv->next;
}
th = GetCurrentThread ();
int oldpri = GetThreadPriority (th);
SetThreadPriority (th, THREAD_PRIORITY_HIGHEST);
if (vblankthread_mode <= VBLANKTH_KILL) {
unsigned th;
vblankthread_mode = VBLANKTH_CALIBRATE;
_beginthreadex (NULL, 0, vblankthread, 0, 0, &th);
flipthread_mode = 1;
flipevent_mode = 0;
flipevent = CreateEvent (NULL, FALSE, FALSE, NULL);
flipevent2 = CreateEvent (NULL, FALSE, FALSE, NULL);
vblankwaitevent = CreateEvent (NULL, FALSE, FALSE, NULL);
_beginthreadex (NULL, 0, flipthread, 0, 0, &th);
} else {
changevblankthreadmode (VBLANKTH_CALIBRATE);
}
sleep_millis (100);
maxtotal = 10;
maxcnt = maxtotal;
maxscanline = 0;
minscanline = -1;
tsum2 = 0;
tcnt2 = 0;
for (maxcnt = 0; maxcnt < maxtotal; maxcnt++) {
total = 5;
tsum = 0;
cnt = total;
for (cnt = 0; cnt < total; cnt++) {
int maxvpos1, maxvpos2;
int flags1, flags2;
if (!waitvblankstate (true, NULL, NULL))
goto fail;
if (!waitvblankstate (false, NULL, NULL))
goto fail;
if (!waitvblankstate (true, NULL, NULL))
goto fail;
t1 = read_processor_time ();
if (!waitvblankstate (false, NULL, NULL))
goto fail;
maxscanline = 0;
if (!waitvblankstate (true, &maxvpos1, &flags1))
goto fail;
if (!waitvblankstate (false, NULL, NULL))
goto fail;
maxscanline = 0;
if (!waitvblankstate (true, &maxvpos2, &flags2))
goto fail;
t2 = read_processor_time ();
maxvpos = maxvpos1 > maxvpos2 ? maxvpos1 : maxvpos2;
// count two fields: works with interlaced modes too.
tval = (double)syncbase * 2.0 / (t2 - t1);
if (cnt == 0)
tfirst = tval;
if (abs (tval - tfirst) > 1) {
write_log (_T("Very unstable vsync! %.6f vs %.6f, retrying..\n"), tval, tfirst);
break;
}
tsum2 += tval;
tcnt2++;
if (abs (tval - tfirst) > 0.1) {
write_log (_T("Unstable vsync! %.6f vs %.6f\n"), tval, tfirst);
break;
}
tsum += tval;
if ((flags1 > 0 && flags1 < 3) && (flags2 > 0 && flags2 < 3) && (flags1 != flags2)) {
lace = true;
}
}
if (cnt >= total)
break;
}
vblankbaseadjust = timezeroonevblank (-1, 1);
changevblankthreadmode (VBLANKTH_IDLE);
if (maxcnt >= maxtotal) {
tsum = tsum2 / tcnt2;
write_log (_T("Unstable vsync reporting, using average value\n"));
} else {
tsum /= total;
}
if (ap->gfx_vflip == 0) {
int vsdetect = 0;
int detectcnt = 6;
for (cnt = 0; cnt < detectcnt; cnt++) {
render_screen (true);
show_screen ();
sleep_millis (1);
frame_time_t t = read_processor_time () + 1 * (syncbase / tsum);
for (int cnt2 = 0; cnt2 < 4; cnt2++) {
render_ok = true;
show_screen ();
}
int diff = (int)read_processor_time () - (int)t;
if (diff >= 0)
vsdetect++;
}
if (vsdetect >= detectcnt / 2) {
write_log (L"Forced vsync detected, switching to double buffered\n");
changed_prefs.gfx_apmode[0].gfx_backbuffers = 1;
}
}
SetThreadPriority (th, oldpri);
if (waitonly)
tsum = approx_vblank;
skip:
vblank_skipeveryother = false;
getvsyncrate (tsum, &mult);
if (mult < 0) {
div = 2.0;
vblank_skipeveryother = true;
} else if (mult > 0) {
div = 0.5;
} else {
div = 1.0;
}
tsum2 = tsum / div;
vblankbasefull = (syncbase / tsum2);
vblankbasewait1 = (syncbase / tsum2) * 70 / 100;
vblankbasewait2 = (syncbase / tsum2) * 55 / 100;
vblankbasewait3 = (syncbase / tsum2) * 99 / 100 - syncbase / (250 * (vblank_skipeveryother ? 1 : 2)); // at least 2ms before vblank
vblankbaselace = lace;
write_log (_T("VSync %s: %.6fHz/%.1f=%.6fHz. MinV=%d MaxV=%d%s Adj=%d Units=%d %.1f%%\n"),
waitonly ? _T("remembered") : _T("calibrated"), tsum, div, tsum2,
minscanline, maxvpos, lace ? _T("i") : _T(""), vblankbaseadjust, vblankbasefull,
vblankbasewait3 * 100 / (syncbase / tsum2));
if (minscanline == 1) {
if (vblankbaseadjust < 0)
vblankbaseadjust = 0;
else if (vblankbaseadjust > vblankbasefull / 10)
vblankbaseadjust = vblankbasefull / 10;
} else {
vblankbaseadjust = 0;
}
remembered_vblank = tsum;
vblank_prev_time = read_processor_time ();
if (!remembered) {
rv = xcalloc (struct remembered_vsync, 1);
rv->width = width;
rv->height = height;
rv->depth = depth;
rv->rate = rate;
rv->mode = isfullscreen ();
rv->rtg = picasso_on;
rv->remembered_rate = tsum;
rv->remembered_rate2 = tsum2;
rv->remembered_adjust = vblankbaseadjust;
rv->maxscanline = maxscanline;
rv->minscanline = minscanline;
rv->maxvpos = maxvpos;
rv->lace = lace;
if (vsyncmemory == NULL) {
vsyncmemory = rv;
} else {
rv->next = vsyncmemory;
vsyncmemory = rv;
}
}
vblank_reset (tsum);
return tsum;
fail:*/
write_log (_T("VSync calibration failed\n"));
ap->gfx_vsync = 0;
return -1;
}
static bool waitvblankstate (bool state, int *maxvpos, int *flags)
{
int vp;
@ -1759,55 +1192,6 @@ static bool isthreadedvsync (void)
return isvsync_chipset () <= -2 || isvsync_rtg () < 0;
}
frame_time_t vsync_busywait_end (int *flipdelay)
{
/*
if (isthreadedvsync ()) {
frame_time_t prev;
if (!currprefs.turbo_emulation) {
for (;;) {
int v = vblankthread_mode;
if (v != VBLANKTH_ACTIVE_START && v != VBLANKTH_ACTIVE_SKIPFRAME && v != VBLANKTH_ACTIVE_SKIPFRAME2)
break;
sleep_millis_main (1);
}
prev = vblank_prev_time;
if (!dooddevenskip) {
int delay = 10;
frame_time_t t = read_processor_time ();
while (delay-- > 0) {
if (WaitForSingleObject (vblankwaitevent, 10) != WAIT_TIMEOUT)
break;
}
idletime += read_processor_time () - t;
}
if (flipdelay)
*flipdelay = vblank_found_flipdelay;
} else {
show_screen ();
prev = read_processor_time ();
}
changevblankthreadmode_fast (VBLANKTH_ACTIVE_WAIT);
return prev + vblankbasefull;
} else {
if (flipdelay)
*flipdelay = vblank_flip_delay;
return vblank_prev_time;
}
*/
return 0;
}
void vsync_busywait_start (void)
{
if (vblankthread_mode < 0)
write_log (_T("low latency threaded mode but thread is not running!?\n"));
else if (vblankthread_mode != VBLANKTH_ACTIVE_WAIT)
write_log (_T("low latency vsync state mismatch %d\n"), vblankthread_mode);
changevblankthreadmode_fast (VBLANKTH_ACTIVE_START);
}
bool vsync_busywait_do (int *freetime, bool lace, bool oddeven)
{
bool v;
@ -1817,41 +1201,17 @@ bool vsync_busywait_do (int *freetime, bool lace, bool oddeven)
frame_time_t prevtime = vblank_prev_time;
struct apmode *ap = picasso_on ? &currprefs.gfx_apmode[1] : &currprefs.gfx_apmode[0];
dooddevenskip = false;
if (lace)
vblankbaselace_chipset = oddeven == true ? 1 : 0;
else
vblankbaselace_chipset = -1;
t = read_processor_time ();
ti = t - prevtime;
if (ti > 2 * vblankbasefull || ti < -2 * vblankbasefull) {
changevblankthreadmode_fast (VBLANKTH_ACTIVE_WAIT);
if (ti) {
waitvblankstate (false, NULL, NULL);
vblank_prev_time = t;
thread_vblank_time = t;
frame_missed++;
return true;
}
if (log_vsync & 1) {
write_log (_T("F:%8d M:%8d E:%8d %3d%% (%3d%%) %10d\r"), frame_counted, frame_missed, frame_errors, frame_usage, frame_usage_avg, (t - vblank_prev_time) - vblankbasefull);
return true;
}
if (freetime)
*freetime = 0;
frame_usage = (t - prevtime) * 100 / vblankbasefull;
if (frame_usage > 99)
frame_usage = 99;
else if (frame_usage < 0)
frame_usage = 0;
frame_usage_total += frame_usage;
if (freetime)
*freetime = frame_usage;
if (frame_counted)
frame_usage_avg = frame_usage_total / frame_counted;
v = 0;
if (isthreadedvsync ()) {
@ -1862,39 +1222,21 @@ bool vsync_busywait_do (int *freetime, bool lace, bool oddeven)
} else {
int vp;
vblank_flip_delay = 0;
dooddevenskip = false;
if (vblanklaceskip_check ()) {
vblank_prev_time = read_processor_time () + vblankbasewait1;
dooddevenskip = true;
framelost = false;
v = -1;
} else if (currprefs.turbo_emulation) {
if (currprefs.turbo_emulation) {
show_screen ();
vblank_prev_time = read_processor_time ();
framelost = true;
v = -1;
} else {
while (!framelost && read_processor_time () - prevtime < vblankbasewait1) {
while (!framelost && read_processor_time () - prevtime < 0) {
vsync_sleep (false);
}
vp = vblank_wait ();
if (vp >= -1) {
vblank_prev_time = read_processor_time ();
if (ap->gfx_vflip == 0) {
show_screen ();
vblank_flip_delay = (read_processor_time () - vblank_prev_time) / (vblank_skipeveryother ? 2 : 1);
if (vblank_flip_delay < 0)
vblank_flip_delay = 0;
else if (vblank_flip_delay > vblankbasefull * 2 / 3)
vblank_flip_delay = vblankbasefull * 2 / 3;
}
for (;;) {
if (!getvblankpos (&vp))
@ -1906,9 +1248,6 @@ bool vsync_busywait_do (int *freetime, bool lace, bool oddeven)
if (ap->gfx_vflip != 0) {
show_screen ();
}
vblank_prev_time -= vblankbaseadjust;
vblank_prev_time -= (vblankbasefull * vp / maxscanline) / (vblank_skipeveryother ? 2 : 1 );
v = framelost ? -1 : 1;
}
@ -1917,42 +1256,12 @@ bool vsync_busywait_do (int *freetime, bool lace, bool oddeven)
getvblankpos (&vp);
}
if (v) {
frame_counted++;
return v;
}
frame_errors++;
return 0;
}
double getcurrentvblankrate (void)
{
if (remembered_vblank)
return remembered_vblank;
/*
if (currprefs.gfx_api)
return D3D_getrefreshrate ();
else
return DirectDraw_CurrentRefreshRate ();
*/
return 50;
}
///////////////////////////////////////////////////
// parser.c
///////////////////////////////////////////////////
void serialuartbreak (int v)
{
if (/*hCom == INVALID_HANDLE_VALUE ||*/ !currprefs.use_serial)
return;
/*
if (v)
EscapeCommFunction (hCom, SETBREAK);
else
EscapeCommFunction (hCom, CLRBREAK);
*/
}
unsigned int flashscreen;

View File

@ -10,12 +10,7 @@
* Copyright 2010-2013 Mustafa TUFAN
*/
int ispressed (int key);
int D3D_goodenough (void);
int DirectDraw_CurrentRefreshRate (void);
int DirectDraw_GetVerticalBlankStatus (void);
double getcurrentvblankrate (void);
void getgfxoffset (int *dxp, int *dyp, int *mxp, int *myp);
int isfullscreen (void);
void fetch_configurationpath (TCHAR *out, int size);
TCHAR* buf_out (TCHAR *buffer, int *bufsize, const TCHAR *format, ...);
@ -24,7 +19,6 @@ char *ua (const TCHAR *s);
char *uutf8 (const char *s);
char *utf8u (const char *s);
int my_existsdir (const char *name);
bool target_graphics_buffer_update (void);
bool show_screen_maybe (bool show);
bool render_screen (bool immediate);
void show_screen (void);
@ -43,5 +37,8 @@ char *ua_fs (const char *s, int defchar);
void close_console (void);
bool console_isch (void);
TCHAR console_getch (void);
int vsync_switchmode (int hz);
bool vsync_busywait_do (int *freetime, bool lace, bool oddeven);
void doflashscreen (void);
#endif /* SRC_MISC_H_INCLUDED */

File diff suppressed because it is too large Load Diff

View File

@ -80,7 +80,6 @@ static void init_libs (void)
}
static int fromWB;
static FILE *logfile;
/*
* Amiga-specific main entry
@ -89,9 +88,6 @@ int main (int argc, char *argv[])
{
fromWB = argc == 0;
if (fromWB)
set_logfile ("T:E-UAE.log");
init_libs ();
#ifdef USE_SDL
@ -100,9 +96,6 @@ int main (int argc, char *argv[])
real_main (argc, argv);
if (fromWB)
set_logfile (0);
return 0;
}

View File

@ -25,8 +25,7 @@
#define DEBUG_ME
#ifdef DEBUG_ME
extern int log_scsi;
# define DEBUG_LOG if (log_scsi) write_log
# define DEBUG_LOG write_log
#else
# define DEBUG_LOG(...) { }
#endif

View File

@ -366,15 +366,11 @@ NSString *finderLaunchFilename = nil;
/* Main entry point to executable - should *not* be SDL_main! */
int main (int argc, char **argv)
{
char logfile_path[MAX_PATH] = "~/Library/Logs/PUAE.log";
/* Copy the arguments into a global variable */
/* This is passed if we are launched by double-clicking */
if (argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
gArgc = 1;
gFinderLaunch = YES;
// cfgfile_subst_home (logfile_path, MAX_PATH);
set_logfile (logfile_path);
} else {
gArgc = argc;
gFinderLaunch = NO;

View File

@ -1,11 +0,0 @@
AM_CPPFLAGS = @UAE_CPPFLAGS@
AM_CPPFLAGS += -I$(top_srcdir)/src/include -I$(top_builddir)/src -I$(top_srcdir)/src
AM_CFLAGS = @UAE_CFLAGS@
AM_CXXFLAGS = @UAE_CXXFLAGS@
noinst_LIBRARIES = libosdep.a
libosdep_a_SOURCES = main.c memory.c posixemu.c writelog.c fsdb_win32.c \
hardfile_win32.c bsdsock.c
noinst_HEADERS = memory_uae.h hrtimer.h posixemu.h

File diff suppressed because it is too large Load Diff

View File

@ -1,228 +0,0 @@
/*
* UAE - The Un*x Amiga Emulator
*
* Library of functions to make emulated filesystem as independent as
* possible of the host filesystem's capabilities.
* This is the Win32 version.
*
* Copyright 1997 Mathias Ortmann
* Copyright 1999 Bernd Schmidt
*/
#ifdef FILESYS
#include "sysconfig.h"
#include "sysdeps.h"
#include "fsdb.h"
#include <windows.h>
/* these are deadly (but I think allowed on the Amiga): */
#define NUM_EVILCHARS 7
static const char evilchars[NUM_EVILCHARS] = { '\\', '*', '?', '\"', '<', '>', '|' };
/* Return nonzero for any name we can't create on the native filesystem. */
int fsdb_name_invalid (const char *n)
{
int i;
char a = n[0];
char b = (a == '\0' ? a : n[1]);
char c = (b == '\0' ? b : n[2]);
char d = (c == '\0' ? c : n[3]);
int l = strlen (n), ll;
if (a >= 'a' && a <= 'z')
a -= 32;
if (b >= 'a' && b <= 'z')
b -= 32;
if (c >= 'a' && c <= 'z')
c -= 32;
/* reserved dos devices */
ll = 0;
if (a == 'A' && b == 'U' && c == 'X') ll = 3; /* AUX */
if (a == 'C' && b == 'O' && c == 'N') ll = 3; /* CON */
if (a == 'P' && b == 'R' && c == 'N') ll = 3; /* PRN */
if (a == 'N' && b == 'U' && c == 'L') ll = 3; /* NUL */
if (a == 'L' && b == 'P' && c == 'T' && (d >= '0' && d <= '9')) ll = 4; /* LPT# */
if (a == 'C' && b == 'O' && c == 'M' && (d >= '0' && d <= '9')) ll = 4; /* COM# */
/* AUX.anything, CON.anything etc.. are also illegal names */
if (ll && (l == ll || (l > ll && n[ll] == '.')))
return 1;
/* spaces and periods at the end are a no-no */
i = l - 1;
if (n[i] == '.' || n[i] == ' ')
return 1;
/* these characters are *never* allowed */
for (i = 0; i < NUM_EVILCHARS; i++) {
if (strchr (n, evilchars[i]) != 0)
return 1;
}
/* the reserved fsdb filename */
if (strcmp (n, FSDB_FILE) == 0)
return 1;
return 0; /* the filename passed all checks, now it should be ok */
}
static uae_u32 filesys_parse_mask (uae_u32 mask)
{
return mask ^ 0xf;
}
int fsdb_exists (char *nname)
{
if (GetFileAttributes(nname) == 0xFFFFFFFF)
return 0;
return 1;
}
/* For an a_inode we have newly created based on a filename we found on the
* native fs, fill in information about this file/directory. */
int fsdb_fill_file_attrs (a_inode *base, a_inode *aino)
{
DWORD mode;
if ((mode = GetFileAttributes (aino->nname)) == 0xFFFFFFFF) {
write_log ("GetFileAttributes('%s') failed! error=%d, aino=%p dir=%d\n", aino->nname,GetLastError(),aino,aino->dir);
return 0;
}
aino->dir = (mode & FILE_ATTRIBUTE_DIRECTORY) ? 1 : 0;
aino->amigaos_mode = A_FIBF_EXECUTE | A_FIBF_READ;
if (FILE_ATTRIBUTE_ARCHIVE & mode)
aino->amigaos_mode |= A_FIBF_ARCHIVE;
if (! (FILE_ATTRIBUTE_READONLY & mode))
aino->amigaos_mode |= A_FIBF_WRITE | A_FIBF_DELETE;
aino->amigaos_mode = filesys_parse_mask (aino->amigaos_mode);
return 1;
}
int fsdb_set_file_attrs (a_inode *aino)
{
struct stat statbuf;
uae_u32 mode=0, tmpmask;
tmpmask = filesys_parse_mask (aino->amigaos_mode);
if (stat (aino->nname, &statbuf) == -1)
return ERROR_OBJECT_NOT_AROUND;
/* Unix dirs behave differently than AmigaOS ones. */
/* windows dirs go where no dir has gone before... */
if (! aino->dir) {
if ((tmpmask & (A_FIBF_READ | A_FIBF_DELETE)) == 0)
mode |= FILE_ATTRIBUTE_READONLY;
if (tmpmask & A_FIBF_ARCHIVE)
mode |= FILE_ATTRIBUTE_ARCHIVE;
else
mode &= ~FILE_ATTRIBUTE_ARCHIVE;
SetFileAttributes(aino->nname, mode);
}
aino->dirty = 1;
return 0;
}
/* Return nonzero if we can represent the amigaos_mode of AINO within the
* native FS. Return zero if that is not possible. */
int fsdb_mode_representable_p (const a_inode *aino)
{
int mask = aino->amigaos_mode;
int m1;
if (aino->dir)
return aino->amigaos_mode == 0;
/* P or S set, or E or R clear, means we can't handle it. */
if (mask & (A_FIBF_SCRIPT | A_FIBF_PURE | A_FIBF_EXECUTE | A_FIBF_READ))
return 0;
m1 = A_FIBF_DELETE | A_FIBF_WRITE;
/* If it's rwed, we are OK... */
if ((mask & m1) == 0)
return 1;
/* We can also represent r-e-, by setting the host's readonly flag. */
if ((mask & m1) == m1)
return 1;
return 0;
}
char *fsdb_create_unique_nname (a_inode *base, const char *suggestion)
{
char *c;
char tmp[256] = "__uae___";
int i;
strncat (tmp, suggestion, 240);
/* replace the evil ones... */
for (i=0; i < NUM_EVILCHARS; i++)
while ((c = strchr (tmp, evilchars[i])) != 0)
*c = '_';
while ((c = strchr (tmp, '.')) != 0)
*c = '_';
while ((c = strchr (tmp, ' ')) != 0)
*c = '_';
for (;;) {
char *p = build_nname (base->nname, tmp);
if (access (p, R_OK) < 0 && errno == ENOENT) {
write_log ("unique name: %s\n", p);
return p;
}
xfree (p);
/* tmpnam isn't reentrant and I don't really want to hack configure
* right now to see whether tmpnam_r is available... */
for (i = 0; i < 8; i++) {
tmp[i+8] = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[rand () % 63];
}
}
}
int dos_errno (void)
{
DWORD e = GetLastError ();
//write_log ("ec=%d\n", e);
switch (e) {
case ERROR_NOT_ENOUGH_MEMORY:
case ERROR_OUTOFMEMORY:
return ERROR_NO_FREE_STORE;
case ERROR_FILE_EXISTS:
case ERROR_ALREADY_EXISTS:
return ERROR_OBJECT_EXISTS;
case ERROR_WRITE_PROTECT:
case ERROR_ACCESS_DENIED:
return ERROR_WRITE_PROTECTED;
case ERROR_FILE_NOT_FOUND:
case ERROR_INVALID_DRIVE:
return ERROR_OBJECT_NOT_AROUND;
case ERROR_HANDLE_DISK_FULL:
return ERROR_DISK_IS_FULL;
case ERROR_SHARING_VIOLATION:
case ERROR_BUSY:
return ERROR_OBJECT_IN_USE;
case ERROR_CURRENT_DIRECTORY:
return ERROR_DIRECTORY_NOT_EMPTY;
case ERROR_NEGATIVE_SEEK:
case ERROR_SEEK_ON_DEVICE:
return ERROR_SEEK_ERROR;
default:
write_log ("Unimplemented error %d\n", e);
return ERROR_NOT_IMPLEMENTED;
}
}
#endif

View File

@ -1,789 +0,0 @@
#ifdef FILESYS
#define WIN32_LEAN_AND_MEAN
#include "sysconfig.h"
#include "sysdeps.h"
#include "threaddep/thread.h"
#include "filesys.h"
#include "blkdev.h"
#define hfd_log write_log
#include <windef.h>
#include <winbase.h>
#ifdef WINDDK
#include <devioctl.h>
#include <ntddstor.h>
#include <winioctl.h>
#include <initguid.h> // Guid definition
#include <devguid.h> // Device guids
#include <setupapi.h> // for SetupDiXxx functions.
#include <cfgmgr32.h> // for SetupDiXxx functions.
#endif
struct uae_driveinfo {
uae_u64 offset2;
uae_u64 size2;
char vendor_id[128];
char product_id[128];
char product_rev[128];
char product_serial[128];
char device_name[256];
char device_path[2048];
uae_u64 size;
uae_u64 offset;
int bytespersector;
};
#define CACHE_SIZE 16384
#define CACHE_FLUSH_TIME 5
/* safety check: only accept drives that:
* - contain RDSK in block 0
* - block 0 is zeroed
*/
int harddrive_dangerous, do_rdbdump;
static int num_drives;
static struct uae_driveinfo uae_drives[MAX_FILESYSTEM_UNITS];
static void rdbdump (HANDLE *h, uae_u64 offset, uae_u8 *buf, unsigned int blocksize)
{
static int cnt = 1;
int i, blocks;
char name[100];
FILE *f;
blocks = (buf[132] << 24) | (buf[133] << 16) | (buf[134] << 8) | (buf[135] << 0);
if (blocks < 0 || blocks > 100000)
return;
sprintf (name, "rdb_dump_%d.rdb", cnt);
f = fopen (name, "wb");
if (!f)
return;
for (i = 0; i <= blocks; i++) {
DWORD outlen, high;
high = (DWORD)(offset >> 32);
if (SetFilePointer (h, (DWORD)offset, &high, FILE_BEGIN) == INVALID_FILE_SIZE)
break;
ReadFile (h, buf, blocksize, &outlen, NULL);
fwrite (buf, 1, blocksize, f);
offset += blocksize;
}
fclose (f);
cnt++;
}
static int safetycheck (HANDLE *h, uae_u64 offset, uae_u8 *buf, unsigned int blocksize)
{
unsigned int i, j, blocks = 63, empty = 1;
DWORD outlen, high;
for (j = 0; j < blocks; j++) {
high = (DWORD)(offset >> 32);
if (SetFilePointer (h, (DWORD)offset, &high, FILE_BEGIN) == INVALID_FILE_SIZE) {
write_log ("hd ignored, SetFilePointer failed, error %d\n", GetLastError());
return 0;
}
memset (buf, 0xaa, blocksize);
ReadFile (h, buf, blocksize, &outlen, NULL);
if (outlen != blocksize) {
write_log ("hd ignored, read error %d!\n", GetLastError());
return 0;
}
if (!memcmp (buf, "RDSK", 4)) {
if (do_rdbdump)
rdbdump (h, offset, buf, blocksize);
write_log ("hd accepted (rdb detected at block %d)\n", j);
return 1;
}
if (j == 0) {
for (i = 0; i < blocksize; i++) {
if (buf[i])
empty = 0;
}
}
offset += blocksize;
}
if (harddrive_dangerous != 0x1234dead) {
if (!empty) {
write_log ("hd ignored, not empty and no RDB detected\n");
return 0;
}
write_log ("hd accepted (empty)\n");
return 1;
}
gui_message ("WARNING: Non-empty or Amiga formatted\n"
"harddrive detected and safety test was disabled\n\n"
"Harddrives marked with 'HD_*_' are not empty\n");
return 2;
}
static void trim (char *s)
{
while(strlen (s) > 0 && s[strlen (s) - 1] == ' ')
s[strlen(s) - 1] = 0;
}
static int isharddrive (const char *name)
{
int i;
for (i = 0; i < num_drives; i++) {
if (!strcmp (uae_drives[i].device_name, name))
return i;
}
return -1;
}
int hdf_open (struct hardfiledata *hfd, const char *name)
{
HANDLE h = INVALID_HANDLE_VALUE;
int i;
struct uae_driveinfo *udi;
hdf_close (hfd);
hfd->cache = VirtualAlloc (NULL, CACHE_SIZE, MEM_COMMIT, PAGE_READWRITE);
hfd->cache_valid = 0;
if (!hfd->cache) {
write_log ("VirtualAlloc(%d) failed, error %d\n", CACHE_SIZE, GetLastError());
return 0;
}
hfd_log ("hfd open: '%s'\n", name);
if (strlen (name) > 4 && !memcmp (name, "HD_", 3)) {
hdf_init ();
i = isharddrive (name);
if (i >= 0) {
udi = &uae_drives[i];
hfd->flags = 1;
h = CreateFile (udi->device_path, GENERIC_READ | (hfd->readonly ? 0 : GENERIC_WRITE), FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS | FILE_FLAG_NO_BUFFERING, NULL);
hfd->handle = h;
if (h == INVALID_HANDLE_VALUE) {
hdf_close (hfd);
return 0;
}
strncpy (hfd->vendor_id, udi->vendor_id, 8);
strncpy (hfd->product_id, udi->product_id, 16);
strncpy (hfd->product_rev, udi->product_rev, 4);
hfd->offset2 = hfd->offset = udi->offset;
hfd->size2 = hfd->size = udi->size;
if (hfd->offset != udi->offset2 || hfd->size != udi->size2) {
gui_message ("Harddrive safety check: fatal memory corruption\n");
abort ();
}
hfd->blocksize = udi->bytespersector;
if (hfd->offset == 0) {
if (!safetycheck (hfd->handle, 0, hfd->cache, hfd->blocksize)) {
hdf_close (hfd);
return 0;
}
}
}
} else {
h = CreateFile (name, GENERIC_READ | (hfd->readonly ? 0 : GENERIC_WRITE), hfd->readonly ? FILE_SHARE_READ : 0, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL);
hfd->handle = h;
i = strlen (name) - 1;
while (i >= 0) {
if ((i > 0 && (name[i - 1] == '/' || name[i - 1] == '\\')) || i == 0) {
strcpy (hfd->vendor_id, "UAE");
strncpy (hfd->product_id, name + i, 15);
strcpy (hfd->product_rev, "0.2");
break;
}
i--;
}
if (h != INVALID_HANDLE_VALUE) {
DWORD ret, low, high;
high = 0;
ret = SetFilePointer (h, 0, &high, FILE_END);
if (ret == INVALID_FILE_SIZE && GetLastError() != NO_ERROR) {
hdf_close (hfd);
return 0;
}
low = GetFileSize (h, &high);
if (low == INVALID_FILE_SIZE && GetLastError() != NO_ERROR) {
hdf_close (hfd);
return 0;
}
low &= ~(hfd->blocksize - 1);
hfd->size = hfd->size2 = ((uae_u64)high << 32) | low;
} else {
write_log ("HDF '%s' failed to open. error = %d\n", name, GetLastError ());
}
}
hfd->handle = h;
if (hfd->handle != INVALID_HANDLE_VALUE) {
hfd_log ("HDF '%s' opened succesfully, handle=%p\n", name, hfd->handle);
return 1;
}
hdf_close (hfd);
return 0;
}
void hdf_close (struct hardfiledata *hfd)
{
hfd_log ("close handle=%p\n", hfd->handle);
hfd->flags = 0;
if (hfd->handle && hfd->handle != INVALID_HANDLE_VALUE)
CloseHandle (hfd->handle);
hfd->handle = 0;
if (hfd->cache)
VirtualFree (hfd->cache, 0, MEM_RELEASE);
hfd->cache = 0;
hfd->cache_valid = 0;
}
int hdf_dup (struct hardfiledata *hfd, const struct hardfiledata *src)
{
HANDLE duphandle;
if (src == 0 || src == INVALID_HANDLE_VALUE)
return 0;
if (!DuplicateHandle (GetCurrentProcess(), src, GetCurrentProcess() , &duphandle, 0, FALSE, DUPLICATE_SAME_ACCESS))
return 0;
hfd->handle = duphandle;
hfd->cache = VirtualAlloc (NULL, CACHE_SIZE, MEM_COMMIT, PAGE_READWRITE);
hfd->cache_valid = 0;
if (!hfd->cache) {
hdf_close (hfd);
return 0;
}
hfd_log ("dup handle %p->%p\n", src, duphandle);
return 1;
}
static int hdf_seek (struct hardfiledata *hfd, uae_u64 offset)
{
DWORD high, ret;
if (hfd->offset != hfd->offset2 || hfd->size != hfd->size2) {
gui_message ("hd: memory corruption detected in seek");
abort ();
}
if (offset >= hfd->size) {
gui_message ("hd: tried to seek out of bounds! (%I64X >= %I64X)\n", offset, hfd->size);
abort ();
}
offset += hfd->offset;
if (offset & (hfd->blocksize - 1)) {
gui_message ("hd: poscheck failed, offset not aligned to blocksize! (%I64X & %04.4X = %04.4X)\n", offset, hfd->blocksize, offset & (hfd->blocksize - 1));
abort ();
}
high = (DWORD)(offset >> 32);
ret = SetFilePointer (hfd->handle, (DWORD)offset, &high, FILE_BEGIN);
if (ret == INVALID_FILE_SIZE && GetLastError() != NO_ERROR)
return -1;
return 0;
}
static void poscheck (struct hardfiledata *hfd, int len)
{
DWORD high, ret, err;
uae_u64 pos;
if (hfd->offset != hfd->offset2 || hfd->size != hfd->size2) {
gui_message ("hd: memory corruption detected in poscheck");
abort ();
}
high = 0;
ret = SetFilePointer (hfd->handle, 0, &high, FILE_CURRENT);
err = GetLastError ();
if (ret == INVALID_FILE_SIZE && err != NO_ERROR) {
gui_message ("hd: poscheck failed. seek failure, error %d", err);
abort ();
}
if (len < 0) {
gui_message ("hd: poscheck failed, negative length! (%d)", len);
abort ();
}
pos = ((uae_u64)high) << 32 | ret;
if (pos < hfd->offset) {
gui_message ("hd: poscheck failed, offset out of bounds! (%I64d < %I64d)", pos, hfd->offset);
abort ();
}
if (pos >= hfd->offset + hfd->size || pos >= hfd->offset + hfd->size + len) {
gui_message ("hd: poscheck failed, offset out of bounds! (%I64d >= %I64d, LEN=%d)", pos, hfd->offset + hfd->size, len);
abort ();
}
if (pos & (hfd->blocksize - 1)) {
gui_message ("hd: poscheck failed, offset not aligned to blocksize! (%I64X & %04.4X = %04.4X\n", pos, hfd->blocksize, pos & hfd->blocksize);
abort ();
}
}
static int isincache (struct hardfiledata *hfd, uae_u64 offset, int len)
{
if (!hfd->cache_valid)
return -1;
if (offset >= hfd->cache_offset && offset + len <= hfd->cache_offset + CACHE_SIZE)
return (int)(offset - hfd->cache_offset);
return -1;
}
#if 0
void hfd_flush_cache (struct hardfiledata *hfd, int now)
{
DWORD outlen = 0;
if (!hfd->cache_needs_flush || !hfd->cache_valid)
return;
if (now || time (NULL) > hfd->cache_needs_flush + CACHE_FLUSH_TIME) {
hdf_log ("flushed %d %d %d\n", now, time(NULL), hfd->cache_needs_flush);
hdf_seek (hfd, hfd->cache_offset);
poscheck (hfd, CACHE_SIZE);
WriteFile (hfd->handle, hfd->cache, CACHE_SIZE, &outlen, NULL);
hfd->cache_needs_flush = 0;
}
}
#endif
#if 0
int hdf_read (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
{
DWORD outlen = 0;
hfd->cache_valid = 0;
hdf_seek (hfd, offset);
poscheck (hfd, len);
ReadFile (hfd->handle, hfd->cache, len, &outlen, NULL);
memcpy (buffer, hfd->cache, len);
return outlen;
}
#endif
int hdf_read (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
{
DWORD outlen = 0;
int coffset;
if (offset == 0)
hfd->cache_valid = 0;
coffset = isincache (hfd, offset, len);
if (coffset >= 0) {
memcpy (buffer, hfd->cache + coffset, len);
return len;
}
hfd->cache_offset = offset;
if (offset + CACHE_SIZE > hfd->offset + hfd->size)
hfd->cache_offset = hfd->offset + hfd->size - CACHE_SIZE;
hdf_seek (hfd, hfd->cache_offset);
poscheck (hfd, CACHE_SIZE);
ReadFile (hfd->handle, hfd->cache, CACHE_SIZE, &outlen, NULL);
hfd->cache_valid = 0;
if (outlen != CACHE_SIZE)
return 0;
hfd->cache_valid = 1;
coffset = isincache (hfd, offset, len);
if (coffset >= 0) {
memcpy (buffer, hfd->cache + coffset, len);
return len;
}
write_log ("hdf_read: cache bug! offset=%I64d len=%d\n", offset, len);
hfd->cache_valid = 0;
return 0;
}
int hdf_write (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
{
DWORD outlen = 0;
hfd->cache_valid = 0;
hdf_seek (hfd, offset);
poscheck (hfd, len);
memcpy (hfd->cache, buffer, len);
WriteFile (hfd->handle, hfd->cache, len, &outlen, NULL);
return outlen;
}
#ifdef WINDDK
/* see MS KB article Q264203 more more information */
static BOOL GetDeviceProperty (HDEVINFO IntDevInfo, DWORD Index, DWORD *index2, uae_u8 *buffer)
/*++
Routine Description:
This routine enumerates the disk devices using the Device interface
GUID DiskClassGuid. Gets the Adapter & Device property from the port
driver. Then sends IOCTL through SPTI to get the device Inquiry data.
Arguments:
IntDevInfo - Handles to the interface device information list
Index - Device member
Return Value:
TRUE / FALSE. This decides whether to continue or not
--*/
{
STORAGE_PROPERTY_QUERY query;
SP_DEVICE_INTERFACE_DATA interfaceData;
PSP_DEVICE_INTERFACE_DETAIL_DATA interfaceDetailData = NULL;
PSTORAGE_ADAPTER_DESCRIPTOR adpDesc;
PSTORAGE_DEVICE_DESCRIPTOR devDesc;
HANDLE hDevice = INVALID_HANDLE_VALUE;
BOOL status;
PUCHAR p;
UCHAR outBuf[20000];
ULONG length = 0,
returned = 0,
returnedLength;
DWORD interfaceDetailDataSize = 0,
reqSize,
errorCode,
i, j;
DRIVE_LAYOUT_INFORMATION *dli;
DISK_GEOMETRY dg;
int ret = -1;
struct uae_driveinfo *udi;
char orgname[1024];
interfaceData.cbSize = sizeof (SP_INTERFACE_DEVICE_DATA);
status = SetupDiEnumDeviceInterfaces (
IntDevInfo, // Interface Device Info handle
0, // Device Info data
(LPGUID)&DiskClassGuid, // Interface registered by driver
Index, // Member
&interfaceData // Device Interface Data
);
if ( status == FALSE ) {
errorCode = GetLastError();
if ( errorCode != ERROR_NO_MORE_ITEMS ) {
write_log ("SetupDiEnumDeviceInterfaces failed with error: %d\n", errorCode);
}
ret = 0;
goto end;
}
//
// Find out required buffer size, so pass NULL
//
status = SetupDiGetDeviceInterfaceDetail (
IntDevInfo, // Interface Device info handle
&interfaceData, // Interface data for the event class
NULL, // Checking for buffer size
0, // Checking for buffer size
&reqSize, // Buffer size required to get the detail data
NULL // Checking for buffer size
);
//
// This call returns ERROR_INSUFFICIENT_BUFFER with reqSize
// set to the required buffer size. Ignore the above error and
// pass a bigger buffer to get the detail data
//
if ( status == FALSE ) {
errorCode = GetLastError();
if ( errorCode != ERROR_INSUFFICIENT_BUFFER ) {
write_log ("SetupDiGetDeviceInterfaceDetail failed with error: %d\n", errorCode);
ret = 0;
goto end;
}
}
//
// Allocate memory to get the interface detail data
// This contains the devicepath we need to open the device
//
interfaceDetailDataSize = reqSize;
interfaceDetailData = malloc (interfaceDetailDataSize);
if ( interfaceDetailData == NULL ) {
write_log ("Unable to allocate memory to get the interface detail data.\n");
ret = 0;
goto end;
}
interfaceDetailData->cbSize = sizeof (SP_INTERFACE_DEVICE_DETAIL_DATA);
status = SetupDiGetDeviceInterfaceDetail (
IntDevInfo, // Interface Device info handle
&interfaceData, // Interface data for the event class
interfaceDetailData, // Interface detail data
interfaceDetailDataSize, // Interface detail data size
&reqSize, // Buffer size required to get the detail data
NULL); // Interface device info
if ( status == FALSE ) {
write_log ("Error in SetupDiGetDeviceInterfaceDetail failed with error: %d\n", GetLastError());
ret = 0;
goto end;
}
//
// Now we have the device path. Open the device interface
// to send Pass Through command
udi = &uae_drives[*index2];
strcpy (udi->device_path, interfaceDetailData->DevicePath);
write_log ("opening device '%s'\n", udi->device_path);
hDevice = CreateFile(
interfaceDetailData->DevicePath, // device interface name
GENERIC_READ | GENERIC_WRITE, // dwDesiredAccess
FILE_SHARE_READ | FILE_SHARE_WRITE, // dwShareMode
NULL, // lpSecurityAttributes
OPEN_EXISTING, // dwCreationDistribution
0, // dwFlagsAndAttributes
NULL // hTemplateFile
);
//
// We have the handle to talk to the device.
// So we can release the interfaceDetailData buffer
//
xfree (interfaceDetailData);
interfaceDetailData = NULL;
if (hDevice == INVALID_HANDLE_VALUE) {
write_log ("CreateFile failed with error: %d\n", GetLastError());
ret = 1;
goto end;
}
query.PropertyId = StorageAdapterProperty;
query.QueryType = PropertyStandardQuery;
status = DeviceIoControl(
hDevice,
IOCTL_STORAGE_QUERY_PROPERTY,
&query,
sizeof( STORAGE_PROPERTY_QUERY ),
&outBuf,
sizeof (outBuf),
&returnedLength,
NULL
);
if ( !status ) {
write_log ("IOCTL_STORAGE_QUERY_PROPERTY failed with error code%d.\n", GetLastError());
ret = 1;
goto end;
}
adpDesc = (PSTORAGE_ADAPTER_DESCRIPTOR) outBuf;
query.PropertyId = StorageDeviceProperty;
query.QueryType = PropertyStandardQuery;
status = DeviceIoControl(
hDevice,
IOCTL_STORAGE_QUERY_PROPERTY,
&query,
sizeof( STORAGE_PROPERTY_QUERY ),
&outBuf,
sizeof (outBuf),
&returnedLength,
NULL);
if ( !status ) {
write_log ("IOCTL_STORAGE_QUERY_PROPERTY failed with error code %d.\n", GetLastError());
ret = 1;
goto end;
}
devDesc = (PSTORAGE_DEVICE_DESCRIPTOR) outBuf;
p = (PUCHAR) outBuf;
if (devDesc->DeviceType != INQ_DASD && devDesc->DeviceType != INQ_ROMD && devDesc->DeviceType != INQ_OPTD) {
ret = 1;
write_log ("not a direct access device, ignored (type=%d)\n", devDesc->DeviceType);
goto end;
}
if ( devDesc->VendorIdOffset && p[devDesc->VendorIdOffset] ) {
j = 0;
for ( i = devDesc->VendorIdOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++ )
udi->vendor_id[j++] = p[i];
}
if ( devDesc->ProductIdOffset && p[devDesc->ProductIdOffset] ) {
j = 0;
for ( i = devDesc->ProductIdOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++ )
udi->product_id[j++] = p[i];
}
if ( devDesc->ProductRevisionOffset && p[devDesc->ProductRevisionOffset] ) {
j = 0;
for ( i = devDesc->ProductRevisionOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++ )
udi->product_rev[j++] = p[i];
}
if ( devDesc->SerialNumberOffset && p[devDesc->SerialNumberOffset] ) {
j = 0;
for ( i = devDesc->SerialNumberOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++ )
udi->product_serial[j++] = p[i];
}
if (udi->vendor_id[0])
strcat (udi->device_name, udi->vendor_id);
if (udi->product_id[0]) {
if (udi->device_name[0])
strcat (udi->device_name, " ");
strcat (udi->device_name, udi->product_id);
}
if (udi->product_rev[0]) {
if (udi->device_name[0])
strcat (udi->device_name, " ");
strcat (udi->device_name, udi->product_rev);
}
if (udi->product_serial[0]) {
if (udi->device_name[0])
strcat (udi->device_name, " ");
strcat (udi->device_name, udi->product_serial);
}
write_log ("device id string: '%s'\n", udi->device_name);
if (!DeviceIoControl (hDevice, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, (void*)&dg, sizeof (dg), &returnedLength, NULL)) {
write_log ("IOCTL_DISK_GET_DRIVE_GEOMETRY failed with error code %d.\n", GetLastError());
ret = 1;
goto end;
}
udi->bytespersector = dg.BytesPerSector;
if (dg.BytesPerSector < 512) {
write_log ("unsupported blocksize < 512 (%d)\n", dg.BytesPerSector);
ret = 1;
goto end;
}
if (dg.BytesPerSector > 2048) {
write_log ("unsupported blocksize > 2048 (%d)\n", dg.BytesPerSector);
ret = 1;
goto end;
}
udi->offset = udi->offset2 = 0;
udi->size = udi->size2 = (uae_u64)dg.BytesPerSector * (uae_u64)dg.Cylinders.QuadPart * (uae_u64)dg.TracksPerCylinder * (uae_u64)dg.SectorsPerTrack;
write_log ("device size %I64d bytes\n", udi->size);
memset (outBuf, 0, sizeof (outBuf));
status = DeviceIoControl(hDevice, IOCTL_DISK_GET_DRIVE_LAYOUT, NULL, 0,
&outBuf, sizeof (outBuf), &returnedLength, NULL);
if (!status) {
write_log ("IOCTL_DISK_GET_DRIVE_LAYOUT failed with error code%d.\n", GetLastError());
ret = 1;
goto end;
}
strcpy (orgname, udi->device_name);
trim (orgname);
dli = (DRIVE_LAYOUT_INFORMATION*)outBuf;
if (dli->PartitionCount) {
struct uae_driveinfo *udi2 = udi;
int nonzeropart = 0;
int gotpart = 0;
write_log ("%d MBR partitions found\n", dli->PartitionCount);
for (i = 0; i < dli->PartitionCount && (*index2) < MAX_FILESYSTEM_UNITS; i++) {
PARTITION_INFORMATION *pi = &dli->PartitionEntry[i];
if (pi->PartitionType == PARTITION_ENTRY_UNUSED)
continue;
write_log ("%d: num: %d type: %02.2X offset: %I64d size: %I64d, ", i, pi->PartitionNumber, pi->PartitionType, pi->StartingOffset.QuadPart, pi->PartitionLength.QuadPart);
if (pi->RecognizedPartition == 0) {
write_log ("unrecognized\n");
continue;
}
nonzeropart++;
if (pi->PartitionType != 0x76) {
write_log ("type not 0x76\n");
continue;
}
memmove (udi, udi2, sizeof (*udi));
udi->device_name[0] = 0;
udi->offset = udi->offset2 = pi->StartingOffset.QuadPart;
udi->size = udi->size2 = pi->PartitionLength.QuadPart;
write_log ("used\n");
if (safetycheck (hDevice, udi->offset, buffer, dg.BytesPerSector)) {
sprintf (udi->device_name, "HD_P#%d_%s", pi->PartitionNumber, orgname);
udi++;
(*index2)++;
}
gotpart = 1;
}
if (!nonzeropart) {
write_log ("empty MBR partition table detected, checking for RDB\n");
} else if (!gotpart) {
write_log ("non-empty MBR partition table detected, doing RDB check anyway\n");
} else if (harddrive_dangerous != 0x1234dead) {
ret = 1;
goto end;
}
} else {
write_log ("no MBR partition table detected, checking for RDB\n");
}
i = safetycheck (hDevice, 0, buffer, dg.BytesPerSector);
if (!i) {
ret = 1;
goto end;
}
write_log ("device accepted, start=%I64d, size=%I64d, block=%d\n", udi->offset, udi->size, udi->bytespersector);
if (i > 1)
sprintf (udi->device_name, "HD_*_%s", orgname);
else
sprintf (udi->device_name, "HD_%s", orgname);
while (isharddrive (udi->device_name) >= 0)
strcat (udi->device_name, "_");
(*index2)++;
end:
xfree (interfaceDetailData);
if (hDevice != INVALID_HANDLE_VALUE)
CloseHandle (hDevice);
return ret;
}
#endif
int hdf_init (void)
{
#ifdef WINDDK
HDEVINFO hIntDevInfo;
#endif
DWORD index = 0, index2 = 0;
uae_u8 *buffer;
static int done;
if (done)
return num_drives;
done = 1;
num_drives = 0;
#ifdef WINDDK
buffer = VirtualAlloc (NULL, 512, MEM_COMMIT, PAGE_READWRITE);
if (buffer) {
memset (uae_drives, 0, sizeof (uae_drives));
num_drives = 0;
hIntDevInfo = SetupDiGetClassDevs ((LPGUID)&DiskClassGuid, NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);
if (hIntDevInfo != INVALID_HANDLE_VALUE) {
while (index < MAX_FILESYSTEM_UNITS) {
memset (uae_drives + index2, 0, sizeof (struct uae_driveinfo));
if (!GetDeviceProperty (hIntDevInfo, index, &index2, buffer))
break;
index++;
num_drives = index2;
}
SetupDiDestroyDeviceInfoList(hIntDevInfo);
}
VirtualFree (buffer, 0, MEM_RELEASE);
}
num_drives = index2;
write_log ("Drive scan result: %d Amiga formatted drives detected\n", num_drives);
#endif
return num_drives;
}
int hdf_getnumharddrives (void)
{
return num_drives;
}
char *hdf_getnameharddrive (int index, int flags)
{
static char name[512];
char tmp[32];
uae_u64 size = uae_drives[index].size;
if (flags & 1) {
if (size >= 1024 * 1024 * 1024)
sprintf (tmp, "%.1fG", ((double)(uae_u32)(size / (1024 * 1024))) / 1024.0);
else
sprintf (tmp, "%.1fM", ((double)(uae_u32)(size / (1024))) / 1024.0);
sprintf (name, "%s (%s)", uae_drives[index].device_name, tmp);
return name;
}
return uae_drives[index].device_name;
}
#endif

View File

@ -1,30 +0,0 @@
/*
* E-UAE - The portable Amiga Emulator
*
* Generic high-resolution timer support.
*
* (c) 2005 Richard Drummond
*/
#ifndef EUAE_OSDEP_HRTIMER_H
#define EUAE_OSDEP_HRTIMER_H
#include "posixemu.h"
#include "machdep/rpt.h"
STATIC_INLINE frame_time_t osdep_gethrtime (void)
{
struct timeval t;
gettimeofday (&t, 0);
return t.tv_sec * 1000000 + t.tv_usec;
}
STATIC_INLINE frame_time_t osdep_gethrtimebase (void)
{
return 1000000;
}
STATIC_INLINE void osdep_inithrtimer (void)
{
}
#endif

View File

@ -1,246 +0,0 @@
/*
* UAE - The Un*x Amiga Emulator
*
* Start-up and support functions used by Win32
*/
#include "sysconfig.h"
#include "sysdeps.h"
#include <windows.h>
#include "uae.h"
#include "options.h"
#include "debug.h"
#include <SDL_main.h>
/*
* Handle break signal
*/
#include <signal.h>
#ifdef __cplusplus
static RETSIGTYPE sigbrkhandler(...)
#else
static RETSIGTYPE sigbrkhandler (int foo)
#endif
{
#ifdef DEBUGGER
activate_debugger ();
#endif
#if !defined(__unix) || defined(__NeXT__)
signal (SIGINT, sigbrkhandler);
#endif
}
void setup_brkhandler (void)
{
#if defined(__unix) && !defined(__NeXT__)
struct sigaction sa;
sa.sa_handler = sigbrkhandler;
sa.sa_flags = 0;
#ifdef SA_RESTART
sa.sa_flags = SA_RESTART;
#endif
sigemptyset (&sa.sa_mask);
sigaction (SIGINT, &sa, NULL);
#else
signal (SIGINT, sigbrkhandler);
#endif
}
HINSTANCE hInst;
char *start_path;
char start_path_data[MAX_DPATH];
int os_winnt, os_winnt_admin;
static OSVERSIONINFO osVersion;
static SYSTEM_INFO SystemInfo;
static int isadminpriv (void)
{
DWORD i, dwSize = 0, dwResult = 0;
HANDLE hToken;
PTOKEN_GROUPS pGroupInfo;
BYTE sidBuffer[100];
PSID pSID = (PSID)&sidBuffer;
SID_IDENTIFIER_AUTHORITY SIDAuth = {SECURITY_NT_AUTHORITY};
int isadmin = 0;
// Open a handle to the access token for the calling process.
if (!OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &hToken)) {
write_log ("OpenProcessToken Error %u\n", GetLastError());
return FALSE;
}
// Call GetTokenInformation to get the buffer size.
if (!GetTokenInformation(hToken, TokenGroups, NULL, dwSize, &dwSize)) {
dwResult = GetLastError();
if (dwResult != ERROR_INSUFFICIENT_BUFFER) {
write_log ("GetTokenInformation Error %u\n", dwResult);
return FALSE;
}
}
// Allocate the buffer.
pGroupInfo = (PTOKEN_GROUPS) GlobalAlloc (GPTR, dwSize);
// Call GetTokenInformation again to get the group information.
if (!GetTokenInformation (hToken, TokenGroups, pGroupInfo, dwSize, &dwSize)) {
write_log ("GetTokenInformation Error %u\n", GetLastError ());
return FALSE;
}
// Create a SID for the BUILTIN\Administrators group.
if (!AllocateAndInitializeSid (&SIDAuth, 2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0,
&pSID)) {
write_log ("AllocateAndInitializeSid Error %u\n", GetLastError ());
return FALSE;
}
// Loop through the group SIDs looking for the administrator SID.
for (i = 0; i < pGroupInfo->GroupCount; i++) {
if (EqualSid (pSID, pGroupInfo->Groups[i].Sid))
isadmin = 1;
}
if (pSID)
FreeSid (pSID);
if (pGroupInfo)
GlobalFree (pGroupInfo);
return isadmin;
}
typedef void (CALLBACK* PGETNATIVESYSTEMINFO)(LPSYSTEM_INFO);
static PGETNATIVESYSTEMINFO pGetNativeSystemInfo;
static int osdetect (void)
{
os_winnt = 0;
os_winnt_admin = 0;
pGetNativeSystemInfo = (PGETNATIVESYSTEMINFO)GetProcAddress (
GetModuleHandle ("kernel32.dll"), "GetNativeSystemInfo");
GetSystemInfo (&SystemInfo);
if (pGetNativeSystemInfo)
pGetNativeSystemInfo (&SystemInfo);
osVersion.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (GetVersionEx (&osVersion)) {
if ((osVersion.dwPlatformId == VER_PLATFORM_WIN32_NT) &&
(osVersion.dwMajorVersion <= 4)) {
/* WinUAE not supported on this version of Windows... */
// char szWrongOSVersion[MAX_DPATH];
// WIN32GUI_LoadUIString(IDS_WRONGOSVERSION, szWrongOSVersion, MAX_DPATH);
// pre_gui_message(szWrongOSVersion);
return FALSE;
}
if (osVersion.dwPlatformId == VER_PLATFORM_WIN32_NT)
os_winnt = 1;
}
if (!os_winnt) {
return 1;
}
os_winnt_admin = isadminpriv ();
return 1;
}
//int _stdcall WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmd, int show)
int main (int argc, char **argv)
{
// char **argv,
char *posn;
// int argc;
// hInst = hInstance;
// argc = __argc; argv = __argv;
start_path = xmalloc( MAX_DPATH );
GetModuleFileName( NULL, start_path, MAX_DPATH );
if ((posn = strrchr( start_path, '\\')))
*posn = 0;
init_sdl ();
real_main (argc, argv);
xfree (start_path);
return 0;
}
extern FILE *debugfile;
void logging_init (void)
{
static int first;
char debugfilename[MAX_DPATH];
if (first > 1) {
write_log ("** RESTART **\n");
return;
}
if (first == 1) {
if (debugfile)
fclose (debugfile);
debugfile = 0;
}
#ifndef SINGLEFILE
if (currprefs.win32_logfile) {
sprintf (debugfilename, "%swinuaelog.txt", start_path_data);
if (!debugfile)
debugfile = fopen (debugfilename, "wt");
} else if (!first) {
sprintf (debugfilename, "%swinuaebootlog.txt", start_path_data);
if (!debugfile)
debugfile = fopen (debugfilename, "wt");
}
#endif
first++;
// write_log ("%s (%s %d.%d %s%s%s)", VersionStr, os_winnt ? "NT" : "W9X/ME",
// osVersion.dwMajorVersion, osVersion.dwMinorVersion, osVersion.szCSDVersion,
// strlen(osVersion.szCSDVersion) > 0 ? " " : "", os_winnt_admin ? "Admin" : "");
// write_log (" %s %X.%X %d",
// SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL ? "32-bit x86" :
// SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64 ? "IA64" :
// SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ? "AMD64" : "Unknown",
// SystemInfo.wProcessorLevel, SystemInfo.wProcessorRevision,
// SystemInfo.dwNumberOfProcessors);
write_log ("\n(c) 1995-2001 Bernd Schmidt - Core UAE concept and implementation."
"\n(c) 1998-2005 Toni Wilen - Win32 port, core code updates."
"\n(c) 1996-2001 Brian King - Win32 port, Picasso96 RTG, and GUI."
"\n(c) 1996-1999 Mathias Ortmann - Win32 port and bsdsocket support."
"\n(c) 2000-2001 Bernd Meyer - JIT engine."
"\n(c) 2000-2005 Bernd Roesch - MIDI input, many fixes."
"\nPress F12 to show the Settings Dialog (GUI), Alt-F4 to quit."
"\nEnd+F1 changes floppy 0, End+F2 changes floppy 1, etc."
"\n");
// write_log ("EXE: '%s'\nDATA: '%s'\n", start_path_exe, start_path_data);
}
/* dummy to get this thing to build */
void filesys_init (void)
{
}
/*
* Handle target-specific cfgfile options
*/
void target_save_options (FILE *f, const struct uae_prefs *p)
{
}
int target_parse_option (struct uae_prefs *p, const char *option, const char *value)
{
return 0;
}
void target_default_options (struct uae_prefs *p, int type)
{
}

View File

@ -1,29 +0,0 @@
/*
* UAE - The Un*x Amiga Emulator
*
* OS-specific memory support functions
*
* Copyright 2004 Richard Drummond
*/
#include "sysconfig.h"
#include "sysdeps.h"
#include "memory_uae.h"
#ifdef JIT
/*
* Allocate executable memory for JIT cache
*/
void *cache_alloc (int size)
{
return malloc (size);
}
void cache_free (void *cache)
{
xfree (cache);
}
#endif

Some files were not shown because too many files have changed in this diff Show More