From a3dd9af8958c42090e0544a412f1453f455aa6d6 Mon Sep 17 00:00:00 2001 From: Christer Solskogen Date: Sun, 23 Dec 2018 15:34:53 +0100 Subject: [PATCH] Code cleanup (#393) * Code cleanup using deheader for removing unnused headers and adding others to be portable. Removed unused files and renamed .cpp files that are only used as #includes in others * add missing files --- Makefile | 4 +- src/akiko.cpp | 5 +- src/ar.cpp | 6 +- src/audio.cpp | 10 +- src/autoconf.cpp | 5 +- src/blitfunc.cpp | 8 +- src/blitops.cpp | 262 - src/blittable.cpp | 6 +- src/blitter.cpp | 5 +- src/blkdev.cpp | 9 +- src/blkdev_cdimage.cpp | 11 +- src/bsdsocket.cpp | 20 +- src/build68k.cpp | 341 -- src/calc.cpp | 9 +- src/caps/caps_win32.cpp | 5 +- src/cd32_fmv.cpp | 14 +- src/cd32_fmv_genlock.cpp | 7 +- src/cdrom.cpp | 5 +- src/cfgfile.cpp | 12 +- src/cia.cpp | 12 +- src/cpudefs.cpp | 1 - src/cpuemu_0.cpp | 6 +- src/cpuemu_11.cpp | 3 - src/cpuemu_4.cpp | 3 - src/cpuemu_40.cpp | 6 +- src/cpuemu_44.cpp | 3 - src/cpustbl.cpp | 3 - src/crc32.cpp | 2 +- src/custom.cpp | 11 +- src/devices.cpp | 7 +- src/disk.cpp | 9 +- src/diskutil.cpp | 3 +- src/dlopen.cpp | 6 +- src/drawing.cpp | 14 +- src/events.cpp | 2 +- src/expansion.cpp | 9 +- src/fdi2raw.cpp | 4 - src/filesys.cpp | 9 +- src/filesys.sh | 2 +- ...sys_bootrom.cpp => filesys_bootrom.cpp.in} | 0 src/flashrom.cpp | 4 - src/fpp.cpp | 17 +- src/{fpp_native.cpp => fpp_native.cpp.in} | 0 src/fsdb.cpp | 14 +- src/fsdb_unix.cpp | 8 +- src/fsusage.cpp | 12 +- src/gayle.cpp | 12 +- src/genblitter.cpp | 188 - src/gencpu.cpp | 4242 ----------------- src/genlinetoscr.cpp | 605 --- src/gfxboard.cpp | 1 - src/gfxutil.cpp | 3 +- src/hardfile.cpp | 11 +- src/ide.cpp | 6 +- src/{ => include}/blit.h | 0 src/{ => include}/blitfunc.h | 0 src/{ => include}/cputbl.h | 0 src/include/genblitter.h | 20 - src/include/mackbd.h | 114 - src/include/uae/api.h | 103 - src/include/uae/attributes.h | 34 - src/include/uae/cdrom.h | 8 - src/include/uae/io.h | 13 - src/include/uae/vm.h | 32 - src/inputdevice.cpp | 9 +- .../{codegen_arm.cpp => codegen_arm.cpp.in} | 0 src/jit/compemu_fpp.cpp | 4 +- ...unc_arm.cpp => compemu_midfunc_arm.cpp.in} | 0 ...c_arm2.cpp => compemu_midfunc_arm2.cpp.in} | 0 src/jit/compemu_support.cpp | 16 +- src/jit/gencomp_arm.cpp | 3492 -------------- src/keybuf.cpp | 9 +- src/{linetoscr.cpp => linetoscr.cpp.in} | 0 src/machdep/support.cpp | 7 - src/main.cpp | 16 +- src/memory.cpp | 6 +- src/native2amiga.cpp | 6 - src/newcpu.cpp | 11 +- src/newcpu_common.cpp | 5 +- src/osdep/amiberry.cpp | 22 +- src/osdep/amiberry_filesys.cpp | 12 +- src/osdep/amiberry_gfx.cpp | 14 +- src/osdep/amiberry_gui.cpp | 24 +- src/osdep/amiberry_hardfile.cpp | 7 +- src/osdep/amiberry_input.cpp | 11 +- src/osdep/amiberry_mem.cpp | 13 +- src/osdep/amiberry_rp9.cpp | 13 +- src/osdep/amiberry_whdbooter.cpp | 18 +- src/osdep/bsdsocket_host.cpp | 23 +- src/osdep/cda_play.cpp | 7 +- src/osdep/charset.cpp | 2 +- src/osdep/fsdb_host.cpp | 7 +- src/osdep/gui/CreateFilesysHardfile.cpp | 12 +- src/osdep/gui/EditFilesysHardfile.cpp | 9 +- src/osdep/gui/EditFilesysVirtual.cpp | 11 +- src/osdep/gui/InGameMessage.cpp | 9 +- src/osdep/gui/Navigation.cpp | 7 +- src/osdep/gui/PanelAbout.cpp | 7 +- src/osdep/gui/PanelCPU.cpp | 6 +- src/osdep/gui/PanelChipset.cpp | 8 +- src/osdep/gui/PanelConfig.cpp | 8 +- src/osdep/gui/PanelCustom.cpp | 14 +- src/osdep/gui/PanelDisplay.cpp | 8 +- src/osdep/gui/PanelFloppy.cpp | 11 +- src/osdep/gui/PanelHD.cpp | 6 +- src/osdep/gui/PanelInput.cpp | 9 - src/osdep/gui/PanelMisc.cpp | 11 +- src/osdep/gui/PanelPaths.cpp | 3 - src/osdep/gui/PanelQuickstart.cpp | 13 +- src/osdep/gui/PanelRAM.cpp | 8 - src/osdep/gui/PanelROM.cpp | 10 +- src/osdep/gui/PanelSavestate.cpp | 14 +- src/osdep/gui/PanelSound.cpp | 10 +- src/osdep/gui/SelectFile.cpp | 13 +- src/osdep/gui/SelectFolder.cpp | 11 +- src/osdep/gui/SelectorEntry.cpp | 2 + src/osdep/gui/ShowHelp.cpp | 9 +- src/osdep/gui/ShowMessage.cpp | 9 +- src/osdep/gui/androidsdl_event.cpp | 2 + src/osdep/gui/main_window.cpp | 6 +- src/osdep/keyboard.cpp | 14 +- src/osdep/mp3decoder.cpp | 5 +- src/osdep/picasso96.cpp | 125 +- src/osdep/sigsegv_handler.cpp | 8 +- src/osdep/writelog.cpp | 4 +- src/{p96_blit.cpp => p96_blit.cpp.in} | 0 src/readcpu.cpp | 4 +- src/rommgr.cpp | 4 +- src/rtc.cpp | 5 +- src/savestate.cpp | 7 +- src/scsi.cpp | 3 +- src/{sinctable.cpp => sinctable.cpp.in} | 0 src/sounddep/sound.cpp | 14 +- src/statusline.cpp | 9 +- src/table68k | 531 --- src/traps.cpp | 5 +- src/uaelib.cpp | 9 +- src/uaeresource.cpp | 5 - src/zfile.cpp | 13 +- src/zfile_archive.cpp | 10 +- 140 files changed, 442 insertions(+), 10639 deletions(-) delete mode 100644 src/blitops.cpp delete mode 100644 src/build68k.cpp rename src/{filesys_bootrom.cpp => filesys_bootrom.cpp.in} (100%) rename src/{fpp_native.cpp => fpp_native.cpp.in} (100%) delete mode 100644 src/genblitter.cpp delete mode 100644 src/gencpu.cpp delete mode 100644 src/genlinetoscr.cpp rename src/{ => include}/blit.h (100%) rename src/{ => include}/blitfunc.h (100%) rename src/{ => include}/cputbl.h (100%) delete mode 100644 src/include/genblitter.h delete mode 100644 src/include/mackbd.h delete mode 100644 src/include/uae/api.h delete mode 100644 src/include/uae/attributes.h delete mode 100644 src/include/uae/cdrom.h delete mode 100644 src/include/uae/io.h delete mode 100644 src/include/uae/vm.h rename src/jit/{codegen_arm.cpp => codegen_arm.cpp.in} (100%) rename src/jit/{compemu_midfunc_arm.cpp => compemu_midfunc_arm.cpp.in} (100%) rename src/jit/{compemu_midfunc_arm2.cpp => compemu_midfunc_arm2.cpp.in} (100%) delete mode 100644 src/jit/gencomp_arm.cpp rename src/{linetoscr.cpp => linetoscr.cpp.in} (100%) rename src/{p96_blit.cpp => p96_blit.cpp.in} (100%) rename src/{sinctable.cpp => sinctable.cpp.in} (100%) delete mode 100644 src/table68k mode change 100755 => 100644 src/uaelib.cpp diff --git a/Makefile b/Makefile index 3d353101..3db2cdda 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ endif # DispmanX Common flags for both SDL1 and SDL2 (RPI-specific) # DISPMANX_FLAGS = -DUSE_DISPMANX -I/opt/vc/include -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/vcos/pthreads -DISPMANX_LDFLAGS = -lbcm_host -lvchiq_arm -L/opt/vc/lib +DISPMANX_LDFLAGS = -lbcm_host -lvchiq_arm -L/opt/vc/lib -Wl,-rpath=/opt/vc/lib CPPFLAGS=-MD -MT $@ -MF $(@:%.o=%.d) #DEBUG=1 @@ -171,7 +171,7 @@ endif RM = rm -f CC ?= gcc CXX ?= g++ -STRIP = strip +STRIP ?= strip PROG = $(NAME) # diff --git a/src/akiko.cpp b/src/akiko.cpp index 70971c0b..1e75ce1d 100644 --- a/src/akiko.cpp +++ b/src/akiko.cpp @@ -10,8 +10,10 @@ * Copyright 2001-2016 Toni Wilen * */ +#include +#include +#include -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" @@ -21,7 +23,6 @@ #include "blkdev.h" #include "zfile.h" #include "threaddep/thread.h" -#include "akiko.h" #include "gui.h" #include "crc32.h" #include "uae.h" diff --git a/src/ar.cpp b/src/ar.cpp index 72aad439..17502fc5 100644 --- a/src/ar.cpp +++ b/src/ar.cpp @@ -201,7 +201,10 @@ * */ -#include "sysconfig.h" +#include +#include +#include + #include "sysdeps.h" #include "options.h" @@ -214,7 +217,6 @@ #include "ar.h" #include "savestate.h" #include "crc32.h" -#include "akiko.h" static const TCHAR *cart_memnames[] = { NULL, _T("hrtmon"), _T("arhrtmon"), _T("superiv") }; diff --git a/src/audio.cpp b/src/audio.cpp index 526e740a..0d3313af 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -12,22 +12,20 @@ * */ -#include "sysconfig.h" +#include +#include + #include "sysdeps.h" #include "options.h" #include "memory.h" #include "custom.h" #include "newcpu.h" -#include "autoconf.h" -#include "gensound.h" #include "audio.h" #include "sounddep/sound.h" #include "savestate.h" #include "gui.h" -#include - #define PERIOD_MIN 4 #define PERIOD_MIN_NONCE 60 @@ -48,7 +46,7 @@ STATIC_INLINE bool usehacks (void) * sufficient for all imaginable purposes. This must be power of two. */ #define SINC_QUEUE_LENGTH 256 -#include "sinctable.cpp" +#include "sinctable.cpp.in" typedef struct { int time, output; diff --git a/src/autoconf.cpp b/src/autoconf.cpp index 79e6938a..eebe806d 100644 --- a/src/autoconf.cpp +++ b/src/autoconf.cpp @@ -7,16 +7,13 @@ * Copyright 1996 Ed Hanway */ -#include "sysconfig.h" +#include #include "sysdeps.h" #include "options.h" #include "uae.h" #include "memory.h" -#include "custom.h" -#include "newcpu.h" #include "autoconf.h" -#include "traps.h" #include "inputdevice.h" /* Commonly used autoconfig strings */ diff --git a/src/blitfunc.cpp b/src/blitfunc.cpp index e55f881f..616ec74a 100644 --- a/src/blitfunc.cpp +++ b/src/blitfunc.cpp @@ -1,12 +1,8 @@ -#include "sysconfig.h" #include "sysdeps.h" -#include "options.h" -#include "include/memory.h" -#include "newcpu.h" -#include "custom.h" #include "savestate.h" +#include "options.h" #include "blitter.h" -#include "blitfunc.h" +#include "memory.h" void blitdofast_0(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) { diff --git a/src/blitops.cpp b/src/blitops.cpp deleted file mode 100644 index 8e9b1ec0..00000000 --- a/src/blitops.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/* This file generated automatically - do not edit */ - -#include "genblitter.h" - -struct blitop blitops[256] = { - /* 00 */{ "0", 0 }, - /* 01 */{ "~(srca | srcb | srcc)", 7 }, - /* 02 */{ "(srcc & ~(srca | srcb))", 7 }, - /* 03 */{ "~(srca | srcb)", 3 }, - /* 04 */{ "(srcb & ~(srca | srcc))", 7 }, - /* 05 */{ "~(srca | srcc)", 5 }, - /* 06 */{ "(~srca & (srcb ^ srcc))", 7 }, - /* 07 */{ "~(srca | (srcb & srcc))", 7 }, - /* 08 */{ "(~srca & srcb & srcc)", 7 }, - /* 09 */{ "~(srca | (srcb ^ srcc))", 7 }, - /* 0a */{ "(~srca & srcc)", 5 }, - /* 0b */{ "~(srca | (srcb & ~srcc))", 7 }, - /* 0c */{ "(~srca & srcb)", 3 }, - /* 0d */{ "~(srca | (~srcb & srcc))", 7 }, - /* 0e */{ "(~srca & (srcb | srcc))", 7 }, - /* 0f */{ "~srca", 1 }, - /* 10 */{ "(srca & ~(srcb | srcc))", 7 }, - /* 11 */{ "~(srcb | srcc)", 6 }, - /* 12 */{ "(~srcb & (srca ^ srcc))", 7 }, - /* 13 */{ "~(srcb | (srca & srcc))", 7 }, - /* 14 */{ "(~srcc & (srca ^ srcb))", 7 }, - /* 15 */{ "~(srcc | (srca & srcb))", 7 }, - /* 16 */{ "(srca ^ ((srca & srcb) | (srcb ^ srcc)))", 7 }, - /* 17 */{ "~(srca ^ ((srca ^ srcb) & (srca ^ srcc)))", 7 }, - /* 18 */{ "((srca ^ srcb) & (srca ^ srcc))", 7 }, - /* 19 */{ "(srcb ^ (~srcc | (srca & srcb)))", 7 }, - /* 1a */{ "(srca ^ (srcc | (srca & srcb)))", 7 }, - /* 1b */{ "(srca ^ (srcc | ~(srca ^ srcb)))", 7 }, - /* 1c */{ "(srca ^ (srcb | (srca & srcc)))", 7 }, - /* 1d */{ "(srca ^ (srcb | ~(srca ^ srcc)))", 7 }, - /* 1e */{ "(srca ^ (srcb | srcc))", 7 }, - /* 1f */{ "~(srca & (srcb | srcc))", 7 }, - /* 20 */{ "(srca & ~srcb & srcc)", 7 }, - /* 21 */{ "~(srcb | (srca ^ srcc))", 7 }, - /* 22 */{ "(~srcb & srcc)", 6 }, - /* 23 */{ "~(srcb | (srca & ~srcc))", 7 }, - /* 24 */{ "((srca ^ srcb) & (srcb ^ srcc))", 7 }, - /* 25 */{ "(srca ^ (~srcc | (srca & srcb)))", 7 }, - /* 26 */{ "(srcb ^ (srcc | (srca & srcb)))", 7 }, - /* 27 */{ "~(srca ^ (srcc & (srca ^ srcb)))", 7 }, - /* 28 */{ "(srcc & (srca ^ srcb))", 7 }, - /* 29 */{ "~(srca ^ srcb ^ (srcc | (srca & srcb)))", 7 }, - /* 2a */{ "(srcc & ~(srca & srcb))", 7 }, - /* 2b */{ "~(srca ^ ((srca ^ srcb) & (srcb ^ srcc)))", 7 }, - /* 2c */{ "(srcb ^ (srca & (srcb | srcc)))", 7 }, - /* 2d */{ "(srca ^ (srcb | ~srcc))", 7 }, - /* 2e */{ "(srca ^ (srcb | (srca ^ srcc)))", 7 }, - /* 2f */{ "~(srca & (srcb | ~srcc))", 7 }, - /* 30 */{ "(srca & ~srcb)", 3 }, - /* 31 */{ "~(srcb | (~srca & srcc))", 7 }, - /* 32 */{ "(~srcb & (srca | srcc))", 7 }, - /* 33 */{ "~srcb", 2 }, - /* 34 */{ "(srcb ^ (srca | (srcb & srcc)))", 7 }, - /* 35 */{ "(srcb ^ (srca | ~(srcb ^ srcc)))", 7 }, - /* 36 */{ "(srcb ^ (srca | srcc))", 7 }, - /* 37 */{ "~(srcb & (srca | srcc))", 7 }, - /* 38 */{ "(srca ^ (srcb & (srca | srcc)))", 7 }, - /* 39 */{ "(srcb ^ (srca | ~srcc))", 7 }, - /* 3a */{ "(srcb ^ (srca | (srcb ^ srcc)))", 7 }, - /* 3b */{ "~(srcb & (srca | ~srcc))", 7 }, - /* 3c */{ "(srca ^ srcb)", 3 }, - /* 3d */{ "(srca ^ (srcb | ~(srca | srcc)))", 7 }, - /* 3e */{ "(srca ^ (srcb | (srca ^ (srca | srcc))))", 7 }, - /* 3f */{ "~(srca & srcb)", 3 }, - /* 40 */{ "(srca & srcb & ~srcc)", 7 }, - /* 41 */{ "~(srcc | (srca ^ srcb))", 7 }, - /* 42 */{ "((srca ^ srcc) & (srcb ^ srcc))", 7 }, - /* 43 */{ "(srca ^ (~srcb | (srca & srcc)))", 7 }, - /* 44 */{ "(srcb & ~srcc)", 6 }, - /* 45 */{ "~(srcc | (srca & ~srcb))", 7 }, - /* 46 */{ "(srcc ^ (srcb | (srca & srcc)))", 7 }, - /* 47 */{ "~(srca ^ (srcb & (srca ^ srcc)))", 7 }, - /* 48 */{ "(srcb & (srca ^ srcc))", 7 }, - /* 49 */{ "~(srca ^ srcc ^ (srcb | (srca & srcc)))", 7 }, - /* 4a */{ "(srcc ^ (srca & (srcb | srcc)))", 7 }, - /* 4b */{ "(srca ^ (~srcb | srcc))", 7 }, - /* 4c */{ "(srcb & ~(srca & srcc))", 7 }, - /* 4d */{ "(srca ^ ((srca ^ srcb) | ~(srca ^ srcc)))", 7 }, - /* 4e */{ "(srca ^ (srcc | (srca ^ srcb)))", 7 }, - /* 4f */{ "~(srca & (~srcb | srcc))", 7 }, - /* 50 */{ "(srca & ~srcc)", 5 }, - /* 51 */{ "~(srcc | (~srca & srcb))", 7 }, - /* 52 */{ "(srcc ^ (srca | (srcb & srcc)))", 7 }, - /* 53 */{ "~(srcb ^ (srca & (srcb ^ srcc)))", 7 }, - /* 54 */{ "(~srcc & (srca | srcb))", 7 }, - /* 55 */{ "~srcc", 4 }, - /* 56 */{ "(srcc ^ (srca | srcb))", 7 }, - /* 57 */{ "~(srcc & (srca | srcb))", 7 }, - /* 58 */{ "(srca ^ (srcc & (srca | srcb)))", 7 }, - /* 59 */{ "(srcc ^ (srca | ~srcb))", 7 }, - /* 5a */{ "(srca ^ srcc)", 5 }, - /* 5b */{ "(srca ^ (srcc | ~(srca | srcb)))", 7 }, - /* 5c */{ "(srcc ^ (srca | (srcb ^ srcc)))", 7 }, - /* 5d */{ "~(srcc & (srca | ~srcb))", 7 }, - /* 5e */{ "(srca ^ (srcc | (srca ^ (srca | srcb))))", 7 }, - /* 5f */{ "~(srca & srcc)", 5 }, - /* 60 */{ "(srca & (srcb ^ srcc))", 7 }, - /* 61 */{ "~(srcb ^ srcc ^ (srca | (srcb & srcc)))", 7 }, - /* 62 */{ "(srcc ^ (srcb & (srca | srcc)))", 7 }, - /* 63 */{ "(srcb ^ (~srca | srcc))", 7 }, - /* 64 */{ "(srcb ^ (srcc & (srca | srcb)))", 7 }, - /* 65 */{ "(srcc ^ (~srca | srcb))", 7 }, - /* 66 */{ "(srcb ^ srcc)", 6 }, - /* 67 */{ "(srcb ^ (srcc | ~(srca | srcb)))", 7 }, - /* 68 */{ "((srca & srcb) ^ (srcc & (srca | srcb)))", 7 }, - /* 69 */{ "~(srca ^ srcb ^ srcc)", 7 }, - /* 6a */{ "(srcc ^ (srca & srcb))", 7 }, - /* 6b */{ "~(srca ^ srcb ^ (srcc & (srca | srcb)))", 7 }, - /* 6c */{ "(srcb ^ (srca & srcc))", 7 }, - /* 6d */{ "~(srca ^ srcc ^ (srcb & (srca | srcc)))", 7 }, - /* 6e */{ "((~srca & srcb) | (srcb ^ srcc))", 7 }, - /* 6f */{ "(~srca | (srcb ^ srcc))", 7 }, - /* 70 */{ "(srca & ~(srcb & srcc))", 7 }, - /* 71 */{ "~(srca ^ ((srca ^ srcb) | (srca ^ srcc)))", 7 }, - /* 72 */{ "(srcb ^ (srcc | (srca ^ srcb)))", 7 }, - /* 73 */{ "~(srcb & (~srca | srcc))", 7 }, - /* 74 */{ "(srcc ^ (srcb | (srca ^ srcc)))", 7 }, - /* 75 */{ "~(srcc & (~srca | srcb))", 7 }, - /* 76 */{ "(srcb ^ (srcc | (srca ^ (srca & srcb))))", 7 }, - /* 77 */{ "~(srcb & srcc)", 6 }, - /* 78 */{ "(srca ^ (srcb & srcc))", 7 }, - /* 79 */{ "~(srcb ^ srcc ^ (srca & (srcb | srcc)))", 7 }, - /* 7a */{ "((srca & ~srcb) | (srca ^ srcc))", 7 }, - /* 7b */{ "(~srcb | (srca ^ srcc))", 7 }, - /* 7c */{ "((srca ^ srcb) | (srca & ~srcc))", 7 }, - /* 7d */{ "(~srcc | (srca ^ srcb))", 7 }, - /* 7e */{ "((srca ^ srcb) | (srca ^ srcc))", 7 }, - /* 7f */{ "~(srca & srcb & srcc)", 7 }, - /* 80 */{ "(srca & srcb & srcc)", 7 }, - /* 81 */{ "~((srca ^ srcb) | (srca ^ srcc))", 7 }, - /* 82 */{ "(srcc & ~(srca ^ srcb))", 7 }, - /* 83 */{ "(srca ^ (~srcb | (srca & ~srcc)))", 7 }, - /* 84 */{ "(srcb & ~(srca ^ srcc))", 7 }, - /* 85 */{ "(srca ^ (~srcc | (srca & ~srcb)))", 7 }, - /* 86 */{ "(srcb ^ srcc ^ (srca & (srcb | srcc)))", 7 }, - /* 87 */{ "~(srca ^ (srcb & srcc))", 7 }, - /* 88 */{ "(srcb & srcc)", 6 }, - /* 89 */{ "(srcb ^ (~srcc & (~srca | srcb)))", 7 }, - /* 8a */{ "(srcc & (~srca | srcb))", 7 }, - /* 8b */{ "(srca ^ (~srcb | (srca ^ srcc)))", 7 }, - /* 8c */{ "(srcb & (~srca | srcc))", 7 }, - /* 8d */{ "(srca ^ (~srcc | (srca ^ srcb)))", 7 }, - /* 8e */{ "(srca ^ ((srca ^ srcb) | (srca ^ srcc)))", 7 }, - /* 8f */{ "(~srca | (srcb & srcc))", 7 }, - /* 90 */{ "(srca & ~(srcb ^ srcc))", 7 }, - /* 91 */{ "(srcb ^ (~srcc | (~srca & srcb)))", 7 }, - /* 92 */{ "(srca ^ srcc ^ (srcb & (srca | srcc)))", 7 }, - /* 93 */{ "~(srcb ^ (srca & srcc))", 7 }, - /* 94 */{ "(srca ^ srcb ^ (srcc & (srca | srcb)))", 7 }, - /* 95 */{ "~(srcc ^ (srca & srcb))", 7 }, - /* 96 */{ "(srca ^ srcb ^ srcc)", 7 }, - /* 97 */{ "(srca ^ srcb ^ (srcc | ~(srca | srcb)))", 7 }, - /* 98 */{ "(srcb ^ (~srcc & (srca | srcb)))", 7 }, - /* 99 */{ "~(srcb ^ srcc)", 6 }, - /* 9a */{ "(srcc ^ (srca & ~srcb))", 7 }, - /* 9b */{ "~(srcb ^ (srcc & (srca | srcb)))", 7 }, - /* 9c */{ "(srcb ^ (srca & ~srcc))", 7 }, - /* 9d */{ "~(srcc ^ (srcb & (srca | srcc)))", 7 }, - /* 9e */{ "(srcb ^ srcc ^ (srca | (srcb & srcc)))", 7 }, - /* 9f */{ "~(srca & (srcb ^ srcc))", 7 }, - /* a0 */{ "(srca & srcc)", 5 }, - /* a1 */{ "(srca ^ (~srcc & (srca | ~srcb)))", 7 }, - /* a2 */{ "(srcc & (srca | ~srcb))", 7 }, - /* a3 */{ "(srcb ^ (~srca | (srcb ^ srcc)))", 7 }, - /* a4 */{ "(srca ^ (~srcc & (srca | srcb)))", 7 }, - /* a5 */{ "~(srca ^ srcc)", 5 }, - /* a6 */{ "(srcc ^ (~srca & srcb))", 7 }, - /* a7 */{ "~(srca ^ (srcc & (srca | srcb)))", 7 }, - /* a8 */{ "(srcc & (srca | srcb))", 7 }, - /* a9 */{ "~(srcc ^ (srca | srcb))", 7 }, - /* aa */{ "srcc", 4 }, - /* ab */{ "(srcc | ~(srca | srcb))", 7 }, - /* ac */{ "(srcb ^ (srca & (srcb ^ srcc)))", 7 }, - /* ad */{ "~(srcc ^ (srca | (srcb & srcc)))", 7 }, - /* ae */{ "(srcc | (~srca & srcb))", 7 }, - /* af */{ "(~srca | srcc)", 5 }, - /* b0 */{ "(srca & (~srcb | srcc))", 7 }, - /* b1 */{ "~(srca ^ (srcc | (srca ^ srcb)))", 7 }, - /* b2 */{ "(srca ^ ((srca ^ srcc) & (srcb ^ srcc)))", 7 }, - /* b3 */{ "(~srcb | (srca & srcc))", 7 }, - /* b4 */{ "(srca ^ (srcb & ~srcc))", 7 }, - /* b5 */{ "~(srcc ^ (srca & (srcb | srcc)))", 7 }, - /* b6 */{ "(srca ^ srcc ^ (srcb | (srca & srcc)))", 7 }, - /* b7 */{ "~(srcb & (srca ^ srcc))", 7 }, - /* b8 */{ "(srca ^ (srcb & (srca ^ srcc)))", 7 }, - /* b9 */{ "~(srcc ^ (srcb | (srca & srcc)))", 7 }, - /* ba */{ "(srcc | (srca & ~srcb))", 7 }, - /* bb */{ "(~srcb | srcc)", 6 }, - /* bc */{ "((srca ^ srcb) | (srca & srcc))", 7 }, - /* bd */{ "((srca ^ srcb) | ~(srca ^ srcc))", 7 }, - /* be */{ "(srcc | (srca ^ srcb))", 7 }, - /* bf */{ "(srcc | ~(srca & srcb))", 7 }, - /* c0 */{ "(srca & srcb)", 3 }, - /* c1 */{ "(srca ^ (~srcb & (srca | ~srcc)))", 7 }, - /* c2 */{ "(srca ^ (~srcb & (srca | srcc)))", 7 }, - /* c3 */{ "~(srca ^ srcb)", 3 }, - /* c4 */{ "(srcb & (srca | ~srcc))", 7 }, - /* c5 */{ "~(srcb ^ (srca | (srcb ^ srcc)))", 7 }, - /* c6 */{ "(srcb ^ (~srca & srcc))", 7 }, - /* c7 */{ "~(srca ^ (srcb & (srca | srcc)))", 7 }, - /* c8 */{ "(srcb & (srca | srcc))", 7 }, - /* c9 */{ "~(srcb ^ (srca | srcc))", 7 }, - /* ca */{ "(srcc ^ (srca & (srcb ^ srcc)))", 7 }, - /* cb */{ "~(srcb ^ (srca | (srcb & srcc)))", 7 }, - /* cc */{ "srcb", 2 }, - /* cd */{ "(srcb | ~(srca | srcc))", 7 }, - /* ce */{ "(srcb | (~srca & srcc))", 7 }, - /* cf */{ "(~srca | srcb)", 3 }, - /* d0 */{ "(srca & (srcb | ~srcc))", 7 }, - /* d1 */{ "~(srca ^ (srcb | (srca ^ srcc)))", 7 }, - /* d2 */{ "(srca ^ (~srcb & srcc))", 7 }, - /* d3 */{ "~(srcb ^ (srca & (srcb | srcc)))", 7 }, - /* d4 */{ "(srca ^ ((srca ^ srcb) & (srcb ^ srcc)))", 7 }, - /* d5 */{ "(~srcc | (srca & srcb))", 7 }, - /* d6 */{ "(srca ^ srcb ^ (srcc | (srca & srcb)))", 7 }, - /* d7 */{ "~(srcc & (srca ^ srcb))", 7 }, - /* d8 */{ "(srca ^ (srcc & (srca ^ srcb)))", 7 }, - /* d9 */{ "~(srcb ^ (srcc | (srca & srcb)))", 7 }, - /* da */{ "((srca & srcb) | (srca ^ srcc))", 7 }, - /* db */{ "~((srca ^ srcb) & (srcb ^ srcc))", 7 }, - /* dc */{ "(srcb | (srca & ~srcc))", 7 }, - /* dd */{ "(srcb | ~srcc)", 6 }, - /* de */{ "(srcb | (srca ^ srcc))", 7 }, - /* df */{ "(srcb | ~(srca & srcc))", 7 }, - /* e0 */{ "(srca & (srcb | srcc))", 7 }, - /* e1 */{ "~(srca ^ (srcb | srcc))", 7 }, - /* e2 */{ "(srcc ^ (srcb & (srca ^ srcc)))", 7 }, - /* e3 */{ "~(srca ^ (srcb | (srca & srcc)))", 7 }, - /* e4 */{ "(srcb ^ (srcc & (srca ^ srcb)))", 7 }, - /* e5 */{ "~(srca ^ (srcc | (srca & srcb)))", 7 }, - /* e6 */{ "((srca & srcb) | (srcb ^ srcc))", 7 }, - /* e7 */{ "~((srca ^ srcb) & (srca ^ srcc))", 7 }, - /* e8 */{ "(srca ^ ((srca ^ srcb) & (srca ^ srcc)))", 7 }, - /* e9 */{ "(srca ^ srcb ^ (~srcc | (srca & srcb)))", 7 }, - /* ea */{ "(srcc | (srca & srcb))", 7 }, - /* eb */{ "(srcc | ~(srca ^ srcb))", 7 }, - /* ec */{ "(srcb | (srca & srcc))", 7 }, - /* ed */{ "(srcb | ~(srca ^ srcc))", 7 }, - /* ee */{ "(srcb | srcc)", 6 }, - /* ef */{ "(~srca | srcb | srcc)", 7 }, - /* f0 */{ "srca", 1 }, - /* f1 */{ "(srca | ~(srcb | srcc))", 7 }, - /* f2 */{ "(srca | (~srcb & srcc))", 7 }, - /* f3 */{ "(srca | ~srcb)", 3 }, - /* f4 */{ "(srca | (srcb & ~srcc))", 7 }, - /* f5 */{ "(srca | ~srcc)", 5 }, - /* f6 */{ "(srca | (srcb ^ srcc))", 7 }, - /* f7 */{ "(srca | ~(srcb & srcc))", 7 }, - /* f8 */{ "(srca | (srcb & srcc))", 7 }, - /* f9 */{ "(srca | ~(srcb ^ srcc))", 7 }, - /* fa */{ "(srca | srcc)", 5 }, - /* fb */{ "(srca | ~srcb | srcc)", 7 }, - /* fc */{ "(srca | srcb)", 3 }, - /* fd */{ "(srca | srcb | ~srcc)", 7 }, - /* fe */{ "(srca | srcb | srcc)", 7 }, - /* ff */{ "0xFFFFFFFF", 0 } -}; diff --git a/src/blittable.cpp b/src/blittable.cpp index dbcdb38a..504d9c57 100644 --- a/src/blittable.cpp +++ b/src/blittable.cpp @@ -1,9 +1,7 @@ -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" -#include "include/memory.h" -#include "newcpu.h" -#include "custom.h" +#include "memory.h" +//#include "newcpu.h" #include "savestate.h" #include "blitter.h" #include "blitfunc.h" diff --git a/src/blitter.cpp b/src/blitter.cpp index 1386fbb5..4e49ea64 100644 --- a/src/blitter.cpp +++ b/src/blitter.cpp @@ -6,13 +6,12 @@ * (c) 1995 Bernd Schmidt, Alessandro Bissacco * (c) 2002 - 2005 Toni Wilen */ +#include -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" -#include "uae.h" -#include "include/memory.h" +#include "memory.h" #include "custom.h" #include "newcpu.h" #include "savestate.h" diff --git a/src/blkdev.cpp b/src/blkdev.cpp index 2d97dfbb..68746b46 100644 --- a/src/blkdev.cpp +++ b/src/blkdev.cpp @@ -7,19 +7,18 @@ * */ -#include "sysconfig.h" +#include +#include +#include + #include "sysdeps.h" #include "options.h" -#include "include/memory.h" -#include "traps.h" #include "blkdev.h" #include "savestate.h" #include "crc32.h" #include "threaddep/thread.h" -#include "execio.h" #include "zfile.h" -#include "fsdb.h" #define PRE_INSERT_DELAY (3 * (currprefs.ntscmode ? 60 : 50)) diff --git a/src/blkdev_cdimage.cpp b/src/blkdev_cdimage.cpp index ebe84b2a..0faaf238 100644 --- a/src/blkdev_cdimage.cpp +++ b/src/blkdev_cdimage.cpp @@ -11,13 +11,16 @@ * Copyright 2010-2013 Toni Wilen * */ -#include "sysconfig.h" -#include "sysdeps.h" +#include +#include +#include #include +#include +#include +#include "sysdeps.h" #include "options.h" -#include "traps.h" #include "blkdev.h" #include "zfile.h" #include "gui.h" @@ -26,9 +29,7 @@ #include "mp3decoder.h" #include "cda_play.h" #include "include/memory.h" -#include "audio.h" #include "uae.h" -#include "uae/cdrom.h" #define FLAC__NO_DLL #include "FLAC/stream_decoder.h" diff --git a/src/bsdsocket.cpp b/src/bsdsocket.cpp index d1c7a9f1..bc987dd8 100644 --- a/src/bsdsocket.cpp +++ b/src/bsdsocket.cpp @@ -8,18 +8,23 @@ * Library initialization code (c) Tauno Taipaleenmaki */ -#include "sysconfig.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "sysdeps.h" -#include -#include #include "options.h" #include "include/memory.h" -#include "custom.h" -#include "newcpu.h" #include "autoconf.h" -#include "traps.h" #include "threaddep/thread.h" #include "bsdsocket.h" #include "native2amiga.h" @@ -1049,9 +1054,6 @@ static uae_u32 REGPARAM2 bsdsocklib_Dup2Socket (TrapContext *ctx) return host_dup2socket(ctx, sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1)); } -#define MSG_EOR 0x08 /* data completes record */ -#define MSG_TRUNC 0x10 /* data discarded before delivery */ - static uae_u32 REGPARAM2 bsdsocklib_sendmsg (TrapContext *ctx) { struct socketbase *sb = get_socketbase (ctx); diff --git a/src/build68k.cpp b/src/build68k.cpp deleted file mode 100644 index 6269fad2..00000000 --- a/src/build68k.cpp +++ /dev/null @@ -1,341 +0,0 @@ -/* - * UAE - The Un*x Amiga Emulator - * - * Read 68000 CPU specs from file "table68k" and build table68k.c - * - * Copyright 1995,1996 Bernd Schmidt - */ - -#include "sysconfig.h" -#include "sysdeps.h" - -#include -#include -#include -#include - -#define TCHAR char - -#include "readcpu.h" - -static FILE *tablef; -static int nextch = 0; - -static void getnextch(void) -{ - do { - nextch = fgetc(tablef); - if (nextch == '%') { - do { - nextch = fgetc(tablef); - } while (nextch != EOF && nextch != '\n'); - } - } while (nextch != EOF && isspace(nextch)); -} - -static int nextchtohex(void) -{ - switch (isupper (nextch) ? tolower (nextch) : nextch) { - case '0': return 0; - case '1': return 1; - case '2': return 2; - case '3': return 3; - case '4': return 4; - case '5': return 5; - case '6': return 6; - case '7': return 7; - case '8': return 8; - case '9': return 9; - case 'a': return 10; - case 'b': return 11; - case 'c': return 12; - case 'd': return 13; - case 'e': return 14; - case 'f': return 15; - default: abort(); - } -} - -int main(int argc, char **argv) -{ - int no_insns = 0; - - printf ("#include \"sysconfig.h\"\n"); - printf ("#include \"sysdeps.h\"\n"); - printf ("#include \"readcpu.h\"\n"); - printf ("struct instr_def defs68k[] = {\n"); - tablef = stdin; - getnextch(); - while (nextch != EOF) { - int cpulevel, uncpulevel, plevel, sduse; - int i; - - char opcstr[256]; - int bitpos[16]; - int flagset[5], flaguse[5]; - char cflow; - - unsigned int bitmask,bitpattern; - int n_variable; - - int head = 0, tail = 0, clocks = 0, fetchmode = 0; - - n_variable = 0; - bitmask = bitpattern = 0; - memset (bitpos, 0, sizeof(bitpos)); - for(i=0; i<16; i++) { - int currbit; - bitmask <<= 1; - bitpattern <<= 1; - - switch (nextch) { - case '0': currbit = bit0; bitmask |= 1; break; - case '1': currbit = bit1; bitmask |= 1; bitpattern |= 1; break; - case 'c': currbit = bitc; break; - case 'C': currbit = bitC; break; - case 'f': currbit = bitf; break; - case 'i': currbit = biti; break; - case 'I': currbit = bitI; break; - case 'j': currbit = bitj; break; - case 'J': currbit = bitJ; break; - case 'k': currbit = bitk; break; - case 'K': currbit = bitK; break; - case 's': currbit = bits; break; - case 'S': currbit = bitS; break; - case 'd': currbit = bitd; break; - case 'D': currbit = bitD; break; - case 'r': currbit = bitr; break; - case 'R': currbit = bitR; break; - case 'z': currbit = bitz; break; - case 'E': currbit = bitE; break; - case 'p': currbit = bitp; break; - default: abort(); - } - if (!(bitmask & 1)) { - bitpos[n_variable] = currbit; - n_variable++; - } - - if (nextch == '0' || nextch == '1') - bitmask |= 1; - if (nextch == '1') - bitpattern |= 1; - getnextch(); - } - - while (isspace(nextch) || nextch == ':') /* Get CPU level, unimplemented level, and privilege level */ - getnextch(); - - switch (nextch) { - case '0': cpulevel = 0; break; - case '1': cpulevel = 1; break; - case '2': cpulevel = 2; break; - case '3': cpulevel = 3; break; - case '4': cpulevel = 4; break; - case '5': cpulevel = 5; break; - case '6': cpulevel = 6; break; - case '7': cpulevel = 7; break; - default: abort(); - } - getnextch(); - - switch (nextch) { - case '0': uncpulevel = 0; break; - case '1': uncpulevel = 1; break; - case '2': uncpulevel = 2; break; - case '3': uncpulevel = 3; break; - case '4': uncpulevel = 4; break; - case '5': uncpulevel = 5; break; - case '6': uncpulevel = 6; break; - case '7': uncpulevel = 7; break; - default: abort(); - } - getnextch(); - - switch (nextch) { - case '0': plevel = 0; break; - case '1': plevel = 1; break; - case '2': plevel = 2; break; - case '3': plevel = 3; break; - default: abort(); - } - getnextch(); - - while (isspace(nextch)) /* Get flag set information */ - getnextch(); - - if (nextch != ':') - abort(); - - for(i = 0; i < 5; i++) { - getnextch(); - switch(nextch) { - case '-': flagset[i] = fa_unset; break; - case '/': flagset[i] = fa_isjmp; break; - case '+': flagset[i] = fa_isbranch; break; - case '0': flagset[i] = fa_zero; break; - case '1': flagset[i] = fa_one; break; - case 'x': flagset[i] = fa_dontcare; break; - case '?': flagset[i] = fa_unknown; break; - default: flagset[i] = fa_set; break; - } - } - - getnextch(); - while (isspace(nextch)) - getnextch(); - - if (nextch != ':') /* Get flag used information */ - abort(); - - for(i = 0; i < 5; i++) { - getnextch(); - switch(nextch) { - case '-': flaguse[i] = fu_unused; break; - case '/': flaguse[i] = fu_isjmp; break; - case '+': flaguse[i] = fu_maybecc; break; - case '?': flaguse[i] = fu_unknown; break; - default: flaguse[i] = fu_used; break; - } - } - - getnextch(); - while (isspace(nextch)) - getnextch(); - - if (nextch != ':') /* Get control flow information */ - abort(); - - cflow = 0; - for(i = 0; i < 2; i++) { - getnextch(); - switch(nextch) { - case '-': break; - case 'R': cflow |= fl_return; break; - case 'B': cflow |= fl_branch; break; - case 'J': cflow |= fl_jump; break; - case 'T': cflow |= fl_trap; break; - default: abort(); - } - } - - getnextch(); - while (isspace(nextch)) - getnextch(); - - if (nextch != ':') /* Get source/dest usage information */ - abort(); - - getnextch(); - sduse = nextchtohex() << 4; - getnextch(); - sduse |= nextchtohex(); - - getnextch(); - while (isspace(nextch)) - getnextch(); - - if (nextch != ':') - abort(); - - if (fgets(opcstr, 250, tablef) != opcstr) { - abort(); - } - getnextch(); - - if (nextch == '-') { - int neg; - char fm[20]; - getnextch(); - while (isspace(nextch)) - getnextch(); - neg = 1; - if (nextch == '-') { - neg = -1; - getnextch(); - } - for (;;) { - if (nextch < '0' || nextch > '9') - break; - head *= 10; - head += nextch - '0'; - nextch = fgetc (tablef); - } - head *= neg; - while (isspace(nextch)) - getnextch(); - for (;;) { - if (nextch < '0' || nextch > '9') - break; - tail *= 10; - tail += nextch - '0'; - nextch = fgetc (tablef); - } - while (isspace(nextch)) - getnextch(); - for (;;) { - if (nextch < '0' || nextch > '9') - break; - clocks *= 10; - clocks += nextch - '0'; - nextch = fgetc (tablef); - } - if (nextch == ' ') { - if (fgets(fm, sizeof fm, tablef) != fm) { - abort(); - } - if (!strnicmp(fm, "fea", 3)) - fetchmode = 1; - if (!strnicmp(fm, "cea", 3)) - fetchmode = 2; - if (!strnicmp(fm, "fiea", 4)) - fetchmode = 3; - if (!strnicmp(fm, "ciea", 4)) - fetchmode = 4; - if (!strnicmp(fm, "jea", 3)) - fetchmode = 5; - } - getnextch(); - } - - int j; - /* Remove superfluous spaces from the string */ - char *opstrp = opcstr, *osendp; - char tmp[100], *p; - int slen = 0; - - while (isspace((int)*opstrp)) - opstrp++; - - osendp = opstrp; - while (*osendp) { - if (!isspace ((int)*osendp)) - slen = osendp - opstrp + 1; - osendp++; - } - opstrp[slen] = 0; - - if (no_insns > 0) - printf(",\n"); - no_insns++; - strcpy (tmp, opstrp); - strcat (tmp, " "); - p = tmp; - while (!isspace(*p++)); - *p = 0; - printf("/* %s */\n", tmp); - printf("{0x%04X,%2d,{", bitpattern, n_variable); - for (j = 0; j < 16; j++) { - printf("%2d", bitpos[j]); - if (j < 15) - printf(","); - } - printf ("},0x%04X,%d,%d,%d,{", bitmask, cpulevel, uncpulevel, plevel); - for(i = 0; i < 5; i++) { - printf("{%d,%d}%s", flaguse[i], flagset[i], i == 4 ? "" : ","); - } - printf("}, %2d, %2d,_T(\"%s\"),%2d,%2d,%2d,%2d}", cflow, sduse, opstrp, head, tail, clocks, fetchmode); - } - printf("};\nint n_defs68k = %d;\n", no_insns); - return 0; -} diff --git a/src/calc.cpp b/src/calc.cpp index af09a977..c3102446 100644 --- a/src/calc.cpp +++ b/src/calc.cpp @@ -13,15 +13,10 @@ */ #define calc_log(x) - -#include "sysconfig.h" +#include +#include #include "sysdeps.h" -#include "calc.h" - -#include -#include - #define STACK_SIZE 32 #define MAX_VALUES 32 #define IOBUFFERS 256 diff --git a/src/caps/caps_win32.cpp b/src/caps/caps_win32.cpp index 57f8db6a..d52e29f2 100644 --- a/src/caps/caps_win32.cpp +++ b/src/caps/caps_win32.cpp @@ -1,4 +1,5 @@ -#include "sysconfig.h" +#include +#include #include "sysdeps.h" #ifdef CAPS @@ -367,4 +368,4 @@ int caps_loadtrack (uae_u16 *mfmbuf, uae_u16 *tracktiming, int drv, int track, i return 1; } -#endif /* CAPS */ \ No newline at end of file +#endif /* CAPS */ diff --git a/src/cd32_fmv.cpp b/src/cd32_fmv.cpp index 817c03d7..224772ba 100644 --- a/src/cd32_fmv.cpp +++ b/src/cd32_fmv.cpp @@ -7,20 +7,18 @@ * */ -#include "sysconfig.h" +#include +#include +#include +#include + #include "sysdeps.h" #include "options.h" -#include "include/memory.h" +#include "memory.h" #include "rommgr.h" #include "custom.h" -#include "newcpu.h" -#include "zfile.h" #include "cd32_fmv.h" -#include "uae.h" -#include "custom.h" -#include "audio.h" -#include "threaddep/thread.h" #include "cda_play.h" #include "archivers/mp2/kjmp2.h" diff --git a/src/cd32_fmv_genlock.cpp b/src/cd32_fmv_genlock.cpp index 0ba66481..cdae8c57 100644 --- a/src/cd32_fmv_genlock.cpp +++ b/src/cd32_fmv_genlock.cpp @@ -7,13 +7,10 @@ * */ -#include "sysconfig.h" +#include + #include "sysdeps.h" -#include "options.h" -#include "memory.h" -#include "cd32_fmv.h" -#include "custom.h" #include "xwin.h" static uae_u8 *mpeg_out_buffer; diff --git a/src/cdrom.cpp b/src/cdrom.cpp index 616301f2..304e28bf 100644 --- a/src/cdrom.cpp +++ b/src/cdrom.cpp @@ -1,7 +1,6 @@ -#include "sysconfig.h" -#include "sysdeps.h" +#include -#include "uae/cdrom.h" +#include "sysconfig.h" /* CDROM MODE 1 EDC/ECC code (from Reed-Solomon library by Heiko Eissfeldt) */ diff --git a/src/cfgfile.cpp b/src/cfgfile.cpp index c35682e2..f5242431 100644 --- a/src/cfgfile.cpp +++ b/src/cfgfile.cpp @@ -7,18 +7,21 @@ * Copyright 1998 Brian King, Bernd Schmidt */ -#include "sysconfig.h" +#include +#include +#include +#include +#include + #include "sysdeps.h" -#include - #include "options.h" +#include "memory.h" #include "uae.h" #include "audio.h" #include "custom.h" #include "inputdevice.h" #include "savestate.h" -#include "include/memory.h" #include "autoconf.h" #include "rommgr.h" #include "gui.h" @@ -30,7 +33,6 @@ #include "blkdev.h" #include "calc.h" #include "gfxboard.h" -#include "native2amiga_api.h" #define cfgfile_warning write_log #define cfgfile_warning_obsolete write_log diff --git a/src/cia.cpp b/src/cia.cpp index 4aa4a7f1..17c76918 100644 --- a/src/cia.cpp +++ b/src/cia.cpp @@ -6,29 +6,25 @@ * Copyright 1995 Bernd Schmidt, Alessandro Bissacco * Copyright 1996, 1997 Stefan Reinauer, Christian Schmitt */ +#include +#include +#include -#include "sysconfig.h" #include "sysdeps.h" -#include #include "options.h" -#include "include/memory.h" +#include "memory.h" #include "custom.h" #include "newcpu.h" -#include "cia.h" #include "disk.h" -#include "xwin.h" #include "keybuf.h" #include "gui.h" #include "savestate.h" #include "inputdevice.h" -#include "zfile.h" #include "include/ar.h" #include "akiko.h" #include "audio.h" #include "keyboard.h" -#include "uae.h" -#include "autoconf.h" #include "rtc.h" /* Akiko internal CIA differences: diff --git a/src/cpudefs.cpp b/src/cpudefs.cpp index 7984d2b7..2f12728d 100644 --- a/src/cpudefs.cpp +++ b/src/cpudefs.cpp @@ -1,4 +1,3 @@ -#include "sysconfig.h" #include "sysdeps.h" #include "readcpu.h" struct instr_def defs68k[] = { diff --git a/src/cpuemu_0.cpp b/src/cpuemu_0.cpp index f6919f14..25dff6da 100644 --- a/src/cpuemu_0.cpp +++ b/src/cpuemu_0.cpp @@ -1,11 +1,9 @@ -#include "sysconfig.h" +#include + #include "sysdeps.h" #include "options.h" #include "include/memory.h" -#include "custom.h" #include "newcpu.h" -#include "cpu_prefetch.h" -#include "cputbl.h" #define CPUFUNC(x) x##_ff #define SET_CFLG_ALWAYS(x) SET_CFLG(x) #define SET_NFLG_ALWAYS(x) SET_NFLG(x) diff --git a/src/cpuemu_11.cpp b/src/cpuemu_11.cpp index 5ab1bad6..c34904b6 100644 --- a/src/cpuemu_11.cpp +++ b/src/cpuemu_11.cpp @@ -1,11 +1,8 @@ -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" #include "memory.h" -#include "custom.h" #include "newcpu.h" #include "cpu_prefetch.h" -#include "cputbl.h" #define CPUFUNC(x) x##_ff #define SET_CFLG_ALWAYS(x) SET_CFLG(x) #define SET_NFLG_ALWAYS(x) SET_NFLG(x) diff --git a/src/cpuemu_4.cpp b/src/cpuemu_4.cpp index a4659f4e..543de656 100644 --- a/src/cpuemu_4.cpp +++ b/src/cpuemu_4.cpp @@ -1,11 +1,8 @@ -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" #include "memory.h" -#include "custom.h" #include "newcpu.h" #include "cpu_prefetch.h" -#include "cputbl.h" #define CPUFUNC(x) x##_ff #define SET_CFLG_ALWAYS(x) SET_CFLG(x) #define SET_NFLG_ALWAYS(x) SET_NFLG(x) diff --git a/src/cpuemu_40.cpp b/src/cpuemu_40.cpp index 03cf9562..4c1c1969 100644 --- a/src/cpuemu_40.cpp +++ b/src/cpuemu_40.cpp @@ -1,11 +1,9 @@ -#include "sysconfig.h" +#include + #include "sysdeps.h" #include "options.h" #include "memory.h" -#include "custom.h" #include "newcpu.h" -#include "cpu_prefetch.h" -#include "cputbl.h" #define CPUFUNC(x) x##_ff #define SET_CFLG_ALWAYS(x) SET_CFLG(x) #define SET_NFLG_ALWAYS(x) SET_NFLG(x) diff --git a/src/cpuemu_44.cpp b/src/cpuemu_44.cpp index b325f60b..afb1f45a 100644 --- a/src/cpuemu_44.cpp +++ b/src/cpuemu_44.cpp @@ -1,11 +1,8 @@ -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" #include "memory.h" -#include "custom.h" #include "newcpu.h" #include "cpu_prefetch.h" -#include "cputbl.h" #define CPUFUNC(x) x##_ff #define SET_CFLG_ALWAYS(x) SET_CFLG(x) #define SET_NFLG_ALWAYS(x) SET_NFLG(x) diff --git a/src/cpustbl.cpp b/src/cpustbl.cpp index 39fddae5..5c79c598 100644 --- a/src/cpustbl.cpp +++ b/src/cpustbl.cpp @@ -1,10 +1,7 @@ -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" #include "memory.h" -#include "custom.h" #include "newcpu.h" -#include "cpu_prefetch.h" #include "cputbl.h" #define CPUFUNC(x) x##_ff #define SET_CFLG_ALWAYS(x) SET_CFLG(x) diff --git a/src/crc32.cpp b/src/crc32.cpp index 200da20b..6a722f36 100644 --- a/src/crc32.cpp +++ b/src/crc32.cpp @@ -1,5 +1,5 @@ +#include -#include "sysconfig.h" #include "sysdeps.h" #include "crc32.h" diff --git a/src/custom.cpp b/src/custom.cpp index 9f1e903a..106c095f 100644 --- a/src/custom.cpp +++ b/src/custom.cpp @@ -7,13 +7,15 @@ * Copyright 1995 Alessandro Bissacco * Copyright 2000-2015 Toni Wilen */ +#include +#include +#include +#include +#include +#include -#include "sysconfig.h" #include "sysdeps.h" -#include -#include - #include "options.h" #include "uae.h" #include "audio.h" @@ -27,7 +29,6 @@ #include "xwin.h" #include "inputdevice.h" #include "autoconf.h" -#include "traps.h" #include "gui.h" #include "picasso96.h" #include "drawing.h" diff --git a/src/devices.cpp b/src/devices.cpp index 8e0ad667..c687dfe6 100644 --- a/src/devices.cpp +++ b/src/devices.cpp @@ -1,13 +1,9 @@ -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" -#include "threaddep/thread.h" -#include "traps.h" +#include "thread.h" #include "memory.h" #include "audio.h" -#include "gfxboard.h" -#include "scsi.h" #include "cd32_fmv.h" #include "akiko.h" #include "gayle.h" @@ -16,7 +12,6 @@ #include "inputdevice.h" #include "picasso96.h" #include "blkdev.h" -#include "picasso96.h" #include "autoconf.h" #include "newcpu.h" #include "savestate.h" diff --git a/src/disk.cpp b/src/disk.cpp index 33578b86..e6b70f90 100644 --- a/src/disk.cpp +++ b/src/disk.cpp @@ -11,7 +11,12 @@ * */ -#include "sysconfig.h" +#include +#include +#include +#include +#include + #include "sysdeps.h" #define MFM_VALIDATOR 0 @@ -24,7 +29,6 @@ #include "gui.h" #include "zfile.h" #include "newcpu.h" -#include "execlib.h" #include "savestate.h" #include "cia.h" #ifdef FDI2RAW @@ -35,7 +39,6 @@ #endif #include "crc32.h" #include "fsdb.h" -#include "rommgr.h" static int longwritemode = 0; diff --git a/src/diskutil.cpp b/src/diskutil.cpp index 98aeb839..391e8bb7 100644 --- a/src/diskutil.cpp +++ b/src/diskutil.cpp @@ -1,8 +1,7 @@ -#include "sysconfig.h" +#include #include "sysdeps.h" #include "crc32.h" -#include "diskutil.h" #define MFMMASK 0x55555555 static uae_u32 getmfmlong(uae_u16 * mbuf) diff --git a/src/dlopen.cpp b/src/dlopen.cpp index 702ad37a..c1d82105 100644 --- a/src/dlopen.cpp +++ b/src/dlopen.cpp @@ -1,8 +1,6 @@ -#include "sysconfig.h" +#include #include "sysdeps.h" -#include "uae/api.h" #include "uae/dlopen.h" -//#include "uae/log.h" #define FSUAE @@ -112,4 +110,4 @@ void uae_dlopen_patch_common(UAE_DLHANDLE handle) write_log(_T("DLOPEN: Patching common functions\n")); // *((uae_log_function *)ptr) = &uae_log; } -} \ No newline at end of file +} diff --git a/src/drawing.cpp b/src/drawing.cpp index 1af9a2bf..d2f595aa 100644 --- a/src/drawing.cpp +++ b/src/drawing.cpp @@ -26,11 +26,11 @@ To prevent extremely bad things (think pixels cut in half by window borders) from happening, all ports should restrict window widths to be multiples of 16 pixels. */ -#include "sysconfig.h" -#include "sysdeps.h" +#include +#include +#include -#include -#include +#include "sysdeps.h" #include "options.h" #include "threaddep/thread.h" @@ -39,13 +39,11 @@ #include "custom.h" #include "newcpu.h" #include "xwin.h" -#include "autoconf.h" #include "gui.h" #include "picasso96.h" #include "drawing.h" #include "savestate.h" #include "statusline.h" -#include "inputdevice.h" #include "cd32_fmv.h" #include "audio.h" #include "devices.h" @@ -1018,7 +1016,7 @@ STATIC_INLINE bool get_genlock_transparency(uae_u8 v) } } -#include "linetoscr.cpp" +#include "linetoscr.cpp.in" #define LTPARMS src_pixel, start, stop @@ -3543,4 +3541,4 @@ int isvsync(void) if (picasso_on) return isvsync_rtg(); return isvsync_chipset(); -} \ No newline at end of file +} diff --git a/src/events.cpp b/src/events.cpp index 3831fdd9..cf154b7f 100644 --- a/src/events.cpp +++ b/src/events.cpp @@ -7,8 +7,8 @@ * Copyright 1995 Alessandro Bissacco * Copyright 2000-2012 Toni Wilen */ +#include -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" diff --git a/src/expansion.cpp b/src/expansion.cpp index 8009cdfd..f27aaed2 100644 --- a/src/expansion.cpp +++ b/src/expansion.cpp @@ -8,25 +8,20 @@ * - added gfxcard code * */ +#include +#include -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" -#include "uae.h" -#include "traps.h" #include "memory.h" #include "rommgr.h" -#include "custom.h" #include "newcpu.h" #include "savestate.h" -#include "zfile.h" -#include "threaddep/thread.h" #include "gfxboard.h" #include "cd32_fmv.h" #include "gayle.h" #include "autoconf.h" -#include "filesys.h" #define CARD_FLAG_CAN_Z3 1 diff --git a/src/fdi2raw.cpp b/src/fdi2raw.cpp index 77ff2d28..23a33a5e 100644 --- a/src/fdi2raw.cpp +++ b/src/fdi2raw.cpp @@ -29,17 +29,14 @@ with this program; if not, write to the Free Software Foundation, Inc., */ -#include #include #include /* IF UAE */ -#include "sysconfig.h" #include "sysdeps.h" #include "zfile.h" #include "uae.h" /* ELSE */ -//#include "types.h" #include "fdi2raw.h" #include "crc32.h" @@ -47,7 +44,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #undef DEBUG #define VERBOSE -#include #ifdef DEBUG static TCHAR *datalog (uae_u8 *src, int len) diff --git a/src/filesys.cpp b/src/filesys.cpp index 88ff9571..b04cbce3 100644 --- a/src/filesys.cpp +++ b/src/filesys.cpp @@ -21,17 +21,17 @@ * Will probably fail spectacularly in some cases if the filesystem is * modified at the same time by another process while UAE is running. */ +#include +#include +#include -#include "sysconfig.h" #include "sysdeps.h" #include "threaddep/thread.h" #include "options.h" -#include "traps.h" #include "uae.h" #include "memory.h" #include "custom.h" -#include "newcpu.h" #include "filesys.h" #include "autoconf.h" #include "fsusage.h" @@ -45,7 +45,6 @@ #include "bsdsocket.h" #include "uaeresource.h" #include "inputdevice.h" -#include "blkdev.h" #include "picasso96.h" #include "rommgr.h" @@ -7499,7 +7498,7 @@ void filesys_install_code (void) bootrom_header = 3 * 4; align(4); bootrom_start = here (); - #include "filesys_bootrom.cpp" + #include "filesys_bootrom.cpp.in" items = dlg (bootrom_start + 8) & 0xffff; /* The last offset comes from the code itself, look for it near the top. */ diff --git a/src/filesys.sh b/src/filesys.sh index e07c14ac..d20ba37d 100644 --- a/src/filesys.sh +++ b/src/filesys.sh @@ -11,4 +11,4 @@ # delete fs.out # # That is what you get if you assemble/link with a68k/blink -od -v -t xC -w8 filesys |tail -n +5 | sed -e "s,^.......,," -e "s,[0123456789abcdefABCDEF][0123456789abcdefABCDEF],db(0x&);,g" > filesys_bootrom.cpp +od -v -t xC -w8 filesys |tail -n +5 | sed -e "s,^.......,," -e "s,[0123456789abcdefABCDEF][0123456789abcdefABCDEF],db(0x&);,g" > filesys_bootrom.cpp.in diff --git a/src/filesys_bootrom.cpp b/src/filesys_bootrom.cpp.in similarity index 100% rename from src/filesys_bootrom.cpp rename to src/filesys_bootrom.cpp.in diff --git a/src/flashrom.cpp b/src/flashrom.cpp index 75dc2a4d..522464bc 100644 --- a/src/flashrom.cpp +++ b/src/flashrom.cpp @@ -8,14 +8,10 @@ * (c) 2014 Toni Wilen */ -#include "sysconfig.h" #include "sysdeps.h" -#include "options.h" #include "zfile.h" #include "flashrom.h" -#include "memory.h" -#include "newcpu.h" #include "gui.h" #include "uae.h" diff --git a/src/fpp.cpp b/src/fpp.cpp index dd2d1135..47fb3f3a 100644 --- a/src/fpp.cpp +++ b/src/fpp.cpp @@ -9,27 +9,18 @@ */ #define __USE_ISOC9X /* We might be able to pick up a NaN */ +#include +#include -#include -#include -#include -#include "sysconfig.h" +//#include "sysconfig.h" #include "sysdeps.h" -#include "options.h" -#include "memory.h" -#include "uae/attributes.h" -#include "uae/vm.h" -#include "custom.h" -#include "newcpu.h" -#include "fpp.h" #include "savestate.h" -#include "cpu_prefetch.h" static void fpsr_set_exception(uae_u32 exception); -#include "fpp_native.cpp" +#include "fpp_native.cpp.in" struct fpp_cr_entry { uae_u32 val[3]; diff --git a/src/fpp_native.cpp b/src/fpp_native.cpp.in similarity index 100% rename from src/fpp_native.cpp rename to src/fpp_native.cpp.in diff --git a/src/fsdb.cpp b/src/fsdb.cpp index 680c5743..41967016 100644 --- a/src/fsdb.cpp +++ b/src/fsdb.cpp @@ -7,20 +7,16 @@ * Copyright 1999 Bernd Schmidt */ -#include "sysconfig.h" +#include +#include +#include +#include + #include "sysdeps.h" #include "options.h" -#include "uae.h" -#include "traps.h" #include "memory.h" -#include "custom.h" -#include "newcpu.h" -#include "filesys.h" -#include "autoconf.h" -#include "fsusage.h" #include "fsdb.h" -#include "uae/io.h" /* The on-disk format is as follows: * Offset 0, 1 byte, valid diff --git a/src/fsdb_unix.cpp b/src/fsdb_unix.cpp index ffe9cf26..9da406bf 100644 --- a/src/fsdb_unix.cpp +++ b/src/fsdb_unix.cpp @@ -8,12 +8,14 @@ * Copyright 1999 Bernd Schmidt */ -#include "sysconfig.h" +#include +#include +#include +#include + #include "sysdeps.h" -#include "config.h" #include "fsdb.h" -#include "uae.h" /* these are deadly (but I think allowed on the Amiga): */ #define NUM_EVILCHARS 7 diff --git a/src/fsusage.cpp b/src/fsusage.cpp index 9893e4b8..53992816 100644 --- a/src/fsusage.cpp +++ b/src/fsusage.cpp @@ -15,15 +15,15 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "sysconfig.h" -#include "sysdeps.h" - #include #include +#include +#include +#include +#include + +#include "sysconfig.h" -#if HAVE_SYS_STATFS_H -# include -#endif #if defined(STAT_STATVFS) && !defined(__ANDROID__) #include #else diff --git a/src/gayle.cpp b/src/gayle.cpp index 7be89512..1142d927 100644 --- a/src/gayle.cpp +++ b/src/gayle.cpp @@ -10,11 +10,13 @@ #define MBRES_LOG 0 #define PCMCIA_LOG 0 -#include "sysconfig.h" +#include +#include +#include +#include + #include "sysdeps.h" - #include "options.h" - #include "memory.h" #include "custom.h" #include "newcpu.h" @@ -22,13 +24,9 @@ #include "gayle.h" #include "savestate.h" #include "uae.h" -#include "gui.h" #include "threaddep/thread.h" -#include "blkdev.h" -#include "scsi.h" #include "ide.h" #include "autoconf.h" -#include "rommgr.h" #define PCMCIA_SRAM 1 #define PCMCIA_IDE 2 diff --git a/src/genblitter.cpp b/src/genblitter.cpp deleted file mode 100644 index 981a7b77..00000000 --- a/src/genblitter.cpp +++ /dev/null @@ -1,188 +0,0 @@ - /* - * UAE - The Un*x Amiga Emulator - * - * Optimized blitter minterm function generator - * - * Copyright 1995,1996 Bernd Schmidt - * Copyright 1996 Alessandro Bissacco - */ - -#include "sysconfig.h" -#include -#include - -#include "genblitter.h" - -/* Here is the minterm table used in blitter function generation */ - -static unsigned char blttbl[]= { - 0x00, 0x0a, 0x2a, 0x30, 0x3a, 0x3c, 0x4a, 0x6a, 0x8a, 0x8c, 0x9a, 0xa8, - 0xaa, 0xb1, 0xca, 0xcc, 0xd8, 0xe2, 0xea, 0xf0, 0xfa, 0xfc -}; - -static void generate_include(void) -{ - int minterm; - printf("STATIC_INLINE uae_u32 blit_func(const uae_u32 srca, const uae_u32 srcb, const uae_u32 srcc, const uae_u8 mt)\n{\nswitch(mt){\n"); - for (minterm = 0; minterm < 256; minterm++) { - printf("case 0x%x:\n", minterm); - printf("\treturn %s;\n", blitops[minterm].s); - } - printf("}\n"); - printf("return 0;\n"); /* No, sir, it doesn't! */ - printf("}\n"); -} - -static void generate_func(void) -{ - unsigned int i; - printf("#include \"sysconfig.h\"\n"); - printf("#include \"sysdeps.h\"\n"); - printf("#include \"options.h\"\n"); - printf("#include \"include/memory.h\"\n"); - printf("#include \"newcpu.h\"\n"); - printf("#include \"custom.h\"\n"); - printf("#include \"savestate.h\"\n"); - printf("#include \"blitter.h\"\n"); - printf("#include \"blitfunc.h\"\n\n"); - - for (i = 0; i < sizeof(blttbl); i++) { - int active = blitops[blttbl[i]].used; - int a_is_on = active & 1, b_is_on = active & 2, c_is_on = active & 4; - printf("void blitdofast_%x (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)\n",blttbl[i]); - printf("{\n"); - printf("int i,j;\n"); - printf("uae_u32 totald = 0;\n"); - if (b_is_on) printf("uae_u32 srcb = b->bltbhold;\n"); - if (c_is_on) printf("uae_u32 srcc = b->bltcdat;\n"); - printf("uae_u32 dstd=0;\n"); - printf("uaecptr dstp = 0;\n"); - printf("for (j = 0; j < b->vblitsize; j++) {\n"); - printf("\tfor (i = 0; i < b->hblitsize; i++) {\n\t\tuae_u32 bltadat, srca;\n\n"); - if (c_is_on) printf("\t\tif (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; }\n"); - if (b_is_on) printf("\t\tif (ptb) {\n\t\t\tuae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2;\n"); - if (b_is_on) printf("\t\t\tsrcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift;\n"); - if (b_is_on) printf("\t\t\tb->bltbold = bltbdat;\n\t\t}\n"); - if (a_is_on) printf("\t\tif (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; }\n"); - if (a_is_on) printf("\t\tbltadat &= blit_masktable[i];\n"); - if (a_is_on) printf("\t\tsrca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift;\n"); - if (a_is_on) printf("\t\tb->bltaold = bltadat;\n"); - printf("\t\tif (dstp)\n\t\t\tchipmem_wput_indirect (dstp, dstd);\n"); - printf("\t\tdstd = (%s);\n", blitops[blttbl[i]].s); - printf("\t\ttotald |= dstd;\n"); - printf("\t\tif (ptd) { dstp = ptd; ptd += 2; }\n"); - printf("\t}\n"); - if (a_is_on) printf("\tif (pta) pta += b->bltamod;\n"); - if (b_is_on) printf("\tif (ptb) ptb += b->bltbmod;\n"); - if (c_is_on) printf("\tif (ptc) ptc += b->bltcmod;\n"); - printf("\tif (ptd) ptd += b->bltdmod;\n"); - printf("}\n"); - if (b_is_on) printf("b->bltbhold = srcb;\n"); - if (c_is_on) printf("b->bltcdat = srcc;\n"); - printf("\t\tif (dstp)\n\t\t\tchipmem_wput_indirect (dstp, dstd);\n"); - printf("if ((totald<<16) != 0) b->blitzero = 0;\n"); - printf("}\n"); - - printf("void blitdofast_desc_%x (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)\n",blttbl[i]); - printf("{\n"); - printf("uae_u32 totald = 0;\n"); - printf("int i,j;\n"); - if (b_is_on) printf("uae_u32 srcb = b->bltbhold;\n"); - if (c_is_on) printf("uae_u32 srcc = b->bltcdat;\n"); - printf("uae_u32 dstd = 0;\n"); - printf("uaecptr dstp = 0;\n"); - printf("for (j = 0; j < b->vblitsize; j++) {\n"); - printf("\tfor (i = 0; i < b->hblitsize; i++) {\n\t\tuae_u32 bltadat, srca;\n"); - if (c_is_on) printf("\t\tif (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; }\n"); - if (b_is_on) printf("\t\tif (ptb) {\n\t\t\tuae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2;\n"); - if (b_is_on) printf("\t\t\tsrcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift;\n"); - if (b_is_on) printf("\t\t\tb->bltbold = bltbdat;\n\t\t}\n"); - if (a_is_on) printf("\t\tif (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; }\n"); - if (a_is_on) printf("\t\tbltadat &= blit_masktable[i];\n"); - if (a_is_on) printf("\t\tsrca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift;\n"); - if (a_is_on) printf("\t\tb->bltaold = bltadat;\n"); - printf("\t\tif (dstp)\n\t\t\tchipmem_wput_indirect (dstp, dstd);\n"); - printf("\t\tdstd = (%s);\n", blitops[blttbl[i]].s); - printf("\t\ttotald |= dstd;\n"); - printf("\t\tif (ptd) { dstp = ptd; ptd -= 2; }\n"); - printf("\t}\n"); - if (a_is_on) printf("\tif (pta) pta -= b->bltamod;\n"); - if (b_is_on) printf("\tif (ptb) ptb -= b->bltbmod;\n"); - if (c_is_on) printf("\tif (ptc) ptc -= b->bltcmod;\n"); - printf("\tif (ptd) ptd -= b->bltdmod;\n"); - printf("}\n"); - if (b_is_on) printf("b->bltbhold = srcb;\n"); - if (c_is_on) printf("b->bltcdat = srcc;\n"); - printf("\t\tif (dstp)\n\t\t\tchipmem_wput_indirect (dstp, dstd);\n"); - printf("if ((totald<<16) != 0) b->blitzero = 0;\n"); - printf("}\n"); - } -} - -static void generate_table(void) -{ - unsigned int index = 0; - unsigned int i; - printf("#include \"sysconfig.h\"\n"); - printf("#include \"sysdeps.h\"\n"); - printf("#include \"options.h\"\n"); - printf("#include \"include/memory.h\"\n"); - printf("#include \"newcpu.h\"\n"); - printf("#include \"custom.h\"\n"); - printf("#include \"savestate.h\"\n"); - printf("#include \"blitter.h\"\n"); - printf("#include \"blitfunc.h\"\n\n"); - printf("blitter_func * const blitfunc_dofast[256] = {\n"); - for (i = 0; i < 256; i++) { - if (index < sizeof(blttbl) && i == blttbl[index]) { - printf("blitdofast_%x",i); - index++; - } - else printf("0"); - if (i < 255) printf(", "); - if ((i & 7) == 7) printf("\n"); - } - printf("};\n\n"); - - index = 0; - printf("blitter_func * const blitfunc_dofast_desc[256] = {\n"); - for (i = 0; i < 256; i++) { - if (index < sizeof(blttbl) && i == blttbl[index]) { - printf("blitdofast_desc_%x",i); - index++; - } - else printf("0"); - if (i < 255) printf(", "); - if ((i & 7) == 7) printf("\n"); - } - printf("};\n"); -} - -static void generate_header(void) -{ - unsigned int i; - for (i = 0; i < sizeof(blttbl); i++) { - printf("extern blitter_func blitdofast_%x;\n",blttbl[i]); - printf("extern blitter_func blitdofast_desc_%x;\n",blttbl[i]); - } -} - -int main(int argc, char **argv) -{ - char mode = 'i'; - - if (argc == 2) mode = *argv[1]; - switch (mode) { - case 'i': generate_include(); - break; - case 'f': generate_func(); - break; - case 't': generate_table(); - break; - case 'h': generate_header(); - break; - default: abort(); - } - return 0; -} - diff --git a/src/gencpu.cpp b/src/gencpu.cpp deleted file mode 100644 index 8bf15edc..00000000 --- a/src/gencpu.cpp +++ /dev/null @@ -1,4242 +0,0 @@ -/* -* UAE - The Un*x Amiga Emulator -* -* MC68000 emulation generator -* -* This is a fairly stupid program that generates a lot of case labels that -* can be #included in a switch statement. -* As an alternative, it can generate functions that handle specific -* MC68000 instructions, plus a prototype header file and a function pointer -* array to look up the function for an opcode. -* Error checking is bad, an illegal table68k file will cause the program to -* call abort(). -* The generated code is sometimes sub-optimal, an optimizing compiler should -* take care of this. -* -* The source for the insn timings is Markt & Technik's Amiga Magazin 8/1992. -* -* Copyright 1995, 1996, 1997, 1998, 1999, 2000 Bernd Schmidt -*/ - -#include "sysconfig.h" -#include "sysdeps.h" -#include - -#include "readcpu.h" - -#define BOOL_TYPE "int" -/* Define the minimal 680x0 where NV flags are not affected by xBCD instructions. */ -#define xBCD_KEEPS_N_FLAG 4 -#define xBCD_KEEPS_V_FLAG 2 - -static FILE *headerfile; -static FILE *stblfile; - -static int using_prefetch, using_indirect; -static int using_exception_3; -static int using_simple_cycles; -static int cpu_level, cpu_generic; -static int count_read, count_write, count_cycles, count_ncycles; -static int count_read_ea, count_write_ea, count_cycles_ea; -static int did_prefetch; - -static int optimized_flags; - -#define GF_APDI 1 -#define GF_AD8R 2 -#define GF_PC8R 4 -#define GF_AA 7 -#define GF_NOREFILL 8 -#define GF_PREFETCH 16 -#define GF_FC 32 -#define GF_MOVE 64 -#define GF_IR2IRC 128 -#define GF_LRMW 256 -#define GF_NOFAULTPC 512 -#define GF_RMW 1024 -#define GF_OPCE020 2048 - -/* For the current opcode, the next lower level that will have different code. -* Initialized to -1 for each opcode. If it remains unchanged, indicates we -* are done with that opcode. */ -static int next_cpu_level; - -static int *opcode_map; -static int *opcode_next_clev; -static int *opcode_last_postfix; -static unsigned long *counts; -static int generate_stbl; -static int disp020cnt; -static bool genastore_done; - -#define GENA_GETV_NO_FETCH 0 -#define GENA_GETV_FETCH 1 -#define GENA_GETV_FETCH_ALIGN 2 -#define GENA_MOVEM_DO_INC 0 -#define GENA_MOVEM_NO_INC 1 -#define GENA_MOVEM_MOVE16 2 - -static const char *srcl, *dstl; -static const char *srcw, *dstw; -static const char *srcb, *dstb; -static const char *srcblrmw, *srcwlrmw, *srcllrmw; -static const char *dstblrmw, *dstwlrmw, *dstllrmw; -static const char *prefetch_long, *prefetch_word, *prefetch_opcode; -static const char *srcli, *srcwi, *srcbi, *nextl, *nextw; -static const char *srcld, *dstld; -static const char *srcwd, *dstwd; -static const char *do_cycles, *disp000, *disp020, *getpc; - -#define fetchmode_fea 1 -#define fetchmode_cea 2 -#define fetchmode_fiea 3 -#define fetchmode_ciea 4 -#define fetchmode_jea 5 - -NORETURN static void term (void) -{ - printf("Abort!\n"); - abort (); -} -NORETURN static void term (const char *err) -{ - printf ("%s\n", err); - term (); -} - -static void read_counts (void) -{ - FILE *file; - unsigned int opcode, count, total; - char name[20]; - int nr = 0; - memset (counts, 0, 65536 * sizeof *counts); - - count = 0; - file = fopen ("frequent.68k", "r"); - if (file) { - if (fscanf (file, "Total: %u\n", &total) == 0) { - abort (); - } - while (fscanf (file, "%x: %u %s\n", &opcode, &count, name) == 3) { - opcode_next_clev[nr] = 5; - opcode_last_postfix[nr] = -1; - opcode_map[nr++] = opcode; - counts[opcode] = count; - } - fclose (file); - } - if (nr == nr_cpuop_funcs) - return; - for (opcode = 0; opcode < 0x10000; opcode++) { - if (table68k[opcode].handler == -1 && table68k[opcode].mnemo != i_ILLG - && counts[opcode] == 0) - { - opcode_next_clev[nr] = 5; - opcode_last_postfix[nr] = -1; - opcode_map[nr++] = opcode; - counts[opcode] = count; - } - } - if (nr != nr_cpuop_funcs) - term (); -} - -static char endlabelstr[80]; -static int endlabelno = 0; -static int need_endlabel; -static int genamode_cnt, genamode8r_offset[2]; - -static int n_braces, limit_braces; -static int m68k_pc_offset, m68k_pc_offset_old; -static int m68k_pc_total; -static int branch_inst; -static int insn_n_cycles; -static int ir2irc; - -static void fpulimit (void) -{ - if (limit_braces) - return; - printf ("\n#ifdef FPUEMU\n"); - limit_braces = n_braces; - n_braces = 0; -} - -static int s_count_read, s_count_write, s_count_cycles, s_count_ncycles; - -static void push_ins_cnt(void) -{ - s_count_read = count_read; - s_count_write = count_write; - s_count_cycles = count_cycles; - s_count_ncycles = count_ncycles; -} -static void pop_ins_cnt(void) -{ - count_read = s_count_read; - count_write = s_count_write; - count_cycles = s_count_cycles; - count_ncycles = s_count_ncycles; -} - -static void returncycles (const char *s, int cycles) -{ - if (using_simple_cycles) - printf ("%sreturn %d * CYCLE_UNIT / 2 + count_cycles;\n", s, cycles); - else - printf ("%sreturn %d * CYCLE_UNIT / 2;\n", s, cycles); -} - -static void returncycles_exception (char *s, int cycles) -{ - printf ("\t\t%sreturn %d * CYCLE_UNIT / 2;\n", s, cycles); -} - -static void addcycles000_nonces(const char *s, const char *sc) -{ - if (using_simple_cycles) { - printf("%scount_cycles += (%s) * CYCLE_UNIT / 2;\n", s, sc); - count_ncycles++; - } -} -static void addcycles000_nonce(const char *s, int c) -{ - if (using_simple_cycles) { - printf("%scount_cycles += %d * CYCLE_UNIT / 2;\n", s, c); - count_ncycles++; - } -} - -static void addcycles000 (int cycles) -{ - count_cycles += cycles; -} -static void addcycles000_2 (const char *s, int cycles) -{ - count_cycles += cycles; -} - -static void addcycles000_3 (const char *s) -{ - count_ncycles++; -} - -static int isreg (amodes mode) -{ - if (mode == Dreg || mode == Areg) - return 1; - return 0; -} - -static void start_brace (void) -{ - n_braces++; - printf ("{"); -} - -static void close_brace (void) -{ - assert (n_braces > 0); - n_braces--; - printf ("}"); -} - -static void finish_braces (void) -{ - while (n_braces > 0) - close_brace (); -} - -static void pop_braces (int to) -{ - while (n_braces > to) - close_brace (); -} - -static int bit_size (int size) -{ - switch (size) { - case sz_byte: return 8; - case sz_word: return 16; - case sz_long: return 32; - default: term (); - } - return 0; -} - -static const char *bit_mask (int size) -{ - switch (size) { - case sz_byte: return "0xff"; - case sz_word: return "0xffff"; - case sz_long: return "0xffffffff"; - default: term (); - } - return 0; -} - -static void gen_nextilong2 (const char *type, const char *name, int flags, int movem) -{ - int r = m68k_pc_offset; - m68k_pc_offset += 4; - - printf ("\t%s %s;\n", type, name); - if (using_prefetch) { - if (flags & GF_NOREFILL) { - printf ("\t%s = %s (%d) << 16;\n", name, prefetch_word, r + 2); - count_read++; - printf ("\t%s |= regs.irc;\n", name); - insn_n_cycles += 4; - } else { - printf ("\t%s = %s (%d) << 16;\n", name, prefetch_word, r + 2); - count_read += 2; - printf ("\t%s |= %s (%d);\n", name, prefetch_word, r + 4); - insn_n_cycles += 8; - } - } else { - count_read += 2; - insn_n_cycles += 8; - printf ("\t%s = %s (%d);\n", name, prefetch_long, r); - } -} -static void gen_nextilong (const char *type, const char *name, int flags) -{ - gen_nextilong2 (type, name, flags, 0); -} - -static const char *gen_nextiword (int flags) -{ - static char buffer[80]; - int r = m68k_pc_offset; - m68k_pc_offset += 2; - - if (using_prefetch) { - if (flags & GF_NOREFILL) { - strcpy (buffer, "regs.irc"); - } else { - sprintf (buffer, "%s (%d)", prefetch_word, r + 2); - count_read++; - insn_n_cycles += 4; - } - } else { - sprintf (buffer, "%s (%d)", prefetch_word, r); - count_read++; - insn_n_cycles += 4; - } - return buffer; -} - -static const char *gen_nextibyte (int flags) -{ - static char buffer[80]; - int r = m68k_pc_offset; - m68k_pc_offset += 2; - - insn_n_cycles += 4; - if (using_prefetch) { - if (flags & GF_NOREFILL) { - strcpy (buffer, "(uae_u8)regs.irc"); - } else { - sprintf (buffer, "(uae_u8)%s (%d)", prefetch_word, r + 2); - insn_n_cycles += 4; - count_read++; - } - } else { - sprintf (buffer, "%s (%d)", srcbi, r); - insn_n_cycles += 4; - count_read++; - } - return buffer; -} - -static void makefromsr (void) -{ - printf ("\tMakeFromSR();\n"); -} - -static void makefromsr_t0(void) -{ - printf ("\tMakeFromSR_T0();\n"); -} - -static void irc2ir (bool dozero) -{ - if (!using_prefetch) - return; - if (ir2irc) - return; - ir2irc = 1; - printf ("\tregs.ir = regs.irc;\n"); - if (dozero) - printf ("\tregs.irc = 0;\n"); -} -static void irc2ir (void) -{ - irc2ir (false); -} - -static void fill_prefetch_2 (void) -{ - if (!using_prefetch) - return; - printf ("\t%s (%d);\n", prefetch_word, m68k_pc_offset + 2); - did_prefetch = 1; - ir2irc = 0; - count_read++; - insn_n_cycles += 4; -} - -static void fill_prefetch_1 (int o) -{ - if (using_prefetch) { - printf ("\t%s (%d);\n", prefetch_word, o); - did_prefetch = 1; - ir2irc = 0; - count_read++; - insn_n_cycles += 4; - } -} - -static void fill_prefetch_full_2 (void) -{ - if (using_prefetch) { - fill_prefetch_1 (0); - irc2ir (); - fill_prefetch_1 (2); - } -} - -// don't check trace bits -static void fill_prefetch_full_ntx (void) -{ - if (using_prefetch) { - fill_prefetch_1 (0); - irc2ir (); - fill_prefetch_1 (2); - } else { - // Count cycles for 2nd prefetch - count_read++; - insn_n_cycles += 4; - } -} -// check trace bits -static void fill_prefetch_full (void) -{ - if (using_prefetch) { - fill_prefetch_1 (0); - irc2ir (); - fill_prefetch_1 (2); - } else { - if (cpu_level >= 2) { - printf("\tif(regs.t0) check_t0_trace();\n"); - } - // Count cycles for 2nd prefetch - count_read++; - insn_n_cycles += 4; - } -} - -// 68000 and 68010 only -static void fill_prefetch_full_000 (void) -{ - if (!using_prefetch) - return; - fill_prefetch_full (); -} - -static void fill_prefetch_0 (void) -{ - if (!using_prefetch) - return; - printf ("\t%s (0);\n", prefetch_word); - did_prefetch = 1; - ir2irc = 0; - count_read++; - insn_n_cycles += 4; -} - -static void fill_prefetch_next_1 (void) -{ - irc2ir (); - fill_prefetch_1 (m68k_pc_offset + 2); -} - -static void fill_prefetch_next (void) -{ - if (using_prefetch) { - fill_prefetch_next_1 (); - } -} - -static void fill_prefetch_finish (void) -{ - if (did_prefetch) - return; - if (using_prefetch) { - fill_prefetch_1 (m68k_pc_offset); - } -} - -static void setpc (const char *format, ...) -{ - va_list parms; - char buffer[1000]; - - va_start (parms, format); - _vsnprintf (buffer, 1000 - 1, format, parms); - va_end (parms); - - if (using_prefetch) - printf ("\tm68k_setpci (%s);\n", buffer); - else - printf ("\tm68k_setpc (%s);\n", buffer); -} - -static void incpc (const char *format, ...) -{ - va_list parms; - char buffer[1000]; - - va_start (parms, format); - _vsnprintf (buffer, 1000 - 1, format, parms); - va_end (parms); - - if (using_prefetch) - printf ("\tm68k_incpci (%s);\n", buffer); - else - printf ("\tm68k_incpc (%s);\n", buffer); -} - -static void sync_m68k_pc (void) -{ - m68k_pc_offset_old = m68k_pc_offset; - if (m68k_pc_offset == 0) - return; - incpc ("%d", m68k_pc_offset); - m68k_pc_total += m68k_pc_offset; - m68k_pc_offset = 0; -} - -static void clear_m68k_offset(void) -{ - m68k_pc_total += m68k_pc_offset; - m68k_pc_offset = 0; -} - -static void sync_m68k_pc_noreset (void) -{ - sync_m68k_pc (); - m68k_pc_offset = m68k_pc_offset_old; -} - -static void next_level_000 (void) -{ - if (next_cpu_level < 0) - next_cpu_level = 0; -} - -/* 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 */ - -/* fixup indicates if we want to fix up address registers in pre decrement -* or post increment mode now (0) or later (1). A value of 2 will then be -* used to do the actual fix up. This allows to do all memory readings -* before any register is modified, and so to rerun operation without -* side effect in case a bus fault is generated by any memory access. -* XJ - 2006/11/13 */ - -static void genamode2x (amodes mode, const char *reg, wordsizes size, const char *name, int getv, int movem, int flags, int fetchmode) -{ - char namea[100]; - bool rmw = false; - int pc_68000_offset = m68k_pc_offset; - int pc_68000_offset_fetch = 0; - int pc_68000_offset_store = 0; - - sprintf (namea, "%sa", name); - - if (mode == Ad8r || mode == PC8r) { - genamode8r_offset[genamode_cnt] = m68k_pc_total + m68k_pc_offset; - genamode_cnt++; - } - - start_brace (); - - switch (mode) { - case Dreg: - if (movem) - term (); - if (getv == 1) - switch (size) { - case sz_byte: -#ifdef USE_DUBIOUS_BIGENDIAN_OPTIMIZATION - /* This causes the target compiler to generate better code on few systems */ - printf ("\tuae_s8 %s = ((uae_u8*)&m68k_dreg (regs, %s))[3];\n", name, reg); -#else - printf ("\tuae_s8 %s = m68k_dreg (regs, %s);\n", name, reg); -#endif - break; - case sz_word: -#ifdef USE_DUBIOUS_BIGENDIAN_OPTIMIZATION - printf ("\tuae_s16 %s = ((uae_s16*)&m68k_dreg (regs, %s))[1];\n", name, reg); -#else - printf ("\tuae_s16 %s = m68k_dreg (regs, %s);\n", name, reg); -#endif - break; - case sz_long: - printf ("\tuae_s32 %s = m68k_dreg (regs, %s);\n", name, reg); - break; - default: - term (); - } - return; - case Areg: - if (movem) - term (); - if (getv == 1) - switch (size) { - case sz_word: - printf ("\tuae_s16 %s = m68k_areg (regs, %s);\n", name, reg); - break; - case sz_long: - printf ("\tuae_s32 %s = m68k_areg (regs, %s);\n", name, reg); - break; - default: - term (); - } - return; - case Aind: // (An) - printf ("\tuaecptr %sa;\n", name); - printf ("\t%sa = m68k_areg (regs, %s);\n", name, reg); - break; - case Aipi: // (An)+ - printf ("\tuaecptr %sa;\n", name); - printf ("\t%sa = m68k_areg (regs, %s);\n", name, reg); - break; - case Apdi: // -(An) - printf ("\tuaecptr %sa;\n", name); - switch (size) { - case sz_byte: - if (movem) - printf ("\t%sa = m68k_areg (regs, %s);\n", name, reg); - else - printf ("\t%sa = m68k_areg (regs, %s) - areg_byteinc[%s];\n", name, reg, reg); - break; - case sz_word: - printf ("\t%sa = m68k_areg (regs, %s) - %d;\n", name, reg, movem ? 0 : 2); - break; - case sz_long: - printf ("\t%sa = m68k_areg (regs, %s) - %d;\n", name, reg, movem ? 0 : 4); - break; - default: - term (); - } - if (!(flags & GF_APDI)) { - addcycles000 (2); - insn_n_cycles += 2; - count_cycles_ea += 2; - pc_68000_offset_fetch += 2; - } - break; - case Ad16: // (d16,An) - printf ("\tuaecptr %sa;\n", name); - printf ("\t%sa = m68k_areg (regs, %s) + (uae_s32)(uae_s16)%s;\n", name, reg, gen_nextiword (flags)); - count_read_ea++; - break; - case PC16: // (d16,PC,Xn) - printf ("\tuaecptr %sa;\n", name); - printf ("\t%sa = %s + %d;\n", name, getpc, m68k_pc_offset); - printf ("\t%sa += (uae_s32)(uae_s16)%s;\n", name, gen_nextiword (flags)); - break; - case Ad8r: // (d8,An,Xn) - printf ("\tuaecptr %sa;\n", name); - if (cpu_level > 1) { - if (next_cpu_level < 1) - next_cpu_level = 1; - sync_m68k_pc (); - 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), %d);\n", name, disp020, reg, disp020cnt++); - } else { - if (!(flags & GF_AD8R)) { - addcycles000 (2); - insn_n_cycles += 2; - count_cycles_ea += 2; - } - if ((flags & GF_NOREFILL) && using_prefetch) { - printf ("\t%sa = %s (m68k_areg (regs, %s), regs.irc);\n", name, disp000, reg); - } else { - printf ("\t%sa = %s (m68k_areg (regs, %s), %s);\n", name, disp000, reg, gen_nextiword (flags)); - } - count_read_ea++; - } - break; - case PC8r: // (d8,PC,Xn) - printf ("\tuaecptr tmppc;\n"); - printf ("\tuaecptr %sa;\n", name); - if (cpu_level > 1) { - if (next_cpu_level < 1) - next_cpu_level = 1; - sync_m68k_pc (); - start_brace (); - /* This would ordinarily be done in gen_nextiword, which we bypass. */ - insn_n_cycles += 4; - printf ("\ttmppc = %s;\n", getpc); - printf ("\t%sa = %s (tmppc, %d);\n", name, disp020, disp020cnt++); - } else { - printf ("\ttmppc = %s + %d;\n", getpc, m68k_pc_offset); - if (!(flags & GF_PC8R)) { - addcycles000 (2); - insn_n_cycles += 2; - count_cycles_ea += 2; - } - if ((flags & GF_NOREFILL) && using_prefetch) { - printf ("\t%sa = %s (tmppc, regs.irc);\n", name, disp000); - } else { - printf ("\t%sa = %s (tmppc, %s);\n", name, disp000, gen_nextiword (flags)); - } - } - - break; - case absw: - printf ("\tuaecptr %sa;\n", name); - printf ("\t%sa = (uae_s32)(uae_s16)%s;\n", name, gen_nextiword (flags)); - pc_68000_offset_fetch += 2; - break; - case absl: - gen_nextilong2 ("uaecptr", namea, flags, movem); - count_read_ea += 2; - pc_68000_offset_fetch += 4; - pc_68000_offset_store += 2; - break; - case imm: - // fetch immediate address - if (getv != 1) - term (); - switch (size) { - case sz_byte: - printf ("\tuae_s8 %s = %s;\n", name, gen_nextibyte (flags)); - count_read_ea++; - break; - case sz_word: - printf ("\tuae_s16 %s = %s;\n", name, gen_nextiword (flags)); - count_read_ea++; - break; - case sz_long: - gen_nextilong ("uae_s32", name, flags); - count_read_ea += 2; - break; - default: - term (); - } - return; - case imm0: - if (getv != 1) - term (); - printf ("\tuae_s8 %s = %s;\n", name, gen_nextibyte (flags)); - count_read_ea++; - return; - case imm1: - if (getv != 1) - term (); - printf ("\tuae_s16 %s = %s;\n", name, gen_nextiword (flags)); - count_read_ea++; - return; - case imm2: - if (getv != 1) - term (); - gen_nextilong ("uae_s32", name, flags); - count_read_ea += 2; - return; - case immi: - if (getv != 1) - term (); - printf ("\tuae_u32 %s = %s;\n", name, reg); - return; - default: - term (); - } - - /* We get here for all non-reg non-immediate addressing modes to - * actually fetch the value. */ - - int exception_pc_offset = 0; - if (getv == 2) { - // store - if (pc_68000_offset) { - exception_pc_offset = pc_68000_offset + pc_68000_offset_store + 2; - } - } else { - // fetch - exception_pc_offset = pc_68000_offset + pc_68000_offset_fetch; - } - - if ((using_prefetch) && using_exception_3 && getv != 0 && size != sz_byte) { - printf ("\tif (%sa & 1) {\n", name); - if (exception_pc_offset) - incpc("%d", exception_pc_offset); - printf ("\t\texception3_%s(opcode, %sa);\n", getv == 2 ? "write" : "read", name); - returncycles_exception ("", (count_read + 1 + count_write) * 4 + count_cycles); - printf ("\t}\n"); - start_brace (); - } - - if (flags & GF_PREFETCH) - fill_prefetch_next (); - else if (flags & GF_IR2IRC) - irc2ir (true); - - if (getv == 1) { - start_brace (); - if (using_prefetch) { - switch (size) { - case sz_byte: insn_n_cycles += 4; printf ("\tuae_s8 %s = %s (%sa);\n", name, srcb, name); count_read++; break; - case sz_word: insn_n_cycles += 4; printf ("\tuae_s16 %s = %s (%sa);\n", name, srcw, name); count_read++; break; - case sz_long: insn_n_cycles += 8; printf ("\tuae_s32 %s = %s (%sa) << 16; %s |= %s (%sa + 2);\n", name, srcw, name, name, srcw, name); count_read += 2; break; - default: term (); - } - } else { - switch (size) { - case sz_byte: insn_n_cycles += 4; printf ("\tuae_s8 %s = %s (%sa);\n", name, srcb, name); count_read++; break; - case sz_word: insn_n_cycles += 4; printf ("\tuae_s16 %s = %s (%sa);\n", name, srcw, name); count_read++; break; - case sz_long: insn_n_cycles += 8; printf ("\tuae_s32 %s = %s (%sa);\n", name, srcl, name); count_read += 2; break; - default: term (); - } - } - } - - /* We now might have to fix up the register for pre-dec or post-inc - * addressing modes. */ - if (!movem) - switch (mode) { - case Aipi: - switch (size) { - case sz_byte: - printf ("\tm68k_areg (regs, %s) += areg_byteinc[%s];\n", reg, reg); - break; - case sz_word: - printf ("\tm68k_areg (regs, %s) += 2;\n", reg); - break; - case sz_long: - printf ("\tm68k_areg (regs, %s) += 4;\n", reg); - break; - default: - term (); - } - break; - case Apdi: - printf ("\tm68k_areg (regs, %s) = %sa;\n", reg, name); - break; - default: - break; - } - - if (movem == 3) { - close_brace (); - } -} - -static void genamode2 (amodes mode, const char *reg, wordsizes size, const char *name, int getv, int movem, int flags) -{ - genamode2x (mode, reg, size, name, getv, movem, flags, -1); -} - -static void genamode (instr *curi, amodes mode, const char *reg, wordsizes size, const char *name, int getv, int movem, int flags) -{ - genamode2 (mode, reg, size, name, getv, movem, flags); -} - -static void genamode3 (instr *curi, amodes mode, const char *reg, wordsizes size, const char *name, int getv, int movem, int flags) -{ - genamode2x (mode, reg, size, name, getv, movem, flags, curi ? curi->fetchmode : -1); -} - -static void genamodedual (instr *curi, amodes smode, const char *sreg, wordsizes ssize, const char *sname, int sgetv, int sflags, - amodes dmode, const char *dreg, wordsizes dsize, const char *dname, int dgetv, int dflags) -{ - int subhead = 0; - bool eadmode = false; - - genamode3 (curi, smode, sreg, ssize, sname, sgetv, 0, sflags); - genamode3 (NULL, dmode, dreg, dsize, dname, dgetv, 0, dflags | (eadmode == true ? GF_OPCE020 : 0)); -} - -static void genastore_2 (const char *from, amodes mode, const char *reg, wordsizes size, const char *to, int store_dir, int flags) -{ - genastore_done = true; - - switch (mode) { - case Dreg: - switch (size) { - case sz_byte: - printf ("\tm68k_dreg (regs, %s) = (m68k_dreg (regs, %s) & ~0xff) | ((%s) & 0xff);\n", reg, reg, from); - break; - case sz_word: - printf ("\tm68k_dreg (regs, %s) = (m68k_dreg (regs, %s) & ~0xffff) | ((%s) & 0xffff);\n", reg, reg, from); - break; - case sz_long: - printf ("\tm68k_dreg (regs, %s) = (%s);\n", reg, from); - break; - default: - term (); - } - break; - case Areg: - switch (size) { - case sz_word: - printf ("\tm68k_areg (regs, %s) = (uae_s32)(uae_s16)(%s);\n", reg, from); - break; - case sz_long: - printf ("\tm68k_areg (regs, %s) = (%s);\n", reg, from); - break; - default: - term (); - } - break; - case Aind: - case Aipi: - case Apdi: - case Ad16: - case Ad8r: - case absw: - case absl: - case PC16: - case PC8r: - if (using_prefetch) { - switch (size) { - case sz_byte: - insn_n_cycles += 4; - printf ("\t%s (%sa, %s);\n", dstb, to, from); - count_write++; - break; - case sz_word: - insn_n_cycles += 4; - if (cpu_level < 2 && (mode == PC16 || mode == PC8r)) - term (); - printf ("\t%s (%sa, %s);\n", dstw, to, from); - count_write++; - break; - case sz_long: - insn_n_cycles += 8; - if (cpu_level < 2 && (mode == PC16 || mode == PC8r)) - term (); - if (store_dir) - printf ("\t%s (%sa + 2, %s); %s (%sa, %s >> 16);\n", dstw, to, from, dstw, to, from); - else - printf ("\t%s (%sa, %s >> 16); %s (%sa + 2, %s);\n", dstw, to, from, dstw, to, from); - count_write += 2; - break; - default: - term (); - } - } else { - switch (size) { - case sz_byte: - insn_n_cycles += 4; - printf ("\t%s (%sa, %s);\n", dstb, to, from); - count_write++; - break; - case sz_word: - insn_n_cycles += 4; - if (cpu_level < 2 && (mode == PC16 || mode == PC8r)) - term (); - printf ("\t%s (%sa, %s);\n", dstw, to, from); - count_write++; - break; - case sz_long: - insn_n_cycles += 8; - if (cpu_level < 2 && (mode == PC16 || mode == PC8r)) - term (); - printf ("\t%s (%sa, %s);\n", dstl, to, from); - count_write += 2; - break; - default: - term (); - } - } - break; - case imm: - case imm0: - case imm1: - case imm2: - case immi: - term (); - break; - default: - term (); - } -} - -static void genastore (const char *from, amodes mode, const char *reg, wordsizes size, const char *to) -{ - genastore_2 (from, mode, reg, size, to, 0, 0); -} -static void genastore_tas (const char *from, amodes mode, const char *reg, wordsizes size, const char *to) -{ - genastore_2 (from, mode, reg, size, to, 0, GF_LRMW); -} -static void genastore_cas (const char *from, amodes mode, const char *reg, wordsizes size, const char *to) -{ - genastore_2 (from, mode, reg, size, to, 0, GF_LRMW | GF_NOFAULTPC); -} -static void genastore_rev (const char *from, amodes mode, const char *reg, wordsizes size, const char *to) -{ - genastore_2 (from, mode, reg, size, to, 1, 0); -} -static void genastore_fc (const char *from, amodes mode, const char *reg, wordsizes size, const char *to) -{ - genastore_2 (from, mode, reg, size, to, 1, GF_FC); -} - -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)", srcld); - } else { - 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 (NULL, table68k[opcode].dmode, "dstreg", table68k[opcode].size, "src", 2, 1, GF_MOVE); - start_brace (); - printf ("\twhile (dmask) {\n"); - printf ("\t\tm68k_dreg (regs, movem_index1[dmask]) = %s; srca += %d; dmask = movem_next[dmask];\n", getcode, size); - printf ("\t}\n"); - printf ("\twhile (amask) {\n"); - printf ("\t\tm68k_areg (regs, movem_index1[amask]) = %s; srca += %d; amask = movem_next[amask];\n", getcode, size); - printf ("\t}\n"); - if (table68k[opcode].dmode == Aipi) { - printf ("\tm68k_areg (regs, dstreg) = srca;\n"); - count_read++; - } - count_ncycles++; - fill_prefetch_next (); -} - -static void genmovemel_ce (uae_u16 opcode) -{ - int size = table68k[opcode].size == sz_long ? 4 : 2; - printf ("\tuae_u16 mask = %s;\n", gen_nextiword (0)); - printf ("\tuae_u32 dmask = mask & 0xff, amask = (mask >> 8) & 0xff;\n"); - if (using_prefetch && table68k[opcode].size == sz_long) - printf ("\tuae_u32 v;\n"); - genamode (NULL, table68k[opcode].dmode, "dstreg", table68k[opcode].size, "src", 2, 1, GF_AA | GF_MOVE); - if (table68k[opcode].dmode == Ad8r || table68k[opcode].dmode == PC8r) - addcycles000 (2); - start_brace (); - if (table68k[opcode].size == sz_long) { - printf ("\twhile (dmask) {\n"); - if (using_prefetch) { - printf ("\t\tv = %s (srca) << 16;\n", srcw); - printf ("\t\tv |= %s (srca + 2);\n", srcw); - printf ("\t\tm68k_dreg (regs, movem_index1[dmask]) = v;\n"); - } else - printf ("\t\tm68k_dreg (regs, movem_index1[dmask]) = %s (srca);\n", srcl); - printf ("\t\tsrca += %d;\n", size); - printf ("\t\tdmask = movem_next[dmask];\n"); - addcycles000_nonce("\t\t", cpu_level > 1 ? 4 : 8); - printf ("\t}\n"); - printf ("\twhile (amask) {\n"); - if (using_prefetch) { - printf ("\t\tv = %s (srca) << 16;\n", srcw); - printf ("\t\tv |= %s (srca + 2);\n", srcw); - printf ("\t\tm68k_areg (regs, movem_index1[amask]) = v;\n"); - } else - printf ("\t\tm68k_areg (regs, movem_index1[amask]) = %s (srca);\n", srcl); - printf ("\t\tsrca += %d;\n", size); - printf ("\t\tamask = movem_next[amask];\n"); - addcycles000_nonce("\t\t", cpu_level > 1 ? 4 : 8); - printf ("\t}\n"); - } else { - printf ("\twhile (dmask) {\n"); - printf ("\t\tm68k_dreg (regs, movem_index1[dmask]) = (uae_s32)(uae_s16)%s (srca);\n", srcw); - printf ("\t\tsrca += %d;\n", size); - printf ("\t\tdmask = movem_next[dmask];\n"); - addcycles000_nonce("\t\t", 4); - printf ("\t}\n"); - printf ("\twhile (amask) {\n"); - printf ("\t\tm68k_areg (regs, movem_index1[amask]) = (uae_s32)(uae_s16)%s (srca);\n", srcw); - printf ("\t\tsrca += %d;\n", size); - printf ("\t\tamask = movem_next[amask];\n"); - addcycles000_nonce("\t\t", 4); - printf ("\t}\n"); - } - printf ("\t%s (srca);\n", srcw); // and final extra word fetch that goes nowhere.. - count_read++; - if (table68k[opcode].dmode == Aipi) - printf ("\tm68k_areg (regs, dstreg) = srca;\n"); - count_ncycles++; - fill_prefetch_next (); -} - -static void genmovemle (uae_u16 opcode) -{ - char putcode[100]; - int size = table68k[opcode].size == sz_long ? 4 : 2; - - if (table68k[opcode].size == sz_long) { - sprintf (putcode, "%s (srca", dstld); - } else { - sprintf (putcode, "%s (srca", dstwd); - } - count_write += table68k[opcode].size == sz_long ? 2 : 1; - - printf ("\tuae_u16 mask = %s;\n", gen_nextiword (0)); - genamode (NULL, table68k[opcode].dmode, "dstreg", table68k[opcode].size, "src", 2, 1, GF_MOVE); - start_brace (); - if (table68k[opcode].dmode == Apdi) { - printf ("\tuae_u16 amask = mask & 0xff, dmask = (mask >> 8) & 0xff;\n"); - printf ("\tint type = get_cpu_model () >= 68020;\n"); - printf ("\twhile (amask) {\n"); - printf ("\t\tsrca -= %d;\n", size); - - printf ("\t\tif (!type || movem_index2[amask] != dstreg)\n"); - printf ("\t\t\t%s, m68k_areg (regs, movem_index2[amask]));\n", putcode); - printf ("\t\telse\n"); - printf ("\t\t\t%s, m68k_areg (regs, movem_index2[amask]) - %d);\n", putcode, size); - - 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 (); -} - -static void genmovemle_ce (uae_u16 opcode) -{ - int size = table68k[opcode].size == sz_long ? 4 : 2; - - printf ("\tuae_u16 mask = %s;\n", gen_nextiword (0)); - genamode (NULL, table68k[opcode].dmode, "dstreg", table68k[opcode].size, "src", 2, 1, GF_AA | GF_MOVE); - if (table68k[opcode].dmode == Ad8r || table68k[opcode].dmode == PC8r) - addcycles000 (2); - start_brace (); - if (table68k[opcode].size == sz_long) { - if (table68k[opcode].dmode == Apdi) { - printf ("\tuae_u16 amask = mask & 0xff, dmask = (mask >> 8) & 0xff;\n"); - printf ("\twhile (amask) {\n"); - printf ("\t\tsrca -= %d;\n", size); - if(cpu_level >= 2) - printf ("\t\tm68k_areg (regs, dstreg) = srca;\n"); - if (using_prefetch) { - printf ("\t\t%s (srca, m68k_areg (regs, movem_index2[amask]) >> 16);\n", dstw); - printf ("\t\t%s (srca + 2, m68k_areg (regs, movem_index2[amask]));\n", dstw); - } else - printf ("\t\t%s (srca, m68k_areg (regs, movem_index2[amask]));\n", dstl); - printf ("\t\tamask = movem_next[amask];\n"); - addcycles000_nonce("\t\t", cpu_level > 1 ? 3 : 8); - printf ("\t}\n"); - printf ("\twhile (dmask) {\n"); - printf ("\t\tsrca -= %d;\n", size); - if (using_prefetch) { - printf ("\t\t%s (srca, m68k_dreg (regs, movem_index2[dmask]) >> 16);\n", dstw); - printf ("\t\t%s (srca + 2, m68k_dreg (regs, movem_index2[dmask]));\n", dstw); - } else - printf ("\t\t%s (srca, m68k_dreg (regs, movem_index2[dmask]));\n", dstl); - printf ("\t\tdmask = movem_next[dmask];\n"); - addcycles000_nonce("\t\t", cpu_level > 1 ? 3 : 8); - printf ("\t}\n"); - printf ("\tm68k_areg (regs, dstreg) = srca;\n"); - } else { - printf ("\tuae_u16 dmask = mask & 0xff, amask = (mask >> 8) & 0xff;\n"); - printf ("\twhile (dmask) {\n"); - if (using_prefetch) { - printf ("\t\t%s (srca, m68k_dreg (regs, movem_index1[dmask]) >> 16);\n", dstw); - printf ("\t\t%s (srca + 2, m68k_dreg (regs, movem_index1[dmask]));\n", dstw); - } else - printf ("\t\t%s (srca, m68k_dreg (regs, movem_index1[dmask]));\n", dstl); - printf ("\t\tsrca += %d;\n", size); - printf ("\t\tdmask = movem_next[dmask];\n"); - addcycles000_nonce("\t\t", cpu_level > 1 ? 3 : 8); - printf ("\t}\n"); - printf ("\twhile (amask) {\n"); - if (using_prefetch) { - printf ("\t\t%s (srca, m68k_areg (regs, movem_index1[amask]) >> 16);\n", dstw); - printf ("\t\t%s (srca + 2, m68k_areg (regs, movem_index1[amask]));\n", dstw); - } else - printf ("\t\t%s (srca, m68k_areg (regs, movem_index1[amask]));\n", dstl); - printf ("\t\tsrca += %d;\n", size); - printf ("\t\tamask = movem_next[amask];\n"); - addcycles000_nonce("\t\t", cpu_level > 1 ? 3 : 8); - printf ("\t}\n"); - } - } else { - if (table68k[opcode].dmode == Apdi) { - printf ("\tuae_u16 amask = mask & 0xff, dmask = (mask >> 8) & 0xff;\n"); - printf ("\twhile (amask) {\n"); - printf ("\t\tsrca -= %d;\n", size); - if(cpu_level >= 2) - printf ("\t\tm68k_areg (regs, dstreg) = srca;\n"); - printf ("\t\t%s (srca, m68k_areg (regs, movem_index2[amask]));\n", dstw); - printf ("\tamask = movem_next[amask];\n"); - addcycles000_nonce("\t\t", cpu_level > 1 ? 3 : 4); - printf ("\t}\n"); - printf ("\twhile (dmask) {\n"); - printf ("\t\tsrca -= %d;\n", size); - printf ("\t\t%s (srca, m68k_dreg (regs, movem_index2[dmask]));\n", dstw); - printf ("\t\tdmask = movem_next[dmask];\n"); - addcycles000_nonce("\t\t", cpu_level > 1 ? 3 : 4); - printf ("\t}\n"); - printf ("\tm68k_areg (regs, dstreg) = srca;\n"); - } else { - printf ("\tuae_u16 dmask = mask & 0xff, amask = (mask >> 8) & 0xff;\n"); - printf ("\twhile (dmask) {\n"); - printf ("\t\t%s (srca, m68k_dreg (regs, movem_index1[dmask]));\n", dstw); - printf ("\t\tsrca += %d;\n", size); - printf ("\t\tdmask = movem_next[dmask];\n"); - addcycles000_nonce("\t\t", cpu_level > 1 ? 3 : 4); - printf ("\t}\n"); - printf ("\twhile (amask) {\n"); - printf ("\t\t%s (srca, m68k_areg (regs, movem_index1[amask]));\n", dstw); - printf ("\t\tsrca += %d;\n", size); - printf ("\t\tamask = movem_next[amask];\n"); - addcycles000_nonce("\t\t", cpu_level > 1 ? 3 : 4); - printf ("\t}\n"); - } - } - count_ncycles++; - fill_prefetch_next (); -} - -static void duplicate_carry (int n) -{ - int i; - for (i = 0; i <= n; i++) - printf ("\t"); - printf ("COPY_CARRY ();\n"); -} - -typedef enum -{ - flag_logical_noclobber, flag_logical, flag_add, flag_sub, flag_cmp, flag_addx, flag_subx, flag_z, flag_zn, - flag_av, flag_sv -} -flagtypes; - -static void genflags_normal (flagtypes type, wordsizes size, const char *value, const char *src, const char *dst) -{ - char vstr[100], sstr[100], dstr[100]; - char usstr[100], udstr[100]; - char unsstr[100], undstr[100]; - - switch (size) { - case sz_byte: - strcpy (vstr, "((uae_s8)("); - strcpy (usstr, "((uae_u8)("); - break; - case sz_word: - strcpy (vstr, "((uae_s16)("); - strcpy (usstr, "((uae_u16)("); - break; - case sz_long: - strcpy (vstr, "((uae_s32)("); - strcpy (usstr, "((uae_u32)("); - break; - default: - term (); - } - strcpy (unsstr, usstr); - - strcpy (sstr, vstr); - strcpy (dstr, vstr); - strcat (vstr, value); - strcat (vstr, "))"); - strcat (dstr, dst); - strcat (dstr, "))"); - strcat (sstr, src); - strcat (sstr, "))"); - - strcpy (udstr, usstr); - strcat (udstr, dst); - strcat (udstr, "))"); - strcat (usstr, src); - strcat (usstr, "))"); - - strcpy (undstr, unsstr); - strcat (unsstr, "-"); - strcat (undstr, "~"); - strcat (undstr, dst); - strcat (undstr, "))"); - strcat (unsstr, src); - strcat (unsstr, "))"); - - switch (type) { - case flag_logical_noclobber: - case flag_logical: - case flag_z: - case flag_zn: - case flag_av: - case flag_sv: - case flag_addx: - case flag_subx: - break; - - case flag_add: - start_brace (); - printf ("uae_u32 %s = %s + %s;\n", value, udstr, usstr); - break; - case flag_sub: - case flag_cmp: - start_brace (); - printf ("uae_u32 %s = %s - %s;\n", value, udstr, usstr); - break; - } - - switch (type) { - case flag_logical_noclobber: - case flag_logical: - case flag_zn: - break; - - case flag_add: - case flag_sub: - case flag_addx: - case flag_subx: - case flag_cmp: - case flag_av: - case flag_sv: - start_brace (); - printf ("\t" BOOL_TYPE " flgs = %s < 0;\n", sstr); - printf ("\t" BOOL_TYPE " flgo = %s < 0;\n", dstr); - printf ("\t" BOOL_TYPE " flgn = %s < 0;\n", vstr); - break; - } - - switch (type) { - case flag_logical: - printf ("\tCLEAR_CZNV ();\n"); - printf ("\tSET_ZFLG (%s == 0);\n", vstr); - printf ("\tSET_NFLG (%s < 0);\n", vstr); - break; - case flag_logical_noclobber: - printf ("\tSET_ZFLG (%s == 0);\n", vstr); - printf ("\tSET_NFLG (%s < 0);\n", vstr); - break; - case flag_av: - printf ("\tSET_VFLG ((flgs ^ flgn) & (flgo ^ flgn));\n"); - break; - case flag_sv: - printf ("\tSET_VFLG ((flgs ^ flgo) & (flgn ^ flgo));\n"); - break; - case flag_z: - printf ("\tSET_ZFLG (GET_ZFLG () & (%s == 0));\n", vstr); - break; - case flag_zn: - printf ("\tSET_ZFLG (GET_ZFLG () & (%s == 0));\n", vstr); - printf ("\tSET_NFLG (%s < 0);\n", vstr); - break; - case flag_add: - printf ("\tSET_ZFLG (%s == 0);\n", vstr); - printf ("\tSET_VFLG ((flgs ^ flgn) & (flgo ^ flgn));\n"); - printf ("\tSET_CFLG (%s < %s);\n", undstr, usstr); - duplicate_carry (0); - printf ("\tSET_NFLG (flgn != 0);\n"); - break; - case flag_sub: - printf ("\tSET_ZFLG (%s == 0);\n", vstr); - printf ("\tSET_VFLG ((flgs ^ flgo) & (flgn ^ flgo));\n"); - printf ("\tSET_CFLG (%s > %s);\n", usstr, udstr); - duplicate_carry (0); - printf ("\tSET_NFLG (flgn != 0);\n"); - break; - case flag_addx: - printf ("\tSET_VFLG ((flgs ^ flgn) & (flgo ^ flgn));\n"); /* minterm SON: 0x42 */ - printf ("\tSET_CFLG (flgs ^ ((flgs ^ flgo) & (flgo ^ flgn)));\n"); /* minterm SON: 0xD4 */ - duplicate_carry (0); - break; - case flag_subx: - printf ("\tSET_VFLG ((flgs ^ flgo) & (flgo ^ flgn));\n"); /* minterm SON: 0x24 */ - printf ("\tSET_CFLG (flgs ^ ((flgs ^ flgn) & (flgo ^ flgn)));\n"); /* minterm SON: 0xB2 */ - duplicate_carry (0); - break; - case flag_cmp: - printf ("\tSET_ZFLG (%s == 0);\n", vstr); - printf ("\tSET_VFLG ((flgs != flgo) && (flgn != flgo));\n"); - printf ("\tSET_CFLG (%s > %s);\n", usstr, udstr); - printf ("\tSET_NFLG (flgn != 0);\n"); - break; - } -} - -static void genflags (flagtypes type, wordsizes size, const char *value, const char *src, const char *dst) -{ - /* Temporarily deleted 68k/ARM flag optimizations. I'd prefer to have - them in the appropriate m68k.h files and use just one copy of this - code here. The API can be changed if necessary. */ - if (optimized_flags) { - switch (type) { - case flag_add: - case flag_sub: - start_brace (); - printf ("\tuae_u32 %s;\n", value); - break; - - default: - break; - } - - /* At least some of those casts are fairly important! */ - switch (type) { - case flag_logical_noclobber: - printf ("\t{uae_u32 oldcznv = GET_CZNV & ~(FLAGVAL_Z | FLAGVAL_N);\n"); - if (strcmp (value, "0") == 0) { - printf ("\tSET_CZNV (olcznv | FLAGVAL_Z);\n"); - } else { - switch (size) { - case sz_byte: printf ("\toptflag_testb (regs, (uae_s8)(%s));\n", value); break; - case sz_word: printf ("\toptflag_testw (regs, (uae_s16)(%s));\n", value); break; - case sz_long: printf ("\toptflag_testl (regs, (uae_s32)(%s));\n", value); break; - } - printf ("\tIOR_CZNV (oldcznv);\n"); - } - printf ("\t}\n"); - return; - case flag_logical: - if (strcmp (value, "0") == 0) { - printf ("\tSET_CZNV (FLAGVAL_Z);\n"); - } else { - switch (size) { - case sz_byte: printf ("\toptflag_testb (regs, (uae_s8)(%s));\n", value); break; - case sz_word: printf ("\toptflag_testw (regs, (uae_s16)(%s));\n", value); break; - case sz_long: printf ("\toptflag_testl (regs, (uae_s32)(%s));\n", value); break; - } - } - return; - - case flag_add: - switch (size) { - case sz_byte: printf ("\toptflag_addb (regs, %s, (uae_s8)(%s), (uae_s8)(%s));\n", value, src, dst); break; - case sz_word: printf ("\toptflag_addw (regs, %s, (uae_s16)(%s), (uae_s16)(%s));\n", value, src, dst); break; - case sz_long: printf ("\toptflag_addl (regs, %s, (uae_s32)(%s), (uae_s32)(%s));\n", value, src, dst); break; - } - return; - - case flag_sub: - switch (size) { - case sz_byte: printf ("\toptflag_subb (regs, %s, (uae_s8)(%s), (uae_s8)(%s));\n", value, src, dst); break; - case sz_word: printf ("\toptflag_subw (regs, %s, (uae_s16)(%s), (uae_s16)(%s));\n", value, src, dst); break; - case sz_long: printf ("\toptflag_subl (regs, %s, (uae_s32)(%s), (uae_s32)(%s));\n", value, src, dst); break; - } - return; - - case flag_cmp: - switch (size) { - case sz_byte: printf ("\toptflag_cmpb (regs, (uae_s8)(%s), (uae_s8)(%s));\n", src, dst); break; - case sz_word: printf ("\toptflag_cmpw (regs, (uae_s16)(%s), (uae_s16)(%s));\n", src, dst); break; - case sz_long: printf ("\toptflag_cmpl (regs, (uae_s32)(%s), (uae_s32)(%s));\n", src, dst); break; - } - return; - - default: - break; - } - } - - genflags_normal (type, size, value, src, dst); -} - -static void force_range_for_rox (const char *var, wordsizes size) -{ - /* Could do a modulo operation here... which one is faster? */ - switch (size) { - case sz_long: - printf ("\tif (%s >= 33) %s -= 33;\n", var, var); - break; - case sz_word: - printf ("\tif (%s >= 34) %s -= 34;\n", var, var); - printf ("\tif (%s >= 17) %s -= 17;\n", var, var); - break; - case sz_byte: - printf ("\tif (%s >= 36) %s -= 36;\n", var, var); - printf ("\tif (%s >= 18) %s -= 18;\n", var, var); - printf ("\tif (%s >= 9) %s -= 9;\n", var, var); - break; - } -} - -static const char *cmask (wordsizes size) -{ - switch (size) { - case sz_byte: return "0x80"; - case sz_word: return "0x8000"; - case sz_long: return "0x80000000"; - default: term (); - } -} - -static int source_is_imm1_8 (struct instr *i) -{ - return i->stype == 3; -} - -static void shift_ce (amodes dmode, int size) -{ - if (isreg (dmode)) { - int c = size == sz_long ? 4 : 2; - addcycles000_nonces("\t", "2 * ccnt"); - count_cycles += c; - count_ncycles++; - } -} - -// BCHG/BSET/BCLR Dx,Dx or #xx,Dx adds 2 cycles if bit number > 15 -static void bsetcycles (struct instr *curi) -{ - if (curi->size == sz_byte) { - printf ("\tsrc &= 7;\n"); - } else { - printf ("\tsrc &= 31;\n"); - if (isreg (curi->dmode)) { - addcycles000 (2); - if (curi->mnemo != i_BTST) { - addcycles000_nonce("\tif (src > 15) ", 2); - count_ncycles++; - } - } - } -} - -static int islongimm (struct instr *curi) -{ - return (curi->size == sz_long && (curi->smode == Dreg || curi->smode == imm || curi->smode == Areg)); -} - - -static void resetvars (void) -{ - insn_n_cycles = using_prefetch ? 0 : 4; - genamode_cnt = 0; - genamode8r_offset[0] = genamode8r_offset[1] = 0; - m68k_pc_total = 0; - branch_inst = 0; - - ir2irc = 0; - disp020cnt = 0; - genastore_done = false; - - prefetch_long = NULL; - prefetch_opcode = NULL; - srcli = NULL; - srcbi = NULL; - disp000 = "get_disp_ea_000"; - disp020 = "get_disp_ea_020"; - nextw = NULL; - nextl = NULL; - do_cycles = "do_cycles"; - srcwd = srcld = NULL; - dstwd = dstld = NULL; - srcblrmw = NULL; - srcwlrmw = NULL; - srcllrmw = NULL; - dstblrmw = NULL; - dstwlrmw = NULL; - dstllrmw = NULL; - getpc = "m68k_getpc ()"; - - if (using_prefetch) { - // 68000 prefetch - prefetch_word = "get_word_000_prefetch"; - prefetch_long = "get_long_000_prefetch"; - srcwi = "get_wordi_000"; - srcl = "get_long_000"; - dstl = "put_long_000"; - srcw = "get_word_000"; - dstw = "put_word_000"; - srcb = "get_byte_000"; - dstb = "put_byte_000"; - getpc = "m68k_getpci ()"; - } else { - // generic + direct - prefetch_long = "get_dilong"; - prefetch_word = "get_diword"; - nextw = "next_diword"; - nextl = "next_dilong"; - srcli = "get_dilong"; - srcwi = "get_diword"; - srcbi = "get_dibyte"; - if (using_indirect < 0) { - srcl = "get_long_jit"; - dstl = "put_long_jit"; - srcw = "get_word_jit"; - dstw = "put_word_jit"; - srcb = "get_byte_jit"; - dstb = "put_byte_jit"; - } else { - srcl = "get_long"; - dstl = "put_long"; - srcw = "get_word"; - dstw = "put_word"; - srcb = "get_byte"; - dstb = "put_byte"; - } - } - if (!dstld) - dstld = dstl; - if (!dstwd) - dstwd = dstw; - if (!srcld) - srcld = srcl; - if (!srcwd) - srcwd = srcw; - if (!srcblrmw) { - srcblrmw = srcb; - srcwlrmw = srcw; - srcllrmw = srcl; - dstblrmw = dstb; - dstwlrmw = dstw; - dstllrmw = dstl; - } - if (!prefetch_opcode) - prefetch_opcode = prefetch_word; -} - -static void gen_opcode (unsigned int opcode) -{ - struct instr *curi = table68k + opcode; - - resetvars (); - - if(curi->mnemo == i_DIVL) - printf ("\tuae_u32 cyc = 0;\n"); - - start_brace (); - - m68k_pc_offset = 2; - - // do not unnecessarily create useless mmuop030 - // functions when CPU is not 68030 - if (curi->mnemo == i_MMUOP030 && cpu_level != 3 && !cpu_generic) { - printf("\top_illg (opcode);\n"); - did_prefetch = -1; - goto end; - } - - switch (curi->plev) { - case 0: /* not privileged */ - break; - case 1: /* unprivileged only on 68000 */ - if (cpu_level == 0) - break; - if (next_cpu_level < 0) - next_cpu_level = 0; - - /* fall through */ - case 2: /* priviledged */ - printf ("if (!regs.s) { Exception (8); return 4 * CYCLE_UNIT / 2; }\n"); - start_brace (); - break; - case 3: /* privileged if size == word */ - if (curi->size == sz_byte) - break; - printf ("if (!regs.s) { Exception (8); return 4 * CYCLE_UNIT / 2; }\n"); - start_brace (); - break; - } - switch (curi->mnemo) { - case i_OR: - case i_AND: - case i_EOR: - { - // documentaion error: and.l #imm,dn = 2 idle, not 1 idle (same as OR and EOR) - int c = 0; - genamodedual (curi, - curi->smode, "srcreg", curi->size, "src", 1, 0, - curi->dmode, "dstreg", curi->size, "dst", 1, GF_RMW); -// genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, 0); -// genamode (curi, curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_RMW); - printf ("\tsrc %c= dst;\n", curi->mnemo == i_OR ? '|' : curi->mnemo == i_AND ? '&' : '^'); - genflags (flag_logical, curi->size, "src", "", ""); - if (curi->dmode == Dreg && curi->size == sz_long) { - c += 2; - if (curi->smode == imm || curi->smode == Dreg) - c += 2; - } - fill_prefetch_next (); - if (c > 0) - addcycles000 (c); - genastore_rev ("src", curi->dmode, "dstreg", curi->size, "dst"); - break; - } - // all SR/CCR modifications does full prefetch - case i_ORSR: - case i_EORSR: - printf ("\tMakeSR ();\n"); - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - if (curi->size == sz_byte) { - printf ("\tsrc &= 0xFF;\n"); - } - addcycles000 (8); - printf ("\tregs.sr %c= src;\n", curi->mnemo == i_EORSR ? '^' : '|'); - makefromsr_t0(); - sync_m68k_pc (); - fill_prefetch_full_ntx(); - break; - case i_ANDSR: - printf ("\tMakeSR ();\n"); - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - if (curi->size == sz_byte) { - printf ("\tsrc |= 0xFF00;\n"); - } - addcycles000 (8); - printf ("\tregs.sr &= src;\n"); - makefromsr_t0(); - sync_m68k_pc (); - fill_prefetch_full_ntx(); - break; - case i_SUB: - { - int c = 0; - genamodedual (curi, - curi->smode, "srcreg", curi->size, "src", 1, 0, - curi->dmode, "dstreg", curi->size, "dst", 1, GF_RMW); - //genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - //genamode (curi, curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_RMW); - if (curi->dmode == Dreg) { - if (curi->size == sz_long) { - c += 2; - if (curi->smode == imm || curi->smode == immi || curi->smode == Dreg || curi->smode == Areg) - c += 2; - } - } - fill_prefetch_next (); - if (c > 0) - addcycles000 (c); - start_brace (); - genflags (flag_sub, curi->size, "newv", "src", "dst"); - genastore_rev ("newv", curi->dmode, "dstreg", curi->size, "dst"); - break; - } - case i_SUBA: - { - int c = 0; - genamodedual (curi, - curi->smode, "srcreg", curi->size, "src", 1, 0, - curi->dmode, "dstreg", sz_long, "dst", 1, GF_RMW); - //genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - //genamode (curi, curi->dmode, "dstreg", sz_long, "dst", 1, 0, GF_RMW); - if (curi->smode == immi) { - // SUBAQ.x is always 8 cycles - c += 4; - } else { - c = curi->size == sz_long ? 2 : 4; - if (islongimm (curi)) - c += 2; - } - fill_prefetch_next (); - if (c > 0) - addcycles000 (c); - start_brace (); - printf ("\tuae_u32 newv = dst - src;\n"); - genastore ("newv", curi->dmode, "dstreg", sz_long, "dst"); - break; - } - case i_SUBX: - if (!isreg (curi->smode)) - addcycles000 (2); - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA); - genamode (curi, curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_AA | GF_RMW); - fill_prefetch_next (); - if (curi->size == sz_long && isreg (curi->smode)) - addcycles000 (4); - start_brace (); - printf ("\tuae_u32 newv = dst - src - (GET_XFLG () ? 1 : 0);\n"); - genflags (flag_subx, curi->size, "newv", "src", "dst"); - genflags (flag_zn, curi->size, "newv", "", ""); - genastore ("newv", curi->dmode, "dstreg", curi->size, "dst"); - break; - case i_SBCD: - if (!isreg (curi->smode)) - addcycles000 (2); - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA); - genamode (curi, curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_AA | GF_RMW); - fill_prefetch_next (); - start_brace (); - printf ("\tuae_u16 newv_lo = (dst & 0xF) - (src & 0xF) - (GET_XFLG () ? 1 : 0);\n"); - printf ("\tuae_u16 newv_hi = (dst & 0xF0) - (src & 0xF0);\n"); - printf ("\tuae_u16 newv, tmp_newv;\n"); - printf ("\tint bcd = 0;\n"); - printf ("\tnewv = tmp_newv = newv_hi + newv_lo;\n"); - printf ("\tif (newv_lo & 0xF0) { newv -= 6; bcd = 6; };\n"); - printf ("\tif ((((dst & 0xFF) - (src & 0xFF) - (GET_XFLG () ? 1 : 0)) & 0x100) > 0xFF) { newv -= 0x60; }\n"); - printf ("\tSET_CFLG ((((dst & 0xFF) - (src & 0xFF) - bcd - (GET_XFLG () ? 1 : 0)) & 0x300) > 0xFF);\n"); - duplicate_carry (0); - /* Manual says bits NV are undefined though a real 68030 doesn't change V and 68040/060 don't change both */ - if (cpu_level >= xBCD_KEEPS_N_FLAG) { - if (next_cpu_level < xBCD_KEEPS_N_FLAG) - next_cpu_level = xBCD_KEEPS_N_FLAG - 1; - genflags (flag_z, curi->size, "newv", "", ""); - } else { - genflags (flag_zn, curi->size, "newv", "", ""); - } - if (cpu_level >= xBCD_KEEPS_V_FLAG) { - if (next_cpu_level < xBCD_KEEPS_V_FLAG) - next_cpu_level = xBCD_KEEPS_V_FLAG - 1; - } else { - printf ("\tSET_VFLG ((tmp_newv & 0x80) != 0 && (newv & 0x80) == 0);\n"); - } - if (isreg (curi->smode)) { - addcycles000 (2); - } - genastore ("newv", curi->dmode, "dstreg", curi->size, "dst"); - break; - case i_ADD: - { - int c = 0; - genamodedual (curi, - curi->smode, "srcreg", curi->size, "src", 1, 0, - curi->dmode, "dstreg", curi->size, "dst", 1, GF_RMW); - //genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - //genamode (curi, curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_RMW); - if (curi->dmode == Dreg) { - if (curi->size == sz_long) { - c += 2; - if (curi->smode == imm || curi->smode == immi || curi->smode == Dreg || curi->smode == Areg) - c += 2; - } - } - fill_prefetch_next (); - if (c > 0) - addcycles000 (c); - start_brace (); - genflags (flag_add, curi->size, "newv", "src", "dst"); - genastore_rev ("newv", curi->dmode, "dstreg", curi->size, "dst"); - break; - } - case i_ADDA: - { - int c = 0; - genamodedual (curi, - curi->smode, "srcreg", curi->size, "src", 1, 0, - curi->dmode, "dstreg", sz_long, "dst", 1, GF_RMW); - //genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - //genamode (curi, curi->dmode, "dstreg", sz_long, "dst", 1, 0, GF_RMW); - if (curi->smode == immi) { - // ADDAQ.x is always 8 cycles - c += 4; - } else { - c = curi->size == sz_long ? 2 : 4; - if (islongimm (curi)) - c += 2; - } - fill_prefetch_next (); - if (c > 0) - addcycles000 (c); - start_brace (); - printf ("\tuae_u32 newv = dst + src;\n"); - genastore ("newv", curi->dmode, "dstreg", sz_long, "dst"); - break; - } - case i_ADDX: - if (!isreg (curi->smode)) - addcycles000 (2); - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA); - genamode (curi, curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_AA | GF_RMW); - fill_prefetch_next (); - if (curi->size == sz_long && isreg (curi->smode)) - addcycles000 (4); - start_brace (); - printf ("\tuae_u32 newv = dst + src + (GET_XFLG () ? 1 : 0);\n"); - genflags (flag_addx, curi->size, "newv", "src", "dst"); - genflags (flag_zn, curi->size, "newv", "", ""); - genastore ("newv", curi->dmode, "dstreg", curi->size, "dst"); - break; - case i_ABCD: - if (!isreg (curi->smode)) - addcycles000 (2); - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA); - genamode (curi, curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_AA | GF_RMW); - fill_prefetch_next (); - start_brace (); - printf ("\tuae_u16 newv_lo = (src & 0xF) + (dst & 0xF) + (GET_XFLG () ? 1 : 0);\n"); - printf ("\tuae_u16 newv_hi = (src & 0xF0) + (dst & 0xF0);\n"); - printf ("\tuae_u16 newv, tmp_newv;\n"); - printf ("\tint cflg;\n"); - printf ("\tnewv = tmp_newv = newv_hi + newv_lo;\n"); - printf ("\tif (newv_lo > 9) { newv += 6; }\n"); - printf ("\tcflg = (newv & 0x3F0) > 0x90;\n"); - printf ("\tif (cflg) newv += 0x60;\n"); - printf ("\tSET_CFLG (cflg);\n"); - duplicate_carry (0); - /* Manual says bits NV are undefined though a real 68030 doesn't change V and 68040/060 don't change both */ - if (cpu_level >= xBCD_KEEPS_N_FLAG) { - if (next_cpu_level < xBCD_KEEPS_N_FLAG) - next_cpu_level = xBCD_KEEPS_N_FLAG - 1; - genflags (flag_z, curi->size, "newv", "", ""); - } else { - genflags (flag_zn, curi->size, "newv", "", ""); - } - if (cpu_level >= xBCD_KEEPS_V_FLAG) { - if (next_cpu_level < xBCD_KEEPS_V_FLAG) - next_cpu_level = xBCD_KEEPS_V_FLAG - 1; - } else { - printf ("\tSET_VFLG ((tmp_newv & 0x80) == 0 && (newv & 0x80) != 0);\n"); - } - if (isreg (curi->smode)) { - addcycles000 (2); - } - genastore ("newv", curi->dmode, "dstreg", curi->size, "dst"); - break; - case i_NEG: - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, GF_RMW); - fill_prefetch_next (); - if (isreg (curi->smode) && curi->size == sz_long) - addcycles000 (2); - start_brace (); - genflags (flag_sub, curi->size, "dst", "src", "0"); - genastore_rev ("dst", curi->smode, "srcreg", curi->size, "src"); - break; - case i_NEGX: - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, GF_RMW); - fill_prefetch_next (); - if (isreg (curi->smode) && curi->size == sz_long) - addcycles000 (2); - start_brace (); - printf ("\tuae_u32 newv = 0 - src - (GET_XFLG () ? 1 : 0);\n"); - genflags (flag_subx, curi->size, "newv", "src", "0"); - genflags (flag_zn, curi->size, "newv", "", ""); - genastore_rev ("newv", curi->smode, "srcreg", curi->size, "src"); - break; - case i_NBCD: - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, GF_RMW); - if (isreg (curi->smode)) - addcycles000 (2); - fill_prefetch_next (); - start_brace (); - printf ("\tuae_u16 newv_lo = - (src & 0xF) - (GET_XFLG () ? 1 : 0);\n"); - printf ("\tuae_u16 newv_hi = - (src & 0xF0);\n"); - printf ("\tuae_u16 newv;\n"); - printf ("\tint cflg, tmp_newv;\n"); - printf ("\ttmp_newv = newv_hi + newv_lo;\n"); - printf ("\tif (newv_lo > 9) { newv_lo -= 6; }\n"); - printf ("\tnewv = newv_hi + newv_lo;\n"); - printf ("\tcflg = (newv & 0x1F0) > 0x90;\n"); - printf ("\tif (cflg) newv -= 0x60;\n"); - printf ("\tSET_CFLG (cflg);\n"); - duplicate_carry(0); - /* Manual says bits NV are undefined though a real 68030 doesn't change V and 68040/060 don't change both */ - if (cpu_level >= xBCD_KEEPS_N_FLAG) { - if (next_cpu_level < xBCD_KEEPS_N_FLAG) - next_cpu_level = xBCD_KEEPS_N_FLAG - 1; - genflags (flag_z, curi->size, "newv", "", ""); - } else { - genflags (flag_zn, curi->size, "newv", "", ""); - } - if (cpu_level >= xBCD_KEEPS_V_FLAG) { - if (next_cpu_level < xBCD_KEEPS_V_FLAG) - next_cpu_level = xBCD_KEEPS_V_FLAG - 1; - } else { - printf ("\tSET_VFLG ((tmp_newv & 0x80) != 0 && (newv & 0x80) == 0);\n"); - } - genastore ("newv", curi->smode, "srcreg", curi->size, "src"); - break; - case i_CLR: - next_level_000 (); - genamode (curi, curi->smode, "srcreg", curi->size, "src", cpu_level == 0 ? 1 : 2, 0, 0); - fill_prefetch_next (); - if(!using_prefetch && curi->smode != Dreg) { - if(curi->size != sz_long) - addcycles000(4); - else - addcycles000(8); - } - if (isreg (curi->smode) && curi->size == sz_long) - addcycles000 (2); - genflags (flag_logical, curi->size, "0", "", ""); - genastore_rev ("0", curi->smode, "srcreg", curi->size, "src"); - break; - case i_NOT: - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, GF_RMW); - fill_prefetch_next (); - if (isreg (curi->smode) && curi->size == sz_long) - addcycles000 (2); - start_brace (); - printf ("\tuae_u32 dst = ~src;\n"); - genflags (flag_logical, curi->size, "dst", "", ""); - genastore_rev ("dst", curi->smode, "srcreg", curi->size, "src"); - break; - case i_TST: - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - fill_prefetch_next (); - genflags (flag_logical, curi->size, "src", "", ""); - break; - case i_BTST: - genamodedual (curi, - curi->smode, "srcreg", curi->size, "src", 1, 0, - curi->dmode, "dstreg", curi->size, "dst", 1, 0); - //genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - //genamode (curi, curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_IR2IRC); - fill_prefetch_next (); - bsetcycles (curi); - printf ("\tSET_ZFLG (1 ^ ((dst >> src) & 1));\n"); - break; - case i_BCHG: - case i_BCLR: - case i_BSET: - // on 68000 these have weird side-effect, if EA points to write-only custom register - //during instruction's read access CPU data lines appear as zero to outside world, - // (normally previously fetched data appears in data lines if reading write-only register) - // this allows stupid things like bset #2,$dff096 to work "correctly" - // NOTE: above can't be right. - genamodedual (curi, - curi->smode, "srcreg", curi->size, "src", 1, 0, - curi->dmode, "dstreg", curi->size, "dst", 1, GF_RMW); - //genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - //genamode (curi, curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_IR2IRC | GF_RMW); - fill_prefetch_next (); - bsetcycles (curi); - // bclr needs 1 extra cycle - if (curi->mnemo == i_BCLR && curi->dmode == Dreg) - addcycles000 (2); - if (curi->mnemo == i_BCHG) { - printf ("\tdst ^= (1 << src);\n"); - printf ("\tSET_ZFLG (((uae_u32)dst & (1 << src)) >> src);\n"); - } else if (curi->mnemo == i_BCLR) { - printf ("\tSET_ZFLG (1 ^ ((dst >> src) & 1));\n"); - printf ("\tdst &= ~(1 << src);\n"); - } else if (curi->mnemo == i_BSET) { - printf ("\tSET_ZFLG (1 ^ ((dst >> src) & 1));\n"); - printf ("\tdst |= (1 << src);\n"); - } - genastore ("dst", curi->dmode, "dstreg", curi->size, "dst"); - break; - case i_CMPM: - // confirmed - genamodedual (curi, - curi->smode, "srcreg", curi->size, "src", 1, GF_AA, - curi->dmode, "dstreg", curi->size, "dst", 1, GF_AA); - //genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA); - //genamode (curi, curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_AA); - fill_prefetch_next (); - start_brace (); - genflags (flag_cmp, curi->size, "newv", "src", "dst"); - break; - case i_CMP: - genamodedual (curi, - curi->smode, "srcreg", curi->size, "src", 1, 0, - curi->dmode, "dstreg", curi->size, "dst", 1, 0); - //genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - //genamode (curi, curi->dmode, "dstreg", curi->size, "dst", 1, 0, 0); - fill_prefetch_next (); - if (curi->dmode == Dreg && curi->size == sz_long) - addcycles000 (2); - start_brace (); - genflags (flag_cmp, curi->size, "newv", "src", "dst"); - break; - case i_CMPA: - genamodedual (curi, - curi->smode, "srcreg", curi->size, "src", 1, 0, - curi->dmode, "dstreg", sz_long, "dst", 1, 0); - //genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - //genamode (curi, curi->dmode, "dstreg", sz_long, "dst", 1, 0, 0); - fill_prefetch_next (); - addcycles000 (2); - start_brace (); - genflags (flag_cmp, sz_long, "newv", "src", "dst"); - break; - /* The next two are coded a little unconventional, but they are doing - * weird things... */ - case i_MVPRM: // MOVEP R->M - genamode (curi, 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);\n\t%s (memp + 2, src);\n", dstb, dstb); - count_write += 2; - } else { - 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 (); - break; - case i_MVPMR: // MOVEP M->R - printf ("\tuaecptr memp = m68k_areg (regs, srcreg) + (uae_s32)(uae_s16)%s;\n", gen_nextiword (0)); - genamode (curi, curi->dmode, "dstreg", curi->size, "dst", 2, 0, 0); - if (curi->size == sz_word) { - printf ("\tuae_u16 val = (%s (memp) & 0xff) << 8;\n", srcb); - printf ("\t val |= (%s (memp + 2) & 0xff);\n", srcb); - count_read += 2; - } else { - printf ("\tuae_u32 val = (%s (memp) & 0xff) << 24;\n", srcb); - printf ("\t val |= (%s (memp + 2) & 0xff) << 16;\n", srcb); - printf ("\t val |= (%s (memp + 4) & 0xff) << 8;\n", srcb); - printf ("\t val |= (%s (memp + 6) & 0xff);\n", srcb); - count_read += 4; - } - fill_prefetch_next (); - genastore ("val", curi->dmode, "dstreg", curi->size, "dst"); - break; - case i_MOVE: - case i_MOVEA: - { - /* 2 MOVE instruction variants have special prefetch sequence: - * - MOVE ,-(An) = prefetch is before writes (Apdi) - * - MOVE memory,(xxx).L = 2 prefetches after write - * - move.x #imm = prefetch is done before write - * - all others = prefetch is done after writes - * - * - move.x xxx,[at least 1 extension word here] = fetch 1 extension word before (xxx) - * - */ - int prefetch_done = 0, flags; - int dualprefetch = curi->dmode == absl && (curi->smode != Dreg && curi->smode != Areg && curi->smode != imm); - - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - flags = GF_MOVE | GF_APDI; - //if (curi->size == sz_long && (curi->smode == Dreg || curi->smode == Areg)) - // flags &= ~GF_APDI; - flags |= dualprefetch ? GF_NOREFILL : 0; - genamode (curi, curi->dmode, "dstreg", curi->size, "dst", 2, 0, flags); - if (curi->mnemo == i_MOVEA && curi->size == sz_word) - printf ("\tsrc = (uae_s32)(uae_s16)src;\n"); - if (curi->dmode == Apdi) { - fill_prefetch_next (); - prefetch_done = 1; - } - if (curi->mnemo == i_MOVE) - genflags (flag_logical, curi->size, "src", "", ""); - - genastore ("src", curi->dmode, "dstreg", curi->size, "dst"); - sync_m68k_pc (); - if (dualprefetch) { - fill_prefetch_full_000 (); - prefetch_done = 1; - } - if (!prefetch_done) - fill_prefetch_next (); - } - break; - case i_MVSR2: // MOVE FROM SR - genamode (curi, curi->smode, "srcreg", sz_word, "src", 2, 0, 0); - if (isreg (curi->smode)) { - fill_prefetch_next (); - addcycles000 (2); - } else { - // write to memory, dummy write to same address, X-flag seems to be always set - if (cpu_level <= 1 && curi->size == sz_word) { - printf ("\t%s (srca, regs.sr | 0x0010);\n", dstw); - count_write++; - } - fill_prefetch_next (); - } - printf ("\tMakeSR ();\n"); - // real write - if (curi->size == sz_byte) - genastore ("regs.sr & 0xff", curi->smode, "srcreg", sz_word, "src"); - else - genastore ("regs.sr", curi->smode, "srcreg", sz_word, "src"); - break; - case i_MV2SR: // MOVE TO SR - genamode (curi, curi->smode, "srcreg", sz_word, "src", 1, 0, 0); - if (curi->size == sz_byte) { - // MOVE TO CCR - addcycles000 (4); - printf ("\tMakeSR ();\n\tregs.sr &= 0xFF00;\n\tregs.sr |= src & 0xFF;\n"); - } else { - // MOVE TO SR - addcycles000 (4); - printf ("\tregs.sr = src;\n"); - } - makefromsr_t0(); - // does full prefetch because S-bit change may change memory mapping under the CPU - sync_m68k_pc (); - fill_prefetch_full_ntx(); - break; - case i_SWAP: - genamode (curi, curi->smode, "srcreg", sz_long, "src", 1, 0, 0); - fill_prefetch_next (); - start_brace (); - printf ("\tuae_u32 dst = ((src >> 16)&0xFFFF) | ((src&0xFFFF)<<16);\n"); - genflags (flag_logical, sz_long, "dst", "", ""); - genastore ("dst", curi->smode, "srcreg", sz_long, "src"); - break; - case i_EXG: - // confirmed - genamodedual (curi, - curi->smode, "srcreg", curi->size, "src", 1, 0, - curi->dmode, "dstreg", curi->size, "dst", 1, 0); - //genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - //genamode (curi, curi->dmode, "dstreg", curi->size, "dst", 1, 0, 0); - fill_prefetch_next (); - addcycles000 (2); - genastore ("dst", curi->smode, "srcreg", curi->size, "src"); - genastore ("src", curi->dmode, "dstreg", curi->size, "dst"); - break; - case i_EXT: - // confirmed - genamode (curi, curi->smode, "srcreg", sz_long, "src", 1, 0, 0); - fill_prefetch_next (); - start_brace (); - switch (curi->size) { - case sz_byte: printf ("\tuae_u32 dst = (uae_s32)(uae_s8)src;\n"); break; - case sz_word: printf ("\tuae_u16 dst = (uae_s16)(uae_s8)src;\n"); break; - case sz_long: printf ("\tuae_u32 dst = (uae_s32)(uae_s16)src;\n"); break; - default: term (); - } - genflags (flag_logical, - curi->size == sz_word ? sz_word : sz_long, "dst", "", ""); - genastore ("dst", curi->smode, "srcreg", - curi->size == sz_word ? sz_word : sz_long, "src"); - break; - case i_MVMEL: - // confirmed - //if (using_prefetch) - genmovemel_ce (opcode); - //else - // genmovemel (opcode); - break; - case i_MVMLE: - // confirmed - //if (using_prefetch) - genmovemle_ce (opcode); - //else - // genmovemle (opcode); - break; - case i_TRAP: - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - sync_m68k_pc (); - printf ("\tException_cpu(src + 32);\n"); - did_prefetch = 1; - clear_m68k_offset(); - break; - case i_MVR2USP: - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - fill_prefetch_next (); - printf ("\tregs.usp = src;\n"); - break; - case i_MVUSP2R: - genamode (curi, curi->smode, "srcreg", curi->size, "src", 2, 0, 0); - fill_prefetch_next (); - genastore ("regs.usp", curi->smode, "srcreg", curi->size, "src"); - break; - case i_RESET: - fill_prefetch_next (); - printf ("\tcpureset ();\n"); - sync_m68k_pc (); - addcycles000 (128); - if (using_prefetch) { - printf ("\t%s (2);\n", prefetch_word); - clear_m68k_offset(); - } - break; - case i_NOP: - fill_prefetch_next (); - break; - case i_STOP: - next_level_000(); - if (using_prefetch) { - printf("\tuae_u16 sr = regs.irc;\n"); - m68k_pc_offset += 2; - } else { - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - printf("\tuae_u16 sr = src;\n"); - } - // STOP undocumented features: - // if SR is not set: - // 68000 (68010?): Update SR, increase PC and then cause privilege violation exception (handled in newcpu) - // 68000 (68010?): Traced STOP also runs 4 cycles faster. - // 68020 68030: STOP works normally - // 68040 68060: Immediate privilege violation exception - if (cpu_level >= 4) { - printf("\tif (!(sr & 0x2000)) {\n"); - incpc("%d", m68k_pc_offset); - printf("\t\tException(8); return 4 * CYCLE_UNIT / 2;\n"); - printf("\t}\n"); - } - printf("\tregs.sr = sr;\n"); - makefromsr (); - printf ("\tm68k_setstopped ();\n"); - sync_m68k_pc (); - // STOP does not prefetch anything - did_prefetch = -1; - next_cpu_level = cpu_level - 1; - break; - case i_LPSTOP: /* 68060 */ - printf ("\tuae_u16 sw = %s (2);\n", srcwi); - printf ("\tif (sw != (0x100|0x80|0x40)) { Exception (4); return 4 * CYCLE_UNIT / 2; }\n"); - printf("\tif (!(regs.sr & 0x2000)) {\n"); - printf("\t\tException(8); return 4 * CYCLE_UNIT / 2;\n"); - printf("\t}\n"); - printf("\tregs.sr = %s (4);\n", srcwi); - makefromsr (); - printf ("\tm68k_setstopped();\n"); - m68k_pc_offset += 4; - sync_m68k_pc (); - fill_prefetch_full_ntx(); - break; - case i_RTE: - next_level_000 (); - if (cpu_level == 0) { - genamode (NULL, Aipi, "7", sz_word, "sr", 1, 0, GF_NOREFILL); - genamode (NULL, Aipi, "7", sz_long, "pc", 1, 0, GF_NOREFILL); - printf ("\tregs.sr = sr;\n"); - printf ("\tif (pc & 1) {\n"); - printf ("\t\texception3i (0x%04X, pc);\n", opcode); - returncycles_exception ("", (count_read + 1 + count_write) * 4 + count_cycles); - printf ("\t}\n"); - setpc ("pc"); - makefromsr (); - } else if (cpu_level == 1 && using_prefetch) { - int old_brace_level = n_braces; - printf ("\tuae_u16 newsr; uae_u32 newpc;\n"); - printf ("\tfor (;;) {\n"); - printf ("\t\tuaecptr a = m68k_areg (regs, 7);\n"); - printf ("\t\tuae_u16 sr = %s (a);\n", srcw); - count_read++; - printf ("\t\tuae_u32 pc = %s (a + 2) << 16; pc |= %s (a + 4);\n", srcw, srcw); - count_read += 2; - printf ("\t\tuae_u16 format = %s (a + 2 + 4);\n", srcw); - count_read++; - 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 == 0x8) { m68k_areg (regs, 7) += offset + 50; break; }\n"); - printf ("\t\telse { m68k_areg (regs, 7) += offset; Exception_cpu(14); return 4 * CYCLE_UNIT / 2; }\n"); - printf ("\t\tregs.sr = newsr;\n"); - makefromsr (); - printf ("}\n"); - pop_braces (old_brace_level); - printf ("\tregs.sr = newsr;\n"); - makefromsr (); - printf ("\tif (newpc & 1) {\n"); - printf ("\t\texception3i (0x%04X, newpc);\n", opcode); - returncycles_exception ("", (count_read + 1 + count_write) * 4 + count_cycles); - printf ("\t}\n"); - setpc ("newpc"); - } else { - int old_brace_level = n_braces; - printf ("\tuae_u16 newsr; uae_u32 newpc;\n"); - printf ("\tfor (;;) {\n"); - printf ("\t\tuaecptr a = m68k_areg (regs, 7);\n"); - printf ("\t\tuae_u16 sr = %s (a);\n", srcw); - count_read++; - printf ("\t\tuae_u32 pc = %s (a + 2);\n", srcl); - count_read += 2; - printf ("\t\tuae_u16 format = %s (a + 2 + 4);\n", srcw); - count_read++; - 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"); - if (cpu_level >= 4) { - printf ("\t\telse if (frame == 0x3) { m68k_areg (regs, 7) += offset + 4; break; }\n"); - } - if (cpu_level >= 4) { - printf ("\t\telse if (frame == 0x4) { m68k_areg (regs, 7) += offset + 8; break; }\n"); - } - if (cpu_level == 1) // 68010 only - printf ("\t\telse if (frame == 0x8) { m68k_areg (regs, 7) += offset + 50; break; }\n"); - if (cpu_level >= 4) { - printf ("\t\telse if (frame == 0x7) { m68k_areg (regs, 7) += offset + 52; break; }\n"); - } - if (cpu_level == 2 || cpu_level == 3) { // 68020/68030 only - 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_cpu(14); return 4 * CYCLE_UNIT / 2; }\n"); - printf ("\t\tregs.sr = newsr;\n"); - makefromsr_t0(); - printf ("}\n"); - pop_braces (old_brace_level); - printf ("\tregs.sr = newsr;\n"); - makefromsr_t0(); - printf ("\tif (newpc & 1) {\n"); - printf ("\t\texception3i (0x%04X, newpc);\n", opcode); - printf ("\t\treturn 4 * CYCLE_UNIT / 2;\n"); - printf ("\t}\n"); - setpc ("newpc"); - } - /* PC is set and prefetch filled. */ - clear_m68k_offset(); - fill_prefetch_full_ntx(); - branch_inst = 1; - next_cpu_level = cpu_level - 1; - break; - case i_RTD: - genamode (NULL, Aipi, "7", sz_long, "pc", 1, 0, 0); - genamode (curi, curi->smode, "srcreg", curi->size, "offs", 1, 0, 0); - printf ("\tm68k_areg (regs, 7) += offs;\n"); - printf ("\tif (pc & 1) {\n"); - printf ("\t\texception3i (0x%04X, pc);\n", opcode); - returncycles_exception ("", (count_read + 1 + count_write) * 4 + count_cycles); - printf ("\t}\n"); - setpc ("pc"); - /* PC is set and prefetch filled. */ - clear_m68k_offset(); - fill_prefetch_full (); - branch_inst = 1; - break; - case i_LINK: - // ce confirmed - genamode (NULL, Apdi, "7", sz_long, "old", 2, 0, GF_AA); - genamode (NULL, curi->smode, "srcreg", sz_long, "src", 1, 0, GF_AA); - genamode (NULL, curi->dmode, "dstreg", curi->size, "offs", 1, 0, 0); - genastore ("src", Apdi, "7", sz_long, "old"); - genastore ("m68k_areg (regs, 7)", curi->smode, "srcreg", sz_long, "src"); - printf ("\tm68k_areg (regs, 7) += offs;\n"); - fill_prefetch_next (); - break; - case i_UNLK: - // ce confirmed - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - printf ("\tm68k_areg (regs, 7) = src;\n"); - genamode (NULL, Aipi, "7", sz_long, "old", 1, 0, 0); - fill_prefetch_next (); - genastore ("old", curi->smode, "srcreg", curi->size, "src"); - break; - case i_RTS: - printf ("\tuaecptr pc = %s;\n", getpc); - if (using_prefetch) { - printf ("\tm68k_do_rtsi ();\n"); - } else { - printf ("\tm68k_do_rts ();\n"); - } - printf ("\tif (%s & 1) {\n", getpc); - printf ("\t\tuaecptr faultpc = %s;\n", getpc); - setpc ("pc"); - printf ("\t\texception3i (0x%04X, faultpc);\n", opcode); - printf ("\t\treturn 8 * CYCLE_UNIT / 2;\n"); - printf ("\t}\n"); - count_read += 2; - clear_m68k_offset(); - fill_prefetch_full (); - branch_inst = 1; - break; - case i_TRAPV: - sync_m68k_pc (); - fill_prefetch_next (); - printf ("\tif (GET_VFLG ()) {\n"); - printf ("\t\tException_cpu(7);\n"); - printf ("\t\treturn 4 * CYCLE_UNIT / 2;\n"); - printf ("\t}\n"); - break; - case i_RTR: - printf ("\tuaecptr oldpc = %s;\n", getpc); - printf ("\tMakeSR ();\n"); - genamode (NULL, Aipi, "7", sz_word, "sr", 1, 0, 0); - genamode (NULL, Aipi, "7", sz_long, "pc", 1, 0, 0); - printf ("\tregs.sr &= 0xFF00; sr &= 0xFF;\n"); - printf ("\tregs.sr |= sr;\n"); - setpc ("pc"); - makefromsr (); - printf ("\tif (%s & 1) {\n", getpc); - printf ("\t\tuaecptr faultpc = %s;\n", getpc); - setpc ("oldpc"); - printf ("\t\texception3i (0x%04X, faultpc);\n", opcode); - printf ("\t\treturn 8 * CYCLE_UNIT / 2;\n"); - printf ("\t}\n"); - clear_m68k_offset(); - fill_prefetch_full (); - branch_inst = 1; - break; - case i_JSR: - // possible idle cycle, prefetch from new address, stack high return addr, stack low, prefetch - genamode (curi, curi->smode, "srcreg", curi->size, "src", 0, 0, GF_AA|GF_NOREFILL); - start_brace (); - printf ("\tuaecptr oldpc = %s + %d;\n", getpc, m68k_pc_offset); - if (using_exception_3) { - printf ("\tif (srca & 1) {\n"); - printf ("\t\texception3i (opcode, srca);\n"); - returncycles_exception ("", (count_read + 1 + count_write) * 4 + count_cycles); - printf ("\t}\n"); - } - if (curi->smode == Ad16 || curi->smode == absw || curi->smode == PC16) - addcycles000 (2); - if (curi->smode == Ad8r || curi->smode == PC8r) { - addcycles000 (6); - if (cpu_level <= 1 && using_prefetch) - printf ("\toldpc += 2;\n"); - } - setpc ("srca"); - clear_m68k_offset(); - fill_prefetch_1 (0); - printf ("\tm68k_areg (regs, 7) -= 4;\n"); - if (using_prefetch) { - printf ("\t%s (m68k_areg (regs, 7), oldpc >> 16);\n", dstw); - printf ("\t%s (m68k_areg (regs, 7) + 2, oldpc);\n", dstw); - } else { - printf ("\t%s (m68k_areg (regs, 7), oldpc);\n", dstl); - } - count_write += 2; - if(!using_prefetch && curi->smode == Aind) - addcycles000 (4); - fill_prefetch_next (); - branch_inst = 1; - break; - case i_JMP: - genamode (curi, curi->smode, "srcreg", curi->size, "src", 0, 0, GF_AA|GF_NOREFILL); - if (using_prefetch && (curi->smode == Ad8r || curi->smode == PC8r)) - addcycles000 (4); - if (using_exception_3) { - printf ("\tif (srca & 1) {\n"); - printf ("\t\texception3i (opcode, srca);\n"); - returncycles_exception ("", (count_read + 1 + count_write) * 4 + count_cycles); - printf ("\t}\n"); - } - if(!(using_prefetch)) { - if (curi->smode != Aind && curi->smode != Ad8r && curi->smode != PC8r) - count_read--; - } - if (curi->smode == Ad16 || curi->smode == Ad8r || curi->smode == absw || curi->smode == PC16 || curi->smode == PC8r) - addcycles000 (2); - setpc ("srca"); - clear_m68k_offset(); - fill_prefetch_full (); - branch_inst = 1; - break; - case i_BSR: - // .b/.w = idle cycle, store high, store low, 2xprefetch - printf ("\tuae_s32 s;\n"); - if (curi->size == sz_long) { - if (next_cpu_level < 1) - next_cpu_level = 1; - } - if (curi->size == sz_long && cpu_level < 2) { - printf ("\tuae_u32 src = 0xffffffff;\n"); - } else { - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA|GF_NOREFILL); - } - printf ("\ts = (uae_s32)src + 2;\n"); - if (using_exception_3) { - printf ("\tif (src & 1) {\n"); - printf ("\t\texception3b (opcode, %s + s, 0, 1, %s + s);\n", getpc, getpc); - returncycles_exception ("", (count_read + 1 + count_write) * 4 + count_cycles); - printf ("\t}\n"); - } - addcycles000 (2); - if (using_prefetch) { - printf ("\tm68k_do_bsri (%s + %d, s);\n", getpc, m68k_pc_offset); - } else { - printf ("\tm68k_do_bsr (%s + %d, s);\n", getpc, m68k_pc_offset); - } - count_write += 2; - if(!using_prefetch && curi->smode == imm1) - count_write--; - clear_m68k_offset(); - fill_prefetch_full (); - branch_inst = 1; - break; - case i_Bcc: - // bcc.b branch: idle cycle, prefetch, prefetch - // bcc.b not branch: 2 idle cycles, prefetch - if (curi->size == sz_long) { - if (cpu_level < 2) { - addcycles000 (2); - printf ("\tif (cctrue (%d)) {\n", curi->cc); - printf ("\t\texception3i (opcode, %s + 1);\n", getpc); - returncycles_exception ("", (count_read + 1 + count_write) * 4 + count_cycles); - printf ("\t}\n"); - sync_m68k_pc (); - addcycles000 (2); - irc2ir (); - fill_prefetch_2 (); - goto bccl_not68020; - } else { - if (next_cpu_level < 1) - next_cpu_level = 1; - } - } - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA | (cpu_level < 2 ? GF_NOREFILL : 0)); - addcycles000 (2); - printf ("\tif (!cctrue (%d)) goto didnt_jump;\n", curi->cc); - if (using_exception_3) { - printf ("\tif (src & 1) {\n"); - printf ("\t\texception3i (opcode, %s + 2 + (uae_s32)src);\n", getpc); - returncycles_exception ("", (count_read + 1 + count_write) * 4 + count_cycles); - printf ("\t}\n"); - } - push_ins_cnt(); - if (using_prefetch) { - incpc ("(uae_s32)src + 2"); - fill_prefetch_full_000 (); - printf ("\treturn 10 * CYCLE_UNIT / 2;\n"); - } else { - incpc ("(uae_s32)src + 2"); - returncycles ("\t", 10); - } - pop_ins_cnt(); - printf ("didnt_jump:;\n"); - sync_m68k_pc (); - if (curi->size == sz_byte) { - addcycles000 (2); - irc2ir (); - fill_prefetch_2 (); - } else if (curi->size == sz_word) { - addcycles000 (2); - fill_prefetch_full_000 (); - } else { - fill_prefetch_full_000 (); - } - if (using_prefetch) { - count_read = curi->size == sz_byte ? 1 : 2; - } else { - count_read = 0; - count_cycles = 0; - } - insn_n_cycles = curi->size == sz_byte ? 8 : 12; - branch_inst = 1; -bccl_not68020: - break; - case i_LEA: - if (curi->smode == Ad8r || curi->smode == PC8r) - addcycles000 (2); - genamodedual (curi, - curi->smode, "srcreg", curi->size, "src", 0, GF_AA, - curi->dmode, "dstreg", curi->size, "dst", 2, GF_AA); - //genamode (curi, curi->smode, "srcreg", curi->size, "src", 0, 0, GF_AA); - //genamode (curi, curi->dmode, "dstreg", curi->size, "dst", 2, 0, GF_AA); - if (curi->smode == Ad8r || curi->smode == PC8r) - addcycles000 (2); - fill_prefetch_next (); - genastore ("srca", curi->dmode, "dstreg", curi->size, "dst"); - break; - case i_PEA: - if (curi->smode == Ad8r || curi->smode == PC8r) - addcycles000 (2); - genamode (curi, curi->smode, "srcreg", curi->size, "src", 0, 0, GF_AA); - genamode (NULL, Apdi, "7", sz_long, "dst", 2, 0, GF_AA); - if (!(curi->smode == absw || curi->smode == absl)) - fill_prefetch_next (); - if (curi->smode == Ad8r || curi->smode == PC8r) - addcycles000 (2); - genastore ("srca", Apdi, "7", sz_long, "dst"); - if ((curi->smode == absw || curi->smode == absl)) - fill_prefetch_next (); - break; - case i_DBcc: - // cc true: idle cycle, prefetch - // cc false, counter expired: idle cycle, prefetch (from branch address), 2xprefetch (from next address) - // cc false, counter not expired: idle cycle, prefetch - genamodedual (curi, - curi->smode, "srcreg", curi->size, "src", 1, GF_AA | (cpu_level < 2 ? GF_NOREFILL : 0), - curi->dmode, "dstreg", curi->size, "offs", 1, GF_AA | (cpu_level < 2 ? GF_NOREFILL : 0)); - //genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA | (cpu_level < 2 ? GF_NOREFILL : 0)); - //genamode (curi, curi->dmode, "dstreg", curi->size, "offs", 1, 0, GF_AA | (cpu_level < 2 ? GF_NOREFILL : 0)); - printf ("\tuaecptr oldpc = %s;\n", getpc); - addcycles000 (2); - push_ins_cnt(); - printf ("\tif (!cctrue (%d)) {\n", curi->cc); - incpc ("(uae_s32)offs + 2"); - printf ("\t"); - fill_prefetch_1 (0); - printf ("\t"); - genastore ("(src - 1)", curi->smode, "srcreg", curi->size, "src"); - - printf ("\t\tif (src) {\n"); - if (using_exception_3) { - printf ("\t\t\tif (offs & 1) {\n"); - printf ("\t\t\t\texception3i (opcode, %s + 2 + (uae_s32)offs + 2);\n", getpc); - returncycles_exception ("", (count_read + 1 + count_write) * 4 + count_cycles); - printf ("\t\t\t}\n"); - } - irc2ir (); - fill_prefetch_1 (2); - returncycles ("\t\t\t", 10); - printf ("\t\t}\n"); - addcycles000_nonce("\t\t", 2 + 2); - printf ("\t} else {\n"); - // cc == true - addcycles000_nonce("\t\t", 2); - printf ("\t}\n"); - pop_ins_cnt(); - setpc ("oldpc + %d", m68k_pc_offset); - clear_m68k_offset(); - fill_prefetch_full_000 (); - insn_n_cycles = 12; - if (using_prefetch) - count_read = 2; - else - count_read = 1; - count_write = 0; - branch_inst = 1; - break; - case i_Scc: - // confirmed - next_level_000 (); - genamode (curi, curi->smode, "srcreg", curi->size, "src", cpu_level == 0 ? 1 : 2, 0, 0); - start_brace (); - fill_prefetch_next(); - start_brace (); - printf ("\tint val = cctrue (%d) ? 0xff : 0;\n", curi->cc); - if (isreg (curi->smode)) { - addcycles000_3 ("\t"); - addcycles000_nonces("\t", "(val ? 2 : 0)"); - } - genastore ("val", curi->smode, "srcreg", curi->size, "src"); - if(!using_prefetch && curi->smode != Dreg && cpu_level == 1) - addcycles000 (2); - break; - case i_DIVU: - genamodedual (curi, - curi->smode, "srcreg", sz_word, "src", 1, 0, - curi->dmode, "dstreg", sz_long, "dst", 1, 0); - printf ("\tCLEAR_CZNV ();\n"); - printf ("\tif (src == 0) {\n"); - if (cpu_level > 1) - printf ("\t\tdivbyzero_special (0, dst);\n"); - incpc ("%d", m68k_pc_offset); - printf ("\t\tException_cpu(5);\n"); - returncycles_exception ("", (count_read + 1 + count_write) * 4 + count_cycles); - printf ("\t} else {\n"); - printf ("\t\tuae_u32 newv = (uae_u32)dst / (uae_u32)(uae_u16)src;\n"); - printf ("\t\tuae_u32 rem = (uae_u32)dst %% (uae_u32)(uae_u16)src;\n"); - addcycles000_nonces("\t\t", "(getDivu68kCycles((uae_u32)dst, (uae_u16)src)) - 4"); - fill_prefetch_next (); - /* The N flag appears to be set each time there is an overflow. - * Weird. but 68020 only sets N when dst is negative.. */ - printf ("\t\tif (newv > 0xffff) {\n"); - printf ("\t\t\tsetdivuoverflowflags((uae_u32)dst, (uae_u16)src);\n"); - printf ("\t\t} else {\n"); - printf ("\t\t"); genflags (flag_logical, sz_word, "newv", "", ""); - printf ("\t\t\tnewv = (newv & 0xffff) | ((uae_u32)rem << 16);\n"); - printf ("\t\t"); genastore ("newv", curi->dmode, "dstreg", sz_long, "dst"); - printf ("\t\t}\n"); - sync_m68k_pc (); - printf ("\t}\n"); - count_ncycles++; - //insn_n_cycles += 136 - (136 - 76) / 2; /* average */ - break; - case i_DIVS: - genamodedual (curi, - curi->smode, "srcreg", sz_word, "src", 1, 0, - curi->dmode, "dstreg", sz_long, "dst", 1, 0); - printf ("\tif (src == 0) {\n"); - if (cpu_level > 1) - printf ("\t\tdivbyzero_special (1, dst);\n"); - incpc ("%d", m68k_pc_offset); - printf ("\t\tException_cpu(5);\n"); - returncycles_exception ("", (count_read + 1 + count_write) * 4 + count_cycles); - printf ("\t}\n"); - printf ("\tCLEAR_CZNV ();\n"); - addcycles000_nonces("\t\t", "(getDivs68kCycles((uae_s32)dst, (uae_s16)src)) - 4"); - fill_prefetch_next (); - printf ("\tif (dst == 0x80000000 && src == -1) {\n"); - printf ("\t\tsetdivsoverflowflags((uae_s32)dst, (uae_s16)src);\n"); - printf ("\t} else {\n"); - printf ("\t\tuae_s32 newv = (uae_s32)dst / (uae_s32)(uae_s16)src;\n"); - printf ("\t\tuae_u16 rem = (uae_s32)dst %% (uae_s32)(uae_s16)src;\n"); - printf ("\t\tif ((newv & 0xffff8000) != 0 && (newv & 0xffff8000) != 0xffff8000) {\n"); - printf ("\t\t\tsetdivsoverflowflags((uae_s32)dst, (uae_s16)src);\n"); - printf ("\t\t} else {\n"); - printf ("\t\t\tif (((uae_s16)rem < 0) != ((uae_s32)dst < 0)) rem = -rem;\n"); - genflags (flag_logical, sz_word, "newv", "", ""); - printf ("\t\t\tnewv = (newv & 0xffff) | ((uae_u32)rem << 16);\n"); - printf ("\t\t"); genastore ("newv", curi->dmode, "dstreg", sz_long, "dst"); - printf ("\t\t}\n"); - printf ("\t}\n"); - sync_m68k_pc (); - count_ncycles++; - //insn_n_cycles += 156 - (156 - 120) / 2; /* average */ - break; - case i_MULU: - genamodedual (curi, - curi->smode, "srcreg", sz_word, "src", 1, 0, - curi->dmode, "dstreg", sz_word, "dst", 1, 0); - fill_prefetch_next(); - start_brace (); - printf ("\tuae_u32 newv = (uae_u32)(uae_u16)dst * (uae_u32)(uae_u16)src;\n"); - genflags (flag_logical, sz_long, "newv", "", ""); - addcycles000_nonces("\t", "bitset_count16(src) * 2"); - genastore ("newv", curi->dmode, "dstreg", sz_long, "dst"); - sync_m68k_pc (); - count_cycles += 38 - 4; - count_ncycles++; - insn_n_cycles += (70 - 38) / 2 + 38; /* average */ - break; - case i_MULS: - genamodedual (curi, - curi->smode, "srcreg", sz_word, "src", 1, 0, - curi->dmode, "dstreg", sz_word, "dst", 1, 0); - fill_prefetch_next(); - start_brace (); - printf ("\tuae_u32 newv = (uae_s32)(uae_s16)dst * (uae_s32)(uae_s16)src;\n"); - genflags (flag_logical, sz_long, "newv", "", ""); - addcycles000_nonces("\t", "bitset_count16(src ^ (src << 1)) * 2"); - genastore ("newv", curi->dmode, "dstreg", sz_long, "dst"); - count_cycles += 38 - 4; - count_ncycles++; - insn_n_cycles += (70 - 38) / 2 + 38; /* average */ - break; - case i_CHK: - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - genamode (curi, curi->dmode, "dstreg", curi->size, "dst", 1, 0, 0); - sync_m68k_pc (); - addcycles000 (4); - printf ("\tif (dst > src) {\n"); - printf ("\t\tSET_NFLG (0);\n"); - printf ("\t\tException_cpu(6);\n"); - returncycles_exception ("", (count_read + 1 + count_write) * 4 + count_cycles); - printf ("\t}\n"); - addcycles000 (2); - printf ("\tif ((uae_s32)dst < 0) {\n"); - printf ("\t\tSET_NFLG (1);\n"); - printf ("\t\tException_cpu(6);\n"); - returncycles_exception ("", (count_read + 1 + count_write) * 4 + count_cycles); - printf ("\t}\n"); - fill_prefetch_next (); - break; - case i_CHK2: - genamode (curi, curi->smode, "srcreg", curi->size, "extra", 1, 0, 0); - genamode (curi, curi->dmode, "dstreg", curi->size, "dst", 2, 0, 0); - fill_prefetch_0 (); - printf ("\t{uae_s32 upper,lower,reg = regs.regs[(extra >> 12) & 15];\n"); - switch (curi->size) { - case sz_byte: - printf ("\tlower = (uae_s32)(uae_s8)%s (dsta); upper = (uae_s32)(uae_s8)%s (dsta + 1);\n", srcb, srcb); - printf ("\tif ((extra & 0x8000) == 0) reg = (uae_s32)(uae_s8)reg;\n"); - break; - case sz_word: - printf ("\tlower = (uae_s32)(uae_s16)%s (dsta); upper = (uae_s32)(uae_s16)%s (dsta + 2);\n", srcw, srcw); - printf ("\tif ((extra & 0x8000) == 0) reg = (uae_s32)(uae_s16)reg;\n"); - break; - case sz_long: - printf ("\tlower = %s (dsta); upper = %s (dsta + 4);\n", srcl, srcl); - break; - default: - term (); - } - printf ("\tSET_ZFLG (upper == reg || lower == reg);\n"); - printf ("\tSET_CFLG_ALWAYS (lower <= upper ? reg < lower || reg > upper : reg > upper || reg < lower);\n"); - printf ("\tif ((extra & 0x800) && GET_CFLG ()) { Exception_cpu(6); \n"); - returncycles_exception ("", (count_read + 1 + count_write) * 4 + count_cycles); - printf("\t}\n}\n"); - break; - - case i_ASR: - genamodedual (curi, - curi->smode, "srcreg", curi->size, "cnt", 1, 0, - curi->dmode, "dstreg", curi->size, "data", 1, GF_RMW); - //genamode (curi, curi->smode, "srcreg", curi->size, "cnt", 1, 0, 0); - //genamode (curi, curi->dmode, "dstreg", curi->size, "data", 1, 0, GF_RMW); - fill_prefetch_next(); - start_brace (); - switch (curi->size) { - case sz_byte: printf ("\tuae_u32 val = (uae_u8)data;\n"); break; - case sz_word: printf ("\tuae_u32 val = (uae_u16)data;\n"); break; - case sz_long: printf ("\tuae_u32 val = data;\n"); break; - default: term (); - } - printf ("\tuae_u32 sign = (%s & val) >> %d;\n", cmask (curi->size), bit_size (curi->size) - 1); - printf ("\tint ccnt = cnt & 63;\n"); - printf ("\tcnt &= 63;\n"); - printf ("\tCLEAR_CZNV ();\n"); - printf ("\tif (cnt >= %d) {\n", bit_size (curi->size)); - printf ("\t\tval = %s & (uae_u32)-sign;\n", bit_mask (curi->size)); - printf ("\t\tSET_CFLG (sign);\n"); - duplicate_carry (1); - if (source_is_imm1_8 (curi)) - printf ("\t} else {\n"); - else - printf ("\t} else if (cnt > 0) {\n"); - printf ("\t\tval >>= cnt - 1;\n"); - printf ("\t\tSET_CFLG (val & 1);\n"); - duplicate_carry (1); - printf ("\t\tval >>= 1;\n"); - printf ("\t\tval |= (%s << (%d - cnt)) & (uae_u32)-sign;\n", - bit_mask (curi->size), - bit_size (curi->size)); - printf ("\t\tval &= %s;\n", bit_mask (curi->size)); - printf ("\t}\n"); - genflags (flag_logical_noclobber, curi->size, "val", "", ""); - shift_ce (curi->dmode, curi->size); - genastore ("val", curi->dmode, "dstreg", curi->size, "data"); - break; - case i_ASL: - genamodedual (curi, - curi->smode, "srcreg", curi->size, "cnt", 1, 0, - curi->dmode, "dstreg", curi->size, "data", 1, GF_RMW); - //genamode (curi, curi->smode, "srcreg", curi->size, "cnt", 1, 0, 0); - //genamode (curi, curi->dmode, "dstreg", curi->size, "data", 1, 0, GF_RMW); - fill_prefetch_next(); - start_brace (); - switch (curi->size) { - case sz_byte: printf ("\tuae_u32 val = (uae_u8)data;\n"); break; - case sz_word: printf ("\tuae_u32 val = (uae_u16)data;\n"); break; - case sz_long: printf ("\tuae_u32 val = data;\n"); break; - default: term (); - } - printf ("\tint ccnt = cnt & 63;\n"); - printf ("\tcnt &= 63;\n"); - printf ("\tCLEAR_CZNV ();\n"); - printf ("\tif (cnt >= %d) {\n", bit_size (curi->size)); - printf ("\t\tSET_VFLG (val != 0);\n"); - printf ("\t\tSET_CFLG (cnt == %d ? val & 1 : 0);\n", - bit_size (curi->size)); - duplicate_carry (1); - printf ("\t\tval = 0;\n"); - if (source_is_imm1_8 (curi)) - printf ("\t} else {\n"); - else - printf ("\t} else if (cnt > 0) {\n"); - printf ("\t\tuae_u32 mask = (%s << (%d - cnt)) & %s;\n", - bit_mask (curi->size), - bit_size (curi->size) - 1, - bit_mask (curi->size)); - printf ("\t\tSET_VFLG ((val & mask) != mask && (val & mask) != 0);\n"); - printf ("\t\tval <<= cnt - 1;\n"); - printf ("\t\tSET_CFLG ((val & %s) >> %d);\n", cmask (curi->size), bit_size (curi->size) - 1); - duplicate_carry (1); - printf ("\t\tval <<= 1;\n"); - printf ("\t\tval &= %s;\n", bit_mask (curi->size)); - printf ("\t}\n"); - genflags (flag_logical_noclobber, curi->size, "val", "", ""); - shift_ce (curi->dmode, curi->size); - genastore ("val", curi->dmode, "dstreg", curi->size, "data"); - break; - case i_LSR: - genamodedual (curi, - curi->smode, "srcreg", curi->size, "cnt", 1, 0, - curi->dmode, "dstreg", curi->size, "data", 1, GF_RMW); - //genamode (curi, curi->smode, "srcreg", curi->size, "cnt", 1, 0, 0); - //genamode (curi, curi->dmode, "dstreg", curi->size, "data", 1, 0, GF_RMW); - fill_prefetch_next(); - start_brace (); - switch (curi->size) { - case sz_byte: printf ("\tuae_u32 val = (uae_u8)data;\n"); break; - case sz_word: printf ("\tuae_u32 val = (uae_u16)data;\n"); break; - case sz_long: printf ("\tuae_u32 val = data;\n"); break; - default: term (); - } - printf ("\tint ccnt = cnt & 63;\n"); - printf ("\tcnt &= 63;\n"); - printf ("\tCLEAR_CZNV ();\n"); - printf ("\tif (cnt >= %d) {\n", bit_size (curi->size)); - printf ("\t\tSET_CFLG ((cnt == %d) & (val >> %d));\n", - bit_size (curi->size), bit_size (curi->size) - 1); - duplicate_carry (1); - printf ("\t\tval = 0;\n"); - if (source_is_imm1_8 (curi)) - printf ("\t} else {\n"); - else - printf ("\t} else if (cnt > 0) {\n"); - printf ("\t\tval >>= cnt - 1;\n"); - printf ("\t\tSET_CFLG (val & 1);\n"); - duplicate_carry (1); - printf ("\t\tval >>= 1;\n"); - printf ("\t}\n"); - genflags (flag_logical_noclobber, curi->size, "val", "", ""); - shift_ce (curi->dmode, curi->size); - genastore ("val", curi->dmode, "dstreg", curi->size, "data"); - break; - case i_LSL: - genamodedual (curi, - curi->smode, "srcreg", curi->size, "cnt", 1, 0, - curi->dmode, "dstreg", curi->size, "data", 1, GF_RMW); - //genamode (curi, curi->smode, "srcreg", curi->size, "cnt", 1, 0, 0); - //genamode (curi, curi->dmode, "dstreg", curi->size, "data", 1, 0, GF_RMW); - fill_prefetch_next(); - start_brace (); - switch (curi->size) { - case sz_byte: printf ("\tuae_u32 val = (uae_u8)data;\n"); break; - case sz_word: printf ("\tuae_u32 val = (uae_u16)data;\n"); break; - case sz_long: printf ("\tuae_u32 val = data;\n"); break; - default: term (); - } - printf ("\tint ccnt = cnt & 63;\n"); - printf ("\tcnt &= 63;\n"); - printf ("\tCLEAR_CZNV ();\n"); - printf ("\tif (cnt >= %d) {\n", bit_size (curi->size)); - printf ("\t\tSET_CFLG (cnt == %d ? val & 1 : 0);\n", bit_size (curi->size)); - duplicate_carry (1); - printf ("\t\tval = 0;\n"); - if (source_is_imm1_8 (curi)) - printf ("\t} else {\n"); - else - printf ("\t} else if (cnt > 0) {\n"); - printf ("\t\tval <<= (cnt - 1);\n"); - printf ("\t\tSET_CFLG ((val & %s) >> %d);\n", cmask (curi->size), bit_size (curi->size) - 1); - duplicate_carry (1); - printf ("\t\tval <<= 1;\n"); - printf ("\tval &= %s;\n", bit_mask (curi->size)); - printf ("\t}\n"); - genflags (flag_logical_noclobber, curi->size, "val", "", ""); - shift_ce (curi->dmode, curi->size); - genastore ("val", curi->dmode, "dstreg", curi->size, "data"); - break; - case i_ROL: - genamodedual (curi, - curi->smode, "srcreg", curi->size, "cnt", 1, 0, - curi->dmode, "dstreg", curi->size, "data", 1, GF_RMW); - //genamode (curi, curi->smode, "srcreg", curi->size, "cnt", 1, 0, 0); - //genamode (curi, curi->dmode, "dstreg", curi->size, "data", 1, 0, GF_RMW); - fill_prefetch_next (); - start_brace (); - switch (curi->size) { - case sz_byte: printf ("\tuae_u32 val = (uae_u8)data;\n"); break; - case sz_word: printf ("\tuae_u32 val = (uae_u16)data;\n"); break; - case sz_long: printf ("\tuae_u32 val = data;\n"); break; - default: term (); - } - printf ("\tint ccnt = cnt & 63;\n"); - printf ("\tcnt &= 63;\n"); - printf ("\tCLEAR_CZNV ();\n"); - if (source_is_imm1_8 (curi)) - printf ("{"); - else - printf ("\tif (cnt > 0) {\n"); - printf ("\tuae_u32 loval;\n"); - printf ("\tcnt &= %d;\n", bit_size (curi->size) - 1); - printf ("\tloval = val >> (%d - cnt);\n", bit_size (curi->size)); - printf ("\tval <<= cnt;\n"); - printf ("\tval |= loval;\n"); - printf ("\tval &= %s;\n", bit_mask (curi->size)); - printf ("\tSET_CFLG (val & 1);\n"); - printf ("}\n"); - genflags (flag_logical_noclobber, curi->size, "val", "", ""); - shift_ce (curi->dmode, curi->size); - genastore ("val", curi->dmode, "dstreg", curi->size, "data"); - break; - case i_ROR: - genamodedual (curi, - curi->smode, "srcreg", curi->size, "cnt", 1, 0, - curi->dmode, "dstreg", curi->size, "data", 1, GF_RMW); - //genamode (curi, curi->smode, "srcreg", curi->size, "cnt", 1, 0, 0); - //genamode (curi, curi->dmode, "dstreg", curi->size, "data", 1, 0, GF_RMW); - fill_prefetch_next (); - start_brace (); - switch (curi->size) { - case sz_byte: printf ("\tuae_u32 val = (uae_u8)data;\n"); break; - case sz_word: printf ("\tuae_u32 val = (uae_u16)data;\n"); break; - case sz_long: printf ("\tuae_u32 val = data;\n"); break; - default: term (); - } - printf ("\tint ccnt = cnt & 63;\n"); - printf ("\tcnt &= 63;\n"); - printf ("\tCLEAR_CZNV ();\n"); - if (source_is_imm1_8 (curi)) - printf ("{"); - else - printf ("\tif (cnt > 0) {"); - printf ("\tuae_u32 hival;\n"); - printf ("\tcnt &= %d;\n", bit_size (curi->size) - 1); - printf ("\thival = val << (%d - cnt);\n", bit_size (curi->size)); - printf ("\tval >>= cnt;\n"); - printf ("\tval |= hival;\n"); - printf ("\tval &= %s;\n", bit_mask (curi->size)); - printf ("\tSET_CFLG ((val & %s) >> %d);\n", cmask (curi->size), bit_size (curi->size) - 1); - printf ("\t}\n"); - genflags (flag_logical_noclobber, curi->size, "val", "", ""); - shift_ce (curi->dmode, curi->size); - genastore ("val", curi->dmode, "dstreg", curi->size, "data"); - break; - case i_ROXL: - genamodedual (curi, - curi->smode, "srcreg", curi->size, "cnt", 1, 0, - curi->dmode, "dstreg", curi->size, "data", 1, GF_RMW); - //genamode (curi, curi->smode, "srcreg", curi->size, "cnt", 1, 0, 0); - //genamode (curi, curi->dmode, "dstreg", curi->size, "data", 1, 0, GF_RMW); - fill_prefetch_next (); - start_brace (); - switch (curi->size) { - case sz_byte: printf ("\tuae_u32 val = (uae_u8)data;\n"); break; - case sz_word: printf ("\tuae_u32 val = (uae_u16)data;\n"); break; - case sz_long: printf ("\tuae_u32 val = data;\n"); break; - default: term (); - } - printf ("\tint ccnt = cnt & 63;\n"); - printf ("\tcnt &= 63;\n"); - printf ("\tCLEAR_CZNV ();\n"); - if (source_is_imm1_8 (curi)) - printf ("{"); - else { - force_range_for_rox ("cnt", curi->size); - printf ("\tif (cnt > 0) {\n"); - } - printf ("\tcnt--;\n"); - printf ("\t{\n\tuae_u32 carry;\n"); - printf ("\tuae_u32 loval = val >> (%d - cnt);\n", bit_size (curi->size) - 1); - printf ("\tcarry = loval & 1;\n"); - printf ("\tval = (((val << 1) | GET_XFLG ()) << cnt) | (loval >> 1);\n"); - printf ("\tSET_XFLG (carry);\n"); - printf ("\tval &= %s;\n", bit_mask (curi->size)); - printf ("\t} }\n"); - printf ("\tSET_CFLG (GET_XFLG ());\n"); - genflags (flag_logical_noclobber, curi->size, "val", "", ""); - shift_ce (curi->dmode, curi->size); - genastore ("val", curi->dmode, "dstreg", curi->size, "data"); - break; - case i_ROXR: - genamodedual (curi, - curi->smode, "srcreg", curi->size, "cnt", 1, 0, - curi->dmode, "dstreg", curi->size, "data", 1, GF_RMW); - //genamode (curi, curi->smode, "srcreg", curi->size, "cnt", 1, 0, 0); - //genamode (curi, curi->dmode, "dstreg", curi->size, "data", 1, 0, GF_RMW); - fill_prefetch_next (); - start_brace (); - switch (curi->size) { - case sz_byte: printf ("\tuae_u32 val = (uae_u8)data;\n"); break; - case sz_word: printf ("\tuae_u32 val = (uae_u16)data;\n"); break; - case sz_long: printf ("\tuae_u32 val = data;\n"); break; - default: term (); - } - printf ("\tint ccnt = cnt & 63;\n"); - printf ("\tcnt &= 63;\n"); - printf ("\tCLEAR_CZNV ();\n"); - if (source_is_imm1_8 (curi)) - printf ("{"); - else { - force_range_for_rox ("cnt", curi->size); - printf ("\tif (cnt > 0) {\n"); - } - printf ("\tcnt--;\n"); - printf ("\t{\n\tuae_u32 carry;\n"); - printf ("\tuae_u32 hival = (val << 1) | GET_XFLG ();\n"); - printf ("\thival <<= (%d - cnt);\n", bit_size (curi->size) - 1); - printf ("\tval >>= cnt;\n"); - printf ("\tcarry = val & 1;\n"); - printf ("\tval >>= 1;\n"); - printf ("\tval |= hival;\n"); - printf ("\tSET_XFLG (carry);\n"); - printf ("\tval &= %s;\n", bit_mask (curi->size)); - printf ("\t} }\n"); - printf ("\tSET_CFLG (GET_XFLG ());\n"); - genflags (flag_logical_noclobber, curi->size, "val", "", ""); - shift_ce (curi->dmode, curi->size); - genastore ("val", curi->dmode, "dstreg", curi->size, "data"); - break; - case i_ASRW: - genamode (curi, curi->smode, "srcreg", curi->size, "data", 1, 0, GF_RMW); - fill_prefetch_next (); - start_brace (); - switch (curi->size) { - case sz_byte: printf ("\tuae_u32 val = (uae_u8)data;\n"); break; - case sz_word: printf ("\tuae_u32 val = (uae_u16)data;\n"); break; - case sz_long: printf ("\tuae_u32 val = data;\n"); break; - default: term (); - } - printf ("\tuae_u32 sign = %s & val;\n", cmask (curi->size)); - printf ("\tuae_u32 cflg = val & 1;\n"); - printf ("\tval = (val >> 1) | sign;\n"); - genflags (flag_logical, curi->size, "val", "", ""); - printf ("\tSET_CFLG (cflg);\n"); - duplicate_carry (0); - genastore ("val", curi->smode, "srcreg", curi->size, "data"); - break; - case i_ASLW: - genamode (curi, curi->smode, "srcreg", curi->size, "data", 1, 0, GF_RMW); - fill_prefetch_next (); - start_brace (); - switch (curi->size) { - case sz_byte: printf ("\tuae_u32 val = (uae_u8)data;\n"); break; - case sz_word: printf ("\tuae_u32 val = (uae_u16)data;\n"); break; - case sz_long: printf ("\tuae_u32 val = data;\n"); break; - default: term (); - } - printf ("\tuae_u32 sign = %s & val;\n", cmask (curi->size)); - printf ("\tuae_u32 sign2;\n"); - printf ("\tval <<= 1;\n"); - genflags (flag_logical, curi->size, "val", "", ""); - printf ("\tsign2 = %s & val;\n", cmask (curi->size)); - printf ("\tSET_CFLG (sign != 0);\n"); - duplicate_carry (0); - printf ("\tSET_VFLG (GET_VFLG () | (sign2 != sign));\n"); - genastore ("val", curi->smode, "srcreg", curi->size, "data"); - break; - case i_LSRW: - genamode (curi, curi->smode, "srcreg", curi->size, "data", 1, 0, GF_RMW); - fill_prefetch_next (); - start_brace (); - switch (curi->size) { - case sz_byte: printf ("\tuae_u32 val = (uae_u8)data;\n"); break; - case sz_word: printf ("\tuae_u32 val = (uae_u16)data;\n"); break; - case sz_long: printf ("\tuae_u32 val = data;\n"); break; - default: term (); - } - printf ("\tuae_u32 carry = val & 1;\n"); - printf ("\tval >>= 1;\n"); - genflags (flag_logical, curi->size, "val", "", ""); - printf ("\tSET_CFLG (carry);\n"); - duplicate_carry (0); - genastore ("val", curi->smode, "srcreg", curi->size, "data"); - break; - case i_LSLW: - genamode (curi, curi->smode, "srcreg", curi->size, "data", 1, 0, GF_RMW); - fill_prefetch_next (); - start_brace (); - switch (curi->size) { - case sz_byte: printf ("\tuae_u8 val = data;\n"); break; - case sz_word: printf ("\tuae_u16 val = data;\n"); break; - case sz_long: printf ("\tuae_u32 val = data;\n"); break; - default: term (); - } - printf ("\tuae_u32 carry = val & %s;\n", cmask (curi->size)); - printf ("\tval <<= 1;\n"); - genflags (flag_logical, curi->size, "val", "", ""); - printf ("\tSET_CFLG (carry >> %d);\n", bit_size (curi->size) - 1); - duplicate_carry (0); - genastore ("val", curi->smode, "srcreg", curi->size, "data"); - break; - case i_ROLW: - genamode (curi, curi->smode, "srcreg", curi->size, "data", 1, 0, GF_RMW); - fill_prefetch_next (); - start_brace (); - switch (curi->size) { - case sz_byte: printf ("\tuae_u8 val = data;\n"); break; - case sz_word: printf ("\tuae_u16 val = data;\n"); break; - case sz_long: printf ("\tuae_u32 val = data;\n"); break; - default: term (); - } - printf ("\tuae_u32 carry = val & %s;\n", cmask (curi->size)); - printf ("\tval <<= 1;\n"); - printf ("\tif (carry) val |= 1;\n"); - genflags (flag_logical, curi->size, "val", "", ""); - printf ("\tSET_CFLG (carry >> %d);\n", bit_size (curi->size) - 1); - genastore ("val", curi->smode, "srcreg", curi->size, "data"); - break; - case i_RORW: - genamode (curi, curi->smode, "srcreg", curi->size, "data", 1, 0, GF_RMW); - fill_prefetch_next (); - start_brace (); - switch (curi->size) { - case sz_byte: printf ("\tuae_u8 val = data;\n"); break; - case sz_word: printf ("\tuae_u16 val = data;\n"); break; - case sz_long: printf ("\tuae_u32 val = data;\n"); break; - default: term (); - } - printf ("\tuae_u32 carry = val & 1;\n"); - printf ("\tval >>= 1;\n"); - printf ("\tif (carry) val |= %s;\n", cmask (curi->size)); - genflags (flag_logical, curi->size, "val", "", ""); - printf ("\tSET_CFLG (carry);\n"); - genastore ("val", curi->smode, "srcreg", curi->size, "data"); - break; - case i_ROXLW: - genamode (curi, curi->smode, "srcreg", curi->size, "data", 1, 0, GF_RMW); - fill_prefetch_next (); - start_brace (); - switch (curi->size) { - case sz_byte: printf ("\tuae_u8 val = data;\n"); break; - case sz_word: printf ("\tuae_u16 val = data;\n"); break; - case sz_long: printf ("\tuae_u32 val = data;\n"); break; - default: term (); - } - printf ("\tuae_u32 carry = val & %s;\n", cmask (curi->size)); - printf ("\tval <<= 1;\n"); - printf ("\tif (GET_XFLG ()) val |= 1;\n"); - genflags (flag_logical, curi->size, "val", "", ""); - printf ("\tSET_CFLG (carry >> %d);\n", bit_size (curi->size) - 1); - duplicate_carry (0); - genastore ("val", curi->smode, "srcreg", curi->size, "data"); - break; - case i_ROXRW: - genamode (curi, curi->smode, "srcreg", curi->size, "data", 1, 0, GF_RMW); - fill_prefetch_next (); - start_brace (); - switch (curi->size) { - case sz_byte: printf ("\tuae_u8 val = data;\n"); break; - case sz_word: printf ("\tuae_u16 val = data;\n"); break; - case sz_long: printf ("\tuae_u32 val = data;\n"); break; - default: term (); - } - printf ("\tuae_u32 carry = val & 1;\n"); - printf ("\tval >>= 1;\n"); - printf ("\tif (GET_XFLG ()) val |= %s;\n", cmask (curi->size)); - genflags (flag_logical, curi->size, "val", "", ""); - printf ("\tSET_CFLG (carry);\n"); - duplicate_carry (0); - genastore ("val", curi->smode, "srcreg", curi->size, "data"); - break; - case i_MOVEC2: - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - fill_prefetch_next (); - start_brace (); - printf ("\tint regno = (src >> 12) & 15;\n"); - printf ("\tuae_u32 *regp = regs.regs + regno;\n"); - printf ("\tif (! m68k_movec2(src & 0xFFF, regp)) goto %s;\n", endlabelstr); - need_endlabel = 1; - break; - case i_MOVE2C: - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - fill_prefetch_next (); - start_brace (); - printf ("\tint regno = (src >> 12) & 15;\n"); - printf ("\tuae_u32 *regp = regs.regs + regno;\n"); - printf ("\tif (! m68k_move2c(src & 0xFFF, regp)) goto %s;\n", endlabelstr); - need_endlabel = 1; - break; - case i_CAS: - { - int old_brace_level; - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, GF_LRMW); - genamode (curi, curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_LRMW); - fill_prefetch_0 (); - start_brace (); - printf ("\tint ru = (src >> 6) & 7;\n"); - printf ("\tint rc = src & 7;\n"); - genflags (flag_cmp, curi->size, "newv", "m68k_dreg (regs, rc)", "dst"); - printf ("\tif (GET_ZFLG ())"); - old_brace_level = n_braces; - start_brace (); - printf ("\n\t"); - genastore_cas ("(m68k_dreg (regs, ru))", curi->dmode, "dstreg", curi->size, "dst"); - printf ("\t"); - pop_braces (old_brace_level); - printf ("else"); - start_brace (); - printf ("\n"); - if (cpu_level >= 4) { - // apparently 68040/060 needs to always write at the end of RMW cycle - printf ("\t"); - genastore_cas ("dst", curi->dmode, "dstreg", curi->size, "dst"); - } - switch (curi->size) { - case sz_byte: - printf ("\t\tm68k_dreg(regs, rc) = (m68k_dreg(regs, rc) & ~0xff) | (dst & 0xff);\n"); - break; - case sz_word: - printf ("\t\tm68k_dreg(regs, rc) = (m68k_dreg(regs, rc) & ~0xffff) | (dst & 0xffff);\n"); - break; - default: - printf ("\t\tm68k_dreg(regs, rc) = dst;\n"); - break; - } - pop_braces (old_brace_level); - } - break; - case i_CAS2: - genamode (curi, curi->smode, "srcreg", curi->size, "extra", 1, 0, GF_LRMW); - printf ("\tuae_u32 rn1 = regs.regs[(extra >> 28) & 15];\n"); - printf ("\tuae_u32 rn2 = regs.regs[(extra >> 12) & 15];\n"); - if (curi->size == sz_word) { - int old_brace_level = n_braces; - printf ("\tuae_u16 dst1 = %s (rn1), dst2 = %s (rn2);\n", srcwlrmw, srcwlrmw); - genflags (flag_cmp, curi->size, "newv", "m68k_dreg (regs, (extra >> 16) & 7)", "dst1"); - printf ("\tif (GET_ZFLG ()) {\n"); - genflags (flag_cmp, curi->size, "newv", "m68k_dreg (regs, extra & 7)", "dst2"); - printf ("\tif (GET_ZFLG ()) {\n"); - printf ("\t%s (rn1, m68k_dreg (regs, (extra >> 22) & 7));\n", dstwlrmw); - printf ("\t%s (rn2, m68k_dreg (regs, (extra >> 6) & 7));\n", dstwlrmw); - printf ("\t}}\n"); - pop_braces (old_brace_level); - printf ("\tif (! GET_ZFLG ()) {\n"); - printf ("\tm68k_dreg (regs, (extra >> 0) & 7) = (m68k_dreg (regs, (extra >> 6) & 7) & ~0xffff) | (dst2 & 0xffff);\n"); - printf ("\tm68k_dreg (regs, (extra >> 16) & 7) = (m68k_dreg (regs, (extra >> 22) & 7) & ~0xffff) | (dst1 & 0xffff);\n"); - printf ("\t}\n"); - } else { - int old_brace_level = n_braces; - printf ("\tuae_u32 dst1 = %s (rn1), dst2 = %s (rn2);\n", srcllrmw, srcllrmw); - genflags (flag_cmp, curi->size, "newv", "m68k_dreg (regs, (extra >> 16) & 7)", "dst1"); - printf ("\tif (GET_ZFLG ()) {\n"); - genflags (flag_cmp, curi->size, "newv", "m68k_dreg (regs, extra & 7)", "dst2"); - printf ("\tif (GET_ZFLG ()) {\n"); - printf ("\t%s (rn1, m68k_dreg (regs, (extra >> 22) & 7));\n", dstllrmw); - printf ("\t%s (rn2, m68k_dreg (regs, (extra >> 6) & 7));\n", dstllrmw); - printf ("\t}}\n"); - pop_braces (old_brace_level); - printf ("\tif (! GET_ZFLG ()) {\n"); - printf ("\tm68k_dreg (regs, (extra >> 0) & 7) = dst2;\n"); - printf ("\tm68k_dreg (regs, (extra >> 16) & 7) = dst1;\n"); - printf ("\t}\n"); - } - break; - case i_MOVES: /* ignore DFC and SFC */ - { - int old_brace_level; - genamode (curi, curi->smode, "srcreg", curi->size, "extra", 1, 0, 0); - printf ("\tif (extra & 0x800)\n"); - { - int old_m68k_pc_offset = m68k_pc_offset; - old_brace_level = n_braces; - start_brace (); - printf ("\tuae_u32 src = regs.regs[(extra >> 12) & 15];\n"); - genamode (curi, curi->dmode, "dstreg", curi->size, "dst", 2, 0, 0); - genastore_fc ("src", curi->dmode, "dstreg", curi->size, "dst"); - pop_braces (old_brace_level); - m68k_pc_offset = old_m68k_pc_offset; - } - printf ("else"); - { - start_brace (); - genamode (curi, curi->dmode, "dstreg", curi->size, "src", 1, 0, GF_FC); - printf ("\tif (extra & 0x8000) {\n"); - switch (curi->size) { - case sz_byte: printf ("\tm68k_areg (regs, (extra >> 12) & 7) = (uae_s32)(uae_s8)src;\n"); break; - case sz_word: printf ("\tm68k_areg (regs, (extra >> 12) & 7) = (uae_s32)(uae_s16)src;\n"); break; - case sz_long: printf ("\tm68k_areg (regs, (extra >> 12) & 7) = src;\n"); break; - default: term (); - } - printf ("\t} else {\n"); - genastore ("src", Dreg, "(extra >> 12) & 7", curi->size, ""); - printf ("\t}\n"); - pop_braces (old_brace_level); - } - } - break; - case i_BKPT: /* only needed for hardware emulators */ - sync_m68k_pc (); - printf ("\top_illg (opcode);\n"); - did_prefetch = -1; - break; - case i_CALLM: /* not present in 68030 */ - sync_m68k_pc (); - printf ("\top_illg (opcode);\n"); - did_prefetch = -1; - break; - case i_RTM: /* not present in 68030 */ - sync_m68k_pc (); - printf ("\top_illg (opcode);\n"); - did_prefetch = -1; - break; - case i_TRAPcc: - if (curi->smode != am_unknown && curi->smode != am_illg) - genamode (curi, curi->smode, "srcreg", curi->size, "dummy", 1, 0, 0); - fill_prefetch_0 (); - printf ("\tif (cctrue (%d)) { Exception_cpu(7); goto %s; }\n", curi->cc, endlabelstr); - need_endlabel = 1; - break; - case i_DIVL: - genamode (curi, curi->smode, "srcreg", curi->size, "extra", 1, 0, 0); - printf ("\tif (extra & 0x800) cyc = 12 * CYCLE_UNIT / 2;\n"); - genamode (curi, curi->dmode, "dstreg", curi->size, "dst", 1, 0, 0); - sync_m68k_pc (); - printf ("\tif (dst == 0) {\n"); - printf ("\t\tException_cpu(5);\n"); - printf ("\t\treturn 4 * CYCLE_UNIT / 2;\n"); - printf ("\t}\n"); - printf ("\tm68k_divl(opcode, dst, extra);\n"); - break; - case i_MULL: - genamode (curi, curi->smode, "srcreg", curi->size, "extra", 1, 0, 0); - genamode (curi, curi->dmode, "dstreg", curi->size, "dst", 1, 0, 0); - sync_m68k_pc (); - printf ("\tm68k_mull(opcode, dst, extra);\n"); - break; - case i_BFTST: - case i_BFEXTU: - case i_BFCHG: - case i_BFEXTS: - case i_BFCLR: - case i_BFFFO: - case i_BFSET: - case i_BFINS: - { - const char *getb, *putb; - - getb = "get_bitfield"; - putb = "put_bitfield"; - - genamode (curi, curi->smode, "srcreg", curi->size, "extra", 1, 0, 0); - genamode (curi, curi->dmode, "dstreg", sz_long, "dst", 2, 0, 0); - start_brace (); - printf ("\tuae_u32 bdata[2];\n"); - printf ("\tuae_s32 offset = extra & 0x800 ? m68k_dreg(regs, (extra >> 6) & 7) : (extra >> 6) & 0x1f;\n"); - printf ("\tint width = (((extra & 0x20 ? m68k_dreg(regs, extra & 7) : extra) -1) & 0x1f) +1;\n"); - if (curi->mnemo == i_BFFFO) - printf("\tuae_u32 offset2 = offset;\n"); - if (curi->dmode == Dreg) { - printf ("\tuae_u32 tmp = m68k_dreg(regs, dstreg);\n"); - printf ("\toffset &= 0x1f;\n"); - printf ("\ttmp = (tmp << offset) | (tmp >> (32 - offset));\n"); - printf ("\tbdata[0] = tmp & ((1 << (32 - width)) - 1);\n"); - } else { - printf ("\tuae_u32 tmp;\n"); - printf ("\tdsta += offset >> 3;\n"); - printf ("\ttmp = %s (dsta, bdata, offset, width);\n", getb); - } - printf ("\tSET_NFLG_ALWAYS (((uae_s32)tmp) < 0 ? 1 : 0);\n"); - if (curi->mnemo == i_BFEXTS) - printf ("\ttmp = (uae_s32)tmp >> (32 - width);\n"); - else - printf ("\ttmp >>= (32 - width);\n"); - printf ("\tSET_ZFLG (tmp == 0); SET_VFLG (0); SET_CFLG (0);\n"); - switch (curi->mnemo) { - case i_BFTST: - break; - case i_BFEXTU: - case i_BFEXTS: - printf ("\tm68k_dreg (regs, (extra >> 12) & 7) = tmp;\n"); - break; - case i_BFCHG: - printf ("\ttmp = tmp ^ (0xffffffffu >> (32 - width));\n"); - break; - case i_BFCLR: - printf ("\ttmp = 0;\n"); - break; - case i_BFFFO: - printf ("\t{ uae_u32 mask = 1 << (width - 1);\n"); - printf ("\twhile (mask) { if (tmp & mask) break; mask >>= 1; offset2++; }}\n"); - printf ("\tm68k_dreg (regs, (extra >> 12) & 7) = offset2;\n"); - break; - case i_BFSET: - printf ("\ttmp = 0xffffffffu >> (32 - width);\n"); - break; - case i_BFINS: - printf ("\ttmp = m68k_dreg (regs, (extra >> 12) & 7);\n"); - printf ("\ttmp = tmp & (0xffffffffu >> (32 - width));\n"); - printf ("\tSET_NFLG (tmp & (1 << (width - 1)) ? 1 : 0);\n"); - printf ("\tSET_ZFLG (tmp == 0);\n"); - break; - default: - break; - } - if (curi->mnemo == i_BFCHG - || curi->mnemo == i_BFCLR - || curi->mnemo == i_BFSET - || curi->mnemo == i_BFINS) { - if (curi->dmode == Dreg) { - printf ("\ttmp = bdata[0] | (tmp << (32 - width));\n"); - printf ("\tm68k_dreg(regs, dstreg) = (tmp >> offset) | (tmp << (32 - offset));\n"); - } else { - printf ("\t%s(dsta, bdata, tmp, offset, width);\n", putb); - } - } - } - break; - case i_PACK: - if (curi->smode == Dreg) { - printf ("\tuae_u16 val = m68k_dreg (regs, srcreg) + %s;\n", gen_nextiword (0)); - printf ("\tm68k_dreg (regs, dstreg) = (m68k_dreg (regs, dstreg) & 0xffffff00) | ((val >> 4) & 0xf0) | (val & 0xf);\n"); - } else { - printf ("\tuae_u16 val;\n"); - printf ("\tm68k_areg (regs, srcreg) -= areg_byteinc[srcreg];\n"); - printf ("\tval = (uae_u16)(%s (m68k_areg (regs, srcreg)) & 0xff);\n", srcb); - printf ("\tm68k_areg (regs, srcreg) -= areg_byteinc[srcreg];\n"); - printf ("\tval = (val | ((uae_u16)(%s (m68k_areg (regs, srcreg)) & 0xff) << 8)) + %s;\n", srcb, gen_nextiword (0)); - printf ("\tm68k_areg (regs, dstreg) -= areg_byteinc[dstreg];\n"); - printf ("\t%s (m68k_areg (regs, dstreg),((val >> 4) & 0xf0) | (val & 0xf));\n", dstb); - } - break; - case i_UNPK: - if (curi->smode == Dreg) { - printf ("\tuae_u16 val = m68k_dreg (regs, srcreg);\n"); - printf ("\tval = (((val << 4) & 0xf00) | (val & 0xf)) + %s;\n", gen_nextiword (0)); - printf ("\tm68k_dreg (regs, dstreg) = (m68k_dreg (regs, dstreg) & 0xffff0000) | (val & 0xffff);\n"); - } else { - printf ("\tuae_u16 val;\n"); - printf ("\tm68k_areg (regs, srcreg) -= areg_byteinc[srcreg];\n"); - printf ("\tval = (uae_u16)(%s (m68k_areg (regs, srcreg)) & 0xff);\n", srcb); - printf ("\tval = (((val << 4) & 0xf00) | (val & 0xf)) + %s;\n", gen_nextiword (0)); - 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); - printf ("\t%s (m68k_areg (regs, dstreg), val >> 8);\n", dstb); - } else { - printf ("\tm68k_areg (regs, dstreg) -= areg_byteinc[dstreg];\n"); - printf ("\t%s (m68k_areg (regs, dstreg),val);\n", dstb); - printf ("\tm68k_areg (regs, dstreg) -= areg_byteinc[dstreg];\n"); - printf ("\t%s (m68k_areg (regs, dstreg),val >> 8);\n", dstb); - } - } - break; - case i_TAS: - genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, GF_LRMW); - genflags (flag_logical, curi->size, "src", "", ""); - if (!isreg (curi->smode)) - addcycles000 (6); - fill_prefetch_next (); - printf ("\tsrc |= 0x80;\n"); - if (next_cpu_level < 2) - next_cpu_level = 2 - 1; - genastore_tas ("src", curi->smode, "srcreg", curi->size, "src"); - break; - case i_FPP: - fpulimit(); - genamode (curi, curi->smode, "srcreg", curi->size, "extra", 1, 0, 0); - sync_m68k_pc (); - printf ("\tfpuop_arithmetic(opcode, extra);\n"); - if (using_prefetch) { - printf ("\tif (regs.fp_exception) goto %s;\n", endlabelstr); - need_endlabel = 1; - } - break; - case i_FDBcc: - fpulimit(); - genamode (curi, curi->smode, "srcreg", curi->size, "extra", 1, 0, 0); - sync_m68k_pc (); - printf ("\tfpuop_dbcc (opcode, extra);\n"); - if (using_prefetch) { - printf ("\tif (regs.fp_exception) goto %s;\n", endlabelstr); - printf ("\tif (regs.fp_branch) {\n"); - printf ("\t\tregs.fp_branch = false;\n"); - printf ("\t\tfill_prefetch();\n"); - printf ("\t\tgoto %s;\n", endlabelstr); - printf ("\t}\n"); - need_endlabel = 1; - } else { - printf ("\tif (regs.fp_branch) {\n"); - printf ("\t\tregs.fp_branch = false;\n"); - printf ("\t\tif(regs.t0) check_t0_trace();\n"); - printf ("\t}\n"); - } - break; - case i_FScc: - fpulimit(); - genamode (curi, curi->smode, "srcreg", curi->size, "extra", 1, 0, 0); - sync_m68k_pc (); - printf ("\tfpuop_scc (opcode, extra);\n"); - if (using_prefetch) { - printf ("\tif (regs.fp_exception) goto %s;\n", endlabelstr); - need_endlabel = 1; - } - break; - case i_FTRAPcc: - fpulimit(); - printf ("\tuaecptr oldpc = %s;\n", getpc); - printf ("\tuae_u16 extra = %s;\n", gen_nextiword (0)); - if (curi->smode != am_unknown && curi->smode != am_illg) - genamode (curi, curi->smode, "srcreg", curi->size, "dummy", 1, 0, 0); - sync_m68k_pc (); - printf ("\tfpuop_trapcc (opcode, oldpc, extra);\n"); - if (using_prefetch) { - printf ("\tif (regs.fp_exception) goto %s;\n", endlabelstr); - need_endlabel = 1; - } - break; - case i_FBcc: - fpulimit(); - sync_m68k_pc (); - start_brace (); - printf ("\tuaecptr pc = %s;\n", getpc); - genamode (curi, curi->dmode, "srcreg", curi->size, "extra", 1, 0, 0); - sync_m68k_pc (); - printf ("\tfpuop_bcc (opcode, pc,extra);\n"); - if (using_prefetch) { - printf ("\tif (regs.fp_exception) goto %s;\n", endlabelstr); - printf ("\tif (regs.fp_branch) {\n"); - printf ("\t\tregs.fp_branch = false;\n"); - printf ("\t\tfill_prefetch();\n"); - printf ("\t\tgoto %s;\n", endlabelstr); - printf ("\t}\n"); - need_endlabel = 1; - } else { - printf ("\tif (regs.fp_branch) {\n"); - printf ("\t\tregs.fp_branch = false;\n"); - printf ("\t\tif(regs.t0) check_t0_trace();\n"); - printf ("\t}\n"); - } - break; - case i_FSAVE: - fpulimit(); - sync_m68k_pc (); - printf ("\tfpuop_save (opcode);\n"); - if (using_prefetch) { - printf ("\tif (regs.fp_exception) goto %s;\n", endlabelstr); - need_endlabel = 1; - } - break; - case i_FRESTORE: - fpulimit(); - sync_m68k_pc (); - printf ("\tfpuop_restore (opcode);\n"); - if (using_prefetch) { - printf ("\tif (regs.fp_exception) goto %s;\n", endlabelstr); - need_endlabel = 1; - } - break; - - case i_CINVL: - case i_CINVP: - case i_CINVA: - case i_CPUSHL: - case i_CPUSHP: - case i_CPUSHA: - printf ("\tflush_cpu_caches_040(opcode);\n"); - printf ("\tif (opcode & 0x80)\n"); - printf ("\t\tflush_icache((opcode >> 6) & 3);\n"); - break; - - case i_MOVE16: - { - if ((opcode & 0xfff8) == 0xf620) { - /* MOVE16 (Ax)+,(Ay)+ */ - 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 ("\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 v[4];\n"); - genamode (curi, curi->smode, "srcreg", curi->size, "mems", 0, 2, 0); - genamode (curi, curi->dmode, "dstreg", curi->size, "memd", 0, 2, 0); - printf ("\tmemsa &= ~15;\n"); - printf ("\tmemda &= ~15;\n"); - 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) - printf ("\tm68k_areg (regs, dstreg) += 16;\n"); - } - } - break; - - case i_PFLUSHN: - case i_PFLUSH: - case i_PFLUSHAN: - case i_PFLUSHA: - case i_PLPAR: - case i_PLPAW: - case i_PTESTR: - case i_PTESTW: - sync_m68k_pc (); - printf ("\tmmu_op (opcode, 0);\n"); - break; - case i_MMUOP030: - printf ("\tuaecptr pc = %s;\n", getpc); - printf ("\tuae_u16 extra = %s (2);\n", prefetch_word); - m68k_pc_offset += 2; - sync_m68k_pc (); - if (curi->smode == Areg || curi->smode == Dreg) - printf("\tuae_u16 extraa = 0;\n"); - else - genamode (curi, curi->smode, "srcreg", curi->size, "extra", 0, 0, 0); - sync_m68k_pc (); - printf ("\tmmu_op30 (pc, opcode, extra, extraa);\n"); - break; - default: - term (); - break; - } -end: - finish_braces (); - if (limit_braces) { - printf ("\n#endif\n"); - n_braces = limit_braces; - limit_braces = 0; - finish_braces (); - } - if (did_prefetch >= 0) - fill_prefetch_finish (); - sync_m68k_pc (); - did_prefetch = 0; - if (cpu_level >= 2) { - int v = curi->clocks; - if (v < 4) - v = 4; - count_cycles = insn_n_cycles = v; - } -} - -static void generate_includes (FILE * f, int id) -{ - fprintf (f, "#include \"sysconfig.h\"\n"); - fprintf (f, "#include \"sysdeps.h\"\n"); - fprintf (f, "#include \"options.h\"\n"); - fprintf (f, "#include \"memory.h\"\n"); - fprintf (f, "#include \"custom.h\"\n"); - fprintf (f, "#include \"newcpu.h\"\n"); - fprintf (f, "#include \"cpu_prefetch.h\"\n"); - fprintf (f, "#include \"cputbl.h\"\n"); - - fprintf (f, "#define CPUFUNC(x) x##_ff\n" - "#define SET_CFLG_ALWAYS(x) SET_CFLG(x)\n" - "#define SET_NFLG_ALWAYS(x) SET_NFLG(x)\n" - "#ifdef NOFLAGS\n" - "#include \"noflags.h\"\n" - "#endif\n"); -} - -static int postfix; - - -static char *decodeEA (amodes mode, wordsizes size) -{ - static char buffer[80]; - - buffer[0] = 0; - switch (mode){ - case Dreg: - strcpy (buffer,"Dn"); - break; - case Areg: - strcpy (buffer,"An"); - break; - case Aind: - strcpy (buffer,"(An)"); - break; - case Aipi: - strcpy (buffer,"(An)+"); - break; - case Apdi: - strcpy (buffer,"-(An)"); - break; - case Ad16: - strcpy (buffer,"(d16,An)"); - break; - case Ad8r: - strcpy (buffer,"(d8,An,Xn)"); - break; - case PC16: - strcpy (buffer,"(d16,PC)"); - break; - case PC8r: - strcpy (buffer,"(d8,PC,Xn)"); - break; - case absw: - strcpy (buffer,"(xxx).W"); - break; - case absl: - strcpy (buffer,"(xxx).L"); - break; - case imm: - switch (size){ - case sz_byte: - strcpy (buffer,"#.B"); - break; - case sz_word: - strcpy (buffer,"#.W"); - break; - case sz_long: - strcpy (buffer,"#.L"); - break; - default: - break; - } - break; - case imm0: - strcpy (buffer,"#.B"); - break; - case imm1: - strcpy (buffer,"#.W"); - break; - case imm2: - strcpy (buffer,"#.L"); - break; - case immi: - strcpy (buffer,"#"); - break; - - default: - break; - } - return buffer; -} - -static const char *m68k_cc[] = { - "T", - "F", - "HI", - "LS", - "CC", - "CS", - "NE", - "EQ", - "VC", - "VS", - "PL", - "MI", - "GE", - "LT", - "GT", - "LE" -}; - -static char *outopcode (int opcode) -{ - static char out[100]; - struct instr *ins; - int i; - - ins = &table68k[opcode]; - for (i = 0; lookuptab[i].name[0]; i++) { - if (ins->mnemo == lookuptab[i].mnemo) - break; - } - { - char *s = ua (lookuptab[i].name); - strcpy (out, s); - xfree (s); - } - if (ins->smode == immi) - strcat (out, "Q"); - if (ins->size == sz_byte) - strcat (out,".B"); - if (ins->size == sz_word) - strcat (out,".W"); - if (ins->size == sz_long) - strcat (out,".L"); - strcat (out," "); - if (ins->suse) - strcat (out, decodeEA (ins->smode, ins->size)); - if (ins->duse) { - if (ins->suse) strcat (out,","); - strcat (out, decodeEA (ins->dmode, ins->size)); - } - if (ins->mnemo == i_DBcc || ins->mnemo == i_Scc || ins->mnemo == i_Bcc || ins->mnemo == i_TRAPcc) { - strcat (out, " ("); - strcat (out, m68k_cc[table68k[opcode].cc]); - strcat (out, ")"); - } - - return out; -} - -struct cputbl_tmp -{ - uae_s16 length; - uae_s8 disp020[2]; - uae_u8 branch; -}; -static struct cputbl_tmp cputbltmp[65536]; - -static int count_required(int opcode) -{ - struct instr *curi = table68k + opcode; - - switch(curi->mnemo) { - case i_MVMLE: - case i_MVMEL: - return 1; - case i_ASR: - case i_ASL: - case i_LSR: - case i_LSL: - case i_ROXR: - case i_ROR: - case i_ROXL: - case i_ROL: - case i_MULU: - case i_MULS: - case i_DIVU: - case i_DIVS: - case i_DBcc: - if(cpu_level <= 1) - return 1; - break; - case i_Scc: - if(curi->smode == Dreg && cpu_level <= 1) - return 1; - break; - } - return 0; -} - -static void generate_one_opcode (int rp, const char *extra) -{ - int idx; - uae_u16 smsk, dmsk; - unsigned int opcode = opcode_map[rp]; - int i68000 = table68k[opcode].clev > 0; - - if (table68k[opcode].mnemo == i_ILLG - || table68k[opcode].clev > cpu_level) - return; - - for (idx = 0; lookuptab[idx].name[0]; idx++) { - if (table68k[opcode].mnemo == lookuptab[idx].mnemo) - break; - } - - if (table68k[opcode].handler != -1) - return; - - if (opcode_next_clev[rp] != cpu_level) { - char *name = ua (lookuptab[idx].name); - if (generate_stbl) - fprintf (stblfile, "{ CPUFUNC(op_%04x_%d%s), 0x%04x, %d, { %d, %d }, %d }, /* %s */\n", - opcode, opcode_last_postfix[rp], - extra, opcode, - cputbltmp[opcode].length, cputbltmp[opcode].disp020[0], cputbltmp[opcode].disp020[1], cputbltmp[opcode].branch, name); - xfree (name); - return; - } - fprintf (headerfile, "extern %s op_%04x_%d%s_nf;\n", - "cpuop_func", opcode, postfix, extra); - fprintf (headerfile, "extern %s op_%04x_%d%s_ff;\n", - "cpuop_func", opcode, postfix, extra); - printf ("/* %s */\n", outopcode (opcode)); - printf ("%s REGPARAM2 CPUFUNC(op_%04x_%d%s)(uae_u32 opcode)\n{\n", "uae_u32", opcode, postfix, extra); - int org_using_simple_cycles = using_simple_cycles; - if(count_required(opcode)) - using_simple_cycles = 1; - if (using_simple_cycles) - printf("\tint count_cycles = 0;\n"); - - switch (table68k[opcode].stype) { - case 0: smsk = 7; break; - case 1: smsk = 255; break; - case 2: smsk = 15; break; - case 3: smsk = 7; break; - case 4: smsk = 7; break; - case 5: smsk = 63; break; - case 6: smsk = 255; break; - case 7: smsk = 3; break; - default: term (); - } - dmsk = 7; - - next_cpu_level = -1; - if (table68k[opcode].suse - && table68k[opcode].smode != imm && table68k[opcode].smode != imm0 - && table68k[opcode].smode != imm1 && table68k[opcode].smode != imm2 - && table68k[opcode].smode != absw && table68k[opcode].smode != absl - && table68k[opcode].smode != PC8r && table68k[opcode].smode != PC16 - /* gb-- We don't want to fetch the EmulOp code since the EmulOp() - routine uses the whole opcode value. Maybe all the EmulOps - could be expanded out but I don't think it is an improvement */ - && table68k[opcode].stype != 6 - ) - { - if (table68k[opcode].spos == -1) { - if (((int) table68k[opcode].sreg) >= 128) - printf ("\tuae_u32 srcreg = (uae_s32)(uae_s8)%d;\n", (int) table68k[opcode].sreg); - else - printf ("\tuae_u32 srcreg = %d;\n", (int) table68k[opcode].sreg); - } else { - char source[100]; - int pos = table68k[opcode].spos; - - if (pos) - sprintf (source, "((opcode >> %d) & %d)", pos, smsk); - else - sprintf (source, "(opcode & %d)", smsk); - - if (table68k[opcode].stype == 3) - printf ("\tuae_u32 srcreg = imm8_table[%s];\n", source); - else if (table68k[opcode].stype == 1) - printf ("\tuae_u32 srcreg = (uae_s32)(uae_s8)%s;\n", source); - else - printf ("\tuae_u32 srcreg = %s;\n", source); - } - } - if (table68k[opcode].duse - /* Yes, the dmode can be imm, in case of LINK or DBcc */ - && table68k[opcode].dmode != imm && table68k[opcode].dmode != imm0 - && table68k[opcode].dmode != imm1 && table68k[opcode].dmode != imm2 - && table68k[opcode].dmode != absw && table68k[opcode].dmode != absl) - { - if (table68k[opcode].dpos == -1) { - if (((int) table68k[opcode].dreg) >= 128) - printf ("\tuae_u32 dstreg = (uae_s32)(uae_s8)%d;\n", (int) table68k[opcode].dreg); - else - printf ("\tuae_u32 dstreg = %d;\n", (int) table68k[opcode].dreg); - } else { - int pos = table68k[opcode].dpos; - if (pos) - printf ("\tuae_u32 dstreg = (opcode >> %d) & %d;\n", - pos, dmsk); - else - printf ("\tuae_u32 dstreg = opcode & %d;\n", dmsk); - } - } - need_endlabel = 0; - endlabelno++; - sprintf (endlabelstr, "l_%d", endlabelno); - count_read = count_write = count_ncycles = count_cycles = 0; - count_read_ea = count_write_ea = count_cycles_ea = 0; - gen_opcode (opcode); - if (need_endlabel) - printf ("%s: ;\n", endlabelstr); - if (using_prefetch) { - if (count_read + count_write + count_cycles == 0) - count_cycles = 4; - returncycles ("", (count_read + count_write) * 4 + count_cycles); - printf ("}"); - printf (" /* %d%s (%d/%d)", - (count_read + count_write) * 4 + count_cycles, count_ncycles ? "+" : "", count_read, count_write); - printf (" */\n"); - } else if (count_read + count_write + count_cycles) { - returncycles ("", (count_read + count_write) * 4 + count_cycles + 4); - printf ("}"); - printf("\n"); - } else { - returncycles ("", insn_n_cycles); - printf ("}"); - printf("\n"); - } - printf ("\n"); - using_simple_cycles = org_using_simple_cycles; - - opcode_next_clev[rp] = next_cpu_level; - opcode_last_postfix[rp] = postfix; - - if ((opcode & 0xf000) == 0xf000) - m68k_pc_total = -1; - cputbltmp[opcode].length = m68k_pc_total; - - cputbltmp[opcode].disp020[0] = 0; - if (genamode8r_offset[0] > 0) - cputbltmp[opcode].disp020[0] = m68k_pc_total - genamode8r_offset[0] + 2; - cputbltmp[opcode].disp020[1] = 0; - if (genamode8r_offset[1] > 0) - cputbltmp[opcode].disp020[1] = m68k_pc_total - genamode8r_offset[1] + 2; - - cputbltmp[opcode].branch = branch_inst; - - if (generate_stbl) { - char *name = ua (lookuptab[idx].name); - fprintf (stblfile, "{ CPUFUNC(op_%04x_%d%s), 0x%04x, %d, { %d, %d }, %d }, /* %s */\n", - opcode, postfix, extra, opcode, - cputbltmp[opcode].length, cputbltmp[opcode].disp020[0], cputbltmp[opcode].disp020[1], cputbltmp[opcode].branch, name); - xfree (name); - } -} - -static void generate_func (const char *extra) -{ - int j, rp; - - /* sam: this is for people with low memory (eg. me :)) */ - printf ("\n" - "#if !defined(PART_1) && !defined(PART_2) && " - "!defined(PART_3) && !defined(PART_4) && " - "!defined(PART_5) && !defined(PART_6) && " - "!defined(PART_7) && !defined(PART_8)" - "\n" - "#define PART_1 1\n" - "#define PART_2 1\n" - "#define PART_3 1\n" - "#define PART_4 1\n" - "#define PART_5 1\n" - "#define PART_6 1\n" - "#define PART_7 1\n" - "#define PART_8 1\n" - "#endif\n\n"); - - rp = 0; - for(j = 1; j <= 8; ++j) { - int k = (j * nr_cpuop_funcs) / 8; - printf ("#ifdef PART_%d\n",j); - for (; rp < k; rp++) - generate_one_opcode (rp, extra); - printf ("#endif\n\n"); - } - - if (generate_stbl) - fprintf (stblfile, "{ 0, 0 }};\n"); -} - -static void generate_cpu (int id, int mode) -{ - char fname[100]; - const char *extra, *extraup; - static int postfix2 = -1; - int rp; - - extra = ""; - extraup = ""; - - postfix = id; - if (id == 0 || id == 4 || id == 11 || id == 40 || id == 44) { - if (generate_stbl && id != 4 && id != 44) - fprintf (stblfile, "#ifdef CPUEMU_%d%s\n", postfix, extraup); - postfix2 = postfix; - sprintf (fname, "cpuemu_%d%s.cpp", postfix, extra); - if (freopen (fname, "wb", stdout) == NULL) { - abort (); - } - generate_includes (stdout, id); - } - - using_exception_3 = 1; - using_prefetch = 0; - using_simple_cycles = 0; - using_indirect = 0; - cpu_generic = false; - - if (id == 11 || id == 12) { // 11 = 68010 prefetch, 12 = 68000 prefetch - cpu_level = id == 11 ? 1 : 0; - using_prefetch = 1; - using_exception_3 = 1; - using_simple_cycles = 1; - if (id == 11) { - read_counts (); - for (rp = 0; rp < nr_cpuop_funcs; rp++) - opcode_next_clev[rp] = cpu_level; - } - } else if (id < 6) { - cpu_level = 5 - (id - 0); // "generic" - cpu_generic = true; - } else if (id >= 40 && id < 46) { - cpu_level = 5 - (id - 40); // "generic" + direct - cpu_generic = true; - if (id == 40) { - read_counts(); - for (rp = 0; rp < nr_cpuop_funcs; rp++) - opcode_next_clev[rp] = cpu_level; - } - using_indirect = -1; - } - if (id == 4 || id == 44) { - cpu_level = 1; - for (rp = 0; rp < nr_cpuop_funcs; rp++) { - opcode_next_clev[rp] = cpu_level; - } - } - - if (generate_stbl) { - fprintf (stblfile, "const struct cputbl CPUFUNC(op_smalltbl_%d%s)[] = {\n", postfix, extra); - } - endlabelno = id * 10000; - generate_func (extra); - if (generate_stbl) { - if (postfix2 >= 0 && postfix2 != 4 && postfix2 != 44) - fprintf (stblfile, "#endif /* CPUEMU_%d%s */\n", postfix2, extraup); - } - postfix2 = -1; -} - -int main(int argc, char *argv[]) -{ - int i; - - read_table68k (); - do_merges (); - - 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 (); - - /* It would be a lot nicer to put all in one file (we'd also get rid of - * cputbl.h that way), but cpuopti can't cope. That could be fixed, but - * I don't dare to touch the 68k version. */ - - headerfile = fopen ("cputbl.h", "wb"); - - stblfile = fopen ("cpustbl.cpp", "wb"); - generate_includes (stblfile, 0); - - for (i = 0; i <= 45; i++) { - if ((i >= 6 && i < 11) || (i > 12 && i < 40)) - continue; - generate_stbl = 1; - generate_cpu (i, 0); - } - - free (table68k); - fclose(headerfile); - fclose(stblfile); - return 0; -} - -void write_log (const TCHAR *format,...) -{ -} diff --git a/src/genlinetoscr.cpp b/src/genlinetoscr.cpp deleted file mode 100644 index 5ad25657..00000000 --- a/src/genlinetoscr.cpp +++ /dev/null @@ -1,605 +0,0 @@ -/* -* E-UAE - The portable Amiga Emulator -* -* Generate pixel output code. -* -* (c) 2006 Richard Drummond -*/ - -#include "sysconfig.h" -#include "sysdeps.h" - -#include -#include -#include - -/* Output for big-endian target if true, little-endian is false. */ -int do_bigendian; - -typedef int DEPTH_T; - -#define DEPTH_8BPP 0 -#define DEPTH_16BPP 1 -#define DEPTH_32BPP 2 -#define DEPTH_MAX DEPTH_32BPP - -static const char *get_depth_str (DEPTH_T bpp) -{ - if (bpp == DEPTH_8BPP) - return "8"; - else if (bpp == DEPTH_16BPP) - return "16"; - else - return "32"; -} - -static const char *get_depth_type_str (DEPTH_T bpp) -{ - if (bpp == DEPTH_8BPP) - return "uae_u8"; - else if (bpp == DEPTH_16BPP) - return "uae_u16"; - else - return "uae_u32"; -} - -typedef int HMODE_T; - -#define HMODE_NORMAL 0 -#define HMODE_DOUBLE 1 -#define HMODE_DOUBLE2X 2 -#define HMODE_HALVE1 3 -#define HMODE_HALVE1F 4 -#define HMODE_HALVE2 5 -#define HMODE_HALVE2F 6 -#define HMODE_MAX HMODE_HALVE2F - -static const char *get_hmode_str (HMODE_T hmode) -{ - if (hmode == HMODE_DOUBLE) - return "_stretch1"; - else if (hmode == HMODE_DOUBLE2X) - return "_stretch2"; - else if (hmode == HMODE_HALVE1) - return "_shrink1"; - else if (hmode == HMODE_HALVE1F) - return "_shrink1f"; - else if (hmode == HMODE_HALVE2) - return "_shrink2"; - else if (hmode == HMODE_HALVE2F) - return "_shrink2f"; - else - return ""; -} - - -typedef enum -{ - CMODE_NORMAL, - CMODE_DUALPF, - CMODE_EXTRAHB, - CMODE_HAM -} CMODE_T; -#define CMODE_MAX CMODE_HAM - - -static FILE *outfile; -static unsigned int outfile_indent = 0; - -static void set_outfile (FILE *f) -{ - outfile = f; -} - -static int set_indent (int indent) -{ - int old_indent = outfile_indent; - outfile_indent = indent; - return old_indent; -} - -static void outindent(void) -{ - unsigned int i; - for (i = 0; i < outfile_indent; i++) - fputc(' ', outfile); -} - -static void outf(const char *s, ...) -{ - va_list ap; - va_start(ap, s); - vfprintf(outfile, s, ap); -} - -static void outln (const char *s) -{ - outindent(); - fprintf (outfile, "%s\n", s); -} - -static void outlnf (const char *s, ...) -{ - va_list ap; - outindent(); - va_start (ap, s); - vfprintf (outfile, s, ap); - fputc ('\n', outfile); -} - -static void out_linetoscr_decl (DEPTH_T bpp, HMODE_T hmode, int aga, int spr, int genlock) -{ - outlnf ("static int NOINLINE linetoscr_%s%s%s%s%s(int spix, int dpix, int dpix_end)", - get_depth_str (bpp), - get_hmode_str (hmode), aga ? "_aga" : "", spr > 0 ? "_spr" : (spr < 0 ? "_spronly" : ""), genlock ? "_genlock" : ""); -} - -static void out_linetoscr_do_srcpix (DEPTH_T bpp, HMODE_T hmode, int aga, CMODE_T cmode, int spr) -{ - if (spr < 0) { - outln ( " sprpix_val = 0;"); - } else { - if (aga && cmode != CMODE_DUALPF) { - if (spr) - outln ( " sprpix_val = pixdata.apixels[spix];"); - if (cmode != CMODE_HAM) - outln ( " spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;"); - } else if (cmode != CMODE_HAM) { - outln ( " spix_val = pixdata.apixels[spix];"); - if (spr) - outln ( " sprpix_val = spix_val;"); - } - } -} - -static void out_linetoscr_do_dstpix (DEPTH_T bpp, HMODE_T hmode, int aga, CMODE_T cmode, int spr) -{ - if (spr < 0) - return; - if (aga && cmode == CMODE_HAM) { - outln ( " spix_val = ham_linebuf[spix];"); - outln ( " dpix_val = CONVERT_RGB (spix_val);"); - } else if (cmode == CMODE_HAM) { - outln ( " spix_val = ham_linebuf[spix];"); - outln ( " dpix_val = p_xcolors[spix_val];"); - if (spr) - outln ( " sprpix_val = pixdata.apixels[spix];"); - } else if (aga && cmode == CMODE_DUALPF) { - outln ( " {"); - outln ( " uae_u8 val = lookup[spix_val];"); - outln ( " if (lookup_no[spix_val])"); - outln ( " val += dblpfofs[bpldualpf2of];"); - outln ( " val ^= xor_val;"); - outln ( " dpix_val = p_acolors[val];"); - outln ( " }"); - } else if (cmode == CMODE_DUALPF) { - outln ( " dpix_val = p_acolors[lookup[spix_val]];"); - } else if (aga && cmode == CMODE_EXTRAHB) { - outln ( " if (pixdata.apixels[spix] & 0x20) {"); - outln ( " unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;"); - outln ( " dpix_val = CONVERT_RGB (c);"); - outln ( " } else"); - outln ( " dpix_val = p_acolors[spix_val];"); - } else if (cmode == CMODE_EXTRAHB) { - outln ( " if (spix_val <= 31)"); - outln ( " dpix_val = p_acolors[spix_val];"); - outln ( " else"); - outln ( " dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];"); - } else - outln ( " dpix_val = p_acolors[spix_val];"); -} - -static void out_linetoscr_do_incspix (DEPTH_T bpp, HMODE_T hmode, int aga, CMODE_T cmode, int spr) -{ - if (spr < 0) { - outln(" spix++;"); - return; - } - if (hmode == HMODE_HALVE1F) { - outln ( " {"); - outln ( " uae_u32 tmp_val;"); - outln ( " spix++;"); - outln ( " tmp_val = dpix_val;"); - out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr); - out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr); - outlnf ( " dpix_val = merge_2pixel%d (dpix_val, tmp_val);", bpp == 0 ? 8 : bpp == 1 ? 16 : 32); - outln ( " spix++;"); - outln ( " }"); - } else if (hmode == HMODE_HALVE2F) { - outln ( " {"); - outln ( " uae_u32 tmp_val, tmp_val2, tmp_val3;"); - outln ( " spix++;"); - outln ( " tmp_val = dpix_val;"); - out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr); - out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr); - outln ( " spix++;"); - outln ( " tmp_val2 = dpix_val;"); - out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr); - out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr); - outln ( " spix++;"); - outln ( " tmp_val3 = dpix_val;"); - out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr); - out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr); - outlnf ( " tmp_val = merge_2pixel%d (tmp_val, tmp_val2);", bpp == 0 ? 8 : bpp == 1 ? 16 : 32); - outlnf ( " tmp_val2 = merge_2pixel%d (tmp_val3, dpix_val);", bpp == 0 ? 8 : bpp == 1 ? 16 : 32); - outlnf ( " dpix_val = merge_2pixel%d (tmp_val, tmp_val2);", bpp == 0 ? 8 : bpp == 1 ? 16 : 32); - outln ( " spix++;"); - outln ( " }"); - } else if (hmode == HMODE_HALVE1) { - outln ( " spix += 2;"); - } else if (hmode == HMODE_HALVE2) { - outln ( " spix += 4;"); - } else { - outln ( " spix++;"); - } -} - -static void put_dpixsprgenlock(int offset, int genlock) -{ - if (!genlock) - return; - if (offset) - outlnf(" genlock_buf[dpix + %d] = get_genlock_transparency(sprcol);", offset); - else - outlnf(" genlock_buf[dpix] = get_genlock_transparency(sprcol);"); -} - -static void put_dpixgenlock(int offset, CMODE_T cmode, int aga, int genlock, const char *var2) -{ - if (!genlock) - return; - outindent(); - if (offset) - outf(" genlock_buf[dpix + %d] = get_genlock_transparency(", offset); - else - outf(" genlock_buf[dpix] = get_genlock_transparency("); - - if (genlock) { - if (cmode == CMODE_EXTRAHB) { - outf("%s", var2 ? var2 : "spix_val & 31"); - } - else if (cmode == CMODE_DUALPF) { - outf("%s", var2 ? var2 : "lookup[spix_val]"); - } - else if (cmode == CMODE_HAM) { - if (aga) { - outf("%s", var2 ? var2 : "(spix_val >> 2) & 63"); - } - else { - outf("%s", var2 ? var2 : "spix_val & 15"); - } - } - else { - outf("%s", var2 ? var2 : "spix_val"); - } - } - outf(");\n"); -} - -static void put_dpix (const char *var) -{ - outlnf(" buf[dpix++] = %s;", var); -} - -static void out_sprite (DEPTH_T bpp, HMODE_T hmode, CMODE_T cmode, int aga, int cnt, int spr, int genlock) -{ - if (aga) { - if (cnt == 1) { - outlnf ( " if (spritepixels[dpix].data) {"); - outlnf ( " sprcol = render_sprites (dpix + 0, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga); - outlnf(" if (sprcol) {"); - outlnf ( " out_val = p_acolors[sprcol];"); - put_dpixsprgenlock(0, genlock); - outlnf(" }"); - outlnf(" }"); - put_dpix("out_val"); - } else if (cnt == 2) { - outlnf ( " {"); - outlnf ( " uae_u32 out_val1 = out_val;"); - outlnf ( " uae_u32 out_val2 = out_val;"); - outlnf(" if (spritepixels[dpix + 0].data) {"); - outlnf ( " sprcol = render_sprites (dpix + 0, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga); - outlnf ( " if (sprcol) {"); - outlnf ( " out_val1 = p_acolors[sprcol];"); - put_dpixsprgenlock(0, genlock); - outlnf(" }"); - outlnf(" }"); - outlnf ( " if (spritepixels[dpix + 1].data) {"); - outlnf ( " sprcol = render_sprites (dpix + 1, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga); - outlnf ( " if (sprcol) {"); - outlnf ( " out_val2 = p_acolors[sprcol];"); - put_dpixsprgenlock(1, genlock); - outlnf(" }"); - outlnf(" }"); - put_dpix("out_val1"); - put_dpix("out_val2"); - outlnf ( " }"); - } else if (cnt == 4) { - outlnf ( " {"); - outlnf ( " uae_u32 out_val1 = out_val;"); - outlnf ( " uae_u32 out_val2 = out_val;"); - outlnf ( " uae_u32 out_val3 = out_val;"); - outlnf ( " uae_u32 out_val4 = out_val;"); - outlnf(" if (spritepixels[dpix + 0].data) {"); - outlnf ( " sprcol = render_sprites (dpix + 0, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga); - outlnf ( " if (sprcol) {"); - outlnf ( " out_val1 = p_acolors[sprcol];"); - put_dpixsprgenlock(0, genlock); - outlnf(" }"); - outlnf(" }"); - outlnf ( " if (spritepixels[dpix + 1].data) {"); - outlnf ( " sprcol = render_sprites (dpix + 1, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga); - outlnf ( " if (sprcol) {"); - outlnf ( " out_val2 = p_acolors[sprcol];"); - put_dpixsprgenlock(1, genlock); - outlnf(" }"); - outlnf(" }"); - outlnf ( " if (spritepixels[dpix + 2].data) {"); - outlnf ( " sprcol = render_sprites (dpix + 2, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga); - outlnf ( " if (sprcol) {"); - outlnf ( " out_val3 = p_acolors[sprcol];"); - put_dpixsprgenlock(2, genlock); - outlnf(" }"); - outlnf(" }"); - outlnf ( " if (spritepixels[dpix + 3].data) {"); - outlnf ( " sprcol = render_sprites (dpix + 3, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga); - outlnf ( " if (sprcol) {"); - outlnf ( " out_val4 = p_acolors[sprcol];"); - put_dpixsprgenlock(3, genlock); - outlnf(" }"); - outlnf(" }"); - put_dpix("out_val1"); - put_dpix("out_val2"); - put_dpix("out_val3"); - put_dpix("out_val4"); - outlnf ( " }"); - } - } else { - outlnf ( " if (spritepixels[dpix].data) {"); - outlnf ( " sprcol = render_sprites (dpix, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga); - put_dpixsprgenlock(0, genlock); - outlnf(" if (sprcol) {"); - outlnf ( " uae_u32 spcol = p_acolors[sprcol];"); - outlnf ( " out_val = spcol;"); - outlnf ( " }"); - outlnf ( " }"); - while (cnt-- > 0) - put_dpix("out_val"); - } -} - - -static void out_linetoscr_mode (DEPTH_T bpp, HMODE_T hmode, int aga, int spr, CMODE_T cmode, int genlock) -{ - int old_indent = set_indent (8); - - if (aga && cmode == CMODE_DUALPF) { - outln ( "int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;"); - outln ( "int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;"); - } else if (cmode == CMODE_DUALPF) - outln ( "int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;"); - - if (bpp == DEPTH_16BPP && hmode != HMODE_DOUBLE && hmode != HMODE_DOUBLE2X && spr == 0) { - outln ( "int rem;"); - outln ( "if (((uintptr_t)&buf[dpix]) & 2) {"); - outln ( " uae_u32 spix_val;"); - outln ( " uae_u32 dpix_val;"); - - out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr); - out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr); - out_linetoscr_do_incspix (bpp, hmode, aga, cmode, spr); - - put_dpix("dpix_val"); - outln ( "}"); - outln ( "if (dpix >= dpix_end)"); - outln ( " return spix;"); - outln ( "rem = (((uintptr_t)&buf[dpix_end]) & 2);"); - outln ( "if (rem)"); - outln ( " dpix_end--;"); - } - - outln ( "while (dpix < dpix_end) {"); - if (spr) - outln ( " uae_u32 sprpix_val;"); - if (spr >= 0) { - outln ( " uae_u32 spix_val;"); - outln ( " uae_u32 dpix_val;"); - } - outln ( " uae_u32 out_val;"); - outln ( ""); - - out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr); - out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr); - out_linetoscr_do_incspix (bpp, hmode, aga, cmode, spr); - - if (spr >= 0) - outln ( " out_val = dpix_val;"); - else - outln ( " out_val = p_acolors[0];"); - - if (hmode == HMODE_DOUBLE) { - put_dpixgenlock(0, cmode, aga, genlock, NULL); - put_dpixgenlock(1, cmode, aga, genlock, NULL); - } else if (hmode == HMODE_DOUBLE2X) { - put_dpixgenlock(0, cmode, aga, genlock, NULL); - put_dpixgenlock(1, cmode, aga, genlock, NULL); - put_dpixgenlock(2, cmode, aga, genlock, NULL); - put_dpixgenlock(3, cmode, aga, genlock, NULL); - } else { - put_dpixgenlock(0, cmode, aga, genlock, NULL); - } - - if (hmode != HMODE_DOUBLE && hmode != HMODE_DOUBLE2X && bpp == DEPTH_16BPP && spr == 0) { - out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr); - out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr); - out_linetoscr_do_incspix (bpp, hmode, aga, cmode, spr); - - if (do_bigendian) - outln ( " out_val = (out_val << 16) | (dpix_val & 0xFFFF);"); - else - outln ( " out_val = (out_val & 0xFFFF) | (dpix_val << 16);"); - } - - if (hmode == HMODE_DOUBLE) { - if (bpp == DEPTH_8BPP) { - outln ( " *((uae_u16 *)&buf[dpix]) = (uae_u16) out_val;"); - outln ( " dpix += 2;"); - } else if (bpp == DEPTH_16BPP) { - if (spr) { - out_sprite(bpp, hmode, cmode, aga, 2, spr, genlock); - } else { - outln ( " *((uae_u32 *)&buf[dpix]) = out_val;"); - outln ( " dpix += 2;"); - } - } else { - if (spr) { - out_sprite(bpp, hmode, cmode, aga, 2, spr, genlock); - } else { - put_dpix("out_val"); - put_dpix("out_val"); - } - } - } else if (hmode == HMODE_DOUBLE2X) { - if (bpp == DEPTH_8BPP) { - outln ( " *((uae_u32 *)&buf[dpix]) = (uae_u32) out_val;"); - outln ( " dpix += 4;"); - } else if (bpp == DEPTH_16BPP) { - if (spr) { - out_sprite(bpp, hmode, cmode, aga, 4, spr, genlock); - } else { - outln ( " *((uae_u32 *)&buf[dpix]) = out_val;"); - outln ( " dpix += 2;"); - outln ( " *((uae_u32 *)&buf[dpix]) = out_val;"); - outln ( " dpix += 2;"); - } - } else { - if (spr) { - out_sprite(bpp, hmode, cmode, aga, 4, spr, genlock); - } else { - put_dpix("out_val"); - put_dpix("out_val"); - put_dpix("out_val"); - put_dpix("out_val"); - } - } - } else { - if (bpp == DEPTH_16BPP) { - if (spr) { - out_sprite(bpp, hmode, cmode, aga, 1, spr, genlock); - } else { - outln ( " *((uae_u32 *)&buf[dpix]) = out_val;"); - outln ( " dpix += 2;"); - } - } else { - if (spr) { - out_sprite(bpp, hmode, cmode, aga, 1, spr, genlock); - } else { - put_dpix("out_val"); - } - } - } - - outln ( "}"); - - - if (bpp == DEPTH_16BPP && hmode != HMODE_DOUBLE && hmode != HMODE_DOUBLE2X && spr == 0) { - outln ( "if (rem) {"); - outln ( " uae_u32 spix_val;"); - outln ( " uae_u32 dpix_val;"); - - out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr); - out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr); - out_linetoscr_do_incspix (bpp, hmode, aga, cmode, spr); - - put_dpix("dpix_val"); - outln ( "}"); - } - - set_indent (old_indent); - - return; -} - -static void out_linetoscr (DEPTH_T bpp, HMODE_T hmode, int aga, int spr, int genlock) -{ - if (aga) - outln ("#ifdef AGA"); - - out_linetoscr_decl (bpp, hmode, aga, spr, genlock); - outln ( "{"); - - outlnf ( " %s *buf = (%s *) xlinebuffer;", get_depth_type_str (bpp), get_depth_type_str (bpp)); - if (genlock) - outlnf(" uae_u8 *genlock_buf = xlinebuffer_genlock;"); - if (spr) - outln ( " uae_u8 sprcol;"); - if (aga && spr >= 0) { - outln(" uae_u8 xor_val = bplxor;"); - outln(" uae_u8 and_val = bpland;"); - } - outln ( ""); - - if (spr >= 0) { - outln ( " if (bplham) {"); - out_linetoscr_mode(bpp, hmode, aga, spr, CMODE_HAM, genlock); - outln ( " } else if (bpldualpf) {"); - out_linetoscr_mode(bpp, hmode, aga, spr, CMODE_DUALPF, genlock); - outln ( " } else if (bplehb) {"); - out_linetoscr_mode(bpp, hmode, aga, spr, CMODE_EXTRAHB, genlock); - outln ( " } else {"); - out_linetoscr_mode(bpp, hmode, aga, spr, CMODE_NORMAL, genlock); - } else { - outln ( " if (1) {"); - out_linetoscr_mode(bpp, hmode, aga, spr, CMODE_NORMAL, genlock); - } - - outln ( " }\n"); - outln ( " return spix;"); - outln ( "}"); - - if (aga) - outln ( "#endif"); - outln ( ""); -} - -int main (int argc, char *argv[]) -{ - DEPTH_T bpp; - int aga, spr; - HMODE_T hmode; - - do_bigendian = 0; - - for (int i = 1; i < argc; i++) { - if (argv[i][0] != '-') - continue; - if (argv[i][1] == 'b' && argv[i][2] == '\0') - do_bigendian = 1; - } - - set_outfile (stdout); - - outln ("/*"); - outln (" * UAE - The portable Amiga emulator."); - outln (" *"); - outln (" * This file was generated by genlinetoscr. Don't edit."); - outln (" */"); - outln (""); - - for (bpp = DEPTH_16BPP; bpp <= DEPTH_MAX; bpp++) { - for (aga = 0; aga <= 1 ; aga++) { - if (aga && bpp == DEPTH_8BPP) - continue; - for (spr = -1; spr <= 1; spr++) { - if (!aga && spr < 0) - continue; - for (hmode = HMODE_NORMAL; hmode <= HMODE_MAX; hmode++) { - out_linetoscr(bpp, hmode, aga, spr, 0); - if (spr >= 0) - out_linetoscr(bpp, hmode, aga, spr, 1); - } - } - } - } - return 0; -} diff --git a/src/gfxboard.cpp b/src/gfxboard.cpp index 1da4877b..2d72f414 100644 --- a/src/gfxboard.cpp +++ b/src/gfxboard.cpp @@ -7,7 +7,6 @@ * */ -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" diff --git a/src/gfxutil.cpp b/src/gfxutil.cpp index 65e6e8a1..b4c2ec1c 100644 --- a/src/gfxutil.cpp +++ b/src/gfxutil.cpp @@ -6,7 +6,8 @@ * (c) 1996 Bernd Schmidt, Ed Hanway, Samuel Devulder */ -#include "sysconfig.h" +#include + #include "sysdeps.h" #include "options.h" #include "custom.h" diff --git a/src/hardfile.cpp b/src/hardfile.cpp index f167eb43..9480be39 100644 --- a/src/hardfile.cpp +++ b/src/hardfile.cpp @@ -7,17 +7,14 @@ * 2002 Toni Wilen (scsi emulation, 64-bit support) */ -#include "sysconfig.h" +#include +#include + #include "sysdeps.h" #include "threaddep/thread.h" #include "options.h" -#include "memory.h" -#include "custom.h" -#include "newcpu.h" -#include "disk.h" #include "autoconf.h" -#include "traps.h" #include "filesys.h" #include "execlib.h" #include "native2amiga.h" @@ -26,8 +23,6 @@ #include "scsi.h" #include "gayle.h" #include "execio.h" -#include "zfile.h" -#include "ide.h" #define HDF_SUPPORT_NSD 1 #define HDF_SUPPORT_TD64 1 diff --git a/src/ide.cpp b/src/ide.cpp index 5eb94111..9bc0c09c 100644 --- a/src/ide.cpp +++ b/src/ide.cpp @@ -7,17 +7,15 @@ */ #define IDE_LOG 0 +#include +#include -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" -#include "blkdev.h" #include "filesys.h" #include "gui.h" #include "uae.h" -#include "memory.h" -#include "newcpu.h" #include "threaddep/thread.h" #include "savestate.h" #include "scsi.h" diff --git a/src/blit.h b/src/include/blit.h similarity index 100% rename from src/blit.h rename to src/include/blit.h diff --git a/src/blitfunc.h b/src/include/blitfunc.h similarity index 100% rename from src/blitfunc.h rename to src/include/blitfunc.h diff --git a/src/cputbl.h b/src/include/cputbl.h similarity index 100% rename from src/cputbl.h rename to src/include/cputbl.h diff --git a/src/include/genblitter.h b/src/include/genblitter.h deleted file mode 100644 index cb8116da..00000000 --- a/src/include/genblitter.h +++ /dev/null @@ -1,20 +0,0 @@ - /* - * UAE - The Un*x Amiga Emulator - * - * Optimized blitter minterm function generator - * - * Copyright 1995,1996 Bernd Schmidt - * Copyright 1996 Alessandro Bissacco - */ - -#ifndef UAE_GENBLITTER_H -#define UAE_GENBLITTER_H - -struct blitop { - const char *s; - int used; -}; - -extern struct blitop blitops[256]; - -#endif /* UAE_GENBLITTER_H */ diff --git a/src/include/mackbd.h b/src/include/mackbd.h deleted file mode 100644 index ce37e6bb..00000000 --- a/src/include/mackbd.h +++ /dev/null @@ -1,114 +0,0 @@ - /* - * UAE - The Un*x Amiga Emulator - * - * Mac keycodes - * - * (c) 1996 Ernesto Corvi - */ - -#ifndef UAE_MACKBD_H -#define UAE_MACKBD_H - -#define kUpArrowKeyMap 0x7E /* key map offset for up arrow */ -#define kDownArrowKeyMap 0x7D /* key map offset for down arrow */ -#define kRightArrowKeyMap 0x7C /* key map offset for right arrow */ -#define kLeftArrowKeyMap 0x7B /* key map offset for left arrow */ - -#define kBackSpaceKeyMap 0x33 -#define kReturnKeyMap 0x24 -#define kEscapeKeyMap 0x35 -#define kLBracketKeyMap 0x21 -#define kRBracketKeyMap 0x1E -#define kCommaKeyMap 0x2B -#define kSlashKeyMap 0x2C -#define kSemiColonKeyMap 0x29 -#define kMinusKeyMap 0x1B -#define kEqualKeyMap 0x18 -#define kQuoteKeyMap 0x27 - -#define k0KeyMap 0x1D -#define k1KeyMap 0x12 -#define k2KeyMap 0x13 -#define k3KeyMap 0x14 -#define k4KeyMap 0x15 -#define k5KeyMap 0x17 -#define k6KeyMap 0x16 -#define k7KeyMap 0x1A -#define k8KeyMap 0x1C -#define k9KeyMap 0x19 - -#define kAKeyMap 0x00 -#define kBKeyMap 0x0B -#define kCKeyMap 0x08 -#define kDKeyMap 0x02 -#define kEKeyMap 0x0E -#define kFKeyMap 0x03 -#define kGKeyMap 0x05 -#define kHKeyMap 0x04 -#define kIKeyMap 0x22 -#define kJKeyMap 0x26 -#define kKKeyMap 0x28 -#define kLKeyMap 0x25 -#define kMKeyMap 0x2E -#define kNKeyMap 0x2D -#define kOKeyMap 0x1F -#define kPKeyMap 0x23 -#define kQKeyMap 0x0C -#define kRKeyMap 0x0F -#define kSKeyMap 0x01 -#define kTKeyMap 0x11 -#define kUKeyMap 0x20 -#define kVKeyMap 0x09 -#define kWKeyMap 0x0D -#define kXKeyMap 0x07 -#define kYKeyMap 0x10 -#define kZKeyMap 0x06 -#define kPeriodKeyMap 0x2F -#define kCommandKeyMap 0x37 -#define kSpaceBarMap 0x31 -#define kTabKeyMap 0x30 -#define kControlKeyMap 0x3B -#define kOptionKeyMap 0x3A -#define kCapsLockKeyMap 0x39 -#define kShiftKeyMap 0x38 -#define kPgUpKeyMap 0x74 -#define kPgDnKeyMap 0x79 -#define kBackSlash 0x2A - - -#define kF1KeyMap 0x7A -#define kF2KeyMap 0x78 -#define kF3KeyMap 0x63 -#define kF4KeyMap 0x76 -#define kF5KeyMap 0x60 -#define kF6KeyMap 0x61 -#define kF7KeyMap 0x62 -#define kF8KeyMap 0x64 -#define kF9KeyMap 0x65 -#define kF10KeyMap 0x6D -#define kF11KeyMap 0x67 -#define kF12KeyMap 0x6F - -#define kShiftRawKey 0x3F -#define kControlRawKey 0x3C -#define kOptionRawKey 0x3D -#define kCapsRawKey 0x3E -#define kCommandRawKey 0x30 -#define kUpRawKey 0x79 -#define kDownRawKey 0x7A -#define kLeftRawKey 0x7C -#define kRightRawKey 0x7B -#define kSpaceRawKey 0x36 - -#define kKP0KeyMap 0x52 -#define kKP1KeyMap 0x53 -#define kKP2KeyMap 0x54 -#define kKP3KeyMap 0x55 -#define kKP4KeyMap 0x56 -#define kKP5KeyMap 0x57 -#define kKP6KeyMap 0x58 -#define kKP7KeyMap 0x59 -#define kKP8KeyMap 0x5B -#define kKP9KeyMap 0x5C - -#endif /* UAE_MACKBD_H */ diff --git a/src/include/uae/api.h b/src/include/uae/api.h deleted file mode 100644 index 6ef51ca9..00000000 --- a/src/include/uae/api.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Helpers used to export UAE functions for use with other modules - * Copyright (C) 2014 Frode Solheim - * - * Licensed under the terms of the GNU General Public License version 2. - * See the file 'COPYING' for full license text. - */ - -#ifndef UAE_API_H -#define UAE_API_H - -/* This file is intended to be included by external libraries as well, - * so don't pull in too much UAE-specific stuff. */ - -#include "uae/attributes.h" - -/* Handy define so we can disable C++ name mangling without considering - * whether the source language is C or C++. */ - -#ifdef __cplusplus -#define UAE_EXTERN_C extern "C" -#else -#define UAE_EXTERN_C -#endif - -/* UAE_EXPORT / UAE_IMPORT are mainly intended as helpers for UAEAPI - * defined below. */ - -#ifdef _WIN32 -#define UAE_EXPORT __declspec(dllexport) -#define UAE_IMPORT __declspec(dllimport) -#else -#define UAE_EXPORT __attribute__((visibility("default"))) -#define UAE_IMPORT -#endif - -/* UAEAPI marks a function for export across library boundaries. You'll - * likely want to use this together with UAECALL. */ - -#ifdef UAE -#define UAEAPI UAE_EXTERN_C UAE_EXPORT -#else -#define UAEAPI UAE_EXTERN_C UAE_IMPORT -#endif - -/* WinUAE (or external libs) might be compiled with fastcall by default, - * so we force all external functions to use cdecl calling convention. */ - -#define UAECALL uae_cdecl - -/* Helpers to make it easy to import functions from plugins. */ - -#ifdef UAE - -#define UAE_DECLARE_IMPORT_FUNCTION(return_type, function_name, ...) \ - typedef return_type (UAECALL * function_name ## _function)(__VA_ARGS__); \ - extern function_name ## _function function_name; - -#define UAE_IMPORT_FUNCTION(handle, function_name) \ -{ \ - function_name = (function_name ## _function) uae_dlsym( \ - handle, #function_name); \ - if (function_name) { \ - write_log("Imported " #function_name "\n"); \ - } else { \ - write_log("WARNING: Could not import " #function_name "\n"); \ - } \ -} - -#define UAE_DECLARE_EXPORT_FUNCTION(return_type, function_name, ...) \ - typedef return_type (UAECALL * function_name ## _function)(__VA_ARGS__); \ - return_type UAECALL function_name(__VA_ARGS__); - -#define UAE_EXPORT_FUNCTION(handle, function_name) \ -{ \ - void *ptr = uae_dlsym(handle, #function_name); \ - if (ptr) { \ - *((function_name ## _function *) ptr) = function_name; \ - write_log("Exported " #function_name "\n"); \ - } else { \ - write_log("WARNING: Could not export " #function_name "\n"); \ - } \ -} - -#else - -#define UAE_DECLARE_IMPORT_FUNCTION(return_type, function_name, ...) \ - return_type UAECALL function_name(__VA_ARGS__); - -#define UAE_DECLARE_EXPORT_FUNCTION(return_type, function_name, ...) \ - typedef return_type (UAECALL * function_name ## _function)(__VA_ARGS__); \ - extern function_name ## _function function_name; - -#endif - -/** - * Used in both UAE and plugin code to define storage for the function - * imported from the other module. - */ -#define UAE_DEFINE_IMPORT_FUNCTION(function_name) \ - function_name ## _function function_name = NULL; - -#endif /* UAE_API_H */ \ No newline at end of file diff --git a/src/include/uae/attributes.h b/src/include/uae/attributes.h deleted file mode 100644 index c53e0e1f..00000000 --- a/src/include/uae/attributes.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Defines useful functions and variable attributes for UAE - * Copyright (C) 2014 Frode Solheim - * - * Licensed under the terms of the GNU General Public License version 2. - * See the file 'COPYING' for full license text. - */ - -#ifndef UAE_ATTRIBUTES_H -#define UAE_ATTRIBUTES_H - -/* This file is intended to be included by external libraries as well, - * so don't pull in too much UAE-specific stuff. */ - -#ifdef _WIN32_ -#define uae_cdecl __cdecl -#elif defined(__GNUC__) && defined(__i386__) -#define uae_cdecl __attribute__((cdecl)) -#else -#define uae_cdecl -#endif - -/* This attribute allows (some) compiles to emit warnings when incorrect - * arguments are used with the format string. */ - -#ifdef __GNUC__ -#define UAE_PRINTF_FORMAT(f, a) __attribute__((format(printf, f, a))) -#else -#define UAE_PRINTF_FORMAT(f, a) -#endif - -#define UAE_WPRINTF_FORMAT(f, a) - -#endif /* UAE_ATTRIBUTES_H */ diff --git a/src/include/uae/cdrom.h b/src/include/uae/cdrom.h deleted file mode 100644 index ca813568..00000000 --- a/src/include/uae/cdrom.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef UAE_CDROM_H -#define UAE_CDROM_H - -#include "uae/types.h" - -void encode_l2(uae_u8 *p, int address); - -#endif /* UAE_CDROM_H */ diff --git a/src/include/uae/io.h b/src/include/uae/io.h deleted file mode 100644 index 34be1838..00000000 --- a/src/include/uae/io.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef UAE_IO_H -#define UAE_IO_H - -#include "uae/types.h" -#include - -#ifdef WINUAE -#define uae_tfopen _tfopen -#else -FILE *uae_tfopen(const TCHAR *path, const TCHAR *mode); -#endif - -#endif /* UAE_IO_H */ diff --git a/src/include/uae/vm.h b/src/include/uae/vm.h deleted file mode 100644 index 662fc6ea..00000000 --- a/src/include/uae/vm.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Multi-platform virtual memory functions for UAE. - * Copyright (C) 2015 Frode Solheim - * - * Licensed under the terms of the GNU General Public License version 2. - * See the file 'COPYING' for full license text. - */ - -#ifndef UAE_VM_H -#define UAE_VM_H - -#include "uae/types.h" - -#define UAE_VM_WRITE 2 -#define UAE_VM_EXECUTE 4 - -#define UAE_VM_32BIT (1 << 8) -#define UAE_VM_WRITE_WATCH (1 << 9) -#define UAE_VM_ALLOC_FAILED NULL - -/* Even though it looks like you can OR together vm protection values, - * do not do this. Not all combinations are supported (on Windows), and only - * a few combinations are implemented. Only use the following predefined - * constants to be safe. */ - -#define UAE_VM_NO_ACCESS 0 -#define UAE_VM_READ 1 -#define UAE_VM_READ_WRITE (UAE_VM_READ | UAE_VM_WRITE) -#define UAE_VM_READ_EXECUTE (UAE_VM_READ | UAE_VM_EXECUTE) -#define UAE_VM_READ_WRITE_EXECUTE (UAE_VM_READ | UAE_VM_WRITE | UAE_VM_EXECUTE) - -#endif /* UAE_VM_H */ diff --git a/src/inputdevice.cpp b/src/inputdevice.cpp index 49cc16be..dd30c5f1 100644 --- a/src/inputdevice.cpp +++ b/src/inputdevice.cpp @@ -15,8 +15,11 @@ * - fully backward compatible with old joystick/mouse configuration * */ +#include +#include +#include +#include -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" @@ -33,11 +36,7 @@ #include "ar.h" #include "gui.h" #include "savestate.h" -#include "zfile.h" -#include "cia.h" #include "autoconf.h" -#include "statusline.h" -#include "native2amiga_api.h" #include "sounddep/sound.h" #include "disk.h" #include "amiberry_gfx.h" diff --git a/src/jit/codegen_arm.cpp b/src/jit/codegen_arm.cpp.in similarity index 100% rename from src/jit/codegen_arm.cpp rename to src/jit/codegen_arm.cpp.in diff --git a/src/jit/compemu_fpp.cpp b/src/jit/compemu_fpp.cpp index 505a9283..e12d4863 100644 --- a/src/jit/compemu_fpp.cpp +++ b/src/jit/compemu_fpp.cpp @@ -8,14 +8,12 @@ * Modified 2005 Peter Keunecke */ -#include +#include -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" #include "memory.h" -#include "custom.h" #include "newcpu.h" #include "compemu.h" #include "flags_arm.h" diff --git a/src/jit/compemu_midfunc_arm.cpp b/src/jit/compemu_midfunc_arm.cpp.in similarity index 100% rename from src/jit/compemu_midfunc_arm.cpp rename to src/jit/compemu_midfunc_arm.cpp.in diff --git a/src/jit/compemu_midfunc_arm2.cpp b/src/jit/compemu_midfunc_arm2.cpp.in similarity index 100% rename from src/jit/compemu_midfunc_arm2.cpp rename to src/jit/compemu_midfunc_arm2.cpp.in diff --git a/src/jit/compemu_support.cpp b/src/jit/compemu_support.cpp index 69f2daa0..967c3f0b 100644 --- a/src/jit/compemu_support.cpp +++ b/src/jit/compemu_support.cpp @@ -28,10 +28,14 @@ * along with ARAnyM; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include +#include +#include +#include +#include +#include +#include -#include - -#include "sysconfig.h" #include "sysdeps.h" #if defined(JIT) @@ -705,7 +709,7 @@ STATIC_INLINE void reset_data_buffer(void) STATIC_INLINE void clobber_flags(void); #if defined(CPU_arm) -#include "codegen_arm.cpp" +#include "codegen_arm.cpp.in" #endif #if defined(CPU_i386) || defined(CPU_x86_64) #include "codegen_x86.cpp" @@ -1294,8 +1298,8 @@ static void fflags_into_flags_internal(void) #endif #if defined(CPU_arm) -#include "compemu_midfunc_arm.cpp" -#include "compemu_midfunc_arm2.cpp" +#include "compemu_midfunc_arm.cpp.in" +#include "compemu_midfunc_arm2.cpp.in" #endif #if defined(CPU_i386) || defined(CPU_x86_64) diff --git a/src/jit/gencomp_arm.cpp b/src/jit/gencomp_arm.cpp deleted file mode 100644 index 8a6e785c..00000000 --- a/src/jit/gencomp_arm.cpp +++ /dev/null @@ -1,3492 +0,0 @@ -/* - * compiler/gencomp_arm2.c - MC680x0 compilation generator (ARM Adaption JIT v1 & JIT v2) - * - * Based on work Copyright 1995, 1996 Bernd Schmidt - * Changes for UAE-JIT Copyright 2000 Bernd Meyer - * - * Adaptation for ARAnyM/ARM, copyright 2001-2015 - * Milan Jurik, Jens Heitmann - * - * Basilisk II (C) 1997-2005 Christian Bauer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Notes - * ===== - * - * Advantages of JIT v2 - * - Processor independent style - * - Reduced overhead - * - Easier to understand / read - * - Easier to optimize - * - More precise flag handling - * - Better optimization for different CPU version ARM, ARMv6 etc.. - * - * Disadvantages of JIT v2 - * - Less generated - * - Requires more code implementation by hand (MidFunc) - * - MIDFUNCS are more CPU minded (closer to raw) - * - Separate code for each instruction (but this could be also an advantage, because you can concentrate on it) - * - * Additional note: - * - current using jnf_xxx calls for non-flag operations and - * jff_xxx for flag operations - * - * Still todo: - * - Optimize genamode, genastore, gen_writeXXX, gen_readXXX, genmovemXXX - * - */ - -#include "sysconfig.h" -#include "sysdeps.h" -#include - -#include "readcpu.h" - -#include -#include -#include -#include -#include -#undef abort - -#define USE_JIT2 - -//#define DISABLE_I_OR_AND_EOR -//#define DISABLE_I_ORSR_EORSR_ANDSR -//#define DISABLE_I_SUB -//#define DISABLE_I_SUBA -//#define DISABLE_I_SUBX -//#define DISABLE_I_ADD -//#define DISABLE_I_ADDA -//#define DISABLE_I_ADDX -//#define DISABLE_I_NEG -//#define DISABLE_I_NEGX -//#define DISABLE_I_CLR -//#define DISABLE_I_NOT -//#define DISABLE_I_TST -//#define DISABLE_I_BCHG_BCLR_BSET_BTST -//#define DISABLE_I_CMPM_CMP -//#define DISABLE_I_CMPA -//#define DISABLE_I_MOVE -//#define DISABLE_I_MOVEA -//#define DISABLE_I_SWAP -//#define DISABLE_I_EXG -//#define DISABLE_I_EXT -//#define DISABLE_I_MVMEL -//#define DISABLE_I_MVMLE -//#define DISABLE_I_RTD -//#define DISABLE_I_LINK -//#define DISABLE_I_UNLK -//#define DISABLE_I_RTS -//#define DISABLE_I_JSR -//#define DISABLE_I_JMP -//#define DISABLE_I_BSR -//#define DISABLE_I_BCC -//#define DISABLE_I_LEA -//#define DISABLE_I_PEA -//#define DISABLE_I_DBCC -//#define DISABLE_I_SCC -//#define DISABLE_I_MULU -//#define DISABLE_I_MULS -//#define DISABLE_I_ASR -//#define DISABLE_I_ASL -//#define DISABLE_I_LSR -//#define DISABLE_I_LSL -//#define DISABLE_I_ROL -//#define DISABLE_I_ROR -//#define DISABLE_I_ROXL -//#define DISABLE_I_ROXR -//#define DISABLE_I_ASRW -//#define DISABLE_I_ASLW -//#define DISABLE_I_LSRW -//#define DISABLE_I_LSLW -//#define DISABLE_I_ROLW -//#define DISABLE_I_RORW -#define DISABLE_I_ROXLW -#define DISABLE_I_ROXRW -//#define DISABLE_I_MULL -//#define DISABLE_I_FPP -//#define DISABLE_I_FBCC -//#define DISABLE_I_FSCC -//#define DISABLE_I_MOVE16 - -//#define DISABLE_I_DIVU -//#define DISABLE_I_DIVS -//#define DISABLE_I_DIVL - - -#define RETURN "return 0;" -#define RETTYPE "uae_u32" -#define NEXT_CPU_LEVEL 5 - -#define BOOL_TYPE "int" -#define failure global_failure=1 -#define FAILURE global_failure=1 -#define isjump global_isjump=1 -#define is_const_jump global_iscjump=1; -#define isaddx global_isaddx=1 -#define uses_cmov global_cmov=1 -#define mayfail global_mayfail=1 -#define uses_fpu global_fpu=1 - -int hack_opcode; - -static int global_failure; -static int global_isjump; -static int global_iscjump; -static int global_isaddx; -static int global_cmov; -static int long_opcode; -static int global_mayfail; -static int global_fpu; - -static char endstr[1000]; -static char lines[100000]; -static int comp_index = 0; - -#include "flags_arm.h" - -static int cond_codes[] = { - NATIVE_CC_AL, -1, - NATIVE_CC_HI, NATIVE_CC_LS, - NATIVE_CC_CC, NATIVE_CC_CS, - NATIVE_CC_NE, NATIVE_CC_EQ, - NATIVE_CC_VC, NATIVE_CC_VS, - NATIVE_CC_PL, NATIVE_CC_MI, - NATIVE_CC_GE, NATIVE_CC_LT, - NATIVE_CC_GT, NATIVE_CC_LE -}; - -static void comprintf(const char* format, ...) -{ - va_list args; - - va_start(args, format); - comp_index += vsprintf(lines + comp_index, format, args); -} - -static void com_discard(void) -{ - comp_index = 0; -} - -static void com_flush(void) -{ - int i; - for (i = 0; i < comp_index; i++) - putchar(lines[i]); - com_discard(); -} - - -static FILE *headerfile; -static FILE *stblfile; - -static int using_prefetch; -static int using_exception_3; -static int cpu_level; -static int noflags; - -/* For the current opcode, the next lower level that will have different code. - * Initialized to -1 for each opcode. If it remains unchanged, indicates we - * are done with that opcode. */ -static int next_cpu_level; - -static int *opcode_map; -static int *opcode_next_clev; -static int *opcode_last_postfix; -static unsigned long *counts; - -static void read_counts(void) -{ - FILE *file; - unsigned long opcode, count = 0, total; - char name[20]; - int nr = 0; - memset(counts, 0, 65536 * sizeof *counts); - - file = fopen("frequent.68k", "r"); - if (file) - { - fscanf(file, "Total: %lu\n", &total); - while (fscanf(file, "%lx: %lu %s\n", &opcode, &count, name) == 3) - { - opcode_next_clev[nr] = NEXT_CPU_LEVEL; - opcode_last_postfix[nr] = -1; - opcode_map[nr++] = opcode; - counts[opcode] = count; - } - fclose(file); - } - if (nr == nr_cpuop_funcs) - return; - for (opcode = 0; opcode < 0x10000; opcode++) - { - if (table68k[opcode].handler == -1 && table68k[opcode].mnemo != i_ILLG - && counts[opcode] == 0) - { - opcode_next_clev[nr] = NEXT_CPU_LEVEL; - opcode_last_postfix[nr] = -1; - opcode_map[nr++] = opcode; - counts[opcode] = count; - } - } - if (nr != nr_cpuop_funcs) - abort(); -} - -static int n_braces = 0; -static int insn_n_cycles; - -static void start_brace(void) -{ - n_braces++; - comprintf("{"); -} - -static void close_brace(void) -{ - assert(n_braces > 0); - n_braces--; - comprintf("}"); -} - -static void finish_braces(void) -{ - while (n_braces > 0) - close_brace(); -} - -static inline void gen_update_next_handler(void) -{ - return; /* Can anything clever be done here? */ -} - -static void gen_writebyte(const char* address, const char* source) -{ - comprintf("\twritebyte(%s,%s);\n", address, source); -} - -static void gen_writeword(const char* address, const char* source) -{ - comprintf("\twriteword(%s,%s);\n", address, source); -} - -static void gen_writelong(const char* address, const char* source) -{ - comprintf("\twritelong(%s,%s);\n", address, source); -} - -static void gen_readbyte(const char* address, const char* dest) -{ - comprintf("\treadbyte(%s,%s);\n", address, dest); -} - -static void gen_readword(const char* address, const char* dest) -{ - comprintf("\treadword(%s,%s);\n", address, dest); -} - -static void gen_readlong(const char* address, const char* dest) -{ - comprintf("\treadlong(%s,%s);\n", address, dest); -} - - -static const char *gen_nextilong(void) -{ - static char buffer[80]; - - sprintf(buffer, "comp_get_ilong((m68k_pc_offset+=4)-4)"); - insn_n_cycles += 4; - - long_opcode = 1; - return buffer; -} - -static const char *gen_nextiword(void) -{ - static char buffer[80]; - - sprintf(buffer, "comp_get_iword((m68k_pc_offset+=2)-2)"); - insn_n_cycles += 2; - - long_opcode = 1; - return buffer; -} - -static const char *gen_nextibyte(void) -{ - static char buffer[80]; - - sprintf(buffer, "comp_get_ibyte((m68k_pc_offset+=2)-2)"); - insn_n_cycles += 2; - - long_opcode = 1; - return buffer; -} - - -static void swap_opcode (void) -{ - /* no-op */ -} - -static void sync_m68k_pc(void) -{ - comprintf("\t if (m68k_pc_offset>SYNC_PC_OFFSET) sync_m68k_pc();\n"); -} - - -/* 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 */ -static void genamode(amodes mode, const char *reg, wordsizes size, const char *name, int getv, int movem) -{ - switch (mode) - { - case Dreg: /* Do we need to check dodgy here? */ - if (movem) - abort(); - if (getv == 1 || getv == 2) { - /* We generate the variable even for getv==2, so we can use - it as a destination for MOVE */ - comprintf("\tint %s=%s;\n", name, reg); - } - return; - - case Areg: - if (movem) - abort(); - if (getv == 1 || getv == 2) { - /* see above */ - comprintf("\tint %s=dodgy?scratchie++:%s+8;\n", name, reg); - if (getv == 1) { - comprintf("\tif (dodgy) \n"); - comprintf("\t\tmov_l_rr(%s,%s+8);\n", name, reg); - } - } - return; - - case Aind: - comprintf("\tint %sa=dodgy?scratchie++:%s+8;\n", name, reg); - comprintf("\tif (dodgy) \n"); - comprintf("\t\tmov_l_rr(%sa,%s+8);\n", name, reg); - break; - case Aipi: - comprintf("\tint %sa=scratchie++;\n", name, reg); - comprintf("\tmov_l_rr(%sa,%s+8);\n", name, reg); - break; - case Apdi: - switch (size) - { - case sz_byte: - if (movem) { - comprintf("\tint %sa=dodgy?scratchie++:%s+8;\n", name, reg); - comprintf("\tif (dodgy) \n"); - comprintf("\tmov_l_rr(%sa,8+%s);\n", name, reg); - } - else { - start_brace(); - comprintf("\tint %sa=dodgy?scratchie++:%s+8;\n", name, reg); - comprintf("\tarm_SUB_l_ri8(%s+8,areg_byteinc[%s]);\n", reg, reg); - comprintf("\tif (dodgy) \n"); - comprintf("\tmov_l_rr(%sa,8+%s);\n", name, reg); - } - break; - case sz_word: - if (movem) { - comprintf("\tint %sa=dodgy?scratchie++:%s+8;\n", name, reg); - comprintf("\tif (dodgy) \n"); - comprintf("\tmov_l_rr(%sa,8+%s);\n", name, reg); - } - else { - start_brace(); - comprintf("\tint %sa=dodgy?scratchie++:%s+8;\n", name, reg); - comprintf("\tarm_SUB_l_ri8(%s+8,2);\n", reg); - comprintf("\tif (dodgy) \n"); - comprintf("\tmov_l_rr(%sa,8+%s);\n", name, reg); - } - break; - case sz_long: - if (movem) { - comprintf("\tint %sa=dodgy?scratchie++:%s+8;\n", name, reg); - comprintf("\tif (dodgy) \n"); - comprintf("\tmov_l_rr(%sa,8+%s);\n", name, reg); - } - else { - start_brace(); - comprintf("\tint %sa=dodgy?scratchie++:%s+8;\n", name, reg); - comprintf("\tarm_SUB_l_ri8(%s+8,4);\n", reg); - comprintf("\tif (dodgy) \n"); - comprintf("\tmov_l_rr(%sa,8+%s);\n", name, reg); - } - break; - default: - abort(); - } - break; - case Ad16: - comprintf("\tint %sa=scratchie++;\n", name); - comprintf("\tlea_l_brr(%sa,8+%s,(uae_s32)(uae_s16)%s);\n", name, reg, gen_nextiword()); - break; - case Ad8r: - comprintf("\tint %sa=scratchie++;\n", name); - comprintf("\tcalc_disp_ea_020(%s+8,%s,%sa);\n", reg, gen_nextiword(), name); - break; - - case PC16: - comprintf("\tint %sa=scratchie++;\n", name); - comprintf("\tuae_u32 address=start_pc+((char *)comp_pc_p-(char *)start_pc_p)+m68k_pc_offset;\n"); - comprintf("\tuae_s32 PC16off = (uae_s32)(uae_s16)%s;\n", gen_nextiword()); - comprintf("\tmov_l_ri(%sa,address+PC16off);\n", name); - break; - - case PC8r: - comprintf("\tint pctmp=scratchie++;\n"); - comprintf("\tint %sa=scratchie++;\n", name); - comprintf("\tuae_u32 address=start_pc+((char *)comp_pc_p-(char *)start_pc_p)+m68k_pc_offset;\n"); - start_brace(); - comprintf("\tmov_l_ri(pctmp,address);\n"); - - comprintf("\tcalc_disp_ea_020(pctmp,%s,%sa);\n", gen_nextiword(), name); - break; - case absw: - comprintf("\tint %sa = scratchie++;\n", name); - comprintf("\tmov_l_ri(%sa,(uae_s32)(uae_s16)%s);\n", name, gen_nextiword()); - break; - case absl: - comprintf("\tint %sa = scratchie++;\n", name); - comprintf("\tmov_l_ri(%sa,%s); /* absl */\n", name, gen_nextilong()); - break; - case imm: - if (getv != 1) - abort(); - switch (size) - { - case sz_byte: - comprintf("\tint %s = scratchie++;\n", name); - comprintf("\tmov_l_ri(%s,(uae_s32)(uae_s8)%s);\n", name, gen_nextibyte()); - break; - case sz_word: - comprintf("\tint %s = scratchie++;\n", name); - comprintf("\tmov_l_ri(%s,(uae_s32)(uae_s16)%s);\n", name, gen_nextiword()); - break; - case sz_long: - comprintf("\tint %s = scratchie++;\n", name); - comprintf("\tmov_l_ri(%s,%s);\n", name, gen_nextilong()); - break; - default: - abort(); - } - return; - case imm0: - if (getv != 1) - abort(); - comprintf("\tint %s = scratchie++;\n", name); - comprintf("\tmov_l_ri(%s,(uae_s32)(uae_s8)%s);\n", name, gen_nextibyte()); - return; - case imm1: - if (getv != 1) - abort(); - comprintf("\tint %s = scratchie++;\n", name); - comprintf("\tmov_l_ri(%s,(uae_s32)(uae_s16)%s);\n", name, gen_nextiword()); - return; - case imm2: - if (getv != 1) - abort(); - comprintf("\tint %s = scratchie++;\n", name); - comprintf("\tmov_l_ri(%s,%s);\n", name, gen_nextilong()); - return; - case immi: - if (getv != 1) - abort(); - comprintf("\tint %s = scratchie++;\n", name); - comprintf("\tmov_l_ri(%s,%s);\n", name, reg); - return; - default: - abort(); - } - - /* We get here for all non-reg non-immediate addressing modes to - * actually fetch the value. */ - if (getv == 1) - { - char astring[80]; - sprintf(astring, "%sa", name); - switch (size) - { - case sz_byte: - insn_n_cycles += 2; - break; - case sz_word: - insn_n_cycles += 2; - break; - case sz_long: - insn_n_cycles += 4; - break; - default: - abort(); - } - comprintf("\tint %s=scratchie++;\n", name); - switch (size) - { - case sz_byte: - gen_readbyte(astring, name); - break; - case sz_word: - gen_readword(astring, name); - break; - case sz_long: - gen_readlong(astring, name); - break; - default: - abort(); - } - } - - /* We now might have to fix up the register for pre-dec or post-inc - * addressing modes. */ - if (!movem) { - switch (mode) - { - case Aipi: - switch (size) - { - case sz_byte: - comprintf("\tarm_ADD_l_ri8(%s+8,areg_byteinc[%s]);\n", reg, reg); - break; - case sz_word: - comprintf("\tarm_ADD_l_ri8(%s+8,2);\n", reg); - break; - case sz_long: - comprintf("\tarm_ADD_l_ri8(%s+8,4);\n", reg); - break; - default: - abort(); - } - break; - case Apdi: - break; - default: - break; - } - } -} - -/* 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 */ -static void genamode_new(amodes mode, const char *reg, wordsizes size, const char *name, int getv, int movem) -{ - switch (mode) - { - case Dreg: - if (movem) - abort(); - if (getv == 1 || getv == 2) { - /* We generate the variable even for getv==2, so we can use - it as a destination for MOVE */ - if (name != "") { - comprintf("\tint %s=%s;\n", name, reg); - } - } - return; - - case Areg: - if (movem) - abort(); - if (getv == 1 || getv == 2) { - /* see above */ - comprintf("\tint %s=%s+8;\n", name, reg); - } - return; - - case Aind: - comprintf("\tint %sa=%s+8;\n", name, reg); - break; - case Aipi: - comprintf("\tint %sa=%s+8;\n", name, reg); - break; - case Apdi: - switch (size) - { - case sz_byte: - if (movem) { - comprintf("\tint %sa=%s+8;\n", name, reg); - } - else { - comprintf("\tint %sa=%s+8;\n", name, reg); - comprintf("\tarm_SUB_l_ri8(%s+8,areg_byteinc[%s]);\n", reg, reg); - } - break; - case sz_word: - if (movem) { - comprintf("\tint %sa=%s+8;\n", name, reg); - } - else { - comprintf("\tint %sa=%s+8;\n", name, reg); - comprintf("\tarm_SUB_l_ri8(%s+8,2);\n", reg); - } - break; - case sz_long: - if (movem) { - comprintf("\tint %sa=%s+8;\n", name, reg); - } - else { - comprintf("\tint %sa=%s+8;\n", name, reg); - comprintf("\tarm_SUB_l_ri8(%s+8,4);\n", reg); - } - break; - default: - abort(); - } - break; - case Ad16: - comprintf("\tint %sa=scratchie++;\n", name); - comprintf("\tlea_l_brr(%sa,8+%s,(uae_s32)(uae_s16)%s);\n", name, reg, gen_nextiword()); - break; - case Ad8r: - comprintf("\tint %sa=scratchie++;\n", name); - comprintf("\tcalc_disp_ea_020(%s+8,%s,%sa);\n", reg, gen_nextiword(), name); - break; - - case PC16: - comprintf("\tint %sa=scratchie++;\n", name); - comprintf("\tuae_u32 address=start_pc+((char *)comp_pc_p-(char *)start_pc_p)+m68k_pc_offset;\n"); - comprintf("\tuae_s32 PC16off = (uae_s32)(uae_s16)%s;\n", gen_nextiword()); - comprintf("\tmov_l_ri(%sa,address+PC16off);\n", name); - break; - - case PC8r: - comprintf("\tint pctmp=scratchie++;\n"); - comprintf("\tint %sa=scratchie++;\n", name); - comprintf("\tuae_u32 address=start_pc+((char *)comp_pc_p-(char *)start_pc_p)+m68k_pc_offset;\n"); - comprintf("\tmov_l_ri(pctmp,address);\n"); - - comprintf("\tcalc_disp_ea_020(pctmp,%s,%sa);\n", gen_nextiword(), name); - break; - case absw: - comprintf("\tint %sa = scratchie++;\n", name); - comprintf("\tmov_l_ri(%sa,(uae_s32)(uae_s16)%s);\n", name, gen_nextiword()); - break; - case absl: - comprintf("\tint %sa = scratchie++;\n", name); - comprintf("\tmov_l_ri(%sa,%s); /* absl */\n", name, gen_nextilong()); - break; - case imm: - if (getv != 1) - abort(); - switch (size) - { - case sz_byte: - comprintf("\tint %s = scratchie++;\n", name); - comprintf("\tmov_l_ri(%s,(uae_s32)(uae_s8)%s);\n", name, gen_nextibyte()); - break; - case sz_word: - comprintf("\tint %s = scratchie++;\n", name); - comprintf("\tmov_l_ri(%s,(uae_s32)(uae_s16)%s);\n", name, gen_nextiword()); - break; - case sz_long: - comprintf("\tint %s = scratchie++;\n", name); - comprintf("\tmov_l_ri(%s,%s);\n", name, gen_nextilong()); - break; - default: - abort(); - } - return; - case imm0: - if (getv != 1) - abort(); - comprintf("\tint %s = scratchie++;\n", name); - comprintf("\tmov_l_ri(%s,(uae_s32)(uae_s8)%s);\n", name, gen_nextibyte()); - return; - case imm1: - if (getv != 1) - abort(); - comprintf("\tint %s = scratchie++;\n", name); - comprintf("\tmov_l_ri(%s,(uae_s32)(uae_s16)%s);\n", name, gen_nextiword()); - return; - case imm2: - if (getv != 1) - abort(); - comprintf("\tint %s = scratchie++;\n", name); - comprintf("\tmov_l_ri(%s,%s);\n", name, gen_nextilong()); - return; - case immi: - if (getv != 1) - abort(); - if (name != "") { - comprintf("\tint %s = scratchie++;\n", name); - comprintf("\tmov_l_ri(%s,%s);\n", name, reg); - } - return; - default: - abort(); - } - - /* We get here for all non-reg non-immediate addressing modes to - * actually fetch the value. */ - if (getv == 1) - { - char astring[80]; - sprintf(astring, "%sa", name); - switch (size) - { - case sz_byte: - insn_n_cycles += 2; - break; - case sz_word: - insn_n_cycles += 2; - break; - case sz_long: - insn_n_cycles += 4; - break; - default: - abort(); - } - comprintf("\tint %s=scratchie++;\n", name); - switch (size) - { - case sz_byte: - gen_readbyte(astring, name); - break; - case sz_word: - gen_readword(astring, name); - break; - case sz_long: - gen_readlong(astring, name); - break; - default: - abort(); - } - } -} - -static void genamode_post(amodes mode, const char *reg, wordsizes size, const char *name, int getv, int movem) -{ - /* We now might have to fix up the register for pre-dec or post-inc - * addressing modes. */ - if (!movem) { - switch (mode) - { - case Aipi: - switch (size) - { - case sz_byte: - comprintf("\tarm_ADD_l_ri8(%s+8,areg_byteinc[%s]);\n", reg, reg); - break; - case sz_word: - comprintf("\tarm_ADD_l_ri8(%s+8,2);\n", reg); - break; - case sz_long: - comprintf("\tarm_ADD_l_ri8(%s+8,4);\n", reg); - break; - default: - abort(); - } - break; - } - } -} - -static void genastore(const char *from, amodes mode, const char *reg, wordsizes size, const char *to) -{ - switch (mode) - { - case Dreg: - switch (size) - { - case sz_byte: - comprintf("\tif(%s!=%s)\n", reg, from); - comprintf("\t\tmov_b_rr(%s,%s);\n", reg, from); - break; - case sz_word: - comprintf("\tif(%s!=%s)\n", reg, from); - comprintf("\t\tmov_w_rr(%s,%s);\n", reg, from); - break; - case sz_long: - comprintf("\tif(%s!=%s)\n", reg, from); - comprintf("\t\tmov_l_rr(%s,%s);\n", reg, from); - break; - default: - abort(); - } - break; - case Areg: - switch (size) - { - case sz_word: - comprintf("\tif(%s+8!=%s)\n", reg, from); - comprintf("\t\tmov_w_rr(%s+8,%s);\n", reg, from); - break; - case sz_long: - comprintf("\tif(%s+8!=%s)\n", reg, from); - comprintf("\t\tmov_l_rr(%s+8,%s);\n", reg, from); - break; - default: - abort(); - } - break; - - case Apdi: - case absw: - case PC16: - case PC8r: - case Ad16: - case Ad8r: - case Aipi: - case Aind: - case absl: - { - char astring[80]; - sprintf(astring, "%sa", to); - - switch (size) - { - case sz_byte: - insn_n_cycles += 2; - gen_writebyte(astring, from); - break; - case sz_word: - insn_n_cycles += 2; - gen_writeword(astring, from); - break; - case sz_long: - insn_n_cycles += 4; - gen_writelong(astring, from); - break; - default: - abort(); - } - } - break; - case imm: - case imm0: - case imm1: - case imm2: - case immi: - abort(); - break; - default: - abort(); - } -} - -static void genastore_new(const char *from, amodes mode, wordsizes size, const char *to) -{ - switch (mode) - { - case Dreg: - switch (size) - { - case sz_byte: - break; - case sz_word: - break; - case sz_long: - break; - default: - abort(); - } - break; - case Areg: - switch (size) - { - case sz_word: - break; - case sz_long: - break; - default: - abort(); - } - break; - - case Apdi: - case absw: - case PC16: - case PC8r: - case Ad16: - case Ad8r: - case Aipi: - case Aind: - case absl: - { - char astring[80]; - sprintf(astring, "%sa", to); - - switch (size) - { - case sz_byte: - insn_n_cycles += 2; - gen_writebyte(astring, from); - break; - case sz_word: - insn_n_cycles += 2; - gen_writeword(astring, from); - break; - case sz_long: - insn_n_cycles += 4; - gen_writelong(astring, from); - break; - default: - abort(); - } - } - break; - case imm: - case imm0: - case imm1: - case imm2: - case immi: - abort(); - break; - default: - abort(); - } -} - -static void gen_move16(uae_u32 opcode, struct instr *curi) -{ - mayfail; - comprintf("if (special_mem) {\n"); - comprintf(" FAIL(1);\n"); - comprintf(" " RETURN "\n"); - comprintf("} \n"); - - uae_u32 masked_op = (opcode & 0xfff8); - if (masked_op == 0xf620) { - // POSTINCREMENT SOURCE AND DESTINATION version: MOVE16 (Ax)+,(Ay)+ - start_brace(); - comprintf("\t uae_u16 dstreg = ((%s)>>12) & 0x07;\n", gen_nextiword()); - comprintf("\tint srca=srcreg + 8;\n"); - comprintf("\tint dsta=dstreg + 8;\n"); - } else { - /* Other variants */ - genamode_new(curi->smode, "srcreg", curi->size, "src", 0, 2); - genamode_new(curi->dmode, "dstreg", curi->size, "dst", 0, 2); - switch (masked_op) { - case 0xf600: - comprintf("\t jnf_ADD_im8(srcreg + 8, srcreg + 8, 16);\n"); - break; - case 0xf608: - comprintf("\t jnf_ADD_im8(dstreg + 8, dstreg + 8, 16);\n"); - break; - } - } - comprintf("\tjnf_MOVE16(dsta, srca);\n"); - if (masked_op == 0xf620) { - comprintf("\t if (srcreg != dstreg)\n"); - comprintf("\t jnf_ADD_im8(srcreg + 8, srcreg + 8, 16);\n"); - comprintf("\t jnf_ADD_im8(dstreg + 8, dstreg + 8, 16);\n"); - } else { - genamode_post(curi->smode, "srcreg", curi->size, "src", 0, 2); - genamode_post(curi->dmode, "dstreg", curi->size, "dst", 0, 2); - } -} - -static void genmovemel(uae_u16 opcode) -{ - comprintf("\tuae_u16 mask = %s;\n", gen_nextiword()); - comprintf("\tint native=scratchie++;\n"); - comprintf("\tint i;\n"); - comprintf("\tsigned char offset=0;\n"); - genamode_new(table68k[opcode].dmode, "dstreg", table68k[opcode].size, "src", 2, 1); - comprintf("\tif (!special_mem) {\n"); - - /* Fast but unsafe... */ - comprintf("\tget_n_addr(srca,native);\n"); - - comprintf("\tfor (i=0;i<16;i++) {\n" - "\t\tif ((mask>>i)&1) {\n"); - switch (table68k[opcode].size) { - case sz_long: - if (table68k[opcode].dmode == Aipi) - comprintf("\t\t\tif(srca != i)\n"); - comprintf("\t\t\tjnf_MVMEL_l(i,native,offset);\n"); - comprintf("\t\t\toffset+=4;\n"); - break; - case sz_word: - if (table68k[opcode].dmode == Aipi) - comprintf("\t\t\tif(srca != i)\n"); - comprintf("\t\t\tjnf_MVMEL_w(i,native,offset);\n"); - comprintf("\t\t\toffset+=2;\n"); - break; - default: abort(); - } - comprintf("\t\t}\n" - "\t}"); - if (table68k[opcode].dmode == Aipi) { - comprintf("\t\t\tjnf_ADD_im8(8+dstreg,srca,offset);\n"); - } - /* End fast but unsafe. */ - - comprintf("\t} else {\n"); - - comprintf ("\t\tint tmp=scratchie++;\n"); - - comprintf("\t\tmov_l_rr(tmp,srca);\n"); - comprintf("\t\tfor (i=0;i<16;i++) {\n" - "\t\t\tif ((mask>>i)&1) {\n"); - switch(table68k[opcode].size) { - case sz_long: - comprintf("\t\t\t\treadlong(tmp,i);\n" - "\t\t\t\tarm_ADD_l_ri8(tmp,4);\n"); - break; - case sz_word: - comprintf("\t\t\t\treadword(tmp,i);\n" - "\t\t\t\tarm_ADD_l_ri8(tmp,2);\n"); - break; - default: abort(); - } - - comprintf("\t\t\t}\n" - "\t\t}\n"); - if (table68k[opcode].dmode == Aipi) { - comprintf("\t\tmov_l_rr(8+dstreg,tmp);\n"); - } - comprintf("\t}\n"); -} - - -static void genmovemle(uae_u16 opcode) -{ - comprintf("\tuae_u16 mask = %s;\n", gen_nextiword()); - comprintf("\tint native=scratchie++;\n"); - comprintf("\tint i;\n"); - comprintf("\tint tmp=scratchie++;\n"); - comprintf("\tsigned char offset=0;\n"); - genamode_new(table68k[opcode].dmode, "dstreg", table68k[opcode].size, "src", 2, 1); - - /* *Sigh* Some clever geek realized that the fastest way to copy a - buffer from main memory to the gfx card is by using movmle. Good - on her, but unfortunately, gfx mem isn't "real" mem, and thus that - act of cleverness means that movmle must pay attention to special_mem, - or Genetic Species is a rather boring-looking game ;-) */ - comprintf("\tif (!special_mem) {\n"); - comprintf("\tget_n_addr(srca,native);\n"); - - if (table68k[opcode].dmode != Apdi) { - comprintf("\tfor (i=0;i<16;i++) {\n" - "\t\tif ((mask>>i)&1) {\n"); - switch (table68k[opcode].size) { - case sz_long: - comprintf("\t\t\tjnf_MVMLE_l(native,i,offset);\n" - "\t\t\toffset+=4;\n"); - break; - case sz_word: - comprintf("\t\t\tjnf_MVMLE_w(native,i,offset);\n" - "\t\t\toffset+=2;\n"); - break; - default: abort(); - } - } - else { /* Pre-decrement */ - comprintf("\tfor (i=0;i<16;i++) {\n" - "\t\tif ((mask>>i)&1) {\n"); - switch (table68k[opcode].size) { - case sz_long: - comprintf("\t\t\toffset-=4;\n" - "\t\t\tjnf_MVMLE_l(native,15-i,offset);\n" - ); - break; - case sz_word: - comprintf("\t\t\toffset-=2;\n" - "\t\t\tjnf_MVMLE_w(native,15-i,offset);\n" - ); - break; - default: abort(); - } - } - - - comprintf("\t\t}\n" - "\t}"); - if (table68k[opcode].dmode == Apdi) { - comprintf("\t\t\tlea_l_brr(8+dstreg,srca,(uae_s32)offset);\n"); - } - comprintf("\t} else {\n"); - - if (table68k[opcode].dmode!=Apdi) { - comprintf("\tmov_l_rr(tmp,srca);\n"); - comprintf("\tfor (i=0;i<16;i++) {\n" - "\t\tif ((mask>>i)&1) {\n"); - switch(table68k[opcode].size) { - case sz_long: - comprintf("\t\t\twritelong(tmp,i);\n" - "\t\t\tarm_ADD_l_ri8(tmp,4);\n"); - break; - case sz_word: - comprintf("\t\t\twriteword(tmp,i);\n" - "\t\t\tarm_ADD_l_ri8(tmp,2);\n"); - break; - default: abort(); - } - } - else { /* Pre-decrement */ - comprintf("\tfor (i=0;i<16;i++) {\n" - "\t\tif ((mask>>i)&1) {\n"); - switch(table68k[opcode].size) { - case sz_long: - comprintf("\t\t\tarm_SUB_l_ri8(srca,4);\n" - "\t\t\twritelong(srca,15-i);\n"); - break; - case sz_word: - comprintf("\t\t\tarm_SUB_l_ri8(srca,2);\n" - "\t\t\twriteword(srca,15-i);\n"); - break; - default: abort(); - } - } - - - comprintf("\t\t}\n" - "\t}"); - if (table68k[opcode].dmode == Apdi) { - comprintf("\t\t\tmov_l_rr(8+dstreg,srca);\n"); - } - comprintf("\t}\n"); -} - - -typedef enum -{ - flag_logical_noclobber, flag_logical, flag_add, flag_sub, flag_cmp, - flag_addx, flag_subx, flag_zn, flag_av, flag_sv, flag_and, flag_or, - flag_eor, flag_mov -} -flagtypes; - -static void gen_add(uae_u32 opcode, struct instr *curi, char* ssize) -{ - (void) opcode; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "dst", 1, 0); - - comprintf("\t dont_care_flags();\n"); - // Use tmp register to avoid destroying upper part in .B., .W cases - if (!noflags) { - comprintf("\t jff_ADD_%s(dst,src);\n", ssize); - comprintf("\t live_flags();\n"); - comprintf( - "\t if (!(needed_flags & FLAG_CZNV)) dont_care_flags();\n"); - } else { - comprintf("\t jnf_ADD_%s(dst,src);\n", ssize); - } - genastore_new("dst", curi->dmode, curi->size, "dst"); - genamode_post(curi->dmode, "dstreg", curi->size, "dst", 1, 0); -} - -static void gen_adda(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", sz_long, "dst", 1, 0); - comprintf("\t jnf_ADDA_%s(dst, src);\n", ssize); - genastore_new("dst", curi->dmode, sz_long, "dst"); -} - -static void gen_addx(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - isaddx; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "dst", 1, 0); - - // Use tmp register to avoid destroying upper part in .B., .W cases - comprintf("\t dont_care_flags();\n"); - if (!noflags) { - comprintf("\t make_flags_live();\n"); - comprintf("\t jff_ADDX_%s(dst,src);\n", ssize); - comprintf("\t live_flags();\n"); - comprintf("\t if (!(needed_flags & FLAG_CZNV)) dont_care_flags();\n"); - } else { - comprintf("\t jnf_ADDX_%s(dst,src);\n", ssize); - } - genastore_new("dst", curi->dmode, curi->size, "dst"); - genamode_post(curi->dmode, "dstreg", curi->size, "dst", 1, 0); -} - -static void gen_and(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "dst", 1, 0); - - comprintf("\t dont_care_flags();\n"); - if (!noflags) { - comprintf("\t jff_AND_%s(dst,src);\n", ssize); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_AND_%s(dst,src);\n", ssize); - } - genastore_new("dst", curi->dmode, curi->size, "dst"); - genamode_post(curi->dmode, "dstreg", curi->size, "dst", 1, 0); -} - -static void gen_andsr(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - (void) ssize; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - if (!noflags) { - comprintf("\t make_flags_live();\n"); - comprintf("\t jff_ANDSR(ARM_CCR_MAP[src & 0xF], (src & 0x10));\n"); - comprintf("\t live_flags();\n"); - } -} - -static void gen_asl(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - comprintf("\t dont_care_flags();\n"); - - genamode_new(curi->smode, "srcreg", curi->size, "", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "data", 1, 0); - - if (curi->smode != immi) { - if (!noflags) { - comprintf("\t jff_ASL_%s_reg(data,srcreg);\n", ssize); - comprintf("\t live_flags();\n"); - comprintf( - "\t if (!(needed_flags & FLAG_CZNV)) dont_care_flags();\n"); - } else { - comprintf("\t jnf_LSL_%s_reg(data,srcreg);\n", ssize); - } - } else { - if (!noflags) { - comprintf("\t jff_ASL_%s_imm(data,srcreg);\n", ssize); - comprintf("\t live_flags();\n"); - comprintf( - "\t if (!(needed_flags & FLAG_CZNV)) dont_care_flags();\n"); - } else { - comprintf("\t jnf_LSL_%s_imm(data,srcreg);\n", ssize); - } - } - genastore_new("data", curi->dmode, curi->size, "data"); -} - -static void gen_aslw(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - (void) ssize; - comprintf("\t dont_care_flags();\n"); - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - if (!noflags) { - comprintf("\t jff_ASLW(src);\n"); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_ASLW(src);\n"); - } - genastore_new("src", curi->smode, curi->size, "src"); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); -} - -static void gen_asr(uae_u32 opcode, struct instr *curi, char* ssize) { - (void)opcode; - comprintf("\t dont_care_flags();\n"); - - genamode_new(curi->smode, "srcreg", curi->size, "", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "data", 1, 0); - - if (curi->smode != immi) { - if (!noflags) { - comprintf("\t jff_ASR_%s_reg(data,srcreg);\n", ssize); - comprintf("\t live_flags();\n"); - comprintf( - "if (!(needed_flags & FLAG_CZNV)) dont_care_flags();\n"); - } else { - comprintf("\t jnf_ASR_%s_reg(data,srcreg);\n", ssize); - } - } else { - char *op; - if (!noflags) { - op = "ff"; - } else - op = "nf"; - - comprintf("\t j%s_ASR_%s_imm(data,srcreg);\n", op, ssize); - if (!noflags) { - comprintf("\t live_flags();\n"); - comprintf( - "\t if (!(needed_flags & FLAG_CZNV)) dont_care_flags();\n"); - } - } - genastore_new("data", curi->dmode, curi->size, "data"); -} - -static void gen_asrw(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - (void) ssize; - comprintf("\t dont_care_flags();\n"); - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - - if (!noflags) { - comprintf("\t jff_ASRW(src);\n"); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_ASRW(src);\n"); - } - genastore_new("src", curi->smode, curi->size, "src"); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); -} - -static void gen_bchg(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "dst", 1, 0); - - if (!noflags) { - comprintf("\t make_flags_live();\n"); - comprintf("\t jff_BCHG_%s(dst,src);\n", ssize); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_BCHG_%s(dst,src);\n", ssize); - comprintf("\t dont_care_flags();\n"); - } - genastore_new("dst", curi->dmode, curi->size, "dst"); - genamode_post(curi->dmode, "dstreg", curi->size, "dst", 1, 0); -} - -static void gen_bclr(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "dst", 1, 0); - - if (!noflags) { - comprintf("\t make_flags_live();\n"); - comprintf("\t jff_BCLR_%s(dst,src);\n", ssize); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_BCLR_%s(dst,src);\n", ssize); - comprintf("\t dont_care_flags();\n"); - } - genastore_new("dst", curi->dmode, curi->size, "dst"); - genamode_post(curi->dmode, "dstreg", curi->size, "dst", 1, 0); -} - -static void gen_bset(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "dst", 1, 0); - - if (!noflags) { - comprintf("\t make_flags_live();\n"); - comprintf("\t jff_BSET_%s(dst,src);\n", ssize); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_BSET_%s(dst,src);\n", ssize); - comprintf("\t dont_care_flags();\n"); - } - genastore_new("dst", curi->dmode, curi->size, "dst"); - genamode_post(curi->dmode, "dstreg", curi->size, "dst", 1, 0); -} - -static void gen_btst(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "dst", 1, 0); - - // If we are not interested in flags it is not necessary to do - // anything with the data - if (!noflags) { - comprintf("\t make_flags_live();\n"); - comprintf("\t jff_BTST_%s(dst,src);\n", ssize); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t dont_care_flags();\n"); - } - genamode_post(curi->dmode, "dstreg", curi->size, "dst", 1, 0); -} - -static void gen_clr(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - (void) ssize; - genamode_new(curi->smode, "srcreg", curi->size, "src", 2, 0); - if((curi->smode != Dreg) && (curi->smode != Areg)) - comprintf("\t int src=scratchie++;\n"); - comprintf("\t dont_care_flags();\n"); - if (!noflags) { - comprintf("\t jff_CLR_%s(src);\n", ssize); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_CLR_%s(src);\n", ssize); - } - genastore_new("src", curi->smode, curi->size, "src"); - genamode_post(curi->smode, "srcreg", curi->size, "src", 2, 0); -} - -static void gen_cmp(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "dst", 1, 0); - comprintf("\t dont_care_flags();\n"); - if (!noflags) { - comprintf("\t jff_CMP_%s(dst,src);\n", ssize); - comprintf("\t live_flags();\n"); - comprintf("\t if (!(needed_flags & FLAG_CZNV)) dont_care_flags();\n"); - } else { - comprintf("/* Weird --- CMP with noflags ;-) */\n"); - } - genamode_post(curi->dmode, "dstreg", curi->size, "dst", 1, 0); -} - -static void gen_cmpa(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", sz_long, "dst", 1, 0); - if (!noflags) { - comprintf("\t dont_care_flags();\n"); - comprintf("\t jff_CMPA_%s(dst,src);\n", ssize); - comprintf("\t live_flags();\n"); - comprintf("\t if (!(needed_flags & FLAG_CZNV)) dont_care_flags();\n"); - } else { - comprintf("\tdont_care_flags();\n"); - comprintf("/* Weird --- CMP with noflags ;-) */\n"); - } - genamode_post(curi->dmode, "dstreg", sz_long, "dst", 1, 0); -} - -static void gen_dbcc(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - (void) ssize; - isjump; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "offs", 1, 0); - - if (curi->size != sz_word) - abort(); - - /* That offs is an immediate, so we can clobber it with abandon */ - comprintf("\tsub_l_ri(offs, m68k_pc_offset - m68k_pc_offset_thisinst - 2);\n"); - comprintf("\tarm_ADD_l_ri(offs, (uintptr)comp_pc_p);\n"); - /* New PC, once the offset_68k is also added */ - /* Let's fold in the m68k_pc_offset at this point */ - comprintf("\tarm_ADD_l_ri(offs, m68k_pc_offset);\n"); - comprintf("\tarm_ADD_l_ri(PC_P, m68k_pc_offset);\n"); - comprintf("\tm68k_pc_offset=0;\n"); - - if (curi->cc >= 2) { - comprintf("\tmake_flags_live();\n"); /* Load the flags */ - } - - switch (curi->cc) { - case 0: /* This is an elaborate nop? */ - break; - case 1: - comprintf("\tsub_w_ri(src, 1);\n"); - comprintf("\tuae_u32 v2;\n"); - comprintf("\tuae_u32 v1=get_const(PC_P);\n"); - comprintf("\tv2=get_const(offs);\n"); - comprintf("\tregister_branch(v1, v2, %d);\n", NATIVE_CC_CC); - break; - - case 8: - case 9: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - comprintf("\tuae_u32 v1=get_const(PC_P);\n"); - comprintf("\tuae_u32 v2=get_const(offs);\n"); - comprintf("\tjff_DBCC(src, %d);\n", cond_codes[curi->cc]); - comprintf("\tregister_branch(v1, v2, %d);\n", NATIVE_CC_CS); - break; - default: abort(); - } - gen_update_next_handler(); -} - -static void gen_divu(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - (void) ssize; - comprintf("\t dont_care_flags();\n"); - genamode_new(curi->smode, "srcreg", sz_word, "src", 1, 0); - genamode_post(curi->smode, "srcreg", sz_word, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", sz_word, "dst", 1, 0); - - comprintf("\tregister_possible_exception();\n"); - if (!noflags) { - comprintf("\tjff_DIVU(dst,src);\n"); - comprintf("\tlive_flags();\n"); - } else { - comprintf("\tjnf_DIVU(dst,src);\n"); - } - - genastore_new("dst", curi->dmode, sz_long /*curi->size*/, "dst"); -} - -static void gen_divs(uae_u32 opcode, struct instr *curi, char* ssize) { - (void)opcode; - (void)ssize; - comprintf("\t dont_care_flags();\n"); - genamode_new(curi->smode, "srcreg", sz_word, "src", 1, 0); - genamode_post(curi->smode, "srcreg", sz_word, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", sz_word, "dst", 1, 0); - - comprintf("\tregister_possible_exception();\n"); - if (!noflags) { - comprintf("\tjff_DIVS(dst,src);\n"); - comprintf("\tlive_flags();\n"); - } - else { - comprintf("\tjnf_DIVS(dst,src);\n"); - } - - genastore_new("dst", curi->dmode, sz_long /*curi->size*/, "dst"); -} - -static void gen_divl(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - (void) ssize; - comprintf("\t dont_care_flags();\n"); - comprintf("\t uae_u16 extra=%s;\n", gen_nextiword()); - comprintf("\t int r2=(extra>>12)&7;\n"); - comprintf("\t int r3=extra&7;\n"); - genamode_new(curi->dmode, "dstreg", curi->size, "dst", 1, 0); - genamode_post(curi->dmode, "dstreg", curi->size, "dst", 1, 0); - comprintf("\tregister_possible_exception();\n"); - - if (!noflags) { - comprintf("\t if (extra & 0x0400) {\n"); /* Need full 64 bit divisor */ - comprintf("\t FAIL(1);\n"); - comprintf("\t m68k_pc_offset=m68k_pc_offset_thisinst;\n"); - comprintf("\t " RETURN "\n"); - comprintf("\t } else { \n"); - /* operands in src and r2, result goes into r2, remainder into r3 */ - /* s2 = s2 / src */ - /* s3 = s2 % src */ - comprintf("\t if (extra & 0x0800) { \n"); /* signed */ - comprintf("\t jff_DIVLS32(r2,dst,r3);\n"); - comprintf("\t } else { \n"); - comprintf("\t\t jff_DIVLU32(r2,dst,r3);\n"); - comprintf("\t } \n"); - comprintf("\t }\n"); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t if (extra & 0x0400) {\n"); /* Need full 64 bit divisor */ - comprintf("\t FAIL(1);\n"); - comprintf("\t m68k_pc_offset=m68k_pc_offset_thisinst;\n"); - comprintf("\t " RETURN "\n"); - comprintf("\t } else {\n"); - comprintf("\t if (extra & 0x0800) { \n"); /* signed */ - comprintf("\t jnf_DIVLS32(r2,dst,r3);\n"); - comprintf("\t } else { \n"); - comprintf("\t\t jnf_DIVLU32(r2,dst,r3);\n"); - comprintf("\t } \n"); - comprintf("\t }\n"); - } -} - -static void gen_eor(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "dst", 1, 0); - - comprintf("\t dont_care_flags();\n"); - if (!noflags) { - comprintf("\t jff_EOR_%s(dst,src);\n", ssize); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_EOR_%s(dst,src);\n", ssize); - } - genastore_new("dst", curi->dmode, curi->size, "dst"); - genamode_post(curi->dmode, "dstreg", curi->size, "dst", 1, 0); -} - -static void gen_eorsr(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - (void) ssize; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - if (!noflags) { - comprintf("\t make_flags_live();\n"); - comprintf("\t jff_EORSR(ARM_CCR_MAP[src & 0xF], ((src & 0x10) >> 4));\n"); - comprintf("\t live_flags();\n"); - } -} - -static void gen_exg(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - (void) ssize; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "dst", 1, 0); - comprintf("\tint tmp=scratchie++;\n" - "\tmov_l_rr(tmp,src);\n"); - genastore("dst", curi->smode, "srcreg", curi->size, "src"); - genastore("tmp", curi->dmode, "dstreg", curi->size, "dst"); -} - -static void gen_ext(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - genamode_new(curi->smode, "srcreg", sz_long, "src", 1, 0); - comprintf("\t dont_care_flags();\n"); - if (!noflags) { - comprintf("\t jff_EXT_%s(src);\n", ssize); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_EXT_%s(src);\n", ssize); - } - genastore_new("src", curi->smode, curi->size == sz_word ? sz_word : sz_long, "src"); -} - -static void gen_lsl(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - comprintf("\tdont_care_flags();\n"); - - genamode_new(curi->smode, "srcreg", curi->size, "", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "data", 1, 0); - if (curi->smode != immi) { - if (!noflags) { - comprintf("\t jff_LSL_%s_reg(data,srcreg);\n", ssize); - comprintf("\t live_flags();\n"); - comprintf( - "\t if (!(needed_flags & FLAG_CZNV)) dont_care_flags();\n"); - } else { - comprintf("\t jnf_LSL_%s_reg(data,srcreg);\n", ssize); - } - } else { - if (!noflags) { - comprintf("\t jff_LSL_%s_imm(data,srcreg);\n", ssize); - comprintf("\t live_flags();\n"); - comprintf( - "\t if (!(needed_flags & FLAG_CZNV)) dont_care_flags();\n"); - } else { - comprintf("\t jnf_LSL_%s_imm(data,srcreg);\n", ssize); - } - } - genastore_new("data", curi->dmode, curi->size, "data"); -} - -static void gen_lslw(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - (void) ssize; - comprintf("\t dont_care_flags();\n"); - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - if (!noflags) { - comprintf("\t jff_LSLW(src);\n"); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_LSLW(src);\n"); - } - genastore_new("src", curi->smode, curi->size, "src"); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); -} - -static void gen_lsr(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - comprintf("\t dont_care_flags();\n"); - - genamode_new(curi->smode, "srcreg", curi->size, "", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "data", 1, 0); - if (curi->smode != immi) { - if (!noflags) { - comprintf("\t jff_LSR_%s_reg(data,srcreg);\n", ssize); - comprintf("\t live_flags();\n"); - comprintf("if (!(needed_flags & FLAG_CZNV)) dont_care_flags();\n"); - } else { - comprintf("\t jnf_LSR_%s_reg(data,srcreg);\n", ssize); - } - } else { - char *op; - if (!noflags) { - op = "ff"; - } else - op = "nf"; - - comprintf("\t j%s_LSR_%s_imm(data,srcreg);\n", op, ssize); - - if (!noflags) { - comprintf("\t live_flags();\n"); - comprintf( - "\t if (!(needed_flags & FLAG_CZNV)) dont_care_flags();\n"); - } - } - genastore_new("data", curi->dmode, curi->size, "data"); -} - -static void gen_lsrw(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - (void) ssize; - comprintf("\t dont_care_flags();\n"); - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - - if (!noflags) { - comprintf("\t jff_LSRW(src);\n"); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_LSRW(src);\n"); - } - genastore_new("src", curi->smode, curi->size, "src"); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); -} - -static void gen_move(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - switch (curi->dmode) { - case Dreg: - case Areg: - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "dst", 2, 0); - comprintf("\t dont_care_flags();\n"); - if (!noflags && curi->dmode == Dreg) { - comprintf("\t jff_MOVE_%s(dst, src);\n", ssize); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_MOVE_%s(dst, src);\n", ssize); - } - genastore_new("dst", curi->dmode, curi->size, "dst"); - break; - - default: /* It goes to memory, not a register */ - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - if (curi->smode == Areg && (curi->dmode == Apdi || curi->dmode == Aipi)) { - comprintf("\tif(srcreg==(uae_s32)dstreg){\n"); - comprintf("\t\tsrc=scratchie++;\n"); - comprintf("\t\tmov_l_rr(src,srcreg+8);\n"); - comprintf("\t}\n"); - } - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "dst", 2, 0); - comprintf("\t dont_care_flags();\n"); - if (!noflags) { - comprintf("\t jff_TST_%s(src);\n", ssize); - comprintf("\t live_flags();\n"); - } - genastore_new("src", curi->dmode, curi->size, "dst"); - genamode_post(curi->dmode, "dstreg", curi->size, "dst", 2, 0); - break; - } -} - -static void gen_movea(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "dst", 2, 0); - - comprintf("\t jnf_MOVEA_%s(dst, src);\n", ssize); - genastore_new("dst", curi->dmode, sz_long, "dst"); -} - -static void gen_mull(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - (void) ssize; - comprintf("\t uae_u16 extra=%s;\n", gen_nextiword()); - comprintf("\t int r2=(extra>>12)&7;\n"); - genamode_new(curi->dmode, "dstreg", curi->size, "dst", 1, 0); - genamode_post(curi->dmode, "dstreg", curi->size, "dst", 1, 0); - /* The two operands are in dst and r2 */ - if (!noflags) { - comprintf("\t if (extra & 0x0400) {\n"); /* Need full 64 bit result */ - comprintf("\t int r3=(extra & 7);\n"); - comprintf("\t mov_l_rr(r3,dst);\n"); /* operands now in r3 and r2 */ - comprintf("\t if (extra & 0x0800) { \n"); /* signed */ - comprintf("\t\t jff_MULS64(r2,r3);\n"); - comprintf("\t } else { \n"); - comprintf("\t\t jff_MULU64(r2,r3);\n"); - comprintf("\t } \n"); /* The result is in r2/r3, with r2 holding the lower 32 bits */ - comprintf("\t } else {\n"); /* Only want 32 bit result */ - /* operands in dst and r2, result goes into r2 */ - comprintf("\t if (extra & 0x0800) { \n"); /* signed */ - comprintf("\t jff_MULS32(r2,dst);\n"); - comprintf("\t } else { \n"); - comprintf("\t\t jff_MULU32(r2,dst);\n"); - comprintf("\t } \n"); /* The result is in r2, with r2 holding the lower 32 bits */ - comprintf("\t }\n"); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t if (extra & 0x0400) {\n"); /* Need full 64 bit result */ - comprintf("\t int r3=(extra & 7);\n"); - comprintf("\t mov_l_rr(r3,dst);\n"); /* operands now in r3 and r2 */ - comprintf("\t if (extra & 0x0800) { \n"); /* signed */ - comprintf("\t\t jnf_MULS64(r2,r3);\n"); - comprintf("\t } else { \n"); - comprintf("\t\t jnf_MULU64(r2,r3);\n"); - comprintf("\t } \n"); /* The result is in r2/r3, with r2 holding the lower 32 bits */ - comprintf("\t } else {\n"); /* Only want 32 bit result */ - /* operands in dst and r2, result foes into r2 */ - comprintf("\t if (extra & 0x0800) { \n"); /* signed */ - comprintf("\t jnf_MULS32(r2,dst);\n"); - comprintf("\t } else { \n"); - comprintf("\t\t jnf_MULU32(r2,dst);\n"); - comprintf("\t } \n"); /* The result is in r2, with r2 holding the lower 32 bits */ - comprintf("\t }\n"); - } -} - -static void gen_muls(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - (void) ssize; - comprintf("\t dont_care_flags();\n"); - genamode_new(curi->smode, "srcreg", sz_word, "src", 1, 0); - genamode_post(curi->smode, "srcreg", sz_word, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", sz_word, "dst", 1, 0); - if (!noflags) { - comprintf("\t jff_MULS(dst,src);\n"); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_MULS(dst,src);\n"); - } - genastore_new("dst", curi->dmode, sz_long, "dst"); -} - -static void gen_mulu(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - (void) ssize; - comprintf("\t dont_care_flags();\n"); - genamode_new(curi->smode, "srcreg", sz_word, "src", 1, 0); - genamode_post(curi->smode, "srcreg", sz_word, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", sz_word, "dst", 1, 0); - if (!noflags) { - comprintf("\t jff_MULU(dst,src);\n"); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_MULU(dst,src);\n"); - } - genastore_new("dst", curi->dmode, sz_long, "dst"); -} - -static void gen_neg(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - if (!noflags) { - comprintf("\t jff_NEG_%s(src);\n", ssize); - comprintf("\t live_flags();\n"); - comprintf("\t if (!(needed_flags & FLAG_CZNV)) dont_care_flags();\n"); - } else { - comprintf("\t jnf_NEG_%s(src);\n", ssize); - } - genastore_new("src", curi->smode, curi->size, "src"); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); -} - -static void gen_negx(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - isaddx; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - if (!noflags) { - comprintf("\t make_flags_live();\n"); - comprintf("\t jff_NEGX_%s(src);\n", ssize); - comprintf("\t live_flags();\n"); - comprintf("\t if (!(needed_flags & FLAG_CZNV)) dont_care_flags();\n"); - } else { - comprintf("\t jnf_NEGX_%s(src);\n", ssize); - } - genastore_new("src", curi->smode, curi->size, "src"); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); -} - -static void gen_not(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - comprintf("\t dont_care_flags();\n"); - if (!noflags) { - comprintf("\t jff_NOT_%s(src);\n", ssize); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_NOT_%s(src);\n", ssize); - } - genastore_new("src", curi->smode, curi->size, "src"); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); -} - -static void gen_or(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "dst", 1, 0); - - comprintf("\t dont_care_flags();\n"); - if (!noflags) { - comprintf("\t jff_OR_%s(dst,src);\n", ssize); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_OR_%s(dst,src);\n", ssize); - } - genastore_new("dst", curi->dmode, curi->size, "dst"); - genamode_post(curi->dmode, "dstreg", curi->size, "dst", 1, 0); -} - -static void gen_orsr(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - (void) ssize; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - if (!noflags) { - comprintf("\t make_flags_live();\n"); - comprintf("\t jff_ORSR(ARM_CCR_MAP[src & 0xF], ((src & 0x10) >> 4));\n"); - comprintf("\t live_flags();\n"); - } -} - -static void gen_rol(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - comprintf("\t dont_care_flags();\n"); - genamode_new(curi->smode, "srcreg", curi->size, "cnt", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "data", 1, 0); - - if (!noflags) { - comprintf("\t jff_ROL_%s(data,cnt);\n", ssize); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_ROL_%s(data,cnt);\n", ssize); - } - genastore_new("data", curi->dmode, curi->size, "data"); -} - -static void gen_rolw(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - (void) ssize; - comprintf("\t dont_care_flags();\n"); - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - - if (!noflags) { - comprintf("\t jff_ROLW(src);\n"); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_ROLW(src);\n"); - } - genastore_new("src", curi->smode, curi->size, "src"); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); -} - -static void gen_ror(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - comprintf("\t dont_care_flags();\n"); - genamode_new(curi->smode, "srcreg", curi->size, "cnt", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "data", 1, 0); - - if (!noflags) { - comprintf("\t jff_ROR_%s(data,cnt);\n", ssize); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_ROR_%s(data,cnt);\n", ssize); - } - genastore_new("data", curi->dmode, curi->size, "data"); -} - -static void gen_rorw(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - (void) ssize; - comprintf("\t dont_care_flags();\n"); - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - - if (!noflags) { - comprintf("\t jff_RORW(src);\n"); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_RORW(src);\n"); - } - genastore_new("src", curi->smode, curi->size, "src"); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); -} - -static void gen_roxl(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - isaddx; - comprintf("\t dont_care_flags();\n"); - genamode_new(curi->smode, "srcreg", curi->size, "cnt", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "data", 1, 0); - - if (!noflags) { - comprintf("\t make_flags_live();\n"); - comprintf("\t jff_ROXL_%s(data,cnt);\n", ssize); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_ROXL_%s(data,cnt);\n", ssize); - } - genastore_new("data", curi->dmode, curi->size, "data"); -} - -static void gen_roxlw(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - (void) ssize; - isaddx; - comprintf("\t dont_care_flags();\n"); - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - - if (!noflags) { - comprintf("\t make_flags_live();\n"); - comprintf("\t jff_ROXLW(src);\n"); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_ROXLW(src);\n"); - } - genastore_new("src", curi->smode, curi->size, "src"); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); -} - -static void gen_roxr(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - isaddx; - comprintf("\t dont_care_flags();\n"); - genamode_new(curi->smode, "srcreg", curi->size, "cnt", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "data", 1, 0); - - if (!noflags) { - comprintf("\t make_flags_live();\n"); - comprintf("\t jff_ROXR_%s(data,cnt);\n", ssize); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_ROXR_%s(data,cnt);\n", ssize); - } - genastore_new("data", curi->dmode, curi->size, "data"); -} - -static void gen_roxrw(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - (void) ssize; - isaddx; - comprintf("\t dont_care_flags();\n"); - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - - if (!noflags) { - comprintf("\t make_flags_live();\n"); - comprintf("\t jff_ROXRW(src);\n"); - comprintf("\t live_flags();\n"); - } else { - comprintf("\t jnf_ROXRW(src);\n"); - } - genastore_new("src", curi->smode, curi->size, "src"); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); -} - -static void gen_scc(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - (void) ssize; - genamode_new(curi->smode, "srcreg", curi->size, "src", 2, 0); - if (curi->smode != Dreg) - comprintf("\tint val = scratchie++;\n"); - - switch (curi->cc) { - case 0: /* Unconditional set */ - if (curi->smode == Dreg) - comprintf("\tmov_b_ri(srcreg, 0xff);\n"); - else - comprintf("\tmov_b_ri(val, 0xff);\n"); - break; - case 1: - /* Unconditional not-set */ - if (curi->smode == Dreg) - comprintf("\tmov_b_ri(srcreg, 0);\n"); - else - comprintf("\tmov_b_ri(val, 0);\n"); - break; - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - comprintf("\tmake_flags_live();\n"); /* Load the flags */ - if (curi->smode == Dreg) - comprintf("\tjnf_SCC(srcreg, %d);\n", cond_codes[curi->cc]); - else - comprintf("\tjnf_SCC(val, %d);\n", cond_codes[curi->cc]); - break; - default: - abort(); - } - if (curi->smode != Dreg) - genastore_new("val", curi->smode, curi->size, "src"); - genamode_post(curi->smode, "srcreg", curi->size, "src", 2, 0); -} - -static void gen_sub(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "dst", 1, 0); - - comprintf("\t dont_care_flags();\n"); - if (!noflags) { - comprintf("\t jff_SUB_%s(dst,src);\n", ssize); - comprintf("\t live_flags();\n"); - comprintf( - "\t if (!(needed_flags & FLAG_CZNV)) dont_care_flags();\n"); - } else { - comprintf("\t jnf_SUB_%s(dst,src);\n", ssize); - } - genastore_new("dst", curi->dmode, curi->size, "dst"); - genamode_post(curi->dmode, "dstreg", curi->size, "dst", 1, 0); -} - -static void gen_suba(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", sz_long, "dst", 1, 0); - comprintf("\t jnf_SUBA_%s(dst, src);\n", ssize); - genastore_new("dst", curi->dmode, sz_long, "dst"); -} - -static void gen_subx(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - isaddx; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "dst", 1, 0); - comprintf("\tdont_care_flags();\n"); - if (!noflags) { - comprintf("\t make_flags_live();\n"); - comprintf("\t jff_SUBX_%s(dst,src);\n", ssize); - comprintf("\t live_flags();\n"); - comprintf("if (!(needed_flags & FLAG_CZNV)) dont_care_flags();\n"); - } else { - comprintf("\t jnf_SUBX_%s(dst,src);\n", ssize); - } - genastore_new("dst", curi->dmode, curi->size, "dst"); - genamode_post(curi->dmode, "dstreg", curi->size, "dst", 1, 0); -} - -static void gen_swap(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - (void) ssize; - genamode_new(curi->smode, "srcreg", sz_long, "src", 1, 0); - comprintf("\t dont_care_flags();\n"); - - if (!noflags) { - comprintf("\t jff_SWAP(src);\n"); - comprintf("\t live_flags();\n"); - comprintf("if (!(needed_flags & FLAG_CZNV)) dont_care_flags();\n"); - } else { - comprintf("\t jnf_SWAP(src);\n"); - } - genastore_new("src", curi->smode, sz_long, "src"); -} - -static void gen_tst(uae_u32 opcode, struct instr *curi, char* ssize) { - (void) opcode; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - comprintf("\t dont_care_flags();\n"); - if (!noflags) { - comprintf("\t jff_TST_%s(src);\n", ssize); - comprintf("\t live_flags();\n"); - } - genamode_post(curi->smode, "srcreg", curi->size, "src", 1, 0); -} - -/* returns zero for success, non-zero for failure */ -static int gen_opcode(unsigned int opcode) -{ - struct instr *curi = table68k + opcode; - char* ssize = NULL; - - insn_n_cycles = 2; - global_failure = 0; - long_opcode = 0; - global_isjump = 0; - global_iscjump = 0; - global_isaddx = 0; - global_cmov = 0; - global_fpu = 0; - global_mayfail = 0; - hack_opcode = opcode; - endstr[0] = 0; - - comprintf("\tuae_u8 scratchie=S1;\n"); - switch (curi->plev) { - case 0: /* not privileged */ - break; - case 1: /* unprivileged only on 68000 */ - if (cpu_level == 0) - break; - if (next_cpu_level < 0) - next_cpu_level = 0; - - /* fall through */ - case 2: /* priviledged */ - failure; /* Easy ones first */ - break; - case 3: /* privileged if size == word */ - if (curi->size == sz_byte) - break; - failure; - break; - } - switch (curi->size) { - case sz_byte: - ssize = "b"; - break; - case sz_word: - ssize = "w"; - break; - case sz_long: - ssize = "l"; - break; - default: - abort(); - } - (void) ssize; - - switch (curi->mnemo) { - case i_AND: -#ifdef DISABLE_I_OR_AND_EOR - failure; -#endif - gen_and(opcode, curi, ssize); - break; - - case i_OR: -#ifdef DISABLE_I_OR_AND_EOR - failure; -#endif - gen_or(opcode, curi, ssize); - break; - - case i_EOR: -#ifdef DISABLE_I_OR_AND_EOR - failure; -#endif - gen_eor(opcode, curi, ssize); - break; - - case i_ORSR: -#ifdef DISABLE_I_ORSR_EORSR_ANDSR - failure; -#endif - gen_orsr(opcode, curi, ssize); - break; - - case i_EORSR: -#ifdef DISABLE_I_ORSR_EORSR_ANDSR - failure; -#endif - gen_eorsr(opcode, curi, ssize); - break; - - case i_ANDSR: -#ifdef DISABLE_I_ORSR_EORSR_ANDSR - failure; -#endif - gen_andsr(opcode, curi, ssize); - break; - - case i_SUB: -#ifdef DISABLE_I_SUB - failure; -#endif - gen_sub(opcode, curi, ssize); - break; - - case i_SUBA: -#ifdef DISABLE_I_SUBA - failure; -#endif - gen_suba(opcode, curi, ssize); - break; - - case i_SUBX: -#ifdef DISABLE_I_SUBX - failure; -#endif - gen_subx(opcode, curi, ssize); - break; - - case i_SBCD: - failure; - break; - - case i_ADD: -#ifdef DISABLE_I_ADD - failure; -#endif - gen_add(opcode, curi, ssize); - break; - - case i_ADDA: -#ifdef DISABLE_I_ADDA - failure; -#endif - gen_adda(opcode, curi, ssize); - break; - - case i_ADDX: -#ifdef DISABLE_I_ADDX - failure; -#endif - gen_addx(opcode, curi, ssize); - break; - - case i_ABCD: - failure; - break; - - case i_NEG: -#ifdef DISABLE_I_NEG - failure; -#endif - gen_neg(opcode, curi, ssize); - break; - - case i_NEGX: -#ifdef DISABLE_I_NEGX - failure; -#endif - gen_negx(opcode, curi, ssize); - break; - - case i_NBCD: - failure; - break; - - case i_CLR: -#ifdef DISABLE_I_CLR - failure; -#endif - gen_clr(opcode, curi, ssize); - break; - - case i_NOT: -#ifdef DISABLE_I_NOT - failure; -#endif - gen_not(opcode, curi, ssize); - break; - - case i_TST: -#ifdef DISABLE_I_TST - failure; -#endif - gen_tst(opcode, curi, ssize); - break; - - case i_BCHG: -#ifdef DISABLE_I_BCHG_BCLR_BSET_BTST - failure; -#endif - gen_bchg(opcode, curi, ssize); - break; - - case i_BCLR: -#ifdef DISABLE_I_BCHG_BCLR_BSET_BTST - failure; -#endif - gen_bclr(opcode, curi, ssize); - break; - - case i_BSET: -#ifdef DISABLE_I_BCHG_BCLR_BSET_BTST - failure; -#endif - gen_bset(opcode, curi, ssize); - break; - - case i_BTST: -#ifdef DISABLE_I_BCHG_BCLR_BSET_BTST - failure; -#endif - gen_btst(opcode, curi, ssize); - break; - - case i_CMPM: - case i_CMP: -#ifdef DISABLE_I_CMPM_CMP - failure; -#endif - gen_cmp(opcode, curi, ssize); - break; - - case i_CMPA: -#ifdef DISABLE_I_CMPA - failure; -#endif - gen_cmpa(opcode, curi, ssize); - break; - - /* The next two are coded a little unconventional, but they are doing - * weird things... */ - case i_MVPRM: - isjump; - failure; - break; - - case i_MVPMR: - isjump; - failure; - break; - - case i_MOVE: -#ifdef DISABLE_I_MOVE - failure; -#endif - gen_move(opcode, curi, ssize); - break; - - case i_MOVEA: -#ifdef DISABLE_I_MOVEA - failure; -#endif - gen_movea(opcode, curi, ssize); - break; - - case i_MVSR2: - isjump; - failure; - break; - - case i_MV2SR: - isjump; - failure; - break; - - case i_SWAP: -#ifdef DISABLE_I_SWAP - failure; -#endif - gen_swap(opcode, curi, ssize); - break; - - case i_EXG: -#ifdef DISABLE_I_EXG - failure; -#endif - gen_exg(opcode, curi, ssize); - break; - - case i_EXT: -#ifdef DISABLE_I_EXT - failure; -#endif - gen_ext(opcode, curi, ssize); - break; - - case i_MVMEL: -#ifdef DISABLE_I_MVMEL - failure; -#endif - genmovemel(opcode); - break; - - case i_MVMLE: -#ifdef DISABLE_I_MVMLE - failure; -#endif - genmovemle(opcode); - break; - - case i_TRAP: - isjump; - failure; - break; - - case i_MVR2USP: - isjump; - failure; - break; - - case i_MVUSP2R: - isjump; - failure; - break; - - case i_RESET: - isjump; - failure; - break; - - case i_NOP: - break; - - case i_STOP: - isjump; - failure; - break; - - case i_RTE: - isjump; - failure; - break; - - case i_RTD: -#ifdef DISABLE_I_RTD - failure; -#endif - genamode_new(curi->smode, "srcreg", curi->size, "offs", 1, 0); - /* offs is constant */ - comprintf("\tarm_ADD_l_ri8(offs,4);\n"); - start_brace(); - comprintf("\tint newad=scratchie++;\n" - "\treadlong(15,newad);\n" - "\tmov_l_mr((uintptr)®s.pc,newad);\n" - "\tget_n_addr_jmp(newad,PC_P);\n" - "\tmov_l_mr((uintptr)®s.pc_oldp,PC_P);\n" - "\tm68k_pc_offset=0;\n" - "\tarm_ADD_l(15,offs);\n"); - gen_update_next_handler(); - isjump; - break; - - case i_LINK: -#ifdef DISABLE_I_LINK - failure; -#endif - genamode_new(curi->smode, "srcreg", sz_long, "src", 1, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "offs", 1, 0); - comprintf("\tsub_l_ri(15,4);\n" - "\twritelong_clobber(15,src);\n" - "\tmov_l_rr(src,15);\n"); - comprintf("\tarm_ADD_l(15,offs);\n"); - genastore("src", curi->smode, "srcreg", sz_long, "src"); - break; - - case i_UNLK: -#ifdef DISABLE_I_UNLK - failure; -#endif - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - comprintf("\tmov_l_rr(15,src);\n" - "\treadlong(15,src);\n" - "\tarm_ADD_l_ri8(15,4);\n"); - genastore("src", curi->smode, "srcreg", curi->size, "src"); - break; - - case i_RTS: -#ifdef DISABLE_I_RTS - failure; -#endif - comprintf("\tint newad=scratchie++;\n" - "\treadlong(15,newad);\n" - "\tmov_l_mr((uintptr)®s.pc,newad);\n" - "\tget_n_addr_jmp(newad,PC_P);\n" - "\tmov_l_mr((uintptr)®s.pc_oldp,PC_P);\n" - "\tm68k_pc_offset=0;\n" - "\tarm_ADD_l_ri8(15,4);\n"); - gen_update_next_handler(); - isjump; - break; - - case i_TRAPV: - isjump; - failure; - break; - - case i_RTR: - isjump; - failure; - break; - - case i_JSR: -#ifdef DISABLE_I_JSR - failure; -#endif - isjump; - genamode_new(curi->smode, "srcreg", curi->size, "src", 0, 0); - start_brace(); - comprintf("\tuae_u32 retadd=start_pc+((char *)comp_pc_p-(char *)start_pc_p)+m68k_pc_offset;\n"); - comprintf("\tint ret=scratchie++;\n" - "\tmov_l_ri(ret,retadd);\n" - "\tsub_l_ri(15,4);\n" - "\twritelong_clobber(15,ret);\n"); - comprintf("\tmov_l_mr((uintptr)®s.pc,srca);\n" - "\tget_n_addr_jmp(srca,PC_P);\n" - "\tmov_l_mr((uintptr)®s.pc_oldp,PC_P);\n" - "\tm68k_pc_offset=0;\n"); - gen_update_next_handler(); - break; - - case i_JMP: -#ifdef DISABLE_I_JMP - failure; -#endif - isjump; - genamode_new(curi->smode, "srcreg", curi->size, "src", 0, 0); - comprintf("\tmov_l_mr((uintptr)®s.pc,srca);\n" - "\tget_n_addr_jmp(srca,PC_P);\n" - "\tmov_l_mr((uintptr)®s.pc_oldp,PC_P);\n" - "\tm68k_pc_offset=0;\n"); - gen_update_next_handler(); - break; - - case i_BSR: -#ifdef DISABLE_I_BSR - failure; -#endif - is_const_jump; - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - start_brace(); - comprintf("\tuae_u32 retadd=start_pc+((char *)comp_pc_p-(char *)start_pc_p)+m68k_pc_offset;\n"); - comprintf("\tint ret=scratchie++;\n" - "\tmov_l_ri(ret,retadd);\n" - "\tsub_l_ri(15,4);\n" - "\twritelong_clobber(15,ret);\n"); - comprintf("\tarm_ADD_l_ri(src,m68k_pc_offset_thisinst+2);\n"); - comprintf("\tm68k_pc_offset=0;\n"); - comprintf("\tarm_ADD_l(PC_P,src);\n"); - comprintf("\tcomp_pc_p=(uae_u8*)(uintptr)get_const(PC_P);\n"); - break; - - case i_Bcc: -#ifdef DISABLE_I_BCC - failure; -#endif - comprintf("\tuae_u32 v1, v2;\n"); - genamode_new(curi->smode, "srcreg", curi->size, "src", 1, 0); - /* That source is an immediate, so we can clobber it with abandon */ - comprintf("\tsub_l_ri(src, m68k_pc_offset - m68k_pc_offset_thisinst - 2);\n"); - /* Leave the following as "add" --- it will allow it to be optimized - away due to src being a constant ;-) */ - comprintf("\tarm_ADD_l_ri(src, (uintptr)comp_pc_p);\n"); - comprintf("\tmov_l_ri(PC_P, (uintptr)comp_pc_p);\n"); - /* Now they are both constant. Might as well fold in m68k_pc_offset */ - comprintf("\tarm_ADD_l_ri(src, m68k_pc_offset);\n"); - comprintf("\tarm_ADD_l_ri(PC_P, m68k_pc_offset);\n"); - comprintf("\tm68k_pc_offset = 0;\n"); - - if (curi->cc >= 2) { - comprintf("\tv1 = get_const(PC_P);\n"); - comprintf("\tv2 = get_const(src);\n"); - comprintf("\tregister_branch(v1, v2, %d);\n", cond_codes[curi->cc]); - comprintf("\tmake_flags_live();\n"); /* Load the flags */ - isjump; - } else { - is_const_jump; - } - - switch (curi->cc) { - case 0: /* Unconditional jump */ - comprintf("\tmov_l_rr(PC_P, src);\n"); - comprintf("\tcomp_pc_p = (uae_u8*)(uintptr)get_const(PC_P);\n"); - break; - case 1: - break; /* This is silly! */ - case 8: - failure; - break; /* Work out details! FIXME */ - case 9: - failure; - break; /* Not critical, though! */ - - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - break; - default: - abort(); - } - break; - - case i_LEA: -#ifdef DISABLE_I_LEA - failure; -#endif - genamode_new(curi->smode, "srcreg", curi->size, "src", 0, 0); - genamode_new(curi->dmode, "dstreg", curi->size, "dst", 2, 0); - genamode_post(curi->smode, "srcreg", curi->size, "src", 0, 0); - genastore("srca", curi->dmode, "dstreg", curi->size, "dst"); - break; - - case i_PEA: -#ifdef DISABLE_I_PEA - failure; -#endif - comprintf("\tint dodgy=0;\n"); - if (table68k[opcode].smode == Areg - || table68k[opcode].smode == Aind - || table68k[opcode].smode == Aipi - || table68k[opcode].smode == Apdi - || table68k[opcode].smode == Ad16 - || table68k[opcode].smode == Ad8r) - comprintf("if (srcreg==7) dodgy=1;\n"); - - genamode(curi->smode, "srcreg", curi->size, "src", 0, 0); - genamode(Apdi, "7", sz_long, "dst", 2, 0); - genastore("srca", Apdi, "7", sz_long, "dst"); - break; - - case i_DBcc: -#ifdef DISABLE_I_DBCC - failure; -#endif - gen_dbcc(opcode, curi, ssize); - break; - - case i_Scc: -#ifdef DISABLE_I_SCC - failure; -#endif - gen_scc(opcode, curi, ssize); - break; - - case i_DIVU: -#ifdef DISABLE_I_DIVU - isjump; - failure; -#endif - gen_divu(opcode, curi, ssize); - break; - - case i_DIVS: -#ifdef DISABLE_I_DIVS - isjump; - failure; -#endif - gen_divs(opcode, curi, ssize); - break; - - case i_MULU: -#ifdef DISABLE_I_MULU - failure; -#endif - gen_mulu(opcode, curi, ssize); - break; - - case i_MULS: -#ifdef DISABLE_I_MULS - failure; -#endif - gen_muls(opcode, curi, ssize); - break; - - case i_CHK: - isjump; - failure; - break; - - case i_CHK2: - isjump; - failure; - break; - - case i_ASR: -#ifdef DISABLE_I_ASR - failure; -#endif - gen_asr(opcode, curi, ssize); - break; - - case i_ASL: -#ifdef DISABLE_I_ASL - failure; -#endif - gen_asl(opcode, curi, ssize); - break; - - case i_LSR: -#ifdef DISABLE_I_LSR - failure; -#endif - gen_lsr(opcode, curi, ssize); - break; - - case i_LSL: -#ifdef DISABLE_I_LSL - failure; -#endif - gen_lsl(opcode, curi, ssize); - break; - - case i_ROL: -#ifdef DISABLE_I_ROL - failure; -#endif - gen_rol(opcode, curi, ssize); - break; - - case i_ROR: -#ifdef DISABLE_I_ROR - failure; -#endif - gen_ror(opcode, curi, ssize); - break; - - case i_ROXL: -#ifdef DISABLE_I_ROXL - failure; -#endif - gen_roxl(opcode, curi, ssize); - break; - - case i_ROXR: -#ifdef DISABLE_I_ROXR - failure; -#endif - gen_roxr(opcode, curi, ssize); - break; - - case i_ASRW: -#ifdef DISABLE_I_ASRW - failure; -#endif - gen_asrw(opcode, curi, ssize); - break; - - case i_ASLW: -#ifdef DISABLE_I_ASLW - failure; -#endif - gen_aslw(opcode, curi, ssize); - break; - - case i_LSRW: -#ifdef DISABLE_I_LSRW - failure; -#endif - gen_lsrw(opcode, curi, ssize); - break; - - case i_LSLW: -#ifdef DISABLE_I_LSLW - failure; -#endif - gen_lslw(opcode, curi, ssize); - break; - - case i_ROLW: -#ifdef DISABLE_I_ROLW - failure; -#endif - gen_rolw(opcode, curi, ssize); - break; - - case i_RORW: -#ifdef DISABLE_I_RORW - failure; -#endif - gen_rorw(opcode, curi, ssize); - break; - - case i_ROXLW: -#ifdef DISABLE_I_ROXLW - failure; -#endif - gen_roxlw(opcode, curi, ssize); - break; - - case i_ROXRW: -#ifdef DISABLE_I_ROXRW - failure; -#endif - gen_roxrw(opcode, curi, ssize); - break; - - case i_MOVEC2: - isjump; - failure; - break; - - case i_MOVE2C: - isjump; - failure; - break; - - case i_CAS: - failure; - break; - - case i_CAS2: - failure; - break; - - case i_MOVES: /* ignore DFC and SFC because we have no MMU */ - isjump; - failure; - break; - - case i_BKPT: /* only needed for hardware emulators */ - isjump; - failure; - break; - - case i_CALLM: /* not present in 68030 */ - isjump; - failure; - break; - - case i_RTM: /* not present in 68030 */ - isjump; - failure; - break; - - case i_TRAPcc: - isjump; - failure; - break; - - case i_DIVL: -#ifdef DISABLE_I_DIVL - failure; -#endif - gen_divl(opcode, curi, ssize); - break; - - case i_MULL: -#ifdef DISABLE_I_MULL - failure; -#endif - gen_mull(opcode, curi, ssize); - break; - - case i_BFTST: - case i_BFEXTU: - case i_BFCHG: - case i_BFEXTS: - case i_BFCLR: - case i_BFFFO: - case i_BFSET: - case i_BFINS: - failure; - break; - - case i_PACK: - failure; - break; - - case i_UNPK: - failure; - break; - - case i_TAS: - failure; - break; - - case i_FPP: -#ifdef DISABLE_I_FPP - failure; -#endif - uses_fpu; - mayfail; - comprintf("#ifdef USE_JIT_FPU\n"); - comprintf("\tuae_u16 extra=%s;\n",gen_nextiword()); - swap_opcode(); - comprintf("\tcomp_fpp_opp(opcode,extra);\n"); - comprintf("#else\n"); - comprintf("\tfailure = 1;\n"); - comprintf("#endif\n"); - break; - - case i_FBcc: -#ifdef DISABLE_I_FBCC - failure; -#endif - isjump; - uses_cmov; - mayfail; - comprintf("#ifdef USE_JIT_FPU\n"); - swap_opcode(); - comprintf("\tcomp_fbcc_opp(opcode);\n"); - comprintf("#else\n"); - comprintf("\tfailure = 1;\n"); - comprintf("#endif\n"); - break; - - case i_FDBcc: - uses_fpu; - isjump; - failure; - break; - - case i_FScc: -#ifdef DISABLE_I_FSCC - failure; -#endif - mayfail; - uses_cmov; - comprintf("#ifdef USE_JIT_FPU\n"); - comprintf("\tuae_u16 extra=%s;\n",gen_nextiword()); - swap_opcode(); - comprintf("\tcomp_fscc_opp(opcode,extra);\n"); - comprintf("#else\n"); - comprintf("\tfailure = 1;\n"); - comprintf("#endif\n"); - break; - - case i_FTRAPcc: - uses_fpu; - isjump; - failure; - break; - - case i_FSAVE: - uses_fpu; - failure; - break; - - case i_FRESTORE: - uses_fpu; - failure; - break; - - case i_CINVL: - case i_CINVP: - case i_CINVA: - isjump; /* Not really, but it's probably a good idea to stop - translating at this point */ - failure; - comprintf("\tflush_icache(0, 3);\n"); /* Differentiate a bit more? */ - break; - - case i_CPUSHL: - case i_CPUSHP: - case i_CPUSHA: - isjump; /* Not really, but it's probably a good idea to stop - translating at this point */ - failure; - break; - - case i_MOVE16: -#ifdef DISABLE_I_MOVE16 - failure; -#endif - gen_move16(opcode, curi); - break; - - case i_MMUOP030: - case i_PFLUSHN: - case i_PFLUSH: - case i_PFLUSHAN: - case i_PFLUSHA: - case i_PLPAR: - case i_PLPAW: - case i_PTESTR: - case i_PTESTW: - case i_LPSTOP: - isjump; - failure; - break; - - default: - abort(); - break; - } - comprintf("%s", endstr); - finish_braces(); - sync_m68k_pc(); - if (global_mayfail) - comprintf("\tif (failure) m68k_pc_offset=m68k_pc_offset_thisinst;\n"); - return global_failure; -} - -static void -generate_includes(FILE * f) -{ - fprintf (f, "#include \"sysconfig.h\"\n"); - fprintf (f, "#if defined(JIT)\n"); - fprintf(f, "#include \"sysdeps.h\"\n"); - fprintf (f, "#include \"options.h\"\n"); - fprintf(f, "#include \"memory.h\"\n"); - fprintf(f, "#include \"newcpu.h\"\n"); - fprintf (f, "#include \"custom.h\"\n"); - fprintf(f, "#include \"comptbl.h\"\n"); -} - -static int postfix; - - -static char *decodeEA (amodes mode, wordsizes size) -{ - static char buffer[80]; - - buffer[0] = 0; - switch (mode){ - case Dreg: - strcpy (buffer,"Dn"); - break; - case Areg: - strcpy (buffer,"An"); - break; - case Aind: - strcpy (buffer,"(An)"); - break; - case Aipi: - strcpy (buffer,"(An)+"); - break; - case Apdi: - strcpy (buffer,"-(An)"); - break; - case Ad16: - strcpy (buffer,"(d16,An)"); - break; - case Ad8r: - strcpy (buffer,"(d8,An,Xn)"); - break; - case PC16: - strcpy (buffer,"(d16,PC)"); - break; - case PC8r: - strcpy (buffer,"(d8,PC,Xn)"); - break; - case absw: - strcpy (buffer,"(xxx).W"); - break; - case absl: - strcpy (buffer,"(xxx).L"); - break; - case imm: - switch (size){ - case sz_byte: - strcpy (buffer,"#.B"); - break; - case sz_word: - strcpy (buffer,"#.W"); - break; - case sz_long: - strcpy (buffer,"#.L"); - break; - default: - break; - } - break; - case imm0: - strcpy (buffer,"#.B"); - break; - case imm1: - strcpy (buffer,"#.W"); - break; - case imm2: - strcpy (buffer,"#.L"); - break; - case immi: - strcpy (buffer,"#"); - break; - - default: - break; - } - return buffer; -} - -static char *outopcode (int opcode) -{ - static char out[100]; - struct instr *ins; - int i; - - ins = &table68k[opcode]; - for (i = 0; lookuptab[i].name[0]; i++) { - if (ins->mnemo == lookuptab[i].mnemo) - break; - } - { - strcpy (out, lookuptab[i].name); - } - if (ins->smode == immi) - strcat (out, "Q"); - if (ins->size == sz_byte) - strcat (out,".B"); - if (ins->size == sz_word) - strcat (out,".W"); - if (ins->size == sz_long) - strcat (out,".L"); - strcat (out," "); - if (ins->suse) - strcat (out, decodeEA (ins->smode, ins->size)); - if (ins->duse) { - if (ins->suse) strcat (out,","); - strcat (out, decodeEA (ins->dmode, ins->size)); - } - return out; -} - -static void generate_one_opcode(int rp, int noflags) -{ - int i; - uae_u16 smsk, dmsk; - unsigned int opcode = opcode_map[rp]; - int aborted = 0; - int have_srcreg = 0; - int have_dstreg = 0; - - if (table68k[opcode].mnemo == i_ILLG - || table68k[opcode].clev > cpu_level) - return; - - for (i = 0; lookuptab[i].name[0]; i++) - { - if (table68k[opcode].mnemo == lookuptab[i].mnemo) - break; - } - - if (table68k[opcode].handler != -1) - return; - - switch (table68k[opcode].stype) - { - case 0: - smsk = 7; - break; - case 1: - smsk = 255; - break; - case 2: - smsk = 15; - break; - case 3: - smsk = 7; - break; - case 4: - smsk = 7; - break; - case 5: - smsk = 63; - break; - case 6: - smsk = 255; - break; - case 7: - smsk = 3; - break; - default: - abort(); - } - dmsk = 7; - - next_cpu_level = -1; - if (table68k[opcode].mnemo == i_DIVU || table68k[opcode].mnemo == i_DIVS || table68k[opcode].mnemo == i_DIVL) { - comprintf("#ifndef ARMV6T2\n"); - comprintf(" FAIL(1);\n"); - comprintf(" " RETURN "\n"); - comprintf("#else\n"); - } - - if (table68k[opcode].suse - && table68k[opcode].smode != imm && table68k[opcode].smode != imm0 - && table68k[opcode].smode != imm1 && table68k[opcode].smode != imm2 - && table68k[opcode].smode != absw && table68k[opcode].smode != absl - && table68k[opcode].smode != PC8r && table68k[opcode].smode != PC16) - { - have_srcreg = 1; - if (table68k[opcode].spos == -1) - { - if (((int) table68k[opcode].sreg) >= 128) - comprintf("\tuae_s32 srcreg = (uae_s32)(uae_s8)%d;\n", (int) table68k[opcode].sreg); - else - comprintf("\tuae_s32 srcreg = %d;\n", (int) table68k[opcode].sreg); - } - else - { - char source[100]; - int pos = table68k[opcode].spos; - - if (pos) - sprintf(source, "((opcode >> %d) & %d)", pos, smsk); - else - sprintf(source, "(opcode & %d)", smsk); - - if (table68k[opcode].stype == 3) - comprintf("\tuae_s32 srcreg = imm8_table[%s];\n", source); - else if (table68k[opcode].stype == 1) - comprintf("\tuae_s32 srcreg = (uae_s32)(uae_s8)%s;\n", source); - else - comprintf("\tuae_s32 srcreg = %s;\n", source); - } - } - if (table68k[opcode].duse - /* Yes, the dmode can be imm, in case of LINK or DBcc */ - && table68k[opcode].dmode != imm && table68k[opcode].dmode != imm0 - && table68k[opcode].dmode != imm1 && table68k[opcode].dmode != imm2 - && table68k[opcode].dmode != absw && table68k[opcode].dmode != absl) - { - have_dstreg = 1; - if (table68k[opcode].dpos == -1) - { - if (((int) table68k[opcode].dreg) >= 128) - comprintf("\tuae_s32 dstreg = (uae_s32)(uae_s8)%d;\n", (int) table68k[opcode].dreg); - else - comprintf("\tuae_s32 dstreg = %d;\n", (int) table68k[opcode].dreg); - } - else - { - int pos = table68k[opcode].dpos; - - if (pos) - comprintf("\tuae_u32 dstreg = (opcode >> %d) & %d;\n", - pos, dmsk); - else - comprintf("\tuae_u32 dstreg = opcode & %d;\n", dmsk); - } - } - - comprintf("\tuae_u32 m68k_pc_offset_thisinst=m68k_pc_offset;\n"); - comprintf("\tm68k_pc_offset+=2;\n"); - - aborted = gen_opcode(opcode); - { - int flags = 0; - if (global_isjump) flags |= 1; - if (long_opcode) flags |= 2; - if (global_cmov) flags |= 4; - if (global_isaddx) flags |= 8; - if (global_iscjump) flags |= 16; - if (global_fpu) flags |= 32; - - comprintf ("return 0;\n"); - if (table68k[opcode].mnemo == i_DIVU || table68k[opcode].mnemo == i_DIVS || table68k[opcode].mnemo == i_DIVL) { - comprintf("#endif\n"); - } - - comprintf("}\n"); - - char name[100] = { 0 }; - for (int k = 0; lookuptab[i].name[k]; k++) - name[k] = lookuptab[i].name[k]; - - if (aborted) { - fprintf(stblfile, "{ NULL, 0x%08x, %ld }, /* %s */\n", flags, opcode, name); - com_discard(); - } else { - printf ("/* %s */\n", outopcode (opcode)); - if (noflags) { - fprintf(stblfile, "{ op_%lx_%d_comp_nf, 0x%08x, %ld }, /* %s */\n", opcode, postfix, flags, opcode, name); - fprintf(headerfile, "extern compop_func op_%lx_%d_comp_nf;\n", opcode, postfix); - printf("uae_u32 REGPARAM2 op_%lx_%d_comp_nf(uae_u32 opcode)\n{\n", opcode, postfix); - } else { - fprintf(stblfile, "{ op_%lx_%d_comp_ff, 0x%08x, %ld }, /* %s */\n", opcode, postfix, flags, opcode, name); - fprintf(headerfile, "extern compop_func op_%lx_%d_comp_ff;\n", opcode, postfix); - printf("uae_u32 REGPARAM2 op_%lx_%d_comp_ff(uae_u32 opcode)\n{\n", opcode, postfix); - } - com_flush(); - } - } - - opcode_next_clev[rp] = next_cpu_level; - opcode_last_postfix[rp] = postfix; -} - -static void generate_func(int noflags) -{ - int i, j, rp; - const char *tbl = noflags ? "nf" : "ff"; - - using_prefetch = 0; - using_exception_3 = 0; - for (i = 0; i < 1; i++) /* We only do one level! */ - { - cpu_level = NEXT_CPU_LEVEL - i; - postfix = i; - - fprintf(stblfile, "extern const struct comptbl op_smalltbl_%d_comp_%s[] = {\n", postfix, tbl); - - /* sam: this is for people with low memory (eg. me :)) */ - printf("\n" - "#if !defined(PART_1) && !defined(PART_2) && " - "!defined(PART_3) && !defined(PART_4) && " - "!defined(PART_5) && !defined(PART_6) && " - "!defined(PART_7) && !defined(PART_8)" - "\n" - "#define PART_1 1\n" - "#define PART_2 1\n" - "#define PART_3 1\n" - "#define PART_4 1\n" - "#define PART_5 1\n" - "#define PART_6 1\n" - "#define PART_7 1\n" - "#define PART_8 1\n" - "#endif\n\n"); - printf ("extern void comp_fpp_opp();\n" - "extern void comp_fscc_opp();\n" - "extern void comp_fbcc_opp();\n\n"); - - rp = 0; - for (j = 1; j <= 8; ++j) - { - int k = (j * nr_cpuop_funcs) / 8; - printf("#ifdef PART_%d\n", j); - for (; rp < k; rp++) - generate_one_opcode(rp, noflags); - printf("#endif\n\n"); - } - - fprintf(stblfile, "{ 0, 0,65536 }};\n"); - } - -} - -int main(int argc, char *argv[]) -{ - read_table68k(); - do_merges(); - - 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(); - - /* It would be a lot nicer to put all in one file (we'd also get rid of - * cputbl.h that way), but cpuopti can't cope. That could be fixed, but - * I don't dare to touch the 68k version. */ - - headerfile = fopen("jit/comptbl.h", "wb"); - - fprintf (headerfile, "" \ - "extern const struct comptbl op_smalltbl_0_comp_nf[];\n" \ - "extern const struct comptbl op_smalltbl_0_comp_ff[];\n" \ - ""); - - stblfile = fopen("jit/compstbl.cpp", "wb"); - freopen("jit/compemu.cpp", "wb", stdout); - - generate_includes(stdout); - generate_includes(stblfile); - - printf("#include \"compemu.h\"\n"); - - noflags = 0; - generate_func(noflags); - - free(opcode_map); - free(opcode_last_postfix); - free(opcode_next_clev); - free(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); - read_counts(); - noflags = 1; - generate_func(noflags); - - printf ("#endif\n"); - fprintf (stblfile, "#endif\n"); - - free(opcode_map); - free(opcode_last_postfix); - free(opcode_next_clev); - free(counts); - - free(table68k); - fclose(stblfile); - fclose(headerfile); - return 0; -} diff --git a/src/keybuf.cpp b/src/keybuf.cpp index df4de01b..09d4811a 100644 --- a/src/keybuf.cpp +++ b/src/keybuf.cpp @@ -11,17 +11,16 @@ * * Copyright 1995, 1997 Bernd Schmidt */ - -#include "sysconfig.h" -#include "sysdeps.h" +#include +#include #include +#include "sysdeps.h" + #include "options.h" #include "keybuf.h" -#include "keyboard.h" #include "inputdevice.h" #include "custom.h" -#include "savestate.h" static int kpb_first, kpb_last; diff --git a/src/linetoscr.cpp b/src/linetoscr.cpp.in similarity index 100% rename from src/linetoscr.cpp rename to src/linetoscr.cpp.in diff --git a/src/machdep/support.cpp b/src/machdep/support.cpp index 69bf3340..29aee3a5 100644 --- a/src/machdep/support.cpp +++ b/src/machdep/support.cpp @@ -1,10 +1,3 @@ -#include "config.h" -#include "sysconfig.h" - -#include -#include -#include - #include "sysdeps.h" #include "options.h" #include "memory.h" diff --git a/src/main.cpp b/src/main.cpp index 0080d9ef..228188df 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,16 +6,21 @@ * Copyright 1995 Ed Hanway * Copyright 1995, 1996, 1997 Bernd Schmidt */ -#include "sysconfig.h" +#include +#include +#include + +#include +#include + #include "sysdeps.h" -#include #include "options.h" #include "threaddep/thread.h" #include "uae.h" #include "gensound.h" #include "audio.h" -#include "include/memory.h" +#include "memory.h" #include "custom.h" #include "newcpu.h" #include "disk.h" @@ -28,14 +33,9 @@ #include "picasso96.h" #include "native2amiga.h" #include "savestate.h" -#include "filesys.h" #include "blkdev.h" #include "gfxboard.h" #include "devices.h" -#include "jit/compemu.h" -#include -#include "amiberry_gfx.h" -#include "SDL.h" #ifdef USE_SDL2 SDL_Window* sdlWindow; diff --git a/src/memory.cpp b/src/memory.cpp index 838b303f..65a12224 100644 --- a/src/memory.cpp +++ b/src/memory.cpp @@ -6,7 +6,9 @@ * (c) 1995 Bernd Schmidt */ -#include "sysconfig.h" +#include +#include + #include "sysdeps.h" #include "options.h" @@ -22,9 +24,7 @@ #include "crc32.h" #include "gui.h" #include "akiko.h" -#include "threaddep/thread.h" #include "gayle.h" -#include "gfxboard.h" #include "audio.h" #include "devices.h" diff --git a/src/native2amiga.cpp b/src/native2amiga.cpp index 33e7fd68..8a453191 100644 --- a/src/native2amiga.cpp +++ b/src/native2amiga.cpp @@ -9,16 +9,10 @@ * and needs thread support. */ -#include "sysconfig.h" #include "sysdeps.h" #include "threaddep/thread.h" -#include "options.h" -#include "include/memory.h" -#include "custom.h" -#include "newcpu.h" #include "autoconf.h" -#include "traps.h" #include "native2amiga.h" smp_comm_pipe native2amiga_pending; diff --git a/src/newcpu.cpp b/src/newcpu.cpp index 85af3a06..65b37b0c 100644 --- a/src/newcpu.cpp +++ b/src/newcpu.cpp @@ -5,8 +5,12 @@ * * (c) 1995 Bernd Schmidt */ +#include +#include +#include +#include +#include -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" @@ -15,17 +19,12 @@ #include "custom.h" #include "newcpu.h" #include "cpummu.h" -#include "cpu_prefetch.h" #include "autoconf.h" -#include "traps.h" #include "gui.h" #include "savestate.h" #include "blitter.h" #include "ar.h" -#include "cia.h" -#include "inputdevice.h" #include "audio.h" -#include "fpp.h" #include "threaddep/thread.h" #include "bsdsocket.h" #include "statusline.h" diff --git a/src/newcpu_common.cpp b/src/newcpu_common.cpp index 06e95d91..0e240449 100644 --- a/src/newcpu_common.cpp +++ b/src/newcpu_common.cpp @@ -1,10 +1,11 @@ -#include "sysconfig.h" +#include +#include + #include "sysdeps.h" #include "options.h" #include "memory.h" #include "newcpu.h" -#include "cpu_prefetch.h" int movec_illg (int regno) { diff --git a/src/osdep/amiberry.cpp b/src/osdep/amiberry.cpp index d0e60e40..5ee8c9f9 100644 --- a/src/osdep/amiberry.cpp +++ b/src/osdep/amiberry.cpp @@ -4,21 +4,21 @@ * Amiberry interface * */ +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include #ifndef ANDROID #include #endif -#include "sysconfig.h" #include "sysdeps.h" -#include "config.h" #include "uae.h" #include "options.h" #include "custom.h" @@ -27,11 +27,7 @@ #include "savestate.h" #include "rommgr.h" #include "zfile.h" -#include #include "amiberry_rp9.h" -#include "machdep/rpt.h" - -#include "threaddep/thread.h" #include "include/memory.h" #include "keyboard.h" #include "rtgmodes.h" diff --git a/src/osdep/amiberry_filesys.cpp b/src/osdep/amiberry_filesys.cpp index e08cfdd8..f41e397e 100644 --- a/src/osdep/amiberry_filesys.cpp +++ b/src/osdep/amiberry_filesys.cpp @@ -1,10 +1,12 @@ -#include -#include +#include +#include +#include #include -#include "sysconfig.h" +#include +#include +#include + #include "sysdeps.h" -#include "config.h" -#include "zfile.h" #include "options.h" diff --git a/src/osdep/amiberry_gfx.cpp b/src/osdep/amiberry_gfx.cpp index 5e9e8b05..e9d132b8 100644 --- a/src/osdep/amiberry_gfx.cpp +++ b/src/osdep/amiberry_gfx.cpp @@ -1,22 +1,20 @@ -#include "sysconfig.h" +#include +#include +#include +#include +#include + #include "sysdeps.h" -#include "config.h" #include "uae.h" #include "options.h" -#include "gui.h" -#include "memory.h" -#include "newcpu.h" #include "custom.h" #include "xwin.h" #include "drawing.h" -#include "inputdevice.h" #include "savestate.h" #include "picasso96.h" #include "amiberry_gfx.h" #include -#include -#include #ifdef USE_SDL1 #include #include diff --git a/src/osdep/amiberry_gui.cpp b/src/osdep/amiberry_gui.cpp index 7a9430a6..45b6b5e1 100644 --- a/src/osdep/amiberry_gui.cpp +++ b/src/osdep/amiberry_gui.cpp @@ -1,7 +1,10 @@ -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include + #ifdef USE_SDL1 #include #include @@ -10,7 +13,6 @@ #include #include #endif -#include "sysconfig.h" #include "sysdeps.h" #include "uae.h" #include "options.h" @@ -19,24 +21,12 @@ #include "gui.h" #include "osdep/gui/SelectorEntry.hpp" #include "gui/gui_handling.h" -#include "include/memory.h" #include "rommgr.h" -#include "newcpu.h" #include "custom.h" #include "inputdevice.h" -#include "xwin.h" -#include "drawing.h" #include "sounddep/sound.h" -#include "audio.h" -#include "keybuf.h" -#include "keyboard.h" -#include "disk.h" #include "savestate.h" -#include "filesys.h" -#include "autoconf.h" #include "blkdev.h" -#include -#include "threaddep/thread.h" #ifdef AMIBERRY #include diff --git a/src/osdep/amiberry_hardfile.cpp b/src/osdep/amiberry_hardfile.cpp index 0ef4f83f..6faffada 100644 --- a/src/osdep/amiberry_hardfile.cpp +++ b/src/osdep/amiberry_hardfile.cpp @@ -1,7 +1,10 @@ -#include "sysconfig.h" +#include +#include +#include +#include + #include "sysdeps.h" -#include "threaddep/thread.h" #include "options.h" #include "filesys.h" #include "zfile.h" diff --git a/src/osdep/amiberry_input.cpp b/src/osdep/amiberry_input.cpp index 98e0f818..9af0063b 100644 --- a/src/osdep/amiberry_input.cpp +++ b/src/osdep/amiberry_input.cpp @@ -1,15 +1,14 @@ -#include "sysconfig.h" +#include +#include +#include +#include + #include "sysdeps.h" -#include "config.h" #include "options.h" -#include "keyboard.h" #include "inputdevice.h" -#include #include "zfile.h" /// Horace added #include /// Horace added -#include /// Horace added (to remove) -#include /// Horace added /* atol */ #include static struct host_input_button default_controller_map; diff --git a/src/osdep/amiberry_mem.cpp b/src/osdep/amiberry_mem.cpp index d4ef1ade..255195fb 100644 --- a/src/osdep/amiberry_mem.cpp +++ b/src/osdep/amiberry_mem.cpp @@ -1,19 +1,14 @@ -#include "sysconfig.h" +#include +#include +#include + #include "sysdeps.h" -#include "config.h" -#include "uae.h" #include "options.h" -#include "gui.h" #include "include/memory.h" #include "newcpu.h" -#include "custom.h" #include "autoconf.h" -#include "akiko.h" -#include "ar.h" #include "uae/mman.h" #include -#include - static uae_u32 natmem_size; uae_u32 max_z3fastmem; diff --git a/src/osdep/amiberry_rp9.cpp b/src/osdep/amiberry_rp9.cpp index f781c92f..53fb3596 100644 --- a/src/osdep/amiberry_rp9.cpp +++ b/src/osdep/amiberry_rp9.cpp @@ -1,22 +1,19 @@ -#include "sysconfig.h" +#include +#include +#include +#include + #include "sysdeps.h" -#include "config.h" -#include "uae.h" #include "options.h" -#include "gui.h" #include "disk.h" #include "fsdb.h" #include "memory.h" #include "newcpu.h" #include "custom.h" #include "filesys.h" -#include "autoconf.h" #include "zfile.h" #include "archivers/zip/unzip.h" #include -#include -#include - #define RP9_MANIFEST _T("rp9-manifest.xml") #define MAX_MANIFEST_ENTRY 256 diff --git a/src/osdep/amiberry_whdbooter.cpp b/src/osdep/amiberry_whdbooter.cpp index b527aaef..0715627e 100644 --- a/src/osdep/amiberry_whdbooter.cpp +++ b/src/osdep/amiberry_whdbooter.cpp @@ -4,16 +4,15 @@ * Amiberry interface * */ +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include #ifndef ANDROID #endif -#include "sysconfig.h" #include "sysdeps.h" #include "uae.h" #include "options.h" @@ -31,17 +30,12 @@ extern FILE *debugfile; #include "fsdb.h" #include -#include -#include - -#include extern void SetLastActiveConfig(const char* filename); extern char currentDir[MAX_DPATH]; extern char last_loaded_config[MAX_DPATH]; #include /// Horace added -#include /// Horace added (to remove) struct game_options { diff --git a/src/osdep/bsdsocket_host.cpp b/src/osdep/bsdsocket_host.cpp index faef55cf..99af447d 100644 --- a/src/osdep/bsdsocket_host.cpp +++ b/src/osdep/bsdsocket_host.cpp @@ -21,16 +21,26 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" #include "include/memory.h" -#include "newcpu.h" -#include "custom.h" #include "autoconf.h" -#include "traps.h" #include "../threaddep/thread.h" #include "bsdsocket.h" #include "native2amiga.h" @@ -45,20 +55,15 @@ void bsdsock_fake_int_handler(void) #else -#include -#include #include #include #ifdef HAVE_SYS_FILIO_H # include #endif -#include -#include #include #include #include -#include //#define DEBUG_BSDSOCKET #ifdef DEBUG_BSDSOCKET diff --git a/src/osdep/cda_play.cpp b/src/osdep/cda_play.cpp index 24e742e5..c7ef6b65 100644 --- a/src/osdep/cda_play.cpp +++ b/src/osdep/cda_play.cpp @@ -1,12 +1,13 @@ -#include "sysconfig.h" +#include +#include +#include + #include "sysdeps.h" #include "audio.h" #include "cda_play.h" #include "sounddep/sound.h" -#include "uae.h" - cda_audio::~cda_audio() { diff --git a/src/osdep/charset.cpp b/src/osdep/charset.cpp index 664c006a..929d1193 100644 --- a/src/osdep/charset.cpp +++ b/src/osdep/charset.cpp @@ -1,4 +1,4 @@ -#include "sysconfig.h" +#include #include "sysdeps.h" #include diff --git a/src/osdep/fsdb_host.cpp b/src/osdep/fsdb_host.cpp index 43a04c1d..38722358 100644 --- a/src/osdep/fsdb_host.cpp +++ b/src/osdep/fsdb_host.cpp @@ -1,12 +1,13 @@ -#include "sysconfig.h" +#include +#include +#include + #include "sysdeps.h" -#include "config.h" #include "fsdb.h" #include "zfile.h" #include #include - int dos_errno(void) { int e = errno; diff --git a/src/osdep/gui/CreateFilesysHardfile.cpp b/src/osdep/gui/CreateFilesysHardfile.cpp index 754b0191..ca1a8bd9 100644 --- a/src/osdep/gui/CreateFilesysHardfile.cpp +++ b/src/osdep/gui/CreateFilesysHardfile.cpp @@ -1,3 +1,7 @@ +#include +#include +#include + #ifdef USE_SDL1 #include #include @@ -8,22 +12,14 @@ #include #include #endif -#include #include "SelectorEntry.hpp" -#include "UaeRadioButton.hpp" -#include "UaeDropDown.hpp" #include "UaeCheckBox.hpp" -#include "sysconfig.h" #include "sysdeps.h" #include "config.h" #include "options.h" -#include "include/memory.h" -#include "uae.h" -#include "autoconf.h" #include "filesys.h" -#include "gui.h" #include "gui_handling.h" #include "inputdevice.h" #include "amiberry_gfx.h" diff --git a/src/osdep/gui/EditFilesysHardfile.cpp b/src/osdep/gui/EditFilesysHardfile.cpp index 53c86106..2db355ab 100644 --- a/src/osdep/gui/EditFilesysHardfile.cpp +++ b/src/osdep/gui/EditFilesysHardfile.cpp @@ -1,3 +1,7 @@ +#include +#include +#include + #ifdef USE_SDL1 #include #include @@ -10,19 +14,14 @@ #include #endif #include "SelectorEntry.hpp" -#include "UaeRadioButton.hpp" #include "UaeDropDown.hpp" #include "UaeCheckBox.hpp" -#include "sysconfig.h" #include "sysdeps.h" #include "config.h" #include "options.h" -#include "memory.h" -#include "uae.h" #include "autoconf.h" #include "filesys.h" -#include "gui.h" #include "gui_handling.h" #include "inputdevice.h" diff --git a/src/osdep/gui/EditFilesysVirtual.cpp b/src/osdep/gui/EditFilesysVirtual.cpp index 2b3c288e..74b57527 100644 --- a/src/osdep/gui/EditFilesysVirtual.cpp +++ b/src/osdep/gui/EditFilesysVirtual.cpp @@ -1,3 +1,7 @@ +#include +#include +#include + #ifdef USE_SDL1 #include #include @@ -10,19 +14,12 @@ #include #endif #include "SelectorEntry.hpp" -#include "UaeRadioButton.hpp" -#include "UaeDropDown.hpp" #include "UaeCheckBox.hpp" -#include "sysconfig.h" #include "sysdeps.h" #include "config.h" #include "options.h" -#include "memory.h" -#include "uae.h" #include "autoconf.h" -#include "filesys.h" -#include "gui.h" #include "gui_handling.h" #include "inputdevice.h" diff --git a/src/osdep/gui/InGameMessage.cpp b/src/osdep/gui/InGameMessage.cpp index 1706d627..7413b6d1 100644 --- a/src/osdep/gui/InGameMessage.cpp +++ b/src/osdep/gui/InGameMessage.cpp @@ -1,3 +1,6 @@ +#include +#include + #ifdef USE_SDL1 #include #include @@ -12,15 +15,9 @@ #endif #include "SelectorEntry.hpp" -#include "sysconfig.h" #include "sysdeps.h" #include "config.h" #include "options.h" -#include "uae.h" -#include "custom.h" -#include "xwin.h" -#include "drawing.h" -#include "gui.h" #include "gui_handling.h" #include "amiberry_gfx.h" #include "inputdevice.h" diff --git a/src/osdep/gui/Navigation.cpp b/src/osdep/gui/Navigation.cpp index 5fcc1555..42c04ce7 100644 --- a/src/osdep/gui/Navigation.cpp +++ b/src/osdep/gui/Navigation.cpp @@ -1,3 +1,5 @@ +#include + #ifdef USE_SDL1 #include #include @@ -8,12 +10,9 @@ #include #endif #include "SelectorEntry.hpp" -#include "UaeRadioButton.hpp" #include "UaeDropDown.hpp" -#include "sysconfig.h" #include "sysdeps.h" -#include "config.h" #include "gui_handling.h" typedef struct @@ -470,4 +469,4 @@ void PushFakeKey(const SDL_Keycode inKey) nuevent.type = SDL_KEYUP; // and the key up gui_input->pushInput(nuevent); // Fire key down } -#endif \ No newline at end of file +#endif diff --git a/src/osdep/gui/PanelAbout.cpp b/src/osdep/gui/PanelAbout.cpp index bd435f86..32fb56c8 100644 --- a/src/osdep/gui/PanelAbout.cpp +++ b/src/osdep/gui/PanelAbout.cpp @@ -11,12 +11,7 @@ #endif #include "SelectorEntry.hpp" -#include "sysconfig.h" #include "sysdeps.h" -#include "config.h" -#include "options.h" -#include "uae.h" -#include "gui.h" #include "gui_handling.h" static gcn::Label* lblEmulatorVersion; @@ -90,4 +85,4 @@ bool HelpPanelAbout(std::vector &helptext) helptext.emplace_back("Here you can see the version information as well as"); helptext.emplace_back("the people behind the development of this emulator."); return true; -} \ No newline at end of file +} diff --git a/src/osdep/gui/PanelCPU.cpp b/src/osdep/gui/PanelCPU.cpp index 68f75725..82bc0cd4 100644 --- a/src/osdep/gui/PanelCPU.cpp +++ b/src/osdep/gui/PanelCPU.cpp @@ -1,3 +1,5 @@ +#include + #ifdef USE_SDL1 #include #include @@ -13,14 +15,10 @@ #include "UaeRadioButton.hpp" #include "UaeCheckBox.hpp" -#include "sysconfig.h" #include "sysdeps.h" -#include "config.h" #include "options.h" #include "include/memory.h" #include "newcpu.h" -#include "uae.h" -#include "gui.h" #include "gui_handling.h" static gcn::Window* grpCPU; diff --git a/src/osdep/gui/PanelChipset.cpp b/src/osdep/gui/PanelChipset.cpp index 20bf3624..0d99bda1 100644 --- a/src/osdep/gui/PanelChipset.cpp +++ b/src/osdep/gui/PanelChipset.cpp @@ -1,3 +1,5 @@ +#include + #ifdef USE_SDL1 #include #include @@ -14,14 +16,8 @@ #include "UaeCheckBox.hpp" #include "UaeDropDown.hpp" -#include "sysconfig.h" #include "sysdeps.h" -#include "config.h" #include "options.h" -#include "uae.h" -#include "gui.h" -#include "include/memory.h" -#include "newcpu.h" #include "custom.h" #include "gui_handling.h" diff --git a/src/osdep/gui/PanelConfig.cpp b/src/osdep/gui/PanelConfig.cpp index 3db119fd..28a3fa17 100644 --- a/src/osdep/gui/PanelConfig.cpp +++ b/src/osdep/gui/PanelConfig.cpp @@ -1,3 +1,7 @@ +#include +#include +#include + #ifdef USE_SDL1 #include #include @@ -12,13 +16,9 @@ #include "SelectorEntry.hpp" #include "UaeListBox.hpp" -#include "sysconfig.h" #include "sysdeps.h" -#include "config.h" #include "options.h" #include "uae.h" -#include "blkdev.h" -#include "gui.h" #include "gui_handling.h" static char last_active_config[MAX_DPATH] = { '\0' }; diff --git a/src/osdep/gui/PanelCustom.cpp b/src/osdep/gui/PanelCustom.cpp index 8197e792..1230fddd 100644 --- a/src/osdep/gui/PanelCustom.cpp +++ b/src/osdep/gui/PanelCustom.cpp @@ -1,3 +1,7 @@ +#include +#include +#include + #ifdef USE_SDL1 #include #include @@ -14,21 +18,11 @@ #include "UaeDropDown.hpp" #include "UaeCheckBox.hpp" -#include "sysconfig.h" #include "sysdeps.h" -#include "config.h" #include "options.h" -#include "include/memory.h" -#include "uae.h" -#include "autoconf.h" -#include "filesys.h" -#include "gui.h" #include "gui_handling.h" -#include "keyboard.h" #include "inputdevice.h" -#include // horace - static gcn::Window* grpPort; static gcn::UaeRadioButton* optPort0; static gcn::UaeRadioButton* optPort1; diff --git a/src/osdep/gui/PanelDisplay.cpp b/src/osdep/gui/PanelDisplay.cpp index 1e1b1a3a..a470f6b4 100644 --- a/src/osdep/gui/PanelDisplay.cpp +++ b/src/osdep/gui/PanelDisplay.cpp @@ -1,3 +1,5 @@ +#include + #ifdef USE_SDL1 #include #include @@ -11,17 +13,11 @@ #endif #include "SelectorEntry.hpp" #include "UaeRadioButton.hpp" -#include "UaeDropDown.hpp" #include "UaeCheckBox.hpp" -#include "sysconfig.h" #include "sysdeps.h" -#include "config.h" #include "options.h" -#include "include/memory.h" -#include "uae.h" #include "custom.h" -#include "gui.h" #include "gui_handling.h" const int amigawidth_values[] = { 320, 352, 384, 640, 704, 768 }; diff --git a/src/osdep/gui/PanelFloppy.cpp b/src/osdep/gui/PanelFloppy.cpp index 5efed508..4560138e 100644 --- a/src/osdep/gui/PanelFloppy.cpp +++ b/src/osdep/gui/PanelFloppy.cpp @@ -1,3 +1,7 @@ +#include +#include +#include + #ifdef USE_SDL1 #include #include @@ -10,21 +14,14 @@ #include #endif #include "SelectorEntry.hpp" -#include "UaeRadioButton.hpp" #include "UaeDropDown.hpp" #include "UaeCheckBox.hpp" -#include "sysconfig.h" #include "sysdeps.h" -#include "config.h" #include "options.h" -#include "include/memory.h" #include "disk.h" -#include "uae.h" -#include "gui.h" #include "gui_handling.h" - static gcn::UaeCheckBox* chkDFx[4]; static gcn::UaeDropDown* cboDFxType[4]; static gcn::UaeCheckBox* chkDFxWriteProtect[4]; diff --git a/src/osdep/gui/PanelHD.cpp b/src/osdep/gui/PanelHD.cpp index aefee34a..56eff1f3 100644 --- a/src/osdep/gui/PanelHD.cpp +++ b/src/osdep/gui/PanelHD.cpp @@ -1,3 +1,7 @@ +#include +#include +#include + #ifdef USE_SDL1 #include #include @@ -9,11 +13,9 @@ #include #endif #include "SelectorEntry.hpp" -#include "UaeRadioButton.hpp" #include "UaeDropDown.hpp" #include "UaeCheckBox.hpp" -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" #include "autoconf.h" diff --git a/src/osdep/gui/PanelInput.cpp b/src/osdep/gui/PanelInput.cpp index f70d42b0..ee3cdd84 100644 --- a/src/osdep/gui/PanelInput.cpp +++ b/src/osdep/gui/PanelInput.cpp @@ -10,21 +10,12 @@ #include #endif #include "SelectorEntry.hpp" -#include "UaeRadioButton.hpp" #include "UaeDropDown.hpp" #include "UaeCheckBox.hpp" -#include "sysconfig.h" #include "sysdeps.h" -#include "config.h" #include "options.h" -#include "include/memory.h" -#include "uae.h" -#include "autoconf.h" -#include "filesys.h" -#include "gui.h" #include "gui_handling.h" -#include "keyboard.h" #include "inputdevice.h" #ifdef ANDROIDSDL diff --git a/src/osdep/gui/PanelMisc.cpp b/src/osdep/gui/PanelMisc.cpp index 2c7c0b84..97a56cba 100644 --- a/src/osdep/gui/PanelMisc.cpp +++ b/src/osdep/gui/PanelMisc.cpp @@ -1,3 +1,6 @@ +#include +#include + #ifdef USE_SDL1 #include #include @@ -10,19 +13,11 @@ #include #endif #include "SelectorEntry.hpp" -#include "UaeRadioButton.hpp" #include "UaeDropDown.hpp" #include "UaeCheckBox.hpp" -#include "sysconfig.h" #include "sysdeps.h" -#include "config.h" #include "options.h" -#include "include/memory.h" -#include "uae.h" -#include "autoconf.h" -#include "filesys.h" -#include "gui.h" #include "gui_handling.h" static gcn::UaeCheckBox* chkRetroArchQuit; diff --git a/src/osdep/gui/PanelPaths.cpp b/src/osdep/gui/PanelPaths.cpp index 1784abc2..3e30420c 100644 --- a/src/osdep/gui/PanelPaths.cpp +++ b/src/osdep/gui/PanelPaths.cpp @@ -11,12 +11,9 @@ #endif #include "SelectorEntry.hpp" -#include "sysconfig.h" #include "sysdeps.h" -#include "config.h" #include "options.h" #include "uae.h" -#include "gui.h" #include "gui_handling.h" static gcn::Label* lblSystemROMs; diff --git a/src/osdep/gui/PanelQuickstart.cpp b/src/osdep/gui/PanelQuickstart.cpp index aa72386b..e2dd13bd 100644 --- a/src/osdep/gui/PanelQuickstart.cpp +++ b/src/osdep/gui/PanelQuickstart.cpp @@ -1,3 +1,7 @@ +#include +#include +#include + #ifdef USE_SDL1 #include #include @@ -10,24 +14,15 @@ #include #endif #include "SelectorEntry.hpp" -#include "UaeRadioButton.hpp" #include "UaeDropDown.hpp" #include "UaeCheckBox.hpp" -#include "sysconfig.h" #include "sysdeps.h" -#include "config.h" #include "options.h" -#include "include/memory.h" #include "disk.h" -#include "uae.h" -#include "autoconf.h" -#include "filesys.h" #include "blkdev.h" -#include "gui.h" #include "gui_handling.h" - static gcn::Label* lblModel; static gcn::UaeDropDown* cboModel; static gcn::Label* lblConfig; diff --git a/src/osdep/gui/PanelRAM.cpp b/src/osdep/gui/PanelRAM.cpp index 560b8d2b..00946fad 100644 --- a/src/osdep/gui/PanelRAM.cpp +++ b/src/osdep/gui/PanelRAM.cpp @@ -10,18 +10,10 @@ #include #endif #include "SelectorEntry.hpp" -#include "UaeRadioButton.hpp" -#include "UaeDropDown.hpp" -#include "UaeCheckBox.hpp" - -#include "sysconfig.h" #include "sysdeps.h" -#include "config.h" #include "options.h" #include "include/memory.h" -#include "uae.h" #include "gfxboard.h" -#include "gui.h" #include "gui_handling.h" diff --git a/src/osdep/gui/PanelROM.cpp b/src/osdep/gui/PanelROM.cpp index 6c32f7fe..f76a984f 100644 --- a/src/osdep/gui/PanelROM.cpp +++ b/src/osdep/gui/PanelROM.cpp @@ -1,3 +1,6 @@ +#include +#include + #ifdef USE_SDL1 #include #include @@ -10,18 +13,11 @@ #include #endif #include "SelectorEntry.hpp" -#include "UaeRadioButton.hpp" #include "UaeDropDown.hpp" -#include "UaeCheckBox.hpp" -#include "sysconfig.h" #include "sysdeps.h" -#include "config.h" #include "options.h" -#include "include/memory.h" #include "rommgr.h" -#include "uae.h" -#include "gui.h" #include "gui_handling.h" static gcn::Label* lblMainROM; diff --git a/src/osdep/gui/PanelSavestate.cpp b/src/osdep/gui/PanelSavestate.cpp index 300a0601..a4ef608c 100644 --- a/src/osdep/gui/PanelSavestate.cpp +++ b/src/osdep/gui/PanelSavestate.cpp @@ -1,3 +1,7 @@ +#include +#include +#include + #ifdef USE_SDL1 #include #include @@ -13,20 +17,10 @@ #endif #include "SelectorEntry.hpp" #include "UaeRadioButton.hpp" -#include "UaeCheckBox.hpp" -#include "sysconfig.h" #include "sysdeps.h" -#include "config.h" -#include "options.h" -#include "include/memory.h" -#include "newcpu.h" -#include "custom.h" #include "xwin.h" -#include "drawing.h" -#include "uae.h" #include "gui.h" -#include "autoconf.h" #include "savestate.h" #include "gui_handling.h" diff --git a/src/osdep/gui/PanelSound.cpp b/src/osdep/gui/PanelSound.cpp index cb33d955..e3bcc630 100644 --- a/src/osdep/gui/PanelSound.cpp +++ b/src/osdep/gui/PanelSound.cpp @@ -1,3 +1,5 @@ +#include + #ifdef USE_SDL1 #include #include @@ -11,18 +13,10 @@ #endif #include "SelectorEntry.hpp" #include "UaeRadioButton.hpp" -#include "UaeCheckBox.hpp" #include "UaeDropDown.hpp" -#include "sysconfig.h" #include "sysdeps.h" -#include "config.h" #include "options.h" -#include "uae.h" -#include "gui.h" -#include "include/memory.h" -#include "newcpu.h" -#include "custom.h" #include "gui_handling.h" #include "sounddep/sound.h" diff --git a/src/osdep/gui/SelectFile.cpp b/src/osdep/gui/SelectFile.cpp index 0d245ab1..fa885f8b 100644 --- a/src/osdep/gui/SelectFile.cpp +++ b/src/osdep/gui/SelectFile.cpp @@ -1,6 +1,11 @@ -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include + #ifdef USE_SDL1 #include #include @@ -14,12 +19,10 @@ #endif #include "SelectorEntry.hpp" -#include "sysconfig.h" #include "sysdeps.h" #include "config.h" #include "uae.h" #include "fsdb.h" -#include "gui.h" #include "gui_handling.h" #include "options.h" diff --git a/src/osdep/gui/SelectFolder.cpp b/src/osdep/gui/SelectFolder.cpp index bd5ecb57..4f7a7d45 100644 --- a/src/osdep/gui/SelectFolder.cpp +++ b/src/osdep/gui/SelectFolder.cpp @@ -1,6 +1,10 @@ -#include -#include -#include +#include +#include +#include +#include +#include +#include + #ifdef USE_SDL1 #include #include @@ -14,7 +18,6 @@ #endif #include "SelectorEntry.hpp" -#include "sysconfig.h" #include "sysdeps.h" #include "config.h" #include "uae.h" diff --git a/src/osdep/gui/SelectorEntry.cpp b/src/osdep/gui/SelectorEntry.cpp index 7bcbabca..27c8e86e 100644 --- a/src/osdep/gui/SelectorEntry.cpp +++ b/src/osdep/gui/SelectorEntry.cpp @@ -1,3 +1,5 @@ +#include + #include "osdep/gui/SelectorEntry.hpp" #ifdef USE_SDL1 diff --git a/src/osdep/gui/ShowHelp.cpp b/src/osdep/gui/ShowHelp.cpp index 273159ee..cf108803 100644 --- a/src/osdep/gui/ShowHelp.cpp +++ b/src/osdep/gui/ShowHelp.cpp @@ -1,6 +1,7 @@ -#include -#include -#include +#include +#include +#include + #ifdef USE_SDL1 #include #include @@ -14,10 +15,8 @@ #endif #include "SelectorEntry.hpp" -#include "sysconfig.h" #include "sysdeps.h" #include "config.h" -#include "gui.h" #include "gui_handling.h" #include "options.h" diff --git a/src/osdep/gui/ShowMessage.cpp b/src/osdep/gui/ShowMessage.cpp index 409d8573..555a66c2 100644 --- a/src/osdep/gui/ShowMessage.cpp +++ b/src/osdep/gui/ShowMessage.cpp @@ -1,6 +1,7 @@ -#include -#include -#include +#include +#include +#include + #ifdef USE_SDL1 #include #include @@ -14,10 +15,8 @@ #endif #include "SelectorEntry.hpp" -#include "sysconfig.h" #include "sysdeps.h" #include "config.h" -#include "gui.h" #include "gui_handling.h" #ifdef ANDROIDSDL diff --git a/src/osdep/gui/androidsdl_event.cpp b/src/osdep/gui/androidsdl_event.cpp index 545561bd..20fe2df9 100644 --- a/src/osdep/gui/androidsdl_event.cpp +++ b/src/osdep/gui/androidsdl_event.cpp @@ -1,3 +1,5 @@ +#include + #ifdef USE_SDL1 #include #elif USE_SDL2 diff --git a/src/osdep/gui/main_window.cpp b/src/osdep/gui/main_window.cpp index 6707cf9b..e535336a 100644 --- a/src/osdep/gui/main_window.cpp +++ b/src/osdep/gui/main_window.cpp @@ -1,3 +1,8 @@ +#include +#include +#include +#include + #include #ifdef USE_SDL1 #include @@ -12,7 +17,6 @@ #endif #include "SelectorEntry.hpp" -#include "sysconfig.h" #include "sysdeps.h" #include "config.h" #include "options.h" diff --git a/src/osdep/keyboard.cpp b/src/osdep/keyboard.cpp index fc2ab469..092d0bc2 100644 --- a/src/osdep/keyboard.cpp +++ b/src/osdep/keyboard.cpp @@ -1,18 +1,8 @@ -#include "sysconfig.h" +#include + #include "sysdeps.h" -#include "config.h" #include "options.h" -#include "uae.h" -#include "include/memory.h" -#include "newcpu.h" -#include "custom.h" -#include "xwin.h" -#include "drawing.h" #include "inputdevice.h" -#include "keyboard.h" -#include "keybuf.h" -#include "gui.h" -#include char keyboard_type = 0; #ifdef USE_SDL1 diff --git a/src/osdep/mp3decoder.cpp b/src/osdep/mp3decoder.cpp index d8fa14e9..b81ea1b9 100644 --- a/src/osdep/mp3decoder.cpp +++ b/src/osdep/mp3decoder.cpp @@ -1,9 +1,10 @@ -#include "sysconfig.h" +#include +#include + #include "sysdeps.h" #include "zfile.h" #include "mp3decoder.h" -#include "cda_play.h" #include diff --git a/src/osdep/picasso96.cpp b/src/osdep/picasso96.cpp index 4cf71618..9b6c1dca 100644 --- a/src/osdep/picasso96.cpp +++ b/src/osdep/picasso96.cpp @@ -38,8 +38,11 @@ * I removed some code which handled unsupported modes and formats to make code * easier to read. */ +#include +#include +#include +#include -#include "sysconfig.h" #include "sysdeps.h" #include "gfxboard.h" @@ -856,54 +859,54 @@ void picasso_handle_hsync(void) #define BLT_MULT 1 #define BLT_NAME BLIT_FALSE_32 #define BLT_FUNC(s,d) *d = 0 -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NOR_32 #define BLT_FUNC(s,d) *d = ~(*s | * d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_ONLYDST_32 #define BLT_FUNC(s,d) *d = (*d) & ~(*s) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NOTSRC_32 #define BLT_FUNC(s,d) *d = ~(*s) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_ONLYSRC_32 #define BLT_FUNC(s,d) *d = (*s) & ~(*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NOTDST_32 #define BLT_FUNC(s,d) *d = ~(*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_EOR_32 #define BLT_FUNC(s,d) *d = (*s) ^ (*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NAND_32 #define BLT_FUNC(s,d) *d = ~((*s) & (*d)) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_AND_32 #define BLT_FUNC(s,d) *d = (*s) & (*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NEOR_32 #define BLT_FUNC(s,d) *d = ~((*s) ^ (*d)) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NOTONLYSRC_32 #define BLT_FUNC(s,d) *d = ~(*s) | (*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NOTONLYDST_32 #define BLT_FUNC(s,d) *d = ~(*d) | (*s) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_OR_32 #define BLT_FUNC(s,d) *d = (*s) | (*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_TRUE_32 #ifdef AMIBERRY #define BLT_FUNC(s,d) memset(d, 0xff, sizeof (*d)) #else #define BLT_FUNC(s,d) *d = 0xffffffff #endif -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_SWAP_32 #define BLT_FUNC(s,d) tmp = *d ; *d = *s; *s = tmp; #define BLT_TEMP -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #undef BLT_SIZE #undef BLT_MULT @@ -911,54 +914,54 @@ void picasso_handle_hsync(void) #define BLT_MULT 1 #define BLT_NAME BLIT_FALSE_24 #define BLT_FUNC(s,d) *d = 0 -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NOR_24 #define BLT_FUNC(s,d) *d = ~(*s | * d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_ONLYDST_24 #define BLT_FUNC(s,d) *d = (*d) & ~(*s) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NOTSRC_24 #define BLT_FUNC(s,d) *d = ~(*s) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_ONLYSRC_24 #define BLT_FUNC(s,d) *d = (*s) & ~(*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NOTDST_24 #define BLT_FUNC(s,d) *d = ~(*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_EOR_24 #define BLT_FUNC(s,d) *d = (*s) ^ (*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NAND_24 #define BLT_FUNC(s,d) *d = ~((*s) & (*d)) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_AND_24 #define BLT_FUNC(s,d) *d = (*s) & (*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NEOR_24 #define BLT_FUNC(s,d) *d = ~((*s) ^ (*d)) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NOTONLYSRC_24 #define BLT_FUNC(s,d) *d = ~(*s) | (*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NOTONLYDST_24 #define BLT_FUNC(s,d) *d = ~(*d) | (*s) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_OR_24 #define BLT_FUNC(s,d) *d = (*s) | (*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_TRUE_24 #ifdef AMIBERRY #define BLT_FUNC(s,d) memset(d, 0xff, sizeof (*d)) #else #define BLT_FUNC(s,d) *d = 0xffffffff #endif -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_SWAP_24 #define BLT_FUNC(s,d) tmp = *d ; *d = *s; *s = tmp; #define BLT_TEMP -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #undef BLT_SIZE #undef BLT_MULT @@ -966,54 +969,54 @@ void picasso_handle_hsync(void) #define BLT_MULT 2 #define BLT_NAME BLIT_FALSE_16 #define BLT_FUNC(s,d) *d = 0 -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NOR_16 #define BLT_FUNC(s,d) *d = ~(*s | * d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_ONLYDST_16 #define BLT_FUNC(s,d) *d = (*d) & ~(*s) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NOTSRC_16 #define BLT_FUNC(s,d) *d = ~(*s) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_ONLYSRC_16 #define BLT_FUNC(s,d) *d = (*s) & ~(*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NOTDST_16 #define BLT_FUNC(s,d) *d = ~(*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_EOR_16 #define BLT_FUNC(s,d) *d = (*s) ^ (*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NAND_16 #define BLT_FUNC(s,d) *d = ~((*s) & (*d)) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_AND_16 #define BLT_FUNC(s,d) *d = (*s) & (*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NEOR_16 #define BLT_FUNC(s,d) *d = ~((*s) ^ (*d)) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NOTONLYSRC_16 #define BLT_FUNC(s,d) *d = ~(*s) | (*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NOTONLYDST_16 #define BLT_FUNC(s,d) *d = ~(*d) | (*s) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_OR_16 #define BLT_FUNC(s,d) *d = (*s) | (*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_TRUE_16 #ifdef AMIBERRY #define BLT_FUNC(s,d) memset(d, 0xff, sizeof (*d)) #else #define BLT_FUNC(s,d) *d = 0xffffffff #endif -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_SWAP_16 #define BLT_FUNC(s,d) tmp = *d ; *d = *s; *s = tmp; #define BLT_TEMP -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #undef BLT_SIZE #undef BLT_MULT @@ -1021,54 +1024,54 @@ void picasso_handle_hsync(void) #define BLT_MULT 4 #define BLT_NAME BLIT_FALSE_8 #define BLT_FUNC(s,d) *d = 0 -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NOR_8 #define BLT_FUNC(s,d) *d = ~(*s | * d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_ONLYDST_8 #define BLT_FUNC(s,d) *d = (*d) & ~(*s) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NOTSRC_8 #define BLT_FUNC(s,d) *d = ~(*s) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_ONLYSRC_8 #define BLT_FUNC(s,d) *d = (*s) & ~(*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NOTDST_8 #define BLT_FUNC(s,d) *d = ~(*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_EOR_8 #define BLT_FUNC(s,d) *d = (*s) ^ (*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NAND_8 #define BLT_FUNC(s,d) *d = ~((*s) & (*d)) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_AND_8 #define BLT_FUNC(s,d) *d = (*s) & (*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NEOR_8 #define BLT_FUNC(s,d) *d = ~((*s) ^ (*d)) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NOTONLYSRC_8 #define BLT_FUNC(s,d) *d = ~(*s) | (*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_NOTONLYDST_8 #define BLT_FUNC(s,d) *d = ~(*d) | (*s) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_OR_8 #define BLT_FUNC(s,d) *d = (*s) | (*d) -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_TRUE_8 #ifdef AMIBERRY #define BLT_FUNC(s,d) memset(d, 0xff, sizeof (*d)) #else #define BLT_FUNC(s,d) *d = 0xffffffff #endif -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #define BLT_NAME BLIT_SWAP_8 #define BLT_FUNC(s,d) tmp = *d ; *d = *s; *s = tmp; #define BLT_TEMP -#include "p96_blit.cpp" +#include "p96_blit.cpp.in" #undef BLT_SIZE #undef BLT_MULT diff --git a/src/osdep/sigsegv_handler.cpp b/src/osdep/sigsegv_handler.cpp index 3317ce3c..b0573a41 100644 --- a/src/osdep/sigsegv_handler.cpp +++ b/src/osdep/sigsegv_handler.cpp @@ -23,19 +23,16 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ +#include +#include -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" #include "include/memory.h" #include "newcpu.h" -#include "custom.h" -#include "jit/comptbl.h" #include "jit/compemu.h" #include "uae.h" -#include -#include #include #ifndef ANDROID #include @@ -44,7 +41,6 @@ int backtrace(void**,int){ return 0; } char** backtrace_symbols(void* const*,int){return NULL; } void backtrace_symbols_fd(void* const*,int,int){} #endif -#include extern uae_u8* current_compile_p; extern uae_u8* compiled_code; diff --git a/src/osdep/writelog.cpp b/src/osdep/writelog.cpp index 5820ae46..70a6f354 100644 --- a/src/osdep/writelog.cpp +++ b/src/osdep/writelog.cpp @@ -5,7 +5,9 @@ * * Copyright 2001 Bernd Schmidt */ -#include "sysconfig.h" +#include +#include + #include "sysdeps.h" #include "uae.h" diff --git a/src/p96_blit.cpp b/src/p96_blit.cpp.in similarity index 100% rename from src/p96_blit.cpp rename to src/p96_blit.cpp.in diff --git a/src/readcpu.cpp b/src/readcpu.cpp index 4e202570..8fb1f5c0 100644 --- a/src/readcpu.cpp +++ b/src/readcpu.cpp @@ -5,11 +5,9 @@ * * Copyright 1995,1996 Bernd Schmidt */ +#include -#include "sysconfig.h" #include "sysdeps.h" -#include - #include "readcpu.h" int nr_cpuop_funcs; diff --git a/src/rommgr.cpp b/src/rommgr.cpp index e12a0d7a..0c1cd6d1 100644 --- a/src/rommgr.cpp +++ b/src/rommgr.cpp @@ -5,7 +5,9 @@ * */ -#include "sysconfig.h" +#include +#include + #include "sysdeps.h" #include "options.h" diff --git a/src/rtc.cpp b/src/rtc.cpp index 94c8d0c1..b0f17076 100644 --- a/src/rtc.cpp +++ b/src/rtc.cpp @@ -3,12 +3,9 @@ * * RTC chips */ +#include -#include "sysconfig.h" #include "sysdeps.h" - -#include "options.h" - #include "rtc.h" uae_u8 get_clock_msm(struct rtc_msm_data *data, int addr, struct tm *ct) diff --git a/src/savestate.cpp b/src/savestate.cpp index d70e6392..230b5127 100644 --- a/src/savestate.cpp +++ b/src/savestate.cpp @@ -43,23 +43,20 @@ * set savestate_state = STATE_DORESTORE, savestate_filename = "..." * */ +#include +#include -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" -#include "memory.h" #include "zfile.h" #include "autoconf.h" #include "custom.h" -#include "newcpu.h" #include "savestate.h" #include "uae.h" #include "gui.h" #include "audio.h" #include "filesys.h" -#include "disk.h" -#include "threaddep/thread.h" #include "devices.h" int savestate_state = 0; diff --git a/src/scsi.cpp b/src/scsi.cpp index 018cf5b8..7893563a 100644 --- a/src/scsi.cpp +++ b/src/scsi.cpp @@ -6,13 +6,12 @@ * Copyright 2007-2015 Toni Wilen * */ +#include -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" #include "filesys.h" -#include "blkdev.h" #include "scsi.h" static const int outcmd[] = { 0x04, 0x0a, 0x0c, 0x11, 0x2a, 0xaa, 0x15, 0x55, 0x0f, -1 }; diff --git a/src/sinctable.cpp b/src/sinctable.cpp.in similarity index 100% rename from src/sinctable.cpp rename to src/sinctable.cpp.in diff --git a/src/sounddep/sound.cpp b/src/sounddep/sound.cpp index a29085fc..95017e2c 100644 --- a/src/sounddep/sound.cpp +++ b/src/sounddep/sound.cpp @@ -2,27 +2,17 @@ * Sdl sound.c implementation * (c) 2015 */ +#include +#include -#include -#include -#include #include -#include -#include -#include -#include "sysconfig.h" #include "sysdeps.h" -#include "config.h" #include "uae.h" #include "options.h" -#include "memory.h" -#include "newcpu.h" -#include "custom.h" #include "audio.h" #include "gensound.h" #include "sounddep/sound.h" -#include #include "gui.h" #ifdef ANDROIDSDL diff --git a/src/statusline.cpp b/src/statusline.cpp index 78fcb689..fdad1d39 100644 --- a/src/statusline.cpp +++ b/src/statusline.cpp @@ -1,11 +1,10 @@ -#include "sysconfig.h" +#include +#include +#include + #include "sysdeps.h" -#include -#include - #include "options.h" -#include "uae.h" #include "xwin.h" #include "gui.h" #include "custom.h" diff --git a/src/table68k b/src/table68k deleted file mode 100644 index 3e085c9e..00000000 --- a/src/table68k +++ /dev/null @@ -1,531 +0,0 @@ -% 0: bit 0 -% 1: bit 1 -% c: condition code -% C: condition codes, except F -% f: direction -% i: immediate -% E: immediate, except 00 (for EmulOp instructions) -% I: immediate, except 00 and ff -% j: immediate 1..8 -% J: immediate 0..15 -% k: immediate 0..7 -% K: immediate 0..63 -% p: immediate 0..3 (CINV and CPUSH: cache field) -% s: source mode -% S: source reg -% d: dest mode -% D: dest reg -% r: reg -% z: size -% -% Actually, a sssSSS may appear as a destination, and -% vice versa. The only difference between sssSSS and -% dddDDD are the valid addressing modes. There is -% no match for immediate and pc-rel. addressing modes -% in case of dddDDD. -% -% Arp: --> -(Ar) -% ArP: --> (Ar)+ -% Ara: --> (Ar) -% L: --> (xxx.L) -% -% Fields on a line: -% 16 chars bitpattern : -% CPU level / privilege level : -% CPU level 0: 68000 -% 1: 68010 -% 2: 68020 -% 3: 68030 -% 4: 68040 -% 5: 68060 -% [Everything from 68020 possibly allows for FPU emulation] -% Unimplemented after: -% 0: Normal -% 3: Not implemented in 68030 and later -% 4: Not implemented in 68040 and later -% 5: Not implemented in 68060 -% privilege level 0: not privileged -% 1: unprivileged only on 68000 (check regs.s) -% 2: privileged (check regs.s) -% 3: privileged if size == word (check regs.s) -% Flags set by instruction: XNZVC : -% Flags used by instruction: XNZVC : -% - means flag unaffected / unused -% 0 means flag reset -% 1 means flag set -% ? means programmer was too lazy to check or instruction may trap -% + means instruction is conditional branch (ignored, only for sync) -% / means instruction is unconditional branch/call (ignored, only for sync) -% x means flag is unknown and well-behaved programs shouldn't check it -% everything else means flag set/used -% -% Control flow -% two letters, combination of -% - nothing -% T the instruction may trap or cause an exception -% B branch instruction -% J jump instruction -% R return instruction -% -% srcaddr status destaddr status : -% bitmasks of -% 1 means fetched -% 2 means stored -% 4 means jump offset -% 8 means jump address -% instruction -% optional line feed and 68030 Head/Tail/Cycles/ea calculation -% - -0000 0000 0011 1100:000:XNZVC:XNZVC:--:10: ORSR.B #1 -0000 0000 0111 1100:002:XNZVC:XNZVC:T-:10: ORSR.W #1 -0000 0zz0 11ss sSSS:250:-?Z?C:-----:T-:11: CHK2.z #1,s[!Dreg,Areg,Aipi,Apdi,Immd] - -0000 0000 zzdd dDDD:000:-NZ00:-----:--:13: OR.z #z,d[Dreg] -- 2 0 2 fiea -0000 0000 zzdd dDDD:000:-NZ00:-----:--:13: OR.z #z,d[!Areg,Dreg] -- 0 1 3 fiea - -0000 0010 0011 1100:000:XNZVC:XNZVC:--:10: ANDSR.B #1 -0000 0010 0111 1100:002:XNZVC:XNZVC:T-:10: ANDSR.W #1 - -0000 0010 zzdd dDDD:000:-NZ00:-----:--:13: AND.z #z,d[Dreg] -- 2 0 2 fiea -0000 0010 zzdd dDDD:000:-NZ00:-----:--:13: AND.z #z,d[!Areg,Dreg] -- 0 1 3 fiea -0000 0100 zzdd dDDD:000:XNZVC:-----:--:13: SUB.z #z,d[Dreg] -- 2 0 2 fiea -0000 0100 zzdd dDDD:000:XNZVC:-----:--:13: SUB.z #z,d[!Areg,Dreg] -- 0 1 3 fiea -0000 0110 zzdd dDDD:000:XNZVC:-----:--:13: ADD.z #z,d[Dreg] -- 2 0 2 fiea -0000 0110 zzdd dDDD:000:XNZVC:-----:--:13: ADD.z #z,d[!Areg,Dreg] -- 0 1 3 fiea - -0000 0110 11ss sSSS:230:-----:XNZVC:--:10: CALLM s[!Dreg,Areg,Aipi,Apdi,Immd] -0000 0110 11ss sSSS:230:XNZVC:-----:-R:10: RTM s[Dreg,Areg] - -0000 1000 00ss sSSS:000:--Z--:-----:--:11: BTST #1,s[Dreg] -- 4 0 4 -0000 1000 00ss sSSS:000:--Z--:-----:--:11: BTST #1,s[!Areg,Dreg,Immd] -- 0 0 4 fiea -0000 1000 01ss sSSS:000:--Z--:-----:--:13: BCHG #1,s[Dreg] -- 6 0 6 -0000 1000 01ss sSSS:000:--Z--:-----:--:13: BCHG #1,s[!Areg,Dreg,Immd,PC8r,PC16] -- 0 0 6 fiea -0000 1000 10ss sSSS:000:--Z--:-----:--:13: BCLR #1,s[Dreg] -- 6 0 6 -0000 1000 10ss sSSS:000:--Z--:-----:--:13: BCLR #1,s[!Areg,Dreg,Immd,PC8r,PC16] -- 0 0 6 fiea -0000 1000 11ss sSSS:000:--Z--:-----:--:13: BSET #1,s[Dreg] -- 6 0 6 -0000 1000 11ss sSSS:000:--Z--:-----:--:13: BSET #1,s[!Areg,Dreg,Immd,PC8r,PC16] -- 0 0 6 fiea - -0000 1010 0011 1100:000:XNZVC:XNZVC:--:10: EORSR.B #1 -0000 1010 0111 1100:002:XNZVC:XNZVC:T-:10: EORSR.W #1 - -0000 1010 zzdd dDDD:000:-NZ00:-----:--:13: EOR.z #z,d[Dreg] -- 2 0 2 fiea -0000 1010 zzdd dDDD:000:-NZ00:-----:--:13: EOR.z #z,d[!Areg,Dreg] -- 0 1 3 fiea -0000 1100 zzss sSSS:000:-NZVC:-----:--:11: CMP.z #z,s[Dreg] -- 2 0 2 fiea -0000 1100 zzss sSSS:000:-NZVC:-----:--:11: CMP.z #z,s[!Areg,Dreg,Immd,PC8r,PC16] -- 0 0 2 fiea -0000 1100 zzss sSSS:200:-NZVC:-----:--:11: CMP.z #z,s[PC8r,PC16] -- 0 0 2 fiea - -0000 1010 11ss sSSS:200:-NZVC:-----:--:13: CAS.B #1,s[!Dreg,Areg,Immd,PC8r,PC16] -0000 1100 11ss sSSS:200:-NZVC:-----:--:13: CAS.W #1,s[!Dreg,Areg,Immd,PC8r,PC16] -0000 1100 1111 1100:250:-NZVC:-----:--:10: CAS2.W #2 -0000 1110 zzss sSSS:202:-----:-----:T-:13: MOVES.z #1,s[!Dreg,Areg,Immd,PC8r,PC16] -0000 1110 11ss sSSS:200:-NZVC:-----:--:13: CAS.L #1,s[!Dreg,Areg,Immd,PC8r,PC16] -0000 1110 1111 1100:250:-NZVC:-----:--:10: CAS2.L #2 - -0000 rrr1 00dd dDDD:050:-----:-----:--:12: MVPMR.W d[Areg-Ad16],Dr -0000 rrr1 01dd dDDD:050:-----:-----:--:12: MVPMR.L d[Areg-Ad16],Dr -0000 rrr1 10dd dDDD:050:-----:-----:--:12: MVPRM.W Dr,d[Areg-Ad16] -0000 rrr1 11dd dDDD:050:-----:-----:--:12: MVPRM.L Dr,d[Areg-Ad16] - -0000 rrr1 00ss sSSS:000:--Z--:-----:--:11: BTST Dr,s[Dreg] -- 4 0 4 -0000 rrr1 00ss sSSS:000:--Z--:-----:--:11: BTST Dr,s[!Areg,Dreg] -- 0 0 4 fea -0000 rrr1 01ss sSSS:000:--Z--:-----:--:13: BCHG Dr,s[Dreg] -- 6 0 6 -0000 rrr1 01ss sSSS:000:--Z--:-----:--:13: BCHG Dr,s[!Areg,Dreg,Immd,PC8r,PC16] -- 0 0 6 fea -0000 rrr1 10ss sSSS:000:--Z--:-----:--:13: BCLR Dr,s[Dreg] -- 6 0 6 -0000 rrr1 10ss sSSS:000:--Z--:-----:--:13: BCLR Dr,s[!Areg,Dreg,Immd,PC8r,PC16] -- 0 0 6 fea -0000 rrr1 11ss sSSS:000:--Z--:-----:--:13: BSET Dr,s[Dreg] -- 6 0 6 -0000 rrr1 11ss sSSS:000:--Z--:-----:--:13: BSET Dr,s[!Areg,Dreg,Immd,PC8r,PC16] -- 0 0 6 fea - -% Move cycles are special cased in gencpu.c -0001 DDDd ddss sSSS:000:-NZ00:-----:--:12: MOVE.B s,d[!Areg] -0011 DDDd ddss sSSS:000:-----:-----:--:12: MOVEA.W s,d[Areg] -0011 DDDd ddss sSSS:000:-NZ00:-----:--:12: MOVE.W s,d[!Areg] -0010 DDDd ddss sSSS:000:-----:-----:--:12: MOVEA.L s,d[Areg] -0010 DDDd ddss sSSS:000:-NZ00:-----:--:12: MOVE.L s,d[!Areg] - -0100 0000 zzdd dDDD:000:XNZVC:X-Z--:--:30: NEGX.z d[Dreg] -- 2 0 2 -0100 0000 zzdd dDDD:000:XNZVC:X-Z--:--:30: NEGX.z d[!Areg,Dreg] -- 0 1 3 fea -0100 0000 11dd dDDD:001:-----:XNZVC:T-:10: MVSR2.W d[Dreg] -- 2 0 4 -0100 0000 11dd dDDD:001:-----:XNZVC:T-:10: MVSR2.W d[!Areg,Dreg] -- 2 0 4 cea -0100 0010 zzdd dDDD:000:-0100:-----:--:20: CLR.z d[Dreg] -- 2 0 2 -0100 0010 zzdd dDDD:000:-0100:-----:--:20: CLR.z d[!Areg,Dreg] -- 0 1 3 cea -0100 0010 11dd dDDD:100:-----:XNZVC:--:10: MVSR2.B d[Dreg] -- 2 0 4 -0100 0010 11dd dDDD:100:-----:XNZVC:--:10: MVSR2.B d[!Areg,Dreg] -- 2 0 4 cea -0100 0100 zzdd dDDD:000:XNZVC:-----:--:30: NEG.z d[Dreg] -- 2 0 2 -0100 0100 zzdd dDDD:000:XNZVC:-----:--:30: NEG.z d[!Areg,Dreg] -- 0 1 3 fea -0100 0100 11ss sSSS:000:XNZVC:-----:--:10: MV2SR.B s[Dreg] -- 4 0 4 -0100 0100 11ss sSSS:000:XNZVC:-----:--:10: MV2SR.B s[!Areg,Dreg] -- 0 0 4 fea -0100 0110 zzdd dDDD:000:-NZ00:-----:--:30: NOT.z d[Dreg] -- 2 0 2 -0100 0110 zzdd dDDD:000:-NZ00:-----:--:30: NOT.z d[!Areg,Dreg] -- 0 1 3 fea -0100 0110 11ss sSSS:002:XNZVC:XNZVC:T-:10: MV2SR.W s[!Areg] -- 0 0 8 fea -0100 1000 0000 1rrr:200:-----:-----:--:31: LINK.L Ar,#2 -- 2 0 6 -0100 1000 00dd dDDD:000:X?Z?C:X-Z--:--:30: NBCD.B d[!Areg] -- 0 0 6 - -0100 1000 0100 1kkk:200:-----:-----:T-:10: BKPT #k - -0100 1000 01ss sSSS:000:-NZ00:-----:--:30: SWAP.W s[Dreg] -- 4 0 4 -0100 1000 01ss sSSS:000:-----:-----:--:00: PEA.L s[!Dreg,Areg,Aipi,Apdi,Immd] -- 0 2 4 cea -0100 1000 10dd dDDD:000:-NZ00:-----:--:30: EXT.W d[Dreg] -- 4 0 4 - -0100 1000 10dd dDDD:000:-----:-----:--:02: MVMLE.W #1,d[!Dreg,Areg,Aipi] - -0100 1000 11dd dDDD:000:-NZ00:-----:--:30: EXT.L d[Dreg] -- 4 0 4 - -0100 1000 11dd dDDD:000:-----:-----:--:02: MVMLE.L #1,d[!Dreg,Areg,Aipi] - -0100 1001 11dd dDDD:200:-NZ00:-----:--:30: EXT.B d[Dreg] -- 4 0 4 -0100 1010 zzss sSSS:000:-NZ00:-----:--:10: TST.z s[Dreg] -- 0 0 2 -0100 1010 zzss sSSS:000:-NZ00:-----:--:10: TST.z s[!Areg,Dreg,PC16,PC8r,Immd] -- 0 0 2 fea -0100 1010 zzss sSSS:200:-NZ00:-----:--:10: TST.z s[Areg,PC16,PC8r,Immd] -- 0 0 2 fea -0100 1010 11dd dDDD:000:-NZ00:-----:--:30: TAS.B d[Dreg] -- 0 0 2 -0100 1010 11dd dDDD:000:-NZ00:-----:--:30: TAS.B d[!Areg,Dreg] -- 0 0 2 fea - -0100 1010 1111 1100:000:-----:-----:T-:00: ILLEGAL - -0100 1100 00ss sSSS:200:-NZVC:-----:--:13: MULL.L #1,s[!Areg] -- 2 0 30 fiea -0100 1100 01ss sSSS:200:-NZV0:-----:T-:13: DIVL.L #1,s[!Areg] -- 0 0 50 fiea - -0100 1100 10ss sSSS:000:-----:-----:--:01: MVMEL.W #1,s[!Dreg,Areg,Apdi,Immd] -0100 1100 11ss sSSS:000:-----:-----:--:01: MVMEL.L #1,s[!Dreg,Areg,Apdi,Immd] -0100 1110 0100 JJJJ:000:-----:XNZVC:--:10: TRAP #J - -0100 1110 0101 0rrr:000:-----:-----:--:31: LINK.W Ar,#1 -- 0 0 4 -0100 1110 0101 1rrr:000:-----:-----:--:30: UNLK.L Ar -- 0 0 5 -0100 1110 0110 0rrr:002:-----:-----:T-:10: MVR2USP.L Ar -- 4 0 4 -0100 1110 0110 1rrr:002:-----:-----:T-:20: MVUSP2R.L Ar -- 4 0 4 -0100 1110 0111 0000:002:-----:-----:T-:00: RESET -- 0 0 518 -0100 1110 0111 0001:000:-----:-----:--:00: NOP -- 0 0 2 -0100 1110 0111 0010:002:XNZVC:-----:T-:10: STOP #1 -- 0 0 8 -0100 1110 0111 0011:002:XNZVC:-----:TR:00: RTE -- 1 9 18 -0100 1110 0111 0100:100:-----:-----:-R:10: RTD #1 -- 2 0 10 -0100 1110 0111 0101:000:-----:-----:-R:00: RTS -- 1 0 9 - -0100 1110 0111 0110:000:-----:XNZVC:T-:00: TRAPV - -0100 1110 0111 0111:000:XNZVC:-----:-R:00: RTR -- 1 0 12 - -0100 1110 0111 1010:102:-----:-----:T-:10: MOVEC2 #1 -- 6 0 6 -0100 1110 0111 1011:102:-----:-----:T-:10: MOVE2C #1 -- 6 0 6 -0100 1110 10ss sSSS:000://///://///:-J:80: JSR.L s[!Dreg,Areg,Aipi,Apdi,Immd] -- 0 0 4 jea - -0100 rrr1 00ss sSSS:200:-N???:-----:T-:11: CHK.L s[!Areg],Dr -0100 rrr1 10ss sSSS:000:-N???:-----:T-:11: CHK.W s[!Areg],Dr - -0100 1110 11ss sSSS:000://///://///:-J:80: JMP.L s[!Dreg,Areg,Aipi,Apdi,Immd] -- 4 0 4 jea -0100 rrr1 11ss sSSS:000:-----:-----:--:02: LEA.L s[!Dreg,Areg,Aipi,Apdi,Immd],Ar -- 2 0 2 cea - -% This variant of ADDQ is word and long sized only -0101 jjj0 01dd dDDD:000:-----:-----:--:13: ADDA.W #j,d[Areg] -- 2 0 2 -0101 jjj0 10dd dDDD:000:-----:-----:--:13: ADDA.L #j,d[Areg] -- 2 0 2 -0101 jjj0 zzdd dDDD:000:XNZVC:-----:--:13: ADD.z #j,d[Dreg] -- 2 0 2 -0101 jjj0 zzdd dDDD:000:XNZVC:-----:--:13: ADD.z #j,d[!Areg,Dreg] -- 0 1 3 fea - -% This variant of SUBQ is word and long sized only -0101 jjj1 01dd dDDD:000:-----:-----:--:13: SUBA.W #j,d[Areg] -- 2 0 2 -0101 jjj1 10dd dDDD:000:-----:-----:--:13: SUBA.L #j,d[Areg] -- 2 0 2 -0101 jjj1 zzdd dDDD:000:XNZVC:-----:--:13: SUB.z #j,d[Dreg] -- 2 0 2 -0101 jjj1 zzdd dDDD:000:XNZVC:-----:--:13: SUB.z #j,d[!Areg,Dreg] -- 0 1 3 fea - -0101 cccc 1100 1rrr:000:-----:-++++:-B:31: DBcc.W Dr,#1 -- -1 0 0 -0101 cccc 11dd dDDD:000:-----:-++++:--:20: Scc.B d[Dreg] -- 0 0 2 -0101 cccc 11dd dDDD:000:-----:-++++:--:20: Scc.B d[!Areg,Dreg] -- 0 0 2 cea - -0101 cccc 1111 1010:200:-----:-????:T-:10: TRAPcc #1 -0101 cccc 1111 1011:200:-----:-????:T-:10: TRAPcc #2 -0101 cccc 1111 1100:200:-----:-????:T-:00: TRAPcc - -% Bxx.L is 68020 only, but setting the CPU level to 2 would give illegal -% instruction exceptions when compiling a 68000 only emulation, which isn't -% what we want either. -0110 0001 0000 0000:000://///://///:-B:40: BSR.W #1 -- 2 0 6 -0110 0001 IIII IIII:000://///://///:-B:40: BSR.B #i -- 2 0 6 -0110 0001 1111 1111:000://///://///:-B:40: BSR.L #2 -- 2 0 6 -0110 CCCC 0000 0000:000:-----:-++++:-B:40: Bcc.W #1 -- -1 0 0 -0110 CCCC IIII IIII:000:-----:-++++:-B:40: Bcc.B #i -- -1 0 0 -0110 CCCC 1111 1111:000:-----:-++++:-B:40: Bcc.L #2 -- -1 0 0 - -0111 rrr0 iiii iiii:000:-NZ00:-----:--:12: MOVE.L #i,Dr - -1000 rrr0 zzss sSSS:000:-NZ00:-----:--:13: OR.z s[Dreg],Dr -- 2 0 2 -1000 rrr0 zzss sSSS:000:-NZ00:-----:--:13: OR.z s[!Areg,Dreg],Dr -- 0 0 2 fea - -1000 rrr0 11ss sSSS:000:-NZV0:-----:T-:13: DIVU.W s[Dreg],Dr -- 2 0 20 -1000 rrr0 11ss sSSS:000:-NZV0:-----:T-:13: DIVU.W s[!Areg,Dreg],Dr -- 0 0 20 fea - -1000 rrr1 00dd dDDD:000:XxZxC:X-Z--:--:13: SBCD.B d[Dreg],Dr -- 0 0 4 -1000 rrr1 00dd dDDD:000:XxZxC:X-Z--:--:13: SBCD.B d[Areg-Apdi],Arp -- 2 1 13 - -1000 rrr1 zzdd dDDD:000:-NZ00:-----:--:13: OR.z Dr,d[!Areg,Dreg] -- 0 1 3 fea - -1000 rrr1 01dd dDDD:200:-----:-----:--:12: PACK d[Dreg],Dr -- 6 0 6 -1000 rrr1 01dd dDDD:200:-----:-----:--:12: PACK d[Areg-Apdi],Arp -- 2 1 11 -1000 rrr1 10dd dDDD:200:-----:-----:--:12: UNPK d[Dreg],Dr -- 8 0 8 -1000 rrr1 10dd dDDD:200:-----:-----:--:12: UNPK d[Areg-Apdi],Arp -- 2 1 11 - -1000 rrr1 11ss sSSS:000:-NZV0:-----:T-:13: DIVS.W s[Dreg],Dr -- 2 0 20 -1000 rrr1 11ss sSSS:000:-NZV0:-----:T-:13: DIVS.W s[!Areg,Dreg],Dr -- 0 0 20 fea - -1001 rrr0 zzss sSSS:000:XNZVC:-----:--:13: SUB.z s[Areg,Dreg],Dr -- 2 0 2 -1001 rrr0 zzss sSSS:000:XNZVC:-----:--:13: SUB.z s[!Areg,Dreg],Dr -- 0 0 2 fea -1001 rrr0 11ss sSSS:000:-----:-----:--:13: SUBA.W s[Areg,Dreg],Ar -- 4 0 4 -1001 rrr0 11ss sSSS:000:-----:-----:--:13: SUBA.W s[!Areg,Dreg],Ar -- 0 0 4 fea - -1001 rrr1 zzdd dDDD:000:XNZVC:X-Z--:--:13: SUBX.z d[Dreg],Dr -- 2 0 2 -1001 rrr1 zzdd dDDD:000:XNZVC:X-Z--:--:13: SUBX.z d[Areg-Apdi],Arp -- 2 1 9 - -1001 rrr1 zzdd dDDD:000:XNZVC:-----:--:13: SUB.z Dr,d[!Areg,Dreg] -- 0 1 3 fea -1001 rrr1 11ss sSSS:000:-----:-----:--:13: SUBA.L s[Areg,Dreg],Ar -- 2 0 2 -1001 rrr1 11ss sSSS:000:-----:-----:--:13: SUBA.L s[!Areg,Dreg],Ar -- 0 0 2 fea - -1011 rrr0 zzss sSSS:000:-NZVC:-----:--:11: CMP.z s[Areg,Dreg],Dr -- 2 0 2 -1011 rrr0 zzss sSSS:000:-NZVC:-----:--:11: CMP.z s[!Areg,Dreg],Dr -- 0 0 2 fea -1011 rrr0 11ss sSSS:000:-NZVC:-----:--:11: CMPA.W s[Areg,Dreg],Ar -- 4 0 4 -1011 rrr0 11ss sSSS:000:-NZVC:-----:--:11: CMPA.W s[!Areg,Dreg],Ar -- 0 0 4 fea -1011 rrr1 11ss sSSS:000:-NZVC:-----:--:11: CMPA.L s[Areg,Dreg],Ar -- 4 0 4 -1011 rrr1 11ss sSSS:000:-NZVC:-----:--:11: CMPA.L s[!Areg,Dreg],Ar -- 0 0 4 fea -1011 rrr1 zzdd dDDD:000:-NZVC:-----:--:11: CMPM.z d[Areg-Aipi],ArP -- 0 0 8 -1011 rrr1 zzdd dDDD:000:-NZ00:-----:--:13: EOR.z Dr,d[Dreg] -- 2 0 2 -1011 rrr1 zzdd dDDD:000:-NZ00:-----:--:13: EOR.z Dr,d[!Areg,Dreg] -- 0 1 3 fea - -1100 rrr0 zzss sSSS:000:-NZ00:-----:--:13: AND.z s[Dreg],Dr -- 2 0 2 fea -1100 rrr0 zzss sSSS:000:-NZ00:-----:--:13: AND.z s[!Areg,Dreg],Dr -- 0 1 3 fea -1100 rrr0 11ss sSSS:000:-NZ00:-----:--:13: MULU.W s[!Areg],Dr -- 2 0 12 fea - -1100 rrr1 00dd dDDD:000:XxZxC:X-Z--:--:13: ABCD.B d[Dreg],Dr -- 0 0 4 -1100 rrr1 00dd dDDD:000:XxZxC:X-Z--:--:13: ABCD.B d[Areg-Apdi],Arp -- 2 1 13 - -1100 rrr1 zzdd dDDD:000:-NZ00:-----:--:13: AND.z Dr,d[!Areg,Dreg] -- 0 1 3 fea -1100 rrr1 01dd dDDD:000:-----:-----:--:33: EXG.L Dr,d[Dreg] -- 4 0 4 -1100 rrr1 01dd dDDD:000:-----:-----:--:33: EXG.L Ar,d[Areg] -- 4 0 4 -1100 rrr1 10dd dDDD:000:-----:-----:--:33: EXG.L Dr,d[Areg] -- 4 0 4 -1100 rrr1 11ss sSSS:000:-NZ00:-----:--:13: MULS.W s[!Areg],Dr -- 2 0 12 fea - -1101 rrr0 zzss sSSS:000:XNZVC:-----:--:13: ADD.z s[Areg,Dreg],Dr -- 2 0 2 -1101 rrr0 zzss sSSS:000:XNZVC:-----:--:13: ADD.z s[!Areg,Dreg],Dr -- 0 0 2 fea -1101 rrr0 11ss sSSS:000:-----:-----:--:13: ADDA.W s[Areg,Dreg],Ar -- 0 0 4 -1101 rrr0 11ss sSSS:000:-----:-----:--:13: ADDA.W s[!Areg,Dreg],Ar -- 4 0 4 fea - -1101 rrr1 zzdd dDDD:000:XNZVC:X-Z--:--:13: ADDX.z d[Dreg],Dr -- 2 0 2 -1101 rrr1 zzdd dDDD:000:XNZVC:X-Z--:--:13: ADDX.z d[Areg-Apdi],Arp -- 2 1 9 - -1101 rrr1 zzdd dDDD:000:XNZVC:-----:--:13: ADD.z Dr,d[!Areg,Dreg] -- 0 1 3 fea -1101 rrr1 11ss sSSS:000:-----:-----:--:13: ADDA.L s[Areg,Dreg],Ar -- 2 0 2 -1101 rrr1 11ss sSSS:000:-----:-----:--:13: ADDA.L s[!Areg,Dreg],Ar -- 0 0 2 fea - -1110 jjjf zz00 0RRR:000:XNZVC:-----:--:13: ASf.z #j,DR -- 2 0 6 -1110 jjjf zz00 1RRR:000:XNZ0C:-----:--:13: LSf.z #j,DR -- 4 0 4 -1110 jjjf zz01 0RRR:000:XNZ0C:X----:--:13: ROXf.z #j,DR -- 10 0 12 -1110 jjjf zz01 1RRR:000:-NZ0C:-----:--:13: ROf.z #j,DR -- 4 0 6 -1110 rrrf zz10 0RRR:000:XNZVC:X----:--:13: ASf.z Dr,DR -- 4 0 6 -1110 rrrf zz10 1RRR:000:XNZ0C:X----:--:13: LSf.z Dr,DR -- 6 0 6 -1110 rrrf zz11 0RRR:000:XNZ0C:X----:--:13: ROXf.z Dr,DR -- 10 0 12 -1110 rrrf zz11 1RRR:000:-NZ0C:-----:--:13: ROf.z Dr,DR -- 6 0 8 -1110 000f 11dd dDDD:000:XNZVC:-----:--:13: ASfW.W d[!Dreg,Areg] -- 0 0 4 fea -1110 001f 11dd dDDD:000:XNZ0C:-----:--:13: LSfW.W d[!Dreg,Areg] -- 0 0 4 fea -1110 010f 11dd dDDD:000:XNZ0C:X----:--:13: ROXfW.W d[!Dreg,Areg] -- 0 0 4 fea -1110 011f 11dd dDDD:000:-NZ0C:-----:--:13: ROfW.W d[!Dreg,Areg] -- 0 0 6 fea - -1110 1000 11ss sSSS:200:-NZ00:-----:--:11: BFTST #1,s[!Areg,Apdi,Aipi,Immd] -1110 1001 11ss sSSS:200:-NZ00:-----:--:11: BFEXTU #1,s[!Areg,Apdi,Aipi,Immd] -1110 1010 11ss sSSS:200:-NZ00:-----:--:13: BFCHG #1,s[!Areg,Apdi,Aipi,Immd,PC8r,PC16] -1110 1011 11ss sSSS:200:-NZ00:-----:--:11: BFEXTS #1,s[!Areg,Apdi,Aipi,Immd] -1110 1100 11ss sSSS:200:-NZ00:-----:--:13: BFCLR #1,s[!Areg,Apdi,Aipi,Immd,PC8r,PC16] -1110 1101 11ss sSSS:200:-NZ00:-----:--:11: BFFFO #1,s[!Areg,Apdi,Aipi,Immd] -1110 1110 11ss sSSS:200:-NZ00:-----:--:13: BFSET #1,s[!Areg,Apdi,Aipi,Immd,PC8r,PC16] -1110 1111 11ss sSSS:200:-NZ00:-----:--:13: BFINS #1,s[!Areg,Apdi,Aipi,Immd,PC8r,PC16] - -% floating point co processor -1111 0010 00ss sSSS:200:-----:-----:--:11: FPP #1,s -1111 0010 01ss sSSS:200:-----:-----:-B:11: FDBcc #1,s[Areg-Dreg] -1111 0010 01ss sSSS:200:-----:-----:--:11: FScc #1,s[!Areg,Immd,PC8r,PC16] -1111 0010 0111 1010:200:-----:-----:T-:10: FTRAPcc #1 -1111 0010 0111 1011:200:-----:-----:T-:10: FTRAPcc #2 -1111 0010 0111 1100:200:-----:-----:T-:00: FTRAPcc -1111 0010 10KK KKKK:200:-----:-----:-B:11: FBcc #K,#1 -1111 0010 11KK KKKK:200:-----:-----:-B:11: FBcc #K,#2 -1111 0011 00ss sSSS:202:-----:-----:--:20: FSAVE s[!Dreg,Areg,Aipi,Immd,PC8r,PC16] -1111 0011 01ss sSSS:202:-----:-----:--:10: FRESTORE s[!Dreg,Areg,Apdi,Immd] - -% 68030 MMU (allowed addressing modes not checked!) -1111 0000 00ss sSSS:342:?????:?????:T-:11: MMUOP030 s[Dreg,Areg,Apdi,Aipi,Aind,Ad16,Ad8r,absl,absw],#1 - -% 68040/68060 instructions -1111 0100 pp00 1rrr:402:-----:-----:T-:02: CINVL #p,Ar -1111 0100 pp01 0rrr:402:-----:-----:T-:02: CINVP #p,Ar -1111 0100 pp01 1rrr:402:-----:-----:T-:00: CINVA #p -1111 0100 pp10 1rrr:402:-----:-----:T-:02: CPUSHL #p,Ar -1111 0100 pp11 0rrr:402:-----:-----:T-:02: CPUSHP #p,Ar -1111 0100 pp11 1rrr:402:-----:-----:T-:00: CPUSHA #p -1111 0101 0000 0rrr:402:-----:-----:T-:00: PFLUSHN Ara -1111 0101 0000 1rrr:402:-----:-----:T-:00: PFLUSH Ara -1111 0101 0001 0rrr:402:-----:-----:T-:00: PFLUSHAN Ara -1111 0101 0001 1rrr:402:-----:-----:T-:00: PFLUSHA Ara -% 68040 only -1111 0101 0100 1rrr:452:-----:-----:T-:00: PTESTW Ara -1111 0101 0110 1rrr:452:-----:-----:T-:00: PTESTR Ara - -% destination register number is encoded in the following word -1111 0110 0010 0rrr:400:-----:-----:--:12: MOVE16 ArP,AxP -1111 0110 00ss sSSS:400:-----:-----:--:12: MOVE16 s[Dreg-Aipi],Al -1111 0110 00dd dDDD:400:-----:-----:--:12: MOVE16 Al,d[Areg-Aipi] -1111 0110 00ss sSSS:400:-----:-----:--:12: MOVE16 s[Aind],Al -1111 0110 00dd dDDD:400:-----:-----:--:12: MOVE16 Al,d[Aipi-Aind] - -% 68060 -1111 1000 0000 0000:502:?????:?????:T-:10: LPSTOP #1 -1111 0101 1000 1rrr:502:-----:-----:T-:00: PLPAW Ara -1111 0101 1100 1rrr:502:-----:-----:T-:00: PLPAR Ara - diff --git a/src/traps.cpp b/src/traps.cpp index df400311..99a9c330 100644 --- a/src/traps.cpp +++ b/src/traps.cpp @@ -9,17 +9,16 @@ * Copyright 1995, 1996 Bernd Schmidt * Copyright 1996 Ed Hanway */ +#include +#include -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" #include "include/memory.h" -#include "custom.h" #include "newcpu.h" #include "threaddep/thread.h" #include "autoconf.h" -#include "traps.h" #include "uae.h" /* diff --git a/src/uaelib.cpp b/src/uaelib.cpp old mode 100755 new mode 100644 index 78fc5650..c2ebcd56 --- a/src/uaelib.cpp +++ b/src/uaelib.cpp @@ -8,20 +8,13 @@ * Change UAE parameters and other stuff from inside the emulation. */ -#include "sysconfig.h" #include "sysdeps.h" -#include -#include - #include "options.h" #include "uae.h" #include "memory.h" -#include "custom.h" -#include "newcpu.h" -#include "xwin.h" +//#include "newcpu.h" #include "autoconf.h" -#include "traps.h" #include "disk.h" #include "gensound.h" #include "picasso96.h" diff --git a/src/uaeresource.cpp b/src/uaeresource.cpp index fa428a63..4ac6efa1 100644 --- a/src/uaeresource.cpp +++ b/src/uaeresource.cpp @@ -5,17 +5,12 @@ * */ -#include "sysconfig.h" #include "sysdeps.h" #include "options.h" #include "include/memory.h" -#include "custom.h" -#include "newcpu.h" -#include "traps.h" #include "autoconf.h" #include "execlib.h" -#include "uaeresource.h" static uaecptr res_init, res_name, res_id, base; diff --git a/src/zfile.cpp b/src/zfile.cpp index a210cc66..49a9d92c 100644 --- a/src/zfile.cpp +++ b/src/zfile.cpp @@ -9,20 +9,26 @@ #define RECURSIVE_ARCHIVES 1 -#include "sysconfig.h" +#include +#include +#include +#include +#include +#include +#include + + #include "sysdeps.h" #include "options.h" #include "zfile.h" #include "disk.h" -#include "gui.h" #include "crc32.h" #include "fsdb.h" #include "fsusage.h" #include "zarchive.h" #include "diskutil.h" #include "fdi2raw.h" -#include "uae/io.h" #include "uae.h" #include "archivers/zip/unzip.h" @@ -547,7 +553,6 @@ end: return NULL; } -#include "fdi2raw.h" static struct zfile *fdi (struct zfile *z, int index, int *retcode) { int i, j, r; diff --git a/src/zfile_archive.cpp b/src/zfile_archive.cpp index bbbb3ac1..8fe79216 100644 --- a/src/zfile_archive.cpp +++ b/src/zfile_archive.cpp @@ -5,8 +5,11 @@ * * 2007 Toni Wilen */ +#include +#include +#include +#include -#include "sysconfig.h" #include "sysdeps.h" #ifdef _WIN32_ @@ -14,16 +17,11 @@ #include "win32.h" #endif -#include "options.h" #include "zfile.h" #include "archivers/zip/unzip.h" -#include "archivers/dms/pfile.h" -#include "crc32.h" #include "zarchive.h" #include "disk.h" -#include - #define unpack_log write_log #undef unpack_log #define unpack_log(fmt, ...)