From 212f1388ac42965179a01c53fce179a7d33c1e02 Mon Sep 17 00:00:00 2001 From: Mustafa Tufan Date: Thu, 17 Jan 2013 16:11:07 +0200 Subject: [PATCH] puae 2.6.0 --- .gitignore | 135 +- configure.ac | 36 +- release_.sh | 6 +- src/Makefile.am | 12 +- src/a2065.c | 3 - src/a2091.c | 40 +- src/archivers/zip/unzip.h | 2 + src/audio.c | 6 - src/blkdev.c | 54 +- src/blkdev_cdimage.c | 373 ----- src/bsdsocket-posix-new.c | 8 +- src/bsdsocket.c | 36 +- src/cfgfile.c | 501 ++++-- src/compemu_raw_x86.c | 319 +--- src/compemu_support.c | 6 - src/compemu_support_codegen.c | 10 - src/consolehook.c | 9 +- src/cpummu.c | 695 ++++----- src/custom.c | 75 +- src/debug.c | 422 ++--- src/disk.c | 4 - src/drawing.c | 59 +- src/driveclick.c | 2 +- src/enforcer.c | 10 +- src/events.c | 6 +- src/expansion.c | 4 - src/fdi2raw.c | 4 +- src/filesys.asm | 26 +- src/filesys.c | 690 ++++++--- src/filesys_bootrom.c | 1336 ++++++++-------- src/filesys_linux.c | 33 +- src/filesys_unix.c | 1 + src/fpp.c | 31 +- src/fsdb.c | 3 +- src/fsdb_unix.c | 22 +- src/fsusage.c | 35 - src/gayle.c | 140 +- src/genblitter.c | 4 +- src/gencomp.c | 34 +- src/gencpu.c | 496 +++--- src/gfx-amigaos/ami-win.c | 13 - src/gfx-beos/be-Window.cpp | 6 +- src/gfx-cocoa/cocoa_gfx.m | 7 +- src/gfx-curses/ncurses.c | 6 +- src/gfx-sdl/sdlgfx.c | 37 +- src/gfx-svga/svga.c | 2 +- src/gfx-x11/xwin.c | 10 +- src/gui-cocoa/cocoaui.m | 6 +- src/gui-muirexx/ami-gui.c | 3 +- src/gui-qt/puae_mainwindow.cpp | 17 - src/hardfile.c | 525 ++++--- src/hardfile_unix.c | 65 +- src/include/a2091.h | 13 +- src/include/autoconf.h | 4 +- src/include/blitter.h | 1 + src/include/bsdsocket.h | 15 - src/include/cdtv.h | 5 +- src/include/cia.h | 4 +- src/include/cpummu.h | 548 +++++-- src/include/custom.h | 4 + src/include/debug.h | 5 + src/include/disk.h | 4 - src/include/drawing.h | 6 +- src/include/events.h | 3 - src/include/filesys.h | 51 +- src/include/fsdb.h | 8 - src/include/gayle.h | 4 +- src/include/gfxfilter.h | 3 +- src/include/gui.h | 1 + src/include/inputdevice.h | 20 +- src/include/newcpu.h | 45 +- src/include/options.h | 64 +- src/include/picasso96.h | 15 +- src/include/sana2.h | 2 - src/include/scsidev.h | 12 - src/include/serial.h | 4 - src/include/sleep.h | 24 +- src/include/sysdeps.h | 55 - src/include/uaeserial.h | 8 - src/include/xwin.h | 7 - src/include/zfile.h | 2 +- src/inputdevice.c | 89 +- src/inputrecord.c | 10 +- src/keymap/keymap.c | 22 +- src/keymap/keymap.h | 3 - src/main.c | 42 +- src/memory.c | 41 +- src/misc.c | 783 +--------- src/misc.h | 11 +- src/newcpu.c | 1109 +++++++++----- src/od-amiga/main.c | 7 - src/od-linux/blkdev-linux.c | 3 +- src/od-macosx/main.m | 4 - src/od-win32/Makefile.am | 11 - src/od-win32/bsdsock.c | 2624 -------------------------------- src/od-win32/fsdb_win32.c | 228 --- src/od-win32/hardfile_win32.c | 789 ---------- src/od-win32/hrtimer.h | 30 - src/od-win32/main.c | 246 --- src/od-win32/memory.c | 29 - src/od-win32/memory_uae.h | 11 - src/od-win32/posixemu.c | 78 - src/od-win32/posixemu.h | 17 - src/od-win32/win32.h | 10 - src/od-win32/writelog.c | 131 -- src/picasso96.c | 31 +- src/sana2.c | 60 - src/savestate.c | 64 +- src/scsi.c | 68 +- src/statusline.c | 27 +- src/targets/t-win32.h | 25 - src/td-win32/Makefile.am | 10 - src/td-win32/thread.c | 65 - src/td-win32/thread.h | 31 - src/tools/sysconfig.h.in | 342 +---- src/uaelib.c | 8 - src/writelog.c | 57 +- src/zfile.c | 303 ++-- src/zfile_archive.c | 16 +- 119 files changed, 4726 insertions(+), 10031 deletions(-) delete mode 100644 src/od-win32/Makefile.am delete mode 100644 src/od-win32/bsdsock.c delete mode 100644 src/od-win32/fsdb_win32.c delete mode 100644 src/od-win32/hardfile_win32.c delete mode 100644 src/od-win32/hrtimer.h delete mode 100644 src/od-win32/main.c delete mode 100644 src/od-win32/memory.c delete mode 100644 src/od-win32/memory_uae.h delete mode 100644 src/od-win32/posixemu.c delete mode 100644 src/od-win32/posixemu.h delete mode 100644 src/od-win32/win32.h delete mode 100644 src/od-win32/writelog.c delete mode 100644 src/targets/t-win32.h delete mode 100644 src/td-win32/Makefile.am delete mode 100644 src/td-win32/thread.c delete mode 100644 src/td-win32/thread.h diff --git a/.gitignore b/.gitignore index 9a1b926..5c8b3e7 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/configure.ac b/configure.ac index c953185..8270f17 100644 --- a/configure.ac +++ b/configure.ac @@ -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) diff --git a/release_.sh b/release_.sh index a6246e0..79bc3e5 100755 --- a/release_.sh +++ b/release_.sh @@ -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 diff --git a/src/Makefile.am b/src/Makefile.am index 6b88275..c2d1a23 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 diff --git a/src/a2065.c b/src/a2065.c index 0f99938..e704429 100644 --- a/src/a2065.c +++ b/src/a2065.c @@ -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" diff --git a/src/a2091.c b/src/a2091.c index 24bccf1..666ef69 100644 --- a/src/a2091.c +++ b/src/a2091.c @@ -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 ()) diff --git a/src/archivers/zip/unzip.h b/src/archivers/zip/unzip.h index 864a85f..e3a7052 100755 --- a/src/archivers/zip/unzip.h +++ b/src/archivers/zip/unzip.h @@ -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) diff --git a/src/audio.c b/src/audio.c index 019b339..c133c80 100644 --- a/src/audio.c +++ b/src/audio.c @@ -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; diff --git a/src/blkdev.c b/src/blkdev.c index b1841a3..e4a855c 100644 --- a/src/blkdev.c +++ b/src/blkdev.c @@ -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)) { diff --git a/src/blkdev_cdimage.c b/src/blkdev_cdimage.c index c750f04..dd09791 100644 --- a/src/blkdev_cdimage.c +++ b/src/blkdev_cdimage.c @@ -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, §or); - 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, §or); - 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) { diff --git a/src/bsdsocket-posix-new.c b/src/bsdsocket-posix-new.c index 0120f94..7a2fb9d 100644 --- a/src/bsdsocket-posix-new.c +++ b/src/bsdsocket-posix-new.c @@ -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); diff --git a/src/bsdsocket.c b/src/bsdsocket.c index d5d6b83..e3a53b0 100644 --- a/src/bsdsocket.c +++ b/src/bsdsocket.c @@ -29,10 +29,6 @@ int log_bsd; -#ifdef WIN32 -# include -#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) { diff --git a/src/cfgfile.c b/src/cfgfile.c index 695bd3c..ffa4233 100644 --- a/src/cfgfile.c +++ b/src/cfgfile.c @@ -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; diff --git a/src/compemu_raw_x86.c b/src/compemu_raw_x86.c index 369a887..fae3b22 100644 --- a/src/compemu_raw_x86.c +++ b/src/compemu_raw_x86.c @@ -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 -#else #ifndef __USE_GNU #define __USE_GNU -#endif #include #endif #include @@ -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 * diff --git a/src/compemu_support.c b/src/compemu_support.c index ccfcfbc..7a948ea 100644 --- a/src/compemu_support.c +++ b/src/compemu_support.c @@ -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++) { diff --git a/src/compemu_support_codegen.c b/src/compemu_support_codegen.c index 35df4db..9ec0c35 100644 --- a/src/compemu_support_codegen.c +++ b/src/compemu_support_codegen.c @@ -49,11 +49,9 @@ /* kludge for Brian, so he can compile under MSVC++ */ #define USE_NORMAL_CALLING_CONVENTION 0 -#ifndef WIN32 #include #include #include -#endif #include #include @@ -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 { \ diff --git a/src/consolehook.c b/src/consolehook.c index c2dc7cf..da3a77a 100644 --- a/src/consolehook.c +++ b/src/consolehook.c @@ -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) diff --git a/src/cpummu.c b/src/cpummu.c index 97c1570..7661361 100644 --- a/src/cpummu.c +++ b/src/cpummu.c @@ -23,34 +23,26 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#define DEBUG 0 -#define USETAG 0 #include "sysconfig.h" #include "sysdeps.h" -#include "options.h" #include "memory_uae.h" +#include "options.h" #include "newcpu.h" -#include "debug.h" #include "cpummu.h" -static void REGPARAM3 mmu_flush_atc(uaecptr addr, bool super, bool global) REGPARAM; -static void REGPARAM3 mmu_flush_atc_all(bool global) REGPARAM; - #define DBG_MMU_VERBOSE 1 #define DBG_MMU_SANITY 1 #ifdef FULLMMU -mmu_atc_l1_array atc_l1[2]; -mmu_atc_l1_array *current_atc; -static struct mmu_atc_line atc_l2[2][ATC_L2_SIZE]; - -#ifdef ATC_STATS -static unsigned int mmu_atc_hits[ATC_L2_SIZE]; -#endif +uae_u32 mmu_is_super; +uae_u32 mmu_tagmask, mmu_pagemask; +struct mmu_atc_line mmu_atc_array[ATC_TYPE][ATC_WAYS][ATC_SLOTS]; +int mmu060_state; +bool mmu_pagesize_8k; static void mmu_dump_ttr(const TCHAR * label, uae_u32 ttr) { @@ -60,14 +52,17 @@ static void mmu_dump_ttr(const TCHAR * label, uae_u32 ttr) from_addr = ttr & MMU_TTR_LOGICAL_BASE; to_addr = (ttr & MMU_TTR_LOGICAL_MASK) << 8; - D(bug(_T("%s: [%08lx] %08lx - %08lx enabled=%d supervisor=%d wp=%d cm=%02d\n"), + +#if MMUDEBUG > 0 + write_log(_T("%s: [%08lx] %08lx - %08lx enabled=%d supervisor=%d wp=%d cm=%02d\n"), label, ttr, from_addr, to_addr, ttr & MMU_TTR_BIT_ENABLED ? 1 : 0, (ttr & (MMU_TTR_BIT_SFIELD_ENABLED | MMU_TTR_BIT_SFIELD_SUPER)) >> MMU_TTR_SFIELD_SHIFT, ttr & MMU_TTR_BIT_WRITE_PROTECT ? 1 : 0, (ttr & MMU_TTR_CACHE_MASK) >> MMU_TTR_CACHE_SHIFT - )); + ); +#endif } void mmu_make_transparent_region(uaecptr baseaddr, uae_u32 size, int datamode) @@ -87,49 +82,14 @@ void mmu_make_transparent_region(uaecptr baseaddr, uae_u32 size, int datamode) *ttr |= ((baseaddr + size - 1) & MMU_TTR_LOGICAL_BASE) >> 8; *ttr |= MMU_TTR_BIT_ENABLED; - D(bug(_T("MMU: map transparent mapping of %08x\n"), *ttr)); +#if MMUDEBUG > 0 + write_log(_T("MMU: map transparent mapping of %08x\n"), *ttr); +#endif } -/* check if an address matches a ttr */ -static 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; -} - -#if DEBUG +#if 0 /* {{{ mmu_dump_table */ static void mmu_dump_table(const char * label, uaecptr root_ptr) { @@ -145,7 +105,7 @@ static void mmu_dump_table(const char * label, uaecptr root_ptr) uaecptr ptr_des_addr, page_addr, root_log, ptr_log, page_log; - D(bug(_T("%s: root=%lx\n"), label, root_ptr)); + write_log(_T("%s: root=%lx\n", label, root_ptr); for (root_idx = 0; root_idx < ROOT_TABLE_SIZE; root_idx++) { root_des = phys_get_long(root_ptr + root_idx); @@ -153,11 +113,11 @@ static void mmu_dump_table(const char * label, uaecptr root_ptr) if ((root_des & 2) == 0) continue; /* invalid */ - D(bug(_T("ROOT: %03d U=%d W=%d UDT=%02d\n"), root_idx, + write_log(_T("ROOT: %03d U=%d W=%d UDT=%02d\n", root_idx, root_des & 8 ? 1 : 0, root_des & 4 ? 1 : 0, root_des & 3 - )); + ); root_log = root_idx << ROOT_INDEX_SHIFT; @@ -177,7 +137,7 @@ static void mmu_dump_table(const char * label, uaecptr root_ptr) if ((ptr_des & 2) == 0) continue; /* invalid */ - page_addr = ptr_des & (regs.mmu_pagesize_8k ? MMU_PTR_PAGE_ADDR_MASK_8 : MMU_PTR_PAGE_ADDR_MASK_4); + page_addr = ptr_des & (mmu_pagesize_8k ? MMU_PTR_PAGE_ADDR_MASK_8 : MMU_PTR_PAGE_ADDR_MASK_4); n_pages_used = -1; for (page_idx = 0; page_idx < PAGE_TABLE_SIZE; page_idx++) { @@ -208,31 +168,31 @@ static void mmu_dump_table(const char * label, uaecptr root_ptr) if (n_pages_used == -1) continue; - D(bug(_T(" PTR: %03d U=%d W=%d UDT=%02d\n"), ptr_idx, + write_log(_T(" PTR: %03d U=%d W=%d UDT=%02d\n", ptr_idx, ptr_des & 8 ? 1 : 0, ptr_des & 4 ? 1 : 0, ptr_des & 3 - )); + ); for (page_idx = 0; page_idx <= n_pages_used; page_idx++) { page_des = page_info[page_idx].match; if ((page_des & MMU_PDT_MASK) == 2) { - D(bug(_T(" PAGE: %03d-%03d log=%08lx INDIRECT --> addr=%08lx\n"), + write_log(_T(" PAGE: %03d-%03d log=%08lx INDIRECT --> addr=%08lx\n", page_info[page_idx].start_idx, page_info[page_idx].start_idx + page_info[page_idx].n_pages - 1, page_info[page_idx].log, page_des & MMU_PAGE_INDIRECT_MASK - )); + ); } else { - D(bug(_T(" PAGE: %03d-%03d log=%08lx addr=%08lx UR=%02d G=%d U1/0=%d S=%d CM=%d M=%d U=%d W=%d\n"), + write_log(_T(" PAGE: %03d-%03d log=%08lx addr=%08lx UR=%02d G=%d U1/0=%d S=%d CM=%d M=%d U=%d W=%d\n", page_info[page_idx].start_idx, page_info[page_idx].start_idx + page_info[page_idx].n_pages - 1, page_info[page_idx].log, - page_des & (regs.mmu_pagesize_8k ? MMU_PAGE_ADDR_MASK_8 : MMU_PAGE_ADDR_MASK_4), - (page_des & (regs.mmu_pagesize_8k ? MMU_PAGE_UR_MASK_8 : MMU_PAGE_UR_MASK_4)) >> MMU_PAGE_UR_SHIFT, + page_des & (mmu_pagesize_8k ? MMU_PAGE_ADDR_MASK_8 : MMU_PAGE_ADDR_MASK_4), + (page_des & (mmu_pagesize_8k ? MMU_PAGE_UR_MASK_8 : MMU_PAGE_UR_MASK_4)) >> MMU_PAGE_UR_SHIFT, page_des & MMU_DES_GLOBAL ? 1 : 0, (page_des & MMU_TTR_UX_MASK) >> MMU_TTR_UX_SHIFT, page_des & MMU_DES_SUPER ? 1 : 0, @@ -240,7 +200,7 @@ static void mmu_dump_table(const char * label, uaecptr root_ptr) page_des & MMU_DES_MODIFIED ? 1 : 0, page_des & MMU_DES_USED ? 1 : 0, page_des & MMU_DES_WP ? 1 : 0 - )); + ); } } } @@ -253,119 +213,122 @@ static void mmu_dump_table(const char * label, uaecptr root_ptr) /* {{{ mmu_dump_atc */ void mmu_dump_atc(void) { - int i, j; - for (i = 0; i < 2; i++) { - for (j = 0; j < ATC_L2_SIZE; j++) { - if (atc_l2[i][j].tag == 0x8000) - continue; - D(bug(_T("ATC[%02d] G=%d TT=%d M=%d WP=%d VD=%d VI=%d tag=%08x --> phys=%08x\n"), - j, atc_l2[i][j].global, atc_l2[i][j].tt, atc_l2[i][j].modified, - atc_l2[i][j].write_protect, atc_l2[i][j].valid_data, atc_l2[i][j].valid_inst, - atc_l2[i][j].tag, atc_l2[i][j].phys)); - } - } + } /* }}} */ /* {{{ mmu_dump_tables */ void mmu_dump_tables(void) { - D(bug(_T("URP: %08x SRP: %08x MMUSR: %x TC: %x\n"), regs.urp, regs.srp, regs.mmusr, regs.tcr)); + write_log(_T("URP: %08x SRP: %08x MMUSR: %x TC: %x\n"), regs.urp, regs.srp, regs.mmusr, regs.tcr); mmu_dump_ttr(_T("DTT0"), regs.dtt0); mmu_dump_ttr(_T("DTT1"), regs.dtt1); mmu_dump_ttr(_T("ITT0"), regs.itt0); mmu_dump_ttr(_T("ITT1"), regs.itt1); mmu_dump_atc(); -#if DEBUG - mmu_dump_table("SRP", regs.srp); +#if MMUDEBUG + // mmu_dump_table("SRP", regs.srp); #endif } /* }}} */ -static uaecptr REGPARAM2 mmu_lookup_pagetable(uaecptr addr, bool super, bool write); +static uaecptr REGPARAM2 mmu_lookup_pagetable(uaecptr addr, bool super, bool write, uae_u32 *status); static ALWAYS_INLINE int mmu_get_fc(bool super, bool data) { return (super ? 4 : 0) | (data ? 1 : 2); } -static void mmu_bus_error(uaecptr addr, int fc, bool write, int size) +static void mmu_bus_error(uaecptr addr, int fc, bool write, int size, uae_u32 status) { - uae_u16 ssw = 0; + if (currprefs.mmu_model == 68040) { + uae_u16 ssw = 0; + + ssw |= fc & MMU_SSW_TM; /* Copy TM */ + switch (size) { + case sz_byte: + ssw |= MMU_SSW_SIZE_B; + break; + case sz_word: + ssw |= MMU_SSW_SIZE_W; + break; + case sz_long: + ssw |= MMU_SSW_SIZE_L; + break; + } + + regs.wb3_status = write ? 0x80 | ssw : 0; + if (!write) + ssw |= MMU_SSW_RW; + + regs.mmu_ssw = ssw | MMU_SSW_ATC; + +#if MMUDEBUG > 2 + write_log(_T("040 BUS ERROR: fc=%d w=%d logical=%08x ssw=%04x PC=%08x\n"), fc, write, addr, ssw, m68k_getpc()); +#endif + } else { + uae_u32 fslw = 0; + + fslw |= write ? MMU_FSLW_W : MMU_FSLW_R; + switch (size) { + case sz_byte: + fslw |= MMU_FSLW_SIZE_B; + break; + case sz_word: + fslw |= MMU_FSLW_SIZE_W; + break; + case sz_long: + fslw |= MMU_FSLW_SIZE_L; + break; + case 16: // MOVE16 + addr &= ~15; + fslw |= MMU_FSLW_SIZE_D; + break; + } + if (mmu060_state == 0) { + fslw |= MMU_FSLW_IO; // opword fetch + } else if ((fc & 2)) { + fslw |= MMU_FSLW_IO | MMU_FSLW_MA; // extension word + } + fslw |= status; + regs.mmu_fslw = fslw; + +#if MMUDEBUG > 2 + write_log(_T("060 BUS ERROR: fc=%d w=%d logical=%08x ssw=%08x PC=%08x\n"), fc, write, addr, fslw, m68k_getpc()); +#endif - ssw |= fc & MMU_SSW_TM; /* Copy TM */ - switch (size) { - case sz_byte: - ssw |= MMU_SSW_SIZE_B; - break; - case sz_word: - ssw |= MMU_SSW_SIZE_W; - break; - case sz_long: - ssw |= MMU_SSW_SIZE_L; - break; } - regs.wb3_status = write ? 0x80 | ssw : 0; - if (!write) - ssw |= MMU_SSW_RW; - regs.mmu_fault_addr = addr; - regs.mmu_ssw = ssw | MMU_SSW_ATC; - - D(bug(_T("BUS ERROR: fc=%d w=%d log=%08x ssw=%04x PC=%08x\n"), fc, write, addr, ssw, m68k_getpc())); - - //write_log(_T("BUS ERROR: fc=%d w=%d log=%08x ssw=%04x PC=%08x\n"), fc, write, addr, ssw, m68k_getpc()); - //activate_debugger(); THROW(2); } +void mmu_bus_error_ttr_write_fault(uaecptr addr, bool super, bool data, uae_u32 val, int size) +{ + uae_u32 status = 0; + + if (currprefs.mmu_model == 68060) { + status |= MMU_FSLW_TTR; + } + regs.wb3_data = val; + mmu_bus_error(addr, mmu_get_fc (super, data), true, size, status); + } + + /* * Update the atc line for a given address by doing a mmu lookup. */ -static uaecptr mmu_fill_atc_l2(uaecptr addr, bool super, bool data, bool write, struct mmu_atc_line *l) +static uaecptr mmu_fill_atc(uaecptr addr, bool super, bool data, bool write, struct mmu_atc_line *l, uae_u32 *status) { - int res; uae_u32 desc; - l->tag = ATC_TAG(addr); - l->hw = l->bus_fault = 0; - - /* check ttr0 */ - res = mmu_match_ttr(addr, super, data); - if (res != TTR_NO_MATCH) { - l->tt = 1; - if (data) { - l->valid_data = 1; - l->valid_inst = mmu_match_ttr(addr, super, 0) == res; - } else { - l->valid_inst = 1; - l->valid_data = mmu_match_ttr(addr, super, 1) == res; - } - l->global = 1; - l->modified = 1; - l->write_protect = (res == TTR_NO_WRITE); - l->phys = 0; - - return 0; - } - - l->tt = 0; - if (!regs.mmu_enabled) { - l->valid_data = l->valid_inst = 1; - l->global = 1; - l->modified = 1; - l->write_protect = 0; - l->phys = 0; - return 0; - } - + *status = 0; SAVE_EXCEPTION; TRY(prb) { - desc = mmu_lookup_pagetable(addr, super, write); -#if DEBUG > 2 - D(bug(_T("translate: %x,%u,%u,%u -> %x\n"), addr, super, write, data, desc)); + desc = mmu_lookup_pagetable(addr, super, write, status); +#if MMUDEBUG > 2 + write_log(_T("translate: %x,%u,%u,%u -> %x\n"), addr, super, write, data, desc); #endif RESTORE_EXCEPTION; } @@ -373,19 +336,22 @@ static uaecptr mmu_fill_atc_l2(uaecptr addr, bool super, bool data, bool write, RESTORE_EXCEPTION; /* bus error during table search */ desc = 0; - goto fail; - } - - if ((desc & 1) == 0 || (!super && desc & MMU_MMUSR_S)) { -fail: - l->valid_data = l->valid_inst = 0; + *status = MMU_FSLW_TWE; + // goto fail; + } ENDTRY + if ((desc & 1) && (!super && desc & MMU_MMUSR_S)) { + *status |= MMU_FSLW_SP; + l->valid = 0; + l->global = 0; + } else if ((desc & 1) == 0) { + l->valid = 0; l->global = 0; } else { - l->valid_data = l->valid_inst = 1; - if (regs.mmu_pagesize_8k) - l->phys = (desc & ~0x1fff) - (addr & ~0x1fff); + l->valid = 1; + if (mmu_pagesize_8k) + l->phys = (desc & ~0x1fff); else - l->phys = (desc & ~0xfff) - (addr & ~0xfff); + l->phys = (desc & ~0xfff); l->global = (desc & MMU_MMUSR_G) != 0; l->modified = (desc & MMU_MMUSR_M) != 0; l->write_protect = (desc & MMU_MMUSR_W) != 0; @@ -394,64 +360,50 @@ fail: return desc; } -static ALWAYS_INLINE bool mmu_fill_atc_l1(uaecptr addr, bool super, bool data, bool write, struct mmu_atc_line *l1) +static ALWAYS_INLINE bool mmu_fill_atc_try(uaecptr addr, bool super, bool data, bool write, struct mmu_atc_line *l1, uae_u32 *status) { - int idx = ATC_L2_INDEX(addr); - int tag = ATC_TAG(addr); - struct mmu_atc_line *l = &atc_l2[super ? 1 : 0][idx]; - - if (l->tag != tag) { -restart: - mmu_fill_atc_l2(addr, super, data, write, l); - } - if (!(data ? l->valid_data : l->valid_inst)) { - D(bug(_T("MMU: non-resident page (%x,%x,%x)!\n"), addr, regs.pc, regs.instruction_pc)); + mmu_fill_atc(addr,super,data,write,l1, status); + if (!(l1->valid)) { +#if MMUDEBUG > 1 + write_log(_T("MMU: non-resident page (%x,%x)!\n"), addr, regs.pc); +#endif goto fail; } if (write) { - if (l->write_protect) { - D(bug(_T("MMU: write protected (via %s) %lx\n"), l->tt ? "ttr" : "atc", addr)); - goto fail; - } - if (!l->modified) - goto restart; - } - *l1 = *l; -#if 0 - uaecptr phys_addr = addr + l1->phys; - if ((phys_addr & 0xfff00000) == 0x00f00000) { - l1->hw = 1; - goto fail; - } - if ((phys_addr & 0xfff00000) == 0xfff00000) { - l1->hw = 1; - l1->phys -= 0xff000000; + if (l1->write_protect) { + *status |= MMU_FSLW_WP; +#if MMUDEBUG > 1 + write_log(_T("MMU: write protected %lx by atc \n"), addr); +#endif + mmu_dump_atc(); goto fail; } - if (!test_ram_boundary(phys_addr, 1, super, write)) { - l1->bus_fault = 1; - goto fail; } -#endif return true; fail: - l1->tag = ~l1->tag; return false; } uaecptr REGPARAM2 mmu_translate(uaecptr addr, bool super, bool data, bool write) { struct mmu_atc_line *l; + uae_u32 status; - l = &atc_l2[super ? 1 : 0][ATC_L2_INDEX(addr)]; - mmu_fill_atc_l2(addr, super, data, write, l); - if (!(data ? l->valid_data : l->valid_inst)) { + // this should return a miss but choose a valid line + mmu_user_lookup(addr, super, data, write, &l); + + mmu_fill_atc(addr, super, data, write, l, &status); + if (!l->valid) { +#if MMUDEBUG > 0 + write_log(_T("[MMU] mmu_translate error")); +#endif THROW(2); } - return addr + l->phys; + return l->phys | (addr & (mmu_pagesize_8k?0x00001fff:0x00000fff)); + } /* @@ -459,7 +411,7 @@ uaecptr REGPARAM2 mmu_translate(uaecptr addr, bool super, bool data, bool write) * the page descriptors accordingly. Returns the found descriptor * or produces a bus error. */ -static uaecptr REGPARAM2 mmu_lookup_pagetable(uaecptr addr, bool super, bool write) +static uaecptr REGPARAM2 mmu_lookup_pagetable(uaecptr addr, bool super, bool write, uae_u32 *status) { uae_u32 desc, desc_addr, wp; int i; @@ -472,7 +424,11 @@ static uaecptr REGPARAM2 mmu_lookup_pagetable(uaecptr addr, bool super, bool wri desc_addr = (desc & MMU_ROOT_PTR_ADDR_MASK) | i; desc = phys_get_long(desc_addr); if ((desc & 2) == 0) { - D(bug(_T("MMU: invalid root descriptor for %lx\n"), addr)); +#if MMUDEBUG > 1 + write_log(_T("MMU: invalid root descriptor %s for %x desc at %x desc=%x %s at %d\n"), super ? _T("srp"):_T("urp"), + addr,desc_addr,desc,__FILE__,__LINE__); +#endif + *status |= MMU_FSLW_PTA; return 0; } @@ -485,7 +441,11 @@ static uaecptr REGPARAM2 mmu_lookup_pagetable(uaecptr addr, bool super, bool wri desc_addr = (desc & MMU_ROOT_PTR_ADDR_MASK) | i; desc = phys_get_long(desc_addr); if ((desc & 2) == 0) { - D(bug(_T("MMU: invalid ptr descriptor for %lx\n"), addr)); +#if MMUDEBUG > 1 + write_log(_T("MMU: invalid ptr descriptor %s for %x desc at %x desc=%x %s at %d\n"), super ? _T("srp"):_T("urp"), + addr,desc_addr,desc,__FILE__,__LINE__); +#endif + *status |= MMU_FSLW_PTB; return 0; } wp |= desc; @@ -493,12 +453,12 @@ static uaecptr REGPARAM2 mmu_lookup_pagetable(uaecptr addr, bool super, bool wri phys_put_long(desc_addr, desc | MMU_DES_USED); /* fetch page table descriptor */ - if (regs.mmu_pagesize_8k) { + if (mmu_pagesize_8k) { i = (addr >> 11) & 0x7c; - desc_addr = (desc & MMU_PTR_PAGE_ADDR_MASK_8) | i; + desc_addr = (desc & MMU_PTR_PAGE_ADDR_MASK_8) + i; } else { i = (addr >> 10) & 0xfc; - desc_addr = (desc & MMU_PTR_PAGE_ADDR_MASK_4) | i; + desc_addr = (desc & MMU_PTR_PAGE_ADDR_MASK_4) + i; } desc = phys_get_long(desc_addr); @@ -508,7 +468,13 @@ static uaecptr REGPARAM2 mmu_lookup_pagetable(uaecptr addr, bool super, bool wri desc = phys_get_long(desc_addr); } if ((desc & 1) == 0) { - D(bug(_T("MMU: invalid page descriptor log=%08lx desc=%08lx @%08lx\n"), addr, desc, desc_addr)); +#if MMUDEBUG > 1 + write_log(_T("MMU: invalid page descriptor log=%0lx desc=%08x @%08x %s at %d\n"), addr, desc, desc_addr,__FILE__,__LINE__); +#endif + if ((desc & 3) == 2) + *status |= MMU_FSLW_IL; + else + *status |= MMU_FSLW_PF; return desc; } @@ -546,9 +512,10 @@ uae_u16 REGPARAM2 mmu_get_word_unaligned(uaecptr addr, bool data) CATCH(prb) { RESTORE_EXCEPTION; regs.mmu_fault_addr = addr; + regs.mmu_fslw |= MMU_FSLW_MA; regs.mmu_ssw |= MMU_SSW_MA; THROW_AGAIN(prb); - } + } ENDTRY return res; } @@ -568,7 +535,7 @@ uae_u32 REGPARAM2 mmu_get_long_unaligned(uaecptr addr, bool data) regs.mmu_fault_addr = addr; regs.mmu_ssw |= MMU_SSW_MA; THROW_AGAIN(prb); - } + } ENDTRY } else { res = (uae_u32)mmu_get_byte(addr, data, sz_long) << 8; SAVE_EXCEPTION; @@ -581,9 +548,10 @@ uae_u32 REGPARAM2 mmu_get_long_unaligned(uaecptr addr, bool data) CATCH(prb) { RESTORE_EXCEPTION; regs.mmu_fault_addr = addr; + regs.mmu_fslw |= MMU_FSLW_MA; regs.mmu_ssw |= MMU_SSW_MA; THROW_AGAIN(prb); - } + } ENDTRY } return res; } @@ -591,57 +559,33 @@ uae_u32 REGPARAM2 mmu_get_long_unaligned(uaecptr addr, bool data) uae_u8 REGPARAM2 mmu_get_byte_slow(uaecptr addr, bool super, bool data, int size, struct mmu_atc_line *cl) { - uae_u32 tag = ATC_TAG(addr); - - if (USETAG && cl->tag == (uae_u16)~tag) { -redo: - if (cl->hw) - return HWget_b(cl->phys + addr); - mmu_bus_error(addr, mmu_get_fc(super, data), 0, size); + uae_u32 status; + if (!mmu_fill_atc_try(addr, super, data, 0, cl, &status)) { + mmu_bus_error(addr, mmu_get_fc(super, data), 0, size, status); return 0; } - - if (!mmu_fill_atc_l1(addr, super, data, 0, cl)) - goto redo; - return phys_get_byte(mmu_get_real_address(addr, cl)); } uae_u16 REGPARAM2 mmu_get_word_slow(uaecptr addr, bool super, bool data, int size, struct mmu_atc_line *cl) { - uae_u32 tag = ATC_TAG(addr); - - if (USETAG && cl->tag == (uae_u16)~tag) { -redo: - if (cl->hw) - return HWget_w(cl->phys + addr); - mmu_bus_error(addr, mmu_get_fc(super, data), 0, size); + uae_u32 status; + if (!mmu_fill_atc_try(addr, super, data, 0, cl, &status)) { + mmu_bus_error(addr, mmu_get_fc(super, data), 0, size, status); return 0; } - - if (!mmu_fill_atc_l1(addr, super, data, 0, cl)) - goto redo; - return phys_get_word(mmu_get_real_address(addr, cl)); } uae_u32 REGPARAM2 mmu_get_long_slow(uaecptr addr, bool super, bool data, int size, struct mmu_atc_line *cl) { - uae_u32 tag = ATC_TAG(addr); - - if (USETAG && cl->tag == (uae_u16)~tag) { -redo: - if (cl->hw) - return HWget_l(cl->phys + addr); - mmu_bus_error(addr, mmu_get_fc(super, data), 0, size); + uae_u32 status; + if (!mmu_fill_atc_try(addr, super, data, 0, cl, &status)) { + mmu_bus_error(addr, mmu_get_fc(super, data), 0, size, status); return 0; } - - if (!mmu_fill_atc_l1(addr, super, data, 0, cl)) - goto redo; - return phys_get_long(mmu_get_real_address(addr, cl)); } @@ -665,10 +609,11 @@ void REGPARAM2 mmu_put_long_unaligned(uaecptr addr, uae_u32 val, bool data) regs.wb3_data = val; if (regs.mmu_fault_addr != addr) { regs.mmu_fault_addr = addr; + regs.mmu_fslw |= MMU_FSLW_MA; regs.mmu_ssw |= MMU_SSW_MA; } THROW_AGAIN(prb); - } + } ENDTRY } void REGPARAM2 mmu_put_word_unaligned(uaecptr addr, uae_u16 val, bool data) @@ -684,75 +629,46 @@ void REGPARAM2 mmu_put_word_unaligned(uaecptr addr, uae_u16 val, bool data) regs.wb3_data = val; if (regs.mmu_fault_addr != addr) { regs.mmu_fault_addr = addr; + regs.mmu_fslw |= MMU_FSLW_MA; regs.mmu_ssw |= MMU_SSW_MA; } THROW_AGAIN(prb); - } + } ENDTRY } void REGPARAM2 mmu_put_byte_slow(uaecptr addr, uae_u8 val, bool super, bool data, int size, struct mmu_atc_line *cl) { - uae_u32 tag = ATC_TAG(addr); - - if (USETAG && cl->tag == (uae_u16)~tag) { -redo: - if (cl->hw) { - HWput_b(cl->phys + addr, val); - return; - } + uae_u32 status; + if (!mmu_fill_atc_try(addr, super, data, 1, cl, &status)) { regs.wb3_data = val; - mmu_bus_error(addr, mmu_get_fc(super, data), 1, size); + mmu_bus_error(addr, mmu_get_fc(super, data), 1, size, status); return; } - - if (!mmu_fill_atc_l1(addr, super, data, 1, cl)) - goto redo; - phys_put_byte(mmu_get_real_address(addr, cl), val); } void REGPARAM2 mmu_put_word_slow(uaecptr addr, uae_u16 val, bool super, bool data, int size, struct mmu_atc_line *cl) { - uae_u32 tag = ATC_TAG(addr); - - if (USETAG && cl->tag == (uae_u16)~tag) { -redo: - if (cl->hw) { - HWput_w(cl->phys + addr, val); - return; - } + uae_u32 status; + if (!mmu_fill_atc_try(addr, super, data, 1, cl, &status)) { regs.wb3_data = val; - mmu_bus_error(addr, mmu_get_fc(super, data), 1, size); + mmu_bus_error(addr, mmu_get_fc(super, data), 1, size, status); return; } - - if (!mmu_fill_atc_l1(addr, super, data, 1, cl)) - goto redo; - phys_put_word(mmu_get_real_address(addr, cl), val); } void REGPARAM2 mmu_put_long_slow(uaecptr addr, uae_u32 val, bool super, bool data, int size, struct mmu_atc_line *cl) { - uae_u32 tag = ATC_TAG(addr); - - if (USETAG && cl->tag == (uae_u16)~tag) { -redo: - if (cl->hw) { - HWput_l(cl->phys + addr, val); - return; - } + uae_u32 status; + if (!mmu_fill_atc_try(addr, super, data, 1, cl, &status)) { regs.wb3_data = val; - mmu_bus_error(addr, mmu_get_fc(super, data), 1, size); + mmu_bus_error(addr, mmu_get_fc(super, data), 1, size, status); return; } - - if (!mmu_fill_atc_l1(addr, super, data, 1, cl)) - goto redo; - phys_put_long(mmu_get_real_address(addr, cl), val); } @@ -775,9 +691,10 @@ uae_u32 REGPARAM2 sfc_get_long(uaecptr addr) CATCH(prb) { RESTORE_EXCEPTION; regs.mmu_fault_addr = addr; + regs.mmu_fslw |= MMU_FSLW_MA; regs.mmu_ssw |= MMU_SSW_MA; THROW_AGAIN(prb); - } + } ENDTRY } else { res = (uae_u32)mmu_get_user_byte(addr, super, data, sz_long) << 8; SAVE_EXCEPTION; @@ -790,9 +707,10 @@ uae_u32 REGPARAM2 sfc_get_long(uaecptr addr) CATCH(prb) { RESTORE_EXCEPTION; regs.mmu_fault_addr = addr; + regs.mmu_fslw |= MMU_FSLW_MA; regs.mmu_ssw |= MMU_SSW_MA; THROW_AGAIN(prb); - } + } ENDTRY } return res; } @@ -815,9 +733,10 @@ uae_u16 REGPARAM2 sfc_get_word(uaecptr addr) CATCH(prb) { RESTORE_EXCEPTION; regs.mmu_fault_addr = addr; + regs.mmu_fslw |= MMU_FSLW_MA; regs.mmu_ssw |= MMU_SSW_MA; THROW_AGAIN(prb); - } + } ENDTRY return res; } @@ -854,10 +773,11 @@ void REGPARAM2 dfc_put_long(uaecptr addr, uae_u32 val) regs.wb3_data = val; if (regs.mmu_fault_addr != addr) { regs.mmu_fault_addr = addr; + regs.mmu_fslw |= MMU_FSLW_MA; regs.mmu_ssw |= MMU_SSW_MA; } THROW_AGAIN(prb); - } + } ENDTRY } void REGPARAM2 dfc_put_word(uaecptr addr, uae_u16 val) @@ -880,10 +800,11 @@ void REGPARAM2 dfc_put_word(uaecptr addr, uae_u16 val) regs.wb3_data = val; if (regs.mmu_fault_addr != addr) { regs.mmu_fault_addr = addr; + regs.mmu_fslw |= MMU_FSLW_MA; regs.mmu_ssw |= MMU_SSW_MA; } THROW_AGAIN(prb); - } + } ENDTRY } void REGPARAM2 dfc_put_byte(uaecptr addr, uae_u8 val) @@ -900,14 +821,14 @@ void REGPARAM2 dfc_put_byte(uaecptr addr, uae_u8 val) RESTORE_EXCEPTION; regs.wb3_data = val; THROW_AGAIN(prb); - } + } ENDTRY } void REGPARAM2 mmu_op_real(uae_u32 opcode, uae_u16 extra) { bool super = (regs.dfc & 4) != 0; DUNUSED(extra); - if ((opcode & 0xFE0) == 0x0500) { + if ((opcode & 0xFE0) == 0x0500) { // PFLUSH bool glob; int regno; //D(didflush = 0); @@ -917,18 +838,22 @@ void REGPARAM2 mmu_op_real(uae_u32 opcode, uae_u16 extra) glob = (opcode & 8) != 0; if (opcode & 16) { - D(bug(_T("pflusha(%u,%u)\n"), glob, regs.dfc)); +#if MMUDEBUG > 1 + write_log(_T("pflusha(%u,%u)\n"), glob, regs.dfc); +#endif mmu_flush_atc_all(glob); } else { addr = m68k_areg(regs, regno); - D(bug(_T("pflush(%u,%u,%x)\n"), glob, regs.dfc, addr)); +#if MMUDEBUG > 1 + write_log(_T("pflush(%u,%u,%x)\n"), glob, regs.dfc, addr); +#endif mmu_flush_atc(addr, super, glob); } flush_internals(); #ifdef USE_JIT flush_icache(0); #endif - } else if ((opcode & 0x0FD8) == 0x548) { + } else if ((opcode & 0x0FD8) == 0x0548) { // PTEST (68040) bool write; int regno; uae_u32 addr; @@ -936,7 +861,9 @@ void REGPARAM2 mmu_op_real(uae_u32 opcode, uae_u16 extra) regno = opcode & 7; write = (opcode & 32) == 0; addr = m68k_areg(regs, regno); - D(bug(_T("PTEST%c (A%d) %08x DFC=%d\n"), write ? 'W' : 'R', regno, addr, regs.dfc)); +#if MMUDEBUG > 1 + write_log(_T("PTEST%c (A%d) %08x DFC=%d\n"), write ? 'W' : 'R', regno, addr, regs.dfc); +#endif mmu_flush_atc(addr, super, true); SAVE_EXCEPTION; TRY(prb) { @@ -944,107 +871,182 @@ void REGPARAM2 mmu_op_real(uae_u32 opcode, uae_u16 extra) uae_u32 desc; bool data = (regs.dfc & 3) != 2; - l = &atc_l2[super ? 1 : 0][ATC_L2_INDEX(addr)]; - desc = mmu_fill_atc_l2(addr, super, data, write, l); - if (!(data ? l->valid_data : l->valid_inst)) - regs.mmusr = MMU_MMUSR_B; - else if (l->tt) + if (mmu_match_ttr(addr,super,data)!=TTR_NO_MATCH) regs.mmusr = MMU_MMUSR_T | MMU_MMUSR_R; else { + uae_u32 status; + mmu_user_lookup(addr, super, data, write, &l); + desc = mmu_fill_atc(addr, super, data, write, l, &status); + if (!(l->valid)) + regs.mmusr = MMU_MMUSR_B; + else { regs.mmusr = desc & (~0xfff|MMU_MMUSR_G|MMU_MMUSR_Ux|MMU_MMUSR_S| MMU_MMUSR_CM|MMU_MMUSR_M|MMU_MMUSR_W); regs.mmusr |= MMU_MMUSR_R; } } + } CATCH(prb) { regs.mmusr = MMU_MMUSR_B; - } + } ENDTRY RESTORE_EXCEPTION; - D(bug(_T("PTEST result: mmusr %08x\n"), regs.mmusr)); - } else +#if MMUDEBUG > 1 + write_log(_T("PTEST result: mmusr %08x\n"), regs.mmusr); +#endif + } else if ((opcode & 0xFFB8) == 0xF588) { // PLPA (68060) + int write = (opcode & 0x40) == 0; + int regno = opcode & 7; + uae_u32 addr = m68k_areg (regs, regno); + bool data = (regs.dfc & 3) != 2; + +#if MMUDEBUG > 1 + write_log(_T("PLPA%c param: %08x\n"), write ? 'W' : 'R', addr); +#endif + if (mmu_match_ttr(addr,super,data)==TTR_NO_MATCH) { + m68k_areg (regs, regno) = mmu_translate (addr, super, data, write != 0); + } +#if MMUDEBUG > 1 + write_log(_T("PLPA%c result: %08x\n"), write ? 'W' : 'R', m68k_areg (regs, regno)); +#endif + } else { op_illg (opcode); } +} -static void REGPARAM2 mmu_flush_atc(uaecptr addr, bool super, bool global) +// fixme : global parameter? +void REGPARAM2 mmu_flush_atc(uaecptr addr, bool super, bool global) { - struct mmu_atc_line *l; - int i, j; + int way,type,index; - l = atc_l1[super ? 1 : 0][0][0]; - i = ATC_L1_INDEX(addr); - for (j = 0; j < 4; j++) { - if (global || !l[i].global) - l[i].tag = 0x8000; - l += ATC_L1_SIZE; + uaecptr tag = (mmu_is_super | (addr >> 1)) & mmu_tagmask; + if (mmu_pagesize_8k) + index=(addr & 0x0001E000)>>13; + else + index=(addr & 0x0000F000)>>12; + for (type=0;typeglobal) - l->tag = 0x8000; - } - - l = atc_l2[0]; - for (i = 0; i < sizeof(atc_l2) / sizeof(*l); l++, i++) { - if (global || !l->global) - l->tag = 0x8000; + unsigned int way,slot,type; + for (type=0;type0) { + s_try_stack_size--; + if (s_try_stack_size == 0) + return NULL; + memcpy(&__exbuf,&s_try_stack[s_try_stack_size-1],sizeof(jmp_buf)); + // fprintf(stderr,"pop jmpbuf=%08x\n",s_try_stack[s_try_stack_size][0]); + return &s_try_stack[s_try_stack_size-1]; + } + else { + fprintf(stderr,"try stack underflow...\n"); + // return (NULL); + abort(); + } +} +void __pushtry(jmp_buf* j) { + if (s_try_stack_size0); } +#endif + #else void mmu_op(uae_u32 opcode, uae_u16 /*extra*/) @@ -1060,6 +1062,7 @@ void mmu_op(uae_u32 opcode, uae_u16 /*extra*/) #endif + /* vim:ts=4:sw=4: */ diff --git a/src/custom.c b/src/custom.c index 5c30ae6..af8f9ee 100644 --- a/src/custom.c +++ b/src/custom.c @@ -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 (); } diff --git a/src/debug.c b/src/debug.c index 630c869..58c6c02 100644 --- a/src/debug.c +++ b/src/debug.c @@ -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 [] Show DMA data (accurate only in cycle-exact mode).\n" " v [-1 to -4] = enable visual DMA debugger.\n" " ? Hex ($ and 0x)/Bin (%)/Dec (!) converter.\n" -#ifdef _WIN32 - " x Close debugger.\n" - " xx Switch between console and GUI debugger.\n" - " mg
Memory dump starting at
in GUI.\n" - " dg
Disassembly starting at
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(""); - 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(""); - 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(""); - 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); diff --git a/src/disk.c b/src/disk.c index 6c48a80..def86e7 100644 --- a/src/disk.c +++ b/src/disk.c @@ -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" diff --git a/src/drawing.c b/src/drawing.c index 6bb6b15..5ddf86c 100644 --- a/src/drawing.c +++ b/src/drawing.c @@ -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 (); diff --git a/src/driveclick.c b/src/driveclick.c index e451c68..9e0ccf0 100644 --- a/src/driveclick.c +++ b/src/driveclick.c @@ -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; diff --git a/src/enforcer.c b/src/enforcer.c index 7eb524f..e6ff544 100644 --- a/src/enforcer.c +++ b/src/enforcer.c @@ -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 diff --git a/src/events.c b/src/events.c index 46ba0e4..1a35bfb 100644 --- a/src/events.c +++ b/src/events.c @@ -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; diff --git a/src/expansion.c b/src/expansion.c index 3cf80a6..b437b06 100644 --- a/src/expansion.c +++ b/src/expansion.c @@ -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) diff --git a/src/fdi2raw.c b/src/fdi2raw.c index 90540c4..611e96a 100644 --- a/src/fdi2raw.c +++ b/src/fdi2raw.c @@ -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; diff --git a/src/filesys.asm b/src/filesys.asm index 6682812..7932aa2 100644 --- a/src/filesys.asm +++ b/src/filesys.asm @@ -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: diff --git a/src/filesys.c b/src/filesys.c index b36ef35..d047dd3 100644 --- a/src/filesys.c +++ b/src/filesys.c @@ -28,6 +28,7 @@ #include "threaddep/thread.h" #include "options.h" #include "uae.h" +#include "misc.h" #include "memory_uae.h" #include "custom.h" #include "events.h" @@ -43,17 +44,16 @@ #include "gui.h" #include "gayle.h" #include "savestate.h" -#include "consolehook.h" -#include "blkdev.h" -#include "isofs_api.h" -#include "misc.h" +#include "a2091.h" +#include "cdtv.h" +#include "sana2.h" +#include "bsdsocket.h" #include "uaeresource.h" #include "inputdevice.h" #include "clipboard.h" -#include "bsdsocket.h" -#ifdef PICASSO96 -# include "picasso96.h" -#endif +#include "consolehook.h" +#include "blkdev.h" +#include "isofs_api.h" #ifdef TARGET_AMIGAOS #include @@ -84,7 +84,8 @@ int log_filesys = 0; static uae_sem_t test_sem; -int bootrom_header, bootrom_items; +static int bootrom_header; + static uae_u32 dlg (uae_u32 a) { return (dbg (a + 0) << 24) | (dbg (a + 1) << 16) | (dbg (a + 2) << 8) | (dbg (a + 3) << 0); @@ -176,6 +177,8 @@ typedef struct { uae_u8 *rdb_filesysstore; int rdb_filesyssize; TCHAR *filesysdir; + /* filesystem seglist */ + uaecptr filesysseg; /* CDFS */ bool cd_open; @@ -205,7 +208,7 @@ int nr_directory_units (struct uae_prefs *p) int i, cnt = 0; if (p) { for (i = 0; i < p->mountitems; i++) { - if (p->mountconfig[i].controller == 0) + if (p->mountconfig[i].ci.controller == 0) cnt++; } } else { @@ -230,7 +233,7 @@ int is_hardfile (int unit_no) return FILESYS_CD; return FILESYS_VIRTUAL; } - if (mountinfo.ui[unit_no].hf.secspertrack == 0) { + if (mountinfo.ui[unit_no].hf.ci.sectors == 0) { if (mountinfo.ui[unit_no].hf.flags & 1) return FILESYS_HARDDRIVE; return FILESYS_HARDFILE_RDB; @@ -272,7 +275,7 @@ static void close_filesys_unit (UnitInfo *uip) uip->cd_open = 0; } -static struct uaedev_config_info *getuci (struct uaedev_config_info *uci, int nr) +static struct uaedev_config_data *getuci (struct uaedev_config_data *uci, int nr) { return &uci[nr]; } @@ -291,7 +294,7 @@ static UnitInfo *getuip (struct uae_prefs *p, int index) int get_filesys_unitconfig (struct uae_prefs *p, int index, struct mountedinfo *mi) { UnitInfo *ui = getuip(p, index); - struct uaedev_config_info *uci = &p->mountconfig[index]; + struct uaedev_config_data *uci = &p->mountconfig[index]; UnitInfo uitmp; memset (mi, 0, sizeof (struct mountedinfo)); @@ -300,23 +303,23 @@ int get_filesys_unitconfig (struct uae_prefs *p, int index, struct mountedinfo * ui = &uitmp; if (!uci->ishdf) { mi->ismounted = 1; - if (uci->rootdir && _tcslen(uci->rootdir) == 0) + if (uci->ci.rootdir && _tcslen (uci->ci.rootdir) == 0) return FILESYS_VIRTUAL; - if (my_existsfile (uci->rootdir)) { + if (my_existsfile (uci->ci.rootdir)) { mi->ismedia = 1; return FILESYS_VIRTUAL; } - if (my_getvolumeinfo (uci->rootdir) < 0) + if (my_getvolumeinfo (uci->ci.rootdir) < 0) return -1; mi->ismedia = true; return FILESYS_VIRTUAL; } else { - ui->hf.readonly = true; - ui->hf.blocksize = uci->blocksize; - if (!hdf_open (&ui->hf, uci->rootdir)) { + ui->hf.ci.readonly = true; + ui->hf.ci.blocksize = uci->ci.blocksize; + if (!hdf_open (&ui->hf, uci->ci.rootdir)) { mi->ismedia = false; mi->ismounted = true; - if (uci->reserved == 0 && uci->sectors == 0 && uci->surfaces == 0) { + if (uci->ci.reserved == 0 && uci->ci.sectors == 0 && uci->ci.surfaces == 0) { if (ui->hf.flags & 1) return FILESYS_HARDDRIVE; return FILESYS_HARDFILE_RDB; @@ -338,14 +341,14 @@ int get_filesys_unitconfig (struct uae_prefs *p, int index, struct mountedinfo * } } mi->size = ui->hf.virtsize; - if (uci->cyls) { - mi->nrcyls = uci->cyls; + if (uci->ci.highcyl) { + uci->ci.cyls = mi->nrcyls = uci->ci.highcyl; } else { - mi->nrcyls = (int)(uci->sectors * uci->surfaces ? (ui->hf.virtsize / uci->blocksize) / (uci->sectors * uci->surfaces) : 0); + uci->ci.cyls = mi->nrcyls = (int)(uci->ci.sectors * uci->ci.surfaces ? (ui->hf.virtsize / uci->ci.blocksize) / (uci->ci.sectors * uci->ci.surfaces) : 0); } if (!uci->ishdf) return FILESYS_VIRTUAL; - if (uci->reserved == 0 && uci->sectors == 0 && uci->surfaces == 0) { + if (uci->ci.reserved == 0 && uci->ci.sectors == 0 && uci->ci.surfaces == 0) { if (ui->hf.flags & 1) return FILESYS_HARDDRIVE; return FILESYS_HARDFILE_RDB; @@ -484,18 +487,36 @@ static int set_filesys_volume (const TCHAR *rootdir, int *flags, bool *readonly, return 1; } -static int set_filesys_unit_1 (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) +void uci_set_defaults (struct uaedev_config_info *uci, bool rdb) +{ + memset (uci, 0, sizeof (struct uaedev_config_info)); + if (!rdb) { + uci->sectors = 32; + uci->reserved = 2; + uci->surfaces = 1; + } + uci->blocksize = 512; + uci->autoboot = true; + uci->maxtransfer = 0x7fffffff; + uci->mask = 0xffffffff; + uci->bufmemtype = 1; + uci->buffers = 50; + uci->stacksize = 4000; + uci->priority = -129; + uci->sectorsperblock = 1; +} + +static int set_filesys_unit_1 (int nr, struct uaedev_config_info *ci) { UnitInfo *ui; int i; bool emptydrive = false; bool iscd; + struct uaedev_config_info c; - if (hdc) + memcpy (&c, ci, sizeof (struct uaedev_config_info)); + + if (ci->controller) return -1; if (nr < 0) { for (nr = 0; nr < MAX_FILESYSTEM_UNITS; nr++) { @@ -513,8 +534,8 @@ static int set_filesys_unit_1 (int nr, for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) { if (nr == i || !mountinfo.ui[i].open || mountinfo.ui[i].rootdir == NULL || is_hardfile (i) == FILESYS_CD) continue; - if (rootdir && _tcslen (rootdir) > 0 && !_tcsicmp (mountinfo.ui[i].rootdir, rootdir)) { - write_log (_T("directory/hardfile '%s' already added\n"), rootdir); + if (_tcslen (c.rootdir) > 0 && !_tcsicmp (mountinfo.ui[i].rootdir, c.rootdir)) { + write_log (_T("directory/hardfile '%s' already added\n"), c.rootdir); return -1; } } @@ -526,76 +547,78 @@ static int set_filesys_unit_1 (int nr, ui->unit_type = UNIT_CDFS; emptydrive = 1; ui->volflags = MYVOLUMEINFO_CDFS | MYVOLUMEINFO_READONLY; - readonly = true; - } else if (volname != NULL) { + c.readonly = true; + } else if (c.volname[0]) { int flags = 0; emptydrive = 1; - if (rootdir) { - if (set_filesys_volume (rootdir, &flags, &readonly, &emptydrive, &ui->zarchive) < 0) + if (c.rootdir[0]) { + if (set_filesys_volume (c.rootdir, &flags, &c.readonly, &emptydrive, &ui->zarchive) < 0) return -1; } - ui->volname = filesys_createvolname (volname, rootdir, _T("harddrive")); + ui->volname = filesys_createvolname (c.volname, c.rootdir, _T("harddrive")); ui->volflags = flags; } else { ui->unit_type = UNIT_FILESYSTEM; - ui->hf.secspertrack = secspertrack; - ui->hf.surfaces = surfaces; - ui->hf.reservedblocks = reserved; - ui->hf.blocksize = blocksize; + memcpy (&ui->hf.ci, &c, sizeof (struct uaedev_config_info)); ui->hf.unitnum = nr; ui->volname = 0; - ui->hf.readonly = readonly; - if (!hdf_open (&ui->hf, rootdir) && !readonly) { + if (ui->hf.ci.rootdir[0]) { + if (!hdf_open (&ui->hf, NULL) && !c.readonly) { write_log (_T("Attempting to open in read-only mode\n")); - ui->hf.readonly = readonly = 1; - hdf_open (&ui->hf, rootdir); + ui->hf.ci.readonly = c.readonly = true; + hdf_open (&ui->hf, NULL); + } + } else { + // empty drive? + ui->hf.drive_empty = 1; } - ui->hf.readonly = readonly; if (!ui->hf.drive_empty) { if (ui->hf.handle_valid == 0) { write_log (_T("Hardfile %s not found\n"), ui->hf.device_name); goto err; } - if ((ui->hf.blocksize & (ui->hf.blocksize - 1)) != 0 || ui->hf.blocksize == 0) { - write_log (_T("Hardfile %s bad blocksize\n"), ui->hf.device_name); - goto err; - } - if ((ui->hf.secspertrack || ui->hf.surfaces || ui->hf.reservedblocks) && - (ui->hf.secspertrack < 1 || ui->hf.surfaces < 1 || ui->hf.surfaces > 1023 || - ui->hf.reservedblocks < 0 || ui->hf.reservedblocks > 1023) != 0) { - write_log (_T("Hardfile %s bad hardfile geometry\n"), ui->hf.device_name); - goto err; - } - if ( ((uae_u64)ui->hf.blocksize > ui->hf.virtsize) || !ui->hf.virtsize) { + if (ui->hf.ci.blocksize > ui->hf.virtsize || ui->hf.virtsize == 0) { write_log (_T("Hardfile %s too small\n"), ui->hf.device_name); goto err; } - if (cyls) { - ui->hf.nrcyls = cyls; - } else { - ui->hf.nrcyls = (int)(ui->hf.secspertrack * ui->hf.surfaces ? (ui->hf.virtsize / ui->hf.blocksize) / (ui->hf.secspertrack * ui->hf.surfaces) : 0); } + if ((ui->hf.ci.blocksize & (ui->hf.ci.blocksize - 1)) != 0 || ui->hf.ci.blocksize == 0) { + write_log (_T("Hardfile %s bad blocksize\n"), ui->hf.device_name); + goto err; + } + if ((ui->hf.ci.sectors || ui->hf.ci.surfaces || ui->hf.ci.reserved) && + (ui->hf.ci.sectors < 1 || ui->hf.ci.surfaces < 1 || ui->hf.ci.surfaces > 1023 || + ui->hf.ci.reserved < 0 || ui->hf.ci.reserved > 1023) != 0) { + write_log (_T("Hardfile %s bad hardfile geometry\n"), ui->hf.device_name); + goto err; + } + if (!ui->hf.ci.highcyl) { + ui->hf.ci.cyls = (int)(ui->hf.ci.sectors * ui->hf.ci.surfaces ? (ui->hf.virtsize / ui->hf.ci.blocksize) / (ui->hf.ci.sectors * ui->hf.ci.surfaces) : 0); } + if (!ui->hf.ci.cyls) + ui->hf.ci.cyls = ui->hf.ci.highcyl; + if (!ui->hf.ci.cyls) + ui->hf.ci.cyls = 1; } ui->self = 0; ui->reset_state = FS_STARTUP; ui->wasisempty = emptydrive; - ui->canremove = emptydrive && (flags & MYVOLUMEINFO_REUSABLE); - ui->rootdir = my_strdup (rootdir); - ui->devname = my_strdup (devname); + ui->canremove = emptydrive && (ci->flags & MYVOLUMEINFO_REUSABLE); + ui->rootdir = my_strdup (c.rootdir); + ui->devname = my_strdup (c.devname); stripsemicolon(ui->devname); - if (filesysdir && filesysdir[0]) - ui->filesysdir = my_strdup (filesysdir); - ui->readonly = readonly; - if (!autoboot) - bootpri = -128; - if (donotmount) - bootpri = -129; - if (bootpri < -129) - bootpri = -129; - if (bootpri > 127) - bootpri = 127; - ui->bootpri = bootpri; + if (c.filesys[0]) + ui->filesysdir = my_strdup (c.filesys); + ui->readonly = c.readonly; + if (!c.autoboot) + c.bootpri = -128; + if (c.donotmount) + c.bootpri = -129; + if (c.bootpri < -129) + c.bootpri = -129; + if (c.bootpri > 127) + c.bootpri = 127; + ui->bootpri = c.bootpri; ui->open = 1; return nr; @@ -605,37 +628,26 @@ err: return -1; } -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) +static int set_filesys_unit (int nr, struct uaedev_config_info *ci) { int ret; - ret = set_filesys_unit_1 (nr, devname, volname, rootdir, readonly, - cyls, secspertrack, surfaces, reserved, blocksize, bootpri, donotmount, autoboot, - filesysdir, hdc, flags); + ret = set_filesys_unit_1 (nr, ci); return ret; } -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) +static int add_filesys_unit (struct uaedev_config_info *ci) { int ret; if (nr_units() >= MAX_FILESYSTEM_UNITS) return -1; - ret = set_filesys_unit_1 (-1, devname, volname, rootdir, readonly, - cyls, secspertrack, surfaces, reserved, blocksize, - bootpri, donotmount, autoboot, filesysdir, hdc, flags); + ret = set_filesys_unit_1 (-1, ci); #ifdef RETROPLATFORM if (ret >= 0) { rp_hd_device_enable (ret, true); - rp_harddrive_image_change (ret, readonly, rootdir); + rp_harddrive_image_change (ret, ci->readonly, ci->rootdir); } #endif return ret; @@ -643,34 +655,34 @@ int add_filesys_unit (const TCHAR *devname, const TCHAR *volname, const TCHAR *r int kill_filesys_unitconfig (struct uae_prefs *p, int nr) { - struct uaedev_config_info *uci; + struct uaedev_config_data *uci; if (nr < 0) return 0; uci = getuci (p->mountconfig, nr); hardfile_do_disk_change (uci, 0); - if (uci->configoffset >= 0 && uci->controller == 0) - filesys_media_change (uci->rootdir, 0, uci); + if (uci->configoffset >= 0 && uci->ci.controller == 0) + filesys_media_change (uci->ci.rootdir, 0, uci); while (nr < MOUNT_CONFIG_SIZE) { - memmove (&p->mountconfig[nr], &p->mountconfig[nr + 1], sizeof (struct uaedev_config_info)); + memmove (&p->mountconfig[nr], &p->mountconfig[nr + 1], sizeof (struct uaedev_config_data)); nr++; } p->mountitems--; - memset (&p->mountconfig[MOUNT_CONFIG_SIZE - 1], 0, sizeof (struct uaedev_config_info)); + memset (&p->mountconfig[MOUNT_CONFIG_SIZE - 1], 0, sizeof (struct uaedev_config_data)); return 1; } int move_filesys_unitconfig (struct uae_prefs *p, int nr, int to) { - struct uaedev_config_info *uci1, *uci2, tmpuci; + struct uaedev_config_data *uci1, *uci2, tmpuci; uci1 = getuci (p->mountconfig, nr); uci2 = getuci (p->mountconfig, to); if (nr == to) return 0; - memcpy (&tmpuci, uci1, sizeof (struct uaedev_config_info)); - memcpy (uci1, uci2, sizeof (struct uaedev_config_info)); - memcpy (uci2, &tmpuci, sizeof (struct uaedev_config_info)); + memcpy (&tmpuci, uci1, sizeof (struct uaedev_config_data)); + memcpy (uci1, uci2, sizeof (struct uaedev_config_data)); + memcpy (uci2, &tmpuci, sizeof (struct uaedev_config_data)); return 1; } @@ -679,7 +691,7 @@ void filesys_addexternals (void) {} static void allocuci (struct uae_prefs *p, int nr, int idx) { - struct uaedev_config_info *uci = &p->mountconfig[nr]; + struct uaedev_config_data *uci = &p->mountconfig[nr]; if (idx >= 0) { UnitInfo *ui; uci->configoffset = idx; @@ -698,11 +710,12 @@ static void initialize_mountinfo (void) cd_unit_offset = MAX_FILESYSTEM_UNITS; for (nr = 0; nr < currprefs.mountitems; nr++) { - struct uaedev_config_info *uci = &currprefs.mountconfig[nr]; - if (uci->controller == HD_CONTROLLER_UAE) { - int idx = set_filesys_unit_1 (-1, uci->devname, uci->ishdf ? NULL : uci->volname, uci->rootdir, - uci->readonly, uci->cyls, uci->sectors, uci->surfaces, uci->reserved, - uci->blocksize, uci->bootpri, uci->donotmount, uci->autoboot, uci->filesys, 0, MYVOLUMEINFO_REUSABLE); + struct uaedev_config_data *uci = &currprefs.mountconfig[nr]; + if (uci->ci.controller == HD_CONTROLLER_UAE) { + struct uaedev_config_info ci; + memcpy (&ci, &uci->ci, sizeof (struct uaedev_config_info)); + ci.flags = MYVOLUMEINFO_REUSABLE; + int idx = set_filesys_unit_1 (-1, &ci); allocuci (&currprefs, nr, idx); } } @@ -715,10 +728,15 @@ static void initialize_mountinfo (void) uae_u32 mask = scsi_get_cd_drive_mask (); for (int i = 0; i < 32; i++) { if (mask & (1 << i)) { - TCHAR cdname[30]; - _stprintf (cdname, _T("CD%d"), i); + struct uaedev_config_info ci = { 0 }; + _stprintf (ci.devname, _T("CD%d"), i); cd_unit_number++; - int idx = set_filesys_unit_1 (i + cd_unit_offset, cdname, NULL, _T("/"), true, 0, 1, 1, 0, 2048, 0, false, false, NULL, 0, 0); + _tcscpy (ci.rootdir, _T("/")); + ci.readonly = true; + ci.sectors = 1; + ci.surfaces = 1; + ci.blocksize = 2048; + int idx = set_filesys_unit_1 (i + cd_unit_offset, &ci); allocuci (&currprefs, nr, idx); nr++; } @@ -726,36 +744,28 @@ static void initialize_mountinfo (void) } #endif for (nr = 0; nr < currprefs.mountitems; nr++) { - struct uaedev_config_info *uci = &currprefs.mountconfig[nr]; + struct uaedev_config_info *uci = &currprefs.mountconfig[nr].ci; if (uci->controller == HD_CONTROLLER_UAE) continue; if (uci->controller <= HD_CONTROLLER_IDE3) { #ifdef GAYLE - gayle_add_ide_unit (uci->controller - HD_CONTROLLER_IDE0, uci->rootdir, uci->blocksize, uci->readonly, - uci->devname, uci->cyls, uci->sectors, uci->surfaces, uci->reserved, - uci->bootpri, uci->filesys, uci->pcyls, uci->pheads, uci->psecs); + gayle_add_ide_unit (uci->controller - HD_CONTROLLER_IDE0, uci); allocuci (&currprefs, nr, -1); #endif } else if (uci->controller <= HD_CONTROLLER_SCSI6) { if (currprefs.cs_mbdmac > 0) { #ifdef A2091 - a3000_add_scsi_unit (uci->controller - HD_CONTROLLER_SCSI0, uci->rootdir, uci->blocksize, uci->readonly, - uci->devname, uci->sectors, uci->surfaces, uci->reserved, - uci->bootpri, uci->filesys); + a3000_add_scsi_unit (uci->controller - HD_CONTROLLER_SCSI0, uci); allocuci (&currprefs, nr, -1); #endif } else if (currprefs.cs_a2091) { #ifdef A2091 - a2091_add_scsi_unit (uci->controller - HD_CONTROLLER_SCSI0, uci->rootdir, uci->blocksize, uci->readonly, - uci->devname, uci->sectors, uci->surfaces, uci->reserved, - uci->bootpri, uci->filesys); + a2091_add_scsi_unit (uci->controller - HD_CONTROLLER_SCSI0, uci); allocuci (&currprefs, nr, -1); #endif } else if (currprefs.cs_cdtvscsi) { #ifdef CDTV - cdtv_add_scsi_unit (uci->controller - HD_CONTROLLER_SCSI0, uci->rootdir, uci->blocksize, uci->readonly, - uci->devname, uci->sectors, uci->surfaces, uci->reserved, - uci->bootpri, uci->filesys); + cdtv_add_scsi_unit (uci->controller - HD_CONTROLLER_SCSI0, uci); allocuci (&currprefs, nr, -1); #endif } @@ -1285,12 +1295,14 @@ static uae_u32 fs_fsize (struct fs_filehandle *fsf) return (uae_u32)fs_fsize64 (fsf); } +#ifdef SCSI static void set_highcyl (UnitInfo *ui, uae_u32 blocks) { uaecptr startup = get_long (ui->devicenode + 7 * 4) << 2; uaecptr env = get_long (startup + 8) << 2; put_long (env + 10 * 4, blocks); } +#endif static void set_volume_name (Unit *unit, struct mytimeval *tv) { @@ -1521,7 +1533,7 @@ static uae_u32 filesys_media_change_reply (TrapContext *ctx, int mode) // insert struct mytimeval ctime = { 0 }; bool emptydrive = false; - struct uaedev_config_info *uci = NULL; + struct uaedev_config_data *uci = NULL; clear_exkeys (u); xfree (u->ui.rootdir); @@ -1573,13 +1585,13 @@ static uae_u32 filesys_media_change_reply (TrapContext *ctx, int mode) if (u->mount_flags >= 0) ui->volflags = u->volflags = u->ui.volflags = u->mount_flags; if (uci != NULL) { - _tcscpy (uci->volname, ui->volname); - _tcscpy (uci->rootdir, u->mount_rootdir); + _tcscpy (uci->ci.volname, ui->volname); + _tcscpy (uci->ci.rootdir, u->mount_rootdir); } if (u->mount_flags >= 0) { ui->readonly = u->ui.readonly = u->mount_readonly; if (uci != NULL) - uci->readonly = u->mount_readonly; + uci->ci.readonly = u->mount_readonly; } put_byte (u->volume + 44, 0); put_byte (u->volume + 172 - 32, 1); @@ -1599,7 +1611,7 @@ static uae_u32 filesys_media_change_reply (TrapContext *ctx, int mode) return 0; } -int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_config_info *uci) +int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_config_data *uci) { Unit *u; UnitInfo *ui; @@ -1621,7 +1633,7 @@ int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_conf if (ui->rootdir && !memcmp (ui->rootdir, rootdir, _tcslen (rootdir)) && _tcslen (rootdir) + 3 >= _tcslen (ui->rootdir)) { if (filesys_isvolume (u) && inserted) { if (uci) - filesys_delayed_change (u, 50, rootdir, uci->volname, uci->readonly, 0); + filesys_delayed_change (u, 50, rootdir, uci->ci.volname, uci->ci.readonly, 0); return 0; } nr = u->unit; @@ -1641,8 +1653,9 @@ int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_conf if (nr >= 0 && !inserted) return filesys_eject (nr); if (inserted) { + struct uaedev_config_info ci = { 0 }; if (uci) { - volptr = my_strdup (uci->volname); + volptr = my_strdup (uci->ci.volname); } else { volname[0] = 0; //FIXME: target_get_volume_name (&mountinfo, rootdir, volname, MAX_DPATH, 1, 0); @@ -1679,10 +1692,15 @@ int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_conf } /* nope, uh, need black magic now.. */ if (uci) - _tcscpy (devname, uci->devname); + _tcscpy (devname, uci->ci.devname); else _stprintf (devname, _T("RDH%d"), nr_units ()); - nr = add_filesys_unit (devname, volptr, rootdir, 0, 0, 0, 0, 0, 0, 0, 0, 1, NULL, 0, MYVOLUMEINFO_REUSABLE); + _tcscpy (ci.devname, devname); + _tcscpy (ci.volname, volptr); + _tcscpy (ci.rootdir, rootdir); + ci.autoboot = true; + ci.flags = MYVOLUMEINFO_REUSABLE; + nr = add_filesys_unit (&ci); if (nr < 0) return 0; if (inserted > 1) @@ -1697,7 +1715,63 @@ int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_conf return 0; } -#if 0 +int hardfile_media_change (struct hardfiledata *hfd, struct uaedev_config_info *ci, bool inserted, bool timer) +{ + if (!hfd) + return 0; + if (!timer) + hfd->reinsertdelay = 0; + if (hfd->reinsertdelay < 0) { + hfd->reinsertdelay = 0; + if (!hfd->isreinsert) { + hdf_close (hfd); + hardfile_send_disk_change (hfd, false); + if (hfd->delayedci.rootdir[0]) { + hfd->reinsertdelay = 50; + hfd->isreinsert = true; + write_log (_T("HARDFILE: delayed insert %d: '%s'\n"), hfd->unitnum, ci->rootdir ? ci->rootdir : _T("")); + return 0; + } else { + return 1; + } + } + memcpy (&hfd->ci, &hfd->delayedci, sizeof (struct uaedev_config_info)); + if (!hdf_open (hfd, NULL)) { + write_log (_T("HARDFILE: '%s' failed to open\n"), hfd->ci.rootdir); + return 0; + } + hardfile_send_disk_change (hfd, true); + return 1; + } + + if (ci) { + memcpy (&hfd->delayedci, ci, sizeof (struct uaedev_config_info)); + if (hfd && !hfd->drive_empty) { + hfd->reinsertdelay = 50; + hfd->isreinsert = false; + write_log (_T("HARDFILE: delayed eject %d: '%s'\n"), hfd->unitnum, hfd->ci.rootdir ? hfd->ci.rootdir : _T("")); + return 0; + } + if (!hfd) { + return 0; + } + hfd->reinsertdelay = 2; + hfd->isreinsert = true; + } else { + if (inserted) { + hfd->reinsertdelay = 2; + hfd->isreinsert = true; + memcpy (&hfd->delayedci, &hfd->ci, sizeof (struct uaedev_config_info)); + } else { + hfd->reinsertdelay = 2; + hfd->isreinsert = false; + memcpy (&hfd->delayedci, &hfd->ci, sizeof (struct uaedev_config_info)); + hfd->delayedci.rootdir[0] = 0; + } + } + return 0; +} + int hardfile_remount (int nr) { /* this does work but every media reinsert duplicates the device.. */ @@ -1709,7 +1783,7 @@ int hardfile_remount (int nr) #endif return 1; } -#endif + bool filesys_do_disk_change (int cdunitnum, bool insert) { @@ -5974,9 +6048,10 @@ static uae_u32 REGPARAM2 filesys_diagentry (TrapContext *context) #define PP_MAXSIZE 4 * 96 #define PP_FSSIZE 400 #define PP_FSPTR 404 -#define PP_FSRES 408 -#define PP_EXPLIB 412 -#define PP_FSHDSTART 416 +#define PP_ADDTOFSRES 408 +#define PP_FSRES 412 +#define PP_EXPLIB 416 +#define PP_FSHDSTART 420 static uae_u32 REGPARAM2 filesys_dev_bootfilesys (TrapContext *context) { @@ -6004,6 +6079,19 @@ static uae_u32 REGPARAM2 filesys_dev_bootfilesys (TrapContext *context) put_long (devicenode + 16, fshandlername); return 0; } + + if (get_long (parmpacket + PP_FSPTR) && !get_long (parmpacket + PP_ADDTOFSRES)) { + uaecptr fsptr = get_long (parmpacket + PP_FSPTR); + uip->filesysseg = fsptr; + // filesystem but was not added to fs.resource + uae_u32 pf = get_long (parmpacket + PP_FSHDSTART + 8); // fse_PatchFlags + for (int i = 0; i < 32; i++) { + if (pf & (1 << i)) + put_long (devicenode + 4 + i * 4, get_long (parmpacket + PP_FSHDSTART + 8 + 4 + i * 4)); + } + put_long (devicenode + 4 + 7 * 4, fsptr >> 2); // seglist + return 1; + } dostype = get_long (parmpacket + 80); fsnode = get_long (fsres + 18); while (get_long (fsnode)) { @@ -6043,9 +6131,10 @@ static uae_u32 REGPARAM2 filesys_init_storeinfo (TrapContext *context) return ret; } - +#if 0 static uae_u8 *cdfs_handler; static int cdfs_handler_len; +#endif /* Remember a pointer AmigaOS gave us so we can later use it to identify * which unit a given startup message belongs to. */ @@ -6086,7 +6175,7 @@ static int legalrdbblock (UnitInfo *uip, int block) { if (block <= 0) return 0; - if ((uae_u64)block >= (uip->hf.virtsize / uip->hf.blocksize) ) + if (block >= uip->hf.virtsize / uip->hf.ci.blocksize) return 0; return 1; } @@ -6204,7 +6293,7 @@ static void dump_partinfo (struct hardfiledata *hfd, uae_u8 *pp) lowcyl = rl (pp + 36); highcyl = rl (pp + 40); - write_log (_T("RDB: '%s' dostype=%08X (%s) Flags: %08X\n"), s, dostype, dostypes (dostype), flags); + write_log (_T("Partition '%s' Dostype=%08X (%s) Flags: %08X\n"), s, dostype, dostypes (dostype), flags); write_log (_T("BlockSize: %d, Surfaces: %d, SectorsPerBlock %d\n"), blocksize, surfaces, spb); write_log (_T("SectorsPerTrack: %d, Reserved: %d, LowCyl %d, HighCyl %d, Size %dM\n"), @@ -6212,20 +6301,22 @@ static void dump_partinfo (struct hardfiledata *hfd, uae_u8 *pp) write_log (_T("Buffers: %d, BufMemType: %08x, MaxTransfer: %08x, Mask: %08x, BootPri: %d\n"), rl (pp + 44), rl (pp + 48), rl (pp + 52), rl (pp + 56), rl (pp + 60)); - block = lowcyl * surfaces * spt; - if (hdf_read (hfd, buf, (uae_u64)blocksize * block, sizeof buf)) { - write_log (_T("First block %d dostype: %08X (%s)\n"), block, rl (buf), dostypes (rl (buf))); + if (hfd->drive_empty) { + write_log (_T("Empty drive\n")); } else { - write_log (_T("First block %d read failed!\n"), block); + block = lowcyl * surfaces * spt; + if (hdf_read (hfd, buf, (uae_u64)blocksize * block, sizeof buf)) { + write_log (_T("First block %d dostype: %08X (%s)\n"), block, rl (buf), dostypes (rl (buf))); + } else { + write_log (_T("First block %d read failed!\n"), block); + } + xfree (s); + + if ((uae_u64)highcyl * spt * surfaces * blocksize > hfd->virtsize) { + write_log (_T("RDB: WARNING: end of partition > size of disk! (%llu > %llu)\n"), + (uae_u64)highcyl * spt * surfaces * blocksize, hfd->virtsize); + } } - xfree (s); - - if ((uae_u64)highcyl * spt * surfaces * blocksize > hfd->virtsize) { - write_log (_T("RDB: WARNING: end of partition > size of disk! (%llu > %llu)\n"), - (uae_u64)highcyl * spt * surfaces * blocksize, hfd->virtsize); - } - - } static void dump_rdb (UnitInfo *uip, struct hardfiledata *hfd, uae_u8 *bufrdb, uae_u8 *buf, int readblocksize) @@ -6248,7 +6339,7 @@ static void dump_rdb (UnitInfo *uip, struct hardfiledata *hfd, uae_u8 *bufrdb, u break; } memset (buf, 0, readblocksize); - hdf_read (hfd, buf, partblock * hfd->blocksize, readblocksize); + hdf_read (hfd, buf, partblock * hfd->ci.blocksize, readblocksize); if (!rdb_checksum ("PART", buf, partblock)) { write_log (_T("RDB: checksum error PART block %d\n"), partblock); break; @@ -6269,7 +6360,7 @@ static void dump_rdb (UnitInfo *uip, struct hardfiledata *hfd, uae_u8 *bufrdb, u break; } memset (buf, 0, readblocksize); - hdf_read (hfd, buf, fileblock * hfd->blocksize, readblocksize); + hdf_read (hfd, buf, fileblock * hfd->ci.blocksize, readblocksize); if (!rdb_checksum ("FSHD", buf, fileblock)) { write_log (_T("RDB: checksum error FSHD block %d\n"), fileblock); break; @@ -6305,21 +6396,21 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke write_log (_T("ignored, drive is empty\n")); return -2; } - if (hfd->blocksize == 0) { + if (hfd->ci.blocksize == 0) { rdbmnt write_log (_T("failed, blocksize == 0\n")); return -1; } - if ((lastblock > 0) && (((uae_u64)lastblock * hfd->blocksize) > hfd->virtsize) ) { + if ((lastblock > 0) && (((uae_u64)lastblock * hfd->ci.blocksize) > hfd->virtsize) ) { rdbmnt - write_log (_T("failed, too small (%d*%d > %llu)\n"), lastblock, hfd->blocksize, hfd->virtsize); + write_log (_T("failed, too small (%d*%d > %llu)\n"), lastblock, hfd->ci.blocksize, hfd->virtsize); return -2; } for (rdblock = 0; rdblock < lastblock; rdblock++) { - hdf_read_rdb (hfd, bufrdb, rdblock * hfd->blocksize, hfd->blocksize); + hdf_read_rdb (hfd, bufrdb, rdblock * hfd->ci.blocksize, hfd->ci.blocksize); if (rdb_checksum ("RDSK", bufrdb, rdblock)) break; - hdf_read_rdb (hfd, bufrdb, rdblock * hfd->blocksize, hfd->blocksize); + hdf_read_rdb (hfd, bufrdb, rdblock * hfd->ci.blocksize, hfd->ci.blocksize); if (!memcmp ("RDSK", bufrdb, 4)) { bufrdb[0xdc] = 0; bufrdb[0xdd] = 0; @@ -6327,7 +6418,7 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke bufrdb[0xdf] = 0; if (rdb_checksum ("RDSK", bufrdb, rdblock)) { write_log (_T("Windows 95/98/ME trashed RDB detected, fixing..\n")); - hdf_write (hfd, bufrdb, rdblock * hfd->blocksize, hfd->blocksize); + hdf_write (hfd, bufrdb, rdblock * hfd->ci.blocksize, hfd->ci.blocksize); break; } } @@ -6338,7 +6429,7 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke return -2; } blocksize = rl (bufrdb + 16); - readblocksize = blocksize > hfd->blocksize ? blocksize : hfd->blocksize; + readblocksize = blocksize > hfd->ci.blocksize ? blocksize : hfd->ci.blocksize; badblock = rl (bufrdb + 24); if (badblock != -1) { rdbmnt @@ -6351,20 +6442,31 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke write_log (_T("RDB: driveinit is not yet supported. Contact the author.\n")); return -2; } - hfd->cylinders = rl (bufrdb + 64); - hfd->sectors = rl (bufrdb + 68); - hfd->heads = rl (bufrdb + 72); + hfd->rdbcylinders = rl (bufrdb + 64); + hfd->rdbsectors = rl (bufrdb + 68); + hfd->rdbheads = rl (bufrdb + 72); +#if 0 + { + int cyls, secs, heads; + getchsgeometry_hdf (hfd, hfd->virtsize, &cyls, &secs, &heads); + if (cyls * secs * heads > hfd->cylinders * hfd->sectors * hfd->heads) { + hfd->cylinders = cyls; + hfd->sectors = secs; + hfd->heads = heads; + } + } +#endif fileblock = rl (bufrdb + 32); buf = xmalloc (uae_u8, readblocksize); if (showdebug) { - if ((uae_u64)hfd->cylinders * hfd->sectors * hfd->heads * blocksize > hfd->virtsize) + if ((uae_u64)hfd->rdbcylinders * hfd->rdbsectors * hfd->rdbheads * blocksize > hfd->virtsize) write_log (_T("RDB: WARNING: RDSK header disk size > disk size! (%llu > %llu)\n"), - (uae_u64)hfd->cylinders * hfd->sectors * hfd->heads * blocksize, hfd->virtsize); + (uae_u64)hfd->rdbcylinders * hfd->rdbsectors * hfd->rdbheads * blocksize, hfd->virtsize); write_log (_T("RDSK dump start\n")); write_log (_T("RDSK at %d, C=%d S=%d H=%d\n"), - rdblock, hfd->cylinders, hfd->sectors, hfd->heads); + rdblock, hfd->rdbcylinders, hfd->rdbsectors, hfd->rdbheads); dump_rdb (uip, hfd, bufrdb, buf, readblocksize); write_log (_T("RDSK dump end\n")); } @@ -6379,7 +6481,7 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke goto error; } memset (buf, 0, readblocksize); - hdf_read (hfd, buf, partblock * hfd->blocksize, readblocksize); + hdf_read (hfd, buf, partblock * hfd->ci.blocksize, readblocksize); if (!rdb_checksum ("PART", buf, partblock)) { err = -2; goto error; @@ -6451,7 +6553,7 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke goto error; } memset (buf, 0, readblocksize); - hdf_read (hfd, buf, fileblock * hfd->blocksize, readblocksize); + hdf_read (hfd, buf, fileblock * hfd->ci.blocksize, readblocksize); if (!rdb_checksum ("FSHD", buf, fileblock)) { write_log (_T("RDB: checksum error in FSHD block %d\n"), fileblock); goto error; @@ -6485,7 +6587,7 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke if (!legalrdbblock (uip, lsegblock)) goto error; memset (buf, 0, readblocksize); - hdf_read (hfd, buf, lsegblock * hfd->blocksize, readblocksize); + hdf_read (hfd, buf, lsegblock * hfd->ci.blocksize, readblocksize); if (!rdb_checksum ("LSEG", buf, lsegblock)) goto error; lsegblock = rl (buf + 16); @@ -6500,6 +6602,7 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke } write_log (_T("RDB: Filesystem loaded, %d bytes\n"), i * (blocksize - 20)); put_long (parmpacket + PP_FSSIZE, i * (blocksize - 20)); /* RDB filesystem size hack */ + put_long (parmpacket + PP_ADDTOFSRES, -1); uip->rdb_filesysstore = fsmem; uip->rdb_filesyssize = i * (blocksize - 20); xfree (buf); @@ -6510,45 +6613,76 @@ error: return err; } -static void addfakefilesys (uaecptr parmpacket, uae_u32 dostype) +static void addfakefilesys (uaecptr parmpacket, uae_u32 dostype, int ver, int rev, struct uaedev_config_info *ci) { int i; + uae_u32 flags; + flags = 0x180; for (i = 0; i < 140; i++) put_byte (parmpacket + PP_FSHDSTART + i, 0); put_long (parmpacket + 80, dostype); put_long (parmpacket + PP_FSHDSTART, dostype); - put_long (parmpacket + PP_FSHDSTART + 8, 0x100 | (dostype == 0x444f5300 ? 0x0 : 0x80)); - put_long (parmpacket + PP_FSHDSTART + 44, 0xffffffff); + if (ver >= 0 && rev >= 0) + put_long (parmpacket + PP_FSHDSTART + 4, (ver << 16) | rev); + + put_long (parmpacket + PP_FSHDSTART + 12 + 4 * 4, ci->stacksize); + flags |= 0x10; + + if (ci->priority != -129) { + put_long (parmpacket + PP_FSHDSTART + 12 + 5 * 4, ci->priority); + flags |= 0x20; + } + put_long (parmpacket + PP_FSHDSTART + 12 + 8 * 4, kickstart_version < 36 && dostype == 0x444f5300 ? 0 : -1); // globvec + put_long (parmpacket + PP_FSHDSTART + 8, flags); // patchflags } -static int dofakefilesys (UnitInfo *uip, uaecptr parmpacket) +static uaecptr getfakefilesysseg (UnitInfo *uip) +{ + if (uip->filesysdir && _tcslen (uip->filesysdir) > 0) { + for (int i = 0; &mountinfo.ui[i] != uip; i++) { + UnitInfo *uip2 = &mountinfo.ui[i]; + if (!uip2->filesysdir) + continue; + if (_tcsicmp (uip2->filesysdir, uip->filesysdir) != 0) + continue; + if (uip2->filesysseg) + return uip2->filesysseg; + } + } + return 0; +} + +static int dofakefilesys (UnitInfo *uip, uaecptr parmpacket, struct uaedev_config_info *ci) { int i, size; TCHAR tmp[MAX_DPATH]; uae_u8 buf[512]; struct zfile *zf; - uae_u32 dostype, fsres, fsnode; + int ver = -1, rev = -1; + uae_u32 dostype; + uaecptr seg; - memset (buf, 0, 4); - hdf_read (&uip->hf, buf, 0, 512); - dostype = (buf[0] << 24) | (buf[1] << 16) |(buf[2] << 8) | buf[3]; - if (dostype == 0) + // we already have custom filesystem loaded for earlier hardfile? + seg = getfakefilesysseg (uip); + if (seg) { + // yes, re-use it. + put_long (parmpacket + PP_FSSIZE, 0); + put_long (parmpacket + PP_FSPTR, seg); + put_long (parmpacket + PP_ADDTOFSRES, 0); + write_log (_T("HDF: faked RDB filesystem '%s' reused\n"), uip->filesysdir); return FILESYS_HARDFILE; - fsres = get_long (parmpacket + PP_FSRES); - fsnode = get_long (fsres + 18); - while (get_long (fsnode)) { - if (get_long (fsnode + 14) == dostype) { - if (kickstart_version < 36) { - addfakefilesys (parmpacket, dostype); - } else if ((dostype & 0xffffff00) != 0x444f5300) { - addfakefilesys (parmpacket, dostype); - } - return FILESYS_HARDFILE; - } - fsnode = get_long (fsnode); } + if (!ci->dostype) { + memset (buf, 0, 4); + hdf_read (&uip->hf, buf, 0, 512); + dostype = (buf[0] << 24) | (buf[1] << 16) |(buf[2] << 8) | buf[3]; + } else { + dostype = ci->dostype; + } + if (dostype == 0) + return FILESYS_HARDFILE; tmp[0] = 0; if (uip->filesysdir && _tcslen (uip->filesysdir) > 0) { _tcscpy (tmp, uip->filesysdir); @@ -6582,12 +6716,68 @@ static int dofakefilesys (UnitInfo *uip, uaecptr parmpacket) zfile_fseek (zf, 0, SEEK_SET); uip->rdb_filesysstore = xmalloc (uae_u8, size); zfile_fread (uip->rdb_filesysstore, size, 1, zf); + for (i = 0; i < size - 6; i++) { + uae_u8 *p = uip->rdb_filesysstore + i; + if (p[0] == 'V' && p[1] == 'E' && p[2] == 'R' && p[3] == ':' && p[4] == ' ') { + uae_u8 *p2; + p += 5; + p2 = p; + while (*p2 && p2 - uip->rdb_filesysstore < size) + p2++; + if (p2[0] == 0) { + while (*p && (ver < 0 || rev < 0)) { + if (*p == ' ') { + p++; + ver = atol ((char*)p); + if (ver < 0) + ver = 0; + while (*p) { + if (*p == ' ') + break; + if (*p == '.') { + p++; + rev = atol ((char*)p); + if (rev < 0) + rev = 0; + } else { + p++; + } + } + break; + } else { + p++; + } + } + } + break; + } + } } zfile_fclose (zf); uip->rdb_filesyssize = size; + + uae_u32 fsres, fsnode; + int oldversion = -1; + int oldrevision = -1; + fsres = get_long (parmpacket + PP_FSRES); + fsnode = get_long (fsres + 18); + while (get_long (fsnode)) { + uae_u32 fsdostype = get_long (fsnode + 14); + if (fsdostype == dostype) { + oldversion = get_word (fsnode + 18); + oldrevision = get_word (fsnode + 20); + write_log (_T("HDF: %08X (%s) in FileSystem.resource version %d.%d\n"), dostype, dostypes (dostype), oldversion, oldrevision); + break; + } + fsnode = get_long (fsnode); + } + // DOS\0 is not in fs.resource + if (dostype == 0x444f5300 && oldversion < 0) + oldversion = 0; put_long (parmpacket + PP_FSSIZE, uip->rdb_filesyssize); - addfakefilesys (parmpacket, dostype); - write_log (_T("HDF: faked RDB filesystem %08X (%s) loaded\n"), dostype, dostypes (dostype)); + put_long (parmpacket + PP_ADDTOFSRES, oldversion < 0 ? -1 : 0); + addfakefilesys (parmpacket, dostype, ver, rev, ci); + write_log (_T("HDF: faked RDB filesystem %08X (%s %d.%d) loaded. ADD2FS=%d\n"), dostype, dostypes (dostype), ver, rev, oldversion < 0 ? 1 : 0); return FILESYS_HARDFILE; } @@ -6630,6 +6820,7 @@ static uae_u32 REGPARAM2 filesys_dev_storeinfo (TrapContext *context) int iscd = (m68k_dreg (regs, 6) & 0x80000000) != 0 || uip[unit_no].unit_type == UNIT_CDFS; int type; uaecptr parmpacket = m68k_areg (regs, 0); + struct uaedev_config_info *ci = &uip[unit_no].hf.ci; if (iscd) { TCHAR *cdname = NULL; @@ -6712,18 +6903,32 @@ static uae_u32 REGPARAM2 filesys_dev_storeinfo (TrapContext *context) put_long (parmpacket + 52, 0); /* lowCyl */ put_long (parmpacket + 56, 1); /* hiCyl */ } else { + uae_u8 buf[512] = { 0 }; + buf[36] = _tcslen (uip[unit_no].devname); + for (int i = 0; i < buf[36]; i++) + buf[37 + i] = uip[unit_no].devname[i]; put_long (parmpacket + 4, ROM_hardfile_resname); - put_long (parmpacket + 20, uip[unit_no].hf.blocksize >> 2); /* longwords per block */ - put_long (parmpacket + 28, uip[unit_no].hf.surfaces); /* heads */ - put_long (parmpacket + 32, 1); /* sectors per block */ - put_long (parmpacket + 36, uip[unit_no].hf.secspertrack); /* sectors per track */ - put_long (parmpacket + 40, uip[unit_no].hf.reservedblocks); /* reserved blocks */ - put_long (parmpacket + 52, 0); /* lowCyl */ - put_long (parmpacket + 56, uip[unit_no].hf.nrcyls <= 0 ? 0 : uip[unit_no].hf.nrcyls - 1); /* hiCyl */ + put_long (parmpacket + 20, ci->blocksize >> 2); /* longwords per block */ + put_long (parmpacket + 28, ci->surfaces); /* heads */ + put_long (parmpacket + 32, ci->sectorsperblock); /* sectors per block */ + put_long (parmpacket + 36, ci->sectors); /* sectors per track */ + put_long (parmpacket + 40, ci->reserved); /* reserved blocks */ + put_long (parmpacket + 52, ci->lowcyl); /* lowCyl */ + put_long (parmpacket + 56, ci->highcyl <= 0 ? ci->cyls - 1 : ci->highcyl - 1); /* hiCyl */ + put_long (parmpacket + 48, ci->interleave); /* interleave */ + put_long (parmpacket + 60, ci->buffers); /* Number of buffers */ + put_long (parmpacket + 64, ci->bufmemtype); /* Buffer mem type */ + put_long (parmpacket + 68, ci->maxtransfer); /* largest transfer */ + put_long (parmpacket + 72, ci->mask); /* dma mask */ + if (ci->dostype) // forced dostype? + put_long (parmpacket + 80, ci->dostype); /* dostype */ + for (int i = 0; i < 80; i++) + buf[i + 128] = get_byte (parmpacket + 16 + i); + dump_partinfo (&uip[unit_no].hf, buf); } if (type == FILESYS_HARDFILE) - type = dofakefilesys (&uip[unit_no], parmpacket); - if (uip[unit_no].bootpri < -127) + type = dofakefilesys (&uip[unit_no], parmpacket, ci); + if (uip[unit_no].bootpri < -127 || (type == FILESYS_HARDFILE && ci->rootdir[0] == 0)) m68k_dreg (regs, 7) = m68k_dreg (regs, 7) & ~1; /* do not boot */ if (uip[unit_no].bootpri < -128) return -1; /* do not mount */ @@ -6803,6 +7008,19 @@ void filesys_vsync (void) record_timeout (u); } + for (int i = 0; i < currprefs.mountitems; i++) { + struct hardfiledata *hfd = get_hardfile_data (currprefs.mountconfig[i].configoffset); + if (!hfd) + continue; + if (hfd->reinsertdelay > 0) { + hfd->reinsertdelay--; + if (hfd->reinsertdelay == 0) { + hfd->reinsertdelay = -1; + hardfile_media_change (hfd, &hfd->delayedci, true, true); + } + } + } + if (heartbeat_count <= 0) return; @@ -6884,16 +7102,16 @@ extern unsigned int cdfs_rom_len; void filesys_install_code (void) { - uae_u32 a, b; + uae_u32 a, b, items; bootrom_header = 3 * 4; align(4); a = here (); #include "filesys_bootrom.c" - bootrom_items = dlg (a + 8); + items = dlg (a + 8) & 0xffff; /* The last offset comes from the code itself, look for it near the top. */ - EXPANSION_bootcode = a + bootrom_header + bootrom_items * 4 - 4; + EXPANSION_bootcode = a + bootrom_header + items * 4 - 4; b = a + bootrom_header + 3 * 4 - 4; filesys_initcode = a + dlg (b) + bootrom_header - 4; } @@ -6906,16 +7124,16 @@ static uae_u8 *restore_filesys_hardfile (UnitInfo *ui, uae_u8 *src) hfd->virtsize = restore_u64(); hfd->offset = restore_u64(); - hfd->nrcyls = restore_u32(); - hfd->secspertrack = restore_u32(); - hfd->surfaces = restore_u32(); - hfd->reservedblocks = restore_u32(); - hfd->blocksize = restore_u32(); - hfd->readonly = restore_u32(); + hfd->ci.highcyl = restore_u32 (); + hfd->ci.sectors = restore_u32 (); + hfd->ci.surfaces = restore_u32 (); + hfd->ci.reserved = restore_u32 (); + hfd->ci.blocksize = restore_u32 (); + hfd->ci.readonly = restore_u32 () != 0; hfd->flags = restore_u32(); - hfd->cylinders = restore_u32(); - hfd->sectors = restore_u32(); - hfd->heads = restore_u32(); + hfd->rdbcylinders = restore_u32 (); + hfd->rdbsectors = restore_u32 (); + hfd->rdbheads = restore_u32 (); s = restore_string(); _tcscpy (hfd->vendor_id, s); xfree(s); @@ -6937,16 +7155,16 @@ static uae_u8 *save_filesys_hardfile (UnitInfo *ui, uae_u8 *dst) save_u64 (hfd->virtsize); save_u64 (hfd->offset); - save_u32 (hfd->nrcyls); - save_u32 (hfd->secspertrack); - save_u32 (hfd->surfaces); - save_u32 (hfd->reservedblocks); - save_u32 (hfd->blocksize); - save_u32 (hfd->readonly); + save_u32 (hfd->ci.highcyl); + save_u32 (hfd->ci.sectors); + save_u32 (hfd->ci.surfaces); + save_u32 (hfd->ci.reserved); + save_u32 (hfd->ci.blocksize); + save_u32 (hfd->ci.readonly); save_u32 (hfd->flags); - save_u32 (hfd->cylinders); - save_u32 (hfd->sectors); - save_u32 (hfd->heads); + save_u32 (hfd->rdbcylinders); + save_u32 (hfd->rdbsectors); + save_u32 (hfd->rdbheads); save_string (hfd->vendor_id); save_string (hfd->product_id); save_string (hfd->product_rev); @@ -7123,13 +7341,13 @@ static uae_u8 *restore_aino (UnitInfo *ui, Unit *u, uae_u8 *src) static uae_u8 *restore_key (UnitInfo *ui, Unit *u, uae_u8 *src) { + uae_u32 uniq; TCHAR *p, *pn; mode_t openmode; int err; int missing; a_inode *a; Key *k; - uae_u32 uniq; uae_u64 savedsize, size, pos; missing = 0; @@ -7518,13 +7736,15 @@ uae_u8 *restore_filesys (uae_u8 *src) int type, devno; UnitInfo *ui; TCHAR *devname = 0, *volname = 0, *rootdir = 0, *filesysdir = 0; - int bootpri; - bool readonly; uae_u32 startup; + struct uaedev_config_info *ci; if (restore_u32 () != 2) return src; devno = restore_u32 (); + ui = &mountinfo.ui[devno]; + ci = &ui->hf.ci; + uci_set_defaults (ci, false); type = restore_u16 (); if (type == FILESYS_VIRTUAL) { rootdir = restore_path (SAVESTATE_PATH_VDIR); @@ -7543,21 +7763,23 @@ uae_u8 *restore_filesys (uae_u8 *src) devname = restore_string (); volname = restore_string (); filesysdir = restore_path (SAVESTATE_PATH); - bootpri = restore_u8 (); - readonly = restore_u8 () != 0; + ci->bootpri = restore_u8 (); + ci->readonly = restore_u8 () != 0; startup = restore_u32 (); filesys_configdev = restore_u32 (); - ui = &mountinfo.ui[devno]; if (type == FILESYS_HARDFILE || type == FILESYS_HARDFILE_RDB) { src = restore_filesys_hardfile (ui, src); xfree (volname); volname = NULL; } - if (set_filesys_unit (devno, devname, volname, rootdir, readonly, - ui->hf.cylinders, ui->hf.secspertrack, ui->hf.surfaces, ui->hf.reservedblocks, ui->hf.blocksize, - bootpri, false, true, filesysdir[0] ? filesysdir : NULL, 0, 0) < 0) { - write_log (_T("filesys '%s' failed to restore\n"), rootdir); - goto end; + _tcscpy (ci->rootdir, rootdir); + _tcscpy (ci->devname, devname); + _tcscpy (ci->volname, volname); + _tcscpy (ci->filesys, filesysdir); + + if (set_filesys_unit (devno, ci) < 0) { + write_log (_T("filesys '%s' failed to restore\n"), rootdir); + goto end; } ui->devno = devno; ui->startup = startup; diff --git a/src/filesys_bootrom.c b/src/filesys_bootrom.c index ec824ed..c65f075 100644 --- a/src/filesys_bootrom.c +++ b/src/filesys_bootrom.c @@ -1,13 +1,13 @@ db(0x00); db(0x00); db(0x00); db(0x10); db(0x00); db(0x00); db(0x00); db(0x00); - db(0x00); db(0x00); db(0x00); db(0x09); db(0x60); db(0x00); db(0x0a); db(0xfe); - db(0x00); db(0x00); db(0x08); db(0xac); db(0x00); db(0x00); db(0x00); db(0xe0); + db(0x60); db(0x02); db(0x00); db(0x09); db(0x60); db(0x00); db(0x0b); db(0x12); + db(0x00); db(0x00); db(0x08); db(0xae); db(0x00); db(0x00); db(0x00); db(0xe0); db(0x00); db(0x00); db(0x02); db(0x74); db(0x00); db(0x00); db(0x00); db(0x24); db(0x00); db(0x00); db(0x03); db(0x82); db(0x00); db(0x00); db(0x00); db(0x00); - db(0x00); db(0x00); db(0x13); db(0x8c); db(0x43); db(0xfa); db(0x18); db(0x95); + db(0x00); db(0x00); db(0x13); db(0xa0); db(0x43); db(0xfa); db(0x18); db(0xa9); db(0x4e); db(0xae); db(0xff); db(0xa0); db(0x20); db(0x40); db(0x20); db(0x28); db(0x00); db(0x16); db(0x20); db(0x40); db(0x4e); db(0x90); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0xe0); db(0xe2); db(0x30); db(0x3c); db(0xff); db(0x38); - db(0x72); db(0x11); db(0x61); db(0x00); db(0x17); db(0x7e); db(0x4e); db(0x90); + db(0x72); db(0x11); db(0x61); db(0x00); db(0x17); db(0x92); db(0x4e); db(0x90); db(0x4a); db(0x80); db(0x67); db(0x4c); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x0c); db(0x6e); db(0x00); db(0x25); db(0x00); db(0x14); db(0x65); db(0x40); db(0x70); db(0x14); db(0x24); db(0x00); db(0x72); db(0x01); db(0x4e); db(0xae); @@ -22,66 +22,66 @@ db(0x20); db(0x68); db(0x00); db(0x02); db(0x2f); db(0x08); db(0x4e); db(0x90); db(0x20); db(0x5f); db(0x58); db(0x8f); db(0x48); db(0xe7); db(0xff); db(0x7e); db(0x22); db(0x4e); db(0x20); db(0x08); db(0x30); db(0x7c); db(0xff); db(0xb8); - db(0x4e); db(0xae); db(0xfe); db(0x5c); db(0x61); db(0x00); db(0x12); db(0xce); - db(0x61); db(0x00); db(0x16); db(0x94); db(0x4c); db(0xdf); db(0x7e); db(0xff); + db(0x4e); db(0xae); db(0xfe); db(0x5c); db(0x61); db(0x00); db(0x12); db(0xe2); + db(0x61); db(0x00); db(0x16); db(0xa8); db(0x4c); db(0xdf); db(0x7e); db(0xff); db(0x4e); db(0x75); db(0x00); db(0x00); db(0x08); db(0x00); db(0x00); db(0x02); db(0x67); db(0x06); db(0x4e); db(0xb9); db(0x00); db(0xf0); db(0x00); db(0x00); db(0x4e); db(0xf9); db(0x00); db(0xf0); db(0x00); db(0x00); db(0x00); db(0x00); db(0x48); db(0xe7); db(0xff); db(0xfe); db(0x2c); db(0x78); db(0x00); db(0x04); - db(0x30); db(0x3c); db(0xff); db(0xec); db(0x61); db(0x00); db(0x16); db(0xd4); - db(0x2a); db(0x50); db(0x43); db(0xfa); db(0x17); db(0xf6); db(0x70); db(0x24); + db(0x30); db(0x3c); db(0xff); db(0xec); db(0x61); db(0x00); db(0x16); db(0xe8); + db(0x2a); db(0x50); db(0x43); db(0xfa); db(0x18); db(0x0a); db(0x70); db(0x24); db(0x7a); db(0x01); db(0x4e); db(0xae); db(0xfd); db(0xd8); db(0x4a); db(0x80); - db(0x66); db(0x0c); db(0x43); db(0xfa); db(0x17); db(0xe6); db(0x70); db(0x00); + db(0x66); db(0x0c); db(0x43); db(0xfa); db(0x17); db(0xfa); db(0x70); db(0x00); db(0x7a); db(0x00); db(0x4e); db(0xae); db(0xfd); db(0xd8); db(0x28); db(0x40); db(0x4a); db(0xad); db(0x01); db(0x0c); db(0x67); db(0x00); db(0x00); db(0x5c); - db(0x20); db(0x3c); db(0x00); db(0x00); db(0x02); db(0x2c); db(0x22); db(0x3c); + db(0x20); db(0x3c); db(0x00); db(0x00); db(0x02); db(0x30); db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); - db(0x26); db(0x40); db(0x27); db(0x4c); db(0x01); db(0x9c); db(0x7c); db(0x00); + db(0x26); db(0x40); db(0x27); db(0x4c); db(0x01); db(0xa0); db(0x7c); db(0x00); db(0xbc); db(0x6d); db(0x01); db(0x0e); db(0x64); db(0x2c); db(0x2f); db(0x06); db(0x7e); db(0x01); db(0x4a); db(0x45); db(0x67); db(0x04); db(0x08); db(0xc7); db(0x00); db(0x02); db(0x2f); db(0x0b); db(0x20); db(0x4b); db(0x61); db(0x00); - db(0x07); db(0x64); db(0x26); db(0x5f); db(0x0c); db(0x80); db(0xff); db(0xff); + db(0x07); db(0x66); db(0x26); db(0x5f); db(0x0c); db(0x80); db(0xff); db(0xff); db(0xff); db(0xfe); db(0x67); db(0x08); db(0x48); db(0x46); db(0x52); db(0x46); db(0x48); db(0x46); db(0x60); db(0xdc); db(0x2c); db(0x1f); db(0x52); db(0x46); db(0x60); db(0xce); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x22); db(0x4b); - db(0x20); db(0x3c); db(0x00); db(0x00); db(0x02); db(0x2c); db(0x4e); db(0xae); + db(0x20); db(0x3c); db(0x00); db(0x00); db(0x02); db(0x30); db(0x4e); db(0xae); db(0xff); db(0x2e); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x22); db(0x4c); db(0x4e); db(0xae); db(0xfe); db(0x62); db(0x78); db(0x03); db(0x0c); db(0x6e); db(0x00); db(0x24); db(0x00); db(0x14); db(0x65); db(0x04); db(0x00); db(0x44); db(0x01); db(0x00); db(0x43); db(0xf9); db(0x00); db(0x21); db(0x00); db(0x00); db(0x4e); db(0xae); db(0xfd); db(0xea); db(0x4a); db(0x80); db(0x66); db(0x20); - db(0x30); db(0x3c); db(0xff); db(0x80); db(0x61); db(0x00); db(0x16); db(0x24); + db(0x30); db(0x3c); db(0xff); db(0x80); db(0x61); db(0x00); db(0x16); db(0x38); db(0x4e); db(0x90); db(0x22); db(0x04); db(0x74); db(0xf6); db(0x20); db(0x7c); db(0x00); db(0x20); db(0x00); db(0x00); db(0x90); db(0x88); db(0x65); db(0x08); db(0x67); db(0x06); db(0x93); db(0xc9); db(0x4e); db(0xae); db(0xfd); db(0x96); - db(0x30); db(0x3c); db(0xff); db(0x80); db(0x61); db(0x00); db(0x16); db(0x04); + db(0x30); db(0x3c); db(0xff); db(0x80); db(0x61); db(0x00); db(0x16); db(0x18); db(0x4e); db(0x90); db(0x20); db(0x49); db(0x20); db(0x01); db(0x67); db(0x0c); - db(0x22); db(0x04); db(0x74); db(0xfb); db(0x43); db(0xfa); db(0x17); db(0x42); - db(0x4e); db(0xae); db(0xfd); db(0x96); db(0x41); db(0xfa); db(0x16); db(0xb9); + db(0x22); db(0x04); db(0x74); db(0xfb); db(0x43); db(0xfa); db(0x17); db(0x56); + db(0x4e); db(0xae); db(0xfd); db(0x96); db(0x41); db(0xfa); db(0x16); db(0xcd); db(0x43); db(0xfa); db(0x00); db(0x54); db(0x70); db(0x0a); db(0x61); db(0x00); - db(0x0c); db(0x62); db(0x22); db(0x40); db(0x72); db(0x01); db(0x30); db(0x3c); - db(0xff); db(0x48); db(0x61); db(0x00); db(0x15); db(0xd6); db(0x4e); db(0x90); + db(0x0c); db(0x76); db(0x22); db(0x40); db(0x72); db(0x01); db(0x30); db(0x3c); + db(0xff); db(0x48); db(0x61); db(0x00); db(0x15); db(0xea); db(0x4e); db(0x90); db(0x4c); db(0xdf); db(0x7f); db(0xff); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x38); db(0x22); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x24); db(0x00); db(0x28); db(0x01); db(0x26); db(0x09); db(0x24); db(0x48); db(0x43); db(0xfa); - db(0x16); db(0xb3); db(0x70); db(0x00); db(0x4e); db(0xae); db(0xfd); db(0xd8); + db(0x16); db(0xc7); db(0x70); db(0x00); db(0x4e); db(0xae); db(0xfd); db(0xd8); db(0x4a); db(0x80); db(0x67); db(0x14); db(0x2c); db(0x40); db(0x22); db(0x0a); db(0xe4); db(0x8b); db(0x4e); db(0xae); db(0xff); db(0x76); db(0x22); db(0x4e); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x4e); db(0xae); db(0xfe); db(0x62); db(0x4c); db(0xdf); db(0x44); db(0x1c); db(0x4e); db(0x75); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x70); db(0x00); db(0x08); db(0xc0); db(0x00); db(0x0d); - db(0x4e); db(0xae); db(0xfe); db(0xc2); db(0x41); db(0xfa); db(0x16); db(0x64); + db(0x4e); db(0xae); db(0xfe); db(0xc2); db(0x41); db(0xfa); db(0x16); db(0x78); db(0x43); db(0xfa); db(0x00); db(0x16); db(0x70); db(0x0f); db(0x22); db(0x3c); db(0x00); db(0x00); db(0x1f); db(0x40); db(0x61); db(0x00); db(0xff); db(0xa8); db(0x60); db(0xdc); db(0x00); db(0x00); db(0x00); db(0x00); db(0x00); db(0x10); db(0x00); db(0x00); db(0x00); db(0x00); db(0x72); db(0x02); db(0x30); db(0x3c); - db(0xff); db(0x48); db(0x61); db(0x00); db(0x15); db(0x5e); db(0x4e); db(0x90); - db(0x22); db(0x00); db(0x6b); db(0x04); db(0x61); db(0x00); db(0x07); db(0xf0); + db(0xff); db(0x48); db(0x61); db(0x00); db(0x15); db(0x72); db(0x4e); db(0x90); + db(0x22); db(0x00); db(0x6b); db(0x04); db(0x61); db(0x00); db(0x08); db(0x04); db(0x70); db(0x00); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x00); db(0x20); - db(0x30); db(0x3c); db(0xff); db(0x50); db(0x61); db(0x00); db(0x15); db(0x44); + db(0x30); db(0x3c); db(0xff); db(0x50); db(0x61); db(0x00); db(0x15); db(0x58); db(0x70); db(0x00); db(0x4e); db(0x90); db(0x4a); db(0x80); db(0x67); db(0x00); db(0x00); db(0xa2); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x30); db(0x3c); - db(0xff); db(0x50); db(0x61); db(0x00); db(0x15); db(0x2e); db(0x70); db(0x02); + db(0xff); db(0x50); db(0x61); db(0x00); db(0x15); db(0x42); db(0x70); db(0x02); db(0x4e); db(0x90); db(0x0c); db(0x40); db(0x00); db(0x01); db(0x6d); db(0x00); db(0x00); db(0x7c); db(0x6e); db(0x06); db(0x4e); db(0xae); db(0xfe); db(0x92); db(0x60); db(0xe4); db(0x0c); db(0x40); db(0x00); db(0x02); db(0x6e); db(0x08); @@ -99,14 +99,14 @@ db(0x00); db(0x18); db(0x25); db(0x49); db(0x00); db(0x1a); db(0x20); db(0x69); db(0x00); db(0x10); db(0x22); db(0x4a); db(0x4e); db(0xae); db(0xfe); db(0x92); db(0x60); db(0x00); db(0xff); db(0x74); db(0x30); db(0x3c); db(0xff); db(0x50); - db(0x61); db(0x00); db(0x14); db(0xa0); db(0x70); db(0x04); db(0x4e); db(0x90); + db(0x61); db(0x00); db(0x14); db(0xb4); db(0x70); db(0x04); db(0x4e); db(0x90); db(0x70); db(0x01); db(0x4c); db(0xdf); db(0x04); db(0x00); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0xc0); db(0xe0); db(0x30); db(0x3c); db(0xff); db(0x38); - db(0x72); db(0x12); db(0x61); db(0x00); db(0x14); db(0x86); db(0x4e); db(0x90); + db(0x72); db(0x12); db(0x61); db(0x00); db(0x14); db(0x9a); db(0x4e); db(0x90); db(0x24); db(0x40); db(0x70); db(0x16); db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x22); db(0x40); db(0x13); db(0x7c); db(0x00); db(0x02); db(0x00); db(0x08); db(0x13); db(0x7c); - db(0x00); db(0xf6); db(0x00); db(0x09); db(0x41); db(0xfa); db(0x15); db(0x13); + db(0x00); db(0xf6); db(0x00); db(0x09); db(0x41); db(0xfa); db(0x15); db(0x27); db(0x23); db(0x48); db(0x00); db(0x0a); db(0x41); db(0xfa); db(0x00); db(0x16); db(0x23); db(0x48); db(0x00); db(0x12); db(0x23); db(0x4a); db(0x00); db(0x0e); db(0x70); db(0x05); db(0x4e); db(0xae); db(0xff); db(0x58); db(0x4c); db(0xdf); @@ -114,24 +114,24 @@ db(0x4e); db(0x75); db(0x48); db(0xe7); db(0xc0); db(0xc0); db(0x61); db(0x00); db(0xfc); db(0xb0); db(0x70); db(0x1a); db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x22); db(0x40); - db(0x41); db(0xfa); db(0x14); db(0xe6); db(0x23); db(0x48); db(0x00); db(0x0a); + db(0x41); db(0xfa); db(0x14); db(0xfa); db(0x23); db(0x48); db(0x00); db(0x0a); db(0x41); db(0xfa); db(0xfe); db(0xd2); db(0x23); db(0x48); db(0x00); db(0x0e); db(0x41); db(0xfa); db(0xfe); db(0xca); db(0x23); db(0x48); db(0x00); db(0x12); db(0x33); db(0x7c); db(0x02); db(0x14); db(0x00); db(0x08); db(0x70); db(0x03); db(0x4e); db(0xae); db(0xff); db(0x58); db(0x61); db(0x00); db(0xff); db(0x72); db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x04); db(0x61); db(0x00); - db(0x13); db(0xfa); db(0x4e); db(0x90); db(0x4a); db(0x80); db(0x67); db(0x04); - db(0x61); db(0x00); db(0x0a); db(0xcc); db(0x4c); db(0xdf); db(0x03); db(0x03); + db(0x14); db(0x0e); db(0x4e); db(0x90); db(0x4a); db(0x80); db(0x67); db(0x04); + db(0x61); db(0x00); db(0x0a); db(0xe0); db(0x4c); db(0xdf); db(0x03); db(0x03); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0xc0); db(0xf2); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x24); db(0x48); db(0x26); db(0x49); db(0x20); db(0x3c); db(0x00); db(0x00); db(0x00); db(0xbe); db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x20); db(0x40); - db(0x70); db(0x00); db(0x43); db(0xeb); db(0x01); db(0xa0); db(0x11); db(0xb1); + db(0x70); db(0x00); db(0x43); db(0xeb); db(0x01); db(0xa4); db(0x11); db(0xb1); db(0x00); db(0x00); db(0x00); db(0x0e); db(0x52); db(0x40); db(0x0c); db(0x40); db(0x00); db(0x8c); db(0x66); db(0xf2); db(0x20); db(0x0a); db(0xe4); db(0x88); db(0x21); db(0x40); db(0x00); db(0x36); db(0x22); db(0x48); db(0x41); db(0xfa); - db(0x14); db(0x68); db(0x23); db(0x48); db(0x00); db(0x0a); db(0x20); db(0x6b); - db(0x01); db(0x98); db(0x41); db(0xe8); db(0x00); db(0x12); db(0x4e); db(0xae); + db(0x14); db(0x7c); db(0x23); db(0x48); db(0x00); db(0x0a); db(0x20); db(0x6b); + db(0x01); db(0x9c); db(0x41); db(0xe8); db(0x00); db(0x12); db(0x4e); db(0xae); db(0xff); db(0x10); db(0x4c); db(0xdf); db(0x4f); db(0x03); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x7f); db(0x7e); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x24); db(0x48); db(0x0c); db(0x9a); db(0x00); db(0x00); db(0x03); db(0xf3); @@ -163,645 +163,647 @@ db(0x60); db(0xe4); db(0x0c); db(0x83); db(0x00); db(0x00); db(0x03); db(0xf2); db(0x66); db(0x14); db(0x52); db(0x86); db(0xbe); db(0x86); db(0x66); db(0x00); db(0xff); db(0x8a); db(0x7e); db(0x01); db(0x20); db(0x54); db(0x20); db(0x07); - db(0x4c); db(0xdf); db(0x7e); db(0xfe); db(0x4e); db(0x75); db(0x7e); db(0x00); - db(0x60); db(0xf4); db(0x48); db(0xe7); db(0x40); db(0xe2); db(0x2c); db(0x78); - db(0x00); db(0x04); db(0x41); db(0xee); db(0x01); db(0x50); db(0x20); db(0x50); - db(0x4a); db(0x90); db(0x67); db(0x1a); db(0x22); db(0x68); db(0x00); db(0x0a); - db(0x45); db(0xfa); db(0x13); db(0xba); db(0x10); db(0x19); db(0x12); db(0x1a); - db(0xb0); db(0x01); db(0x66); db(0x06); db(0x4a); db(0x00); db(0x67); db(0x42); - db(0x60); db(0xf2); db(0x20); db(0x50); db(0x60); db(0xe2); db(0x70); db(0x20); - db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); - db(0xff); db(0x3a); db(0x24); db(0x40); db(0x15); db(0x7c); db(0x00); db(0x08); - db(0x00); db(0x08); db(0x41); db(0xfa); db(0x13); db(0x90); db(0x25); db(0x48); - db(0x00); db(0x0a); db(0x41); db(0xfa); db(0x13); db(0x0c); db(0x25); db(0x48); - db(0x00); db(0x0e); db(0x41); db(0xea); db(0x00); db(0x12); db(0x20); db(0x88); - db(0x58); db(0x90); db(0x21); db(0x48); db(0x00); db(0x08); db(0x41); db(0xee); - db(0x01); db(0x50); db(0x22); db(0x4a); db(0x4e); db(0xae); db(0xff); db(0x0a); - db(0x20); db(0x4a); db(0x20); db(0x08); db(0x4c); db(0xdf); db(0x47); db(0x02); - db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x01); db(0x02); db(0x2e); db(0x00); - db(0x4a); db(0x2b); db(0x00); db(0x4c); db(0x67); db(0x7c); db(0x2c); db(0x6b); - db(0x00); db(0xa0); db(0x0c); db(0x6e); db(0x00); db(0x25); db(0x00); db(0x14); - db(0x65); db(0x3e); db(0x72); db(0x0e); db(0x4e); db(0xae); db(0xfd); db(0x66); - db(0x02); db(0x80); db(0xff); db(0xff); db(0xff); db(0xfe); db(0x67); db(0x62); - db(0x08); db(0x07); db(0x00); db(0x00); db(0x67); db(0x0a); db(0x41); db(0xeb); - db(0x00); db(0x20); db(0x22); db(0x08); db(0x4e); db(0xae); db(0xfd); db(0x5a); + db(0x4c); db(0xdf); db(0x7e); db(0xfe); db(0x4e); db(0x75); db(0x91); db(0xc8); + db(0x7e); db(0x00); db(0x60); db(0xf2); db(0x48); db(0xe7); db(0x40); db(0xe2); + db(0x2c); db(0x78); db(0x00); db(0x04); db(0x41); db(0xee); db(0x01); db(0x50); + db(0x20); db(0x50); db(0x4a); db(0x90); db(0x67); db(0x1a); db(0x22); db(0x68); + db(0x00); db(0x0a); db(0x45); db(0xfa); db(0x13); db(0xcc); db(0x10); db(0x19); + db(0x12); db(0x1a); db(0xb0); db(0x01); db(0x66); db(0x06); db(0x4a); db(0x00); + db(0x67); db(0x42); db(0x60); db(0xf2); db(0x20); db(0x50); db(0x60); db(0xe2); + db(0x70); db(0x20); db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); + db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x24); db(0x40); db(0x15); db(0x7c); + db(0x00); db(0x08); db(0x00); db(0x08); db(0x41); db(0xfa); db(0x13); db(0xa2); + db(0x25); db(0x48); db(0x00); db(0x0a); db(0x41); db(0xfa); db(0x13); db(0x1e); + db(0x25); db(0x48); db(0x00); db(0x0e); db(0x41); db(0xea); db(0x00); db(0x12); + db(0x20); db(0x88); db(0x58); db(0x90); db(0x21); db(0x48); db(0x00); db(0x08); + db(0x41); db(0xee); db(0x01); db(0x50); db(0x22); db(0x4a); db(0x4e); db(0xae); + db(0xff); db(0x0a); db(0x20); db(0x4a); db(0x20); db(0x08); db(0x4c); db(0xdf); + db(0x47); db(0x02); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x01); db(0x02); + db(0x2e); db(0x00); db(0x4a); db(0x2b); db(0x00); db(0x4c); db(0x67); db(0x7c); + db(0x2c); db(0x6b); db(0x00); db(0xa0); db(0x0c); db(0x6e); db(0x00); db(0x25); + db(0x00); db(0x14); db(0x65); db(0x3e); db(0x72); db(0x0e); db(0x4e); db(0xae); + db(0xfd); db(0x66); db(0x02); db(0x80); db(0xff); db(0xff); db(0xff); db(0xfe); + db(0x67); db(0x62); db(0x08); db(0x07); db(0x00); db(0x00); db(0x67); db(0x0a); + db(0x41); db(0xeb); db(0x00); db(0x20); db(0x22); db(0x08); db(0x4e); db(0xae); + db(0xfd); db(0x5a); db(0x08); db(0x07); db(0x00); db(0x01); db(0x67); db(0x12); + db(0x4a); db(0x2b); db(0x00); db(0x9e); db(0x66); db(0x0c); db(0x50); db(0xeb); + db(0x00); db(0x9e); db(0x22); db(0x2b); db(0x00); db(0xb4); db(0x4e); db(0xae); + db(0xfd); db(0x5a); db(0x72); db(0x0e); db(0x4e); db(0xae); db(0xfd); db(0x6c); + db(0x60); db(0x32); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x4e); db(0xae); + db(0xff); db(0x7c); db(0x08); db(0x07); db(0x00); db(0x00); db(0x67); db(0x08); + db(0x41); db(0xeb); db(0x00); db(0x20); db(0x61); db(0x00); db(0x00); db(0xac); db(0x08); db(0x07); db(0x00); db(0x01); db(0x67); db(0x12); db(0x4a); db(0x2b); db(0x00); db(0x9e); db(0x66); db(0x0c); db(0x50); db(0xeb); db(0x00); db(0x9e); - db(0x22); db(0x2b); db(0x00); db(0xb4); db(0x4e); db(0xae); db(0xfd); db(0x5a); - db(0x72); db(0x0e); db(0x4e); db(0xae); db(0xfd); db(0x6c); db(0x60); db(0x32); - db(0x2c); db(0x78); db(0x00); db(0x04); db(0x4e); db(0xae); db(0xff); db(0x7c); - db(0x08); db(0x07); db(0x00); db(0x00); db(0x67); db(0x08); db(0x41); db(0xeb); - db(0x00); db(0x20); db(0x61); db(0x00); db(0x00); db(0xac); db(0x08); db(0x07); - db(0x00); db(0x01); db(0x67); db(0x12); db(0x4a); db(0x2b); db(0x00); db(0x9e); - db(0x66); db(0x0c); db(0x50); db(0xeb); db(0x00); db(0x9e); db(0x20); db(0x6b); - db(0x00); db(0xb4); db(0x61); db(0x00); db(0x00); db(0x94); db(0x4e); db(0xae); - db(0xff); db(0x76); db(0x4c); db(0xdf); db(0x40); db(0x80); db(0x4e); db(0x75); - db(0x48); db(0xe7); db(0x01); db(0x22); db(0x2e); db(0x00); db(0x2c); db(0x6b); - db(0x00); db(0xa0); db(0x0c); db(0x6e); db(0x00); db(0x25); db(0x00); db(0x14); - db(0x65); db(0x3e); db(0x72); db(0x0e); db(0x4e); db(0xae); db(0xfd); db(0x66); - db(0x02); db(0x80); db(0xff); db(0xff); db(0xff); db(0xfe); db(0x67); db(0x62); - db(0x08); db(0x07); db(0x00); db(0x00); db(0x67); db(0x0a); db(0x41); db(0xeb); - db(0x00); db(0x20); db(0x22); db(0x08); db(0x4e); db(0xae); db(0xfd); db(0x60); + db(0x20); db(0x6b); db(0x00); db(0xb4); db(0x61); db(0x00); db(0x00); db(0x94); + db(0x4e); db(0xae); db(0xff); db(0x76); db(0x4c); db(0xdf); db(0x40); db(0x80); + db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x01); db(0x22); db(0x2e); db(0x00); + db(0x2c); db(0x6b); db(0x00); db(0xa0); db(0x0c); db(0x6e); db(0x00); db(0x25); + db(0x00); db(0x14); db(0x65); db(0x3e); db(0x72); db(0x0e); db(0x4e); db(0xae); + db(0xfd); db(0x66); db(0x02); db(0x80); db(0xff); db(0xff); db(0xff); db(0xfe); + db(0x67); db(0x62); db(0x08); db(0x07); db(0x00); db(0x00); db(0x67); db(0x0a); + db(0x41); db(0xeb); db(0x00); db(0x20); db(0x22); db(0x08); db(0x4e); db(0xae); + db(0xfd); db(0x60); db(0x08); db(0x07); db(0x00); db(0x01); db(0x67); db(0x12); + db(0x4a); db(0x2b); db(0x00); db(0x9e); db(0x67); db(0x0c); db(0x42); db(0x2b); + db(0x00); db(0x9e); db(0x22); db(0x2b); db(0x00); db(0xb4); db(0x4e); db(0xae); + db(0xfd); db(0x60); db(0x72); db(0x0e); db(0x4e); db(0xae); db(0xfd); db(0x6c); + db(0x60); db(0x32); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x4e); db(0xae); + db(0xff); db(0x7c); db(0x08); db(0x07); db(0x00); db(0x00); db(0x67); db(0x08); + db(0x41); db(0xeb); db(0x00); db(0x20); db(0x61); db(0x00); db(0x00); db(0x44); db(0x08); db(0x07); db(0x00); db(0x01); db(0x67); db(0x12); db(0x4a); db(0x2b); db(0x00); db(0x9e); db(0x67); db(0x0c); db(0x42); db(0x2b); db(0x00); db(0x9e); - db(0x22); db(0x2b); db(0x00); db(0xb4); db(0x4e); db(0xae); db(0xfd); db(0x60); - db(0x72); db(0x0e); db(0x4e); db(0xae); db(0xfd); db(0x6c); db(0x60); db(0x32); - db(0x2c); db(0x78); db(0x00); db(0x04); db(0x4e); db(0xae); db(0xff); db(0x7c); - db(0x08); db(0x07); db(0x00); db(0x00); db(0x67); db(0x08); db(0x41); db(0xeb); - db(0x00); db(0x20); db(0x61); db(0x00); db(0x00); db(0x44); db(0x08); db(0x07); - db(0x00); db(0x01); db(0x67); db(0x12); db(0x4a); db(0x2b); db(0x00); db(0x9e); - db(0x67); db(0x0c); db(0x42); db(0x2b); db(0x00); db(0x9e); db(0x20); db(0x6b); - db(0x00); db(0xb4); db(0x61); db(0x00); db(0x00); db(0x2c); db(0x4e); db(0xae); - db(0xff); db(0x76); db(0x4c); db(0xdf); db(0x44); db(0x80); db(0x4e); db(0x75); - db(0x22); db(0x48); db(0x20); db(0x6b); db(0x00); db(0xa0); db(0x20); db(0x68); - db(0x00); db(0x22); db(0x20); db(0x68); db(0x00); db(0x18); db(0xd1); db(0xc8); - db(0xd1); db(0xc8); db(0x22); db(0xa8); db(0x00); db(0x04); db(0x20); db(0x09); - db(0xe4); db(0x88); db(0x21); db(0x40); db(0x00); db(0x04); db(0x4e); db(0x75); - db(0x24); db(0x48); db(0x20); db(0x6b); db(0x00); db(0xa0); db(0x20); db(0x68); - db(0x00); db(0x22); db(0x20); db(0x68); db(0x00); db(0x18); db(0xd1); db(0xc8); - db(0xd1); db(0xc8); db(0x22); db(0x68); db(0x00); db(0x04); db(0xd3); db(0xc9); - db(0xd3); db(0xc9); db(0xb3); db(0xca); db(0x66); db(0x06); db(0x21); db(0x52); - db(0x00); db(0x04); db(0x60); db(0x18); db(0x20); db(0x09); db(0x67); db(0x0e); - db(0x20); db(0x11); db(0xd0); db(0x80); db(0xd0); db(0x80); db(0xb5); db(0xc0); - db(0x67); db(0x04); db(0x22); db(0x40); db(0x60); db(0xee); db(0x20); db(0x09); - db(0x67); db(0x02); db(0x22); db(0x92); db(0x4e); db(0x75); db(0x48); db(0xe7); - db(0x20); db(0x22); db(0x74); db(0x16); db(0x9f); db(0xc2); db(0x24); db(0x4f); - db(0x32); db(0x02); db(0x42); db(0x32); db(0x10); db(0xff); db(0x53); db(0x41); - db(0x66); db(0xf8); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x72); db(0x0f); - db(0x4a); db(0x80); db(0x67); db(0x02); db(0x72); db(0x10); db(0x15); db(0x41); - db(0x00); db(0x04); db(0x35); db(0x7c); db(0x08); db(0x00); db(0x00); db(0x08); - db(0x22); db(0x6b); db(0x00); db(0xa4); db(0x33); db(0x7c); db(0x00); db(0x0b); - db(0x00); db(0x1c); db(0x23); db(0x7c); db(0x00); db(0x00); db(0x00); db(0x16); - db(0x00); db(0x24); db(0x23); db(0x4a); db(0x00); db(0x28); db(0x13); db(0x7c); - db(0x00); db(0x01); db(0x00); db(0x1e); db(0x22); db(0x6b); db(0x00); db(0xa8); - db(0x33); db(0x7c); db(0x00); db(0x0a); db(0x00); db(0x1c); db(0x13); db(0x7c); - db(0x00); db(0x01); db(0x00); db(0x1e); db(0x4e); db(0xae); db(0xfe); db(0x38); - db(0x22); db(0x6b); db(0x00); db(0xa8); db(0x25); db(0x69); db(0x00); db(0x20); - db(0x00); db(0x0e); db(0x25); db(0x69); db(0x00); db(0x24); db(0x00); db(0x12); - db(0x22); db(0x6b); db(0x00); db(0xa4); db(0x4e); db(0xae); db(0xfe); db(0x38); - db(0xdf); db(0xc2); db(0x4c); db(0xdf); db(0x44); db(0x04); db(0x4e); db(0x75); - db(0x4a); db(0x00); db(0x67); db(0x26); db(0x4a); db(0x2b); db(0x00); db(0x4c); - db(0x66); db(0x36); db(0x70); db(0x00); db(0x4a); db(0x33); db(0x00); db(0x4d); - db(0x67); db(0x04); db(0x52); db(0x00); db(0x60); db(0xf6); db(0x17); db(0x40); - db(0x00); db(0x4c); db(0x67); db(0x24); db(0x20); db(0x01); db(0x61); db(0x00); - db(0xfd); db(0xf2); db(0x70); db(0x01); db(0x61); db(0x00); db(0xff); db(0x60); - db(0x60); db(0x16); db(0x4a); db(0x2b); db(0x00); db(0x4c); db(0x67); db(0x10); - db(0x42); db(0x2b); db(0x00); db(0x4c); db(0x20); db(0x01); db(0x61); db(0x00); - db(0xfe); db(0x68); db(0x70); db(0x00); db(0x61); db(0x00); db(0xff); db(0x48); - db(0x4e); db(0x75); db(0x4a); db(0xac); db(0x00); db(0x14); db(0x67); db(0x0a); - db(0x70); db(0x00); db(0x72); db(0x01); db(0x61); db(0x00); db(0xff); db(0xb2); - db(0x4e); db(0x75); db(0x70); db(0x01); db(0x72); db(0x03); db(0x61); db(0x00); - db(0xff); db(0xa8); db(0x4e); db(0x75); db(0x10); db(0x2b); db(0x00); db(0xac); - db(0x6b); db(0x0a); db(0x70); db(0x01); db(0x72); db(0x03); db(0x61); db(0x00); - db(0xff); db(0x98); db(0x4e); db(0x75); db(0x72); db(0x01); db(0x0c); db(0x00); - db(0x00); db(0xfe); db(0x66); db(0x02); db(0x72); db(0x03); db(0x70); db(0x00); - db(0x61); db(0x00); db(0xff); db(0x86); db(0x4e); db(0x75); db(0x20); db(0x6c); - db(0x00); db(0x24); db(0x4a); db(0x90); db(0x67); db(0x0c); db(0x4a); db(0xa8); - db(0x00); db(0x08); db(0x66); db(0x0a); db(0x4a); db(0xa8); db(0x00); db(0x0c); - db(0x66); db(0x04); db(0x70); db(0x01); db(0x4e); db(0x75); db(0x48); db(0xe7); - db(0x3f); db(0x3e); db(0x2a); db(0x48); db(0x24); db(0x6c); db(0x00); db(0x18); - db(0x2e); db(0x15); db(0x7a); db(0x00); db(0x4a); db(0x87); db(0x67); db(0x70); - db(0x20); db(0x0a); db(0x67); db(0x6c); db(0x7c); db(0x00); db(0x22); db(0x2d); - db(0x00); db(0x08); db(0x67); db(0x12); db(0x24); db(0x2a); db(0x00); db(0x04); - db(0x2c); db(0x6b); db(0x00); db(0xa0); db(0x4e); db(0xae); db(0xfc); db(0x34); - db(0x4a); db(0x80); db(0x66); db(0x02); db(0x50); db(0xc6); db(0x22); db(0x2d); - db(0x00); db(0x0c); db(0x67); db(0x1c); db(0x20); db(0x41); db(0x22); db(0x4a); - db(0x2f); db(0x0a); db(0x45); db(0xec); db(0x00); db(0x20); db(0x48); db(0x7a); - db(0x00); db(0x08); db(0x2f); db(0x28); db(0x00); db(0x08); db(0x4e); db(0x75); - db(0x24); db(0x5f); db(0x4a); db(0x80); db(0x66); db(0x02); db(0x50); db(0xc6); - db(0x4a); db(0x06); db(0x67); db(0x24); db(0x20); db(0x2a); db(0x00); db(0x04); - db(0x90); db(0x8a); db(0x4a); db(0x92); db(0x66); db(0x0a); db(0x20); db(0x05); - db(0x67); db(0x10); db(0x20); db(0x40); db(0x42); db(0x90); db(0x60); db(0x0a); - db(0x20); db(0x52); db(0x22); db(0x4a); db(0x22); db(0xd8); db(0x59); db(0x80); - db(0x6a); db(0xfa); db(0x53); db(0x95); db(0x53); db(0x87); db(0x60); db(0x94); - db(0x2a); db(0x0a); db(0x24); db(0x52); db(0x53); db(0x87); db(0x60); db(0x8c); - db(0x4c); db(0xdf); db(0x7c); db(0xfc); db(0x20); db(0x6c); db(0x00); db(0x24); - db(0x4a); db(0x90); db(0x4e); db(0x75); db(0x61); db(0x00); db(0xfc); db(0x7c); - db(0x21); db(0x40); db(0x01); db(0x98); db(0x2f); db(0x08); db(0x30); db(0x3c); - db(0xff); db(0xec); db(0x61); db(0x00); db(0x0f); db(0x06); db(0x2a); db(0x50); - db(0x30); db(0x3c); db(0xff); db(0x28); db(0x61); db(0x00); db(0x0e); db(0xfc); - db(0x22); db(0x48); db(0x20); db(0x5f); db(0x42); db(0xa8); db(0x01); db(0x90); - db(0x42); db(0xa8); db(0x01); db(0x94); db(0x4e); db(0x91); db(0x26); db(0x00); - db(0x0c); db(0x43); db(0xff); db(0xfe); db(0x67); db(0x00); db(0xf9); db(0x16); - db(0x20); db(0x28); db(0x01); db(0x90); db(0x67); db(0x14); db(0x6b); db(0x12); - db(0x2f); db(0x08); db(0x72); db(0x01); db(0x2c); db(0x78); db(0x00); db(0x04); - db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x20); db(0x5f); db(0x21); db(0x40); - db(0x01); db(0x94); db(0x4a); db(0x83); db(0x6a); db(0x0e); db(0x22); db(0x48); - db(0x30); db(0x3c); db(0xff); db(0x20); db(0x61); db(0x00); db(0x0e); db(0xbc); - db(0x4e); db(0x90); db(0x60); db(0x26); db(0x2c); db(0x4c); db(0x2f); db(0x08); - db(0x4e); db(0xae); db(0xff); db(0x70); db(0x20); db(0x5f); db(0x22); db(0x48); - db(0x26); db(0x40); db(0x30); db(0x3c); db(0xff); db(0x20); db(0x61); db(0x00); - db(0x0e); db(0xa2); db(0x4e); db(0x90); db(0x70); db(0x00); db(0x27); db(0x40); - db(0x00); db(0x08); db(0x27); db(0x40); db(0x00); db(0x10); db(0x27); db(0x40); - db(0x00); db(0x20); db(0x4a); db(0xa9); db(0x01); db(0x94); db(0x67); db(0x28); - db(0x20); db(0x69); db(0x01); db(0x94); db(0x61); db(0x00); db(0xfa); db(0xf2); - db(0x48); db(0xe7); db(0x80); db(0xc0); db(0x20); db(0x29); db(0x01); db(0x90); - db(0x22); db(0x69); db(0x01); db(0x94); db(0x2c); db(0x78); db(0x00); db(0x04); - db(0x4e); db(0xae); db(0xff); db(0x2e); db(0x4c); db(0xdf); db(0x03); db(0x01); - db(0x4a); db(0x80); db(0x67); db(0x04); db(0x61); db(0x00); db(0xfa); db(0x7c); - db(0x4a); db(0x83); db(0x6b); db(0x00); db(0xf8); db(0x90); db(0x30); db(0x3c); - db(0xff); db(0x18); db(0x61); db(0x00); db(0x0e); db(0x56); db(0x4e); db(0x90); - db(0x20); db(0x03); db(0x16); db(0x29); db(0x00); db(0x4f); db(0x4a); db(0x80); - db(0x66); db(0x1a); db(0x27); db(0x7c); db(0x00); db(0x00); db(0x17); db(0x70); - db(0x00); db(0x14); db(0x41); db(0xfa); db(0xf6); db(0x78); db(0x20); db(0x08); - db(0xe4); db(0x88); db(0x27); db(0x40); db(0x00); db(0x20); db(0x70); db(0xff); - db(0x27); db(0x40); db(0x00); db(0x24); db(0x08); db(0x07); db(0x00); db(0x00); - db(0x67); db(0x40); db(0x0c); db(0x03); db(0x00); db(0x80); db(0x67); db(0x3a); - db(0x2c); db(0x78); db(0x00); db(0x04); db(0x70); db(0x14); db(0x22); db(0x3c); - db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); - db(0x22); db(0x40); db(0x30); db(0x3c); db(0x10); db(0x00); db(0x80); db(0x03); - db(0x33); db(0x40); db(0x00); db(0x08); db(0x23); db(0x6d); db(0x01); db(0x04); - db(0x00); db(0x0a); db(0x23); db(0x4b); db(0x00); db(0x10); db(0x41); db(0xec); - db(0x00); db(0x4a); db(0x4e); db(0xae); db(0xff); db(0x7c); db(0x4e); db(0xae); - db(0xfe); db(0xf2); db(0x4e); db(0xae); db(0xff); db(0x76); db(0x70); db(0x00); - db(0x4e); db(0x75); db(0x24); db(0x49); db(0x20); db(0x4b); db(0x72); db(0x00); - db(0x22); db(0x41); db(0x08); db(0x07); db(0x00); db(0x01); db(0x67); db(0x08); - db(0x08); db(0x07); db(0x00); db(0x02); db(0x67); db(0x02); db(0x72); db(0x01); - db(0x70); db(0x80); db(0x2c); db(0x4c); db(0x4e); db(0xae); db(0xff); db(0x6a); - db(0x08); db(0x07); db(0x00); db(0x01); db(0x67); db(0x5c); db(0x08); db(0x07); - db(0x00); db(0x02); db(0x66); db(0x56); db(0x20); db(0x52); db(0x74); db(0x02); - db(0x52); db(0x82); db(0x4a); db(0x30); db(0x28); db(0xfd); db(0x66); db(0xf8); - db(0x2c); db(0x78); db(0x00); db(0x04); db(0x20); db(0x02); db(0x72); db(0x01); - db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x4a); db(0x80); db(0x67); db(0x3a); - db(0x20); db(0x52); db(0x24); db(0x40); db(0x22); db(0x4a); db(0x12); db(0xd8); - db(0x66); db(0xfc); db(0x13); db(0x7c); db(0x00); db(0x3a); db(0xff); db(0xff); - db(0x42); db(0x11); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x43); db(0xfa); - db(0x0e); db(0x83); db(0x70); db(0x00); db(0x4e); db(0xae); db(0xfd); db(0xd8); - db(0x2c); db(0x40); db(0x22); db(0x0a); db(0x4e); db(0xae); db(0xff); db(0x52); - db(0x22); db(0x4e); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x4e); db(0xae); - db(0xfe); db(0x62); db(0x22); db(0x4a); db(0x20); db(0x02); db(0x4e); db(0xae); - db(0xff); db(0x2e); db(0x70); db(0x00); db(0x4e); db(0x75); db(0x48); db(0xe7); - db(0x3f); db(0x3e); db(0x2c); db(0x01); db(0x7e); db(0x06); db(0x2c); db(0x78); - db(0x00); db(0x04); db(0x43); db(0xfa); db(0x0e); db(0x7e); db(0x70); db(0x24); - db(0x4e); db(0xae); db(0xfd); db(0xd8); db(0x4a); db(0x80); db(0x66); db(0x0e); - db(0x08); db(0x87); db(0x00); db(0x02); db(0x43); db(0xfa); db(0x0e); db(0x6c); - db(0x70); db(0x00); db(0x4e); db(0xae); db(0xfd); db(0xd8); db(0x28); db(0x40); - db(0x20); db(0x3c); db(0x00); db(0x00); db(0x02); db(0x2c); db(0x22); db(0x3c); - db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); - db(0x20); db(0x40); db(0x4a); db(0x80); db(0x67); db(0x2c); db(0x21); db(0x4c); - db(0x01); db(0x9c); db(0x48); db(0xe7); db(0x00); db(0x8a); db(0x61); db(0x00); - db(0xfe); db(0x04); db(0x4c); db(0xdf); db(0x51); db(0x00); db(0x0c); db(0x80); - db(0xff); db(0xff); db(0xff); db(0xfe); db(0x67); db(0x08); db(0x48); db(0x46); - db(0x52); db(0x46); db(0x48); db(0x46); db(0x60); db(0xe4); db(0x22); db(0x48); - db(0x20); db(0x3c); db(0x00); db(0x00); db(0x02); db(0x2c); db(0x4e); db(0xae); - db(0xff); db(0x2e); db(0x22); db(0x4c); db(0x4e); db(0xae); db(0xfe); db(0x62); - db(0x4c); db(0xdf); db(0x7c); db(0xfc); db(0x4e); db(0x75); db(0x30); db(0x3c); - db(0xff); db(0x58); db(0x61); db(0x00); db(0x0c); db(0xe6); db(0x70); db(0x03); - db(0x4e); db(0x90); db(0x22); db(0x6b); db(0x00); db(0xa8); db(0x23); db(0x40); - db(0x00); db(0x20); db(0x67); db(0x16); db(0x70); db(0x00); db(0x23); db(0x40); - db(0x00); db(0x24); db(0x33); db(0x7c); db(0x00); db(0x0b); db(0x00); db(0x1c); - db(0x13); db(0x7c); db(0x00); db(0x01); db(0x00); db(0x1e); db(0x4e); db(0xae); - db(0xfe); db(0x38); db(0x4e); db(0x75); db(0x2c); db(0x78); db(0x00); db(0x04); - db(0x93); db(0xc9); db(0x4e); db(0xae); db(0xfe); db(0xda); db(0x20); db(0x40); - db(0x4b); db(0xe8); db(0x00); db(0x5c); db(0x43); db(0xfa); db(0x0d); db(0xa5); - db(0x70); db(0x00); db(0x4e); db(0xae); db(0xfd); db(0xd8); db(0x24); db(0x40); - db(0x20); db(0x3c); db(0x00); db(0x00); db(0x00); db(0xb9); db(0x22); db(0x3c); - db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); - db(0x26); db(0x40); db(0x7c); db(0x00); db(0x26); db(0x86); db(0x27); db(0x46); - db(0x00); db(0x04); db(0x27); db(0x46); db(0x00); db(0x08); db(0x27); db(0x4a); - db(0x00); db(0xa0); db(0x50); db(0xeb); db(0x00); db(0x9e); db(0x93); db(0xc9); - db(0x4e); db(0xae); db(0xfe); db(0xda); db(0x27); db(0x40); db(0x00); db(0xb0); - db(0x41); db(0xfa); db(0x0c); db(0x7e); db(0x70); db(0x00); db(0x72); db(0x00); - db(0x61); db(0x00); db(0x02); db(0xae); db(0x27); db(0x40); db(0x00); db(0xa4); - db(0x41); db(0xfa); db(0x0c); db(0x7b); db(0x70); db(0x00); db(0x72); db(0x00); - db(0x61); db(0x00); db(0x02); db(0x9e); db(0x27); db(0x40); db(0x00); db(0xa8); - db(0x7a); db(0x00); db(0x20); db(0x4d); db(0x4e); db(0xae); db(0xfe); db(0x80); - db(0x20); db(0x4d); db(0x4e); db(0xae); db(0xfe); db(0x8c); db(0x28); db(0x40); - db(0x26); db(0x2c); db(0x00); db(0x0a); db(0x30); db(0x3c); db(0xff); db(0x40); - db(0x61); db(0x00); db(0x0c); db(0x38); db(0x70); db(0x00); db(0x4e); db(0x90); - db(0x24); db(0x00); db(0x70); db(0x01); db(0x61); db(0x00); db(0xfa); db(0x04); - db(0x08); db(0x02); db(0x00); db(0x01); db(0x67); db(0x06); db(0x70); db(0x01); - db(0x61); db(0x00); db(0xfb); db(0x6c); db(0x60); db(0x00); db(0x01); db(0x2e); - db(0x20); db(0x4d); db(0x4e); db(0xae); db(0xfe); db(0x8c); db(0x28); db(0x40); - db(0x4a); db(0x80); db(0x66); db(0x10); db(0x70); db(0x00); db(0x12); db(0x2d); - db(0x00); db(0x0f); db(0x03); db(0xc0); db(0x08); db(0xc0); db(0x00); db(0x0d); - db(0x4e); db(0xae); db(0xfe); db(0xc2); db(0x4a); db(0x2b); db(0x00); db(0xad); - db(0x67); db(0x08); db(0x61); db(0x00); db(0xff); db(0x0a); db(0x42); db(0x2b); - db(0x00); db(0xad); db(0x4a); db(0x2b); db(0x00); db(0xac); db(0x67); db(0x24); - db(0x30); db(0x3c); db(0xff); db(0x58); db(0x61); db(0x00); db(0x0b); db(0xe4); - db(0x70); db(0x01); db(0x4e); db(0x90); db(0x4a); db(0x80); db(0x67); db(0x04); - db(0x61); db(0x00); db(0xfb); db(0xfa); db(0x42); db(0x2b); db(0x00); db(0xac); - db(0x30); db(0x3c); db(0xff); db(0x58); db(0x61); db(0x00); db(0x0b); db(0xcc); - db(0x70); db(0x02); db(0x4e); db(0x90); db(0x20); db(0x0c); db(0x67); db(0x56); - db(0x0c); db(0x6c); db(0x00); db(0x26); db(0x00); db(0x12); db(0x66); db(0x4e); - db(0x0c); db(0xac); db(0x40); db(0x00); db(0x00); db(0x00); db(0x00); db(0x14); - db(0x66); db(0x44); db(0x0c); db(0x6c); db(0x12); db(0x34); db(0x00); db(0x18); - db(0x66); db(0x3c); db(0x20); db(0x6c); db(0x00); db(0x1a); db(0x20); db(0x28); - db(0x00); db(0x0c); db(0x02); db(0x80); db(0x80); db(0x00); db(0x00); db(0x08); - db(0x0c); db(0x80); db(0x80); db(0x00); db(0x00); db(0x08); db(0x66); db(0x1a); - db(0x02); db(0xa8); db(0x7f); db(0xff); db(0xff); db(0xff); db(0x00); db(0x0c); - db(0x20); db(0x68); db(0x00); db(0x10); db(0x22); db(0x4c); db(0x12); db(0xbc); - db(0x00); db(0x08); db(0x4e); db(0xae); db(0xfe); db(0x92); db(0x60); db(0x00); - db(0xff); db(0x60); db(0x22); db(0x4c); db(0x70); db(0x26); db(0x4e); db(0xae); - db(0xff); db(0x2e); db(0x60); db(0x00); db(0xff); db(0x54); db(0x74); db(0xfe); - db(0x20); db(0x0c); db(0x67); db(0x14); db(0x26); db(0x2c); db(0x00); db(0x0a); - db(0x66); db(0x42); db(0x74); db(0xff); db(0x30); db(0x3c); db(0xff); db(0x50); - db(0x61); db(0x00); db(0x0b); db(0x58); db(0x70); db(0x01); db(0x4e); db(0x90); - db(0x45); db(0xeb); db(0x00); db(0x04); db(0x20); db(0x52); db(0x20); db(0x08); - db(0x67); db(0x00); db(0xff); db(0x2e); db(0x22); db(0x50); db(0x20); db(0x40); - db(0x20); db(0x28); db(0x00); db(0x04); db(0xb4); db(0x80); db(0x66); db(0x16); - db(0x48); db(0xe7); db(0x00); db(0xc0); db(0x28); db(0x68); db(0x00); db(0x0a); - db(0x61); db(0x4a); db(0x53); db(0x85); db(0x4c); db(0xdf); db(0x03); db(0x00); - db(0x24); db(0x89); db(0x20); db(0x49); db(0x60); db(0xd8); db(0x24); db(0x48); - db(0x20); db(0x49); db(0x60); db(0xd2); db(0x0c); db(0x85); db(0x00); db(0x00); - db(0x00); db(0x14); db(0x65); db(0x00); db(0x00); db(0x0a); db(0x70); db(0x01); - db(0x29); db(0x40); db(0x00); db(0x04); db(0x60); db(0x12); db(0x61); db(0x5e); - db(0x30); db(0x3c); db(0xff); db(0x30); db(0x61); db(0x00); db(0x0b); db(0x04); - db(0x4e); db(0x90); db(0x4a); db(0x80); db(0x67); db(0x0e); db(0x52); db(0x85); - db(0x28); db(0xab); db(0x00); db(0x04); db(0x27); db(0x4c); db(0x00); db(0x04); - db(0x60); db(0x00); db(0xfe); db(0xd6); db(0x28); db(0x43); db(0x61); db(0x04); - db(0x60); db(0x00); db(0xfe); db(0xce); db(0x0c); db(0xac); db(0x00); db(0x00); - db(0x00); db(0x1f); db(0x00); db(0x08); db(0x66); db(0x04); db(0x61); db(0x00); - db(0xfa); db(0xe2); db(0x0c); db(0xac); db(0x00); db(0x00); db(0x04); db(0x09); - db(0x00); db(0x08); db(0x66); db(0x14); db(0x61); db(0x00); db(0xfb); db(0x10); - db(0x66); db(0x0e); db(0x30); db(0x3c); db(0xff); db(0x58); db(0x61); db(0x00); - db(0x0a); db(0xc2); db(0x70); db(0x00); db(0x4e); db(0x90); db(0x60); db(0xec); - db(0x22); db(0x54); db(0x20); db(0x6c); db(0x00); db(0x04); db(0x29); db(0x4d); - db(0x00); db(0x04); db(0x4e); db(0xee); db(0xfe); db(0x92); db(0x2f); db(0x05); - db(0x7a); db(0xfc); db(0x24); db(0x53); db(0x2e); db(0x0a); db(0x22); db(0x0a); - db(0x67); db(0x00); db(0x00); db(0x0c); db(0x52); db(0x85); db(0x67); db(0x1e); - db(0x22); db(0x4a); db(0x24); db(0x52); db(0x60); db(0xf0); db(0x52); db(0x85); - db(0x67); db(0x3c); db(0x24); db(0x47); db(0x70); db(0x18); db(0x72); db(0x01); - db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x52); db(0x46); db(0x24); db(0x40); - db(0x24); db(0x87); db(0x2e); db(0x0a); db(0x60); db(0xe8); db(0x20); db(0x12); - db(0x67); db(0x24); db(0x20); db(0x40); db(0x20); db(0x10); db(0x67); db(0x1e); - db(0x20); db(0x40); db(0x20); db(0x10); db(0x67); db(0x18); db(0x70); db(0x00); - db(0x22); db(0x80); db(0x22); db(0x4a); db(0x24); db(0x51); db(0x70); db(0x18); - db(0x4e); db(0xae); db(0xff); db(0x2e); db(0x06); db(0x86); db(0x00); db(0x01); - db(0x00); db(0x00); db(0x20); db(0x0a); db(0x66); db(0xec); db(0x26); db(0x87); - db(0x2a); db(0x1f); db(0x4e); db(0x75); db(0x20); db(0x88); db(0x58); db(0x90); - db(0x42); db(0xa8); db(0x00); db(0x04); db(0x21); db(0x48); db(0x00); db(0x08); - db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x20); db(0x22); db(0x2c); db(0x78); - db(0x00); db(0x04); db(0x70); db(0xff); db(0x4e); db(0xae); db(0xfe); db(0xb6); - db(0x91); db(0xc8); db(0x24); db(0x00); db(0x6b); db(0x32); db(0x70); db(0x22); - db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); - db(0xff); db(0x3a); db(0x91); db(0xc8); db(0x24); db(0x40); db(0x4a); db(0x80); - db(0x67); db(0x1e); db(0x15); db(0x7c); db(0x00); db(0x04); db(0x00); db(0x08); - db(0x15); db(0x42); db(0x00); db(0x0f); db(0x93); db(0xc9); db(0x4e); db(0xae); - db(0xfe); db(0xda); db(0x25); db(0x40); db(0x00); db(0x10); db(0x41); db(0xea); - db(0x00); db(0x14); db(0x61); db(0x00); db(0xff); db(0xb0); db(0x20); db(0x4a); - db(0x20); db(0x08); db(0x4c); db(0xdf); db(0x44); db(0x04); db(0x4e); db(0x75); - db(0x48); db(0xe7); db(0x20); db(0x22); db(0x2c); db(0x78); db(0x00); db(0x04); - db(0x4a); db(0x80); db(0x67); db(0x24); db(0x24); db(0x40); db(0x24); db(0x01); - db(0x66); db(0x02); db(0x74); db(0x30); db(0x20); db(0x02); db(0x22); db(0x3c); - db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); - db(0x20); db(0x40); db(0x11); db(0x7c); db(0x00); db(0x0a); db(0x00); db(0x08); - db(0x31); db(0x42); db(0x00); db(0x12); db(0x21); db(0x4a); db(0x00); db(0x0e); - db(0x4a); db(0x80); db(0x4c); db(0xdf); db(0x44); db(0x04); db(0x4e); db(0x75); - db(0x48); db(0xe7); db(0x30); db(0x22); db(0x24); db(0x48); db(0x24); db(0x00); - db(0x26); db(0x01); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x61); db(0x00); - db(0xff); db(0x6a); db(0x22); db(0x03); db(0x61); db(0x00); db(0xff); db(0xb2); - db(0x67); db(0x18); db(0x20); db(0x4a); db(0x22); db(0x40); db(0x24); db(0x40); - db(0x20); db(0x02); db(0x72); db(0x00); db(0x4e); db(0xae); db(0xfe); db(0x44); - db(0x22); db(0x00); db(0x70); db(0x00); db(0x4a); db(0x81); db(0x66); db(0x02); - db(0x20); db(0x0a); db(0x4a); db(0x80); db(0x4c); db(0xdf); db(0x44); db(0x0c); - db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x38); db(0x32); db(0x2c); db(0x78); - db(0x00); db(0x04); db(0x28); db(0x00); db(0x24); db(0x08); db(0x26); db(0x09); - db(0x20); db(0x3c); db(0x00); db(0x00); db(0x08); db(0x5c); db(0x22); db(0x3c); - db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); - db(0x4a); db(0x80); db(0x67); db(0x00); db(0x00); db(0x34); db(0x24); db(0x40); - db(0x15); db(0x7c); db(0x00); db(0x01); db(0x00); db(0x08); db(0x15); db(0x44); - db(0x00); db(0x09); db(0x25); db(0x42); db(0x00); db(0x0a); db(0x47); db(0xea); - db(0x00); db(0x5c); db(0x25); db(0x4b); db(0x00); db(0x3a); db(0x47); db(0xeb); - db(0x08); db(0x00); db(0x25); db(0x4b); db(0x00); db(0x3e); db(0x25); db(0x4b); - db(0x00); db(0x36); db(0x22); db(0x4a); db(0x24); db(0x43); db(0x97); db(0xcb); - db(0x24); db(0x09); db(0x4e); db(0xae); db(0xfe); db(0xe6); db(0x20); db(0x02); - db(0x4c); db(0xdf); db(0x4c); db(0x1c); db(0x4e); db(0x75); db(0x41); db(0xfa); - db(0x09); db(0xc0); db(0x43); db(0xfa); db(0x01); db(0x30); db(0x70); db(0x13); - db(0x61); db(0x00); db(0xff); db(0x98); db(0x4e); db(0x75); db(0x22); db(0x6d); - db(0x02); db(0x0c); db(0x33); db(0x7c); db(0x00); db(0x0a); db(0x00); db(0x1c); - db(0x13); db(0x7c); db(0x00); db(0x01); db(0x00); db(0x1e); db(0x4e); db(0xae); - db(0xfe); db(0x38); db(0x22); db(0x6d); db(0x02); db(0x0c); db(0x25); db(0x69); - db(0x00); db(0x20); db(0x00); db(0x0e); db(0x25); db(0x69); db(0x00); db(0x24); - db(0x00); db(0x12); db(0x22); db(0x6d); db(0x02); db(0x08); db(0x13); db(0x7c); - db(0x00); db(0x01); db(0x00); db(0x1e); db(0x4e); db(0xae); db(0xfe); db(0x38); - db(0x4e); db(0x75); db(0x42); db(0xaa); db(0x00); db(0x0e); db(0x42); db(0xaa); - db(0x00); db(0x12); db(0x22); db(0x6d); db(0x02); db(0x08); db(0x13); db(0x7c); - db(0x00); db(0x01); db(0x00); db(0x1e); db(0x4e); db(0xae); db(0xfe); db(0x38); - db(0x4e); db(0x75); db(0x48); db(0xe7); db(0xf8); db(0xfe); db(0x2a); db(0x48); - db(0x95); db(0xca); db(0x97); db(0xcb); db(0x99); db(0xcc); db(0x78); db(0x00); - db(0x2c); db(0x6d); db(0x00); db(0x18); db(0x20); db(0x6d); db(0x00); db(0x14); - db(0x20); db(0x28); db(0x00); db(0x3c); db(0x67); db(0x5c); db(0x20); db(0x40); - db(0x41); db(0xe8); db(0x00); db(0x2c); db(0x28); db(0x48); db(0x4e); db(0xae); - db(0xfc); db(0xe8); db(0x72); db(0xff); db(0x74); db(0xff); db(0xb2); db(0x80); - db(0x67); db(0x48); db(0x26); db(0x00); db(0x2c); db(0x6d); db(0x00); db(0x14); - db(0x41); db(0xed); db(0x00); db(0xc0); db(0x70); db(0x66); db(0x4e); db(0xae); - db(0xff); db(0x7c); db(0x41); db(0xed); db(0x00); db(0xc0); db(0x38); db(0x28); - db(0x00); db(0x64); db(0x2c); db(0x6d); db(0x00); db(0x18); db(0x91); db(0xc8); - db(0x43); db(0xed); db(0x00); db(0x38); db(0x70); db(0x00); db(0x30); db(0x3c); - db(0x00); db(0x58); db(0x22); db(0x3c); db(0x80); db(0x00); db(0x10); db(0x00); - db(0x24); db(0x03); db(0x4e); db(0xae); db(0xfd); db(0x0c); db(0x72); db(0xff); - db(0x74); db(0xff); db(0x4a); db(0x80); db(0x6b); db(0x0c); db(0x45); db(0xed); - db(0x00); db(0x38); db(0x22); db(0x2a); db(0x00); db(0x32); db(0x24); db(0x2a); - db(0x00); db(0x36); db(0x20); db(0x2c); db(0x00); db(0x1c); db(0xb8); db(0x6d); - db(0x00); db(0x2c); db(0x66); db(0x12); db(0xb0); db(0xad); db(0x00); db(0x28); - db(0x66); db(0x0c); db(0xb2); db(0xad); db(0x00); db(0x20); db(0x66); db(0x06); - db(0xb4); db(0xad); db(0x00); db(0x24); db(0x67); db(0x40); db(0x2b); db(0x40); - db(0x00); db(0x28); db(0x2b); db(0x41); db(0x00); db(0x20); db(0x2b); db(0x42); - db(0x00); db(0x24); db(0x3b); db(0x44); db(0x00); db(0x2c); db(0x91); db(0xc8); - db(0x43); db(0xed); db(0x00); db(0x90); db(0x70); db(0x00); db(0x30); db(0x3c); - db(0x00); db(0x58); db(0x22); db(0x3c); db(0x80); db(0x00); db(0x00); db(0x00); - db(0x24); db(0x03); db(0x4e); db(0xae); db(0xfd); db(0x0c); db(0x4a); db(0x80); - db(0x6b); db(0x04); db(0x47); db(0xed); db(0x00); db(0x90); db(0x34); db(0x2d); - db(0x00); db(0x2c); db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x01); - db(0x61); db(0x00); db(0x07); db(0xf8); db(0x4e); db(0x90); db(0x4c); db(0xdf); - db(0x7f); db(0x1f); db(0x4e); db(0x75); db(0x2c); db(0x78); db(0x00); db(0x04); - db(0x3e); db(0x2e); db(0x00); db(0x14); db(0x70); db(0xff); db(0x4e); db(0xae); - db(0xfe); db(0xb6); db(0x7c); db(0x00); db(0x01); db(0xc6); db(0x93); db(0xc9); - db(0x4e); db(0xae); db(0xfe); db(0xda); db(0x28); db(0x40); db(0x70); db(0x14); - db(0x22); db(0x4c); db(0x4e); db(0xae); db(0xfe); db(0xd4); db(0x70); db(0x00); - db(0x30); db(0x3c); db(0x02); db(0x3c); db(0x22); db(0x3c); db(0x00); db(0x01); - db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x2a); db(0x40); - db(0x47); db(0xed); db(0x00); db(0x16); db(0x27); db(0x4e); db(0x00); db(0x10); - db(0x27); db(0x4c); db(0x00); db(0x08); db(0x27); db(0x46); db(0x00); db(0x0c); - db(0x70); db(0xff); db(0x37); db(0x40); db(0x00); db(0x00); db(0x30); db(0x3c); - db(0xff); db(0x38); db(0x72); db(0x05); db(0x61); db(0x00); db(0x07); db(0x9c); - db(0x20); db(0x0d); db(0x06); db(0x80); db(0x00); db(0x00); db(0x02); db(0x10); - db(0x4e); db(0x90); db(0x43); db(0xed); db(0x00); db(0x00); db(0x13); db(0x7c); - db(0x00); db(0x02); db(0x00); db(0x08); db(0x13); db(0x7c); db(0x00); db(0x05); - db(0x00); db(0x09); db(0x41); db(0xfa); db(0x08); db(0x1c); db(0x23); db(0x48); - db(0x00); db(0x0a); db(0x41); db(0xfa); db(0x02); db(0xf4); db(0x23); db(0x48); - db(0x00); db(0x12); db(0x23); db(0x4d); db(0x00); db(0x0e); db(0x70); db(0x05); - db(0x4e); db(0xae); db(0xff); db(0x58); db(0x20); db(0x06); db(0x4e); db(0xae); - db(0xfe); db(0xc2); db(0x70); db(0x00); db(0x53); db(0xab); db(0x00); db(0x1c); - db(0x6a); db(0x06); db(0x70); db(0x0a); db(0x27); db(0x40); db(0x00); db(0x1c); - db(0x4a); db(0xab); db(0x00); db(0x14); db(0x66); db(0x16); db(0x4a); db(0xab); - db(0x00); db(0x1c); db(0x66); db(0xe0); db(0x43); db(0xfa); db(0x08); db(0x49); - db(0x70); db(0x00); db(0x4e); db(0xae); db(0xfd); db(0xd8); db(0x27); db(0x40); - db(0x00); db(0x14); db(0x67); db(0xd0); db(0x4a); db(0xab); db(0x00); db(0x18); - db(0x66); db(0x18); db(0x4a); db(0xab); db(0x00); db(0x1c); db(0x66); db(0xc4); - db(0x43); db(0xfa); db(0x08); db(0x3f); db(0x70); db(0x00); db(0x4e); db(0xae); - db(0xfd); db(0xd8); db(0x27); db(0x40); db(0x00); db(0x18); db(0x67); db(0x00); - db(0xff); db(0xb4); db(0x4a); db(0xad); db(0x02); db(0x08); db(0x66); db(0x38); - db(0x4a); db(0xab); db(0x00); db(0x1c); db(0x66); db(0xa6); db(0x4e); db(0xae); - db(0xff); db(0x7c); db(0x41); db(0xee); db(0x01); db(0x5e); db(0x43); db(0xfa); - db(0x07); db(0x10); db(0x4e); db(0xae); db(0xfe); db(0xec); db(0x24); db(0x00); - db(0x4e); db(0xae); db(0xff); db(0x76); db(0x4a); db(0x82); db(0x67); db(0x8c); - db(0x41); db(0xfa); db(0x06); db(0xfe); db(0x70); db(0x00); db(0x72); db(0x00); - db(0x61); db(0x00); db(0xfd); db(0x2e); db(0x2b); db(0x40); db(0x02); db(0x08); - db(0x67); db(0x00); db(0x02); db(0x32); db(0x60); db(0x00); db(0xff); db(0x76); - db(0x4a); db(0xad); db(0x02); db(0x0c); db(0x66); db(0x48); db(0x4a); db(0xab); - db(0x00); db(0x1c); db(0x66); db(0x00); db(0xff); db(0x68); db(0x4e); db(0xae); - db(0xff); db(0x7c); db(0x41); db(0xee); db(0x01); db(0x5e); db(0x43); db(0xfa); - db(0x06); db(0xdd); db(0x4e); db(0xae); db(0xfe); db(0xec); db(0x24); db(0x00); - db(0x4e); db(0xae); db(0xff); db(0x76); db(0x4a); db(0x82); db(0x67); db(0x00); - db(0xff); db(0x4c); db(0x41); db(0xfa); db(0x06); db(0xc9); db(0x70); db(0x00); - db(0x72); db(0x00); db(0x61); db(0x00); db(0xfc); db(0xec); db(0x2b); db(0x40); - db(0x02); db(0x0c); db(0x67); db(0x00); db(0x01); db(0xf0); db(0x30); db(0x3c); - db(0xff); db(0x38); db(0x72); db(0x00); db(0x61); db(0x00); db(0x06); db(0x94); - db(0x4e); db(0x90); db(0x60); db(0x00); db(0xff); db(0x28); db(0x0c); db(0x47); - db(0x00); db(0x24); db(0x65); db(0x12); db(0x53); db(0xab); db(0x00); db(0x34); - db(0x6a); db(0x0c); db(0x20); db(0x4b); db(0x61); db(0x00); db(0xfd); db(0xb4); - db(0x70); db(0x32); db(0x27); db(0x40); db(0x00); db(0x34); db(0x22); db(0x6d); - db(0x02); db(0x08); db(0x45); db(0xed); db(0x01); db(0x3c); db(0x33); db(0x7c); + db(0x20); db(0x6b); db(0x00); db(0xb4); db(0x61); db(0x00); db(0x00); db(0x2c); + db(0x4e); db(0xae); db(0xff); db(0x76); db(0x4c); db(0xdf); db(0x44); db(0x80); + db(0x4e); db(0x75); db(0x22); db(0x48); db(0x20); db(0x6b); db(0x00); db(0xa0); + db(0x20); db(0x68); db(0x00); db(0x22); db(0x20); db(0x68); db(0x00); db(0x18); + db(0xd1); db(0xc8); db(0xd1); db(0xc8); db(0x22); db(0xa8); db(0x00); db(0x04); + db(0x20); db(0x09); db(0xe4); db(0x88); db(0x21); db(0x40); db(0x00); db(0x04); + db(0x4e); db(0x75); db(0x24); db(0x48); db(0x20); db(0x6b); db(0x00); db(0xa0); + db(0x20); db(0x68); db(0x00); db(0x22); db(0x20); db(0x68); db(0x00); db(0x18); + db(0xd1); db(0xc8); db(0xd1); db(0xc8); db(0x22); db(0x68); db(0x00); db(0x04); + db(0xd3); db(0xc9); db(0xd3); db(0xc9); db(0xb3); db(0xca); db(0x66); db(0x06); + db(0x21); db(0x52); db(0x00); db(0x04); db(0x60); db(0x18); db(0x20); db(0x09); + db(0x67); db(0x0e); db(0x20); db(0x11); db(0xd0); db(0x80); db(0xd0); db(0x80); + db(0xb5); db(0xc0); db(0x67); db(0x04); db(0x22); db(0x40); db(0x60); db(0xee); + db(0x20); db(0x09); db(0x67); db(0x02); db(0x22); db(0x92); db(0x4e); db(0x75); + db(0x48); db(0xe7); db(0x20); db(0x22); db(0x74); db(0x16); db(0x9f); db(0xc2); + db(0x24); db(0x4f); db(0x32); db(0x02); db(0x42); db(0x32); db(0x10); db(0xff); + db(0x53); db(0x41); db(0x66); db(0xf8); db(0x2c); db(0x78); db(0x00); db(0x04); + db(0x72); db(0x0f); db(0x4a); db(0x80); db(0x67); db(0x02); db(0x72); db(0x10); + db(0x15); db(0x41); db(0x00); db(0x04); db(0x35); db(0x7c); db(0x08); db(0x00); + db(0x00); db(0x08); db(0x22); db(0x6b); db(0x00); db(0xa4); db(0x33); db(0x7c); db(0x00); db(0x0b); db(0x00); db(0x1c); db(0x23); db(0x7c); db(0x00); db(0x00); db(0x00); db(0x16); db(0x00); db(0x24); db(0x23); db(0x4a); db(0x00); db(0x28); - db(0x10); db(0x2d); db(0x02); db(0x10); db(0x0c); db(0x47); db(0x00); db(0x27); - db(0x65); db(0x00); db(0x01); db(0x52); db(0x08); db(0x00); db(0x00); db(0x01); - db(0x67); db(0x00); db(0x01); db(0x4a); db(0x41); db(0xed); db(0x01); db(0x68); - db(0x25); db(0x48); db(0x00); db(0x0a); db(0x15); db(0x7c); db(0x00); db(0x13); - db(0x00); db(0x04); db(0x15); db(0x7c); db(0x00); db(0x03); db(0x00); db(0x05); - db(0x42); db(0x90); db(0x42); db(0xa8); db(0x00); db(0x04); db(0x42); db(0xa8); - db(0x00); db(0x08); db(0x42); db(0x68); db(0x00); db(0x0c); db(0x42); db(0x6a); - db(0x00); db(0x06); db(0x61); db(0x00); db(0x01); db(0x72); db(0x31); db(0x6d); - db(0x02); db(0x1a); db(0x00); db(0x0e); db(0x42); db(0x68); db(0x00); db(0x10); - db(0x31); db(0x6d); db(0x02); db(0x1c); db(0x00); db(0x12); db(0x42); db(0x68); - db(0x00); db(0x14); db(0x31); db(0x6d); db(0x02); db(0x14); db(0x00); db(0x16); - db(0x42); db(0x68); db(0x00); db(0x18); db(0x31); db(0x6d); db(0x02); db(0x16); - db(0x00); db(0x1a); db(0x43); db(0xed); db(0x01); db(0x88); db(0x21); db(0x49); - db(0x00); db(0x1c); db(0x22); db(0xfc); db(0x80); db(0x03); db(0xa0); db(0x06); - db(0x30); db(0x2d); db(0x02); db(0x30); db(0x48); db(0xc0); db(0xe1); db(0x80); - db(0x22); db(0xc0); db(0x22); db(0xfc); db(0x80); db(0x03); db(0xa0); db(0x07); - db(0x22); db(0xed); db(0x02); db(0x32); db(0x70); db(0x00); db(0x30); db(0x2d); - db(0x02); db(0x20); db(0x6b); db(0x08); db(0x22); db(0xfc); db(0x80); db(0x03); - db(0xa0); db(0x09); db(0x22); db(0xc0); db(0x30); db(0x2d); db(0x02); db(0x22); - db(0x6b); db(0x08); db(0x22); db(0xfc); db(0x80); db(0x03); db(0xa0); db(0x0a); - db(0x22); db(0xc0); db(0x30); db(0x2d); db(0x02); db(0x18); db(0x6b); db(0x14); - db(0x22); db(0xfc); db(0x80); db(0x03); db(0xa0); db(0x02); db(0x22); db(0xc0); - db(0x30); db(0x2d); db(0x02); db(0x1e); db(0x22); db(0xfc); db(0x80); db(0x03); - db(0xa0); db(0x01); db(0x22); db(0xc0); db(0x30); db(0x2d); db(0x02); db(0x24); - db(0x6b); db(0x10); db(0x22); db(0xfc); db(0x80); db(0x03); db(0xa0); db(0x03); - db(0x30); db(0x2d); db(0x02); db(0x2a); db(0x48); db(0xc0); db(0xe1); db(0x80); - db(0x22); db(0xc0); db(0x30); db(0x2d); db(0x02); db(0x26); db(0x6b); db(0x10); - db(0x22); db(0xfc); db(0x80); db(0x03); db(0xa0); db(0x04); db(0x30); db(0x2d); - db(0x02); db(0x2c); db(0x48); db(0xc0); db(0xe1); db(0x80); db(0x22); db(0xc0); - db(0x30); db(0x2d); db(0x02); db(0x28); db(0x6b); db(0x10); db(0x22); db(0xfc); - db(0x80); db(0x03); db(0xa0); db(0x05); db(0x30); db(0x2d); db(0x02); db(0x2e); - db(0x48); db(0xc0); db(0xe1); db(0x80); db(0x22); db(0xc0); db(0x70); db(0x00); - db(0x30); db(0x2d); db(0x02); db(0x36); db(0x6b); db(0x08); db(0x22); db(0xfc); - db(0x80); db(0x03); db(0xa0); db(0x08); db(0x22); db(0xc0); db(0x42); db(0x91); - db(0x61); db(0x00); db(0xfc); db(0x68); db(0x36); db(0x3c); db(0x00); db(0x68); - db(0x74); db(0x01); db(0x28); db(0x2d); db(0x02); db(0x32); db(0x20); db(0x04); - db(0xc0); db(0x82); db(0x22); db(0x2b); db(0x00); db(0x04); db(0xc2); db(0x82); - db(0xb2); db(0x80); db(0x67); db(0x22); db(0x42); db(0x92); db(0x35); db(0x7c); - db(0x02); db(0x00); db(0x00); db(0x04); db(0x42); db(0xaa); db(0x00); db(0x0a); - db(0x32); db(0x03); db(0x4a); db(0x00); db(0x66); db(0x04); db(0x08); db(0xc1); - db(0x00); db(0x07); db(0x35); db(0x41); db(0x00); db(0x06); db(0x42); db(0x6a); - db(0x00); db(0x08); db(0x61); db(0x00); db(0xfc); db(0x2e); db(0x52); db(0x43); - db(0xd4); db(0x42); db(0x0c); db(0x42); db(0x00); db(0x08); db(0x66); db(0xc6); - db(0x27); db(0x44); db(0x00); db(0x04); db(0x10); db(0x2d); db(0x02); db(0x10); - db(0x08); db(0x00); db(0x00); db(0x00); db(0x67); db(0x00); db(0xfd); db(0x8e); - db(0x42); db(0x92); db(0x35); db(0x7c); db(0x04); db(0x00); db(0x00); db(0x04); - db(0x42); db(0x6a); db(0x00); db(0x06); db(0x61); db(0x00); db(0x00); db(0x38); - db(0x20); db(0x6b); db(0x00); db(0x14); db(0x30); db(0x2d); db(0x02); db(0x38); - db(0x32); db(0x28); db(0x00); db(0x30); db(0xd2); db(0x41); db(0x90); db(0x41); - db(0x6a); db(0x02); db(0x70); db(0x00); db(0x35); db(0x40); db(0x00); db(0x0a); - db(0x30); db(0x2d); db(0x02); db(0x3a); db(0x32); db(0x28); db(0x00); db(0x2e); - db(0xd2); db(0x41); db(0x90); db(0x41); db(0x6a); db(0x02); db(0x70); db(0x00); - db(0x35); db(0x40); db(0x00); db(0x0c); db(0x61); db(0x00); db(0xfb); db(0xa0); - db(0x60); db(0x00); db(0xfd); db(0x4a); db(0x4e); db(0x75); db(0x22); db(0x2d); - db(0x02); db(0x32); db(0x70); db(0x00); db(0x08); db(0x01); db(0x00); db(0x00); - db(0x67); db(0x04); db(0x08); db(0xc0); db(0x00); db(0x0e); db(0x08); db(0x01); - db(0x00); db(0x01); db(0x67); db(0x04); db(0x08); db(0xc0); db(0x00); db(0x0d); - db(0x08); db(0x01); db(0x00); db(0x02); db(0x67); db(0x04); db(0x08); db(0xc0); - db(0x00); db(0x0c); db(0x35); db(0x40); db(0x00); db(0x08); db(0x4e); db(0x75); - db(0x4a); db(0xa9); db(0x02); db(0x08); db(0x67); db(0x14); db(0x4a); db(0xa9); - db(0x02); db(0x0c); db(0x67); db(0x0e); db(0x30); db(0x29); db(0x02); db(0x12); - db(0xb0); db(0x69); db(0x00); db(0x16); db(0x67); db(0x14); db(0x33); db(0x40); - db(0x00); db(0x16); db(0x2c); db(0x69); db(0x00); db(0x26); db(0x20); db(0x29); - db(0x00); db(0x22); db(0x22); db(0x69); db(0x00); db(0x1e); db(0x4e); db(0xae); - db(0xfe); db(0xbc); db(0x53); db(0x69); db(0x00); db(0x46); db(0x6a); db(0x12); - db(0x33); db(0x7c); db(0x00); db(0x32); db(0x00); db(0x46); db(0x30); db(0x3c); - db(0xff); db(0x38); db(0x72); db(0x02); db(0x61); db(0x00); db(0x04); db(0x44); - db(0x4e); db(0x90); db(0x41); db(0xf9); db(0x00); db(0xdf); db(0xf0); db(0x00); - db(0x70); db(0x00); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x00); db(0x06); - db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x11); db(0x61); db(0x00); - db(0x04); db(0x2a); db(0x4e); db(0x90); db(0x08); db(0x00); db(0x00); db(0x00); - db(0x67); db(0x42); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x20); db(0x3c); - db(0x00); db(0x00); db(0x00); db(0x88); db(0x22); db(0x3c); db(0x00); db(0x01); - db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x4a); db(0x80); - db(0x67); db(0x00); db(0x00); db(0x40); db(0x2a); db(0x40); db(0x2b); db(0x4e); - db(0x00); db(0x14); db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x0e); - db(0x61); db(0x00); db(0x03); db(0xf8); db(0x20); db(0x0d); db(0x4e); db(0x90); - db(0x41); db(0xfa); db(0x04); db(0x78); db(0x43); db(0xfa); db(0x01); db(0x12); - db(0x70); db(0xf6); db(0x22); db(0x3c); db(0x00); db(0x00); db(0x27); db(0x10); - db(0x61); db(0x00); db(0xee); db(0x14); db(0x70); db(0x00); db(0x4c); db(0xdf); - db(0x60); db(0x00); db(0x4e); db(0x75); db(0x30); db(0x3c); db(0xff); db(0x38); - db(0x72); db(0x0a); db(0x61); db(0x00); db(0x03); db(0xce); db(0x4e); db(0x90); - db(0x4e); db(0x75); db(0x61); db(0xf0); db(0x20); db(0x0d); db(0x67); db(0x1c); - db(0x2c); db(0x6d); db(0x00); db(0x14); db(0x20); db(0x2d); db(0x00); db(0x18); - db(0x67); db(0x06); db(0x22); db(0x40); db(0x4e); db(0xae); db(0xfe); db(0x62); - db(0x22); db(0x4d); db(0x20); db(0x3c); db(0x00); db(0x00); db(0x00); db(0x88); - db(0x4e); db(0xae); db(0xff); db(0x2e); db(0x70); db(0x00); db(0x4e); db(0x75); - db(0x48); db(0xe7); db(0x38); db(0x3e); db(0x2c); db(0x6d); db(0x00); db(0x18); - db(0x41); db(0xfa); db(0x04); db(0x06); db(0x22); db(0x08); db(0x24); db(0x3c); - db(0x00); db(0x00); db(0x03); db(0xed); db(0x4e); db(0xae); db(0xff); db(0xe2); - db(0x28); db(0x00); db(0x67); db(0x4c); db(0x45); db(0xed); db(0x00); db(0x68); - db(0x42); db(0x92); db(0x34); db(0xaa); db(0x00); db(0x02); db(0x24); db(0x0a); - db(0x54); db(0x82); db(0x76); db(0x02); db(0x22); db(0x04); db(0x4e); db(0xae); - db(0xff); db(0xd6); db(0xb6); db(0x80); db(0x66); db(0x32); db(0x0c); db(0x92); - db(0x50); db(0x4e); db(0x54); db(0x52); db(0x66); db(0xe4); db(0x24); db(0x0a); - db(0x76); db(0x04); db(0x22); db(0x04); db(0x4e); db(0xae); db(0xff); db(0xd6); - db(0x24); db(0x0a); db(0x76); db(0x20); db(0x22); db(0x04); db(0x4e); db(0xae); - db(0xff); db(0xd6); db(0xb6); db(0x80); db(0x66); db(0x12); db(0x4a); db(0x6a); - db(0x00); db(0x10); db(0x66); db(0xc4); db(0x30); db(0x3c); db(0xff); db(0x38); - db(0x72); db(0x10); db(0x61); db(0x00); db(0x03); db(0x3e); db(0x4e); db(0x90); - db(0x22); db(0x04); db(0x67); db(0x04); db(0x4e); db(0xae); db(0xff); db(0xdc); - db(0x4c); db(0xdf); db(0x7c); db(0x1c); db(0x4e); db(0x75); db(0x2c); db(0x6d); - db(0x00); db(0x18); db(0x41); db(0xfa); db(0x03); db(0x7e); db(0x22); db(0x08); - db(0x74); db(0xfe); db(0x4e); db(0xae); db(0xff); db(0xac); db(0x22); db(0x00); - db(0x67); db(0x34); db(0x4e); db(0xae); db(0xff); db(0xa6); db(0x2c); db(0x6d); - db(0x00); db(0x14); db(0x45); db(0xed); db(0x00); db(0x38); db(0x70); db(0xff); - db(0x4e); db(0xae); db(0xfe); db(0xb6); db(0x15); db(0x40); db(0x00); db(0x14); - db(0x41); db(0xfa); db(0x03); db(0x6e); db(0x24); db(0x88); db(0x25); db(0x7c); - db(0x00); db(0x00); db(0x00); db(0x12); db(0x00); db(0x0c); db(0x25); db(0x6d); - db(0x00); db(0x08); db(0x00); db(0x10); db(0x2c); db(0x6d); db(0x00); db(0x18); - db(0x22); db(0x0a); db(0x4e); db(0xae); db(0xfc); db(0x88); db(0x2c); db(0x6d); - db(0x00); db(0x14); db(0x4e); db(0x75); db(0x00); db(0x00); db(0x00); db(0x10); - db(0x00); db(0x00); db(0x00); db(0x00); db(0x30); db(0x3c); db(0xff); db(0x38); - db(0x72); db(0x0d); db(0x61); db(0x00); db(0x02); db(0xce); db(0x4e); db(0x90); - db(0x4a); db(0x80); db(0x67); db(0x00); db(0xfe); db(0xfe); db(0x2a); db(0x40); - db(0x2c); db(0x6d); db(0x00); db(0x14); db(0x93); db(0xc9); db(0x4e); db(0xae); - db(0xfe); db(0xda); db(0x2b); db(0x40); db(0x00); db(0x08); db(0x43); db(0xfa); - db(0x03); db(0xab); db(0x70); db(0x00); db(0x4e); db(0xae); db(0xfd); db(0xd8); - db(0x2b); db(0x40); db(0x00); db(0x18); db(0x67); db(0x00); db(0xfe); db(0xdc); - db(0x2c); db(0x40); db(0x72); db(0x32); db(0x4e); db(0xae); db(0xff); db(0x3a); - db(0x41); db(0xfa); db(0x02); db(0xd4); db(0x22); db(0x08); db(0x74); db(0xfe); - db(0x4e); db(0xae); db(0xff); db(0xac); db(0x4a); db(0x80); db(0x67); db(0xea); - db(0x22); db(0x00); db(0x4e); db(0xae); db(0xff); db(0xa6); db(0x72); db(0x32); - db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x41); db(0xfa); db(0x02); db(0xbe); - db(0x22); db(0x08); db(0x74); db(0xfe); db(0x4e); db(0xae); db(0xff); db(0xac); - db(0x4a); db(0x80); db(0x67); db(0x00); db(0xfe); db(0xa6); db(0x22); db(0x00); - db(0x4e); db(0xae); db(0xff); db(0xa6); db(0x2c); db(0x6d); db(0x00); db(0x14); - db(0x61); db(0x00); db(0xf8); db(0x20); db(0x72); db(0x00); db(0x32); db(0x3c); - db(0x00); db(0x34); db(0x61); db(0x00); db(0xf8); db(0x64); db(0x28); db(0x40); - db(0x4a); db(0x80); db(0x67); db(0x00); db(0xfe); db(0x86); db(0x70); db(0x00); + db(0x13); db(0x7c); db(0x00); db(0x01); db(0x00); db(0x1e); db(0x22); db(0x6b); + db(0x00); db(0xa8); db(0x33); db(0x7c); db(0x00); db(0x0a); db(0x00); db(0x1c); + db(0x13); db(0x7c); db(0x00); db(0x01); db(0x00); db(0x1e); db(0x4e); db(0xae); + db(0xfe); db(0x38); db(0x22); db(0x6b); db(0x00); db(0xa8); db(0x25); db(0x69); + db(0x00); db(0x20); db(0x00); db(0x0e); db(0x25); db(0x69); db(0x00); db(0x24); + db(0x00); db(0x12); db(0x22); db(0x6b); db(0x00); db(0xa4); db(0x4e); db(0xae); + db(0xfe); db(0x38); db(0xdf); db(0xc2); db(0x4c); db(0xdf); db(0x44); db(0x04); + db(0x4e); db(0x75); db(0x4a); db(0x00); db(0x67); db(0x26); db(0x4a); db(0x2b); + db(0x00); db(0x4c); db(0x66); db(0x36); db(0x70); db(0x00); db(0x4a); db(0x33); + db(0x00); db(0x4d); db(0x67); db(0x04); db(0x52); db(0x00); db(0x60); db(0xf6); + db(0x17); db(0x40); db(0x00); db(0x4c); db(0x67); db(0x24); db(0x20); db(0x01); + db(0x61); db(0x00); db(0xfd); db(0xf2); db(0x70); db(0x01); db(0x61); db(0x00); + db(0xff); db(0x60); db(0x60); db(0x16); db(0x4a); db(0x2b); db(0x00); db(0x4c); + db(0x67); db(0x10); db(0x42); db(0x2b); db(0x00); db(0x4c); db(0x20); db(0x01); + db(0x61); db(0x00); db(0xfe); db(0x68); db(0x70); db(0x00); db(0x61); db(0x00); + db(0xff); db(0x48); db(0x4e); db(0x75); db(0x4a); db(0xac); db(0x00); db(0x14); + db(0x67); db(0x0a); db(0x70); db(0x00); db(0x72); db(0x01); db(0x61); db(0x00); + db(0xff); db(0xb2); db(0x4e); db(0x75); db(0x70); db(0x01); db(0x72); db(0x03); + db(0x61); db(0x00); db(0xff); db(0xa8); db(0x4e); db(0x75); db(0x10); db(0x2b); + db(0x00); db(0xac); db(0x6b); db(0x0a); db(0x70); db(0x01); db(0x72); db(0x03); + db(0x61); db(0x00); db(0xff); db(0x98); db(0x4e); db(0x75); db(0x72); db(0x01); + db(0x0c); db(0x00); db(0x00); db(0xfe); db(0x66); db(0x02); db(0x72); db(0x03); + db(0x70); db(0x00); db(0x61); db(0x00); db(0xff); db(0x86); db(0x4e); db(0x75); + db(0x20); db(0x6c); db(0x00); db(0x24); db(0x4a); db(0x90); db(0x67); db(0x0c); + db(0x4a); db(0xa8); db(0x00); db(0x08); db(0x66); db(0x0a); db(0x4a); db(0xa8); + db(0x00); db(0x0c); db(0x66); db(0x04); db(0x70); db(0x01); db(0x4e); db(0x75); + db(0x48); db(0xe7); db(0x3f); db(0x3e); db(0x2a); db(0x48); db(0x24); db(0x6c); + db(0x00); db(0x18); db(0x2e); db(0x15); db(0x7a); db(0x00); db(0x4a); db(0x87); + db(0x67); db(0x70); db(0x20); db(0x0a); db(0x67); db(0x6c); db(0x7c); db(0x00); + db(0x22); db(0x2d); db(0x00); db(0x08); db(0x67); db(0x12); db(0x24); db(0x2a); + db(0x00); db(0x04); db(0x2c); db(0x6b); db(0x00); db(0xa0); db(0x4e); db(0xae); + db(0xfc); db(0x34); db(0x4a); db(0x80); db(0x66); db(0x02); db(0x50); db(0xc6); + db(0x22); db(0x2d); db(0x00); db(0x0c); db(0x67); db(0x1c); db(0x20); db(0x41); + db(0x22); db(0x4a); db(0x2f); db(0x0a); db(0x45); db(0xec); db(0x00); db(0x20); + db(0x48); db(0x7a); db(0x00); db(0x08); db(0x2f); db(0x28); db(0x00); db(0x08); + db(0x4e); db(0x75); db(0x24); db(0x5f); db(0x4a); db(0x80); db(0x66); db(0x02); + db(0x50); db(0xc6); db(0x4a); db(0x06); db(0x67); db(0x24); db(0x20); db(0x2a); + db(0x00); db(0x04); db(0x90); db(0x8a); db(0x4a); db(0x92); db(0x66); db(0x0a); + db(0x20); db(0x05); db(0x67); db(0x10); db(0x20); db(0x40); db(0x42); db(0x90); + db(0x60); db(0x0a); db(0x20); db(0x52); db(0x22); db(0x4a); db(0x22); db(0xd8); + db(0x59); db(0x80); db(0x6a); db(0xfa); db(0x53); db(0x95); db(0x53); db(0x87); + db(0x60); db(0x94); db(0x2a); db(0x0a); db(0x24); db(0x52); db(0x53); db(0x87); + db(0x60); db(0x8c); db(0x4c); db(0xdf); db(0x7c); db(0xfc); db(0x20); db(0x6c); + db(0x00); db(0x24); db(0x4a); db(0x90); db(0x4e); db(0x75); db(0x61); db(0x00); + db(0xfc); db(0x7c); db(0x21); db(0x40); db(0x01); db(0x9c); db(0x2f); db(0x08); + db(0x30); db(0x3c); db(0xff); db(0xec); db(0x61); db(0x00); db(0x0f); db(0x18); + db(0x2a); db(0x50); db(0x30); db(0x3c); db(0xff); db(0x28); db(0x61); db(0x00); + db(0x0f); db(0x0e); db(0x22); db(0x48); db(0x20); db(0x5f); db(0x42); db(0xa8); + db(0x01); db(0x90); db(0x42); db(0xa8); db(0x01); db(0x94); db(0x4e); db(0x91); + db(0x26); db(0x00); db(0x0c); db(0x43); db(0xff); db(0xfe); db(0x67); db(0x00); + db(0xf9); db(0x14); db(0x20); db(0x28); db(0x01); db(0x90); db(0x67); db(0x14); + db(0x6b); db(0x12); db(0x2f); db(0x08); db(0x72); db(0x01); db(0x2c); db(0x78); + db(0x00); db(0x04); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x20); db(0x5f); + db(0x21); db(0x40); db(0x01); db(0x94); db(0x4a); db(0x83); db(0x6a); db(0x0e); + db(0x22); db(0x48); db(0x30); db(0x3c); db(0xff); db(0x20); db(0x61); db(0x00); + db(0x0e); db(0xce); db(0x4e); db(0x90); db(0x60); db(0x26); db(0x2c); db(0x4c); + db(0x2f); db(0x08); db(0x4e); db(0xae); db(0xff); db(0x70); db(0x20); db(0x5f); + db(0x22); db(0x48); db(0x26); db(0x40); db(0x30); db(0x3c); db(0xff); db(0x20); + db(0x61); db(0x00); db(0x0e); db(0xb4); db(0x4e); db(0x90); db(0x70); db(0x00); + db(0x27); db(0x40); db(0x00); db(0x08); db(0x27); db(0x40); db(0x00); db(0x10); + db(0x27); db(0x40); db(0x00); db(0x20); db(0x20); db(0x69); db(0x01); db(0x94); + db(0x4a); db(0xa9); db(0x01); db(0x90); db(0x67); db(0x2c); db(0x20); db(0x08); + db(0x67); db(0x32); db(0x61); db(0x00); db(0xfa); db(0xec); db(0x48); db(0xe7); + db(0x80); db(0xc0); db(0x20); db(0x29); db(0x01); db(0x90); db(0x22); db(0x69); + db(0x01); db(0x94); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x4e); db(0xae); + db(0xff); db(0x2e); db(0x4c); db(0xdf); db(0x03); db(0x01); db(0x42); db(0xa9); + db(0x01); db(0x90); db(0x23); db(0x48); db(0x01); db(0x94); db(0x4a); db(0x80); + db(0x67); db(0x0a); db(0x4a); db(0xa9); db(0x01); db(0x98); db(0x67); db(0x04); + db(0x61); db(0x00); db(0xfa); db(0x68); db(0x4a); db(0x83); db(0x6b); db(0x00); + db(0xf8); db(0x7c); db(0x30); db(0x3c); db(0xff); db(0x18); db(0x61); db(0x00); + db(0x0e); db(0x56); db(0x4e); db(0x90); db(0x20); db(0x03); db(0x16); db(0x29); + db(0x00); db(0x4f); db(0x4a); db(0x80); db(0x66); db(0x1a); db(0x27); db(0x7c); + db(0x00); db(0x00); db(0x17); db(0x70); db(0x00); db(0x14); db(0x41); db(0xfa); + db(0xf6); db(0x64); db(0x20); db(0x08); db(0xe4); db(0x88); db(0x27); db(0x40); + db(0x00); db(0x20); db(0x70); db(0xff); db(0x27); db(0x40); db(0x00); db(0x24); + db(0x08); db(0x07); db(0x00); db(0x00); db(0x67); db(0x40); db(0x0c); db(0x03); + db(0x00); db(0x80); db(0x67); db(0x3a); db(0x2c); db(0x78); db(0x00); db(0x04); + db(0x70); db(0x14); db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); + db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x22); db(0x40); db(0x30); db(0x3c); + db(0x10); db(0x00); db(0x80); db(0x03); db(0x33); db(0x40); db(0x00); db(0x08); + db(0x23); db(0x6d); db(0x01); db(0x04); db(0x00); db(0x0a); db(0x23); db(0x4b); + db(0x00); db(0x10); db(0x41); db(0xec); db(0x00); db(0x4a); db(0x4e); db(0xae); + db(0xff); db(0x7c); db(0x4e); db(0xae); db(0xfe); db(0xf2); db(0x4e); db(0xae); + db(0xff); db(0x76); db(0x70); db(0x00); db(0x4e); db(0x75); db(0x24); db(0x49); + db(0x20); db(0x4b); db(0x72); db(0x00); db(0x22); db(0x41); db(0x08); db(0x07); + db(0x00); db(0x01); db(0x67); db(0x08); db(0x08); db(0x07); db(0x00); db(0x02); + db(0x67); db(0x02); db(0x72); db(0x01); db(0x70); db(0x80); db(0x2c); db(0x4c); + db(0x4e); db(0xae); db(0xff); db(0x6a); db(0x08); db(0x07); db(0x00); db(0x01); + db(0x67); db(0x5c); db(0x08); db(0x07); db(0x00); db(0x02); db(0x66); db(0x56); + db(0x20); db(0x52); db(0x74); db(0x02); db(0x52); db(0x82); db(0x4a); db(0x30); + db(0x28); db(0xfd); db(0x66); db(0xf8); db(0x2c); db(0x78); db(0x00); db(0x04); + db(0x20); db(0x02); db(0x72); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); + db(0x4a); db(0x80); db(0x67); db(0x3a); db(0x20); db(0x52); db(0x24); db(0x40); + db(0x22); db(0x4a); db(0x12); db(0xd8); db(0x66); db(0xfc); db(0x13); db(0x7c); + db(0x00); db(0x3a); db(0xff); db(0xff); db(0x42); db(0x11); db(0x2c); db(0x78); + db(0x00); db(0x04); db(0x43); db(0xfa); db(0x0e); db(0x83); db(0x70); db(0x00); + db(0x4e); db(0xae); db(0xfd); db(0xd8); db(0x2c); db(0x40); db(0x22); db(0x0a); + db(0x4e); db(0xae); db(0xff); db(0x52); db(0x22); db(0x4e); db(0x2c); db(0x78); + db(0x00); db(0x04); db(0x4e); db(0xae); db(0xfe); db(0x62); db(0x22); db(0x4a); + db(0x20); db(0x02); db(0x4e); db(0xae); db(0xff); db(0x2e); db(0x70); db(0x00); + db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x3f); db(0x3e); db(0x2c); db(0x01); + db(0x7e); db(0x06); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x43); db(0xfa); + db(0x0e); db(0x7e); db(0x70); db(0x24); db(0x4e); db(0xae); db(0xfd); db(0xd8); + db(0x4a); db(0x80); db(0x66); db(0x0e); db(0x08); db(0x87); db(0x00); db(0x02); + db(0x43); db(0xfa); db(0x0e); db(0x6c); db(0x70); db(0x00); db(0x4e); db(0xae); + db(0xfd); db(0xd8); db(0x28); db(0x40); db(0x20); db(0x3c); db(0x00); db(0x00); + db(0x02); db(0x30); db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); + db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x20); db(0x40); db(0x4a); db(0x80); + db(0x67); db(0x2c); db(0x21); db(0x4c); db(0x01); db(0xa0); db(0x48); db(0xe7); + db(0x00); db(0x8a); db(0x61); db(0x00); db(0xfd); db(0xf2); db(0x4c); db(0xdf); + db(0x51); db(0x00); db(0x0c); db(0x80); db(0xff); db(0xff); db(0xff); db(0xfe); + db(0x67); db(0x08); db(0x48); db(0x46); db(0x52); db(0x46); db(0x48); db(0x46); + db(0x60); db(0xe4); db(0x22); db(0x48); db(0x20); db(0x3c); db(0x00); db(0x00); + db(0x02); db(0x30); db(0x4e); db(0xae); db(0xff); db(0x2e); db(0x22); db(0x4c); + db(0x4e); db(0xae); db(0xfe); db(0x62); db(0x4c); db(0xdf); db(0x7c); db(0xfc); + db(0x4e); db(0x75); db(0x30); db(0x3c); db(0xff); db(0x58); db(0x61); db(0x00); + db(0x0c); db(0xe6); db(0x70); db(0x03); db(0x4e); db(0x90); db(0x22); db(0x6b); + db(0x00); db(0xa8); db(0x23); db(0x40); db(0x00); db(0x20); db(0x67); db(0x16); + db(0x70); db(0x00); db(0x23); db(0x40); db(0x00); db(0x24); db(0x33); db(0x7c); + db(0x00); db(0x0b); db(0x00); db(0x1c); db(0x13); db(0x7c); db(0x00); db(0x01); + db(0x00); db(0x1e); db(0x4e); db(0xae); db(0xfe); db(0x38); db(0x4e); db(0x75); + db(0x2c); db(0x78); db(0x00); db(0x04); db(0x93); db(0xc9); db(0x4e); db(0xae); + db(0xfe); db(0xda); db(0x20); db(0x40); db(0x4b); db(0xe8); db(0x00); db(0x5c); + db(0x43); db(0xfa); db(0x0d); db(0xa5); db(0x70); db(0x00); db(0x4e); db(0xae); + db(0xfd); db(0xd8); db(0x24); db(0x40); db(0x20); db(0x3c); db(0x00); db(0x00); + db(0x00); db(0xb9); db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); + db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x26); db(0x40); db(0x7c); db(0x00); + db(0x26); db(0x86); db(0x27); db(0x46); db(0x00); db(0x04); db(0x27); db(0x46); + db(0x00); db(0x08); db(0x27); db(0x4a); db(0x00); db(0xa0); db(0x50); db(0xeb); + db(0x00); db(0x9e); db(0x93); db(0xc9); db(0x4e); db(0xae); db(0xfe); db(0xda); + db(0x27); db(0x40); db(0x00); db(0xb0); db(0x41); db(0xfa); db(0x0c); db(0x7e); + db(0x70); db(0x00); db(0x72); db(0x00); db(0x61); db(0x00); db(0x02); db(0xae); + db(0x27); db(0x40); db(0x00); db(0xa4); db(0x41); db(0xfa); db(0x0c); db(0x7b); + db(0x70); db(0x00); db(0x72); db(0x00); db(0x61); db(0x00); db(0x02); db(0x9e); + db(0x27); db(0x40); db(0x00); db(0xa8); db(0x7a); db(0x00); db(0x20); db(0x4d); + db(0x4e); db(0xae); db(0xfe); db(0x80); db(0x20); db(0x4d); db(0x4e); db(0xae); + db(0xfe); db(0x8c); db(0x28); db(0x40); db(0x26); db(0x2c); db(0x00); db(0x0a); + db(0x30); db(0x3c); db(0xff); db(0x40); db(0x61); db(0x00); db(0x0c); db(0x38); + db(0x70); db(0x00); db(0x4e); db(0x90); db(0x24); db(0x00); db(0x70); db(0x01); + db(0x61); db(0x00); db(0xf9); db(0xf2); db(0x08); db(0x02); db(0x00); db(0x01); + db(0x67); db(0x06); db(0x70); db(0x01); db(0x61); db(0x00); db(0xfb); db(0x5a); + db(0x60); db(0x00); db(0x01); db(0x2e); db(0x20); db(0x4d); db(0x4e); db(0xae); + db(0xfe); db(0x8c); db(0x28); db(0x40); db(0x4a); db(0x80); db(0x66); db(0x10); + db(0x70); db(0x00); db(0x12); db(0x2d); db(0x00); db(0x0f); db(0x03); db(0xc0); db(0x08); db(0xc0); db(0x00); db(0x0d); db(0x4e); db(0xae); db(0xfe); db(0xc2); - db(0x72); db(0x00); db(0x20); db(0x2d); db(0x00); db(0x0c); db(0x41); db(0xfa); - db(0x02); db(0x97); db(0x22); db(0x4c); db(0x4e); db(0xae); db(0xfe); db(0x44); - db(0x4a); db(0x80); db(0x66); db(0xe2); db(0x20); db(0x6c); db(0x00); db(0x14); - db(0x0c); db(0x68); db(0x00); db(0x25); db(0x00); db(0x14); db(0x64); db(0x0c); - db(0x61); db(0x00); db(0xfe); db(0x4a); db(0x70); db(0x00); db(0x4e); db(0xae); - db(0xfe); db(0xc2); db(0x60); db(0xf8); db(0x61); db(0x00); db(0xfe); db(0xe8); - db(0x41); db(0xed); db(0x00); db(0x1c); db(0x29); db(0x48); db(0x00); db(0x28); - db(0x70); db(0x01); db(0x29); db(0x40); db(0x00); db(0x24); db(0x39); db(0x7c); - db(0x00); db(0x0c); db(0x00); db(0x1c); db(0x2b); db(0x4d); db(0x00); db(0x2c); - db(0x41); db(0xfa); db(0x01); db(0x60); db(0x2b); db(0x48); db(0x00); db(0x24); - db(0x22); db(0x4c); db(0x4e); db(0xae); db(0xfe); db(0x38); db(0x30); db(0x3c); - db(0xff); db(0x38); db(0x72); db(0x0f); db(0x61); db(0x00); db(0x01); db(0xe4); - db(0x4e); db(0x90); db(0x4a); db(0xad); db(0x00); db(0x00); db(0x66); db(0x1c); - db(0x70); db(0x00); db(0x74); db(0x00); db(0x14); db(0x2d); db(0x00); db(0x4c); - db(0x05); db(0xc0); db(0x08); db(0xc0); db(0x00); db(0x0d); db(0x4e); db(0xae); - db(0xfe); db(0xc2); db(0x05); db(0x00); db(0x67); db(0x06); db(0x61); db(0x00); - db(0xfe); db(0x20); db(0x60); db(0xe4); db(0x20); db(0x2d); db(0x00); db(0x00); - db(0x67); db(0x00); db(0x00); db(0x76); db(0x72); db(0x01); db(0x4e); db(0xae); - db(0xff); db(0x3a); db(0x2b); db(0x40); db(0x00); db(0x04); db(0x30); db(0x3c); - db(0xff); db(0x38); db(0x72); db(0x0c); db(0x61); db(0x00); db(0x01); db(0xa4); - db(0x4e); db(0x90); db(0x4a); db(0x80); db(0x67); db(0x40); db(0x4a); db(0xad); - db(0x00); db(0x04); db(0x67); db(0x3a); db(0x39); db(0x7c); db(0x00); db(0x03); - db(0x00); db(0x1c); db(0x42); db(0x2c); db(0x00); db(0x1f); db(0x42); db(0xac); - db(0x00); db(0x20); db(0x29); db(0x6d); db(0x00); db(0x00); db(0x00); db(0x24); - db(0x29); db(0x6d); db(0x00); db(0x04); db(0x00); db(0x28); db(0x42); db(0xac); - db(0x00); db(0x2c); db(0x42); db(0xac); db(0x00); db(0x30); db(0x22); db(0x4c); - db(0x4e); db(0xae); db(0xfe); db(0x38); db(0x2b); db(0x6c); db(0x00); db(0x30); - db(0x00); db(0x10); db(0x39); db(0x7c); db(0x00); db(0x04); db(0x00); db(0x1c); - db(0x22); db(0x4c); db(0x4e); db(0xae); db(0xfe); db(0x38); db(0x20); db(0x2d); - db(0x00); db(0x00); db(0x42); db(0xad); db(0x00); db(0x00); db(0x22); db(0x2d); - db(0x00); db(0x04); db(0x67); db(0x00); db(0xff); db(0x74); db(0x22); db(0x41); - db(0x4e); db(0xae); db(0xff); db(0x2e); db(0x60); db(0x00); db(0xff); db(0x6a); - db(0x39); db(0x7c); db(0x00); db(0x02); db(0x00); db(0x1c); db(0x41); db(0xed); - db(0x00); db(0x30); db(0x42); db(0x90); db(0x42); db(0xa8); db(0x00); db(0x04); - db(0x42); db(0x2c); db(0x00); db(0x1f); db(0x42); db(0xac); db(0x00); db(0x2c); - db(0x42); db(0xac); db(0x00); db(0x30); db(0x29); db(0x48); db(0x00); db(0x28); - db(0x70); db(0x08); db(0x29); db(0x40); db(0x00); db(0x24); db(0x22); db(0x4c); - db(0x4e); db(0xae); db(0xfe); db(0x38); db(0x0c); db(0xad); db(0x46); db(0x4f); - db(0x52); db(0x4d); db(0x00); db(0x30); db(0x66); db(0x52); db(0x20); db(0x2d); - db(0x00); db(0x34); db(0x67); db(0x4c); db(0x6b); db(0x4a); db(0x2b); db(0x6c); - db(0x00); db(0x30); db(0x00); db(0x10); db(0x50); db(0x80); db(0x24); db(0x00); - db(0x72); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x4a); db(0x80); - db(0x67); db(0x36); db(0x24); db(0x40); db(0x20); db(0x4a); db(0x20); db(0xed); - db(0x00); db(0x30); db(0x20); db(0xed); db(0x00); db(0x34); db(0x29); db(0x48); - db(0x00); db(0x28); db(0x20); db(0x02); db(0x51); db(0x80); db(0x29); db(0x40); + db(0x4a); db(0x2b); db(0x00); db(0xad); db(0x67); db(0x08); db(0x61); db(0x00); + db(0xff); db(0x0a); db(0x42); db(0x2b); db(0x00); db(0xad); db(0x4a); db(0x2b); + db(0x00); db(0xac); db(0x67); db(0x24); db(0x30); db(0x3c); db(0xff); db(0x58); + db(0x61); db(0x00); db(0x0b); db(0xe4); db(0x70); db(0x01); db(0x4e); db(0x90); + db(0x4a); db(0x80); db(0x67); db(0x04); db(0x61); db(0x00); db(0xfb); db(0xe8); + db(0x42); db(0x2b); db(0x00); db(0xac); db(0x30); db(0x3c); db(0xff); db(0x58); + db(0x61); db(0x00); db(0x0b); db(0xcc); db(0x70); db(0x02); db(0x4e); db(0x90); + db(0x20); db(0x0c); db(0x67); db(0x56); db(0x0c); db(0x6c); db(0x00); db(0x26); + db(0x00); db(0x12); db(0x66); db(0x4e); db(0x0c); db(0xac); db(0x40); db(0x00); + db(0x00); db(0x00); db(0x00); db(0x14); db(0x66); db(0x44); db(0x0c); db(0x6c); + db(0x12); db(0x34); db(0x00); db(0x18); db(0x66); db(0x3c); db(0x20); db(0x6c); + db(0x00); db(0x1a); db(0x20); db(0x28); db(0x00); db(0x0c); db(0x02); db(0x80); + db(0x80); db(0x00); db(0x00); db(0x08); db(0x0c); db(0x80); db(0x80); db(0x00); + db(0x00); db(0x08); db(0x66); db(0x1a); db(0x02); db(0xa8); db(0x7f); db(0xff); + db(0xff); db(0xff); db(0x00); db(0x0c); db(0x20); db(0x68); db(0x00); db(0x10); + db(0x22); db(0x4c); db(0x12); db(0xbc); db(0x00); db(0x08); db(0x4e); db(0xae); + db(0xfe); db(0x92); db(0x60); db(0x00); db(0xff); db(0x60); db(0x22); db(0x4c); + db(0x70); db(0x26); db(0x4e); db(0xae); db(0xff); db(0x2e); db(0x60); db(0x00); + db(0xff); db(0x54); db(0x74); db(0xfe); db(0x20); db(0x0c); db(0x67); db(0x14); + db(0x26); db(0x2c); db(0x00); db(0x0a); db(0x66); db(0x42); db(0x74); db(0xff); + db(0x30); db(0x3c); db(0xff); db(0x50); db(0x61); db(0x00); db(0x0b); db(0x58); + db(0x70); db(0x01); db(0x4e); db(0x90); db(0x45); db(0xeb); db(0x00); db(0x04); + db(0x20); db(0x52); db(0x20); db(0x08); db(0x67); db(0x00); db(0xff); db(0x2e); + db(0x22); db(0x50); db(0x20); db(0x40); db(0x20); db(0x28); db(0x00); db(0x04); + db(0xb4); db(0x80); db(0x66); db(0x16); db(0x48); db(0xe7); db(0x00); db(0xc0); + db(0x28); db(0x68); db(0x00); db(0x0a); db(0x61); db(0x4a); db(0x53); db(0x85); + db(0x4c); db(0xdf); db(0x03); db(0x00); db(0x24); db(0x89); db(0x20); db(0x49); + db(0x60); db(0xd8); db(0x24); db(0x48); db(0x20); db(0x49); db(0x60); db(0xd2); + db(0x0c); db(0x85); db(0x00); db(0x00); db(0x00); db(0x14); db(0x65); db(0x00); + db(0x00); db(0x0a); db(0x70); db(0x01); db(0x29); db(0x40); db(0x00); db(0x04); + db(0x60); db(0x12); db(0x61); db(0x5e); db(0x30); db(0x3c); db(0xff); db(0x30); + db(0x61); db(0x00); db(0x0b); db(0x04); db(0x4e); db(0x90); db(0x4a); db(0x80); + db(0x67); db(0x0e); db(0x52); db(0x85); db(0x28); db(0xab); db(0x00); db(0x04); + db(0x27); db(0x4c); db(0x00); db(0x04); db(0x60); db(0x00); db(0xfe); db(0xd6); + db(0x28); db(0x43); db(0x61); db(0x04); db(0x60); db(0x00); db(0xfe); db(0xce); + db(0x0c); db(0xac); db(0x00); db(0x00); db(0x00); db(0x1f); db(0x00); db(0x08); + db(0x66); db(0x04); db(0x61); db(0x00); db(0xfa); db(0xd0); db(0x0c); db(0xac); + db(0x00); db(0x00); db(0x04); db(0x09); db(0x00); db(0x08); db(0x66); db(0x14); + db(0x61); db(0x00); db(0xfa); db(0xfe); db(0x66); db(0x0e); db(0x30); db(0x3c); + db(0xff); db(0x58); db(0x61); db(0x00); db(0x0a); db(0xc2); db(0x70); db(0x00); + db(0x4e); db(0x90); db(0x60); db(0xec); db(0x22); db(0x54); db(0x20); db(0x6c); + db(0x00); db(0x04); db(0x29); db(0x4d); db(0x00); db(0x04); db(0x4e); db(0xee); + db(0xfe); db(0x92); db(0x2f); db(0x05); db(0x7a); db(0xfc); db(0x24); db(0x53); + db(0x2e); db(0x0a); db(0x22); db(0x0a); db(0x67); db(0x00); db(0x00); db(0x0c); + db(0x52); db(0x85); db(0x67); db(0x1e); db(0x22); db(0x4a); db(0x24); db(0x52); + db(0x60); db(0xf0); db(0x52); db(0x85); db(0x67); db(0x3c); db(0x24); db(0x47); + db(0x70); db(0x18); db(0x72); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); + db(0x52); db(0x46); db(0x24); db(0x40); db(0x24); db(0x87); db(0x2e); db(0x0a); + db(0x60); db(0xe8); db(0x20); db(0x12); db(0x67); db(0x24); db(0x20); db(0x40); + db(0x20); db(0x10); db(0x67); db(0x1e); db(0x20); db(0x40); db(0x20); db(0x10); + db(0x67); db(0x18); db(0x70); db(0x00); db(0x22); db(0x80); db(0x22); db(0x4a); + db(0x24); db(0x51); db(0x70); db(0x18); db(0x4e); db(0xae); db(0xff); db(0x2e); + db(0x06); db(0x86); db(0x00); db(0x01); db(0x00); db(0x00); db(0x20); db(0x0a); + db(0x66); db(0xec); db(0x26); db(0x87); db(0x2a); db(0x1f); db(0x4e); db(0x75); + db(0x20); db(0x88); db(0x58); db(0x90); db(0x42); db(0xa8); db(0x00); db(0x04); + db(0x21); db(0x48); db(0x00); db(0x08); db(0x4e); db(0x75); db(0x48); db(0xe7); + db(0x20); db(0x22); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x70); db(0xff); + db(0x4e); db(0xae); db(0xfe); db(0xb6); db(0x91); db(0xc8); db(0x24); db(0x00); + db(0x6b); db(0x32); db(0x70); db(0x22); db(0x22); db(0x3c); db(0x00); db(0x01); + db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x91); db(0xc8); + db(0x24); db(0x40); db(0x4a); db(0x80); db(0x67); db(0x1e); db(0x15); db(0x7c); + db(0x00); db(0x04); db(0x00); db(0x08); db(0x15); db(0x42); db(0x00); db(0x0f); + db(0x93); db(0xc9); db(0x4e); db(0xae); db(0xfe); db(0xda); db(0x25); db(0x40); + db(0x00); db(0x10); db(0x41); db(0xea); db(0x00); db(0x14); db(0x61); db(0x00); + db(0xff); db(0xb0); db(0x20); db(0x4a); db(0x20); db(0x08); db(0x4c); db(0xdf); + db(0x44); db(0x04); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x20); db(0x22); + db(0x2c); db(0x78); db(0x00); db(0x04); db(0x4a); db(0x80); db(0x67); db(0x24); + db(0x24); db(0x40); db(0x24); db(0x01); db(0x66); db(0x02); db(0x74); db(0x30); + db(0x20); db(0x02); db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); + db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x20); db(0x40); db(0x11); db(0x7c); + db(0x00); db(0x0a); db(0x00); db(0x08); db(0x31); db(0x42); db(0x00); db(0x12); + db(0x21); db(0x4a); db(0x00); db(0x0e); db(0x4a); db(0x80); db(0x4c); db(0xdf); + db(0x44); db(0x04); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x30); db(0x22); + db(0x24); db(0x48); db(0x24); db(0x00); db(0x26); db(0x01); db(0x2c); db(0x78); + db(0x00); db(0x04); db(0x61); db(0x00); db(0xff); db(0x6a); db(0x22); db(0x03); + db(0x61); db(0x00); db(0xff); db(0xb2); db(0x67); db(0x18); db(0x20); db(0x4a); + db(0x22); db(0x40); db(0x24); db(0x40); db(0x20); db(0x02); db(0x72); db(0x00); + db(0x4e); db(0xae); db(0xfe); db(0x44); db(0x22); db(0x00); db(0x70); db(0x00); + db(0x4a); db(0x81); db(0x66); db(0x02); db(0x20); db(0x0a); db(0x4a); db(0x80); + db(0x4c); db(0xdf); db(0x44); db(0x0c); db(0x4e); db(0x75); db(0x48); db(0xe7); + db(0x38); db(0x32); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x28); db(0x00); + db(0x24); db(0x08); db(0x26); db(0x09); db(0x20); db(0x3c); db(0x00); db(0x00); + db(0x08); db(0x5c); db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); + db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x4a); db(0x80); db(0x67); db(0x00); + db(0x00); db(0x34); db(0x24); db(0x40); db(0x15); db(0x7c); db(0x00); db(0x01); + db(0x00); db(0x08); db(0x15); db(0x44); db(0x00); db(0x09); db(0x25); db(0x42); + db(0x00); db(0x0a); db(0x47); db(0xea); db(0x00); db(0x5c); db(0x25); db(0x4b); + db(0x00); db(0x3a); db(0x47); db(0xeb); db(0x08); db(0x00); db(0x25); db(0x4b); + db(0x00); db(0x3e); db(0x25); db(0x4b); db(0x00); db(0x36); db(0x22); db(0x4a); + db(0x24); db(0x43); db(0x97); db(0xcb); db(0x24); db(0x09); db(0x4e); db(0xae); + db(0xfe); db(0xe6); db(0x20); db(0x02); db(0x4c); db(0xdf); db(0x4c); db(0x1c); + db(0x4e); db(0x75); db(0x41); db(0xfa); db(0x09); db(0xc0); db(0x43); db(0xfa); + db(0x01); db(0x30); db(0x70); db(0x13); db(0x61); db(0x00); db(0xff); db(0x98); + db(0x4e); db(0x75); db(0x22); db(0x6d); db(0x02); db(0x0c); db(0x33); db(0x7c); + db(0x00); db(0x0a); db(0x00); db(0x1c); db(0x13); db(0x7c); db(0x00); db(0x01); + db(0x00); db(0x1e); db(0x4e); db(0xae); db(0xfe); db(0x38); db(0x22); db(0x6d); + db(0x02); db(0x0c); db(0x25); db(0x69); db(0x00); db(0x20); db(0x00); db(0x0e); + db(0x25); db(0x69); db(0x00); db(0x24); db(0x00); db(0x12); db(0x22); db(0x6d); + db(0x02); db(0x08); db(0x13); db(0x7c); db(0x00); db(0x01); db(0x00); db(0x1e); + db(0x4e); db(0xae); db(0xfe); db(0x38); db(0x4e); db(0x75); db(0x42); db(0xaa); + db(0x00); db(0x0e); db(0x42); db(0xaa); db(0x00); db(0x12); db(0x22); db(0x6d); + db(0x02); db(0x08); db(0x13); db(0x7c); db(0x00); db(0x01); db(0x00); db(0x1e); + db(0x4e); db(0xae); db(0xfe); db(0x38); db(0x4e); db(0x75); db(0x48); db(0xe7); + db(0xf8); db(0xfe); db(0x2a); db(0x48); db(0x95); db(0xca); db(0x97); db(0xcb); + db(0x99); db(0xcc); db(0x78); db(0x00); db(0x2c); db(0x6d); db(0x00); db(0x18); + db(0x20); db(0x6d); db(0x00); db(0x14); db(0x20); db(0x28); db(0x00); db(0x3c); + db(0x67); db(0x5c); db(0x20); db(0x40); db(0x41); db(0xe8); db(0x00); db(0x2c); + db(0x28); db(0x48); db(0x4e); db(0xae); db(0xfc); db(0xe8); db(0x72); db(0xff); + db(0x74); db(0xff); db(0xb2); db(0x80); db(0x67); db(0x48); db(0x26); db(0x00); + db(0x2c); db(0x6d); db(0x00); db(0x14); db(0x41); db(0xed); db(0x00); db(0xc0); + db(0x70); db(0x66); db(0x4e); db(0xae); db(0xff); db(0x7c); db(0x41); db(0xed); + db(0x00); db(0xc0); db(0x38); db(0x28); db(0x00); db(0x64); db(0x2c); db(0x6d); + db(0x00); db(0x18); db(0x91); db(0xc8); db(0x43); db(0xed); db(0x00); db(0x38); + db(0x70); db(0x00); db(0x30); db(0x3c); db(0x00); db(0x58); db(0x22); db(0x3c); + db(0x80); db(0x00); db(0x10); db(0x00); db(0x24); db(0x03); db(0x4e); db(0xae); + db(0xfd); db(0x0c); db(0x72); db(0xff); db(0x74); db(0xff); db(0x4a); db(0x80); + db(0x6b); db(0x0c); db(0x45); db(0xed); db(0x00); db(0x38); db(0x22); db(0x2a); + db(0x00); db(0x32); db(0x24); db(0x2a); db(0x00); db(0x36); db(0x20); db(0x2c); + db(0x00); db(0x1c); db(0xb8); db(0x6d); db(0x00); db(0x2c); db(0x66); db(0x12); + db(0xb0); db(0xad); db(0x00); db(0x28); db(0x66); db(0x0c); db(0xb2); db(0xad); + db(0x00); db(0x20); db(0x66); db(0x06); db(0xb4); db(0xad); db(0x00); db(0x24); + db(0x67); db(0x40); db(0x2b); db(0x40); db(0x00); db(0x28); db(0x2b); db(0x41); + db(0x00); db(0x20); db(0x2b); db(0x42); db(0x00); db(0x24); db(0x3b); db(0x44); + db(0x00); db(0x2c); db(0x91); db(0xc8); db(0x43); db(0xed); db(0x00); db(0x90); + db(0x70); db(0x00); db(0x30); db(0x3c); db(0x00); db(0x58); db(0x22); db(0x3c); + db(0x80); db(0x00); db(0x00); db(0x00); db(0x24); db(0x03); db(0x4e); db(0xae); + db(0xfd); db(0x0c); db(0x4a); db(0x80); db(0x6b); db(0x04); db(0x47); db(0xed); + db(0x00); db(0x90); db(0x34); db(0x2d); db(0x00); db(0x2c); db(0x30); db(0x3c); + db(0xff); db(0x38); db(0x72); db(0x01); db(0x61); db(0x00); db(0x07); db(0xf8); + db(0x4e); db(0x90); db(0x4c); db(0xdf); db(0x7f); db(0x1f); db(0x4e); db(0x75); + db(0x2c); db(0x78); db(0x00); db(0x04); db(0x3e); db(0x2e); db(0x00); db(0x14); + db(0x70); db(0xff); db(0x4e); db(0xae); db(0xfe); db(0xb6); db(0x7c); db(0x00); + db(0x01); db(0xc6); db(0x93); db(0xc9); db(0x4e); db(0xae); db(0xfe); db(0xda); + db(0x28); db(0x40); db(0x70); db(0x14); db(0x22); db(0x4c); db(0x4e); db(0xae); + db(0xfe); db(0xd4); db(0x70); db(0x00); db(0x30); db(0x3c); db(0x02); db(0x3c); + db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); + db(0xff); db(0x3a); db(0x2a); db(0x40); db(0x47); db(0xed); db(0x00); db(0x16); + db(0x27); db(0x4e); db(0x00); db(0x10); db(0x27); db(0x4c); db(0x00); db(0x08); + db(0x27); db(0x46); db(0x00); db(0x0c); db(0x70); db(0xff); db(0x37); db(0x40); + db(0x00); db(0x00); db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x05); + db(0x61); db(0x00); db(0x07); db(0x9c); db(0x20); db(0x0d); db(0x06); db(0x80); + db(0x00); db(0x00); db(0x02); db(0x10); db(0x4e); db(0x90); db(0x43); db(0xed); + db(0x00); db(0x00); db(0x13); db(0x7c); db(0x00); db(0x02); db(0x00); db(0x08); + db(0x13); db(0x7c); db(0x00); db(0x05); db(0x00); db(0x09); db(0x41); db(0xfa); + db(0x08); db(0x1c); db(0x23); db(0x48); db(0x00); db(0x0a); db(0x41); db(0xfa); + db(0x02); db(0xf4); db(0x23); db(0x48); db(0x00); db(0x12); db(0x23); db(0x4d); + db(0x00); db(0x0e); db(0x70); db(0x05); db(0x4e); db(0xae); db(0xff); db(0x58); + db(0x20); db(0x06); db(0x4e); db(0xae); db(0xfe); db(0xc2); db(0x70); db(0x00); + db(0x53); db(0xab); db(0x00); db(0x1c); db(0x6a); db(0x06); db(0x70); db(0x0a); + db(0x27); db(0x40); db(0x00); db(0x1c); db(0x4a); db(0xab); db(0x00); db(0x14); + db(0x66); db(0x16); db(0x4a); db(0xab); db(0x00); db(0x1c); db(0x66); db(0xe0); + db(0x43); db(0xfa); db(0x08); db(0x49); db(0x70); db(0x00); db(0x4e); db(0xae); + db(0xfd); db(0xd8); db(0x27); db(0x40); db(0x00); db(0x14); db(0x67); db(0xd0); + db(0x4a); db(0xab); db(0x00); db(0x18); db(0x66); db(0x18); db(0x4a); db(0xab); + db(0x00); db(0x1c); db(0x66); db(0xc4); db(0x43); db(0xfa); db(0x08); db(0x3f); + db(0x70); db(0x00); db(0x4e); db(0xae); db(0xfd); db(0xd8); db(0x27); db(0x40); + db(0x00); db(0x18); db(0x67); db(0x00); db(0xff); db(0xb4); db(0x4a); db(0xad); + db(0x02); db(0x08); db(0x66); db(0x38); db(0x4a); db(0xab); db(0x00); db(0x1c); + db(0x66); db(0xa6); db(0x4e); db(0xae); db(0xff); db(0x7c); db(0x41); db(0xee); + db(0x01); db(0x5e); db(0x43); db(0xfa); db(0x07); db(0x10); db(0x4e); db(0xae); + db(0xfe); db(0xec); db(0x24); db(0x00); db(0x4e); db(0xae); db(0xff); db(0x76); + db(0x4a); db(0x82); db(0x67); db(0x8c); db(0x41); db(0xfa); db(0x06); db(0xfe); + db(0x70); db(0x00); db(0x72); db(0x00); db(0x61); db(0x00); db(0xfd); db(0x2e); + db(0x2b); db(0x40); db(0x02); db(0x08); db(0x67); db(0x00); db(0x02); db(0x32); + db(0x60); db(0x00); db(0xff); db(0x76); db(0x4a); db(0xad); db(0x02); db(0x0c); + db(0x66); db(0x48); db(0x4a); db(0xab); db(0x00); db(0x1c); db(0x66); db(0x00); + db(0xff); db(0x68); db(0x4e); db(0xae); db(0xff); db(0x7c); db(0x41); db(0xee); + db(0x01); db(0x5e); db(0x43); db(0xfa); db(0x06); db(0xdd); db(0x4e); db(0xae); + db(0xfe); db(0xec); db(0x24); db(0x00); db(0x4e); db(0xae); db(0xff); db(0x76); + db(0x4a); db(0x82); db(0x67); db(0x00); db(0xff); db(0x4c); db(0x41); db(0xfa); + db(0x06); db(0xc9); db(0x70); db(0x00); db(0x72); db(0x00); db(0x61); db(0x00); + db(0xfc); db(0xec); db(0x2b); db(0x40); db(0x02); db(0x0c); db(0x67); db(0x00); + db(0x01); db(0xf0); db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x00); + db(0x61); db(0x00); db(0x06); db(0x94); db(0x4e); db(0x90); db(0x60); db(0x00); + db(0xff); db(0x28); db(0x0c); db(0x47); db(0x00); db(0x24); db(0x65); db(0x12); + db(0x53); db(0xab); db(0x00); db(0x34); db(0x6a); db(0x0c); db(0x20); db(0x4b); + db(0x61); db(0x00); db(0xfd); db(0xb4); db(0x70); db(0x32); db(0x27); db(0x40); + db(0x00); db(0x34); db(0x22); db(0x6d); db(0x02); db(0x08); db(0x45); db(0xed); + db(0x01); db(0x3c); db(0x33); db(0x7c); db(0x00); db(0x0b); db(0x00); db(0x1c); + db(0x23); db(0x7c); db(0x00); db(0x00); db(0x00); db(0x16); db(0x00); db(0x24); + db(0x23); db(0x4a); db(0x00); db(0x28); db(0x10); db(0x2d); db(0x02); db(0x10); + db(0x0c); db(0x47); db(0x00); db(0x27); db(0x65); db(0x00); db(0x01); db(0x52); + db(0x08); db(0x00); db(0x00); db(0x01); db(0x67); db(0x00); db(0x01); db(0x4a); + db(0x41); db(0xed); db(0x01); db(0x68); db(0x25); db(0x48); db(0x00); db(0x0a); + db(0x15); db(0x7c); db(0x00); db(0x13); db(0x00); db(0x04); db(0x15); db(0x7c); + db(0x00); db(0x03); db(0x00); db(0x05); db(0x42); db(0x90); db(0x42); db(0xa8); + db(0x00); db(0x04); db(0x42); db(0xa8); db(0x00); db(0x08); db(0x42); db(0x68); + db(0x00); db(0x0c); db(0x42); db(0x6a); db(0x00); db(0x06); db(0x61); db(0x00); + db(0x01); db(0x72); db(0x31); db(0x6d); db(0x02); db(0x1a); db(0x00); db(0x0e); + db(0x42); db(0x68); db(0x00); db(0x10); db(0x31); db(0x6d); db(0x02); db(0x1c); + db(0x00); db(0x12); db(0x42); db(0x68); db(0x00); db(0x14); db(0x31); db(0x6d); + db(0x02); db(0x14); db(0x00); db(0x16); db(0x42); db(0x68); db(0x00); db(0x18); + db(0x31); db(0x6d); db(0x02); db(0x16); db(0x00); db(0x1a); db(0x43); db(0xed); + db(0x01); db(0x88); db(0x21); db(0x49); db(0x00); db(0x1c); db(0x22); db(0xfc); + db(0x80); db(0x03); db(0xa0); db(0x06); db(0x30); db(0x2d); db(0x02); db(0x30); + db(0x48); db(0xc0); db(0xe1); db(0x80); db(0x22); db(0xc0); db(0x22); db(0xfc); + db(0x80); db(0x03); db(0xa0); db(0x07); db(0x22); db(0xed); db(0x02); db(0x32); + db(0x70); db(0x00); db(0x30); db(0x2d); db(0x02); db(0x20); db(0x6b); db(0x08); + db(0x22); db(0xfc); db(0x80); db(0x03); db(0xa0); db(0x09); db(0x22); db(0xc0); + db(0x30); db(0x2d); db(0x02); db(0x22); db(0x6b); db(0x08); db(0x22); db(0xfc); + db(0x80); db(0x03); db(0xa0); db(0x0a); db(0x22); db(0xc0); db(0x30); db(0x2d); + db(0x02); db(0x18); db(0x6b); db(0x14); db(0x22); db(0xfc); db(0x80); db(0x03); + db(0xa0); db(0x02); db(0x22); db(0xc0); db(0x30); db(0x2d); db(0x02); db(0x1e); + db(0x22); db(0xfc); db(0x80); db(0x03); db(0xa0); db(0x01); db(0x22); db(0xc0); + db(0x30); db(0x2d); db(0x02); db(0x24); db(0x6b); db(0x10); db(0x22); db(0xfc); + db(0x80); db(0x03); db(0xa0); db(0x03); db(0x30); db(0x2d); db(0x02); db(0x2a); + db(0x48); db(0xc0); db(0xe1); db(0x80); db(0x22); db(0xc0); db(0x30); db(0x2d); + db(0x02); db(0x26); db(0x6b); db(0x10); db(0x22); db(0xfc); db(0x80); db(0x03); + db(0xa0); db(0x04); db(0x30); db(0x2d); db(0x02); db(0x2c); db(0x48); db(0xc0); + db(0xe1); db(0x80); db(0x22); db(0xc0); db(0x30); db(0x2d); db(0x02); db(0x28); + db(0x6b); db(0x10); db(0x22); db(0xfc); db(0x80); db(0x03); db(0xa0); db(0x05); + db(0x30); db(0x2d); db(0x02); db(0x2e); db(0x48); db(0xc0); db(0xe1); db(0x80); + db(0x22); db(0xc0); db(0x70); db(0x00); db(0x30); db(0x2d); db(0x02); db(0x36); + db(0x6b); db(0x08); db(0x22); db(0xfc); db(0x80); db(0x03); db(0xa0); db(0x08); + db(0x22); db(0xc0); db(0x42); db(0x91); db(0x61); db(0x00); db(0xfc); db(0x68); + db(0x36); db(0x3c); db(0x00); db(0x68); db(0x74); db(0x01); db(0x28); db(0x2d); + db(0x02); db(0x32); db(0x20); db(0x04); db(0xc0); db(0x82); db(0x22); db(0x2b); + db(0x00); db(0x04); db(0xc2); db(0x82); db(0xb2); db(0x80); db(0x67); db(0x22); + db(0x42); db(0x92); db(0x35); db(0x7c); db(0x02); db(0x00); db(0x00); db(0x04); + db(0x42); db(0xaa); db(0x00); db(0x0a); db(0x32); db(0x03); db(0x4a); db(0x00); + db(0x66); db(0x04); db(0x08); db(0xc1); db(0x00); db(0x07); db(0x35); db(0x41); + db(0x00); db(0x06); db(0x42); db(0x6a); db(0x00); db(0x08); db(0x61); db(0x00); + db(0xfc); db(0x2e); db(0x52); db(0x43); db(0xd4); db(0x42); db(0x0c); db(0x42); + db(0x00); db(0x08); db(0x66); db(0xc6); db(0x27); db(0x44); db(0x00); db(0x04); + db(0x10); db(0x2d); db(0x02); db(0x10); db(0x08); db(0x00); db(0x00); db(0x00); + db(0x67); db(0x00); db(0xfd); db(0x8e); db(0x42); db(0x92); db(0x35); db(0x7c); + db(0x04); db(0x00); db(0x00); db(0x04); db(0x42); db(0x6a); db(0x00); db(0x06); + db(0x61); db(0x00); db(0x00); db(0x38); db(0x20); db(0x6b); db(0x00); db(0x14); + db(0x30); db(0x2d); db(0x02); db(0x38); db(0x32); db(0x28); db(0x00); db(0x30); + db(0xd2); db(0x41); db(0x90); db(0x41); db(0x6a); db(0x02); db(0x70); db(0x00); + db(0x35); db(0x40); db(0x00); db(0x0a); db(0x30); db(0x2d); db(0x02); db(0x3a); + db(0x32); db(0x28); db(0x00); db(0x2e); db(0xd2); db(0x41); db(0x90); db(0x41); + db(0x6a); db(0x02); db(0x70); db(0x00); db(0x35); db(0x40); db(0x00); db(0x0c); + db(0x61); db(0x00); db(0xfb); db(0xa0); db(0x60); db(0x00); db(0xfd); db(0x4a); + db(0x4e); db(0x75); db(0x22); db(0x2d); db(0x02); db(0x32); db(0x70); db(0x00); + db(0x08); db(0x01); db(0x00); db(0x00); db(0x67); db(0x04); db(0x08); db(0xc0); + db(0x00); db(0x0e); db(0x08); db(0x01); db(0x00); db(0x01); db(0x67); db(0x04); + db(0x08); db(0xc0); db(0x00); db(0x0d); db(0x08); db(0x01); db(0x00); db(0x02); + db(0x67); db(0x04); db(0x08); db(0xc0); db(0x00); db(0x0c); db(0x35); db(0x40); + db(0x00); db(0x08); db(0x4e); db(0x75); db(0x4a); db(0xa9); db(0x02); db(0x08); + db(0x67); db(0x14); db(0x4a); db(0xa9); db(0x02); db(0x0c); db(0x67); db(0x0e); + db(0x30); db(0x29); db(0x02); db(0x12); db(0xb0); db(0x69); db(0x00); db(0x16); + db(0x67); db(0x14); db(0x33); db(0x40); db(0x00); db(0x16); db(0x2c); db(0x69); + db(0x00); db(0x26); db(0x20); db(0x29); db(0x00); db(0x22); db(0x22); db(0x69); + db(0x00); db(0x1e); db(0x4e); db(0xae); db(0xfe); db(0xbc); db(0x53); db(0x69); + db(0x00); db(0x46); db(0x6a); db(0x12); db(0x33); db(0x7c); db(0x00); db(0x32); + db(0x00); db(0x46); db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x02); + db(0x61); db(0x00); db(0x04); db(0x44); db(0x4e); db(0x90); db(0x41); db(0xf9); + db(0x00); db(0xdf); db(0xf0); db(0x00); db(0x70); db(0x00); db(0x4e); db(0x75); + db(0x48); db(0xe7); db(0x00); db(0x06); db(0x30); db(0x3c); db(0xff); db(0x38); + db(0x72); db(0x11); db(0x61); db(0x00); db(0x04); db(0x2a); db(0x4e); db(0x90); + db(0x08); db(0x00); db(0x00); db(0x00); db(0x67); db(0x42); db(0x2c); db(0x78); + db(0x00); db(0x04); db(0x20); db(0x3c); db(0x00); db(0x00); db(0x00); db(0x88); + db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01); db(0x4e); db(0xae); + db(0xff); db(0x3a); db(0x4a); db(0x80); db(0x67); db(0x00); db(0x00); db(0x40); + db(0x2a); db(0x40); db(0x2b); db(0x4e); db(0x00); db(0x14); db(0x30); db(0x3c); + db(0xff); db(0x38); db(0x72); db(0x0e); db(0x61); db(0x00); db(0x03); db(0xf8); + db(0x20); db(0x0d); db(0x4e); db(0x90); db(0x41); db(0xfa); db(0x04); db(0x78); + db(0x43); db(0xfa); db(0x01); db(0x12); db(0x70); db(0xf6); db(0x22); db(0x3c); + db(0x00); db(0x00); db(0x27); db(0x10); db(0x61); db(0x00); db(0xee); db(0x00); + db(0x70); db(0x00); db(0x4c); db(0xdf); db(0x60); db(0x00); db(0x4e); db(0x75); + db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x0a); db(0x61); db(0x00); + db(0x03); db(0xce); db(0x4e); db(0x90); db(0x4e); db(0x75); db(0x61); db(0xf0); + db(0x20); db(0x0d); db(0x67); db(0x1c); db(0x2c); db(0x6d); db(0x00); db(0x14); + db(0x20); db(0x2d); db(0x00); db(0x18); db(0x67); db(0x06); db(0x22); db(0x40); + db(0x4e); db(0xae); db(0xfe); db(0x62); db(0x22); db(0x4d); db(0x20); db(0x3c); + db(0x00); db(0x00); db(0x00); db(0x88); db(0x4e); db(0xae); db(0xff); db(0x2e); + db(0x70); db(0x00); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x38); db(0x3e); + db(0x2c); db(0x6d); db(0x00); db(0x18); db(0x41); db(0xfa); db(0x04); db(0x06); + db(0x22); db(0x08); db(0x24); db(0x3c); db(0x00); db(0x00); db(0x03); db(0xed); + db(0x4e); db(0xae); db(0xff); db(0xe2); db(0x28); db(0x00); db(0x67); db(0x4c); + db(0x45); db(0xed); db(0x00); db(0x68); db(0x42); db(0x92); db(0x34); db(0xaa); + db(0x00); db(0x02); db(0x24); db(0x0a); db(0x54); db(0x82); db(0x76); db(0x02); + db(0x22); db(0x04); db(0x4e); db(0xae); db(0xff); db(0xd6); db(0xb6); db(0x80); + db(0x66); db(0x32); db(0x0c); db(0x92); db(0x50); db(0x4e); db(0x54); db(0x52); + db(0x66); db(0xe4); db(0x24); db(0x0a); db(0x76); db(0x04); db(0x22); db(0x04); + db(0x4e); db(0xae); db(0xff); db(0xd6); db(0x24); db(0x0a); db(0x76); db(0x20); + db(0x22); db(0x04); db(0x4e); db(0xae); db(0xff); db(0xd6); db(0xb6); db(0x80); + db(0x66); db(0x12); db(0x4a); db(0x6a); db(0x00); db(0x10); db(0x66); db(0xc4); + db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x10); db(0x61); db(0x00); + db(0x03); db(0x3e); db(0x4e); db(0x90); db(0x22); db(0x04); db(0x67); db(0x04); + db(0x4e); db(0xae); db(0xff); db(0xdc); db(0x4c); db(0xdf); db(0x7c); db(0x1c); + db(0x4e); db(0x75); db(0x2c); db(0x6d); db(0x00); db(0x18); db(0x41); db(0xfa); + db(0x03); db(0x7e); db(0x22); db(0x08); db(0x74); db(0xfe); db(0x4e); db(0xae); + db(0xff); db(0xac); db(0x22); db(0x00); db(0x67); db(0x34); db(0x4e); db(0xae); + db(0xff); db(0xa6); db(0x2c); db(0x6d); db(0x00); db(0x14); db(0x45); db(0xed); + db(0x00); db(0x38); db(0x70); db(0xff); db(0x4e); db(0xae); db(0xfe); db(0xb6); + db(0x15); db(0x40); db(0x00); db(0x14); db(0x41); db(0xfa); db(0x03); db(0x6e); + db(0x24); db(0x88); db(0x25); db(0x7c); db(0x00); db(0x00); db(0x00); db(0x12); + db(0x00); db(0x0c); db(0x25); db(0x6d); db(0x00); db(0x08); db(0x00); db(0x10); + db(0x2c); db(0x6d); db(0x00); db(0x18); db(0x22); db(0x0a); db(0x4e); db(0xae); + db(0xfc); db(0x88); db(0x2c); db(0x6d); db(0x00); db(0x14); db(0x4e); db(0x75); + db(0x00); db(0x00); db(0x00); db(0x10); db(0x00); db(0x00); db(0x00); db(0x00); + db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x0d); db(0x61); db(0x00); + db(0x02); db(0xce); db(0x4e); db(0x90); db(0x4a); db(0x80); db(0x67); db(0x00); + db(0xfe); db(0xfe); db(0x2a); db(0x40); db(0x2c); db(0x6d); db(0x00); db(0x14); + db(0x93); db(0xc9); db(0x4e); db(0xae); db(0xfe); db(0xda); db(0x2b); db(0x40); + db(0x00); db(0x08); db(0x43); db(0xfa); db(0x03); db(0xab); db(0x70); db(0x00); + db(0x4e); db(0xae); db(0xfd); db(0xd8); db(0x2b); db(0x40); db(0x00); db(0x18); + db(0x67); db(0x00); db(0xfe); db(0xdc); db(0x2c); db(0x40); db(0x72); db(0x32); + db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x41); db(0xfa); db(0x02); db(0xd4); + db(0x22); db(0x08); db(0x74); db(0xfe); db(0x4e); db(0xae); db(0xff); db(0xac); + db(0x4a); db(0x80); db(0x67); db(0xea); db(0x22); db(0x00); db(0x4e); db(0xae); + db(0xff); db(0xa6); db(0x72); db(0x32); db(0x4e); db(0xae); db(0xff); db(0x3a); + db(0x41); db(0xfa); db(0x02); db(0xbe); db(0x22); db(0x08); db(0x74); db(0xfe); + db(0x4e); db(0xae); db(0xff); db(0xac); db(0x4a); db(0x80); db(0x67); db(0x00); + db(0xfe); db(0xa6); db(0x22); db(0x00); db(0x4e); db(0xae); db(0xff); db(0xa6); + db(0x2c); db(0x6d); db(0x00); db(0x14); db(0x61); db(0x00); db(0xf8); db(0x20); + db(0x72); db(0x00); db(0x32); db(0x3c); db(0x00); db(0x34); db(0x61); db(0x00); + db(0xf8); db(0x64); db(0x28); db(0x40); db(0x4a); db(0x80); db(0x67); db(0x00); + db(0xfe); db(0x86); db(0x70); db(0x00); db(0x08); db(0xc0); db(0x00); db(0x0d); + db(0x4e); db(0xae); db(0xfe); db(0xc2); db(0x72); db(0x00); db(0x20); db(0x2d); + db(0x00); db(0x0c); db(0x41); db(0xfa); db(0x02); db(0x97); db(0x22); db(0x4c); + db(0x4e); db(0xae); db(0xfe); db(0x44); db(0x4a); db(0x80); db(0x66); db(0xe2); + db(0x20); db(0x6c); db(0x00); db(0x14); db(0x0c); db(0x68); db(0x00); db(0x25); + db(0x00); db(0x14); db(0x64); db(0x0c); db(0x61); db(0x00); db(0xfe); db(0x4a); + db(0x70); db(0x00); db(0x4e); db(0xae); db(0xfe); db(0xc2); db(0x60); db(0xf8); + db(0x61); db(0x00); db(0xfe); db(0xe8); db(0x41); db(0xed); db(0x00); db(0x1c); + db(0x29); db(0x48); db(0x00); db(0x28); db(0x70); db(0x01); db(0x29); db(0x40); + db(0x00); db(0x24); db(0x39); db(0x7c); db(0x00); db(0x0c); db(0x00); db(0x1c); + db(0x2b); db(0x4d); db(0x00); db(0x2c); db(0x41); db(0xfa); db(0x01); db(0x60); + db(0x2b); db(0x48); db(0x00); db(0x24); db(0x22); db(0x4c); db(0x4e); db(0xae); + db(0xfe); db(0x38); db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x0f); + db(0x61); db(0x00); db(0x01); db(0xe4); db(0x4e); db(0x90); db(0x4a); db(0xad); + db(0x00); db(0x00); db(0x66); db(0x1c); db(0x70); db(0x00); db(0x74); db(0x00); + db(0x14); db(0x2d); db(0x00); db(0x4c); db(0x05); db(0xc0); db(0x08); db(0xc0); + db(0x00); db(0x0d); db(0x4e); db(0xae); db(0xfe); db(0xc2); db(0x05); db(0x00); + db(0x67); db(0x06); db(0x61); db(0x00); db(0xfe); db(0x20); db(0x60); db(0xe4); + db(0x20); db(0x2d); db(0x00); db(0x00); db(0x67); db(0x00); db(0x00); db(0x76); + db(0x72); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x2b); db(0x40); + db(0x00); db(0x04); db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x0c); + db(0x61); db(0x00); db(0x01); db(0xa4); db(0x4e); db(0x90); db(0x4a); db(0x80); + db(0x67); db(0x40); db(0x4a); db(0xad); db(0x00); db(0x04); db(0x67); db(0x3a); + db(0x39); db(0x7c); db(0x00); db(0x03); db(0x00); db(0x1c); db(0x42); db(0x2c); + db(0x00); db(0x1f); db(0x42); db(0xac); db(0x00); db(0x20); db(0x29); db(0x6d); + db(0x00); db(0x00); db(0x00); db(0x24); db(0x29); db(0x6d); db(0x00); db(0x04); + db(0x00); db(0x28); db(0x42); db(0xac); db(0x00); db(0x2c); db(0x42); db(0xac); + db(0x00); db(0x30); db(0x22); db(0x4c); db(0x4e); db(0xae); db(0xfe); db(0x38); + db(0x2b); db(0x6c); db(0x00); db(0x30); db(0x00); db(0x10); db(0x39); db(0x7c); + db(0x00); db(0x04); db(0x00); db(0x1c); db(0x22); db(0x4c); db(0x4e); db(0xae); + db(0xfe); db(0x38); db(0x20); db(0x2d); db(0x00); db(0x00); db(0x42); db(0xad); + db(0x00); db(0x00); db(0x22); db(0x2d); db(0x00); db(0x04); db(0x67); db(0x00); + db(0xff); db(0x74); db(0x22); db(0x41); db(0x4e); db(0xae); db(0xff); db(0x2e); + db(0x60); db(0x00); db(0xff); db(0x6a); db(0x39); db(0x7c); db(0x00); db(0x02); + db(0x00); db(0x1c); db(0x41); db(0xed); db(0x00); db(0x30); db(0x42); db(0x90); + db(0x42); db(0xa8); db(0x00); db(0x04); db(0x42); db(0x2c); db(0x00); db(0x1f); + db(0x42); db(0xac); db(0x00); db(0x2c); db(0x42); db(0xac); db(0x00); db(0x30); + db(0x29); db(0x48); db(0x00); db(0x28); db(0x70); db(0x08); db(0x29); db(0x40); db(0x00); db(0x24); db(0x22); db(0x4c); db(0x4e); db(0xae); db(0xfe); db(0x38); - db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x0b); db(0x61); db(0x00); - db(0x00); db(0xca); db(0x20); db(0x2c); db(0x00); db(0x20); db(0x4e); db(0x90); - db(0x22); db(0x4a); db(0x20); db(0x02); db(0x4e); db(0xae); db(0xff); db(0x2e); - db(0x4a); db(0xac); db(0x00); db(0x20); db(0x67); db(0x00); db(0xfe); db(0xda); - db(0x41); db(0xed); db(0x00); db(0x30); db(0x29); db(0x48); db(0x00); db(0x28); - db(0x70); db(0x01); db(0x29); db(0x40); db(0x00); db(0x24); db(0x42); db(0xac); - db(0x00); db(0x20); db(0x22); db(0x4c); db(0x4e); db(0xae); db(0xfe); db(0x38); - db(0x60); db(0xde); db(0x41); db(0xe8); db(0xff); db(0xe4); db(0x20); db(0x29); - db(0x00); db(0x08); db(0xb0); db(0xa8); db(0x00); db(0x10); db(0x67); db(0x1a); - db(0x21); db(0x40); db(0x00); db(0x10); db(0x2f); db(0x0e); db(0x2c); db(0x68); - db(0x00); db(0x14); db(0x22); db(0x68); db(0x00); db(0x08); db(0x70); db(0x00); - db(0x08); db(0xc0); db(0x00); db(0x0d); db(0x4e); db(0xae); db(0xfe); db(0xbc); - db(0x2c); db(0x5f); db(0x70); db(0x00); db(0x4e); db(0x75); db(0x2c); db(0x78); - db(0x00); db(0x04); db(0x74); db(0xff); db(0x30); db(0x3c); db(0xff); db(0x38); - db(0x72); db(0x11); db(0x61); db(0x00); db(0x00); db(0x5e); db(0x4e); db(0x90); - db(0x08); db(0x00); db(0x00); db(0x01); db(0x67); db(0x38); db(0x74); db(0x00); - db(0x4e); db(0xae); db(0xff); db(0x7c); db(0x41); db(0xee); db(0x01); db(0x5e); - db(0x43); db(0xfa); db(0x00); db(0x70); db(0x4e); db(0xae); db(0xfe); db(0xec); - db(0x4a); db(0x80); db(0x67); db(0x1e); db(0x20); db(0x40); db(0x43); db(0xfa); - db(0x00); db(0x22); db(0x24); db(0x68); db(0xff); db(0xe4); db(0x21); db(0x49); - db(0xff); db(0xe4); db(0x22); db(0x48); db(0x30); db(0x3c); db(0xff); db(0x38); - db(0x72); db(0x65); db(0x61); db(0x00); db(0x00); db(0x26); db(0x4e); db(0x90); - db(0x74); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x76); db(0x20); db(0x02); - db(0x4e); db(0x75); db(0x59); db(0x8f); db(0x48); db(0xe7); db(0xc0); db(0x80); - db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x66); db(0x61); db(0x00); - db(0x00); db(0x0a); db(0x4e); db(0x90); db(0x4c); db(0xdf); db(0x01); db(0x03); - db(0x4e); db(0x75); db(0x41); db(0xfa); db(0xe8); db(0x30); db(0x02); db(0x80); - db(0x00); db(0x00); db(0xff); db(0xff); db(0xd1); db(0xc0); db(0x4e); db(0x75); - db(0x69); db(0x6e); db(0x70); db(0x75); db(0x74); db(0x2e); db(0x64); db(0x65); - db(0x76); db(0x69); db(0x63); db(0x65); db(0x00); db(0x74); db(0x69); db(0x6d); - db(0x65); db(0x72); db(0x2e); db(0x64); db(0x65); db(0x76); db(0x69); db(0x63); - db(0x65); db(0x00); db(0x63); db(0x6f); db(0x6e); db(0x73); db(0x6f); db(0x6c); - db(0x65); db(0x2e); db(0x64); db(0x65); db(0x76); db(0x69); db(0x63); db(0x65); - db(0x00); db(0x44); db(0x45); db(0x56); db(0x53); db(0x00); db(0x44); db(0x45); - db(0x56); db(0x53); db(0x3a); db(0x00); db(0x44); db(0x45); db(0x56); db(0x53); - db(0x3a); db(0x63); db(0x6c); db(0x69); db(0x70); db(0x62); db(0x6f); db(0x61); - db(0x72); db(0x64); db(0x2e); db(0x64); db(0x65); db(0x76); db(0x69); db(0x63); - db(0x65); db(0x00); db(0x52); db(0x41); db(0x4d); db(0x3a); db(0x00); db(0x63); - db(0x6c); db(0x69); db(0x70); db(0x62); db(0x6f); db(0x61); db(0x72); db(0x64); - db(0x2e); db(0x64); db(0x65); db(0x76); db(0x69); db(0x63); db(0x65); db(0x00); - db(0x52); db(0x41); db(0x4d); db(0x3a); db(0x45); db(0x6e); db(0x76); db(0x2f); - db(0x53); db(0x79); db(0x73); db(0x2f); db(0x50); db(0x6f); db(0x69); db(0x6e); - db(0x74); db(0x65); db(0x72); db(0x2e); db(0x70); db(0x72); db(0x65); db(0x66); - db(0x73); db(0x00); db(0x55); db(0x41); db(0x45); db(0x20); db(0x63); db(0x6c); - db(0x69); db(0x70); db(0x62); db(0x6f); db(0x61); db(0x72); db(0x64); db(0x20); - db(0x73); db(0x68); db(0x61); db(0x72); db(0x69); db(0x6e); db(0x67); db(0x00); - db(0x55); db(0x41); db(0x45); db(0x20); db(0x6d); db(0x6f); db(0x75); db(0x73); - db(0x65); db(0x20); db(0x64); db(0x72); db(0x69); db(0x76); db(0x65); db(0x72); - db(0x00); db(0x55); db(0x41); db(0x45); db(0x20); db(0x68); db(0x65); db(0x61); - db(0x72); db(0x74); db(0x20); db(0x62); db(0x65); db(0x61); db(0x74); db(0x00); - db(0x55); db(0x41); db(0x45); db(0x20); db(0x66); db(0x69); db(0x6c); db(0x65); - db(0x73); db(0x79); db(0x73); db(0x74); db(0x65); db(0x6d); db(0x00); db(0x55); - db(0x41); db(0x45); db(0x20); db(0x66); db(0x73); db(0x20); db(0x61); db(0x75); - db(0x74); db(0x6f); db(0x6d); db(0x6f); db(0x75); db(0x6e); db(0x74); db(0x65); - db(0x72); db(0x00); db(0x55); db(0x41); db(0x45); db(0x20); db(0x66); db(0x73); - db(0x20); db(0x61); db(0x75); db(0x74); db(0x6f); db(0x6d); db(0x6f); db(0x75); - db(0x6e); db(0x74); db(0x20); db(0x70); db(0x72); db(0x6f); db(0x63); db(0x65); - db(0x73); db(0x73); db(0x00); db(0x64); db(0x6f); db(0x73); db(0x2e); db(0x6c); - db(0x69); db(0x62); db(0x72); db(0x61); db(0x72); db(0x79); db(0x00); db(0x69); - db(0x6e); db(0x74); db(0x75); db(0x69); db(0x74); db(0x69); db(0x6f); db(0x6e); - db(0x2e); db(0x6c); db(0x69); db(0x62); db(0x72); db(0x61); db(0x72); db(0x79); - db(0x00); db(0x67); db(0x72); db(0x61); db(0x70); db(0x68); db(0x69); db(0x63); - db(0x73); db(0x2e); db(0x6c); db(0x69); db(0x62); db(0x72); db(0x61); db(0x72); - db(0x79); db(0x00); db(0x65); db(0x78); db(0x70); db(0x61); db(0x6e); db(0x73); - db(0x69); db(0x6f); db(0x6e); db(0x2e); db(0x6c); db(0x69); db(0x62); db(0x72); - db(0x61); db(0x72); db(0x79); db(0x00); db(0x46); db(0x69); db(0x6c); db(0x65); - db(0x53); db(0x79); db(0x73); db(0x74); db(0x65); db(0x6d); db(0x2e); db(0x72); - db(0x65); db(0x73); db(0x6f); db(0x75); db(0x72); db(0x63); db(0x65); db(0x00); - db(0x6d); db(0x65); db(0x67); db(0x61); db(0x63); db(0x68); db(0x69); db(0x70); - db(0x20); db(0x6d); db(0x65); db(0x6d); db(0x6f); db(0x72); db(0x79); db(0x00); - db(0x00); db(0x00); db(0x03); db(0xf2); + db(0x0c); db(0xad); db(0x46); db(0x4f); db(0x52); db(0x4d); db(0x00); db(0x30); + db(0x66); db(0x52); db(0x20); db(0x2d); db(0x00); db(0x34); db(0x67); db(0x4c); + db(0x6b); db(0x4a); db(0x2b); db(0x6c); db(0x00); db(0x30); db(0x00); db(0x10); + db(0x50); db(0x80); db(0x24); db(0x00); db(0x72); db(0x01); db(0x4e); db(0xae); + db(0xff); db(0x3a); db(0x4a); db(0x80); db(0x67); db(0x36); db(0x24); db(0x40); + db(0x20); db(0x4a); db(0x20); db(0xed); db(0x00); db(0x30); db(0x20); db(0xed); + db(0x00); db(0x34); db(0x29); db(0x48); db(0x00); db(0x28); db(0x20); db(0x02); + db(0x51); db(0x80); db(0x29); db(0x40); db(0x00); db(0x24); db(0x22); db(0x4c); + db(0x4e); db(0xae); db(0xfe); db(0x38); db(0x30); db(0x3c); db(0xff); db(0x38); + db(0x72); db(0x0b); db(0x61); db(0x00); db(0x00); db(0xca); db(0x20); db(0x2c); + db(0x00); db(0x20); db(0x4e); db(0x90); db(0x22); db(0x4a); db(0x20); db(0x02); + db(0x4e); db(0xae); db(0xff); db(0x2e); db(0x4a); db(0xac); db(0x00); db(0x20); + db(0x67); db(0x00); db(0xfe); db(0xda); db(0x41); db(0xed); db(0x00); db(0x30); + db(0x29); db(0x48); db(0x00); db(0x28); db(0x70); db(0x01); db(0x29); db(0x40); + db(0x00); db(0x24); db(0x42); db(0xac); db(0x00); db(0x20); db(0x22); db(0x4c); + db(0x4e); db(0xae); db(0xfe); db(0x38); db(0x60); db(0xde); db(0x41); db(0xe8); + db(0xff); db(0xe4); db(0x20); db(0x29); db(0x00); db(0x08); db(0xb0); db(0xa8); + db(0x00); db(0x10); db(0x67); db(0x1a); db(0x21); db(0x40); db(0x00); db(0x10); + db(0x2f); db(0x0e); db(0x2c); db(0x68); db(0x00); db(0x14); db(0x22); db(0x68); + db(0x00); db(0x08); db(0x70); db(0x00); db(0x08); db(0xc0); db(0x00); db(0x0d); + db(0x4e); db(0xae); db(0xfe); db(0xbc); db(0x2c); db(0x5f); db(0x70); db(0x00); + db(0x4e); db(0x75); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x74); db(0xff); + db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x11); db(0x61); db(0x00); + db(0x00); db(0x5e); db(0x4e); db(0x90); db(0x08); db(0x00); db(0x00); db(0x01); + db(0x67); db(0x38); db(0x74); db(0x00); db(0x4e); db(0xae); db(0xff); db(0x7c); + db(0x41); db(0xee); db(0x01); db(0x5e); db(0x43); db(0xfa); db(0x00); db(0x70); + db(0x4e); db(0xae); db(0xfe); db(0xec); db(0x4a); db(0x80); db(0x67); db(0x1e); + db(0x20); db(0x40); db(0x43); db(0xfa); db(0x00); db(0x22); db(0x24); db(0x68); + db(0xff); db(0xe4); db(0x21); db(0x49); db(0xff); db(0xe4); db(0x22); db(0x48); + db(0x30); db(0x3c); db(0xff); db(0x38); db(0x72); db(0x65); db(0x61); db(0x00); + db(0x00); db(0x26); db(0x4e); db(0x90); db(0x74); db(0x01); db(0x4e); db(0xae); + db(0xff); db(0x76); db(0x20); db(0x02); db(0x4e); db(0x75); db(0x59); db(0x8f); + db(0x48); db(0xe7); db(0xc0); db(0x80); db(0x30); db(0x3c); db(0xff); db(0x38); + db(0x72); db(0x66); db(0x61); db(0x00); db(0x00); db(0x0a); db(0x4e); db(0x90); + db(0x4c); db(0xdf); db(0x01); db(0x03); db(0x4e); db(0x75); db(0x41); db(0xfa); + db(0xe8); db(0x1c); db(0x02); db(0x80); db(0x00); db(0x00); db(0xff); db(0xff); + db(0xd1); db(0xc0); db(0x4e); db(0x75); db(0x69); db(0x6e); db(0x70); db(0x75); + db(0x74); db(0x2e); db(0x64); db(0x65); db(0x76); db(0x69); db(0x63); db(0x65); + db(0x00); db(0x74); db(0x69); db(0x6d); db(0x65); db(0x72); db(0x2e); db(0x64); + db(0x65); db(0x76); db(0x69); db(0x63); db(0x65); db(0x00); db(0x63); db(0x6f); + db(0x6e); db(0x73); db(0x6f); db(0x6c); db(0x65); db(0x2e); db(0x64); db(0x65); + db(0x76); db(0x69); db(0x63); db(0x65); db(0x00); db(0x44); db(0x45); db(0x56); + db(0x53); db(0x00); db(0x44); db(0x45); db(0x56); db(0x53); db(0x3a); db(0x00); + db(0x44); db(0x45); db(0x56); db(0x53); db(0x3a); db(0x63); db(0x6c); db(0x69); + db(0x70); db(0x62); db(0x6f); db(0x61); db(0x72); db(0x64); db(0x2e); db(0x64); + db(0x65); db(0x76); db(0x69); db(0x63); db(0x65); db(0x00); db(0x52); db(0x41); + db(0x4d); db(0x3a); db(0x00); db(0x63); db(0x6c); db(0x69); db(0x70); db(0x62); + db(0x6f); db(0x61); db(0x72); db(0x64); db(0x2e); db(0x64); db(0x65); db(0x76); + db(0x69); db(0x63); db(0x65); db(0x00); db(0x52); db(0x41); db(0x4d); db(0x3a); + db(0x45); db(0x6e); db(0x76); db(0x2f); db(0x53); db(0x79); db(0x73); db(0x2f); + db(0x50); db(0x6f); db(0x69); db(0x6e); db(0x74); db(0x65); db(0x72); db(0x2e); + db(0x70); db(0x72); db(0x65); db(0x66); db(0x73); db(0x00); db(0x55); db(0x41); + db(0x45); db(0x20); db(0x63); db(0x6c); db(0x69); db(0x70); db(0x62); db(0x6f); + db(0x61); db(0x72); db(0x64); db(0x20); db(0x73); db(0x68); db(0x61); db(0x72); + db(0x69); db(0x6e); db(0x67); db(0x00); db(0x55); db(0x41); db(0x45); db(0x20); + db(0x6d); db(0x6f); db(0x75); db(0x73); db(0x65); db(0x20); db(0x64); db(0x72); + db(0x69); db(0x76); db(0x65); db(0x72); db(0x00); db(0x55); db(0x41); db(0x45); + db(0x20); db(0x68); db(0x65); db(0x61); db(0x72); db(0x74); db(0x20); db(0x62); + db(0x65); db(0x61); db(0x74); db(0x00); db(0x55); db(0x41); db(0x45); db(0x20); + db(0x66); db(0x69); db(0x6c); db(0x65); db(0x73); db(0x79); db(0x73); db(0x74); + db(0x65); db(0x6d); db(0x00); db(0x55); db(0x41); db(0x45); db(0x20); db(0x66); + db(0x73); db(0x20); db(0x61); db(0x75); db(0x74); db(0x6f); db(0x6d); db(0x6f); + db(0x75); db(0x6e); db(0x74); db(0x65); db(0x72); db(0x00); db(0x55); db(0x41); + db(0x45); db(0x20); db(0x66); db(0x73); db(0x20); db(0x61); db(0x75); db(0x74); + db(0x6f); db(0x6d); db(0x6f); db(0x75); db(0x6e); db(0x74); db(0x20); db(0x70); + db(0x72); db(0x6f); db(0x63); db(0x65); db(0x73); db(0x73); db(0x00); db(0x64); + db(0x6f); db(0x73); db(0x2e); db(0x6c); db(0x69); db(0x62); db(0x72); db(0x61); + db(0x72); db(0x79); db(0x00); db(0x69); db(0x6e); db(0x74); db(0x75); db(0x69); + db(0x74); db(0x69); db(0x6f); db(0x6e); db(0x2e); db(0x6c); db(0x69); db(0x62); + db(0x72); db(0x61); db(0x72); db(0x79); db(0x00); db(0x67); db(0x72); db(0x61); + db(0x70); db(0x68); db(0x69); db(0x63); db(0x73); db(0x2e); db(0x6c); db(0x69); + db(0x62); db(0x72); db(0x61); db(0x72); db(0x79); db(0x00); db(0x65); db(0x78); + db(0x70); db(0x61); db(0x6e); db(0x73); db(0x69); db(0x6f); db(0x6e); db(0x2e); + db(0x6c); db(0x69); db(0x62); db(0x72); db(0x61); db(0x72); db(0x79); db(0x00); + db(0x46); db(0x69); db(0x6c); db(0x65); db(0x53); db(0x79); db(0x73); db(0x74); + db(0x65); db(0x6d); db(0x2e); db(0x72); db(0x65); db(0x73); db(0x6f); db(0x75); + db(0x72); db(0x63); db(0x65); db(0x00); db(0x6d); db(0x65); db(0x67); db(0x61); + db(0x63); db(0x68); db(0x69); db(0x70); db(0x20); db(0x6d); db(0x65); db(0x6d); + db(0x6f); db(0x72); db(0x79); db(0x00); db(0x00); db(0x00); db(0x03); db(0xf2); diff --git a/src/filesys_linux.c b/src/filesys_linux.c index 3755a7f..001e407 100644 --- a/src/filesys_linux.c +++ b/src/filesys_linux.c @@ -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; diff --git a/src/filesys_unix.c b/src/filesys_unix.c index 9aa430f..258e2aa 100644 --- a/src/filesys_unix.c +++ b/src/filesys_unix.c @@ -8,6 +8,7 @@ #include "sysconfig.h" #include "sysdeps.h" +#include "options.h" #include "filesys.h" diff --git a/src/fpp.c b/src/fpp.c index ed14d3b..5e33314 100644 --- a/src/fpp.c +++ b/src/fpp.c @@ -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? */ diff --git a/src/fsdb.c b/src/fsdb.c index 755f650..367773c 100644 --- a/src/fsdb.c +++ b/src/fsdb.c @@ -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) { diff --git a/src/fsdb_unix.c b/src/fsdb_unix.c index 01d8197..a792a00 100644 --- a/src/fsdb_unix.c +++ b/src/fsdb_unix.c @@ -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) diff --git a/src/fsusage.c b/src/fsusage.c index 6471356..9c55a55 100644 --- a/src/fsusage.c +++ b/src/fsusage.c @@ -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 -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 @@ -402,4 +368,3 @@ int #endif /* ! __BEOS__ */ #endif /* ! TARGET_AMIGAOS */ -#endif /* ! _WIN32 */ diff --git a/src/gayle.c b/src/gayle.c index ec7678f..476dcc8 100644 --- a/src/gayle.c +++ b/src/gayle.c @@ -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; } diff --git a/src/genblitter.c b/src/genblitter.c index 94108a4..66731a7 100755 --- a/src/genblitter.c +++ b/src/genblitter.c @@ -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"); diff --git a/src/gencomp.c b/src/gencomp.c index 64083cd..8c498f4 100755 --- a/src/gencomp.c +++ b/src/gencomp.c @@ -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; } diff --git a/src/gencpu.c b/src/gencpu.c index 98a9861..c3cc934 100755 --- a/src/gencpu.c +++ b/src/gencpu.c @@ -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; diff --git a/src/gfx-amigaos/ami-win.c b/src/gfx-amigaos/ami-win.c index c0940de..cc02c50 100644 --- a/src/gfx-amigaos/ami-win.c +++ b/src/gfx-amigaos/ami-win.c @@ -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 = { diff --git a/src/gfx-beos/be-Window.cpp b/src/gfx-beos/be-Window.cpp index 7a528d3..9433cce 100644 --- a/src/gfx-beos/be-Window.cpp +++ b/src/gfx-beos/be-Window.cpp @@ -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) diff --git a/src/gfx-cocoa/cocoa_gfx.m b/src/gfx-cocoa/cocoa_gfx.m index 012e55f..ab318ef 100644 --- a/src/gfx-cocoa/cocoa_gfx.m +++ b/src/gfx-cocoa/cocoa_gfx.m @@ -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; diff --git a/src/gfx-curses/ncurses.c b/src/gfx-curses/ncurses.c index 6b64f15..1aa6b5d 100644 --- a/src/gfx-curses/ncurses.c +++ b/src/gfx-curses/ncurses.c @@ -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 = { diff --git a/src/gfx-sdl/sdlgfx.c b/src/gfx-sdl/sdlgfx.c index f9a43f2..e390616 100644 --- a/src/gfx-sdl/sdlgfx.c +++ b/src/gfx-sdl/sdlgfx.c @@ -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 #include void setupExtensions(void) @@ -65,7 +58,7 @@ int WIN32GFX_IsPicassoScreen (void); #include #include #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); diff --git a/src/gfx-svga/svga.c b/src/gfx-svga/svga.c index edd6ccb..0b0b70d 100644 --- a/src/gfx-svga/svga.c +++ b/src/gfx-svga/svga.c @@ -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]; diff --git a/src/gfx-x11/xwin.c b/src/gfx-x11/xwin.c index 77e2c8d..f9f4b78 100644 --- a/src/gfx-x11/xwin.c +++ b/src/gfx-x11/xwin.c @@ -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; diff --git a/src/gui-cocoa/cocoaui.m b/src/gui-cocoa/cocoaui.m index 27b8ee6..7da52b0 100644 --- a/src/gui-cocoa/cocoaui.m +++ b/src/gui-cocoa/cocoaui.m @@ -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; diff --git a/src/gui-muirexx/ami-gui.c b/src/gui-muirexx/ami-gui.c index 4701ddb..ebaa22d 100644 --- a/src/gui-muirexx/ami-gui.c +++ b/src/gui-muirexx/ami-gui.c @@ -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 } } diff --git a/src/gui-qt/puae_mainwindow.cpp b/src/gui-qt/puae_mainwindow.cpp index eeb953e..aa39831 100755 --- a/src/gui-qt/puae_mainwindow.cpp +++ b/src/gui-qt/puae_mainwindow.cpp @@ -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; diff --git a/src/hardfile.c b/src/hardfile.c index 206c79c..0e97468 100644 --- a/src/hardfile.c +++ b/src/hardfile.c @@ -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); diff --git a/src/hardfile_unix.c b/src/hardfile_unix.c index cbfebe6..db3d82f 100644 --- a/src/hardfile_unix.c +++ b/src/hardfile_unix.c @@ -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; diff --git a/src/include/a2091.h b/src/include/a2091.h index 4143c48..a222599 100644 --- a/src/include/a2091.h +++ b/src/include/a2091.h @@ -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 diff --git a/src/include/autoconf.h b/src/include/autoconf.h index 2b18216..4e54e98 100644 --- a/src/include/autoconf.h +++ b/src/include/autoconf.h @@ -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); diff --git a/src/include/blitter.h b/src/include/blitter.h index ba3fe1d..1f59d79 100644 --- a/src/include/blitter.h +++ b/src/include/blitter.h @@ -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 *); diff --git a/src/include/bsdsocket.h b/src/include/bsdsocket.h index c0f5c59..3f2eacb 100644 --- a/src/include/bsdsocket.h +++ b/src/include/bsdsocket.h @@ -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); diff --git a/src/include/cdtv.h b/src/include/cdtv.h index 635eae1..c63bf69 100644 --- a/src/include/cdtv.h +++ b/src/include/cdtv.h @@ -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*); diff --git a/src/include/cia.h b/src/include/cia.h index 261d8fe..7afad27 100644 --- a/src/include/cia.h +++ b/src/include/cia.h @@ -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); \ No newline at end of file diff --git a/src/include/cpummu.h b/src/include/cpummu.h index 48ce128..5fdcea8 100644 --- a/src/include/cpummu.h +++ b/src/include/cpummu.h @@ -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;waytag = 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;waytag = 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 */ diff --git a/src/include/custom.h b/src/include/custom.h index eab991a..dfac9f6 100644 --- a/src/include/custom.h +++ b/src/include/custom.h @@ -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); diff --git a/src/include/debug.h b/src/include/debug.h index 7d0e1ca..28ae995 100644 --- a/src/include/debug.h +++ b/src/include/debug.h @@ -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 *, ...); diff --git a/src/include/disk.h b/src/include/disk.h index baa1f75..45db754 100644 --- a/src/include/disk.h +++ b/src/include/disk.h @@ -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 diff --git a/src/include/drawing.h b/src/include/drawing.h index 75d03cd..404f05e 100644 --- a/src/include/drawing.h +++ b/src/include/drawing.h @@ -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; diff --git a/src/include/events.h b/src/include/events.h index 88c314c..74e122b 100644 --- a/src/include/events.h +++ b/src/include/events.h @@ -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 diff --git a/src/include/filesys.h b/src/include/filesys.h index c6cce60..6e2140e 100644 --- a/src/include/filesys.h +++ b/src/include/filesys.h @@ -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 diff --git a/src/include/fsdb.h b/src/include/fsdb.h index 5126d45..d813ae6 100644 --- a/src/include/fsdb.h +++ b/src/include/fsdb.h @@ -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; diff --git a/src/include/gayle.h b/src/include/gayle.h index 234781a..ef80b4c 100644 --- a/src/include/gayle.h +++ b/src/include/gayle.h @@ -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); diff --git a/src/include/gfxfilter.h b/src/include/gfxfilter.h index 9cb34ae..2e2bf04 100644 --- a/src/include/gfxfilter.h +++ b/src/include/gfxfilter.h @@ -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 diff --git a/src/include/gui.h b/src/include/gui.h index bc77256..0cd81ff 100644 --- a/src/include/gui.h +++ b/src/include/gui.h @@ -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; diff --git a/src/include/inputdevice.h b/src/include/inputdevice.h index 935e3e5..cadfeed 100644 --- a/src/include/inputdevice.h +++ b/src/include/inputdevice.h @@ -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 diff --git a/src/include/newcpu.h b/src/include/newcpu.h index 2856976..ec6ec6f 100644 --- a/src/include/newcpu.h +++ b/src/include/newcpu.h @@ -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); \ No newline at end of file +extern bool can_cpu_tracer (void); diff --git a/src/include/options.h b/src/include/options.h index 4e5bd1d..2796c02 100644 --- a/src/include/options.h +++ b/src/include/options.h @@ -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); diff --git a/src/include/picasso96.h b/src/include/picasso96.h index b7f1833..3818755 100644 --- a/src/include/picasso96.h +++ b/src/include/picasso96.h @@ -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 diff --git a/src/include/sana2.h b/src/include/sana2.h index 761ec07..76d9136 100644 --- a/src/include/sana2.h +++ b/src/include/sana2.h @@ -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 diff --git a/src/include/scsidev.h b/src/include/scsidev.h index 0a3c630..5efd2fa 100644 --- a/src/include/scsidev.h +++ b/src/include/scsidev.h @@ -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 diff --git a/src/include/serial.h b/src/include/serial.h index a65edc5..07b512a 100644 --- a/src/include/serial.h +++ b/src/include/serial.h @@ -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*); diff --git a/src/include/sleep.h b/src/include/sleep.h index 0f6b082..ec55104 100644 --- a/src/include/sleep.h +++ b/src/include/sleep.h @@ -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); diff --git a/src/include/sysdeps.h b/src/include/sysdeps.h index 478d655..757726f 100644 --- a/src/include/sysdeps.h +++ b/src/include/sysdeps.h @@ -212,61 +212,6 @@ struct utimbuf extern "C" { # endif -#if defined _WIN32 -#if defined __WATCOMC__ -#define O_NDELAY 0 -#include -#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 // 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 -#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 -#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); diff --git a/src/include/uaeserial.h b/src/include/uaeserial.h index e76ab44..370aabb 100644 --- a/src/include/uaeserial.h +++ b/src/include/uaeserial.h @@ -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 diff --git a/src/include/xwin.h b/src/include/xwin.h index 8e23962..03015ac 100644 --- a/src/include/xwin.h +++ b/src/include/xwin.h @@ -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); diff --git a/src/include/zfile.h b/src/include/zfile.h index 02c4308..bdaa08f 100644 --- a/src/include/zfile.h +++ b/src/include/zfile.h @@ -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); diff --git a/src/inputdevice.c b/src/inputdevice.c index 8ea124e..84856d9 100644 --- a/src/inputdevice.c +++ b/src/inputdevice.c @@ -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; diff --git a/src/inputrecord.c b/src/inputrecord.c index fa324af..89b23f6 100644 --- a/src/inputrecord.c +++ b/src/inputrecord.c @@ -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); } diff --git a/src/keymap/keymap.c b/src/keymap/keymap.c index 3906189..9d8706b 100644 --- a/src/keymap/keymap.c +++ b/src/keymap/keymap.c @@ -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) { diff --git a/src/keymap/keymap.h b/src/keymap/keymap.h index 221edce..e40e64a 100644 --- a/src/keymap/keymap.h +++ b/src/keymap/keymap.h @@ -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); diff --git a/src/main.c b/src/main.c index 81ee1fb..df89333 100644 --- a/src/main.c +++ b/src/main.c @@ -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; } diff --git a/src/memory.c b/src/memory.c index 40850a8..b1220eb 100644 --- a/src/memory.c +++ b/src/memory.c @@ -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; diff --git a/src/misc.c b/src/misc.c index 7421474..94ef77b 100644 --- a/src/misc.c +++ b/src/misc.c @@ -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 = ¤tmodestruct; + 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 = ¤tmodestruct; - -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; diff --git a/src/misc.h b/src/misc.h index e9d596b..400b709 100644 --- a/src/misc.h +++ b/src/misc.h @@ -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 */ diff --git a/src/newcpu.c b/src/newcpu.c index a65a0e0..c8fd507 100644 --- a/src/newcpu.c +++ b/src/newcpu.c @@ -22,6 +22,7 @@ #include "custom.h" #include "newcpu.h" #include "cpummu.h" +#include "cpummu030.h" #include "cpu_prefetch.h" #include "autoconf.h" #include "traps.h" @@ -38,6 +39,7 @@ #define f_out write_log #define console_out write_log +#define console_out_f write_log #ifdef JIT #include "compemu.h" #include @@ -83,9 +85,9 @@ extern uae_u32 get_fpsr (void); #define MC68060_PCR 0x04300000 #define MC68EC060_PCR 0x04310000 -static uae_u64 srp_030, crp_030; -static uae_u32 tt0_030, tt1_030, tc_030; -static uae_u16 mmusr_030; +static uae_u64 fake_srp_030, fake_crp_030; +static uae_u32 fake_tt0_030, fake_tt1_030, fake_tc_030; +static uae_u16 fake_mmusr_030; static struct cache020 caches020[CACHELINES020]; static struct cache030 icaches030[CACHELINES030]; @@ -179,6 +181,17 @@ uae_u32 (*x_get_byte)(uaecptr); void (*x_put_long)(uaecptr,uae_u32); void (*x_put_word)(uaecptr,uae_u32); void (*x_put_byte)(uaecptr,uae_u32); + +uae_u32 (*x_cp_next_iword)(void); +uae_u32 (*x_cp_next_ilong)(void); +uae_u32 (*x_cp_get_long)(uaecptr); +uae_u32 (*x_cp_get_word)(uaecptr); +uae_u32 (*x_cp_get_byte)(uaecptr); +void (*x_cp_put_long)(uaecptr,uae_u32); +void (*x_cp_put_word)(uaecptr,uae_u32); +void (*x_cp_put_byte)(uaecptr,uae_u32); +uae_u32 (REGPARAM3 *x_cp_get_disp_ea_020)(uae_u32 base, int idx) REGPARAM; + void (*x_do_cycles)(unsigned long); void (*x_do_cycles_pre)(unsigned long); void (*x_do_cycles_post)(unsigned long, uae_u32); @@ -676,19 +689,49 @@ static void do_cycles_ce_post (unsigned long cycles, uae_u32 v) static void set_x_funcs (void) { if (currprefs.mmu_model) { - x_prefetch = get_iword_mmu; - x_prefetch_long = get_ilong_mmu; - x_get_ilong = get_ilong_mmu; - x_get_iword = get_iword_mmu; - x_get_ibyte = get_ibyte_mmu; - x_next_iword = next_iword_mmu; - x_next_ilong = next_ilong_mmu; - x_put_long = put_long_mmu; - x_put_word = put_word_mmu; - x_put_byte = put_byte_mmu; - x_get_long = get_long_mmu; - x_get_word = get_word_mmu; - x_get_byte = get_byte_mmu; + if (currprefs.cpu_model == 68060) { + x_prefetch = get_iword_mmu060; + x_prefetch_long = get_ilong_mmu060; + x_get_ilong = get_ilong_mmu060; + x_get_iword = get_iword_mmu060; + x_get_ibyte = get_ibyte_mmu060; + x_next_iword = next_iword_mmu060; + x_next_ilong = next_ilong_mmu060; + x_put_long = put_long_mmu060; + x_put_word = put_word_mmu060; + x_put_byte = put_byte_mmu060; + x_get_long = get_long_mmu060; + x_get_word = get_word_mmu060; + x_get_byte = get_byte_mmu060; + } else if (currprefs.cpu_model == 68040) { + x_prefetch = get_iword_mmu040; + x_prefetch_long = get_ilong_mmu040; + x_get_ilong = get_ilong_mmu040; + x_get_iword = get_iword_mmu040; + x_get_ibyte = get_ibyte_mmu040; + x_next_iword = next_iword_mmu040; + x_next_ilong = next_ilong_mmu040; + x_put_long = put_long_mmu040; + x_put_word = put_word_mmu040; + x_put_byte = put_byte_mmu040; + x_get_long = get_long_mmu040; + x_get_word = get_word_mmu040; + x_get_byte = get_byte_mmu040; + } else { + x_prefetch = get_iword_mmu030; + x_prefetch_long = get_ilong_mmu030; + x_get_ilong = get_ilong_mmu030; + x_get_iword = get_iword_mmu030; + x_get_ibyte = get_ibyte_mmu030; + x_next_iword = next_iword_mmu030; + x_next_ilong = next_ilong_mmu030; + x_put_long = put_long_mmu030; + x_put_word = put_word_mmu030; + x_put_byte = put_byte_mmu030; + x_get_long = get_long_mmu030; + x_get_word = get_word_mmu030; + x_get_byte = get_byte_mmu030; + } x_do_cycles = do_cycles; x_do_cycles_pre = do_cycles; x_do_cycles_post = do_cycles_post; @@ -851,6 +894,28 @@ static void set_x_funcs (void) x_do_cycles_post = cputracefunc2_x_do_cycles_post; } } + + x_cp_put_long = x_put_long; + x_cp_put_word = x_put_word; + x_cp_put_byte = x_put_byte; + x_cp_get_long = x_get_long; + x_cp_get_word = x_get_word; + x_cp_get_byte = x_get_byte; + x_cp_next_iword = x_next_iword; + x_cp_next_ilong = x_next_ilong; + x_cp_get_disp_ea_020 = get_disp_ea_020; + + if (currprefs.mmu_model == 68030) { + x_cp_put_long = put_long_mmu030_state; + x_cp_put_word = put_word_mmu030_state; + x_cp_put_byte = put_byte_mmu030_state; + x_cp_get_long = get_long_mmu030_state; + x_cp_get_word = get_word_mmu030_state; + x_cp_get_byte = get_byte_mmu030_state; + x_cp_next_iword = next_iword_mmu030_state; + x_cp_next_ilong = next_ilong_mmu030_state; + x_cp_get_disp_ea_020 = get_disp_ea_020_mmu030; + } } bool can_cpu_tracer (void) @@ -985,7 +1050,7 @@ static void build_cpufunctbl (void) if (currprefs.cpu_cycle_exact) tbl = op_smalltbl_22_ff; if (currprefs.mmu_model) - tbl = op_smalltbl_31_ff; + tbl = op_smalltbl_33_ff; break; case 68040: lvl = 4; @@ -1000,6 +1065,8 @@ static void build_cpufunctbl (void) tbl = op_smalltbl_2_ff; if (currprefs.cpu_cycle_exact) tbl = op_smalltbl_24_ff; + if (currprefs.mmu_model) + tbl = op_smalltbl_32_ff; break; case 68020: lvl = 2; @@ -1106,13 +1173,6 @@ static void build_cpufunctbl (void) build_comp (); #endif set_cpu_caches (); -#ifdef MMU - if (currprefs.mmu_model) { - mmu_reset (); - mmu_set_tc (regs.tcr); - mmu_set_super (regs.s != 0); - } -#endif } void fill_prefetch (void) @@ -1194,7 +1254,7 @@ void check_prefs_changed_cpu (void) if (changed || currprefs.cpu_model != changed_prefs.cpu_model || currprefs.fpu_model != changed_prefs.fpu_model -#ifdef MMU +#ifdef MMUEMU || currprefs.mmu_model != changed_prefs.mmu_model #endif || currprefs.cpu_compatible != changed_prefs.cpu_compatible @@ -1312,14 +1372,14 @@ static long int m68kpc_offset; #define get_iword_1(o) get_word (regs.pc + (regs.pc_p - regs.pc_oldp) + (o)) #define get_ilong_1(o) get_long (regs.pc + (regs.pc_p - regs.pc_oldp) + (o)) -static uae_s32 ShowEA (void *f, uae_u16 opcode, int reg, amodes mode, wordsizes size, TCHAR *buf, uae_u32 *eaddr, int safemode) +static uaecptr ShowEA (void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsizes size, TCHAR *buf, uae_u32 *eaddr, int safemode) { uae_u16 dp; uae_s8 disp8; uae_s16 disp16; int r; uae_u32 dispreg; - uaecptr addr = 0; + uaecptr addr = pc; uae_s32 offset = 0; TCHAR buffer[80]; @@ -1345,7 +1405,7 @@ static uae_s32 ShowEA (void *f, uae_u16 opcode, int reg, amodes mode, wordsizes case Ad16: { TCHAR offtxt[80]; - disp16 = get_iword_1 (m68kpc_offset); m68kpc_offset += 2; + disp16 = get_word_debug (pc); pc += 2; if (disp16 < 0) _stprintf (offtxt, _T("-$%04x"), -disp16); else @@ -1355,7 +1415,7 @@ static uae_s32 ShowEA (void *f, uae_u16 opcode, int reg, amodes mode, wordsizes } break; case Ad8r: - dp = get_iword_1 (m68kpc_offset); m68kpc_offset += 2; + dp = get_word_debug (pc); pc += 2; disp8 = dp & 0xFF; r = (dp & 0x7000) >> 12; dispreg = dp & 0x8000 ? m68k_areg (regs, r) : m68k_dreg (regs, r); @@ -1369,15 +1429,15 @@ static uae_s32 ShowEA (void *f, uae_u16 opcode, int reg, amodes mode, wordsizes _stprintf (name, _T("A%d, "), reg); if (dp & 0x80) { base = 0; name[0] = 0; } if (dp & 0x40) dispreg = 0; - if ((dp & 0x30) == 0x20) { disp = (uae_s32)(uae_s16)get_iword_1 (m68kpc_offset); m68kpc_offset += 2; } - if ((dp & 0x30) == 0x30) { disp = get_ilong_1 (m68kpc_offset); m68kpc_offset += 4; } + if ((dp & 0x30) == 0x20) { disp = (uae_s32)(uae_s16)get_word_debug (pc); pc += 2; } + if ((dp & 0x30) == 0x30) { disp = get_long_debug (pc); pc += 4; } base += disp; - if ((dp & 0x3) == 0x2) { outer = (uae_s32)(uae_s16)get_iword_1 (m68kpc_offset); m68kpc_offset += 2; } - if ((dp & 0x3) == 0x3) { outer = get_ilong_1 (m68kpc_offset); m68kpc_offset += 4; } + if ((dp & 0x3) == 0x2) { outer = (uae_s32)(uae_s16)get_word_debug (pc); pc += 2; } + if ((dp & 0x3) == 0x3) { outer = get_long_debug (pc); pc += 4; } if (!(dp & 4)) base += dispreg; - if ((dp & 3) && !safemode) base = get_long (base); + if ((dp & 3) && !safemode) base = get_long_debug (base); if (dp & 4) base += dispreg; addr = base + outer; @@ -1395,14 +1455,12 @@ static uae_s32 ShowEA (void *f, uae_u16 opcode, int reg, amodes mode, wordsizes } break; case PC16: - addr = m68k_getpc () + m68kpc_offset; - disp16 = get_iword_1 (m68kpc_offset); m68kpc_offset += 2; + disp16 = get_word_debug (pc); pc += 2; addr += (uae_s16)disp16; _stprintf (buffer, _T("(PC,$%04x) == $%08lx"), disp16 & 0xffff, (unsigned long)addr); break; case PC8r: - addr = m68k_getpc () + m68kpc_offset; - dp = get_iword_1 (m68kpc_offset); m68kpc_offset += 2; + dp = get_word_debug (pc); pc += 2; disp8 = dp & 0xFF; r = (dp & 0x7000) >> 12; dispreg = dp & 0x8000 ? m68k_areg (regs, r) : m68k_dreg (regs, r); @@ -1416,15 +1474,15 @@ static uae_s32 ShowEA (void *f, uae_u16 opcode, int reg, amodes mode, wordsizes _stprintf (name, _T("PC, ")); if (dp & 0x80) { base = 0; name[0] = 0; } if (dp & 0x40) dispreg = 0; - if ((dp & 0x30) == 0x20) { disp = (uae_s32)(uae_s16)get_iword_1 (m68kpc_offset); m68kpc_offset += 2; } - if ((dp & 0x30) == 0x30) { disp = get_ilong_1 (m68kpc_offset); m68kpc_offset += 4; } + if ((dp & 0x30) == 0x20) { disp = (uae_s32)(uae_s16)get_word_debug (pc); pc += 2; } + if ((dp & 0x30) == 0x30) { disp = get_long_debug (pc); pc += 4; } base += disp; - if ((dp & 0x3) == 0x2) { outer = (uae_s32)(uae_s16)get_iword_1 (m68kpc_offset); m68kpc_offset += 2; } - if ((dp & 0x3) == 0x3) { outer = get_ilong_1 (m68kpc_offset); m68kpc_offset += 4; } + if ((dp & 0x3) == 0x2) { outer = (uae_s32)(uae_s16)get_word_debug (pc); pc += 2; } + if ((dp & 0x3) == 0x3) { outer = get_long_debug (pc); pc += 4; } if (!(dp & 4)) base += dispreg; - if ((dp & 3) && !safemode) base = get_long (base); + if ((dp & 3) && !safemode) base = get_long_debug (base); if (dp & 4) base += dispreg; addr = base + outer; @@ -1441,52 +1499,56 @@ static uae_s32 ShowEA (void *f, uae_u16 opcode, int reg, amodes mode, wordsizes } break; case absw: - addr = (uae_s32)(uae_s16)get_iword_1 (m68kpc_offset); + addr = (uae_s32)(uae_s16)get_word_debug (pc); _stprintf (buffer, _T("$%08lx"), (unsigned long)addr); - m68kpc_offset += 2; + pc += 2; break; case absl: - addr = get_ilong_1 (m68kpc_offset); + addr = get_long_debug (pc); _stprintf (buffer, _T("$%08lx"), (unsigned long)addr); - m68kpc_offset += 4; + pc += 4; break; case imm: switch (size){ case sz_byte: - _stprintf (buffer, _T("#$%02x"), (unsigned int)(get_iword_1 (m68kpc_offset) & 0xff)); - m68kpc_offset += 2; + _stprintf (buffer, _T("#$%02x"), (unsigned int)(get_word_debug (pc) & 0xff)); + pc += 2; break; case sz_word: - _stprintf (buffer, _T("#$%04x"), (unsigned int)(get_iword_1 (m68kpc_offset) & 0xffff)); - m68kpc_offset += 2; + _stprintf (buffer, _T("#$%04x"), (unsigned int)(get_word_debug (pc) & 0xffff)); + pc += 2; break; case sz_long: - _stprintf (buffer, _T("#$%08lx"), (unsigned long)(get_ilong_1 (m68kpc_offset))); - m68kpc_offset += 4; + _stprintf (buffer, _T("#$%08lx"), (unsigned long)(get_long_debug (pc))); + pc += 4; break; default: break; } break; case imm0: - offset = (uae_s32)(uae_s8)get_iword_1 (m68kpc_offset); - m68kpc_offset += 2; + offset = (uae_s32)(uae_s8)get_word_debug (pc); _stprintf (buffer, _T("#$%02x"), (unsigned int)(offset & 0xff)); + addr = pc + 2 + offset; + pc += 2; break; case imm1: - offset = (uae_s32)(uae_s16)get_iword_1 (m68kpc_offset); - m68kpc_offset += 2; + offset = (uae_s32)(uae_s16)get_word_debug (pc); buffer[0] = 0; _stprintf (buffer, _T("#$%04x"), (unsigned int)(offset & 0xffff)); + addr = pc + offset; + pc += 2; break; case imm2: - offset = (uae_s32)get_ilong_1 (m68kpc_offset); - m68kpc_offset += 4; + offset = (uae_s32)get_long_debug (pc); _stprintf (buffer, _T("#$%08lx"), (unsigned long)offset); + addr = pc + offset; + pc += 4; break; case immi: offset = (uae_s32)(uae_s8)(reg & 0xff); _stprintf (buffer, _T("#$%08lx"), (unsigned long)offset); + addr = pc + offset; break; default: break; @@ -1497,7 +1559,7 @@ static uae_s32 ShowEA (void *f, uae_u16 opcode, int reg, amodes mode, wordsizes _tcscat (buf, buffer); if (eaddr) *eaddr = addr; - return offset; + return pc; } #if 0 @@ -1722,33 +1784,33 @@ uae_u32 REGPARAM2 x_get_bitfield (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, mask = 0xffffffffu << (32 - width); switch ((offset + width + 7) >> 3) { case 1: - tmp = x_get_byte (src); + tmp = x_cp_get_byte (src); res = tmp << (24 + offset); bdata[0] = tmp & ~(mask >> (24 + offset)); break; case 2: - tmp = x_get_word (src); + tmp = x_cp_get_word (src); res = tmp << (16 + offset); bdata[0] = tmp & ~(mask >> (16 + offset)); break; case 3: - tmp = x_get_word (src); + tmp = x_cp_get_word (src); res = tmp << (16 + offset); bdata[0] = tmp & ~(mask >> (16 + offset)); - tmp = x_get_byte (src + 2); + tmp = x_cp_get_byte (src + 2); res |= tmp << (8 + offset); bdata[1] = tmp & ~(mask >> (8 + offset)); break; case 4: - tmp = x_get_long (src); + tmp = x_cp_get_long (src); res = tmp << offset; bdata[0] = tmp & ~(mask >> offset); break; case 5: - tmp = x_get_long (src); + tmp = x_cp_get_long (src); res = tmp << offset; bdata[0] = tmp & ~(mask >> offset); - tmp = x_get_byte (src + 4); + tmp = x_cp_get_byte (src + 4); res |= tmp >> (8 - offset); bdata[1] = tmp & ~(mask << (8 - offset)); break; @@ -1766,21 +1828,21 @@ void REGPARAM2 x_put_bitfield (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s offset = (offset & 7) + width; switch ((offset + 7) >> 3) { case 1: - x_put_byte (dst, bdata[0] | (val << (8 - offset))); + x_cp_put_byte (dst, bdata[0] | (val << (8 - offset))); break; case 2: - x_put_word (dst, bdata[0] | (val << (16 - offset))); + x_cp_put_word (dst, bdata[0] | (val << (16 - offset))); break; case 3: - x_put_word (dst, bdata[0] | (val >> (offset - 16))); - x_put_byte (dst + 2, bdata[1] | (val << (24 - offset))); + x_cp_put_word (dst, bdata[0] | (val >> (offset - 16))); + x_cp_put_byte (dst + 2, bdata[1] | (val << (24 - offset))); break; case 4: - x_put_long (dst, bdata[0] | (val << (32 - offset))); + x_cp_put_long (dst, bdata[0] | (val << (32 - offset))); break; case 5: - x_put_long (dst, bdata[0] | (val >> (offset - 32))); - x_put_byte (dst + 4, bdata[1] | (val << (40 - offset))); + x_cp_put_long (dst, bdata[0] | (val >> (offset - 32))); + x_cp_put_byte (dst + 4, bdata[1] | (val << (40 - offset))); break; default: write_log (_T("x_put_bitfield() can't happen %d\n"), (offset + 7) >> 3); @@ -1788,8 +1850,9 @@ void REGPARAM2 x_put_bitfield (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s } } -uae_u32 REGPARAM2 get_disp_ea_020 (uae_u32 base, uae_u32 dp) +uae_u32 REGPARAM2 get_disp_ea_020 (uae_u32 base, int idx) { + uae_u16 dp = next_iword (); int reg = (dp >> 12) & 15; uae_s32 regd = regs.regs[reg]; if ((dp & 0x800) == 0) @@ -1823,8 +1886,9 @@ uae_u32 REGPARAM2 get_disp_ea_020 (uae_u32 base, uae_u32 dp) } } -uae_u32 REGPARAM2 x_get_disp_ea_020 (uae_u32 base, uae_u32 dp) +uae_u32 REGPARAM2 x_get_disp_ea_020 (uae_u32 base, int idx) { + uae_u16 dp = x_next_iword (); int reg = (dp >> 12) & 15; int cycles = 0; uae_u32 v; @@ -1879,8 +1943,10 @@ uae_u32 REGPARAM2 x_get_disp_ea_020 (uae_u32 base, uae_u32 dp) return v; } -uae_u32 REGPARAM2 x_get_disp_ea_ce020 (uae_u32 base, uae_u32 dp) + +uae_u32 REGPARAM2 x_get_disp_ea_ce020 (uae_u32 base, int idx) { + uae_u16 dp = next_iword_020ce (); int reg = (dp >> 12) & 15; int cycles = 0; uae_u32 v; @@ -1901,7 +1967,7 @@ uae_u32 REGPARAM2 x_get_disp_ea_ce020 (uae_u32 base, uae_u32 dp) cycles++; } if ((dp & 0x30) == 0x30) { - base += x_next_ilong (); + base += next_ilong_020ce (); cycles++; } @@ -2018,7 +2084,7 @@ void REGPARAM2 MakeFromSR (void) } } } -#ifdef MMU +#ifdef MMUEMU if (currprefs.mmu_model) mmu_set_super (regs.s != 0); #endif @@ -2050,7 +2116,7 @@ static void exception_debug (int nr) #ifdef DEBUGGER if (!exception_debugging) return; - console_out (_T("Exception %d, PC=%08X\n"), nr, M68K_GETPC); + console_out_f (_T("Exception %d, PC=%08X\n"), nr, M68K_GETPC); #endif } @@ -2232,119 +2298,177 @@ static uae_u32 exception_pc (int nr) return regs.instruction_pc; } -static void Exception_mmu (int nr) + +static void Exception_build_stack_frame (uae_u32 oldpc, uae_u32 currpc, uae_u32 ssw, int nr, int format) { - uae_u32 newpc; - int sv = regs.s; - int pc = exception_pc (nr); int i; - exception_debug (nr); - MakeSR (); - - if (!regs.s) { - regs.usp = m68k_areg (regs, 7); - if (currprefs.cpu_model >= 68020) - m68k_areg (regs, 7) = regs.m ? regs.msp : regs.isp; - else - m68k_areg (regs, 7) = regs.isp; - regs.s = 1; - mmu_set_super (1); +#if 0 + if (nr < 24 || nr > 31) { // do not print debugging for interrupts + write_log(_T("Building exception stack frame (format %X)\n"), format); } - if (nr == 2) { -// write_log (_T("%08x %08x %08x\n"), currpc, oldpc, regs.mmu_fault_addr); -// if (currpc == 0x0013b5e2) -// activate_debugger (); - // bus error - for (i = 0 ; i < 7 ; i++) { +#endif + + switch (format) { + case 0x0: // four word stack frame + case 0x1: // throwaway four word stack frame + break; + case 0x2: // six word stack frame + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), oldpc); + break; + case 0x7: // access error stack frame (68040) + for (i = 0 ; i < 7 ; i++) { + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), 0); + } + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), regs.wb3_data); + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), regs.mmu_fault_addr); + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), regs.mmu_fault_addr); + m68k_areg (regs, 7) -= 2; + x_put_word (m68k_areg (regs, 7), 0); + m68k_areg (regs, 7) -= 2; + x_put_word (m68k_areg (regs, 7), 0); + m68k_areg (regs, 7) -= 2; + x_put_word (m68k_areg (regs, 7), regs.wb3_status); + regs.wb3_status = 0; + m68k_areg (regs, 7) -= 2; + x_put_word (m68k_areg (regs, 7), ssw); + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), regs.mmu_fault_addr); + break; + case 0x9: // coprocessor mid-instruction stack frame (68020, 68030) + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), 0); + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), 0); + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), oldpc); + break; + case 0x3: // floating point post-instruction stack frame (68040) + case 0x8: // bus and address error stack frame (68010) + write_log(_T("Exception stack frame format %X not implemented\n"), format); + return; + case 0x4: // floating point unimplemented stack frame (68LC040, 68EC040) + // or 68060 bus access fault stack frame + if (currprefs.cpu_model == 68040) { + // this is actually created in fpp.c + write_log(_T("Exception stack frame format %X not implemented\n"), format); + return; + } + // 68060 bus fault m68k_areg (regs, 7) -= 4; - put_long_mmu (m68k_areg (regs, 7), 0); - } - m68k_areg (regs, 7) -= 4; - put_long_mmu (m68k_areg (regs, 7), regs.wb3_data); - m68k_areg (regs, 7) -= 4; - put_long_mmu (m68k_areg (regs, 7), regs.mmu_fault_addr); - m68k_areg (regs, 7) -= 4; - put_long_mmu (m68k_areg (regs, 7), regs.mmu_fault_addr); - m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), 0); - m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), 0); - m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), regs.wb3_status); - regs.wb3_status = 0; - m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), regs.mmu_ssw); - m68k_areg (regs, 7) -= 4; - put_long_mmu (m68k_areg (regs, 7), regs.mmu_fault_addr); - - m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), 0x7000 + nr * 4); - m68k_areg (regs, 7) -= 4; - put_long_mmu (m68k_areg (regs, 7), regs.instruction_pc); - m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), regs.sr); - goto kludge_me_do; - - } else if (nr == 3) { - - // address error - uae_u16 ssw = (sv ? 4 : 0) | (last_instructionaccess_for_exception_3 ? 2 : 1); - ssw |= last_writeaccess_for_exception_3 ? 0 : 0x40; - ssw |= 0x20; - for (i = 0 ; i < 36; i++) { + x_put_long (m68k_areg (regs, 7), regs.mmu_fslw); + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), regs.mmu_fault_addr); + break; + case 0xB: // long bus cycle fault stack frame (68020, 68030) + // store state information to internal register space + for (i = 0; i < mmu030_idx + 1; i++) { + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), mmu030_ad[i].val); + } + while (i < 9) { + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), 0); + i++; + } + // version & internal information (We store index here) m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), 0); - } - m68k_areg (regs, 7) -= 4; - put_long_mmu (m68k_areg (regs, 7), last_fault_for_exception_3); - m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), 0); - m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), 0); - m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), 0); - m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), ssw); - m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), 0xb000 + nr * 4); + x_put_word (m68k_areg (regs, 7), mmu030_idx); + // 3* internal registers + m68k_areg (regs, 7) -= 2; + x_put_word (m68k_areg (regs, 7), mmu030_state[2]); + m68k_areg (regs, 7) -= 2; + x_put_word (m68k_areg (regs, 7), mmu030_state[1]); + m68k_areg (regs, 7) -= 2; + x_put_word (m68k_areg (regs, 7), mmu030_state[0]); + // data input buffer = fault address + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), regs.mmu_fault_addr); + // 2xinternal + m68k_areg (regs, 7) -= 2; + x_put_word (m68k_areg (regs, 7), 0); + m68k_areg (regs, 7) -= 2; + x_put_word (m68k_areg (regs, 7), 0); + // stage b address + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), mm030_stageb_address); + // 2xinternal + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), mmu030_disp_store[1]); + /* fall through */ + case 0xA: // short bus cycle fault stack frame (68020, 68030) + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), mmu030_disp_store[0]); + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), mmu030_ad[mmu030_idx].val); // Data output buffer = value that was going to be written + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), mmu030_opcode); // Internal register (opcode storage) + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), regs.mmu_fault_addr); + m68k_areg (regs, 7) -= 2; + x_put_word (m68k_areg (regs, 7), 0); // Instr. pipe stage B + m68k_areg (regs, 7) -= 2; + x_put_word (m68k_areg (regs, 7), 0); // Instr. pipe stage C + m68k_areg (regs, 7) -= 2; + x_put_word (m68k_areg (regs, 7), ssw); + m68k_areg (regs, 7) -= 2; + x_put_word (m68k_areg (regs, 7), 0); // Internal register + break; + default: + write_log(_T("Unknown exception stack frame format: %X\n"), format); + return; + } + m68k_areg (regs, 7) -= 2; + x_put_word (m68k_areg (regs, 7), (format<<12) | (nr * 4)); + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), currpc); + m68k_areg (regs, 7) -= 2; + x_put_word (m68k_areg (regs, 7), regs.sr); +} - } else if (nr ==5 || nr == 6 || nr == 7 || nr == 9) { - m68k_areg (regs, 7) -= 4; - put_long_mmu (m68k_areg (regs, 7), regs.instruction_pc); - m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), 0x2000 + nr * 4); +// 68030 MMU +static void Exception_mmu030 (int nr, uaecptr oldpc) +{ + uae_u32 currpc = m68k_getpc(), newpc; + int sv = regs.s; + + exception_debug(nr); + MakeSR(); + + if (!regs.s) { + regs.usp = m68k_areg(regs, 7); + m68k_areg(regs, 7) = regs.m ? regs.msp : regs.isp; + regs.s = 1; + mmu_set_super(1); + } + +#if 0 + if (nr < 24 || nr > 31) { // do not print debugging for interrupts + write_log (_T("Exception_mmu030: Exception %i: %08x %08x %08x\n"), + nr, currpc, oldpc, regs.mmu_fault_addr); + } +#endif - } else if (regs.m && nr >= 24 && nr < 32) { /* M + Interrupt */ - - m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), nr * 4); - m68k_areg (regs, 7) -= 4; - put_long_mmu (m68k_areg (regs, 7), regs.instruction_pc); - m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), regs.sr); - regs.sr |= (1 << 13); - regs.msp = m68k_areg (regs, 7); - m68k_areg (regs, 7) = regs.isp; - m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), 0x1000 + nr * 4); - - } else { - - m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), nr * 4); - - } - m68k_areg (regs, 7) -= 4; - put_long_mmu (m68k_areg (regs, 7), pc); - m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), regs.sr); -kludge_me_do: - newpc = get_long_mmu (regs.vbr + 4 * nr); + if (regs.m && nr >= 24 && nr < 32) { /* M + Interrupt */ + Exception_build_stack_frame(oldpc, currpc, regs.mmu_ssw, nr, 0x1); + } else if (nr ==5 || nr == 6 || nr == 7 || nr == 9 || nr == 56) { + Exception_build_stack_frame(oldpc, currpc, regs.mmu_ssw, nr, 0x2); + } else if (nr == 2 || nr == 3) { + Exception_build_stack_frame(oldpc, currpc, regs.mmu_ssw, nr, 0xB); + } else { + Exception_build_stack_frame(oldpc, currpc, regs.mmu_ssw, nr, 0x0); + } + + newpc = x_get_long (regs.vbr + 4 * nr); if (newpc & 1) { if (nr == 2 || nr == 3) - uae_reset (1, 0); /* there is nothing else we can do.. */ + uae_reset (1, 0); /* there is nothing else we can do.. */ else exception3 (regs.ir, newpc); return; @@ -2357,6 +2481,67 @@ kludge_me_do: exception_trace (nr); } +// 68040/060 MMU +static void Exception_mmu (int nr, uaecptr oldpc) +{ + uae_u32 currpc = m68k_getpc (), newpc; + int sv = regs.s; + + exception_debug (nr); + MakeSR (); + + if (!regs.s) { + regs.usp = m68k_areg (regs, 7); + if (currprefs.cpu_model == 68060) { + m68k_areg (regs, 7) = regs.isp; + if (nr >= 24 && nr < 32) + regs.m = 0; + } else if (currprefs.cpu_model >= 68020) { + m68k_areg (regs, 7) = regs.m ? regs.msp : regs.isp; + } else { + m68k_areg (regs, 7) = regs.isp; + } + regs.s = 1; + mmu_set_super (1); + } + + if (nr == 2) { // bus error + //write_log (_T("Exception_mmu %08x %08x %08x\n"), currpc, oldpc, regs.mmu_fault_addr); + if (currprefs.mmu_model == 68040) + Exception_build_stack_frame(oldpc, currpc, regs.mmu_ssw, nr, 0x7); + else + Exception_build_stack_frame(oldpc, currpc, regs.mmu_fslw, nr, 0x4); + } else if (nr == 3) { // address error + uae_u16 ssw = (sv ? 4 : 0) | (last_instructionaccess_for_exception_3 ? 2 : 1); + ssw |= last_writeaccess_for_exception_3 ? 0 : 0x40; + ssw |= 0x20; + Exception_build_stack_frame(oldpc, currpc, ssw, nr, 0xB); + write_log (_T("Exception %d (%x) at %x -> %x! %s at %d\n"), nr, oldpc, currpc, get_long (regs.vbr + 4*nr),__FILE__,__LINE__); + } else if (nr ==5 || nr == 6 || nr == 7 || nr == 9) { + Exception_build_stack_frame(oldpc, currpc, regs.mmu_ssw, nr, 0x2); + } else if (regs.m && nr >= 24 && nr < 32) { /* M + Interrupt */ + Exception_build_stack_frame(oldpc, currpc, regs.mmu_ssw, nr, 0x1); + } else { + Exception_build_stack_frame(oldpc, currpc, regs.mmu_ssw, nr, 0x0); + } + + newpc = x_get_long (regs.vbr + 4 * nr); + if (newpc & 1) { + if (nr == 2 || nr == 3) + uae_reset (1, 0); /* there is nothing else we can do.. */ + else + exception3 (regs.ir, newpc); + return; + } + m68k_setpc (newpc); +#ifdef JIT + set_special (SPCFLAG_END_COMPILE); +#endif + fill_prefetch (); + exception_trace (nr); +} + + static void Exception_normal (int nr) { uae_u32 currpc, newpc; @@ -2370,12 +2555,17 @@ static void Exception_normal (int nr) if (!regs.s) { regs.usp = m68k_areg (regs, 7); - if (currprefs.cpu_model >= 68020) - m68k_areg (regs, 7) = regs.m ? regs.msp : regs.isp; - else + if (currprefs.cpu_model == 68060) { m68k_areg (regs, 7) = regs.isp; + if (nr >= 24 && nr < 32) + regs.m = 0; + } else if (currprefs.cpu_model >= 68020) { + m68k_areg (regs, 7) = regs.m ? regs.msp : regs.isp; + } else { + m68k_areg (regs, 7) = regs.isp; + } regs.s = 1; -#ifdef MMU +#ifdef MMUEMU if (currprefs.mmu_model) mmu_set_super (regs.s != 0); #endif @@ -2562,10 +2752,16 @@ void REGPARAM2 Exception (int nr) Exception_ce000 (nr); else #endif - if (currprefs.mmu_model) - Exception_mmu (nr); +#ifdef MMUEMU + if (currprefs.mmu_model) { + if (currprefs.cpu_model == 68030) + Exception_mmu030 (nr, m68k_getpc ()); else + Exception_mmu (nr, m68k_getpc ()); + } else { Exception_normal (nr); + } +#endif if (debug_illegal && !in_rom (M68K_GETPC)) { int v = nr; @@ -2677,7 +2873,7 @@ int m68k_move2c (int regno, uae_u32 *regp) /* 68040/060 only */ case 3: regs.tcr = *regp & (currprefs.cpu_model == 68060 ? 0xfffe : 0xc000); -#ifdef MMU +#ifdef MMUEMU if (currprefs.mmu_model) mmu_set_tc (regs.tcr); #endif @@ -3086,26 +3282,32 @@ void m68k_reset (int hardreset) set_cpu_caches (); } -#ifdef MMU +#ifdef MMUEMU mmufixup[0].reg = -1; mmufixup[1].reg = -1; - if (currprefs.mmu_model) { + if (currprefs.mmu_model >= 68040) { mmu_reset (); mmu_set_tc (regs.tcr); mmu_set_super (regs.s != 0); + } else if (currprefs.mmu_model == 68030) { + mmu030_reset (hardreset || regs.halted); + } else { + a3000_fakekick (0); + /* only (E)nable bit is zeroed when CPU is reset, A3000 SuperKickstart expects this */ + fake_tc_030 &= ~0x80000000; + fake_tt0_030 &= ~0x80000000; + fake_tt1_030 &= ~0x80000000; + if (hardreset || regs.halted) { + fake_srp_030 = fake_crp_030 = 0; + fake_tt0_030 = fake_tt1_030 = fake_tc_030 = 0; + } + fake_mmusr_030 = 0; } #endif - a3000_fakekick (0); - /* only (E)nable bit is zeroed when CPU is reset, A3000 SuperKickstart expects this */ - tc_030 &= ~0x80000000; - tt0_030 &= ~0x80000000; - tt1_030 &= ~0x80000000; - if (hardreset) { - srp_030 = crp_030 = 0; - tt0_030 = tt1_030 = tc_030 = 0; - } - mmusr_030 = 0; + regs.halted = 0; + gui_data.cpu_halted = false; + gui_led (LED_CPU, 0); /* 68060 FPU is not compatible with 68040, * 68060 accelerators' boot ROM disables the FPU @@ -3194,14 +3396,14 @@ uae_u32 REGPARAM2 op_illg (uae_u32 opcode) static TCHAR *mmu30regs[] = { _T("TCR"), _T(""), _T("SRP"), _T("CRP"), _T(""), _T(""), _T(""), _T("") }; -static void mmu_op30_pmove (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr extra) +static void mmu_op30fake_pmove (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr extra) { int mode = (opcode >> 3) & 7; int preg = (next >> 10) & 31; int rw = (next >> 9) & 1; int fd = (next >> 8) & 1; TCHAR *reg = NULL; - uae_u32 otc = tc_030; + uae_u32 otc = fake_tc_030; int siz; // Dn, An, (An)+, -(An), abs and indirect @@ -3216,55 +3418,55 @@ static void mmu_op30_pmove (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr ex reg = _T("TC"); siz = 4; if (rw) - x_put_long (extra, tc_030); + x_put_long (extra, fake_tc_030); else - tc_030 = x_get_long (extra); + fake_tc_030 = x_get_long (extra); break; case 0x12: // SRP reg = _T("SRP"); siz = 8; if (rw) { - x_put_long (extra, srp_030 >> 32); - x_put_long (extra + 4, srp_030); + x_put_long (extra, fake_srp_030 >> 32); + x_put_long (extra + 4, fake_srp_030); } else { - srp_030 = (uae_u64)x_get_long (extra) << 32; - srp_030 |= x_get_long (extra + 4); + fake_srp_030 = (uae_u64)x_get_long (extra) << 32; + fake_srp_030 |= x_get_long (extra + 4); } break; case 0x13: // CRP reg = _T("CRP"); siz = 8; if (rw) { - x_put_long (extra, crp_030 >> 32); - x_put_long (extra + 4, crp_030); + x_put_long (extra, fake_crp_030 >> 32); + x_put_long (extra + 4, fake_crp_030); } else { - crp_030 = (uae_u64)x_get_long (extra) << 32; - crp_030 |= x_get_long (extra + 4); + fake_crp_030 = (uae_u64)x_get_long (extra) << 32; + fake_crp_030 |= x_get_long (extra + 4); } break; case 0x18: // MMUSR reg = _T("MMUSR"); siz = 2; if (rw) - x_put_word (extra, mmusr_030); + x_put_word (extra, fake_mmusr_030); else - mmusr_030 = x_get_word (extra); + fake_mmusr_030 = x_get_word (extra); break; case 0x02: // TT0 reg = _T("TT0"); siz = 4; if (rw) - x_put_long (extra, tt0_030); + x_put_long (extra, fake_tt0_030); else - tt0_030 = x_get_long (extra); + fake_tt0_030 = x_get_long (extra); break; case 0x03: // TT1 reg = _T("TT1"); siz = 4; if (rw) - x_put_long (extra, tt1_030); + x_put_long (extra, fake_tt1_030); else - tt1_030 = x_get_long (extra); + fake_tt1_030 = x_get_long (extra); break; } @@ -3296,13 +3498,13 @@ static void mmu_op30_pmove (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr ex } #endif if (currprefs.cs_mbdmac == 1 && currprefs.mbresmem_low_size > 0) { - if (otc != tc_030) { - a3000_fakekick (tc_030 & 0x80000000); + if (otc != fake_tc_030) { + a3000_fakekick (fake_tc_030 & 0x80000000); } } } -static void mmu_op30_ptest (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr extra) +static void mmu_op30fake_ptest (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr extra) { #if MMUOP_DEBUG > 0 TCHAR tmp[10]; @@ -3313,10 +3515,10 @@ static void mmu_op30_ptest (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr ex write_log (_T("PTEST%c %02X,%08X,#%X%s PC=%08X\n"), ((next >> 9) & 1) ? 'W' : 'R', (next & 15), extra, (next >> 10) & 7, tmp, pc); #endif - mmusr_030 = 0; + fake_mmusr_030 = 0; } -static void mmu_op30_pflush (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr extra) +static void mmu_op30fake_pflush (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr extra) { int mode = (opcode >> 3) & 7; int reg = opcode & 7; @@ -3350,8 +3552,21 @@ static void mmu_op30_pflush (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr e #endif } +// 68030 (68851) MMU instructions only void mmu_op30 (uaecptr pc, uae_u32 opcode, uae_u16 extra, uaecptr extraa) { + if (currprefs.mmu_model) { + if (extra & 0x8000) + mmu_op30_ptest (pc, opcode, extra, extraa); + else if ((extra&0xE000)==0x2000 && (extra & 0x1C00)) + mmu_op30_pflush (pc, opcode, extra, extraa); + else if ((extra&0xE000)==0x2000 && !(extra & 0x1C00)) + mmu_op30_pload (pc, opcode, extra, extraa); + else + mmu_op30_pmove (pc, opcode, extra, extraa); + return; + } + int type = extra >> 13; switch (type) @@ -3359,13 +3574,13 @@ void mmu_op30 (uaecptr pc, uae_u32 opcode, uae_u16 extra, uaecptr extraa) case 0: case 2: case 3: - mmu_op30_pmove (pc, opcode, extra, extraa); + mmu_op30fake_pmove (pc, opcode, extra, extraa); break; case 1: - mmu_op30_pflush (pc, opcode, extra, extraa); + mmu_op30fake_pflush (pc, opcode, extra, extraa); break; case 4: - mmu_op30_ptest (pc, opcode, extra, extraa); + mmu_op30fake_ptest (pc, opcode, extra, extraa); break; default: op_illg (opcode); @@ -3373,10 +3588,11 @@ void mmu_op30 (uaecptr pc, uae_u32 opcode, uae_u16 extra, uaecptr extraa) } } +// 68040+ MMU instructions only void mmu_op (uae_u32 opcode, uae_u32 extra) { -#ifdef MMU - if (currprefs.cpu_model) { +#ifdef MMUEMU + if (currprefs.mmu_model) { mmu_op_real (opcode, extra); return; } @@ -4045,10 +4261,78 @@ static void opcodedebug (uae_u32 pc, uae_u16 opcode, bool full) m68k_disasm_2 (buf, sizeof buf / sizeof (TCHAR), addr, NULL, 1, NULL, NULL, 0); write_log (_T("%s\n"), buf); if (full) - m68k_dumpstate (stdout, NULL); + m68k_dumpstate (NULL); } } +void cpu_halt (int id) +{ + if (!regs.halted) { + write_log (_T("CPU halted: reason = %d\n"), id); + regs.halted = id; + gui_data.cpu_halted = true; + gui_led (LED_CPU, 0); + } + while (regs.halted) { + do_cycles (8 * CYCLE_UNIT); + cpu_cycles = adjust_cycles (cpu_cycles); + if (regs.spcflags) { + if (do_specialties (cpu_cycles)) + return; + } + } +} + +#ifdef CPUEMU_33 + +/* MMU 68060 */ +static void m68k_run_mmu060 (void) +{ + uae_u16 opcode; + uaecptr pc; +retry: + TRY (prb) { + for (;;) { + pc = regs.instruction_pc = m68k_getpc (); + mmu060_state = 0; + opcode = x_prefetch (0); + mmu060_state = 1; + count_instr (opcode); + do_cycles (cpu_cycles); + cpu_cycles = (*cpufunctbl[opcode])(opcode); + cpu_cycles = adjust_cycles (cpu_cycles); + if (regs.spcflags) { + if (do_specialties (cpu_cycles)) + return; + } + } + } CATCH (prb) { + + m68k_setpc (regs.instruction_pc); + + if (mmufixup[0].reg >= 0) { + m68k_areg (regs, mmufixup[0].reg) = mmufixup[0].value; + mmufixup[0].reg = -1; + } + if (mmufixup[1].reg >= 0) { + m68k_areg (regs, mmufixup[1].reg) = mmufixup[1].value; + mmufixup[1].reg = -1; + } + + //activate_debugger (); + TRY (prb2) { + Exception (0); //prb + } CATCH (prb2) { + cpu_halt (1); + return; + } + goto retry; + } + +} + +#endif + #ifdef CPUEMU_31 /* Aranym MMU 68040 */ @@ -4056,45 +4340,12 @@ static void m68k_run_mmu040 (void) { uae_u16 opcode; uaecptr pc; + retry: TRY (prb) { for (;;) { pc = regs.instruction_pc = m68k_getpc (); -#if 0 - if (regs.regs[8+1] == 0x5b) { - static int cnt = 6; - cnt--; - if (cnt > 0) - activate_debugger(); - } -#endif -#if 0 - static int done; - if (pc == 0x16AF94) { -// write_log (_T("D0=%d A7=%08x\n"), regs.regs[0], regs.regs[15]); - if (regs.regs[0] == 360) { - done = 1; - activate_debugger (); - } - } -/* - if (pc == 0x16B01A) { - write_log (_T("-> ERR\n")); - } - if (pc == 0x16B018) { - write_log (_T("->\n")); - } -*/ - if (pc == 0x17967C || pc == 0x13b5e2 - 4) { - if (done) { - write_log (_T("*\n")); - mmu_dump_tables (); - activate_debugger (); - } - } -#endif - - opcode = get_iword_mmu (0); + opcode = x_prefetch (0); count_instr (opcode); do_cycles (cpu_cycles); cpu_cycles = (*cpufunctbl[opcode])(opcode); @@ -4106,13 +4357,6 @@ retry: } } CATCH (prb) { - if (currprefs.mmu_model == 68060) { - regs.instruction_pc = pc; - if (mmufixup[1].reg >= 0) { - m68k_areg (regs, mmufixup[1].reg) = mmufixup[1].value; - mmufixup[1].reg = -1; - } - } else { #if 0 if (regs.wb3_status & 0x80) { // movem to memory? @@ -4120,9 +4364,7 @@ retry: regs.mmu_ssw |= MMU_SSW_CM; //write_log (_T("MMU_SSW_CM\n")); } - } #endif - } //opcodedebug (pc, opcode, false); @@ -4132,14 +4374,9 @@ retry: } //activate_debugger (); TRY (prb2) { - Exception (0); //Exception (prb) + Exception (0); //prb } CATCH (prb2) { - write_log (_T("MMU: double bus error, rebooting..\n")); - regs.tcr = 0; - m68k_reset (0); - m68k_setpc (0xf80002); - mmu_reset (); - uae_reset (1, 0); + cpu_halt (1); return; } goto retry; @@ -4149,6 +4386,91 @@ retry: #endif +#ifdef CPUEMU_32 + +// Previous MMU 68030 +static void m68k_run_mmu030 (void) +{ + uae_u16 opcode; + uaecptr pc; + + mmu030_opcode_stageb = -1; +retry: + TRY (prb) { + for (;;) { + int cnt; +insretry: + pc = regs.instruction_pc = m68k_getpc (); + + mmu030_state[0] = mmu030_state[1] = mmu030_state[2] = 0; +#if 1 + if (pc == 0x1000) { + write_log (_T("*")); + //activate_debugger (); + } +#endif + mmu030_opcode = -1; + if (mmu030_opcode_stageb < 0) { + opcode = get_iword_mmu030 (0); + } else { + opcode = mmu030_opcode_stageb; + mmu030_opcode_stageb = -1; + } + + mmu030_opcode = opcode; + mmu030_ad[0].done = false; + + cnt = 50; + for (;;) { + opcode = mmu030_opcode; + mmu030_idx = 0; + count_instr (opcode); + do_cycles (cpu_cycles); + mmu030_retry = false; + cpu_cycles = (*cpufunctbl[opcode])(opcode); + cnt--; // so that we don't get in infinite loop if things go horribly wrong + if (!mmu030_retry) + break; + if (cnt < 0) + break; + if (mmu030_retry && mmu030_opcode == -1) + goto insretry; // urgh + } + + mmu030_opcode = -1; + + cpu_cycles = adjust_cycles (cpu_cycles); + if (regs.spcflags) { + if (do_specialties (cpu_cycles)) + return; + } + } + } CATCH (prb) { + + m68k_setpc (regs.instruction_pc); + if (mmufixup[0].reg >= 0) { + m68k_areg (regs, mmufixup[0].reg) = mmufixup[0].value; + mmufixup[0].reg = -1; + } + if (mmufixup[1].reg >= 0) { + m68k_areg (regs, mmufixup[1].reg) = mmufixup[1].value; + mmufixup[1].reg = -1; + } + + TRY (prb2) { + Exception (0); //prb + } CATCH (prb2) { + cpu_halt (1); + return; + } + goto retry; + } + +} + +#endif + + /* "cycle exact" 68020/030 */ STATIC_INLINE void docodece020 (uae_u32 opcode) @@ -4478,6 +4800,13 @@ void m68k_go (int may_quit) } savestate_restore_finish (); memory_map_dump (); +#ifdef MMUEMU + if (currprefs.mmu_model == 68030) { + mmu030_decode_tc (tc_030); + } else if (currprefs.mmu_model >= 68040) { + mmu_set_tc (regs.tcr); + } +#endif startup = 1; restored = 1; } @@ -4515,14 +4844,15 @@ void m68k_go (int may_quit) /* program jumped to non-existing memory and cpu was >= 68020 */ get_real_address (regs.isp); /* stack in no one's land? -> reboot */ if (regs.isp & 1) - regs.panic = 1; + regs.panic = 5; if (!regs.panic) exception2_handle (regs.panic_pc, regs.panic_addr); if (regs.panic) { + int id = regs.panic; /* system is very badly confused */ write_log (_T("double bus error or corrupted stack, forcing reboot..\n")); regs.panic = 0; - uae_reset (1, 0); + cpu_halt (id); } } @@ -4542,6 +4872,10 @@ void m68k_go (int may_quit) #endif } startup = 0; + if (regs.halted) { + cpu_halt (regs.halted); + continue; + } if (mmu_enabled && !currprefs.cachesize) { run_func = m68k_run_mmu; } else { @@ -4550,7 +4884,11 @@ void m68k_go (int may_quit) #ifdef JIT currprefs.cpu_model >= 68020 && currprefs.cachesize ? m68k_run_jit : #endif - (currprefs.cpu_model == 68040 || currprefs.cpu_model == 68060) && currprefs.mmu_model ? m68k_run_mmu040 : +#ifdef MMUEMU + currprefs.cpu_model == 68030 && currprefs.mmu_model ? m68k_run_mmu030 : + currprefs.cpu_model == 68040 && currprefs.mmu_model ? m68k_run_mmu040 : + currprefs.cpu_model == 68060 && currprefs.mmu_model ? m68k_run_mmu060 : +#endif currprefs.cpu_model >= 68020 && currprefs.cpu_cycle_exact ? m68k_run_2ce : currprefs.cpu_compatible ? (currprefs.cpu_model <= 68020 ? m68k_run_2p : m68k_run_2pf) : m68k_run_2; } @@ -4679,10 +5017,10 @@ static void disasm_size (TCHAR *instrname, struct instr *dp) } } -void m68k_disasm_2 (TCHAR *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int cnt, uae_u32 *seaddr, uae_u32 *deaddr, int safemode) +void m68k_disasm_2 (TCHAR *buf, int bufsize, uaecptr pc, uaecptr *nextpc, int cnt, uae_u32 *seaddr, uae_u32 *deaddr, int safemode) { - uaecptr newpc = 0; - m68kpc_offset = addr - m68k_getpc (); + uae_u32 seaddr2 = 0; + uae_u32 deaddr2 = 0; if (buf) memset (buf, 0, bufsize * sizeof (TCHAR)); @@ -4695,13 +5033,13 @@ void m68k_disasm_2 (TCHAR *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int struct mnemolookup *lookup; struct instr *dp; int oldpc; - int m68kpc_illg = 0; + uaecptr m68kpc_illg = 0; bool illegal = false; - oldpc = m68kpc_offset; - opcode = get_iword_1 (m68kpc_offset); + oldpc = pc; + opcode = get_word_debug (pc); if (cpufunctbl[opcode] == op_illg_1 || cpufunctbl[opcode] == op_unimpl_1) { - m68kpc_illg = m68kpc_offset + 2; + m68kpc_illg = pc + 2; illegal = true; } @@ -4714,9 +5052,9 @@ void m68k_disasm_2 (TCHAR *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int for (lookup = lookuptab;lookup->mnemo != dp->mnemo; lookup++) ; - buf = buf_out (buf, &bufsize, _T("%08lX "), m68k_getpc () + m68kpc_offset); + buf = buf_out (buf, &bufsize, _T("%08lX "), pc); - m68kpc_offset += 2; + pc += 2; if (lookup->friendlyname) _tcscpy (instrname, lookup->friendlyname); @@ -4729,7 +5067,7 @@ void m68k_disasm_2 (TCHAR *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int disasm_size (instrname, dp); if (lookup->mnemo == i_MOVEC2 || lookup->mnemo == i_MOVE2C) { - uae_u16 imm = get_iword_1 (m68kpc_offset); + uae_u16 imm = get_word_debug (pc); uae_u16 creg = imm & 0x0fff; uae_u16 r = imm >> 12; TCHAR regs[16], *cname = _T("?"); @@ -4750,34 +5088,30 @@ void m68k_disasm_2 (TCHAR *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int _tcscat (instrname, _T(",")); _tcscat (instrname, regs); } - m68kpc_offset += 2; + pc += 2; } else if (lookup->mnemo == i_MVMEL) { - newpc = m68k_getpc () + m68kpc_offset; - m68kpc_offset += 2; - newpc += ShowEA (0, opcode, dp->dreg, dp->dmode, dp->size, instrname, deaddr, safemode); + pc = ShowEA (0, pc, opcode, dp->dreg, dp->dmode, dp->size, instrname, deaddr, safemode); _tcscat (instrname, _T(",")); - movemout (instrname, get_iword_1 (oldpc + 2), dp->dmode); + movemout (instrname, get_word_debug (pc), dp->dmode); + pc += 2; } else if (lookup->mnemo == i_MVMLE) { - m68kpc_offset += 2; - movemout (instrname, get_iword_1 (oldpc + 2), dp->dmode); + movemout (instrname, get_word_debug (pc), dp->dmode); + pc += 2; _tcscat (instrname, _T(",")); - newpc = m68k_getpc () + m68kpc_offset; - newpc += ShowEA (0, opcode, dp->dreg, dp->dmode, dp->size, instrname, deaddr, safemode); + pc = ShowEA (0, pc, opcode, dp->dreg, dp->dmode, dp->size, instrname, deaddr, safemode); } else { if (dp->suse) { - newpc = m68k_getpc () + m68kpc_offset; - newpc += ShowEA (0, opcode, dp->sreg, dp->smode, dp->size, instrname, seaddr, safemode); + pc = ShowEA (0, pc, opcode, dp->sreg, dp->smode, dp->size, instrname, &seaddr2, safemode); } if (dp->suse && dp->duse) _tcscat (instrname, _T(",")); if (dp->duse) { - newpc = m68k_getpc () + m68kpc_offset; - newpc += ShowEA (0, opcode, dp->dreg, dp->dmode, dp->size, instrname, deaddr, safemode); + pc = ShowEA (0, pc, opcode, dp->dreg, dp->dmode, dp->size, instrname, &deaddr2, safemode); } } - for (i = 0; i < (m68kpc_offset - oldpc) / 2; i++) { - buf = buf_out (buf, &bufsize, _T("%04x "), get_iword_1 (oldpc + i * 2)); + for (i = 0; i < (pc - oldpc) / 2; i++) { + buf = buf_out (buf, &bufsize, _T("%04x "), get_word_debug (oldpc + i * 2)); } while (i++ < 5) buf = buf_out (buf, &bufsize, _T(" ")); @@ -4790,26 +5124,30 @@ void m68k_disasm_2 (TCHAR *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int if (ccpt != 0) { if (deaddr) - *deaddr = newpc; + *deaddr = pc; if (cctrue (dp->cc)) - buf = buf_out (buf, &bufsize, _T(" == $%08lX (T)"), newpc); + buf = buf_out (buf, &bufsize, _T(" == $%08x (T)"), seaddr2); else - buf = buf_out (buf, &bufsize, _T(" == $%08lX (F)"), newpc); + buf = buf_out (buf, &bufsize, _T(" == $%08x (F)"), seaddr2); } else if ((opcode & 0xff00) == 0x6100) { /* BSR */ if (deaddr) - *deaddr = newpc; - buf = buf_out (buf, &bufsize, _T(" == $%08lX"), newpc); + *deaddr = pc; + buf = buf_out (buf, &bufsize, _T(" == $%08x"), seaddr2); } buf = buf_out (buf, &bufsize, _T("\n")); if (illegal) - m68kpc_offset = m68kpc_illg; + pc = m68kpc_illg; } if (nextpc) - *nextpc = m68k_getpc () + m68kpc_offset; + *nextpc = pc; + if (seaddr) + *seaddr = seaddr2; + if (deaddr) + *deaddr = deaddr2; } -void m68k_disasm_ea (void *f, uaecptr addr, uaecptr *nextpc, int cnt, uae_u32 *seaddr, uae_u32 *deaddr) +void m68k_disasm_ea (uaecptr addr, uaecptr *nextpc, int cnt, uae_u32 *seaddr, uae_u32 *deaddr) { TCHAR *buf; @@ -4817,10 +5155,10 @@ void m68k_disasm_ea (void *f, uaecptr addr, uaecptr *nextpc, int cnt, uae_u32 *s if (!buf) return; m68k_disasm_2 (buf, (MAX_LINEWIDTH + 1) * cnt, addr, nextpc, cnt, seaddr, deaddr, 1); - f_out (f, _T("%s"), buf); + console_out_f (_T("%s"), buf); xfree (buf); } -void m68k_disasm (void *f, uaecptr addr, uaecptr *nextpc, int cnt) +void m68k_disasm (uaecptr addr, uaecptr *nextpc, int cnt) { TCHAR *buf; @@ -4828,7 +5166,7 @@ void m68k_disasm (void *f, uaecptr addr, uaecptr *nextpc, int cnt) if (!buf) return; m68k_disasm_2 (buf, (MAX_LINEWIDTH + 1) * cnt, addr, nextpc, cnt, NULL, NULL, 0); - f_out (f, _T("%s"), buf); + console_out_f (_T("%s"), buf); xfree (buf); } @@ -4842,21 +5180,17 @@ void sm68k_disasm (TCHAR *instrname, TCHAR *instrcode, uaecptr addr, uaecptr *ne uae_u32 opcode; struct mnemolookup *lookup; struct instr *dp; - int oldpc; + uaecptr pc, oldpc; - uaecptr newpc = 0; - - m68kpc_offset = addr - m68k_getpc (); - - oldpc = m68kpc_offset; - opcode = get_iword_1 (m68kpc_offset); + oldpc = pc = m68k_getpc (); + opcode = get_word_debug (pc); if (cpufunctbl[opcode] == op_illg_1) { opcode = 0x4AFC; } dp = table68k + opcode; for (lookup = lookuptab;lookup->mnemo != dp->mnemo; lookup++); - m68kpc_offset += 2; + pc += 2; _tcscpy (instrname, lookup->name); ccpt = _tcsstr (instrname, _T("cc")); @@ -4871,20 +5205,18 @@ void sm68k_disasm (TCHAR *instrname, TCHAR *instrcode, uaecptr addr, uaecptr *ne } if (dp->suse) { - newpc = m68k_getpc () + m68kpc_offset; - newpc += ShowEA (0, opcode, dp->sreg, dp->smode, dp->size, instrname, NULL, 0); + pc += ShowEA (0, pc, opcode, dp->sreg, dp->smode, dp->size, instrname, NULL, 0); } if (dp->suse && dp->duse) _tcscat (instrname, _T(",")); if (dp->duse) { - newpc = m68k_getpc () + m68kpc_offset; - newpc += ShowEA (0, opcode, dp->dreg, dp->dmode, dp->size, instrname, NULL, 0); + pc += ShowEA (0, pc, opcode, dp->dreg, dp->dmode, dp->size, instrname, NULL, 0); } if (instrcode) { int i; - for (i = 0; i < (m68kpc_offset - oldpc) / 2; i++) + for (i = 0; i < (pc - oldpc) / 2; i++) { _stprintf (instrcode, _T("%04x "), get_iword_1 (oldpc + i * 2)); instrcode += _tcslen (instrcode); @@ -4892,7 +5224,7 @@ void sm68k_disasm (TCHAR *instrname, TCHAR *instrcode, uaecptr addr, uaecptr *ne } if (nextpc) - *nextpc = m68k_getpc () + m68kpc_offset; + *nextpc = pc; } struct cpum2c m2cregs[] = { @@ -4966,17 +5298,17 @@ uae_u32 val_move2c (int regno) } } -void m68k_dumpstate (void *f, uaecptr *nextpc) +void m68k_dumpstate (uaecptr *nextpc) { int i, j; for (i = 0; i < 8; i++){ - f_out (f, _T(" D%d %08lX "), i, m68k_dreg (regs, i)); - if ((i & 3) == 3) f_out (f, _T("\n")); + console_out_f (_T(" D%d %08lX "), i, m68k_dreg (regs, i)); + if ((i & 3) == 3) console_out_f (_T("\n")); } for (i = 0; i < 8; i++){ - f_out (f, _T(" A%d %08lX "), i, m68k_areg (regs, i)); - if ((i & 3) == 3) f_out (f, _T("\n")); + console_out_f (_T(" A%d %08lX "), i, m68k_areg (regs, i)); + if ((i & 3) == 3) console_out_f (_T("\n")); } if (regs.s == 0) regs.usp = m68k_areg (regs, 7); @@ -4985,20 +5317,20 @@ void m68k_dumpstate (void *f, uaecptr *nextpc) if (regs.s && regs.m == 0) regs.isp = m68k_areg (regs, 7); j = 2; - f_out (f, _T("USP %08X ISP %08X "), regs.usp, regs.isp); + console_out_f (_T("USP %08X ISP %08X "), regs.usp, regs.isp); for (i = 0; m2cregs[i].regno>= 0; i++) { if (!movec_illg (m2cregs[i].regno)) { if (!_tcscmp (m2cregs[i].regname, _T("USP")) || !_tcscmp (m2cregs[i].regname, _T("ISP"))) continue; if (j > 0 && (j % 4) == 0) - f_out (f, _T("\n")); - f_out (f, _T("%-4s %08X "), m2cregs[i].regname, val_move2c (m2cregs[i].regno)); + console_out_f (_T("\n")); + console_out_f (_T("%-4s %08X "), m2cregs[i].regname, val_move2c (m2cregs[i].regno)); j++; } } if (j > 0) - f_out (f, _T("\n")); - f_out (f, _T("T=%d%d S=%d M=%d X=%d N=%d Z=%d V=%d C=%d IMASK=%d STP=%d\n"), + console_out_f (_T("\n")); + console_out_f (_T("T=%d%d S=%d M=%d X=%d N=%d Z=%d V=%d C=%d IMASK=%d STP=%d\n"), regs.t1, regs.t0, regs.s, regs.m, GET_XFLG (), GET_NFLG (), GET_ZFLG (), GET_VFLG (), GET_CFLG (), @@ -5007,12 +5339,12 @@ void m68k_dumpstate (void *f, uaecptr *nextpc) if (currprefs.fpu_model) { uae_u32 fpsr; for (i = 0; i < 8; i++){ - f_out (f, _T("FP%d: %g "), i, regs.fp[i]); + console_out_f (_T("FP%d: %g "), i, regs.fp[i]); if ((i & 3) == 3) - f_out (f, _T("\n")); + console_out_f (_T("\n")); } fpsr = get_fpsr (); - f_out (f, _T("FPSR: %04X FPCR: %08x FPIAR: %08x N=%d Z=%d I=%d NAN=%d\n"), + console_out_f (_T("FPSR: %04X FPCR: %08x FPIAR: %08x N=%d Z=%d I=%d NAN=%d\n"), fpsr, regs.fpcr, regs.fpiar, (fpsr & 0x8000000) != 0, (fpsr & 0x4000000) != 0, @@ -5027,17 +5359,17 @@ void m68k_dumpstate (void *f, uaecptr *nextpc) for (lookup1 = lookuptab; lookup1->mnemo != dp->mnemo; lookup1++); dp = table68k + regs.ir; for (lookup2 = lookuptab; lookup2->mnemo != dp->mnemo; lookup2++); - f_out (f, _T("Prefetch %04x (%s) %04x (%s)\n"), regs.irc, lookup1->name, regs.ir, lookup2->name); + console_out_f (_T("Prefetch %04x (%s) %04x (%s)\n"), regs.irc, lookup1->name, regs.ir, lookup2->name); } - m68k_disasm (f, m68k_getpc (), nextpc, 1); + m68k_disasm (m68k_getpc (), nextpc, 1); if (nextpc) - f_out (f, _T("Next PC: %08lx\n"), *nextpc); + console_out_f (_T("Next PC: %08lx\n"), *nextpc); } #else -void m68k_dumpstate (void *f, uaecptr *nextpc) +void m68k_dumpstate (uaecptr *nextpc) { } @@ -5093,12 +5425,12 @@ uae_u8 *restore_cpu (uae_u8 *src) regs.msp = restore_u32 (); } if (model >= 68030) { - crp_030 = restore_u64 (); - srp_030 = restore_u64 (); - tt0_030 =restore_u32 (); - tt1_030 = restore_u32 (); - tc_030 = restore_u32 (); - mmusr_030 = restore_u16 (); + crp_030 = fake_crp_030 = restore_u64 (); + srp_030 = fake_srp_030 = restore_u64 (); + tt0_030 = fake_tt0_030 = restore_u32 (); + tt1_030 = fake_tt1_030 = restore_u32 (); + tc_030 = fake_tc_030 = restore_u32 (); + mmusr_030 = fake_mmusr_030 = restore_u16 (); } if (model >= 68040) { regs.itt0 = restore_u32 (); @@ -5382,12 +5714,21 @@ uae_u8 *save_cpu (int *len, uae_u8 *dstptr) save_u32 (regs.msp); /* MSP */ } if (model >= 68030) { - save_u64 (crp_030); /* CRP */ - save_u64 (srp_030); /* SRP */ - save_u32 (tt0_030); /* TT0/AC0 */ - save_u32 (tt1_030); /* TT1/AC1 */ - save_u32 (tc_030); /* TCR */ - save_u16 (mmusr_030); /* MMUSR/ACUSR */ + if (currprefs.mmu_model) { + save_u64 (crp_030); /* CRP */ + save_u64 (srp_030); /* SRP */ + save_u32 (tt0_030); /* TT0/AC0 */ + save_u32 (tt1_030); /* TT1/AC1 */ + save_u32 (tc_030); /* TCR */ + save_u16 (mmusr_030); /* MMUSR/ACUSR */ + } else { + save_u64 (fake_crp_030); /* CRP */ + save_u64 (fake_srp_030); /* SRP */ + save_u32 (fake_tt0_030); /* TT0/AC0 */ + save_u32 (fake_tt1_030); /* TT1/AC1 */ + save_u32 (fake_tc_030); /* TCR */ + save_u16 (fake_mmusr_030); /* MMUSR/ACUSR */ + } } if (model >= 68040) { save_u32 (regs.itt0); /* ITT0 */ @@ -5445,14 +5786,14 @@ uae_u8 *save_cpu (int *len, uae_u8 *dstptr) return dstbak; } -#ifdef MMU +#ifdef MMUEMU uae_u8 *save_mmu (int *len, uae_u8 *dstptr) { uae_u8 *dstbak, *dst; int model; model = currprefs.mmu_model; - if (model != 68040 && model != 68060) + if (model != 68030 && model != 68040 && model != 68060) return NULL; if (dstptr) dstbak = dst = dstptr; @@ -5473,8 +5814,7 @@ uae_u8 *restore_mmu (uae_u8 *src) write_log (_T("MMU: %d\n"), model); return src; } -#endif - +#endif //MMUEMU #endif /* SAVESTATE */ static void exception3f (uae_u32 opcode, uaecptr addr, int writeaccess, int instructionaccess, uae_u32 pc) @@ -5516,7 +5856,7 @@ void exception2 (uaecptr addr) write_log (_T("delayed exception2!\n")); regs.panic_pc = m68k_getpc (); regs.panic_addr = addr; - regs.panic = 2; + regs.panic = 6; set_special (SPCFLAG_BRK); m68k_setpc (0xf80000); #ifdef JIT @@ -5767,7 +6107,7 @@ STATIC_INLINE void fill_cache040 (uae_u32 addr) } // this one is really simple and easy -static void fill_icache020 (uae_u32 addr) +void fill_icache020 (uae_u32 addr) { int index; uae_u32 tag; @@ -6071,34 +6411,3 @@ void flush_dcache (uaecptr addr, int size) } } -#ifdef MMU -void m68k_do_rte_mmu (uaecptr a7) -{ - uae_u16 ssr = get_word_mmu (a7 + 8 + 4); - if (ssr & MMU_SSW_CT) { - uaecptr src_a7 = a7 + 8 - 8; - uaecptr dst_a7 = a7 + 8 + 52; - put_word_mmu (dst_a7 + 0, get_word_mmu (src_a7 + 0)); - put_long_mmu (dst_a7 + 2, get_long_mmu (src_a7 + 2)); - // skip this word - put_long_mmu (dst_a7 + 8, get_long_mmu (src_a7 + 8)); - } -} - -void flush_mmu (uaecptr addr, int n) -{ -} - -void m68k_do_rts_mmu (void) -{ - m68k_setpc (get_long_mmu (m68k_areg (regs, 7))); - m68k_areg (regs, 7) += 4; -} - -void m68k_do_bsr_mmu (uaecptr oldpc, uae_s32 offset) -{ - put_long_mmu (m68k_areg (regs, 7) - 4, oldpc); - m68k_areg (regs, 7) -= 4; - m68k_incpci (offset); -} -#endif diff --git a/src/od-amiga/main.c b/src/od-amiga/main.c index a2345c2..f0cf6bd 100644 --- a/src/od-amiga/main.c +++ b/src/od-amiga/main.c @@ -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; } diff --git a/src/od-linux/blkdev-linux.c b/src/od-linux/blkdev-linux.c index a7bcd4f..e92b24f 100644 --- a/src/od-linux/blkdev-linux.c +++ b/src/od-linux/blkdev-linux.c @@ -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 diff --git a/src/od-macosx/main.m b/src/od-macosx/main.m index 49e486a..9629972 100644 --- a/src/od-macosx/main.m +++ b/src/od-macosx/main.m @@ -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; diff --git a/src/od-win32/Makefile.am b/src/od-win32/Makefile.am deleted file mode 100644 index becd877..0000000 --- a/src/od-win32/Makefile.am +++ /dev/null @@ -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 diff --git a/src/od-win32/bsdsock.c b/src/od-win32/bsdsock.c deleted file mode 100644 index e32b7e0..0000000 --- a/src/od-win32/bsdsock.c +++ /dev/null @@ -1,2624 +0,0 @@ -/* - * UAE - The Un*x Amiga Emulator - * - * bsdsocket.library emulation - Win32 OS-dependent part - * - * Copyright 1997,98 Mathias Ortmann - * Copyright 1999,2000 Brian King - * - * GNU Public License - * - */ -#ifdef BSDSOCKET - -#include "sysconfig.h" -#include "sysdeps.h" - -#include -#include -#include - -#include "options.h" -#include "include/memory_uae.h" -#include "custom.h" -#include "events.h" -#include "newcpu.h" -#include "autoconf.h" -#include "bsdsocket.h" - -#include "osdep/exectasks.h" -#include "threaddep/thread.h" -#include "native2amiga.h" -//#include "resource.h" -//#include "win32gui.h" -#include "wininet.h" -#include "mmsystem.h" -#include "win32.h" - - - -static HWND hSockWnd; -static long FAR PASCAL SocketWindowProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ); - -extern HWND hAmigaWnd; -int hWndSelector = 0; /* Set this to zero to get hSockWnd */ -CRITICAL_SECTION csSigQueueLock; - -DWORD threadid; -#ifdef __GNUC__ -#define THREAD(func,arg) CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)func,(LPVOID)arg,0,&threadid) -#else -#define THREAD(func,arg) _beginthreadex( NULL, 0, func, (void *)arg, 0, (unsigned *)&threadid ) -#endif - -#define SETERRNO seterrno(sb,WSAGetLastError()-WSABASEERR) -#define SETHERRNO setherrno(sb,WSAGetLastError()-WSABASEERR) -#define WAITSIGNAL waitsig(sb) - -#define SETSIGNAL addtosigqueue(sb,0) -#define CANCELSIGNAL cancelsig(sb) - -#define FIOSETOWN _IOW('f', 124, long) /* set owner (struct Task *) */ -#define FIOGETOWN _IOR('f', 123, long) /* get owner (struct Task *) */ - -#define BEGINBLOCKING if (sb->ftable[sd-1] & SF_BLOCKING) sb->ftable[sd-1] |= SF_BLOCKINGINPROGRESS -#define ENDBLOCKING sb->ftable[sd-1] &= ~SF_BLOCKINGINPROGRESS - -static WSADATA wsbData; - -int PASCAL WSAEventSelect(SOCKET,HANDLE,long); - -#define MAX_SELECT_THREADS 64 -static HANDLE hThreads[MAX_SELECT_THREADS]; -uae_u32 *threadargs[MAX_SELECT_THREADS]; -static HANDLE hEvents[MAX_SELECT_THREADS]; - -#define MAX_GET_THREADS 64 -static HANDLE hGetThreads[MAX_GET_THREADS]; -uae_u32 *threadGetargs[MAX_GET_THREADS]; -static HANDLE hGetEvents[MAX_GET_THREADS]; - - -static HANDLE hSockThread; -static HANDLE hSockReq, hSockReqHandled; -static unsigned int __stdcall sock_thread(void *); - -CRITICAL_SECTION SockThreadCS; -#define PREPARE_THREAD EnterCriticalSection( &SockThreadCS ) -#define TRIGGER_THREAD { SetEvent( hSockReq ); WaitForSingleObject( hSockReqHandled, INFINITE ); LeaveCriticalSection( &SockThreadCS ); } - -#define SOCKVER_MAJOR 2 -#define SOCKVER_MINOR 2 - -#define SF_RAW_UDP 0x10000000 -#define SF_RAW_RAW 0x20000000 -#define SF_RAW_RUDP 0x08000000 -#define SF_RAW_RICMP 0x04000000 - -typedef struct ip_option_information { - u_char Ttl; /* Time To Live (used for traceroute) */ - u_char Tos; /* Type Of Service (usually 0) */ - u_char Flags; /* IP header flags (usually 0) */ - u_char OptionsSize; /* Size of options data (usually 0, max 40) */ - u_char FAR *OptionsData; /* Options data buffer */ -} IPINFO, *PIPINFO, FAR *LPIPINFO; - -static void bsdsetpriority (HANDLE thread) -{ -// int pri = os_winnt ? THREAD_PRIORITY_NORMAL : priorities[currprefs.win32_active_priority].value; - int pri = THREAD_PRIORITY_NORMAL; - SetThreadPriority(thread, pri); -} - -static int mySockStartup( void ) -{ - int result = 0; - SOCKET dummy; - DWORD lasterror; - - if (WSAStartup(MAKEWORD( SOCKVER_MAJOR, SOCKVER_MINOR ), &wsbData)) - { - lasterror = WSAGetLastError(); - - if( lasterror == WSAVERNOTSUPPORTED ) - { -// char szMessage[ MAX_DPATH ]; -// WIN32GUI_LoadUIString( IDS_WSOCK2NEEDED, szMessage, MAX_DPATH ); -// gui_message( szMessage ); - } - else - write_log ( "BSDSOCK: ERROR - Unable to initialize Windows socket layer! Error code: %d\n", lasterror ); - return 0; - } - - if (LOBYTE (wsbData.wVersion) != SOCKVER_MAJOR || HIBYTE (wsbData.wVersion) != SOCKVER_MINOR ) - { -// char szMessage[ MAX_DPATH ]; -// WIN32GUI_LoadUIString( IDS_WSOCK2NEEDED, szMessage, MAX_DPATH ); -// gui_message( szMessage ); - - return 0; - } - else - { - write_log ( "BSDSOCK: using %s\n", wsbData.szDescription ); - // make sure WSP/NSPStartup gets called from within the regular stack - // (Windows 95/98 need this) - if( ( dummy = socket( AF_INET,SOCK_STREAM,IPPROTO_TCP ) ) != INVALID_SOCKET ) - { - closesocket( dummy ); - result = 1; - } - else - { - write_log ( "BSDSOCK: ERROR - WSPStartup/NSPStartup failed! Error code: %d\n",WSAGetLastError() ); - result = 0; - } - } - - return result; -} - -static int socket_layer_initialized = 0; - -int init_socket_layer(void) -{ - int result = 0; - -#ifndef CAN_DO_STACK_MAGIC - currprefs.socket_emu = 0; -#endif - if( currprefs.socket_emu ) - { - if( ( result = mySockStartup() ) ) - { - InitializeCriticalSection(&csSigQueueLock); - - if( hSockThread == NULL ) - { - WNDCLASS wc; // Set up an invisible window and dummy wndproc - - InitializeCriticalSection( &SockThreadCS ); - hSockReq = CreateEvent( NULL, FALSE, FALSE, NULL ); - hSockReqHandled = CreateEvent( NULL, FALSE, FALSE, NULL ); - - wc.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW; - wc.lpfnWndProc = SocketWindowProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = 0; -// wc.hIcon = LoadIcon (GetModuleHandle (NULL), MAKEINTRESOURCE (IDI_APPICON)); - wc.hCursor = LoadCursor (NULL, IDC_ARROW); - wc.hbrBackground = GetStockObject (BLACK_BRUSH); - wc.lpszMenuName = 0; - wc.lpszClassName = "SocketFun"; - if( RegisterClass (&wc) ) - { - hSockWnd = CreateWindowEx ( 0, - "SocketFun", "WinUAE Socket Window", - WS_POPUP, - 0, 0, - 1, 1, - NULL, NULL, 0, NULL); - hSockThread = (void *)THREAD(sock_thread,NULL); - } - } - } - } - - socket_layer_initialized = result; - - return result; -} - -void deinit_socket_layer(void) -{ - int i; - if( currprefs.socket_emu ) - { - WSACleanup(); - if( socket_layer_initialized ) - { - DeleteCriticalSection( &csSigQueueLock ); - if( hSockThread ) - { - DeleteCriticalSection( &SockThreadCS ); - CloseHandle( hSockReq ); - hSockReq = NULL; - CloseHandle( hSockReqHandled ); - WaitForSingleObject( hSockThread, INFINITE ); - CloseHandle( hSockThread ); - } - for (i = 0; i < MAX_SELECT_THREADS; i++) - { - if (hThreads[i]) - { - CloseHandle( hThreads[i] ); - } - } - } - } -} - -#ifdef BSDSOCKET - -void locksigqueue(void) -{ - EnterCriticalSection(&csSigQueueLock); -} - -void unlocksigqueue(void) -{ - LeaveCriticalSection(&csSigQueueLock); -} - -// Asynchronous completion notification - -// We use window messages posted to hAmigaWnd in the range from 0xb000 to 0xb000+MAXPENDINGASYNC*2 -// Socket events cause even-numbered messages, task events odd-numbered messages -// Message IDs are allocated on a round-robin basis and deallocated by the main thread. - -// WinSock tends to choke on WSAAsyncCancelMessage(s,w,m,0,0) called too often with an event pending - -// @@@ Enabling all socket event messages for every socket by default and basing things on that would -// be cleaner (and allow us to write a select() emulation that doesn't need to be kludge-aborted). -// However, the latency of the message queue is too high for that at the moment (setting up a dummy -// window from a separate thread would fix that). - -// Blocking sockets with asynchronous event notification are currently not safe to use. - -struct socketbase *asyncsb[MAXPENDINGASYNC]; -SOCKET asyncsock[MAXPENDINGASYNC]; -uae_u32 asyncsd[MAXPENDINGASYNC]; -int asyncindex; - -int host_sbinit(SB) -{ - sb->sockAbort = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); - - if (sb->sockAbort == INVALID_SOCKET) return 0; - if ((sb->hEvent = CreateEvent(NULL,FALSE,FALSE,NULL)) == NULL) return 0; - - sb->mtable = calloc(sb->dtablesize,sizeof(*sb->mtable)); - - return 1; -} - -void host_closesocketquick(int s) -{ - BOOL true = 1; - - if( s ) - { - setsockopt((SOCKET)s,SOL_SOCKET,SO_DONTLINGER,(char *)&true,sizeof(true)); - shutdown(s,1); - closesocket((SOCKET)s); - } -} - -void host_sbcleanup(SB) -{ - int i; - - for (i = 0; i < MAXPENDINGASYNC; i++) if (asyncsb[i] == sb) asyncsb[i] = NULL; - - if (sb->hEvent != NULL) CloseHandle(sb->hEvent); - - for (i = sb->dtablesize; i--; ) - { - if (sb->dtable[i] != (int)INVALID_SOCKET) host_closesocketquick(sb->dtable[i]); - - if (sb->mtable[i]) asyncsb[(sb->mtable[i]-0xb000)/2] = NULL; - } - - shutdown(sb->sockAbort,1); - closesocket(sb->sockAbort); - - xfree(sb->mtable); -} - -void host_sbreset(void) -{ - memset(asyncsb,0,sizeof asyncsb); - memset(asyncsock,0,sizeof asyncsock); - memset(asyncsd,0,sizeof asyncsd); - memset(threadargs,0,sizeof threadargs); -} - -void sockmsg(unsigned int msg, unsigned long wParam, unsigned long lParam) -{ - SB; - unsigned int index; - int sdi; - - index = (msg-0xb000)/2; - sb = asyncsb[index]; - - if (!(msg & 1)) - { - // is this one really for us? - if ((SOCKET)wParam != asyncsock[index]) - { - // cancel socket event - WSAAsyncSelect((SOCKET)wParam,hWndSelector ? hAmigaWnd : hSockWnd,0,0); - return; - } - - sdi = asyncsd[index]-1; - - // asynchronous socket event? - if (sb && !(sb->ftable[sdi] & SF_BLOCKINGINPROGRESS) && sb->mtable[sdi]) - { - long wsbevents = WSAGETSELECTEVENT(lParam); - int fmask = 0; - - // regular socket event? - if (wsbevents & FD_READ) fmask = REP_READ; - else if (wsbevents & FD_WRITE) fmask = REP_WRITE; - else if (wsbevents & FD_OOB) fmask = REP_OOB; - else if (wsbevents & FD_ACCEPT) fmask = REP_ACCEPT; - else if (wsbevents & FD_CONNECT) fmask = REP_CONNECT; - else if (wsbevents & FD_CLOSE) fmask = REP_CLOSE; - - // error? - if (WSAGETSELECTERROR(lParam)) fmask |= REP_ERROR; - - // notify - if (sb->ftable[sdi] & fmask) sb->ftable[sdi] |= fmask<<8; - - addtosigqueue(sb,1); - return; - } - } - - locksigqueue(); - - if (sb != NULL) - { - - - asyncsb[index] = NULL; - - if (WSAGETASYNCERROR(lParam)) - { - seterrno(sb,WSAGETASYNCERROR(lParam)-WSABASEERR); - if (sb->sb_errno >= 1001 && sb->sb_errno <= 1005) setherrno(sb,sb->sb_errno-1000); - else if (sb->sb_errno == 55) // ENOBUFS - write_log ("BSDSOCK: ERROR - Buffer overflow - %d bytes requested\n",WSAGETASYNCBUFLEN(lParam)); - } - else seterrno(sb,0); - - - SETSIGNAL; - } - - unlocksigqueue(); -} - -static unsigned int allocasyncmsg(SB,uae_u32 sd,SOCKET s) -{ - int i; - locksigqueue(); - - for (i = asyncindex+1; i != asyncindex; i++) - { - if (i == MAXPENDINGASYNC) i = 0; - - if (!asyncsb[i]) - { - asyncsb[i] = sb; - if (++asyncindex == MAXPENDINGASYNC) asyncindex = 0; - unlocksigqueue(); - - if (s == INVALID_SOCKET) - { - return i*2+0xb001; - } - else - { - asyncsd[i] = sd; - asyncsock[i] = s; - return i*2+0xb000; - } - } - } - - unlocksigqueue(); - - seterrno(sb,12); // ENOMEM - write_log ("BSDSOCK: ERROR - Async operation completion table overflow\n"); - - return 0; -} - -static void cancelasyncmsg(unsigned int wMsg) -{ - SB; - - wMsg = (wMsg-0xb000)/2; - - sb = asyncsb[wMsg]; - - if (sb != NULL) - { - asyncsb[wMsg] = NULL; - CANCELSIGNAL; - } -} - -void sockabort(SB) -{ - locksigqueue(); - - unlocksigqueue(); -} - -void setWSAAsyncSelect(SB, uae_u32 sd, SOCKET s, long lEvent ) - { - if (sb->mtable[sd-1]) - { - long wsbevents = 0; - long eventflags; - int i; - locksigqueue(); - - - eventflags = sb->ftable[sd-1] & REP_ALL; - - if (eventflags & REP_ACCEPT) wsbevents |= FD_ACCEPT; - if (eventflags & REP_CONNECT) wsbevents |= FD_CONNECT; - if (eventflags & REP_OOB) wsbevents |= FD_OOB; - if (eventflags & REP_READ) wsbevents |= FD_READ; - if (eventflags & REP_WRITE) wsbevents |= FD_WRITE; - if (eventflags & REP_CLOSE) wsbevents |= FD_CLOSE; - wsbevents |= lEvent; - i = (sb->mtable[sd-1]-0xb000)/2; - asyncsb[i] = sb; - asyncsd[i] = sd; - asyncsock[i] = s; - WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : hSockWnd,sb->mtable[sd-1],wsbevents); - - unlocksigqueue(); - } - } - - -// address cleaning -static void prephostaddr(SOCKADDR_IN *addr) -{ - addr->sin_family = AF_INET; -} - -static void prepamigaaddr(struct sockaddr *realpt, int len) -{ - // little endian address family value to the byte sin_family member - ((char *)realpt)[1] = *((char *)realpt); - - // set size of address - *((char *)realpt) = len; -} - - -int host_dup2socket(SB, int fd1, int fd2) - { - SOCKET s1,s2; - - TRACE(("dup2socket(%d,%d) -> ",fd1,fd2)); - fd1++; - - s1 = getsock(sb, fd1); - if (s1 != INVALID_SOCKET) - { - if (fd2 != -1) - { - if ((unsigned int) (fd2) >= (unsigned int) sb->dtablesize) - { - TRACE (("Bad file descriptor (%d)\n", fd2)); - seterrno (sb, 9); /* EBADF */ - } - fd2++; - s2 = getsock(sb,fd2); - if (s2 != INVALID_SOCKET) - { - shutdown(s2,1); - closesocket(s2); - } - setsd(sb,fd2,s1); - TRACE(("0\n")); - return 0; - } - else - { - fd2 = getsd(sb, 1); - setsd(sb,fd2,s1); - TRACE(("%d\n",fd2)); - return (fd2 - 1); - } - } - TRACE(("-1\n")); - return -1; - } - -int host_socket(SB, int af, int type, int protocol) -{ - int sd; - SOCKET s; - unsigned long nonblocking = 1; - - TRACE(("socket(%s,%s,%d) -> ",af == AF_INET ? "AF_INET" : "AF_other",type == SOCK_STREAM ? "SOCK_STREAM" : type == SOCK_DGRAM ? "SOCK_DGRAM " : "SOCK_RAW",protocol)); - - if ((s = socket(af,type,protocol)) == INVALID_SOCKET) - { - SETERRNO; - TRACE(("failed (%d)\n",sb->sb_errno)); - return -1; - } - else - sd = getsd(sb,(int)s); - - sb->ftable[sd-1] = SF_BLOCKING; - ioctlsocket(s,FIONBIO,&nonblocking); - TRACE(("%d\n",sd)); - - if (type == SOCK_RAW) - { - if (protocol==IPPROTO_UDP) - { - sb->ftable[sd-1] |= SF_RAW_UDP; - } - if (protocol==IPPROTO_ICMP) - { - struct sockaddr_in sin; - - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = INADDR_ANY; - bind(s,(struct sockaddr *)&sin,sizeof(sin)) ; - } - if (protocol==IPPROTO_RAW) - { - sb->ftable[sd-1] |= SF_RAW_RAW; - } - } - return sd-1; -} - -uae_u32 host_bind(SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) -{ - char buf[MAXADDRLEN]; - uae_u32 success = 0; - SOCKET s; - - sd++; - TRACE(("bind(%d,0x%lx,%d) -> ",sd,name,namelen)); - s = getsock(sb, sd); - - if (s != INVALID_SOCKET) - { - if (namelen <= sizeof buf) - { - memcpy(buf,get_real_address (name),namelen); - - // some Amiga programs set this field to bogus values - prephostaddr((SOCKADDR_IN *)buf); - - if ((success = bind(s,(struct sockaddr *)buf,namelen)) != 0) - { - SETERRNO; - TRACE(("failed (%d)\n",sb->sb_errno)); - } - else - TRACE(("OK\n")); - } - else - write_log ("BSDSOCK: ERROR - Excessive namelen (%d) in bind()!\n",namelen); - } - - return success; -} - -uae_u32 host_listen(SB, uae_u32 sd, uae_u32 backlog) -{ - SOCKET s; - uae_u32 success = -1; - - sd++; - TRACE(("listen(%d,%d) -> ",sd,backlog)); - s = getsock(sb, sd); - - if (s != INVALID_SOCKET) - { - if ((success = listen(s,backlog)) != 0) - { - SETERRNO; - TRACE(("failed (%d)\n",sb->sb_errno)); - } - else - TRACE(("OK\n")); - } - - return success; -} - -void host_accept(SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) -{ - struct sockaddr *rp_name,*rp_nameuae; - struct sockaddr sockaddr; - int hlen,hlenuae=0; - SOCKET s, s2; - int success = 0; - unsigned int wMsg; - - sd++; - if (name != 0 ) - { - rp_nameuae = rp_name = (struct sockaddr *)get_real_address (name); - hlenuae = hlen = get_long (namelen); - if (hlenuae < sizeof(sockaddr)) - { // Fix for CNET BBS Windows must have 16 Bytes (sizeof(sockaddr)) otherwise Error WSAEFAULT - rp_name = &sockaddr; - hlen = sizeof(sockaddr); - } - } - else - { - rp_name = &sockaddr; - hlen = sizeof(sockaddr); - } - TRACE(("accept(%d,%d,%d) -> ",sd,name,hlenuae)); - - s = (SOCKET)getsock(sb,(int)sd); - - if (s != INVALID_SOCKET) - { - BEGINBLOCKING; - - s2 = accept(s,rp_name,&hlen); - - if (s2 == INVALID_SOCKET) - { - SETERRNO; - - if (sb->ftable[sd-1] & SF_BLOCKING && sb->sb_errno == WSAEWOULDBLOCK-WSABASEERR) - { - if (sb->mtable[sd-1] || (wMsg = allocasyncmsg(sb,sd,s)) != 0) - { - if (sb->mtable[sd-1] == 0) - { - WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : hSockWnd,wMsg,FD_ACCEPT); - } - else - { - setWSAAsyncSelect(sb,sd,s,FD_ACCEPT); - } - - WAITSIGNAL; - - if (sb->mtable[sd-1] == 0) - { - cancelasyncmsg(wMsg); - } - else - { - setWSAAsyncSelect(sb,sd,s,0); - } - - if (sb->eintr) - { - TRACE(("[interrupted]\n")); - ENDBLOCKING; - return; - } - - s2 = accept(s,rp_name,&hlen); - - if (s2 == INVALID_SOCKET) - { - SETERRNO; - - if (sb->sb_errno == WSAEWOULDBLOCK-WSABASEERR) write_log ("BSDSOCK: ERRRO - accept() would block despite FD_ACCEPT message\n"); - } - } - } - } - - if (s2 == INVALID_SOCKET) - { - sb->resultval = -1; - TRACE(("failed (%d)\n",sb->sb_errno)); - } - else - { - sb->resultval = getsd(sb, s2); - sb->ftable[sb->resultval-1] = sb->ftable[sd-1]; // new socket inherits the old socket's properties - sb->resultval--; - if (rp_name != 0) - { // 1.11.2002 XXX - if (hlen <= hlenuae) - { // Fix for CNET BBS Part 2 - prepamigaaddr(rp_name,hlen); - if (namelen != 0) - { - put_long (namelen,hlen); - } - } - else - { // Copy only the number of bytes requested - if (hlenuae != 0) - { - prepamigaaddr(rp_name,hlenuae); - memcpy(rp_nameuae,rp_name,hlenuae); - put_long (namelen,hlenuae); - } - } - } - TRACE(("%d/%d\n",sb->resultval,hlen)); - } - - ENDBLOCKING; - } - - } - -typedef enum -{ - connect_req, - recvfrom_req, - sendto_req, - abort_req, - last_req -} threadsock_e; - -struct threadsock_packet -{ - threadsock_e packet_type; - union - { - struct sendto_params - { - char *buf; - char *realpt; - uae_u32 sd; - uae_u32 msg; - uae_u32 len; - uae_u32 flags; - uae_u32 to; - uae_u32 tolen; - } sendto_s; - struct recvfrom_params - { - char *realpt; - uae_u32 addr; - uae_u32 len; - uae_u32 flags; - struct sockaddr *rp_addr; - int *hlen; - } recvfrom_s; - struct connect_params - { - char *buf; - uae_u32 namelen; - } connect_s; - struct abort_params - { - SOCKET *newsock; - } abort_s; - } params; - SOCKET s; - SB; -} sockreq; - -BOOL HandleStuff( void ) -{ - BOOL quit = FALSE; - SB = NULL; - BOOL handled = TRUE; - if( hSockReq ) - { - // 100ms sleepiness might need some tuning... - //if(WaitForSingleObject( hSockReq, 100 ) == WAIT_OBJECT_0 ) - { - switch( sockreq.packet_type ) - { - case connect_req: - sockreq.sb->resultval = connect(sockreq.s,(struct sockaddr *)(sockreq.params.connect_s.buf),sockreq.params.connect_s.namelen); - break; - case sendto_req: - if( sockreq.params.sendto_s.to ) - { - sockreq.sb->resultval = sendto(sockreq.s,sockreq.params.sendto_s.realpt,sockreq.params.sendto_s.len,sockreq.params.sendto_s.flags,(struct sockaddr *)(sockreq.params.sendto_s.buf),sockreq.params.sendto_s.tolen); - } - else - { - sockreq.sb->resultval = send(sockreq.s,sockreq.params.sendto_s.realpt,sockreq.params.sendto_s.len,sockreq.params.sendto_s.flags); - } - break; - case recvfrom_req: - if( sockreq.params.recvfrom_s.addr ) - { - sockreq.sb->resultval = recvfrom( sockreq.s, sockreq.params.recvfrom_s.realpt, sockreq.params.recvfrom_s.len, - sockreq.params.recvfrom_s.flags, sockreq.params.recvfrom_s.rp_addr, - sockreq.params.recvfrom_s.hlen ); - - } - else - { - sockreq.sb->resultval = recv( sockreq.s, sockreq.params.recvfrom_s.realpt, sockreq.params.recvfrom_s.len, - sockreq.params.recvfrom_s.flags ); - } - break; - case abort_req: - *(sockreq.params.abort_s.newsock) = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); - if (*(sockreq.params.abort_s.newsock) != sb->sockAbort) - { - shutdown( sb->sockAbort, 1 ); - closesocket(sb->sockAbort); - } - handled = FALSE; /* Don't bother the SETERRNO section after the switch() */ - break; - case last_req: - default: - write_log ( "BSDSOCK: Invalid sock-thread request!\n" ); - handled = FALSE; - break; - } - if( handled ) - { - if( sockreq.sb->resultval == SOCKET_ERROR ) - { - sb = sockreq.sb; - - SETERRNO; - } - } - SetEvent( hSockReqHandled ); - } - } - else - { - quit = TRUE; - } - return quit; -} - -static long FAR PASCAL SocketWindowProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ) -{ - if( message >= 0xB000 && message < 0xB000+MAXPENDINGASYNC*2 ) - { -#if DEBUG_SOCKETS - write_log ( "sockmsg(0x%x, 0x%x, 0x%x)\n", message, wParam, lParam ); -#endif - sockmsg( message, wParam, lParam ); - return 0; - } - return DefWindowProc( hwnd, message, wParam, lParam ); -} - - - -static unsigned int __stdcall sock_thread(void *blah) -{ - unsigned int result = 0; - HANDLE WaitHandle; - MSG msg; - - if( hSockWnd ) - { - // Make sure we're outrunning the wolves - int pri = THREAD_PRIORITY_ABOVE_NORMAL; -#if 0 - if (!os_winnt) { - pri = priorities[currprefs.win32_active_priority].value; - if (pri == THREAD_PRIORITY_HIGHEST) - pri = THREAD_PRIORITY_TIME_CRITICAL; - else - pri++; - } -#endif - SetThreadPriority( GetCurrentThread(), pri ); - - while( TRUE ) - { - if( hSockReq ) - { - DWORD wait; - WaitHandle = hSockReq; - wait = MsgWaitForMultipleObjects (1, &WaitHandle, FALSE,INFINITE, QS_POSTMESSAGE); - if (wait == WAIT_OBJECT_0) - { - if( HandleStuff() ) // See if its time to quit... - break; - } - if (wait == WAIT_OBJECT_0 +1) - { - Sleep(10); - while( PeekMessage( &msg, NULL, WM_USER, 0xB000+MAXPENDINGASYNC*2, PM_REMOVE ) > 0 ) - { - TranslateMessage( &msg ); - DispatchMessage( &msg ); - } - } - } - } - } - write_log ( "BSDSOCK: We have exited our sock_thread()\n" ); -#ifndef __GNUC__ - _endthreadex( result ); -#endif - return result; -} - - -void host_connect(SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) -{ - SOCKET s; - int success = 0; - unsigned int wMsg; - char buf[MAXADDRLEN]; - - - sd++; - TRACE(("connect(%d,0x%lx,%d) -> ",sd,name,namelen)); - - s = (SOCKET)getsock(sb,(int)sd); - - if (s != INVALID_SOCKET) - { - if (namelen <= MAXADDRLEN) - { - if (sb->mtable[sd-1] || (wMsg = allocasyncmsg(sb,sd,s)) != 0) - { - if (sb->mtable[sd-1] == 0) - { - WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : hSockWnd,wMsg,FD_CONNECT); - } - else - { - setWSAAsyncSelect(sb,sd,s,FD_CONNECT); - } - - - BEGINBLOCKING; - PREPARE_THREAD; - - memcpy(buf,get_real_address (name),namelen); - prephostaddr((SOCKADDR_IN *)buf); - - sockreq.packet_type = connect_req; - sockreq.s = s; - sockreq.sb = sb; - sockreq.params.connect_s.buf = buf; - sockreq.params.connect_s.namelen = namelen; - - TRIGGER_THREAD; - - - if (sb->resultval) - { - if (sb->sb_errno == WSAEWOULDBLOCK-WSABASEERR) - { - if (sb->ftable[sd-1] & SF_BLOCKING) - { - seterrno(sb,0); - - - WAITSIGNAL; - - if (sb->eintr) - { - // Destroy socket to cancel abort, replace it with fake socket to enable proper closing. - // This is in accordance with BSD behaviour. - shutdown(s,1); - closesocket(s); - sb->dtable[sd-1] = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); - } - } - else - { - seterrno(sb,36); // EINPROGRESS - - } - } - else - { - CANCELSIGNAL; // Cancel pending signal - - } - } - - ENDBLOCKING; - if (sb->mtable[sd-1] == 0) - { - cancelasyncmsg(wMsg); - } - else - { - setWSAAsyncSelect(sb,sd,s,0); - } - } - - } - else - write_log ("BSDSOCK: WARNING - Excessive namelen (%d) in connect()!\n",namelen); - } - TRACE(("%d\n",sb->sb_errno)); -} - -void host_sendto(SB, uae_u32 sd, uae_u32 msg, uae_u32 len, uae_u32 flags, uae_u32 to, uae_u32 tolen) -{ - SOCKET s; - char *realpt; - unsigned int wMsg; - char buf[MAXADDRLEN]; - int iCut; - -#ifdef TRACING_ENABLED - if (to) - TRACE(("sendto(%d,0x%lx,%d,0x%lx,0x%lx,%d) -> ",sd,msg,len,flags,to,tolen)); - else - TRACE(("send(%d,0x%lx,%d,%d) -> ",sd,msg,len,flags)); -#endif - sd++; - s = getsock(sb,sd); - - if (s != INVALID_SOCKET) - { - realpt = get_real_address (msg); - - if (to) - { - if (tolen > sizeof buf) write_log ("BSDSOCK: WARNING - Target address in sendto() too large (%d)!\n",tolen); - else - { - memcpy(buf,get_real_address (to),tolen); - // some Amiga software sets this field to bogus values - prephostaddr((SOCKADDR_IN *)buf); - } - } - if (sb->ftable[sd-1]&SF_RAW_RAW) - { - if (*(realpt+9) == 0x1) - { // ICMP - struct sockaddr_in sin; - shutdown(s,1); - closesocket(s); - s = socket(AF_INET,SOCK_RAW,IPPROTO_ICMP); - - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = INADDR_ANY; - sin.sin_port = (unsigned short) (*(realpt+21)&0xff)*256 + (unsigned short) (*(realpt+20)&0xff); - bind(s,(struct sockaddr *)&sin,sizeof(sin)) ; - - sb->dtable[sd-1] = s; - sb->ftable[sd-1]&= ~SF_RAW_RAW; - sb->ftable[sd-1]|= SF_RAW_RICMP; - } - if (*(realpt+9) == 0x11) - { // UDP - struct sockaddr_in sin; - shutdown(s,1); - closesocket(s); - s = socket(AF_INET,SOCK_RAW,IPPROTO_UDP); - - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = INADDR_ANY; - sin.sin_port = (unsigned short) (*(realpt+21)&0xff)*256 + (unsigned short) (*(realpt+20)&0xff); - bind(s,(struct sockaddr *)&sin,sizeof(sin)) ; - - sb->dtable[sd-1] = s; - sb->ftable[sd-1]&= ~SF_RAW_RAW; - sb->ftable[sd-1]|= SF_RAW_RUDP; - } - } - - BEGINBLOCKING; - - for (;;) - { - PREPARE_THREAD; - - sockreq.packet_type = sendto_req; - sockreq.s = s; - sockreq.sb = sb; - sockreq.params.sendto_s.realpt = realpt; - sockreq.params.sendto_s.buf = buf; - sockreq.params.sendto_s.sd = sd; - sockreq.params.sendto_s.msg = msg; - sockreq.params.sendto_s.len = len; - sockreq.params.sendto_s.flags = flags; - sockreq.params.sendto_s.to = to; - sockreq.params.sendto_s.tolen = tolen; - - if (sb->ftable[sd-1]&SF_RAW_UDP) - { - *(buf+2) = *(realpt+2); - *(buf+3) = *(realpt+3); - // Copy DST-Port - iCut = 8; - sockreq.params.sendto_s.realpt += iCut; - sockreq.params.sendto_s.len -= iCut; - } - if (sb->ftable[sd-1]&SF_RAW_RUDP) - { - int iTTL; - iTTL = (int) *(realpt+8)&0xff; - setsockopt(s,IPPROTO_IP,4,(char*) &iTTL,sizeof(iTTL)); - *(buf+2) = *(realpt+22); - *(buf+3) = *(realpt+23); - // Copy DST-Port - iCut = 28; - sockreq.params.sendto_s.realpt += iCut; - sockreq.params.sendto_s.len -= iCut; - } - if (sb->ftable[sd-1]&SF_RAW_RICMP) - { - int iTTL; - iTTL = (int) *(realpt+8)&0xff; - setsockopt(s,IPPROTO_IP,4,(char*) &iTTL,sizeof(iTTL)); - iCut = 20; - sockreq.params.sendto_s.realpt += iCut; - sockreq.params.sendto_s.len -= iCut; - } - - - - TRIGGER_THREAD; - if (sb->ftable[sd-1]&SF_RAW_UDP||sb->ftable[sd-1]&SF_RAW_RUDP||sb->ftable[sd-1]&SF_RAW_RICMP) - { - sb->resultval += iCut; - } - if (sb->resultval == -1) - { - if (sb->sb_errno != WSAEWOULDBLOCK-WSABASEERR || !(sb->ftable[sd-1] & SF_BLOCKING)) break; - } - else - { - realpt += sb->resultval; - len -= sb->resultval; - - if (len <= 0) break; - else continue; - } - - if (sb->mtable[sd-1] || (wMsg = allocasyncmsg(sb,sd,s)) != 0) - { - if (sb->mtable[sd-1] == 0) - { - WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : hSockWnd,wMsg,FD_WRITE); - } - else - { - setWSAAsyncSelect(sb,sd,s,FD_WRITE); - } - - WAITSIGNAL; - - if (sb->mtable[sd-1] == 0) - { - cancelasyncmsg(wMsg); - } - else - { - setWSAAsyncSelect(sb,sd,s,0); - } - - if (sb->eintr) - { - TRACE(("[interrupted]\n")); - return; - } - } - else break; - } - - ENDBLOCKING; - } - else sb->resultval = -1; - -#ifdef TRACING_ENABLED - if (sb->resultval == -1) - TRACE(("failed (%d)\n",sb->sb_errno)); - else - TRACE(("%d\n",sb->resultval)); -#endif - -} - -void host_recvfrom(SB, uae_u32 sd, uae_u32 msg, uae_u32 len, uae_u32 flags, uae_u32 addr, uae_u32 addrlen) -{ - SOCKET s; - char *realpt; - struct sockaddr *rp_addr = NULL; - int hlen; - unsigned int wMsg; - -#ifdef TRACING_ENABLED - if (addr) - TRACE(("recvfrom(%d,0x%lx,%d,0x%lx,0x%lx,%d) -> ",sd,msg,len,flags,addr,get_long (addrlen))); - else - TRACE(("recv(%d,0x%lx,%d,0x%lx) -> ",sd,msg,len,flags)); -#endif - sd++; - s = getsock(sb,sd); - - if (s != INVALID_SOCKET) - { - realpt = get_real_address (msg); - - if (addr) - { - hlen = get_long (addrlen); - rp_addr = (struct sockaddr *)get_real_address (addr); - } - - BEGINBLOCKING; - - for (;;) - { - PREPARE_THREAD; - - sockreq.packet_type = recvfrom_req; - sockreq.s = s; - sockreq.sb = sb; - sockreq.params.recvfrom_s.addr = addr; - sockreq.params.recvfrom_s.flags = flags; - sockreq.params.recvfrom_s.hlen = &hlen; - sockreq.params.recvfrom_s.len = len; - sockreq.params.recvfrom_s.realpt = realpt; - sockreq.params.recvfrom_s.rp_addr = rp_addr; - - TRIGGER_THREAD; - if (sb->resultval == -1) - { - if (sb->sb_errno == WSAEWOULDBLOCK-WSABASEERR && sb->ftable[sd-1] & SF_BLOCKING) - { - if (sb->mtable[sd-1] || (wMsg = allocasyncmsg(sb,sd,s)) != 0) - { - if (sb->mtable[sd-1] == 0) - { - WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : hSockWnd,wMsg,FD_READ|FD_CLOSE); - } - else - { - setWSAAsyncSelect(sb,sd,s,FD_READ|FD_CLOSE); - } - - WAITSIGNAL; - - if (sb->mtable[sd-1] == 0) - { - cancelasyncmsg(wMsg); - } - else - { - setWSAAsyncSelect(sb,sd,s,0); - } - - - if (sb->eintr) - { - TRACE(("[interrupted]\n")); - return; - } - } - else break; - } - else break; - } - else break; - } - - ENDBLOCKING; - - if (addr) - { - prepamigaaddr(rp_addr,hlen); - put_long (addrlen,hlen); - } - } - else sb->resultval = -1; - -#ifdef TRACING_ENABLED - if (sb->resultval == -1) - TRACE(("failed (%d)\n",sb->sb_errno)); - else - TRACE(("%d\n",sb->resultval)); -#endif - -} - -uae_u32 host_shutdown(SB, uae_u32 sd, uae_u32 how) -{ - SOCKET s; - - TRACE(("shutdown(%d,%d) -> ",sd,how)); - sd++; - s = getsock(sb,sd); - - if (s != INVALID_SOCKET) - { - if (shutdown(s,how)) - { - SETERRNO; - TRACE(("failed (%d)\n",sb->sb_errno)); - } - else - { - TRACE(("OK\n")); - return 0; - } - } - - return -1; -} - -void host_setsockopt(SB, uae_u32 sd, uae_u32 level, uae_u32 optname, uae_u32 optval, uae_u32 len) -{ - SOCKET s; - char buf[MAXADDRLEN]; - - TRACE(("setsockopt(%d,%d,0x%lx,0x%lx,%d) -> ",sd,(short)level,optname,optval,len)); - sd++; - s = getsock(sb,sd); - - if (s != INVALID_SOCKET) - { - if (len > sizeof buf) - { - write_log ("BSDSOCK: WARNING - Excessive optlen in setsockopt() (%d)\n",len); - len = sizeof buf; - } - if (level == IPPROTO_IP && optname == 2) - { // IP_HDRINCL emulated by icmp.dll - sb->resultval = 0; - return; - } - if (level == SOL_SOCKET && optname == SO_LINGER) - { - ((LINGER *)buf)->l_onoff = get_long (optval); - ((LINGER *)buf)->l_linger = get_long (optval+4); - } - else - { - if (len == 4) *(long *)buf = get_long (optval); - else if (len == 2) *(short *)buf = get_word (optval); - else write_log ("BSDSOCK: ERROR - Unknown optlen (%d) in setsockopt(%d,%d)\n",level,optname); - } - - // handle SO_EVENTMASK - if (level == 0xffff && optname == 0x2001) - { - long wsbevents = 0; - uae_u32 eventflags = get_long (optval); - - sb->ftable[sd-1] = (sb->ftable[sd-1] & ~REP_ALL) | (eventflags & REP_ALL); - - if (eventflags & REP_ACCEPT) wsbevents |= FD_ACCEPT; - if (eventflags & REP_CONNECT) wsbevents |= FD_CONNECT; - if (eventflags & REP_OOB) wsbevents |= FD_OOB; - if (eventflags & REP_READ) wsbevents |= FD_READ; - if (eventflags & REP_WRITE) wsbevents |= FD_WRITE; - if (eventflags & REP_CLOSE) wsbevents |= FD_CLOSE; - - if (sb->mtable[sd-1] || (sb->mtable[sd-1] = allocasyncmsg(sb,sd,s))) - { - WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : hSockWnd,sb->mtable[sd-1],wsbevents); - sb->resultval = 0; - } - else sb->resultval = -1; - } - else sb->resultval = setsockopt(s,level,optname,buf,len); - - if (!sb->resultval) - { - TRACE(("OK\n")); - return; - } - else SETERRNO; - - TRACE(("failed (%d)\n",sb->sb_errno)); - } -} - -uae_u32 host_getsockopt(SB, uae_u32 sd, uae_u32 level, uae_u32 optname, uae_u32 optval, uae_u32 optlen) -{ - SOCKET s; - char buf[MAXADDRLEN]; - int len = sizeof(buf); - - TRACE(("getsockopt(%d,%d,0x%lx,0x%lx,0x%lx) -> ",sd,(short)level,optname,optval,optlen)); - sd++; - s = getsock(sb,sd); - - if (s != INVALID_SOCKET) - { - if (!getsockopt(s,level,optname,buf,&len)) - { - if (level == SOL_SOCKET && optname == SO_LINGER) - { - put_long (optval,((LINGER *)buf)->l_onoff); - put_long (optval+4,((LINGER *)buf)->l_linger); - } - else - { - if (len == 4) put_long (optval,*(long *)buf); - else if (len == 2) put_word (optval,*(short *)buf); - else write_log ("BSDSOCK: ERROR - Unknown optlen (%d) in setsockopt(%d,%d)\n",level,optname); - } - -// put_long (optlen,len); // some programs pass the actual ength instead of a pointer to the length, so... - TRACE(("OK (%d,%d)\n",len,*(long *)buf)); - return 0; - } - else - { - SETERRNO; - TRACE(("failed (%d)\n",sb->sb_errno)); - } - } - - return -1; -} - -uae_u32 host_getsockname(SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) -{ - SOCKET s; - int len; - struct sockaddr *rp_name; - - sd++; - len = get_long (namelen); - - TRACE(("getsockname(%d,0x%lx,%d) -> ",sd,name,len)); - - s = getsock(sb,sd); - - if (s != INVALID_SOCKET) - { - rp_name = (struct sockaddr *)get_real_address (name); - - if (getsockname(s,rp_name,&len)) - { - SETERRNO; - TRACE(("failed (%d)\n",sb->sb_errno)); - } - else - { - TRACE(("%d\n",len)); - prepamigaaddr(rp_name,len); - put_long (namelen,len); - return 0; - } - } - - return -1; -} - -uae_u32 host_getpeername(SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) -{ - SOCKET s; - int len; - struct sockaddr *rp_name; - - sd++; - len = get_long (namelen); - - TRACE(("getpeername(%d,0x%lx,%d) -> ",sd,name,len)); - - s = getsock(sb,sd); - - if (s != INVALID_SOCKET) - { - rp_name = (struct sockaddr *)get_real_address (name); - - if (getpeername(s,rp_name,&len)) - { - SETERRNO; - TRACE(("failed (%d)\n",sb->sb_errno)); - } - else - { - TRACE(("%d\n",len)); - prepamigaaddr(rp_name,len); - put_long (namelen,len); - return 0; - } - } - - return -1; -} - -uae_u32 host_IoctlSocket(SB, uae_u32 sd, uae_u32 request, uae_u32 arg) -{ - SOCKET s; - uae_u32 data; - int success = SOCKET_ERROR; - - TRACE(("IoctlSocket(%d,0x%lx,0x%lx) ",sd,request,arg)); - sd++; - s = getsock(sb,sd); - - if (s != INVALID_SOCKET) - { - switch (request) - { - case FIOSETOWN: - sb->ownertask = get_long (arg); - success = 0; - break; - case FIOGETOWN: - put_long (arg,sb->ownertask); - success = 0; - break; - case FIONBIO: - TRACE(("[FIONBIO] -> ")); - if (get_long (arg)) - { - TRACE(("nonblocking\n")); - sb->ftable[sd-1] &= ~SF_BLOCKING; - } - else - { - TRACE(("blocking\n")); - sb->ftable[sd-1] |= SF_BLOCKING; - } - success = 0; - break; - case FIONREAD: - ioctlsocket(s,request,(u_long *)&data); - TRACE(("[FIONREAD] -> %d\n",data)); - put_long (arg,data); - success = 0; - break; - case FIOASYNC: - if (get_long (arg)) - { - sb->ftable[sd-1] |= REP_ALL; - - TRACE(("[FIOASYNC] -> enabled\n")); - if (sb->mtable[sd-1] || (sb->mtable[sd-1] = allocasyncmsg(sb,sd,s))) - { - WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : hSockWnd,sb->mtable[sd-1],FD_ACCEPT | FD_CONNECT | FD_OOB | FD_READ | FD_WRITE | FD_CLOSE); - success = 0; - break; - } - } - else write_log (("BSDSOCK: WARNING - FIOASYNC disabling unsupported.\n")); - - success = -1; - break; - default: - write_log ("BSDSOCK: WARNING - Unknown IoctlSocket request: 0x%08lx\n",request); - seterrno(sb,22); // EINVAL - } - } - - return success; -} - -int host_CloseSocket(SB, int sd) -{ - unsigned int wMsg; - SOCKET s; - - TRACE(("CloseSocket(%d) -> ",sd)); - sd++; - - s = getsock(sb,sd); - if (s != INVALID_SOCKET) - { - if (sb->mtable[sd-1]) - { - asyncsb[(sb->mtable[sd-1]-0xb000)/2] = NULL; - sb->mtable[sd-1] = 0; - } - - if (checksd(sb ,sd) == TRUE) - return 0; - - - - BEGINBLOCKING; - - for (;;) - { - shutdown(s,1); - if (!closesocket(s)) - { - releasesock(sb,sd); - TRACE(("OK\n")); - return 0; - } - - SETERRNO; - - if (sb->sb_errno != WSAEWOULDBLOCK-WSABASEERR || !(sb->ftable[sd-1] & SF_BLOCKING)) break; - - if ((wMsg = allocasyncmsg(sb,sd,s)) != 0) - { - WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : hSockWnd,wMsg,FD_CLOSE); - - - WAITSIGNAL; - - - cancelasyncmsg(wMsg); - - if (sb->eintr) - { - TRACE(("[interrupted]\n")); - break; - } - } - else break; - } - - ENDBLOCKING; - } - - TRACE(("failed (%d)\n",sb->sb_errno)); - - return -1; -} - -// For the sake of efficiency, we do not malloc() the fd_sets here. -// 64 sockets should be enough for everyone. -static void makesocktable(SB, uae_u32 fd_set_amiga, struct fd_set *fd_set_win, int nfds, SOCKET addthis) -{ - int i, j; - uae_u32 currlong, mask; - SOCKET s; - - if (addthis != INVALID_SOCKET) - { - *fd_set_win->fd_array = addthis; - fd_set_win->fd_count = 1; - } - else fd_set_win->fd_count = 0; - - if (!fd_set_amiga) - { - fd_set_win->fd_array[fd_set_win->fd_count] = INVALID_SOCKET; - return; - } - - if (nfds > sb->dtablesize) - { - write_log ("BSDSOCK: ERROR - select()ing more sockets (%d) than socket descriptors available (%d)!\n",nfds,sb->dtablesize); - nfds = sb->dtablesize; - } - - for (j = 0; ; j += 32, fd_set_amiga += 4) - { - currlong = get_long (fd_set_amiga); - - mask = 1; - - for (i = 0; i < 32; i++, mask <<= 1) - { - if (i+j > nfds) - { - fd_set_win->fd_array[fd_set_win->fd_count] = INVALID_SOCKET; - return; - } - - if (currlong & mask) - { - s = getsock(sb,j+i+1); - - if (s != INVALID_SOCKET) - { - fd_set_win->fd_array[fd_set_win->fd_count++] = s; - - if (fd_set_win->fd_count >= FD_SETSIZE) - { - write_log ("BSDSOCK: ERROR - select()ing more sockets (%d) than the hard-coded fd_set limit (%d) - please report\n",nfds,FD_SETSIZE); - return; - } - } - } - } - } - - fd_set_win->fd_array[fd_set_win->fd_count] = INVALID_SOCKET; -} - -static void makesockbitfield(SB, uae_u32 fd_set_amiga, struct fd_set *fd_set_win, int nfds) -{ - int n, i, j, val, mask; - SOCKET currsock; - - for (n = 0; n < nfds; n += 32) - { - val = 0; - mask = 1; - - for (i = 0; i < 32; i++, mask <<= 1) - { - if ((currsock = getsock(sb, n+i+1)) != INVALID_SOCKET) - { // Do not use sb->dtable directly because of Newsrog - for (j = fd_set_win->fd_count; j--; ) - { - if (fd_set_win->fd_array[j] == currsock) - { - val |= mask; - break; - } - } - } - } - put_long (fd_set_amiga,val); - fd_set_amiga += 4; - } -} - -static void fd_zero(uae_u32 fdset, uae_u32 nfds) -{ - unsigned int i; - - for (i = 0; i < nfds; i += 32, fdset += 4) put_long (fdset,0); -} - -// This seems to be the only way of implementing a cancelable WinSock2 select() call... sigh. -static unsigned int __stdcall thread_WaitSelect(void *index2) -{ - uae_u32 index = (uae_u32)index2; - unsigned int result = 0; - long nfds; - uae_u32 readfds, writefds, exceptfds; - uae_u32 timeout; - struct fd_set readsocks, writesocks, exceptsocks; - struct timeval tv; - uae_u32 *args; - - SB; - - for (;;) - { - WaitForSingleObject(hEvents[index],INFINITE); - - if ((args = threadargs[index]) != NULL) - { - sb = (struct socketbase *)*args; - nfds = args[1]; - readfds = args[2]; - writefds = args[3]; - exceptfds = args[4]; - timeout = args[5]; - - // construct descriptor tables - makesocktable(sb,readfds,&readsocks,nfds,sb->sockAbort); - if (writefds) makesocktable(sb,writefds,&writesocks,nfds,INVALID_SOCKET); - if (exceptfds) makesocktable(sb,exceptfds,&exceptsocks,nfds,INVALID_SOCKET); - - if (timeout) - { - tv.tv_sec = get_long (timeout); - tv.tv_usec = get_long (timeout+4); - TRACE(("(timeout: %d.%06d) ",tv.tv_sec,tv.tv_usec)); - } - - TRACE(("-> ")); - - sb->resultval = select(nfds+1,&readsocks,writefds ? &writesocks : NULL,exceptfds ? &exceptsocks : NULL,timeout ? &tv : 0); - if (sb->resultval == SOCKET_ERROR) - { - // select was stopped by sb->sockAbort - if (readsocks.fd_count > 1) - { - makesocktable(sb,readfds,&readsocks,nfds,INVALID_SOCKET); - tv.tv_sec = 0; - tv.tv_usec = 10000; - // Check for 10ms if data is available - sb->resultval = select(nfds+1,&readsocks,writefds ? &writesocks : NULL,exceptfds ? &exceptsocks : NULL,&tv); - if (sb->resultval == 0) - { // Now timeout -> really no data available - if (GetLastError() != 0) - { - sb->resultval = SOCKET_ERROR; - // Set old resultval - } - } - } - } - if (FD_ISSET(sb->sockAbort,&readsocks)) - { - if (sb->resultval != SOCKET_ERROR) - { - sb->resultval--; - } - } - else - { - sb->needAbort = 0; - } - if (sb->resultval == SOCKET_ERROR) - { - SETERRNO; - TRACE(("failed (%d) - ",sb->sb_errno)); - if (readfds) fd_zero(readfds,nfds); - if (writefds) fd_zero(writefds,nfds); - if (exceptfds) fd_zero(exceptfds,nfds); - } - else - { - if (readfds) makesockbitfield(sb,readfds,&readsocks,nfds); - if (writefds) makesockbitfield(sb,writefds,&writesocks,nfds); - if (exceptfds) makesockbitfield(sb,exceptfds,&exceptsocks,nfds); - } - - SETSIGNAL; - - threadargs[index] = NULL; - SetEvent(sb->hEvent); - } - } -#ifndef __GNUC__ - _endthreadex( result ); -#endif - return result; -} - -void host_WaitSelect(SB, uae_u32 nfds, uae_u32 readfds, uae_u32 writefds, uae_u32 exceptfds, uae_u32 timeout, uae_u32 sigmp) -{ - uae_u32 sigs, wssigs; - int i; - - wssigs = sigmp ? get_long (sigmp) : 0; - - TRACE(("WaitSelect(%d,0x%lx,0x%lx,0x%lx,0x%lx,0x%lx) ",nfds,readfds,writefds,exceptfds,timeout,wssigs)); - - if (!readfds && !writefds && !exceptfds && !timeout && !wssigs) - { - sb->resultval = 0; - TRACE(("-> [ignored]\n")); - return; - } - if (wssigs) - { - m68k_dreg (®s, 0) = 0; - m68k_dreg (®s, 1) = wssigs; - sigs = CallLib (get_long (4),-0x132) & wssigs; // SetSignal() - - if (sigs) - { - TRACE(("-> [preempted by signals 0x%08lx]\n",sigs & wssigs)); - put_long (sigmp,sigs & wssigs); - // Check for zero address -> otherwise WinUAE crashes - if (readfds) fd_zero(readfds,nfds); - if (writefds) fd_zero(writefds,nfds); - if (exceptfds) fd_zero(exceptfds,nfds); - sb->resultval = 0; - seterrno(sb,0); - return; - } - } - if (nfds == 0) - { // No sockets to check, only wait for signals - m68k_dreg (®s, 0) = wssigs; - sigs = CallLib (get_long (4),-0x13e); // Wait() - - put_long (sigmp,sigs & wssigs); - - if (readfds) fd_zero(readfds,nfds); - if (writefds) fd_zero(writefds,nfds); - if (exceptfds) fd_zero(exceptfds,nfds); - sb->resultval = 0; - return; - } - - ResetEvent(sb->hEvent); - - sb->needAbort = 1; - - for (i = 0; i < MAX_SELECT_THREADS; i++) if (hThreads[i] && !threadargs[i]) break; - - if (i >= MAX_SELECT_THREADS) - { - for (i = 0; i < MAX_SELECT_THREADS; i++) - { - if (!hThreads[i]) - { - if ((hEvents[i] = CreateEvent(NULL,FALSE,FALSE,NULL)) == NULL || (hThreads[i] = (void *)THREAD(thread_WaitSelect,i)) == NULL) - { - hThreads[i] = 0; - write_log ("BSDSOCK: ERROR - Thread/Event creation failed - error code: %d\n",GetLastError()); - seterrno(sb,12); // ENOMEM - sb->resultval = -1; - return; - } - - // this should improve responsiveness - SetThreadPriority(hThreads[i],THREAD_PRIORITY_TIME_CRITICAL); - break; - } - } - } - - if (i >= MAX_SELECT_THREADS) write_log ("BSDSOCK: ERROR - Too many select()s\n"); - else - { - SOCKET newsock = INVALID_SOCKET; - - threadargs[i] = (uae_u32 *)&sb; - - SetEvent(hEvents[i]); - - m68k_dreg (®s, 0) = (((uae_u32)1)<signal)|sb->eintrsigs|wssigs; - sigs = CallLib (get_long (4),-0x13e); // Wait() -/* - if ((1<signal) & sigs) - { // 2.3.2002/SR Fix for AmiFTP -> Thread is ready, no need to Abort - sb->needAbort = 0; - } -*/ - if (sb->needAbort) - { - if ((newsock = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)) == INVALID_SOCKET) - write_log ("BSDSOCK: ERROR - Cannot create socket: %d\n",WSAGetLastError()); - shutdown(sb->sockAbort,1); - if (newsock != sb->sockAbort) - { - shutdown(sb->sockAbort,1); - closesocket(sb->sockAbort); - } - } - - WaitForSingleObject(sb->hEvent,INFINITE); - - CANCELSIGNAL; - - if (newsock != INVALID_SOCKET) sb->sockAbort = newsock; - - if( sigmp ) - { - put_long (sigmp,sigs & wssigs); - - if (sigs & sb->eintrsigs) - { - TRACE(("[interrupted]\n")); - sb->resultval = -1; - seterrno(sb,4); // EINTR - } - else if (sigs & wssigs) - { - TRACE(("[interrupted by signals 0x%08lx]\n",sigs & wssigs)); - if (readfds) fd_zero(readfds,nfds); - if (writefds) fd_zero(writefds,nfds); - if (exceptfds) fd_zero(exceptfds,nfds); - seterrno(sb,0); - sb->resultval = 0; - } - if (sb->resultval >= 0) - { - TRACE(("%d\n",sb->resultval)); - } - else - { - TRACE(("%d errno %d\n",sb->resultval,sb->sb_errno)); - } - - } - else TRACE(("%d\n",sb->resultval)); - } -} - -uae_u32 host_Inet_NtoA(SB, uae_u32 in) -{ - char *addr; - struct in_addr ina; - uae_u32 scratchbuf; - - *(uae_u32 *)&ina = htonl(in); - - TRACE(("Inet_NtoA(%lx) -> ",in)); - - if ((addr = inet_ntoa(ina)) != NULL) - { - scratchbuf = m68k_areg (®s, 6)+offsetof(struct UAEBSDBase,scratchbuf); - strncpyha(scratchbuf,addr,SCRATCHBUFSIZE); - TRACE(("%s\n",addr)); - return scratchbuf; - } - else SETERRNO; - - TRACE(("failed (%d)\n",sb->sb_errno)); - - return 0; -} - -uae_u32 host_inet_addr(uae_u32 cp) -{ - uae_u32 addr; - char *cp_rp; - - cp_rp = get_real_address (cp); - - addr = htonl(inet_addr(cp_rp)); - - TRACE(("inet_addr(%s) -> 0x%08lx\n",cp_rp,addr)); - - return addr; -} - -int isfullscreen (void); -BOOL CheckOnline(SB) - { - DWORD dwFlags; - BOOL bReturn = TRUE; - if (InternetGetConnectedState(&dwFlags,0) == FALSE) - { // Internet is offline - if (InternetAttemptConnect(0) != ERROR_SUCCESS) - { // Show Dialer window - sb->sb_errno = 10001; - sb->sb_herrno = 1; - bReturn = FALSE; - // No success or aborted - } - if (isfullscreen()) - { - ShowWindow (hAmigaWnd, SW_RESTORE); - SetActiveWindow(hAmigaWnd); - } - } - return(bReturn); - } - -static unsigned int __stdcall thread_get(void *index2) -{ - uae_u32 index = (uae_u32)index2; - unsigned int result = 0; - uae_u32 *args; - uae_u32 name; - uae_u32 namelen; - long addrtype; - char *name_rp; - char *buf; - - - SB; - - for (;;) - { - WaitForSingleObject(hGetEvents[index],INFINITE); - if (threadGetargs[index] == -1) - { - threadGetargs[index] = NULL; - } - if ((args = threadGetargs[index]) != NULL ) - { - sb = (struct socketbase *)*args; - if (args[1] == 0) - { // gethostbyname or gethostbyaddr - struct hostent *host; - name = args[2]; - namelen = args[3]; - addrtype = args[4]; - buf = (char*) args[5]; - name_rp = get_real_address (name); - - if (strchr(name_rp,'.') == 0 || CheckOnline(sb) == TRUE) - { // Local Address or Internet Online ? - if (addrtype == -1) - { - host = gethostbyname(name_rp); - } - else - { - host = gethostbyaddr(name_rp,namelen,addrtype); - } - if (threadGetargs[index] != -1) - { // No CTRL-C Signal - if (host == 0) - { - // Error occured - SETERRNO; - TRACE(("failed (%d) - ",sb->sb_errno)); - } - else - { - seterrno(sb,0); - memcpy(buf,host,sizeof(HOSTENT)); - } - } - } - } - if (args[1] == 1) - { // getprotobyname - struct protoent *proto; - - name = args[2]; - buf = (char*) args[5]; - name_rp = get_real_address (name); - proto = getprotobyname (name_rp); - if (threadGetargs[index] != -1) - { // No CTRL-C Signal - if (proto == 0) - { - // Error occured - SETERRNO; - TRACE(("failed (%d) - ",sb->sb_errno)); - } - else - { - seterrno(sb,0); - memcpy(buf,proto,sizeof(struct protoent)); - } - } - } - if (args[1] == 2) - { // getservbyport and getservbyname - uae_u32 nameport; - uae_u32 proto; - uae_u32 type; - char *proto_rp = 0; - struct servent *serv; - - nameport = args[2]; - proto = args[3]; - type = args[4]; - buf = (char*) args[5]; - - if (proto) proto_rp = get_real_address (proto); - - if (type) - { - serv = getservbyport(nameport,proto_rp); - } - else - { - name_rp = get_real_address (nameport); - serv = getservbyname(name_rp,proto_rp); - } - if (threadGetargs[index] != -1) - { // No CTRL-C Signal - if (serv == 0) - { - // Error occured - SETERRNO; - TRACE(("failed (%d) - ",sb->sb_errno)); - } - else - { - seterrno(sb,0); - memcpy(buf,serv,sizeof(struct servent)); - } - } - } - - - - - TRACE(("-> ")); - - if (threadGetargs[index] != -1) - SETSIGNAL; - - threadGetargs[index] = NULL; - - } - } -#ifndef __GNUC__ - _endthreadex( result ); -#endif - return result; -} - - -void host_gethostbynameaddr(SB, uae_u32 name, uae_u32 namelen, long addrtype) -{ - HOSTENT *h; - int size, numaliases = 0, numaddr = 0; - uae_u32 aptr; - char *name_rp; - int i; - - uae_u32 args[6]; - - uae_u32 addr; - uae_u32 *addr_list[2]; - - char buf[MAXGETHOSTSTRUCT]; - unsigned int wMsg = 0; - - - - -// char on = 1; -// InternetSetOption(0,INTERNET_OPTION_SETTINGS_CHANGED,&on,strlen(&on)); -// Do not use: Causes locks with some machines - - name_rp = get_real_address (name); - - - if (addrtype == -1) - { - TRACE(("gethostbyname(%s) -> ",name_rp)); - - // workaround for numeric host "names" - if ((addr = inet_addr(name_rp)) != INADDR_NONE) - { - seterrno(sb,0); - ((HOSTENT *)buf)->h_name = name_rp; - ((HOSTENT *)buf)->h_aliases = NULL; - ((HOSTENT *)buf)->h_addrtype = AF_INET; - ((HOSTENT *)buf)->h_length = 4; - ((HOSTENT *)buf)->h_addr_list = (char **)&addr_list; - addr_list[0] = &addr; - addr_list[1] = NULL; - - goto kludge; - } - } - else - { - TRACE(("gethostbyaddr(0x%lx,0x%lx,%ld) -> ",name,namelen,addrtype)); - } - - args[0] = (uae_u32) sb; - args[1] = 0; - args[2] = name; - args[3] = namelen; - args[4] = addrtype; - args[5] = (uae_u32) &buf[0]; - - for (i = 0; i < MAX_GET_THREADS; i++) - { - if (threadGetargs[i] == -1) - { - threadGetargs[i] = 0; - } - if (hGetThreads[i] && !threadGetargs[i]) break; - } - - if (i >= MAX_GET_THREADS) - { - for (i = 0; i < MAX_GET_THREADS; i++) - { - if (!hGetThreads[i]) - { - if ((hGetEvents[i] = CreateEvent(NULL,FALSE,FALSE,NULL)) == NULL || (hGetThreads[i] = (void *)THREAD(thread_get,i)) == NULL) - { - hGetThreads[i] = 0; - write_log ("BSDSOCK: ERROR - Thread/Event creation failed - error code: %d\n",GetLastError()); - seterrno(sb,12); // ENOMEM - sb->resultval = -1; - return; - } - break; - } - } - } - - if (i >= MAX_GET_THREADS) write_log ("BSDSOCK: ERROR - Too many gethostbyname()s\n"); - else - { - bsdsetpriority (hGetThreads[i]); - threadGetargs[i] = (uae_u32 *)&args[0]; - - SetEvent(hGetEvents[i]); - } - sb->eintr = 0; - while ( threadGetargs[i] != 0 && sb->eintr == 0) - { - WAITSIGNAL; - if (sb->eintr == 1) - threadGetargs[i] = -1; - } - - CANCELSIGNAL; - - if (!sb->sb_errno) - { -kludge: - h = (HOSTENT *)buf; - - // compute total size of hostent - size = 28; - if (h->h_name != NULL) size += strlen(h->h_name)+1; - - if (h->h_aliases != NULL) - while (h->h_aliases[numaliases]) size += strlen(h->h_aliases[numaliases++])+5; - - if (h->h_addr_list != NULL) - { - while (h->h_addr_list[numaddr]) numaddr++; - size += numaddr*(h->h_length+4); - } - - if (sb->hostent) - { - uae_FreeMem( sb->hostent, sb->hostentsize ); - } - - sb->hostent = uae_AllocMem( size, 0 ); - - if (!sb->hostent) - { - write_log ("BSDSOCK: WARNING - gethostby%s() ran out of Amiga memory (couldn't allocate %ld bytes) while returning result of lookup for '%s'\n",addrtype == -1 ? "name" : "addr",size,(char *)name); - seterrno(sb,12); // ENOMEM - return; - } - - sb->hostentsize = size; - - aptr = sb->hostent+28+numaliases*4+numaddr*4; - - // transfer hostent to Amiga memory - put_long (sb->hostent+4,sb->hostent+20); - put_long (sb->hostent+8,h->h_addrtype); - put_long (sb->hostent+12,h->h_length); - put_long (sb->hostent+16,sb->hostent+24+numaliases*4); - - for (i = 0; i < numaliases; i++) put_long (sb->hostent+20+i*4,addstr(&aptr,h->h_aliases[i])); - put_long (sb->hostent+20+numaliases*4,0); - for (i = 0; i < numaddr; i++) put_long (sb->hostent+24+(numaliases+i)*4,addmem(&aptr,h->h_addr_list[i],h->h_length)); - put_long (sb->hostent+24+numaliases*4+numaddr*4,0); - put_long (sb->hostent,aptr); - addstr(&aptr,h->h_name); - - TRACE(("OK (%s)\n",h->h_name)); - seterrno(sb,0); - } - else - { - TRACE(("failed (%d/%d)\n",sb->sb_errno,sb->sb_herrno)); - } - -} - -void host_getprotobyname(SB, uae_u32 name) -{ - PROTOENT *p; - int size, numaliases = 0; - uae_u32 aptr; - char *name_rp; - int i; - - uae_u32 args[6]; - - - char buf[MAXGETHOSTSTRUCT]; - - name_rp = get_real_address (name); - - TRACE(("getprotobyname(%s) -> ",name_rp)); - - args[0] = (uae_u32) sb; - args[1] = 1; - args[2] = name; - args[5] = (uae_u32) &buf[0]; - - for (i = 0; i < MAX_GET_THREADS; i++) - { - if (threadGetargs[i] == -1) - { - threadGetargs[i] = 0; - } - if (hGetThreads[i] && !threadGetargs[i]) break; - } - if (i >= MAX_GET_THREADS) - { - for (i = 0; i < MAX_GET_THREADS; i++) - { - if (!hGetThreads[i]) - { - if ((hGetEvents[i] = CreateEvent(NULL,FALSE,FALSE,NULL)) == NULL || (hGetThreads[i] = (void *)THREAD(thread_get,i)) == NULL) - { - hGetThreads[i] = 0; - write_log ("BSDSOCK: ERROR - Thread/Event creation failed - error code: %d\n",GetLastError()); - seterrno(sb,12); // ENOMEM - sb->resultval = -1; - return; - } - break; - } - } - } - - if (i >= MAX_GET_THREADS) write_log ("BSDSOCK: ERROR - Too many getprotobyname()s\n"); - else - { - bsdsetpriority (hGetThreads[i]); - - threadGetargs[i] = (uae_u32 *)&args[0]; - - SetEvent(hGetEvents[i]); - } - - sb->eintr = 0; - while ( threadGetargs[i] != 0 && sb->eintr == 0) - { - WAITSIGNAL; - if (sb->eintr == 1) - threadGetargs[i] = -1; - } - - CANCELSIGNAL; - - - if (!sb->sb_errno) - { - p = (PROTOENT *)buf; - - // compute total size of protoent - size = 16; - if (p->p_name != NULL) size += strlen(p->p_name)+1; - - if (p->p_aliases != NULL) - while (p->p_aliases[numaliases]) size += strlen(p->p_aliases[numaliases++])+5; - - if (sb->protoent) - { - uae_FreeMem( sb->protoent, sb->protoentsize ); - } - - sb->protoent = uae_AllocMem( size, 0 ); - - if (!sb->protoent) - { - write_log ("BSDSOCK: WARNING - getprotobyname() ran out of Amiga memory (couldn't allocate %ld bytes) while returning result of lookup for '%s'\n",size,(char *)name); - seterrno(sb,12); // ENOMEM - return; - } - - sb->protoentsize = size; - - aptr = sb->protoent+16+numaliases*4; - - // transfer protoent to Amiga memory - put_long (sb->protoent+4,sb->protoent+12); - put_long (sb->protoent+8,p->p_proto); - - for (i = 0; i < numaliases; i++) put_long (sb->protoent+12+i*4,addstr(&aptr,p->p_aliases[i])); - put_long (sb->protoent+12+numaliases*4,0); - put_long (sb->protoent,aptr); - addstr(&aptr,p->p_name); - TRACE(("OK (%s, %d)\n",p->p_name,p->p_proto)); - seterrno(sb,0); - } - else - { - TRACE(("failed (%d)\n",sb->sb_errno)); - } - -} - - -void host_getservbynameport(SB, uae_u32 nameport, uae_u32 proto, uae_u32 type) -{ - SERVENT *s; - int size, numaliases = 0; - uae_u32 aptr; - char *name_rp = NULL, *proto_rp = NULL; - int i; - - char buf[MAXGETHOSTSTRUCT]; - uae_u32 args[6]; - - if (proto) proto_rp = get_real_address (proto); - - if (type) - { - TRACE(("getservbyport(%d,%s) -> ",nameport,proto_rp ? proto_rp : "NULL")); - } - else - { - name_rp = get_real_address (nameport); - TRACE(("getservbyname(%s,%s) -> ",name_rp,proto_rp ? proto_rp : "NULL")); - } - - args[0] = (uae_u32) sb; - args[1] = 2; - args[2] = nameport; - args[3] = proto; - args[4] = type; - args[5] = (uae_u32) &buf[0]; - - for (i = 0; i < MAX_GET_THREADS; i++) - { - if (threadGetargs[i] == -1) - { - threadGetargs[i] = 0; - } - if (hGetThreads[i] && !threadGetargs[i]) break; - } - if (i >= MAX_GET_THREADS) - { - for (i = 0; i < MAX_GET_THREADS; i++) - { - if (!hGetThreads[i]) - { - if ((hGetEvents[i] = CreateEvent(NULL,FALSE,FALSE,NULL)) == NULL || (hGetThreads[i] = (void *)THREAD(thread_get,i)) == NULL) - { - hGetThreads[i] = 0; - write_log ("BSDSOCK: ERROR - Thread/Event creation failed - error code: %d\n",GetLastError()); - seterrno(sb,12); // ENOMEM - sb->resultval = -1; - return; - } - - break; - } - } - } - - if (i >= MAX_GET_THREADS) write_log ("BSDSOCK: ERROR - Too many getprotobyname()s\n"); - else - { - bsdsetpriority (hGetThreads[i]); - - threadGetargs[i] = (uae_u32 *)&args[0]; - - SetEvent(hGetEvents[i]); - } - - sb->eintr = 0; - while ( threadGetargs[i] != 0 && sb->eintr == 0) - { - WAITSIGNAL; - if (sb->eintr == 1) - threadGetargs[i] = -1; - } - - CANCELSIGNAL; - - if (!sb->sb_errno) - { - s = (SERVENT *)buf; - - // compute total size of servent - size = 20; - if (s->s_name != NULL) size += strlen(s->s_name)+1; - if (s->s_proto != NULL) size += strlen(s->s_proto)+1; - - if (s->s_aliases != NULL) - while (s->s_aliases[numaliases]) size += strlen(s->s_aliases[numaliases++])+5; - - if (sb->servent) - { - uae_FreeMem( sb->servent, sb->serventsize ); - } - - sb->servent = uae_AllocMem( size, 0 ); - - if (!sb->servent) - { - write_log ("BSDSOCK: WARNING - getservby%s() ran out of Amiga memory (couldn't allocate %ld bytes)\n",type ? "port" : "name",size); - seterrno(sb,12); // ENOMEM - return; - } - - sb->serventsize = size; - - aptr = sb->servent+20+numaliases*4; - - // transfer servent to Amiga memory - put_long (sb->servent+4,sb->servent+16); - put_long (sb->servent+8,(unsigned short)htons(s->s_port)); - - for (i = 0; i < numaliases; i++) put_long (sb->servent+16+i*4,addstr(&aptr,s->s_aliases[i])); - put_long (sb->servent+16+numaliases*4,0); - put_long (sb->servent,aptr); - addstr(&aptr,s->s_name); - put_long (sb->servent+12,aptr); - addstr(&aptr,s->s_proto); - - TRACE(("OK (%s, %d)\n",s->s_name,(unsigned short)htons(s->s_port))); - seterrno(sb,0); - } - else - { - TRACE(("failed (%d)\n",sb->sb_errno)); - } - -} - - - -uae_u32 host_gethostname(uae_u32 name, uae_u32 namelen) -{ - return gethostname(get_real_address (name),namelen); -} - -#endif -#endif diff --git a/src/od-win32/fsdb_win32.c b/src/od-win32/fsdb_win32.c deleted file mode 100644 index 3dbb978..0000000 --- a/src/od-win32/fsdb_win32.c +++ /dev/null @@ -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 - -/* 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 diff --git a/src/od-win32/hardfile_win32.c b/src/od-win32/hardfile_win32.c deleted file mode 100644 index 6a514d9..0000000 --- a/src/od-win32/hardfile_win32.c +++ /dev/null @@ -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 -#include - -#ifdef WINDDK -#include -#include -#include -#include // Guid definition -#include // Device guids -#include // for SetupDiXxx functions. -#include // 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 diff --git a/src/od-win32/hrtimer.h b/src/od-win32/hrtimer.h deleted file mode 100644 index c803ecc..0000000 --- a/src/od-win32/hrtimer.h +++ /dev/null @@ -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 diff --git a/src/od-win32/main.c b/src/od-win32/main.c deleted file mode 100644 index d291837..0000000 --- a/src/od-win32/main.c +++ /dev/null @@ -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 - -#include "uae.h" -#include "options.h" -#include "debug.h" - -#include - -/* - * Handle break signal - */ -#include - -#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) -{ -} diff --git a/src/od-win32/memory.c b/src/od-win32/memory.c deleted file mode 100644 index 2aff956..0000000 --- a/src/od-win32/memory.c +++ /dev/null @@ -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 diff --git a/src/od-win32/memory_uae.h b/src/od-win32/memory_uae.h deleted file mode 100644 index 5d21b6c..0000000 --- a/src/od-win32/memory_uae.h +++ /dev/null @@ -1,11 +0,0 @@ - /* - * UAE - The Un*x Amiga Emulator - * - * See if this OS has mmap or equivalent - * - * Copyright 1996 Bernd Schmidt - */ - -#undef USE_MAPPED_MEMORY -#undef CAN_MAP_MEMORY - diff --git a/src/od-win32/posixemu.c b/src/od-win32/posixemu.c deleted file mode 100644 index 65d739b..0000000 --- a/src/od-win32/posixemu.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * UAE - The Un*x Amiga Emulator - * - * Win32 interface - * - * Copyright 1997 Mathias Ortmann - */ - -#include "sysconfig.h" -#include "sysdeps.h" - -#include -#include - -#include "posixemu.h" -#include "filesys.h" - -static DWORD lasterror; - - -#ifndef HAVE_GETTIMEOFDAY -/* Our Win32 implementation of this function */ -void gettimeofday (struct timeval *tv, void *blah) -{ - struct timeb time; - ftime (&time); - - tv->tv_sec = time.time; - tv->tv_usec = time.millitm * 1000; -} -#endif - -#ifndef HAVE_TRUNCATE -int truncate (const char *name, long int len) -{ - HANDLE hFile; - BOOL bResult = FALSE; - int result = -1; - - if ((hFile = CreateFile (name, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE) { - if (SetFilePointer (hFile, len, NULL, FILE_BEGIN) == (DWORD)len) { - if (SetEndOfFile (hFile) == TRUE) - result = 0; - } else { - write_log ("SetFilePointer() failure for %s to posn %d\n", name, len); - } - CloseHandle (hFile); - } else { - write_log ( "CreateFile() failed to open %s\n", name ); - } - - if (result == -1) - lasterror = GetLastError (); - return result; -} -#endif - -int isspecialdrive (const char *name) -{ - DWORD v; - DWORD err; - - DWORD last = SetErrorMode (SEM_FAILCRITICALERRORS); - - v = GetFileAttributes (name); - err = GetLastError (); - - SetErrorMode (last); - - if (v != INVALID_FILE_ATTRIBUTES) - return 0; - if (err == ERROR_NOT_READY) - return 1; - if (err) - return -1; - return 0; -} diff --git a/src/od-win32/posixemu.h b/src/od-win32/posixemu.h deleted file mode 100644 index 709e1a0..0000000 --- a/src/od-win32/posixemu.h +++ /dev/null @@ -1,17 +0,0 @@ -/* posixemu prototypes */ -#ifndef __POSIXEMU_H__ -#define __POSIXEMU_H__ - -void fname_atow (const char *src, char *dst, int size); -void fname_wtoa (unsigned char *ptr); -int w32fopendel(char *name, char *mode, int delflag); - -#ifndef HAVE_GETTIMEOFDAY -void gettimeofday (struct timeval *tv, void *blah); -#endif - -#ifndef HAVE_TRUNCATE -int truncate (const char *name, long int len); -#endif - -#endif diff --git a/src/od-win32/win32.h b/src/od-win32/win32.h deleted file mode 100644 index d4e8adb..0000000 --- a/src/od-win32/win32.h +++ /dev/null @@ -1,10 +0,0 @@ - /* - * UAE - The Un*x Amiga Emulator - * - * Win32-specific header file - * - * (c) 1997-1999 Mathias Ortmann - * (c) 1998-2001 Brian King - */ - -extern int os_winnt, os_winnt_admin; diff --git a/src/od-win32/writelog.c b/src/od-win32/writelog.c deleted file mode 100644 index 0b0f3d2..0000000 --- a/src/od-win32/writelog.c +++ /dev/null @@ -1,131 +0,0 @@ - -#include "sysconfig.h" -#include "sysdeps.h" - -#include - -#define SHOW_CONSOLE 0 - -static int consoleopen = 0; -static HANDLE stdinput; -static HANDLE stdoutput; - -FILE *debugfile = NULL; -int console_logging; - -#define WRITE_LOG_BUF_SIZE 4096 - -/* console functions for debugger */ - -static void openconsole (void) -{ - if (consoleopen) - return; - - AllocConsole (); - stdinput = GetStdHandle (STD_INPUT_HANDLE); - stdoutput = GetStdHandle (STD_OUTPUT_HANDLE); - SetConsoleMode (stdinput, ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | - ENABLE_ECHO_INPUT | ENABLE_PROCESSED_OUTPUT); - consoleopen = 1; -} - -void console_out (const char *format,...) -{ - va_list parms; - char buffer[WRITE_LOG_BUF_SIZE]; - DWORD temp; - - va_start (parms, format); - _vsnprintf (buffer, WRITE_LOG_BUF_SIZE - 1, format, parms); - va_end (parms); - - openconsole (); - - WriteConsole (stdoutput, buffer, strlen (buffer), &temp, 0); -} - -int console_get (char *out, int maxlen) -{ - DWORD len; - DWORD totallen = 0; - - while (maxlen > 0) { - ReadConsole (stdinput, out, 1, &len, 0); - if (*out == 13) - break; - out++; - maxlen--; - totallen++; - } - *out = 0; - return totallen; -} - -void console_flush (void) -{ -} - -void write_dlog (const char *format, ...) -{ - int count; - DWORD numwritten; - char buffer[WRITE_LOG_BUF_SIZE]; - - va_list parms; - va_start (parms, format); - count = _vsnprintf (buffer, WRITE_LOG_BUF_SIZE - 1, format, parms); - if (SHOW_CONSOLE || console_logging) { - openconsole (); - WriteConsole (stdoutput, buffer, strlen (buffer), &numwritten, 0); - } - if (debugfile) { - fprintf (debugfile, buffer); - fflush (debugfile); - } - va_end (parms); -} - -void write_log (const char *format, ...) -{ - int count; - DWORD numwritten; - char buffer[WRITE_LOG_BUF_SIZE]; - - va_list parms; - va_start (parms, format); - count = _vsnprintf (buffer, WRITE_LOG_BUF_SIZE - 1, format, parms); - if (SHOW_CONSOLE || console_logging) { - openconsole (); - WriteConsole (stdoutput, buffer, strlen(buffer), &numwritten, 0); - } - if (debugfile) { - fprintf (debugfile, buffer); - fflush (debugfile); - } - va_end (parms); -} - -void flush_log (void) -{ - if (debugfile) - fflush (debugfile); -} - -void f_out (void *f, const char *format, ...) -{ - int count; - DWORD numwritten; - char buffer[WRITE_LOG_BUF_SIZE]; - - va_list parms; - va_start (parms, format); - count = _vsnprintf (buffer, WRITE_LOG_BUF_SIZE - 1, format, parms); - if (f == 0) - write_log (buffer); - else { - openconsole (); - WriteConsole (stdoutput, buffer, strlen (buffer), &numwritten, 0); - va_end (parms); - } -} diff --git a/src/picasso96.c b/src/picasso96.c index 02f3c5d..066b36f 100644 --- a/src/picasso96.c +++ b/src/picasso96.c @@ -54,6 +54,8 @@ #include "gcc_warnings.h" int debug_rtg_blitter = 3; +int screen_is_picasso = 0; +int screen_was_picasso = 0; #define NOBLITTER (0 || !(debug_rtg_blitter & 1)) #define NOBLITTER_BLIT (0 || !(debug_rtg_blitter & 2)) @@ -601,8 +603,6 @@ void picasso_trigger_vblank (void) return; put_long (uaegfx_base + CARD_IRQPTR, ABI_interrupt + PSSO_BoardInfo_SoftInterrupt); put_byte (uaegfx_base + CARD_IRQFLAG, 1); - if (currprefs.win32_rtgvblankrate != 0) - INTREQ (0x8000 | 0x0008); } static bool rtg_render (void) @@ -633,7 +633,6 @@ static void picasso_handle_vsync2 (void) bool rendered = false; if (vsync < 0) { - vsync_busywait_end (NULL); vsync_busywait_do (NULL, false, false); } @@ -658,10 +657,6 @@ static void picasso_handle_vsync2 (void) if (thisisvsync) picasso_trigger_vblank (); - if (vsync < 0) { - vsync_busywait_start (); - } - if (thisisvsync && !rendered) rtg_show (); } @@ -683,8 +678,6 @@ void picasso_handle_vsync (void) if (vsync < 0) { p96hsync = 0; picasso_handle_vsync2 (); - } else if (currprefs.win32_rtgvblankrate == 0) { - picasso_handle_vsync2 (); } } @@ -704,9 +697,6 @@ void picasso_handle_hsync (void) return; } - if (currprefs.win32_rtgvblankrate == 0) - return; - p96hsync++; if (p96hsync >= p96syncrate) { if (!picasso_on) { @@ -1959,14 +1949,14 @@ static void inituaegfx (uaecptr ABI) write_log (_T("P96: Blitter disabled in devs:monitors/uaegfx!\n")); flags |= BIF_BLITTER | BIF_NOMEMORYMODEMIX; flags &= ~BIF_HARDWARESPRITE; - if (currprefs.gfx_api && D3D_goodenough () > 0 && USE_HARDWARESPRITE && currprefs.rtg_hardwaresprite) { +/* if (currprefs.gfx_api && D3D_goodenough () > 0 && USE_HARDWARESPRITE && currprefs.rtg_hardwaresprite) { hwsprite = 1; flags |= BIF_HARDWARESPRITE; write_log (_T("P96: Hardware sprite support enabled\n")); - } else { + } else {*/ hwsprite = 0; write_log (_T("P96: Hardware sprite support disabled\n")); - } +// } if (currprefs.rtg_hardwareinterrupt && !uaegfx_old) flags |= BIF_VBLANKINTERRUPT; if (!(flags & BIF_INDISPLAYCHAIN)) { @@ -3102,17 +3092,6 @@ static uae_u32 REGPARAM2 picasso_SetDisplay (TrapContext *ctx) void init_hz_p96 (void) { - if (currprefs.win32_rtgvblankrate < 0 || isvsync_rtg ()) { - double rate = getcurrentvblankrate (); - if (rate < 0) - p96vblank = vblank_hz; - else - p96vblank = getcurrentvblankrate (); - } else if (currprefs.win32_rtgvblankrate == 0) { - p96vblank = vblank_hz; - } else { - p96vblank = currprefs.win32_rtgvblankrate; - } if (p96vblank <= 0) p96vblank = 60; if (p96vblank >= 300) diff --git a/src/sana2.c b/src/sana2.c index 84d51f8..70c527c 100644 --- a/src/sana2.c +++ b/src/sana2.c @@ -273,8 +273,6 @@ static uae_u32 REGPARAM2 dev_close_2 (TrapContext *context) write_log (_T("%s:%d close with unknown request %08X!?\n"), SANA2NAME, pdev->unit, request); return 0; } - if (log_net) - write_log (_T("%s:%d close, open=%d req=%08X\n"), SANA2NAME, pdev->unit, dev->opencnt, request); put_long (request + 24, 0); dev->opencnt--; pdev->inuse = 0; @@ -310,8 +308,6 @@ static int openfail (uaecptr ioreq, int error) put_long (ioreq + 20, -1); put_byte (ioreq + 31, error); put_long (ioreq + 32, 0); /* io_device */ - if (log_net) - write_log (_T("-> failed with error %d\n"), error); return (uae_u32)-1; } @@ -422,9 +418,6 @@ static int add_async_request (struct s2devstruct *dev, uaecptr request) { struct asyncreq *ar, *ar2; - if (log_net) - write_log (_T("%s:%d async request %x added\n"), getdevname(), dev->unit, request); - uae_sem_wait (&async_sem); ar = xcalloc (struct asyncreq, 1); ar->request = request; @@ -455,8 +448,6 @@ static int release_async_request (struct s2devstruct *dev, uaecptr request) prevar->next = ar->next; uae_sem_post (&async_sem); xfree (ar); - if (log_net) - write_log (_T("%s:%d async request %x removed\n"), getdevname(), dev->unit, request); return 1; } prevar = ar; @@ -482,8 +473,6 @@ static void abort_async (struct s2devstruct *dev, uaecptr request) write_log (_T("%s:%d: abort async but no request %x found!\n"), getdevname(), dev->unit, request); return; } - if (log_net) - write_log (_T("%s:%d asyncronous request=%08X aborted\n"), getdevname(), dev->unit, request); do_abort_async (dev, request); } @@ -491,8 +480,6 @@ static void signalasync (struct s2devstruct *dev, struct asyncreq *ar, int actua { uaecptr request = ar->request; int command = get_word (request + 28); - if (log_net) - write_log (_T("%s:%d CMD=%d async request %x completed\n"), getdevname(), dev->unit, command, request); put_long (request + 32, actual); put_byte (request + 31, err); ar->ready = 1; @@ -699,11 +686,6 @@ void uaenet_gotdata (struct s2devstruct *dev, const uae_u8 *d, int len) type = (d[12] << 8) | d[13]; s2p = createreadpacket (dev, d, len); - if (log_net) - write_log (_T("<-DST:%02X.%02X.%02X.%02X.%02X.%02X SRC:%02X.%02X.%02X.%02X.%02X.%02X E=%04X L=%d P=%p\n"), - d[0], d[1], d[2], d[3], d[4], d[5], - d[6], d[7], d[8], d[9], d[10], d[11], - type, len, s2p); uae_sem_wait (&async_sem); if (!dev->readqueue) { dev->readqueue = s2p; @@ -773,11 +755,6 @@ static int uaenet_getdata (struct s2devstruct *dev, uae_u8 *d, int *len) if (ars2p->request == request) { *len = ars2p->s2p->len; memcpy (d, ars2p->s2p->data, *len); - if (log_net) - write_log (_T("->DST:%02X.%02X.%02X.%02X.%02X.%02X SRC:%02X.%02X.%02X.%02X.%02X.%02X E=%04X S=%d\n"), - d[0], d[1], d[2], d[3], d[4], d[5], - d[6], d[7], d[8], d[9], d[10], d[11], - packettype, *len); gotit = 1; dev->packetssent++; signalasync (dev, ar, *len, 0); @@ -808,8 +785,6 @@ static uae_u32 REGPARAM2 dev_open_2 (TrapContext *context) return openfail (ioreq, IOERR_OPENFAIL); if (!initint(context)) return openfail (ioreq, IOERR_SELFTEST); - if (log_net) - write_log ("opening %s:%d opencnt=%d ioreq=%08X\n", SANA2NAME, unit, dev->opencnt, ioreq); if (get_word (ioreq + 0x12) < IOSTDREQ_SIZE) return openfail (ioreq, IOERR_BADLENGTH); if ((flags & SANA2OPF_PROM) && dev->opencnt > 0) @@ -892,9 +867,6 @@ static uae_u32 REGPARAM2 dev_open_2 (TrapContext *context) break; } } - if (log_net) - write_log ("%s:%d CTB=%08x CFB=%08x PF=%08x\n", - getdevname(), unit, pdev->copytobuff, pdev->copyfrombuff, pdev->packetfilter); m68k_dreg (regs, 0) = dev->td->mtu + ETH_HEADER_SIZE + 2; m68k_dreg (regs, 1) = 1; pdev->tempbuf = CallLib (context, get_long (4), -0xC6); /* AllocMem */ @@ -985,13 +957,6 @@ static int dev_do_io_2 (struct s2devstruct *dev, uaecptr request, int quick) int async = 0; struct priv_s2devstruct *pdev = getps2devstruct (request); - if (log_net) - write_log (_T("S2: C=%02d T=%04X S=%02X%02X%02X%02X%02X%02X D=%02X%02X%02X%02X%02X%02X L=%d D=%08X SD=%08X BM=%08X\n"), - command, packettype, - get_byte (srcaddr + 0), get_byte (srcaddr + 1), get_byte (srcaddr + 2), get_byte (srcaddr + 3), get_byte (srcaddr + 4), get_byte (srcaddr + 5), - get_byte (dstaddr + 0), get_byte (dstaddr + 1), get_byte (dstaddr + 2), get_byte (dstaddr + 3), get_byte (dstaddr + 4), get_byte (dstaddr + 5), - datalength, data, statdata, buffermgmt); - if (command == CMD_READ || command == S2_READORPHAN || command == CMD_WRITE || command == S2_BROADCAST || command == S2_MULTICAST) { if (!pdev->copyfrombuff || !pdev->copytobuff) { io_error = S2ERR_BAD_ARGUMENT; @@ -1039,8 +1004,6 @@ static int dev_do_io_2 (struct s2devstruct *dev, uaecptr request, int quick) case CMD_FLUSH: dev->flush_timeout_cnt = 0; dev->flush_timeout = FLUSH_TIMEOUT; - if (log_net) - write_log (_T("CMD_FLUSH started %08x\n"), request); uae_sem_wait (&async_sem); flush (pdev); uae_sem_post (&async_sem); @@ -1219,8 +1182,6 @@ toobig: } end: - if (log_net && (io_error || wire_error)) - write_log (_T("-> %d (%d)\n"), io_error, wire_error); put_long (request + 32, wire_error); put_byte (request + 31, io_error); return async; @@ -1368,8 +1329,6 @@ static void *dev_thread (void *devs) static uae_u32 REGPARAM2 dev_init_2 (TrapContext *context) { uae_u32 base = m68k_dreg (regs,0); - if (log_net) - write_log (_T("%s init\n"), SANA2NAME); return base; } @@ -1395,8 +1354,6 @@ static uae_u32 REGPARAM2 dev_abortio (TrapContext *context) put_byte (request + 31, 32); return get_byte (request + 31); } - if (log_net) - write_log (_T("%s:%d abortio %08x\n"), getdevname(), dev->unit, request); abort_async (dev, request); return 0; } @@ -1434,15 +1391,11 @@ static uae_u32 REGPARAM2 uaenet_int_handler (TrapContext *ctx) struct priv_s2devstruct *pdev = getps2devstruct (request); if (pdev && pdev->tmp == 0) { if (handleread (ctx, pdev, request, p->data, p->len, command)) { - if (log_net) - write_log (_T("-> %p Accepted, CMD_READ, REQ=%08X LEN=%d\n"), p, request, p->len); write_comm_pipe_u32 (&dev->requests, request, 1); dev->packetsreceived++; gotit = 1; pdev->tmp = 1; } else { - if (log_net) - write_log (_T("-> %p PacketFilter() rejected, CMD_READ, REQ=%08X LEN=%d\n"), p, request, p->len); pdev->tmp = -1; } } @@ -1458,8 +1411,6 @@ static uae_u32 REGPARAM2 uaenet_int_handler (TrapContext *ctx) if (command == S2_READORPHAN) { struct priv_s2devstruct *pdev = getps2devstruct (request); if (pdev && pdev->tmp <= 0) { - if (log_net) - write_log (_T("-> %p Accepted, S2_READORPHAN, REQ=%08X LEN=%d\n"), p, request, p->len); handleread (ctx, pdev, request, p->data, p->len, command); write_comm_pipe_u32 (&dev->requests, request, 1); dev->packetsreceived++; @@ -1472,8 +1423,6 @@ static uae_u32 REGPARAM2 uaenet_int_handler (TrapContext *ctx) ar = ar->next; } if (!gotit) { - if (log_net) - write_log (_T("-> %p packet dropped, LEN=%d\n"), p, p->len); for (j = 0; j < MAX_OPEN_DEVICES; j++) { if (pdevst[j].unit == dev->unit) { if (pdevst[j].tracks[type]) @@ -1521,8 +1470,6 @@ static uae_u32 REGPARAM2 uaenet_int_handler (TrapContext *ctx) } else if (command == CMD_FLUSH) { /* do not reply CMD_FLUSH until all other requests are gone */ if (dev->ar->next == NULL) { - if (log_net) - write_log (_T("CMD_FLUSH replied %08x\n"), request); write_comm_pipe_u32 (&dev->requests, request, 1); uaenet_vsync_requested--; } else { @@ -1589,8 +1536,6 @@ uaecptr netdev_startup (uaecptr resaddr) { if (!currprefs.sana2) return resaddr; - if (log_net) - write_log (_T("netdev_startup(0x%x)\n"), resaddr); /* Build a struct Resident. This will set up and initialize * the uaescsi.device */ put_word (resaddr + 0x0, 0x4AFC); @@ -1613,9 +1558,6 @@ void netdev_install (void) if (!currprefs.sana2) return; - if (log_net) - write_log (_T("netdev_install(): 0x%x\n"), here ()); - uaenet_enumerate_free (td); uaenet_enumerate (&td, NULL); @@ -1716,8 +1658,6 @@ void netdev_start_threads (void) { if (!currprefs.sana2) return; - if (log_net) - write_log (_T("netdev_start_threads()\n")); uae_sem_init (&change_sem, 0, 1); uae_sem_init (&async_sem, 0, 1); } diff --git a/src/savestate.c b/src/savestate.c index 08ae8ae..80bcdfb 100644 --- a/src/savestate.c +++ b/src/savestate.c @@ -66,11 +66,6 @@ #include "disk.h" #include "misc.h" -#ifndef _WIN32 -#define console_out printf -#endif - - int savestate_state = 0; static int savestate_first_capture; @@ -590,7 +585,7 @@ void restore_state (const TCHAR *filename) else if (!_tcscmp (name, _T("FPU "))) end = restore_fpu (chunk); #endif -#ifdef MMU +#ifdef MMUEMU else if (!_tcscmp (name, _T("MMU "))) end = restore_mmu (chunk); #endif @@ -686,7 +681,13 @@ void restore_state (const TCHAR *filename) else if (!_tcscmp (name, _T("CDTV"))) end = restore_cdtv (chunk); else if (!_tcscmp (name, _T("DMAC"))) - end = restore_dmac (chunk); + end = restore_cdtv_dmac (chunk); +#endif +#ifdef SCSI + else if (!_tcscmp (name, _T("DMC2"))) + end = restore_scsi_dmac (chunk); + else if (!_tcscmp (name, _T("SCSI"))) + end = restore_scsi_hd (chunk); #endif #ifdef GAYLE else if (!_tcscmp (name, _T("GAYL"))) @@ -1036,11 +1037,6 @@ static int save_state_internal (struct zfile *f, const TCHAR *description, int c xfree(dst); } len = 30000; - dst = save_log (true, &len); - if (dst) { - save_chunk (f, dst, len, _T("LOG "), comp); - xfree (dst); - } zfile_fwrite (endhunk, 1, 8, f); @@ -1174,30 +1170,6 @@ int savestate_dorewind (int pos) } return 0; } -#if 0 -void savestate_listrewind (void) -{ - int i = replaycounter; - int cnt; - uae_u8 *p; - uae_u32 pc; - - cnt = 1; - for (;;) { - struct staterecord *st; - st = &staterecords[i]; - if (!st->start) - break; - p = st->cpu + 17 * 4; - pc = restore_u32_func (&p); - console_out (_T("%d: PC=%08X %c\n"), cnt, pc, regs.pc == pc ? '*' : ' '); - cnt++; - i--; - if (i < 0) - i += MAX_STATERECORDS; - } -} -#endif void savestate_rewind (void) { @@ -1293,7 +1265,11 @@ void savestate_rewind (void) if (restore_u32_func (&p)) p = restore_cdtv (p); if (restore_u32_func (&p)) - p = restore_dmac (p); + p = restore_cdtv_dmac (p); +#endif +#ifdef SCSCI + if (restore_u32_func (&p)) + p = restore_scsi_dmac (p); #endif #ifdef GAYLE if (restore_u32_func (&p)) @@ -1633,7 +1609,19 @@ retry2: p3 = p; save_u32_func (&p, 0); tlen += 4; - if (save_dmac (&len, p)) { + if (save_cdtv_dmac (&len, p)) { + save_u32_func (&p3, 1); + tlen += len; + p += len; + } +#endif +#ifdef SCSI + if (bufcheck (st, p, 0)) + goto retry; + p3 = p; + save_u32_func (&p, 0); + tlen += 4; + if (save_scsi_dmac (&len, p)) { save_u32_func (&p3, 1); tlen += len; p += len; diff --git a/src/scsi.c b/src/scsi.c index 334c283..a012cfd 100644 --- a/src/scsi.c +++ b/src/scsi.c @@ -19,7 +19,7 @@ static int outcmd[] = { 0x0a, 0x2a, 0x2f, 0xaa, -1 }; static int incmd[] = { 0x03, 0x08, 0x12, 0x1a, 0x25, 0x28, 0x37, 0x42, 0x43, 0xa8, -1 }; static int nonecmd[] = { 0x00, 0x35, -1 }; -int scsi_data_dir(struct scsi_data *sd) +static int scsi_data_dir(struct scsi_data *sd) { int i; uae_u8 cmd; @@ -44,17 +44,55 @@ int scsi_data_dir(struct scsi_data *sd) return -2; } +void scsi_emulate_analyze (struct scsi_data *sd) +{ + int cmd_len, data_len; + + data_len = sd->data_len; + switch (sd->cmd[0]) + { + case 0x0a: + cmd_len = 6; + data_len = sd->cmd[4] * sd->hfd->hfd.ci.blocksize; + break; + case 0x2a: + cmd_len = 10; + data_len = ((sd->cmd[7] << 8) | (sd->cmd[8] << 0)) * (uae_s64)sd->hfd->hfd.ci.blocksize; + break; + case 0xaa: + cmd_len = 12; + data_len = ((sd->cmd[6] << 24) | (sd->cmd[7] << 16) | (sd->cmd[8] << 8) | (sd->cmd[9] << 0)) * (uae_s64)sd->hfd->hfd.ci.blocksize; + break; + + case 0x25: + case 0x28: + case 0x35: + cmd_len = 10; + break; + case 0xa8: + cmd_len = 12; + break; + default: + cmd_len = 6; + break; + } + sd->cmd_len = cmd_len; + sd->data_len = data_len; + sd->direction = scsi_data_dir (sd); +} + void scsi_emulate_cmd(struct scsi_data *sd) { sd->status = 0; if (sd->cmd[0] == 0x03) { /* REQUEST SENSE */ - int len = sd->buffer[4]; + int len = sd->cmd[4]; memset (sd->buffer, 0, len); memcpy (sd->buffer, sd->sense, sd->sense_len > len ? len : sd->sense_len); sd->data_len = len; + sd->status = 0; } else if (sd->nativescsiunit < 0) { sd->status = scsi_emulate(&sd->hfd->hfd, sd->hfd, - sd->cmd, sd->len, sd->buffer, &sd->data_len, sd->reply, &sd->reply_len, sd->sense, &sd->sense_len); + sd->cmd, sd->cmd_len, sd->buffer, &sd->data_len, sd->reply, &sd->reply_len, sd->sense, &sd->sense_len); if (sd->status == 0) { if (sd->reply_len > 0) { memset(sd->buffer, 0, 256); @@ -66,12 +104,12 @@ void scsi_emulate_cmd(struct scsi_data *sd) memset(sd->sense, 0, 256); memset(&as, 0, sizeof as); - memcpy (&as.cmd, sd->cmd, sd->len); + memcpy (&as.cmd, sd->cmd, sd->cmd_len); as.flags = 2 | 1; if (sd->direction > 0) as.flags &= ~1; as.sense_len = 32; - as.cmd_len = sd->len; + as.cmd_len = sd->cmd_len; as.data = sd->buffer; as.len = sd->direction < 0 ? DEVICE_SCSI_BUFSIZE : sd->data_len; sys_command_scsi_direct_native(sd->nativescsiunit, &as); @@ -123,36 +161,42 @@ void scsi_free(struct scsi_data *sd) xfree(sd); } -void scsi_start_transfer(struct scsi_data *sd, int len) +void scsi_start_transfer(struct scsi_data *sd) { - sd->len = len; sd->offset = 0; } int scsi_send_data(struct scsi_data *sd, uae_u8 b) { - if (sd->direction) { + if (sd->direction == 1) { if (sd->offset >= SCSI_DATA_BUFFER_SIZE) { write_log (_T("SCSI data buffer overflow!\n")); return 0; } sd->buffer[sd->offset++] = b; - } else { + } else if (sd->direction == 2) { if (sd->offset >= 16) { write_log (_T("SCSI command buffer overflow!\n")); return 0; } sd->cmd[sd->offset++] = b; + if (sd->offset == sd->cmd_len) + return 1; + } else { + write_log (_T("scsi_send_data() without direction!\n")); + return 0; } - if (sd->offset == sd->len) + if (sd->offset == sd->data_len) return 1; return 0; } int scsi_receive_data(struct scsi_data *sd, uae_u8 *b) { + if (!sd->data_len) + return -1; *b = sd->buffer[sd->offset++]; - if (sd->offset == sd->len) - return 1; + if (sd->offset == sd->data_len) + return 1; // requested length got return 0; } diff --git a/src/statusline.c b/src/statusline.c index 6ca5915..3b05e8e 100644 --- a/src/statusline.c +++ b/src/statusline.c @@ -165,14 +165,23 @@ void draw_status_line_single (uae_u8 *buf, int bpp, int y, int totalwidth, uae_u } else if (led == LED_CPU) { int idle = (gui_data.idle + 5) / 10; pos = 1; - //on = framecnt && !picasso_on; on_rgb = 0xcc0000; off_rgb = 0x000000; - num1 = idle / 100; - num2 = (idle - num1 * 100) / 10; - num3 = idle % 10; - num4 = num1 == 0 ? 13 : -1; - am = 3; + if (gui_data.cpu_halted) { + on_rgb = 0xcccc00; + idle = 0; + on = 1; + num1 = -1; + num2 = 11; + num3 = gui_data.cpu_halted; + am = 2; + } else { + num1 = idle / 100; + num2 = (idle - num1 * 100) / 10; + num3 = idle % 10; + num4 = num1 == 0 ? 13 : -1; + am = 3; + } } else if (led == LED_SND) { int snd = abs(gui_data.sndbuf + 5) / 10; if (snd > 99) @@ -234,8 +243,10 @@ void draw_status_line_single (uae_u8 *buf, int bpp, int y, int totalwidth, uae_u write_tdnumber (buf, bpp, x, y - TD_PADY, num1, pen_rgb, c2); x += TD_NUM_WIDTH; } - write_tdnumber (buf, bpp, x, y - TD_PADY, num2, pen_rgb, c2); - x += TD_NUM_WIDTH; + if (num2 >= 0) { + write_tdnumber (buf, bpp, x, y - TD_PADY, num2, pen_rgb, c2); + x += TD_NUM_WIDTH; + } write_tdnumber (buf, bpp, x, y - TD_PADY, num3, pen_rgb, c2); x += TD_NUM_WIDTH; if (num4 > 0) diff --git a/src/targets/t-win32.h b/src/targets/t-win32.h deleted file mode 100644 index c7f07a6..0000000 --- a/src/targets/t-win32.h +++ /dev/null @@ -1,25 +0,0 @@ - /* - * UAE - The Un*x Amiga Emulator - * - * Target specific stuff, Win32 version - * - * Copyright 1997 Mathias Ortmann - */ - -#define TARGET_NAME "win32" - -#define NO_MAIN_IN_MAIN_C - -#define OPTIONSFILENAME "uae.rc" -#define OPTIONS_IN_HOME - -#define TARGET_ROM_PATH "" -#define TARGET_FLOPPY_PATH "" -#define TARGET_HARDFILE_PATH "" -#define TARGET_SAVESTATE_PATH "" - -#define DEFPRTNAME "LPT1" -#define DEFSERNAME "COM1" - -#define PICASSO96_SUPPORTED -#define BSDSOCKET_SUPPORTED diff --git a/src/td-win32/Makefile.am b/src/td-win32/Makefile.am deleted file mode 100644 index 11c9dd2..0000000 --- a/src/td-win32/Makefile.am +++ /dev/null @@ -1,10 +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 = libthreaddep.a - -libthreaddep_a_SOURCES = thread.c - -noinst_HEADERS = thread.h diff --git a/src/td-win32/thread.c b/src/td-win32/thread.c deleted file mode 100644 index 0a25d64..0000000 --- a/src/td-win32/thread.c +++ /dev/null @@ -1,65 +0,0 @@ - /* - * UAE - The Un*x Amiga Emulator - * - * Win32 thread support - * - * Copyright 1997 Mathias Ortmann - * Copyright 2005 Richard Drummond - * - */ - -#include "thread.h" - -void uae_sem_init (HANDLE *event, int manual_reset, int initial_state) -{ - if (*event) { - if (initial_state) - SetEvent (*event); - else - ResetEvent( *event ); - } else - *event = CreateEvent (NULL, manual_reset, initial_state, NULL); -} - -void uae_sem_wait (HANDLE *event) -{ - WaitForSingleObject (*event, INFINITE); -} - -void uae_sem_post (HANDLE * event) -{ - SetEvent (*event); -} - -int uae_sem_trywait (HANDLE * event) -{ - return WaitForSingleObject (*event, 0) == WAIT_OBJECT_0 ? 0 : -1; -} - -void uae_sem_close (HANDLE * event) -{ - if (*event) { - CloseHandle (*event); - *event = NULL; - } -} - - -typedef unsigned (__stdcall *BEGINTHREADEX_FUNCPTR)(void *); - -int uae_start_thread (void *(*f)(void *), void *arg, DWORD *foo) -{ - HANDLE hThread; - int result = 1; - - hThread = (HANDLE)_beginthreadex (NULL, 0, (BEGINTHREADEX_FUNCPTR)f, arg, 0, foo); - if (hThread) - SetThreadPriority (hThread, THREAD_PRIORITY_HIGHEST); - else - result = 0; - return result; -} - -void uae_set_thread_priority (int pri) -{ -} diff --git a/src/td-win32/thread.h b/src/td-win32/thread.h deleted file mode 100644 index 1c8c2d8..0000000 --- a/src/td-win32/thread.h +++ /dev/null @@ -1,31 +0,0 @@ - /* - * UAE - The Un*x Amiga Emulator - * - * Win32 thread support - * - * Copyright 1997 Mathias Ortmann - * Copyright 2005 Richard Drummond - * - */ - -#include - -typedef HANDLE uae_sem_t; - -void uae_sem_init (uae_sem_t *event, int manual_reset, int initial_state); -void uae_sem_wait (uae_sem_t *event); -void uae_sem_post (uae_sem_t *event); -int uae_sem_trywait (uae_sem_t *event); -void uae_sem_close (uae_sem_t *event); - - - -typedef int uae_thread_id; - -int uae_start_thread (void *(*f)(void *), void *arg, DWORD * foo); -void uae_set_thread_priority (int pri); -int uae_wait_thread (uae_thread_id thread); - - - -#include "commpipe.h" diff --git a/src/tools/sysconfig.h.in b/src/tools/sysconfig.h.in index 9671417..1e2ef32 100644 --- a/src/tools/sysconfig.h.in +++ b/src/tools/sysconfig.h.in @@ -1,149 +1,17 @@ -/* src/sysconfig.h.in. Generated from configure.in by autoheader. */ +/* sysconfig.h.in. Generated from configure.ac by autoheader. */ -/* Define if building universal (internal helper macro) */ -#undef AC_APPLE_UNIVERSAL_BUILD - -/* CPU is 64bit */ -#undef __x86_64__ - -/* we want ecs_denise */ -#undef ECS_DENISE - -/* CPU supports 3DNOW */ -#undef HAVE_3DNOW - -/* Define to 1 if you have the `alarm' function. */ -#undef HAVE_ALARM - -/* Define to 1 if you have the 'bswap_16' function. */ -#undef HAVE_BSWAP_16 - -/* Define to 1 if you have the 'bswap_32' function. */ -#undef HAVE_BSWAP_32 - -/* Define to 1 if you have the header file. */ -#undef HAVE_BYTESWAP_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_CAPS_CAPSIMAGE_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_CURSES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_CYBERGRAPHX_CYBERGRAPHICS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_DEVICES_AHI_H - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -#undef HAVE_DIRENT_H - -/* "Define to 1 if you have 'dlopen' function */ -#undef HAVE_DLOPEN - -/* Define to 1 if you have the header file. */ -#undef HAVE_DUSTAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_FCNTL_H - -/* Define to 1 if you have the CAPS framework. */ -#undef HAVE_FRAMEWORK_CAPSIMAGE - -/* Define to 1 if you have the `gettimeofday' function. */ -#undef HAVE_GETTIMEOFDAY - -/* Define to 1 if you have the `gmtime_r' function. */ -#undef HAVE_GMTIME_R +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +#undef HAVE_DOPRNT /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H -/* Define if exists, doesn't clash with , and - declares uintmax_t. */ -#undef HAVE_INTTYPES_H_WITH_UINTMAX - -/* Define to 1 if you have the `isinf' function. */ -#undef HAVE_ISINF - -/* Define to 1 if you have the `isnan' function. */ -#undef HAVE_ISNAN - -/* Define to 1 if you have the header file. */ -#undef HAVE_LIBRARIES_CYBERGRAPHICS_H - -/* Define to 1 if you have the `localtime_r' function. */ -#undef HAVE_LOCALTIME_R - -/* Define to 1 if you have the header file. */ -#undef HAVE_MACHINE_JOYSTICK_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_MACHINE_SOUNDCARD_H - -/* Define to 1 if you have the header file. */ +/* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H -/* CPU supports MMX */ -#undef HAVE_MMX - -/* Define to 1 if you have the `nanosleep' function. */ -#undef HAVE_NANOSLEEP - -/* Define to 1 if you have the header file. */ -#undef HAVE_NCURSES_H - -/* Define to 1 if you have the header file, and it defines `DIR'. */ -#undef HAVE_NDIR_H - -/* Define if you have POSIX threads libraries and header files. */ -#undef HAVE_PTHREAD - -/* Define to 1 if you have the `readdir_r' function. */ -#undef HAVE_READDIR_R - -/* Define to 1 if you have the `select' function. */ -#undef HAVE_SELECT - -/* Define to 1 if you have the `setitimer' function. */ -#undef HAVE_SETITIMER - -/* Define to 1 if you have the `sigaction' function. */ -#undef HAVE_SIGACTION - -/* Define to 1 if you have the `sleep' function. */ -#undef HAVE_SLEEP - -/* CPU supports SSE */ -#undef HAVE_SSE - -/* CPU supports SSE2 */ -#undef HAVE_SSE2 - -/* CPU supports SSE3 */ -#undef HAVE_SSE3 - -/* CPU supports SSE4_1 */ -#undef HAVE_SSE4_1 - -/* CPU supports SSE4_2 */ -#undef HAVE_SSE4_2 - -/* CPU supports SSSE3 */ -#undef HAVE_SSSE3 - -/* Define to 1 if stdbool.h conforms to C99. */ -#undef HAVE_STDBOOL_H - /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H -/* Define if exists, doesn't clash with , and declares - uintmax_t. */ -#undef HAVE_STDINT_H_WITH_UINTMAX - /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H @@ -156,9 +24,6 @@ /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP -/* Define to 1 if you have the `strerror' function. */ -#undef HAVE_STRERROR - /* Define to 1 if you have the `stricmp' function. */ #undef HAVE_STRICMP @@ -168,126 +33,18 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H -/* Define to 1 if you have the `strstr' function. */ -#undef HAVE_STRSTR - -/* Define to 1 if `st_blocks' is a member of `struct stat'. */ -#undef HAVE_STRUCT_STAT_ST_BLOCKS - -/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use - `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */ -#undef HAVE_ST_BLOCKS - -/* Define to 1 if you have the header file. */ -#undef HAVE_SUN_AUDIOIO_H - -/* Define to 1 if you have the `sync' function. */ -#undef HAVE_SYNC - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_AUDIOIO_H - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -#undef HAVE_SYS_DIR_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_FILIO_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_FILSYS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_FS_S5PARAM_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_FS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_IOCTL_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_IPC_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_MMAN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_MOUNT_H - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -#undef HAVE_SYS_NDIR_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_PARAM_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_SHM_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_SOUNDCARD_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STATFS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STATVFS_H - /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TERMIOS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TIME_H - /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_VFS_H - -/* Define to 1 if you have the `timegm' function. */ -#undef HAVE_TIMEGM - -/* Define if you have the 'uintmax_t' type in or . */ -#undef HAVE_UINTMAX_T - /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H -/* Define if you have the 'unsigned long long' type. */ -#undef HAVE_UNSIGNED_LONG_LONG - -/* Define to 1 if you have the `usleep' function. */ -#undef HAVE_USLEEP - -/* Define to 1 if you have the header file. */ -#undef HAVE_UTIME_H - -/* Define to 1 if `utime(file, NULL)' sets file's timestamp to the present. */ -#undef HAVE_UTIME_NULL - -/* Define to 1 if you have the header file. */ -#undef HAVE_VALUES_H - -/* Define to 1 if you have the `vfprintf' function. */ -#undef HAVE_VFPRINTF - /* Define to 1 if you have the `vprintf' function. */ #undef HAVE_VPRINTF -/* Define to 1 if you have the `vsprintf' function. */ -#undef HAVE_VSPRINTF - -/* Define to 1 if the system has the type `_Bool'. */ -#undef HAVE__BOOL - -/* Name of package */ -#undef PACKAGE - /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT @@ -306,16 +63,6 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION -/* cloned git commit version */ -#undef PACKAGE_COMMIT - -/* Define to the necessary symbol if this constant uses a non-standard name on - your system. */ -#undef PTHREAD_CREATE_JOINABLE - -/* Define as the return type of signal handlers (`int' or `void'). */ -#undef RETSIGTYPE - /* The size of `char', as computed by sizeof. */ #undef SIZEOF_CHAR @@ -337,46 +84,9 @@ /* The size of `__int64', as computed by sizeof. */ #undef SIZEOF___INT64 -/* Define if the block counts reported by statfs may be truncated to 2GB and - the correct values may be stored in the f_spare array. (SunOS 4.1.2, 4.1.3, - and 4.1.3_U1 are reported to have this problem. SunOS 4.1.1 seems not to be - affected.) */ -#undef STATFS_TRUNCATES_BLOCK_COUNTS - -/* Define if there is no specific function for reading filesystems usage - information and you have the header file. (SVR2) */ -#undef STAT_READ_FILSYS - -/* Define if statfs takes 2 args and struct statfs has a field named f_bsize. - (4.3BSD, SunOS 4, HP-UX, AIX PS/2) */ -#undef STAT_STATFS2_BSIZE - -/* Define if statfs takes 2 args and struct statfs has a field named f_fsize. - (4.4BSD, NetBSD) */ -#undef STAT_STATFS2_FSIZE - -/* Define if statfs takes 2 args and the second argument has type struct - fs_data. (Ultrix) */ -#undef STAT_STATFS2_FS_DATA - -/* Define if statfs takes 3 args. (DEC Alpha running OSF/1) */ -#undef STAT_STATFS3_OSF1 - -/* Define if statfs takes 4 args. (SVR3, Dynix, Irix, Dolphin) */ -#undef STAT_STATFS4 - -/* Define if there is a function named statvfs. (SVR4) */ -#undef STAT_STATVFS - /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS -/* Define to 1 if you can safely include both and . */ -#undef TIME_WITH_SYS_TIME - -/* Define to 1 if your declares `struct tm'. */ -#undef TM_IN_SYS_TIME - /* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE # undef _ALL_SOURCE @@ -399,30 +109,6 @@ #endif -/* Version number of package */ -#undef VERSION - -/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most - significant byte first (like Motorola and SPARC, unlike Intel). */ -#if defined AC_APPLE_UNIVERSAL_BUILD -# if defined __BIG_ENDIAN__ -# define WORDS_BIGENDIAN 1 -# endif -#else -# ifndef WORDS_BIGENDIAN -# undef WORDS_BIGENDIAN -# endif -#endif - -/* Define to 1 if the X Window System is missing or not being used. */ -#undef X_DISPLAY_MISSING - -/* Number of bits in a file offset, on hosts where this is settable. */ -#undef _FILE_OFFSET_BITS - -/* Define for large files, on AIX-style hosts. */ -#undef _LARGE_FILES - /* Define to 1 if on MINIX. */ #undef _MINIX @@ -441,23 +127,3 @@ #ifndef __cplusplus #undef inline #endif - -/* Define to `int' if does not define. */ -#undef mode_t - -/* Define to `long int' if does not define. */ -#undef off_t - -/* Define to `unsigned int' if does not define. */ -#undef size_t - -/* Substitute for socklen_t */ -#undef socklen_t - -/* Define to unsigned long or unsigned long long if and - don't define. */ -#undef uintmax_t - -/* Define to empty if the keyword `volatile' does not work. Warning: valid - code using `volatile' can become incorrect without. Disable with care. */ -#undef volatile diff --git a/src/uaelib.c b/src/uaelib.c index 490f4a6..754dd0d 100644 --- a/src/uaelib.c +++ b/src/uaelib.c @@ -448,20 +448,12 @@ static uae_u32 REGPARAM2 uaelib_demux2 (TrapContext *context) return 0; } -extern int uaelib_debug; static uae_u32 REGPARAM2 uaelib_demux (TrapContext *context) { uae_u32 v; struct regstruct *r = ®s; - if (uaelib_debug) - write_log (_T("%d: %08x %08x %08x %08x %08x %08x %08x %08x, %08x %08x %08x %08x %08x %08x %08x %08x\n"), - ARG0, - r->regs[0],r->regs[1],r->regs[2],r->regs[3],r->regs[4],r->regs[5],r->regs[6],r->regs[7], - r->regs[8],r->regs[9],r->regs[10],r->regs[11],r->regs[12],r->regs[13],r->regs[14],r->regs[15]); v = uaelib_demux2 (context); - if (uaelib_debug) - write_log (_T("=%08x\n"), v); return v; } diff --git a/src/writelog.c b/src/writelog.c index 6995641..ae175e7 100644 --- a/src/writelog.c +++ b/src/writelog.c @@ -1,7 +1,7 @@ /* * PUAE - The portable Amiga emulator * - * Standard write_log that writes to the console or to a file. + * Standard write_log that writes to the console * * Copyright 2001 Bernd Schmidt * Copyright 2006 Richard Drummond @@ -17,37 +17,12 @@ #include "uae_types.h" #include "writelog.h" -static FILE *logfile = 0; - -/* - * By default write-log and friends access the stderr stream. - * This function allows you to specify a file to be used for logging - * instead. - * - * Call with NULL to close a previously opened log file. - */ -void set_logfile (const char *logfile_name) -{ - if (logfile_name && strlen (logfile_name)) { - FILE *newfile = fopen (logfile_name, "w"); - - if (newfile) - logfile = newfile; - } else { - if (logfile) { - fclose (logfile); - - logfile = 0; - } - } -} - void write_log (const char *fmt, ...) { va_list ap; va_start (ap, fmt); #ifdef HAVE_VFPRINTF - vfprintf (logfile ? logfile : stderr, fmt, ap); + vfprintf (stderr, fmt, ap); #else /* Technique stolen from GCC. */ { @@ -60,7 +35,7 @@ void write_log (const char *fmt, ...) x6 = va_arg (ap, int); x7 = va_arg (ap, int); x8 = va_arg (ap, int); - fprintf (logfile ? logfile : stderr, fmt, x1, x2, x3, x4, x5, x6, x7, x8); + fprintf (stderr, fmt, x1, x2, x3, x4, x5, x6, x7, x8); } #endif } @@ -71,7 +46,7 @@ void jit_abort (const char *fmt, ...) va_list ap; va_start (ap, fmt); #ifdef HAVE_VFPRINTF - vfprintf (logfile ? logfile : stderr, fmt, ap); + vfprintf (stderr, fmt, ap); #else /* Technique stolen from GCC. */ { @@ -84,7 +59,7 @@ void jit_abort (const char *fmt, ...) x6 = va_arg (ap, int); x7 = va_arg (ap, int); x8 = va_arg (ap, int); - fprintf (logfile ? logfile : stderr, fmt, x1, x2, x3, x4, x5, x6, x7, x8); + fprintf (stderr, fmt, x1, x2, x3, x4, x5, x6, x7, x8); } #endif uae_reset(1, 0); @@ -93,13 +68,31 @@ void jit_abort (const char *fmt, ...) void flush_log (void) { - fflush (logfile ? logfile : stderr); + fflush (stderr); } // Write Debug Log void write_dlog (const char *format, ...) { - + va_list ap; + va_start (ap, format); +#ifdef HAVE_VFPRINTF + vfprintf (stderr, format, ap); +#else + /* Technique stolen from GCC. */ + { + int x1, x2, x3, x4, x5, x6, x7, x8; + x1 = va_arg (ap, int); + x2 = va_arg (ap, int); + x3 = va_arg (ap, int); + x4 = va_arg (ap, int); + x5 = va_arg (ap, int); + x6 = va_arg (ap, int); + x7 = va_arg (ap, int); + x8 = va_arg (ap, int); + fprintf (stderr, format, x1, x2, x3, x4, x5, x6, x7, x8); + } +#endif } static char *console_buffer; diff --git a/src/zfile.c b/src/zfile.c index aa9ffe7..f98cf1b 100644 --- a/src/zfile.c +++ b/src/zfile.c @@ -304,7 +304,7 @@ int zfile_gettype (struct zfile *z) return ZFILE_NVR; if (strcasecmp (ext, _T("uae")) == 0) return ZFILE_CONFIGURATION; - if (strcasecmp (ext, _T("cue")) == 0 || strcasecmp (ext, _T("iso")) == 0 || strcasecmp (ext, _T("ccd")) == 0 || strcasecmp (ext, _T("mds")) == 0) + if (strcasecmp (ext, _T("cue")) == 0 || strcasecmp (ext, _T("iso")) == 0 || strcasecmp (ext, _T("ccd")) == 0 || strcasecmp (ext, _T("mds")) == 0 || strcasecmp (ext, _T("chd")) == 0) return ZFILE_CDIMAGE; } memset (buf, 0, sizeof (buf)); @@ -771,6 +771,8 @@ static struct zfile *fdi (struct zfile *z, int index, int *retcode) uae_u8 tmp[12]; struct zcache *zc; + if (checkwrite (z, retcode)) + return NULL; if (index > 2) return NULL; @@ -899,6 +901,9 @@ static struct zfile *ipf (struct zfile *z, int index, int *retcode) uae_u8 tmp[12]; struct zcache *zc; + if (checkwrite (z, retcode)) + return NULL; + if (index > 2) return NULL; @@ -1016,10 +1021,13 @@ end: #endif #ifdef A_LZX -static struct zfile *dsq (struct zfile *z, int lzx) +static struct zfile *dsq (struct zfile *z, int lzx, int *retcode) { struct zfile *zi = NULL; struct zvolume *zv = NULL; + + if (checkwrite (z, retcode)) + return NULL; /* if (lzx) { zv = archive_directory_lzx (z); @@ -1109,7 +1117,7 @@ static struct zfile *dsq (struct zfile *z, int lzx) #endif #ifdef A_WRP -static struct zfile *wrp (struct zfile *z) +static struct zfile *wrp (struct zfile *z, int *retcode) { //return unwarp (z); return z; @@ -1381,7 +1389,7 @@ struct zfile *zuncompress (struct znode *parent, struct zfile *z, int dodefault, return zfile_gunzip (z, retcode); #ifdef A_WRP if (strcasecmp (ext, _T("wrp")) == 0) - return wrp (z); + return wrp (z, retcode); #endif #ifdef A_7Z // if (strcasecmp (ext, _T("xz")) == 0) @@ -1427,11 +1435,11 @@ struct zfile *zuncompress (struct znode *parent, struct zfile *z, int dodefault, return zfile_gunzip (z, retcode); #ifdef A_LZX if (header[0] == 'P' && header[1] == 'K' && header[2] == 'D') - return dsq (z, 0); + return dsq (z, 0, retcode); #endif #ifdef A_7Z // if (header[0] == 0xfd && header[1] == 0x37 && header[2] == 0x7a && header[3] == 0x58 && header[4] == 0x5a && header[5] == 0) -// return xz (z); +// return xz (z, retcode); #endif } #ifdef A_DMS @@ -1474,7 +1482,7 @@ struct zfile *zuncompress (struct znode *parent, struct zfile *z, int dodefault, if (mask & ZFD_UNPACK) { #ifdef A_LZX if (strcasecmp (ext, _T("dsq")) == 0) - return dsq (z, 1); + return dsq (z, 1, retcode); #endif } if (mask & ZFD_ADF) { @@ -1635,36 +1643,10 @@ static struct zfile *zfile_fopen_2 (const TCHAR *name, const TCHAR *mode, int ma return l; } -#ifdef _WIN32 -#include "win32.h" - -#define AF _T("%AMIGAFOREVERDATA%") - -static void manglefilename (TCHAR *out, const TCHAR *in) -{ - int i; - - out[0] = 0; - if (!strncasecmp (in, AF, _tcslen (AF))) - _tcscpy (out, start_path_data); - if ((in[0] == '/' || in[0] == '\\') || (_tcslen(in) > 3 && in[1] == ':' && in[2] == '\\')) - out[0] = 0; - _tcscat (out, in); - for (i = 0; i < _tcslen (out); i++) { - // remove \\ or // in the middle of path - if ((out[i] == '/' || out[i] == '\\') && (out[i + 1] == '/' || out[i + 1] == '\\') && i > 0) { - memmove (out + i, out + i + 1, (_tcslen (out + i) + 1) * sizeof (TCHAR)); - i--; - continue; - } - } -} -#else static void manglefilename(TCHAR *out, const TCHAR *in) { _tcscpy (out, in); } -#endif int zfile_zopen (const TCHAR *name, zfile_callback zc, void *user) { @@ -1721,116 +1703,11 @@ static struct zfile *zfile_fopen_x (const TCHAR *name, const TCHAR *mode, int ma return l; } -#ifdef _WIN32 -static int isinternetfile (const TCHAR *name) -{ - if (!_tcsnicmp (name, _T("http://"), 7) || !_tcsnicmp (name, _T("https://"), 8)) - return 1; - if (!_tcsnicmp (name, _T("ftp://"), 6)) - return -1; - return 0; -} -#include -#define INETBUFFERLEN 1000000 -static struct zfile *zfile_fopen_internet (const TCHAR *name, const TCHAR *mode, int mask) -{ - static HINTERNET hi; - HINTERNET i = NULL; - TCHAR tmp[MAX_DPATH]; - DWORD ierr = 0; - DWORD outbuf = sizeof tmp / sizeof (TCHAR); - uae_u8 *data = 0; - int bufferlen = INETBUFFERLEN; - int datalen; - DWORD didread; - struct zfile *zf = NULL; - - if (_tcschr (mode, 'w') || _tcschr (mode, 'a')) - return NULL; - tmp[0] = 0; - if (!hi) { - hi = InternetOpen (WINUAEAPPNAME, INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY, NULL, NULL, 0); - if (hi == NULL) { - write_log (_T("InternetOpen() failed, %d\n"), GetLastError ()); - return NULL; - } - } - i = InternetOpenUrl (hi, name, NULL, 0, INTERNET_FLAG_NO_COOKIES, 0); - if (i == NULL) { - DWORD err = GetLastError (); - if (err == ERROR_INTERNET_EXTENDED_ERROR) - InternetGetLastResponseInfo (&ierr, tmp, &outbuf); - write_log (_T("InternetOpenUrl(%s) failed %d (%d,%s)\n"), name, err, ierr, tmp); - goto end; - } - - if (isinternetfile (name) > 0) { - DWORD statuscode; - DWORD hindex = 0; - DWORD size = sizeof statuscode; - if (!HttpQueryInfo (i, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &statuscode, &size, &hindex)) { - DWORD err = GetLastError (); - write_log (_T("HttpQueryInfo(%s) failed %d\n"), name, err); - goto end; - } - if (statuscode != 200) { - write_log (_T("HttpQueryInfo(%s)=%d\n"), name, statuscode); - goto end; - } - } - - if (mask & ZFD_CHECKONLY) { - zf = zfile_create (NULL); - goto end; - } - - datalen = 0; - data = xmalloc (uae_u8, bufferlen); - for (;;) { - if (!InternetReadFile (i, data + datalen, INETBUFFERLEN, &didread)) { - DWORD err = GetLastError (); - if (err == ERROR_INTERNET_EXTENDED_ERROR) - InternetGetLastResponseInfo (&ierr, tmp, &outbuf); - write_log (_T("InternetReadFile(%s) failed %d (%d,%s)\n"), name, err, ierr, tmp); - break; - } - if (didread == 0) - break; - datalen += didread; - if (datalen > bufferlen - INETBUFFERLEN) { - bufferlen += INETBUFFERLEN; - data = xrealloc (uae_u8, data, bufferlen); - if (!data) { - datalen = 0; - break; - } - } - } - if (datalen > 0) { - zf = zfile_create (NULL); - if (zf) { - zf->size = datalen; - zf->data = data; - data = NULL; - } - } -end: - if (i) - InternetCloseHandle (i); - xfree (data); - return zf; -} -#endif - static struct zfile *zfile_fopenx2 (const TCHAR *name, const TCHAR *mode, int mask, int index) { struct zfile *f; TCHAR tmp[MAX_DPATH]; -#ifdef _WIN32 - if (isinternetfile (name)) - return zfile_fopen_internet (name, mode, mask); -#endif f = zfile_fopen_x (name, mode, mask, index); if (f) return f; @@ -1894,6 +1771,8 @@ struct zfile *zfile_dup (struct zfile *zf) struct zfile *nzf; if (!zf) return NULL; + if (zf->archiveparent) + checkarchiveparent (zf); if (zf->userdata) return NULL; if (!zf->data && zf->dataseek) { @@ -1967,6 +1846,11 @@ struct zfile *zfile_fopen_empty (struct zfile *prev, const TCHAR *name, uae_u64 return l; } +/*struct zfile *zfile_fopen_empty (struct zfile *prev, const TCHAR *name) +{ + return zfile_fopen_empty (prev, name, 0); +}*/ + struct zfile *zfile_fopen_parent (struct zfile *z, const TCHAR *name, uae_u64 offset, uae_u64 size) { struct zfile *l; @@ -2446,7 +2330,7 @@ static struct znode *znode_alloc (struct znode *parent, const TCHAR *name) } fullpath[0] = 0; - recurparent (fullpath, parent, 0); + recurparent (fullpath, parent, false); _tcscat (fullpath, FSDB_DIR_SEPARATOR_S); _tcscat (fullpath, tmpname); #ifdef ZFILE_DEBUG @@ -2690,7 +2574,7 @@ static void zfile_fopen_archive_recurse2 (struct zvolume *zv, struct znode *zn, TCHAR tmp[MAX_DPATH]; _stprintf (tmp, _T("%s.DIR"), zn->fullname + _tcslen (zv->root.name) + 1); - zndir = get_znode (zv, tmp, 1); + zndir = get_znode (zv, tmp, true); if (!zndir) { struct zarchive_info zai = { 0 }; zvnew = zvolume_alloc_empty (zv, tmp); @@ -2953,12 +2837,71 @@ struct znode *zvolume_addfile_abs (struct zvolume *zv, struct zarchive_info *zai struct zvolume *zfile_fopen_directory (const TCHAR *dirname) { - return NULL; + struct zvolume *zv = NULL; + struct my_opendir_s *dir; + TCHAR fname[MAX_DPATH]; + + dir = my_opendir (dirname); + if (!dir) + return NULL; + zv = zvolume_alloc_nofile (dirname, ArchiveFormatDIR, NULL, NULL); + while (my_readdir (dir, fname)) { + TCHAR fullname[MAX_DPATH]; + struct mystat statbuf; + struct zarchive_info zai = { 0 }; + if (!_tcscmp (fname, _T(".")) || !_tcscmp (fname, _T(".."))) + continue; + _tcscpy (fullname, dirname); + _tcscat (fullname, FSDB_DIR_SEPARATOR_S); + _tcscat (fullname, fname); + if (!my_stat (fullname, &statbuf)) + continue; + zai.name = fname; + zai.size = statbuf.size; + zai.tv.tv_sec = statbuf.mtime.tv_sec; + zai.tv.tv_usec = statbuf.mtime.tv_usec; + if (statbuf.mode & FILEFLAG_DIR) { + zvolume_adddir_abs (zv, &zai); + } else { + struct znode *zn; + zn = zvolume_addfile_abs (zv, &zai); + //zfile_fopen_archive_recurse2 (zv, zn); + } + } + my_closedir (dir); + // zfile_fopen_archive_recurse (zv); + if (zv) + zvolume_addtolist (zv); + return zv; } struct zvolume *zfile_fopen_archive_flags (const TCHAR *filename, int flags) { - return NULL; + struct zvolume *zv = NULL; + struct zfile *zf = zfile_fopen_nozip (filename, _T("rb")); + + if (!zf) + return NULL; + zf->zfdmask = flags; + zv = zfile_fopen_archive_ext (NULL, zf, flags); + if (!zv) + zv = zfile_fopen_archive_data (NULL, zf, flags); + + /* pointless but who cares? */ + if (!zv && !(flags & ZFD_NORECURSE)) + zv = archive_directory_plain (zf); + +#if RECURSIVE_ARCHIVES + if (zv && !(flags & ZFD_NORECURSE)) + zfile_fopen_archive_recurse (zv, flags); +#endif + + if (zv) + zvolume_addtolist (zv); + else + zfile_fclose (zf); + + return zv; } struct zvolume *zfile_fopen_archive (const TCHAR *filename) @@ -2968,6 +2911,34 @@ struct zvolume *zfile_fopen_archive (const TCHAR *filename) struct zvolume *zfile_fopen_archive_root (const TCHAR *filename, int flags) { + TCHAR path[MAX_DPATH], *p1, *p2, *lastp; + struct zvolume *zv = NULL; + //int last = 0; + int num, i; + + if (my_existsdir (filename)) + return zfile_fopen_directory (filename); + + num = 1; + lastp = NULL; + for (;;) { + _tcscpy (path, filename); + p1 = p2 = path; + for (i = 0; i < num; i++) { + while (*p1 != FSDB_DIR_SEPARATOR && *p1 != 0) + p1++; + if (*p1 == 0 && p1 == lastp) + return NULL; + if (i + 1 < num) + p1++; + } + *p1 = 0; + lastp = p1; + if (my_existsfile (p2)) + return zfile_fopen_archive_flags (p2, flags); + num++; + } + return NULL; } @@ -3192,12 +3163,35 @@ void zfile_close_archive (struct zfile *d) struct zfile *zfile_open_archive (const TCHAR *path, int flags) { - return 0; + struct zvolume *zv = get_zvolume (path); + struct znode *zn = get_znode (zv, path, true); + struct zfile *z; + + if (!zn) + return 0; + if (zn->f) { + zfile_fseek (zn->f, 0, SEEK_SET); + return zn->f; + } + if (zn->vfile) + zn = zn->vfile; + z = archive_getzfile (zn, zn->volume->id, 0); + if (z) + zfile_fseek (z, 0, SEEK_SET); + zn->f = z; + return zn->f; } int zfile_exists_archive (const TCHAR *path, const TCHAR *rel) { - return 0; + TCHAR tmp[MAX_DPATH]; + struct zvolume *zv; + struct znode *zn; + + _stprintf (tmp, _T("%s%c%s"), path, FSDB_DIR_SEPARATOR, rel); + zv = get_zvolume (tmp); + zn = get_znode (zv, tmp, true); + return zn ? 1 : 0; } int zfile_convertimage (const TCHAR *src, const TCHAR *dst) @@ -3205,6 +3199,27 @@ int zfile_convertimage (const TCHAR *src, const TCHAR *dst) struct zfile *s, *d; int ret = 0; + s = zfile_fopen (src, _T("rb"), ZFD_NORMAL); + if (s) { + uae_u8 *b; + int size; + zfile_fseek (s, 0, SEEK_END); + size = zfile_ftell (s); + zfile_fseek (s, 0, SEEK_SET); + b = xcalloc (uae_u8, size); + if (b) { + if (zfile_fread (b, size, 1, s) == 1) { + d = zfile_fopen (dst, _T("wb"), 0); + if (d) { + if (zfile_fwrite (b, size, 1, d) == 1) + ret = 1; + zfile_fclose (d); + } + } + xfree (b); + } + zfile_fclose (s); + } return ret; } diff --git a/src/zfile_archive.c b/src/zfile_archive.c index c0abb50..b7592bb 100644 --- a/src/zfile_archive.c +++ b/src/zfile_archive.c @@ -9,9 +9,9 @@ #include "sysconfig.h" #include "sysdeps.h" -#ifdef _WIN32 -#include -#include "win32.h" +#if defined(__FreeBSD__) +#include +#include #endif #include "options.h" @@ -19,18 +19,12 @@ #include "archivers/zip/unzip.h" #include "archivers/dms/pfile.h" #include "crc32.h" -#include "zfile.h" #include "disk.h" #include "fsdb.h" #include "misc.h" #include -#if defined(__FreeBSD__) -#include -#include -#endif - #define unpack_log write_log #undef unpack_log #define unpack_log @@ -190,6 +184,10 @@ struct zfile *archive_access_select (struct znode *parent, struct zfile *zf, uns whf = 2; ft = ZFILE_CDIMAGE; } + if (ext && !_tcsicmp (ext, _T(".chd"))) { + whf = 2; + ft = ZFILE_CDIMAGE; + } if (ext && !_tcsicmp (ext, _T(".ccd"))) { whf = 9; ft = ZFILE_CDIMAGE;